[osg-users] Can i use MatrixTransform to transform a HUD node?

Chen Gao gaochen010 at sina.com
Mon Jan 7 03:48:56 PST 2019


Thank you Terry! 

     So you mean that if i want to move or scale these hud nodes on the main screen, i have to use the camera's setviewmatrix method to do this? Add the hud nodes to a new MT and use the Mt transform methods won't work,right?

     The node structure instruction is like the following:

      1. Root->hud node->Mt node->geode node->geometries;

      2. Root->Mt node-> hud node->geode node->geometries;

    So the first one will work and the second won't,right?  
        


Terry Welsh wrote:
> I have made plenty of HUD classes derived from osg::Camera. It's easy
> to set it up as an orthographic or perspective projection, depending
> on what look you're going for. Then I compute some simple coordinates
> for the screen corners like this:
> 
> mHUDLRBT[0] = -mAspectRatio;
> mHUDLRBT[1] = mAspectRatio;
> mHUDLRBT[2] = -1.0f;
> mHUDLRBT[3] = 1.0f;
> if(mAspectRatio < 1.0f){
> mHUDLRBT[0] = -1.0f;
> mHUDLRBT[1] = 1.0f;
> mHUDLRBT[2] = -1.0f / mAspectRatio;
> mHUDLRBT[3] = 1.0f / mAspectRatio;
> }
> 
> All your HUD nodes (such as osgText::Text or something derived from
> MatrixTransform) can be positioned relative to those screen corners.
> Every time you resize your window you should call your HUD nodes
> positioning method.
> - Terry
> 


------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=75398#75398







More information about the osg-users mailing list