I have some objects in my scene created like so:

static osg::ref_ptr<osgDB::ReaderWriter::Options> options = new osgDB::ReaderWriter::Options;
  options->setObjectCacheHint(osgDB::ReaderWriter::Options::CACHE_ALL);
  std::string modFname=getModelFilename();
osg::ref_ptr<osg::Node> node = osgDB::readNodeFile(modFname.c_str(), options.get());

osg::ref_ptr<osg::PositionAttitudeTransform> trans = new osg::PositionAttitudeTransform;
  trans->addChild(node.get());

  myNode = trans.get();

  osgRoot->addChild(myNode);

==========================================
I then move my object by setting the position via the PositionAttituteTransform:

    osg::PositionAttitudeTransform* trans = nodes[i];
    pos = trans->getPosition();
    pos += delta;
    trans->setPosition(pos);

I also rotate the object:

    osg::PositionAttitudeTransform* trans = nodes[i];

    const osg::Quat q = trans->getAttitude();
    osg::Quat q2;
    osg::Matrixd matrix;
    osg::Matrixd result;
    q.get(matrix);
osg::Matrixd multiplicand(cos(rad), -sin(rad), 0, 0, sin(rad), cos(rad), 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);

    result.mult(matrix, multiplicand);
    q2.set(result);
    trans->setAttitude(q2);

==========================================================
Later on I want to transform another piece of geometry in the same way as my node. How do I do this? See trans.????() below.

osg::Vec3d min(11.942,0.839105,-36.1137);
osg::Vec3d max(101.942,40.8391,-18.9462);

osg::PositionAttitudeTransform* trans = dynamic_cast<osg::PositionAttituteTransform*>(myNode);
osg::Vec3d transformed_min(trans.????(min));
osg::Vec3d transformed_max(trans.????(max));

Thanks,
James
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to