【发布时间】:2013-01-15 08:24:15
【问题描述】:
首先我要为我的英语道歉。
我正在开发一个应用程序,我们必须在每个时刻都知道每个节点的属性(位置、旋转...),所以我考虑从场景图中获取每个节点的变换矩阵。
我的问题是我不知道该怎么做。例如,如果我有类似的东西:
osg::ref_ptr<osg::Node> root = osgDB::readNodeFile("cessna.osg.15,20,25.trans.180,90,360.rot.2,3,4.scale");
我想从名为 root 的 Node 对象中获取变换矩阵。我发现了类似的东西:
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;
但我只想拥有矩阵,可以吗?
谢谢。
PD:我正在使用 nodeVisitor 来执行此操作。
【问题讨论】:
标签: c++ openscenegraph