Re: [Plib-users] odd text question
Brought to you by:
sjbaker
From: Steve B. <sjb...@ai...> - 2000-02-20 22:30:57
|
Sylvan Clebsch wrote: > > i have an odd text usage question that i'm hoping someone might be able > to help me with. what i'd like to do is have text labels on objects in > the scene, indicating information about that object. > > my first pass at this was to use gluProject to derive the window > coordinates, and then render text with fntRenderer and an orthographic > projection matrix. the result was perfect in all but one way: i don't > want labels to appear for objects which are behind other objects. in > other words, i'd very much like to be able to render the text at the > same depth as the object, so that it gets obscured by closer objects in > the scene graph. > > hack as i might (including writing my own text renderer), i found no way > to match up the depth buffer. No - that would be almost impossible. There isn't a good way to relate what an 'orthographic Z' would be to the corresponding 'perspective Z'... and it might even be implementation dependent. > i tried finding the z distance from the > camera to the object, drawing the text with that z distance and not > clearing the depth buffer and such, but it seems that once i switch to > the orthographic projection matrix, i can't get anything i draw to be > obscured by anything else drawn in the frame. Yep - exactly. > i then tried rendering the text as 3d text, rotating it to face the > camera and scaling it based on the inverse of the distance in order to > get it to maintain a uniform size. That seems like by far the best idea. > this works, but of course perspective > text simply isn't orthographic text; it changes size noticeably from the > center of the viewport to the edge of the viewport. Hmmmm - are you using the SLANT range (ie using Pythagoras) or the simple Z distance (ie measured at right angles to the plane of the screen)? It seems to me that you should be using the latter - and you are using the former - which would account for the problem. > if anyone has any ideas, even if it means not using fntRenderer or > extending it drastically, i'd very much appreciate it. thanks. Well, the FNT library draws text in the 3D position and point size you tell it to - it knows nothing about ortho, perspective or anything else. Hence FNT should work perfectly once you've figured out what to do with all the matrices! No matter what is the final solution, FNT should be useful to you. -- Steve Baker http://web2.airmail.net/sjbaker1 sjb...@ai... (home) http://www.woodsoup.org/~sbaker sj...@ht... (work) |