First af all i have to apologize for my english.
I'm working on an application where we have to know at each moment the attributes of each node (position, rotation...), so I thought about taking from the scene graph the transformation matrix of each node.
Te problem I have is that i don't know how to do this. For example, if I have something like:
osg::ref_ptr<osg::Node> root = osgDB::readNodeFile("cessna.osg.15,20,25.trans.180,90,360.rot.2,3,4.scale");
I want to take the transform matrix from the Node object called root. I have found something like:
osg::Matrix mat = osg::computeWorldToLocal(this->getNodePath());
std::cout << "X: " << mat.getTrans().x() << std::endl;
std::cout << "Rot X: " << mat.getRotate().x() << std::endl;
std::cout << "Scale X: " << mat.getScale().x() << std::endl;
But I would like just to have only the matrix, is it possible?
Thank you.
PD: I'm using nodeVisitor for doing this.
I think you want to just print the matrix to the console. In that case, use the stream operator provided in <osg/io_utils>
:
#include <osg/io_utils>
std:: cout << mat;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With