问题源头
tankOneGroup = dynamic_cast<osg::Group*>
(osgDB::readNodeFile("C:\\Users\\tony\\source\\repos\\RobottakeAndput\\RobottakeAndput\\t72-tank_des.flt"));
tankTwoGroup = dynamic_cast<osg::Group*>
(osgDB::readNodeFile("C:\\Users\\tony\\source\\repos\\RobottakeAndput\\RobottakeAndput\\t72-tank_des.flt"));
tankThreeGroup = dynamic_cast<osg::Group*>
(osgDB::readNodeFile("C:\\Users\\tony\\source\\repos\\RobottakeAndput\\RobottakeAndput\\t72-tank_des.flt"));
问题:当为tankOneGroup添加text1时(通过添加子类Geode,Geode再与Text关联),text1会自动添加至tankTwoGroup 和tankThreeGroup。
解决办法
tankOneGroup = dynamic_cast<osg::Group*>
(osgDB::readNodeFile("C:\\Users\\tony\\source\\repos\\RobottakeAndput\\RobottakeAndput\\t72-tank_des.flt"));
tankTwoGroup = dynamic_cast<osg::Group*>
(osgDB::readNodeFile("C:\\Users\\tony\\Desktop\\t72-tank_des.flt"));
tankThreeGroup = dynamic_cast<osg::Group*>
(osgDB::readNodeFile("C:\\迅雷下载\\t72-tank_des.flt"));
只好把坦克模型的文件放置于三个不同路径下。
前后效果对比
- before

- after

本文解决了在使用相同3D模型文件时,修改一个模型意外影响其他模型的问题。通过将模型文件放置在不同路径下,确保了各模型独立,避免了相互干扰。
802

被折叠的 条评论
为什么被折叠?



