Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Placing a text above an object

Author
Message
Drowneath
15
Years of Service
User Offline
Joined: 22nd Jun 2009
Location: In your eyes
Posted: 22nd Jul 2009 13:37 Edited at: 22nd Jul 2009 13:47
Hello there,

I'm trying to put a text above a picked object (by the mouse), but I really have no idea about the Y positioning.

Here's my try:


my code:


the GetLowIndexRange and GetHighIndexRange returns the lowest and the highest object ID to be checked by the dbPickObject.


Any idea on placing the text?
jezza
16
Years of Service
User Offline
Joined: 8th Mar 2008
Location: Bham, UK
Posted: 22nd Jul 2009 14:25
if you want it directly above cursor, try something like dbText(dbMouseX()-25, dbMouseY() - 100, "Zombie");
if you want it above the object, so when the mouse moves over object, text doesn't, there are functions for getting an object's screen position. something like dbObjectScreenX()

Drowneath
15
Years of Service
User Offline
Joined: 22nd Jun 2009
Location: In your eyes
Posted: 22nd Jul 2009 16:07 Edited at: 22nd Jul 2009 16:13
Thanks jezza for telling me that function.

It's a bit better now. But I need it to appear above the object, not below.



Is it possible to calculate the height of the object as shown in the screen (not actual height) as the replacement for dbObjectSizeY(PickedObject)? or is there any built-in function to do so?

Because I have camera zoom feature (and movable character) in this game. So it can't be done just by deducting the text's Y position using a fixed number.


Thanks.
randal
15
Years of Service
User Offline
Joined: 18th Nov 2008
Location:
Posted: 22nd Jul 2009 16:21
try changing to this:

jezza
16
Years of Service
User Offline
Joined: 8th Mar 2008
Location: Bham, UK
Posted: 22nd Jul 2009 17:21
It's possible but seems overkill. There is, AFAIK, no function to do it.
What one could do is take two boxes positioned at the top and bottom of the object and hide these but use dbObjectScreenY with them, then take the lowest from the highest.
Or you could create two points as D3DXVECTOR3 at the top and bottom of the object as it would be if the origin of the object is 0,0,0. Then transform both of these by the World matrix for the object and the view and projection matrices for the camera. This can all be done using the hidden command in the DarkGDK headers.

Login to post a reply

Server time is: 2024-10-01 08:50:59
Your offset time is: 2024-10-01 08:50:59