About Store Forum Documentation Contact



Post Reply 
Text behind objects
Author Message
Brainache Offline
Member

Post: #1
Text behind objects
Heyas...

When using the various 2D drawing funcions and D.Text, how can you have them use z-order to prevent drawing while behind objects?

example: drawing a name of a chr... and if the chr is behind a building.. dont draw the name ( or only part of the name that is visible )...

Thanks!
11-08-2011 01:12 PM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #2
RE: Text behind objects
Code:
D.textDepth(true, depth);
D.text(..);
11-08-2011 09:12 PM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #3
RE: Text behind objects
Never used it before, so I just tested it out real quickly. Assuming you're doing a RPG with a third-person camera, seems like Cam.dist is what you would want to use.

Or, to be more accurate since Cam.dist is the distance to Cam.at, not the distance to the text's position, you could do this:

Code:
Vec  textPos = ..; // desired position of text
Vec2 screen;

if (PosToScreen(textPos, screen))
{
   D.textDepth(true, Dist(Cam.matrix.pos, textPos));
   D.text(screen, "Hello world!");
   D.textDepth(false);
}

Setting the depth to 1 means that any mesh closer than 1 unit away will block the text. Depth is essentially the distance from the camera to the text position.
11-09-2011 04:16 AM
Find all posts by this user Quote this message in a reply
Post Reply