}boolAutoTransform::computeLocalToWorldMatrix(Matrix& matrix,NodeVisitor*)const{if(_matrixDirty) computeMatrix();if(_referenceFrame==RELATIVE_RF) { matrix.preMult(_cachedMatrix); }else//absolute{ matrix=_cachedMatrix; }returntrue; } 第二种实现 osg::AutoTransform节点位置坐标设置为(200,0,0),此方...
而_pivotPoint指定了变换轴,最终把节点移动到变换轴处。 关于RELATIVE_RF和ABSOLUTE_RF我们前面的例子介绍过。 我们回到例子中: createRoom函数中创建了一个正方体,里面有个 osg::PositionAttitudeTransform* pat = new osg::PositionAttitudeTransform(); pat添加了ModelTransformCallback根据仿真时间重新计算姿态。 pat-...
缺省情况下,参考系是相对的 ( osg::Transform::RELATIVE_RF ),因此也就有了前述的级联特性。 列如: osg::ref_ptr<osg::MatrixTransform> mt = new osg::MatrixTransform; mt->setReferenceFrame( osg::Transform::ABSOLUTE_RF ); MatrixTransform(矩阵变换节点) MatrixTransform 的内部使用了 osg::Matrix 对...
RELATIVE_RF, //全局 相对 () ABSOLUTE_RF, //局部 绝对 () ABSOLUTE_RF_INHERIT_VIEWPOINT //基于视点一个局部坐标系.很少用到. MatrixTransform 故名 矩阵变换节点.在位于它的节点之下的节点都将按照这它的矩阵变换来进行模型变换操作.因此 MatrixTransform的主要功能之一就是提供模型变换操作..你只要根据你所...
你只需牢记 在OSG当中变换的步骤则是左乘操作(全局坐标系)..即左边的是先执行变换的. 谈完如上的那些之后.我们现在来看MatrixTransform 和PositionAttitudeTransform. 参考坐标系有三种 RELATIVE_RF, //全局 相对 () ABSOLUTE_RF, //局部 绝对 () ABSOLUTE_RF_INHERIT_VIEWPOINT //基于视点一个局部坐标系.很少用...
if (transform.getReferenceFrame() != osg::Transform::RELATIVE_RF) { popViewMatrix(); } // tidy up an cached cull variables in the current intersector. leave(); } void IntersectionVisitor::apply(osg::Projection& projection) { if (!enter(projection)) return; ...
*/ #include <osg/Group> #include <osg/BoundingBox> #include <osg/Transform> #include <osg/OccluderNode> #include <osg/Geometry> #include <osg/Notify> #include <stdio.h> #include <math.h> #include <algorithm> using namespace osg; ...
void setReferenceFrame(ReferenceFrame rf) // 设置帧引用 帧引用有两个枚举变量: RELATIVE_RF(相对帧引用), ABSOLUTE_RF(绝对帧引用) 推荐在场景的顶部使用绝对的光源 法线的重缩放, 可以改善光照结果的明亮 osg::StateSet* state = geode->getOrCreateStateSet(); state->setMode(GL_RESCALE_NORMAL, osg...
camera->setReferenceFrame(osg::Transform::RELATIVE_RF); camera->setViewMatrix(osg::Matrix::translate(-2, 0, 0)); osg::MatrixTransform* xform = new osg::MatrixTransform(osg::Matrix::translate(1, 1, 1)); xform->addChild(camera); ...
=_children.end(); ++itr) { osg::Node* child = itr->get(); const osg::Transform* transform = child->asTransform(); if (!transform || transform->getReferenceFrame()==osg::Transform::RELATIVE_RF) { osg::Drawable* drawable = child->asDrawable(); if (drawable) { bb.expandBy(...