[SOLVED] Text at a bone of a VIew-Entity / problem

Posted By: sebbi91

[SOLVED] Text at a bone of a VIew-Entity / problem - 06/07/12 14:17

Hi guys,

I have a problem to set the position of a Text to a bone of a View-Entity.

Here is a Code-Snippet of my try to make it work.

Quote:

//The View-Entity
ENTITY* user_menu=
{
type = "user_menu.mdl";
layer=2;
flags = SHOW|LIGHT|SHADOW;
flags2 =VISIBLE;
}

//Give View-Entitys a position
void activate_panels_startup()
{
user_menu.x=100; // deep
user_menu.y=-50; // X_screen
user_menu.z=15; // Y_screen
...
}


//my Text
TEXT* txt_build =
{
font=main_txt;
layer = 5;
string (user_menue_build);
flags = TRANSLUCENT | SHOW | ARIGHT;
}

//my programm to set the Position
void activate_Textes_startup()
{
VECTOR text_pos1;
vec_for_bone(text_pos1,user_menu,"Bone1");
vec_to_screen (text_pos1,camera1);

txt_build.pos_x=text_pos1.x;
txt_build.pos_y=text_pos1.y;
}




The Text appears but not at the Bone Position.

Any Idea?

Sorry if this is too easy and also sorry for my english^^.

Have a nice day.

best regards
Sebb

Posted By: Locoweed

Re: Text at a bone of a VIew-Entity / problem - 06/07/12 15:42

It looks ok. you might show where you set camera1 to be the current view. Don't see that in the code.

You can also try:

if(vec_to_screen (text_pos1,camera1) != NULL)
{
txt_build.pos_x=text_pos1.x;
txt_build.pos_y=text_pos1.y;
}
else
{
while(1)
{
draw_text("Position was not on screen",0,0,vector(225,0,0));
wait(1);
}
}

Or something like that to make sure that the vec_for_screen() position is actually even on the screen area.

You might also take out the ARIGHT flag and test without that.

Loco
Posted By: sebbi91

Re: Text at a bone of a VIew-Entity / problem - 06/07/12 16:29

Hmm I tryied it but it doesn't work.
the "Error-message" doesnt apear so it seems there is another mistake in my code.

But also thanks for your try.

I'll Post the whole camera code now:
Maybe is there the reason.
Quote:

//splitted views
VIEW* camera1= //camera player1
{
layer=15;
arc=110;
}
VIEW* camera2= //camera player2
{
layer=15;
arc=110;
}

//Set the camera positions
void camera_and_HUD_startup()
{
while(1)
{

reset(camera0,SHOW);
set(camera1,SHOW);
set(camera2,SHOW);

camera1.pos_x=0;
camera1.pos_y=0;
camera1.size_x=screen_size.x;
camera1.size_y=screen_size.y/2;
camera2.pos_x=0;
camera2.pos_y=screen_size.y/2;
camera2.size_x=screen_size.x;
camera2.size_y=screen_size.y/2;

...
wait(1)
}
}




//The View-Entity
ENTITY* user_menu=
{
type = "user_menu.mdl";
layer=2;
flags = SHOW|LIGHT|SHADOW;
flags2 =VISIBLE;
}

//Give View-Entitys a position
void activate_panels_startup()
{
user_menu.x=100; // deep
user_menu.y=-50; // X_screen
user_menu.z=15; // Y_screen
...
}


//my Text
TEXT* txt_build =
{
font=main_txt;
layer = 5;
string (user_menue_build);
flags = TRANSLUCENT | SHOW | ARIGHT;
}

//my programm to set the Position
void activate_Textes_startup()
{
VECTOR text_pos1;
vec_for_bone(text_pos1,user_menu,"Bone1");
vec_to_screen (text_pos1,camera1);


if(vec_to_screen (text_pos1,camera1) != NULL)
{
txt_build.pos_x=text_pos1.x;
txt_build.pos_y=text_pos1.y;
}
else
{
while(1)
{
draw_text("Position was not on screen",0,0,vector(225,0,0));
wait(1);
}
}

}


Thanks anyway
Posted By: MasterQ32

Re: Text at a bone of a VIew-Entity / problem - 06/07/12 17:24

simply use rel_for_screen instead of vec_for_screen if it's a view entity
Posted By: sebbi91

Re: Text at a bone of a VIew-Entity / problem - 06/08/12 15:02

thx for your reply but it doesnt work.
The text is in the top left corner now.

Maybe I did something wrong.
Here is my modified code.
I marked the Vector Funktions.
I think there is a misstake in it.
Quote:

void activate_Textes_startup()
{
while(1)
{

VECTOR text_pos1;
vec_for_bone(text_pos1,user_menu,"build");
rel_for_screen(text_pos1,camera1);

txt_build.pos_x=text_pos1.x;
txt_build.pos_y=text_pos1.y;

wait(1);
}
}


thanks anyway.
Have a nice day.
Posted By: sebbi91

Re: Text at a bone of a VIew-Entity / problem - 06/10/12 09:48

Please is there anyone, who can helps me?
I really need this stuff working to work on my project.

Thanks in andvance.
Posted By: MasterQ32

Re: Text at a bone of a VIew-Entity / problem - 06/10/12 11:01

oh i'm sorry grin
try rel_to_screen if it's a view entity or vec_to_screen if it's a world entity
wrong direction, you converted from screen pos to world position
Posted By: sebbi91

Re: Text at a bone of a VIew-Entity / problem - 06/10/12 11:44

Thanks for the try, but now the Text is out of the screen.
hmmmm.....

I tryied some stuff to handle it, but it doesnt work.

I uploaded a Bughuntingfile.

"Download"

If you could give it a try, I would be very happy.
Thanks anyway,

best regards
sebb
Posted By: Ch40zzC0d3r

Re: Text at a bone of a VIew-Entity / problem - 06/10/12 11:47

vec_to_screen converts your 3d vector (ak your bone) into a 2d, screen coordinate.
Just draw_text on this position and be happy laugh
Posted By: sebbi91

Re: Text at a bone of a VIew-Entity / problem - 06/10/12 14:54

Thanks for your help.
Now it works perfectly.

For everyone who need this too.
The misstake was there:
Quote:

void activate_Textes_startup()
{
while(1)
{
VECTOR text_pos1;

vec_for_bone(text_pos1,user_menu,"build");
vec_to_screen (text_pos1.x,camera1);
wait(1);
}
}


it has to be:

Quote:

void activate_Textes_startup()
{
while(1)
{
VECTOR text_pos1;

vec_for_bone(text_pos1,user_menu,"build");
vec_to_screen (text_pos1.x,camera);
wait(1);
}
}


It seems, that this only works with the regular camera.
An you have to remove the
Quote:
reset(camera,SHOW|AUDIBLE);

in the main-function.


Thank you all.
Have nice Evening.

best regards Sebb
© 2024 lite-C Forums