Re: Keeping an object's label on the screen

"Monteleone, Nathan" <[email protected]>
Newsgroups gmane.games.devel.algorithms
Message-ID <[email protected]>
Ok thanks.  Using the bounding box like that seems a lot faster than
trying to analyze an ID buffer.

Not worried about overlapping for now :)

-----Original Message-----
From: Jon Watte [mailto:[email protected]] 
Sent: Wednesday, April 29, 2009 1:56 PM
To: Game Development Algorithms
Subject: Re: [Algorithms] Keeping an object's label on the screen

Monteleone, Nathan wrote:
>
> What's a good algorithm to figure out where to draw the label?
>

In general, this is easy, by projecting the desired location to screen 
space. However, you can get into situations where a corner is visible on

the screen, but the center of the object is behind the camera, which may

lead to poorly behaved labels.

Just project the corners of the bounding box of the object to screen 
space; take the average of the corners that are in front of the camera, 
and project that to screen space. Form the rectangle around that, and 
clamp that rectangle to screen space to force it onto the screen.

If you also want multiple labels to sort themselves out without 
overlapping, it gets slightly more twisty.

Sincerely,

jw


------------------------------------------------------------------------
------
Register Now & Save for Velocity, the Web Performance & Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance & Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
_______________________________________________
GDAlgorithms-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list
Archives:
http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithms-lis
t

------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance & Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
_______________________________________________
GDAlgorithms-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list
Archives:
http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithms-list
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.