[osg-users] Correct way to set auto scale with osg::AutoTransform

295 views
Skip to first unread message

Victoria Rudakova

unread,
Mar 17, 2016, 2:02:25 PM3/17/16
to OpenSceneGraph Users
Dear OSG community,

I am trying to set auto scale property of osg::AutoTransform variable. I would like to achieve such an effect that whatever the viewing camera position and its distance from a certain geometry, the geometry's size would not change.

As an example geometry, I have this pyramid:

Inline image 1

I found an example "osgautotransform"
http://trac.openscenegraph.org/projects/osg//browser/OpenSceneGraph/trunk/examples/osgautotransform/osgautotransform.cpp

that seem to have an element of what I need. I tried to use the same commands, for example:

osg
::AutoTransform* at = new osg::AutoTransform;
at->addChild(geode); // geode constains my pyramid geometry and color
at->setAutoScaleToScreen(true);
at->setMinimumScale(1); // some test values
at->setMaximumScale(2);

// to render the scene:
root->addChild(at); // root is osg::Group
viewer->setSceneData(root);

However, it did not produce any changes in how the scene is rendered when I change the camera view (i.e., the pyramid becomes smaller when camera zooms out and bigger when zooms in). I tried the command that sets up auto rotate mode and it works to fix the rotation. So how come I cannot control the scale?

Could anyone point out what am I doing wrong or what is missing here? Thank you!

Regards,
Victoria
Reply all
Reply to author
Forward
0 new messages