Hi everyone ^^
I have a question.
I would like to update the position of an object with PositionAttitudeTransform. I get different values that I then pass to the matrix of my object. It works when the program is launched but after I change the values they are well recovered but when I try to give them to the matrix nothing happens. Do you have a solution??
the function of the callback for the update :
class DepthCullBack : public osg::NodeCallback{
public:
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv) {
if (nv->getVisitorType() == osg::NodeVisitor::CULL_VISITOR ||
nv->getVisitorType() == osg::NodeVisitor::TRAVERSE_ACTIVE_CHILDREN ||
nv->getVisitorType() == osg::NodeVisitor::TRAVERSE_ALL_CHILDREN
)
{
osgUtil::CullVisitor* cv = static_cast<osgUtil::CullVisitor*>(nv);
// update position
osg::PositionAttitudeTransform* posM = static_cast<osg::PositionAttitudeTransform*>(node);
posM->setPosition(osg::Vec3f(0.0f, 0.f,m_pPriGroup->m_dDepth));
}
traverse(node, nv);
}
private:
PRIGroup* m_pPriGroup;
};
the function update (loadIslands is the function who create my object) :
osg::Node* PRIGroup::updateScene(int nTypeClass,osg::Group* pGroup)
{
osg::ref_ptr<osg::Node> islandModel = new osg::Node;
FindNamedNodeVisitor fnnv("_oceanScene");
osg::ref_ptr<osg::PositionAttitudeTransform> positionMatrix = new osg::PositionAttitudeTransform;
positionMatrix->setDataVariance(osg::Object::DYNAMIC);
switch (nTypeClass)
{
case CGeneric::SHAPE_SEA:
m_pMainScene->loadIslands("terrain_lispsm")->setCullCallback(new DepthCullBack);
pGroup->accept(fnnv);
if (!fnnv._foundNodes.empty())
{
//pGroup->addChild(positionMatrix);
m_pMainScene->changeScene(CMainScene::CLEAR);
}
else
{
m_pMainScene->changeScene(CMainScene::DUSK);
}
return pGroup;
break;
default:
break;
}
}
thank you in advance ^^