OpenSceneGraph控制模型
转自:http://www.cppblog.com/eryar/archive/2012/05/28/176538.html
一、简介
对模型的控制就是修改模型的位置和方向属性,使模型的位置和方向发生改变,通常通过移动、旋转、缩放来实现。在三维CAD软件中通常要对模型的位置进行修改,如装配模型时把其中一个零件模型移动一个位置。由计算机图形学知识得三维图形的几何变换可用一个四阶齐次矩阵来表示,即模型的几何变换都是对矩阵进行操作。
二、OSG模型控制
在OSG中,加入模型的默认位置是屏幕中心,对模型的位置、方向控制是通过类osg::MatrixTransform来实现。由类图知,类osg::MatrixTransform继承自类osg::Transform,而类osg::Transform是由类osg::Group继承而来。
Figure 3.1 Inheritance Diagram for osg::MatrixTransform
声明类osg::MatrixTransform中的注释为:
/** MatrixTransform - is a subclass of Transform which has an osg::Matrix * which represents a 4x4 transformation of its children from local coordinates * into the Transform's parent coordinates. */