[osg-users] Can i use MatrixTransform to transform a HUD node?
Terry Welsh
mogumbo at gmail.com
Sun Jan 6 20:08:53 PST 2019
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
>
> Message: 5
> Date: Fri, 04 Jan 2019 14:47:01 +0100
> From: "Chen Gao" <gaochen010 at sina.com>
> To: osg-users at lists.openscenegraph.org
> Subject: [osg-users] Can i use MatrixTransform to transform a HUD
> node?
> Message-ID: <1546609621.m2f.75379 at forum.openscenegraph.org>
> Content-Type: text/plain; charset=UTF-8
>
> Hi,guys
>
> Well,as the subject notes,The software in my dev job has to use a HUD to show 2d pics. Generally using a camera to create a new viewport to show the pic will be OK.
>
> But the 'Entity' base class for the software system uses a MT (matrixtransform) to add the detailed entity node(such as basic geometry,text with a geode) and then add this MT node to the root by the datacontainer manager class.
>
> If I create the hud entity class derived from the base class, ie, add the camera node to the MT node,does it work if I operate the move, scale commands to this hud entity by using MT,not the camera? If it doesn't work, how can I change the node structure to make the Hud entity responsive to the transform operations which is generated by MT.Or do I only have to use the camera node itself to do these transformation jobs?
>
> Please do me a favor!Thank you,guys!
> :)
More information about the osg-users
mailing list