XYZ to screenX, screenY
Like in many games, text is above a player's head that usually has their character's name and healthbar etc. I was wondering how to take the 3d coordinates of the player and make them into screen coordinates. I'm guessing I'll have to do something with the camera, because taking just the XY from the 3d XYZ wouldn't do much good.
Could this also be used....lets say for an NPC in an MMO where they sort of "light up" when you hover over them with the mouse? I might not do that. I might have something go over to the NPC and hover over them. ex. Navi from Zelda: Orcarina of Time, she floats around nearby people when you "z-target" them. I want to do the same thing except with "mouse hovering".
Last edited by taelmx; 11-08-2006 at 12:48 PM.
Are the camera standing still or is it moving? Imagin the player sitting in front of his screen, watching the 3d point "through" the screen. Say the coordinates of the point is (X, Y, Z) according to the screen, the actual screen coordinates will then be (X/(Z+a)*a, Y/(Z+a)*a), where a is the distance from the screen the player has. If the camera isn't in origo and facing straight forward, you will have to transform the XYZ coordinates to acording-to-screen-XYZ coordinates before you can calculate the screen XY coordinates, and for that I don't have any formula. Did that answer your question?
Originally Posted by taelmx
Unproject the world coords of the object, compute the scale based on distance and render.