本来自演示了ClipNode。
主要的内容都在decorate_with_clip_node中。
Clip在OpenGL中是定义裁剪面,然后glEnable,设置使用裁剪,于是在OpenGL的固定管线中就根据指定的
裁剪面裁剪。
才以上分析我们可以指定,在OSG中Clip属于一种状态,因此,定义裁剪就是设置一个StateSet。OSG中会
根据设置了节点StateSet构建一棵状态树,这棵状态树会根据State改变当时OpenGL的状态,比如,进入A
节点,它设置了StateSet,此时,根据StateSet设置状态,离开的时候再设置回去。这就是State类中非
常有用的pushStateSet和popStateSet。
因此,ClipNode的实现就不能理解,ClipNode就是定义了裁剪面的组节点,加入到CLipNode中的子节点都
会根据指定的裁剪面裁掉。
在OSG中ClipPlane是一个裁剪面,继承StateAttribute,可以通过Plane指定空间中任意的一个裁剪面。
看看ClipNode中的createClipBox方法,根据BoundingBox定义了一个裁剪盒子,实际上是定义了六个裁剪
面。
_planes.clear();
if (!_stateset.valid()) _stateset = new osg::StateSet;
_pla
主要的内容都在decorate_with_clip_node中。
Clip在OpenGL中是定义裁剪面,然后glEnable,设置使用裁剪,于是在OpenGL的固定管线中就根据指定的
裁剪面裁剪。
才以上分析我们可以指定,在OSG中Clip属于一种状态,因此,定义裁剪就是设置一个StateSet。OSG中会
根据设置了节点StateSet构建一棵状态树,这棵状态树会根据State改变当时OpenGL的状态,比如,进入A
节点,它设置了StateSet,此时,根据StateSet设置状态,离开的时候再设置回去。这就是State类中非
常有用的pushStateSet和popStateSet。
因此,ClipNode的实现就不能理解,ClipNode就是定义了裁剪面的组节点,加入到CLipNode中的子节点都
会根据指定的裁剪面裁掉。
在OSG中ClipPlane是一个裁剪面,继承StateAttribute,可以通过Plane指定空间中任意的一个裁剪面。
看看ClipNode中的createClipBox方法,根据BoundingBox定义了一个裁剪盒子,实际上是定义了六个裁剪
面。
_planes.clear();
if (!_stateset.valid()) _stateset = new osg::StateSet;
_pla