Hi Robert,
I want to come back to my original remark that culling does not work correctly
with AutoTransforms and ROTATE_TO_SCREEN.
I have modified the example osgautotransform.cpp by adding a new class that
contains an AutoTransform and a drawable. An object of this class is added to
the scene (createScene has been extended; basically the shown code replaces the
original createScene method):
Code:
class AutoScaledBox : public osg::Node
{
public:
AutoScaledBox(void) : m_AutoTransformPtr(nullptr)
{
this->initialize();
}
AutoScaledBox(AutoScaledBox const& autoScaledRectangle, osg::CopyOp
const& copyOperator=osg::CopyOp::SHALLOW_COPY) :
osg::Node(autoScaledRectangle,copyOperator),
m_AutoTransformPtr(autoScaledRectangle.m_AutoTransformPtr)
{
}
META_Node("",AutoScaledBox)
virtual osg::BoundingSphere computeBound(void) const override
{
if (m_AutoTransformPtr)
return m_AutoTransformPtr->computeBound();
else
return osg::BoundingSphere();
}
virtual void traverse(osg::NodeVisitor& nodeVisitor) override
{
if (m_AutoTransformPtr)
m_AutoTransformPtr->accept(nodeVisitor);
}
void setPosition(osg::Vec3 const& position)
{
if (m_AutoTransformPtr)
m_AutoTransformPtr->setPosition(position);
}
protected:
void initialize(void)
{
osg::ShapeDrawable* shapeDrawablePtr(new osg::ShapeDrawable());
shapeDrawablePtr->setShape(new osg::Box(osg::Vec3(),4.0f));
m_AutoTransformPtr = new osg::AutoTransform();
m_AutoTransformPtr->addChild(shapeDrawablePtr);
m_AutoTransformPtr->setAutoRotateMode(osg::AutoTransform::ROTATE_TO_SCREEN);
m_AutoTransformPtr->setAutoScaleToScreen(true);
}
private:
osg::ref_ptr<osg::AutoTransform> m_AutoTransformPtr;
};
osg::Node* createAutoScaledBox(osg::Vec3 const& position)
{
AutoScaledBox* autoScaledRectanglePtr(new AutoScaledBox());
autoScaledRectanglePtr->setPosition(position);
return autoScaledRectanglePtr;
}
osg::Node* createScene()
{
osg::Group* root = new osg::Group;
// int numReps = 3333;
int numReps = 10;
root->addChild(createAxis(osg::Vec3(0.0,0.0,0.0),osg::Vec3(1000.0,0.0,0.0),numReps,osg::AutoTransform::ROTATE_TO_CAMERA,osgText::Text::XY_PLANE,
"ROTATE_TO_CAMERA"));
root->addChild(createAxis(osg::Vec3(0.0,0.0,0.0),osg::Vec3(0.0,1000.0,0.0),numReps,osg::AutoTransform::ROTATE_TO_SCREEN,osgText::Text::XY_PLANE,
"ROTATE_TO_SCREEN"));
root->addChild(createAxis(osg::Vec3(0.0,0.0,0.0),osg::Vec3(0.0,0.0,1000.0),numReps,osg::AutoTransform::NO_ROTATION,osgText::Text::XZ_PLANE,
"NO_ROTATION"));
root->addChild(createAutoScale(osg::Vec3(500.0,500.0,500.0), 25.0,
"AutoScale with no min, max limits"));
root->addChild(createAutoScale(osg::Vec3(500.0,500.0,300.0), 25.0,
"AutoScale with minScale = 1, maxScale = 2.0 ", 1, 2.0));
root->addChild(createAutoScale(osg::Vec3(500.0,500.0,700.0), 25.0,
"AutoScale with minScale = 0.0, maxScale = 5.0 ", 0.0, 5.0));
root->addChild(createAutoScaledBox(osg::Vec3(100.0f,100.0f,100.0f)));
return root;
}
If nothing else is modified you will see an additional small box at 100; 100;
100.
Now, I additionally set the small feature culling pixel size to a relatively
large value during the initialisation of the view:
Code:
view->getCamera()->setSmallFeatureCullingPixelSize(200.0f);
Afterwards, all the axis labels disappear (as expected) but the small box is
still visible! But from my understanding this small box should also be culled.
Zooming in and out let the labels appear and disappear but the box remains
visible all the time.
Cheers,
Hartwig
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=73207#73207
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org