当父节点stateset设置为osg::StateAttribute::OVERRIDE之后,子节点设置stateset还管用吗
时间: 2024-01-06 13:04:50 浏览: 32
当父节点的stateset设置为osg::StateAttribute::OVERRIDE时,子节点设置的stateset不再管用。因为当父节点的stateset设置为OVERRIDE时,它将覆盖所有子节点的stateset设置。此时,子节点设置的stateset将被忽略,只有父节点的stateset起作用。所以,如果你需要在子节点中设置stateset,请确保父节点的stateset没有设置为OVERRIDE。
相关问题
父节点设置了osg::StateSet,子节点没有设置osg::StateSet,子节点会默认使用父节点的osg::StateSet吗
是的,如果子节点没有设置自己的osg::StateSet,它将默认使用父节点的osg::StateSet。这是因为在场景图中,节点会继承其父节点的状态属性,如果父节点设置了osg::StateSet,但子节点没有设置,那么子节点将继承父节点的osg::StateSet。这个特性可以让我们在场景图中更加方便地组织和管理状态属性,例如我们可以在父节点中设置一些通用的状态属性,然后让子节点继承使用,这样可以避免重复设置相同的状态属性。需要注意的是,如果子节点设置了自己的osg::StateSet,那么它将不再使用父节点的osg::StateSet。
当父节点设置为state->setDataVariance(osg::Object::STATIC);,子节点设置stateset还管用吗
当父节点的setDataVariance设置为osg::Object::STATIC时,子节点设置的stateset仍然管用。因为setDataVariance方法只是告诉OSG对象该如何处理对象的数据变化,具体来说,STATIC表示该对象的数据不会改变,所以OSG可以对该对象进行一些优化,例如共享数据等。但是,这并不会影响到子节点的stateset设置,因为stateset与数据变化是没有必然联系的。所以,无论父节点的setDataVariance设置为何值,子节点的stateset设置都会被保留。
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)