Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, Nymphodora), 485 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
[SOLVED] Text at a bone of a VIew-Entity / problem #402601
06/07/12 14:17
06/07/12 14:17
Joined: Jun 2008
Posts: 402
Germany
S
sebbi91 Offline OP
Senior Member
sebbi91  Offline OP
Senior Member
S

Joined: Jun 2008
Posts: 402
Germany
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


Last edited by sebbi91; 06/10/12 14:55. Reason: solved

3D-Gamestudio A8 - Commercial
Re: Text at a bone of a VIew-Entity / problem [Re: sebbi91] #402607
06/07/12 15:42
06/07/12 15:42
Joined: Oct 2002
Posts: 2,256
Oz
L
Locoweed Offline
Expert
Locoweed  Offline
Expert
L

Joined: Oct 2002
Posts: 2,256
Oz
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


Professional A8.30
Spoils of War - East Coast Games
Re: Text at a bone of a VIew-Entity / problem [Re: Locoweed] #402612
06/07/12 16:29
06/07/12 16:29
Joined: Jun 2008
Posts: 402
Germany
S
sebbi91 Offline OP
Senior Member
sebbi91  Offline OP
Senior Member
S

Joined: Jun 2008
Posts: 402
Germany
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


3D-Gamestudio A8 - Commercial
Re: Text at a bone of a VIew-Entity / problem [Re: sebbi91] #402620
06/07/12 17:24
06/07/12 17:24
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
simply use rel_for_screen instead of vec_for_screen if it's a view entity


Visit my site: www.masterq32.de
Re: Text at a bone of a VIew-Entity / problem [Re: MasterQ32] #402653
06/08/12 15:02
06/08/12 15:02
Joined: Jun 2008
Posts: 402
Germany
S
sebbi91 Offline OP
Senior Member
sebbi91  Offline OP
Senior Member
S

Joined: Jun 2008
Posts: 402
Germany
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.


3D-Gamestudio A8 - Commercial
Re: Text at a bone of a VIew-Entity / problem [Re: sebbi91] #402771
06/10/12 09:48
06/10/12 09:48
Joined: Jun 2008
Posts: 402
Germany
S
sebbi91 Offline OP
Senior Member
sebbi91  Offline OP
Senior Member
S

Joined: Jun 2008
Posts: 402
Germany
Please is there anyone, who can helps me?
I really need this stuff working to work on my project.

Thanks in andvance.


3D-Gamestudio A8 - Commercial
Re: Text at a bone of a VIew-Entity / problem [Re: sebbi91] #402776
06/10/12 11:01
06/10/12 11:01
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
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


Visit my site: www.masterq32.de
Re: Text at a bone of a VIew-Entity / problem [Re: MasterQ32] #402779
06/10/12 11:44
06/10/12 11:44
Joined: Jun 2008
Posts: 402
Germany
S
sebbi91 Offline OP
Senior Member
sebbi91  Offline OP
Senior Member
S

Joined: Jun 2008
Posts: 402
Germany
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


3D-Gamestudio A8 - Commercial
Re: Text at a bone of a VIew-Entity / problem [Re: sebbi91] #402780
06/10/12 11:47
06/10/12 11:47
Joined: Oct 2011
Posts: 1,082
Germany
C
Ch40zzC0d3r Offline
Serious User
Ch40zzC0d3r  Offline
Serious User
C

Joined: Oct 2011
Posts: 1,082
Germany
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

Re: Text at a bone of a VIew-Entity / problem [Re: Ch40zzC0d3r] #402813
06/10/12 14:54
06/10/12 14:54
Joined: Jun 2008
Posts: 402
Germany
S
sebbi91 Offline OP
Senior Member
sebbi91  Offline OP
Senior Member
S

Joined: Jun 2008
Posts: 402
Germany
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


3D-Gamestudio A8 - Commercial

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1