}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 对...
Matrix 它是直接使用glLoadMatrix(matrix)进行载入矩阵的.因此它的转置刚好适应了OpenGL列优先的模式. 你只需牢记 在OSG当中变换的步骤则是左乘操作(全局坐标系)..即左边的是先执行变换的. 谈完如上的那些之后.我们现在来看MatrixTransform 和PositionAttitudeTransform. 参考坐标系有三种 RELATIVE_RF, //全局 相对 (...
你只需牢记 在OSG当中变换的步骤则是左乘操作(全局坐标系)..即左边的是先执行变换的. 谈完如上的那些之后.我们现在来看MatrixTransform 和PositionAttitudeTransform. 参考坐标系有三种 RELATIVE_RF, //全局 相对 () ABSOLUTE_RF, //局部 绝对 () ABSOLUTE_RF_INHERIT_VIEWPOINT //基于视点一个局部坐标系.很少用...
* This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * OpenSceneGraph Public License for more details. ...
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; ...
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); ...
void setReferenceFrame(ReferenceFrame rf) // 设置帧引用 帧引用有两个枚举变量: RELATIVE_RF(相对帧引用), ABSOLUTE_RF(绝对帧引用) 推荐在场景的顶部使用绝对的光源 法线的重缩放, 可以改善光照结果的明亮 osg::StateSet* state = geode->getOrCreateStateSet(); state->setMode(GL_RESCALE_NORMAL, osg...
=_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(...