观察osg格式文件中如何处理多个节点共享一个子节点
来源:互联网 发布:深入浅出数据分析代码 编辑:程序博客网 时间:2024/05/17 09:26
下面一段程序中,共有三个Group类型根节点:root,grp1和grp2;两个Geode类型节点:geode1和geode2。他们之间的从属关系是:grp1,grp2和geode2是root的孩子,geode1和geode2是grp1的孩子,geode2是grp2的孩子。如下图所示。
.osg格式的文件存储像geode2这个的节点时,采用'Use'这个关键词。
---------------------------------------------------------------------------------------------
.osg文件内容:
Group {
name "root"
nodeMask 0xffffffff
cullingActive TRUE
num_children 3
Group {
UniqueID Group_0
name "grp1"
nodeMask 0xffffffff
cullingActive TRUE
num_children 2
Geode {
UniqueID Geode_1
name "geode1"
nodeMask 0xffffffff
cullingActive TRUE
num_drawables 1
Geometry {
useDisplayList TRUE
useVertexBufferObjects FALSE
PrimitiveSets 1
{
DrawArrays LINE_STRIP 0 3
}
VertexArray Vec3Array 3
{
0 1 0
0 0 0
1 1 0
}
}
}
Geode {
UniqueID Geode_2
name "geode2"
nodeMask 0xffffffff
cullingActive TRUE
num_drawables 1
Geometry {
useDisplayList TRUE
useVertexBufferObjects FALSE
PrimitiveSets 1
{
DrawArrays LINE_STRIP 0 3
}
VertexArray Vec3Array 3
{
1 0 0
2 1 0
2 0 0
}
}
}
}
Group {
UniqueID Group_3
name "grp2"
nodeMask 0xffffffff
cullingActive TRUE
num_children 1
Use Geode_2
}
Use Geode_2
}
-----------------------------------------------------------------------------------------
osg程序代码:
#include <osgDB/ReadFile>
#include <osgViewer/Viewer>
#include <osg/Point>
#include <osg/LineWidth>
#include <osgDB/WriteFile>
// 根据一组点集生成一个Geode对象
osg::ref_ptr< osg::Geode > createProfileGeode( int size, osg::Vec3 *points )
{
osg::ref_ptr< osg::Geode > geode = new osg::Geode();
osg::ref_ptr< osg::Geometry > pointsGeom = new osg::Geometry();
osg::ref_ptr<osg::Vec3Array> vertices = new osg::Vec3Array( size, points);
pointsGeom->setVertexArray(vertices);
pointsGeom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINE_STRIP,0,vertices->size()));
geode->addDrawable(pointsGeom);
return geode.release();
}
int main( int argc, char** argv )
{
osg::Vec3 myCoords1[]=
{
osg::Vec3(0,1,0),
osg::Vec3(0,0,0),
osg::Vec3(1,1,0)
};
osg::Vec3 myCoords2[]=
{
osg::Vec3(1,0,0),
osg::Vec3(2,1,0),
osg::Vec3(2,0,0)
};
osg::ref_ptr< osg::Geode > geode1 = createProfileGeode( sizeof(myCoords1)/sizeof(myCoords1[0]), myCoords1 );
osg::ref_ptr< osg::Geode > geode2 = createProfileGeode( sizeof(myCoords2)/sizeof(myCoords2[0]), myCoords2 );
geode1->setName("geode1");
geode2->setName("geode2");
osg::ref_ptr<osg::Group> root = new osg::Group;
osg::ref_ptr<osg::Group> grp1 = new osg::Group;
osg::ref_ptr<osg::Group> grp2 = new osg::Group;
root->setName("root");
grp1->setName("grp1");
grp2->setName("grp2");
grp1->addChild(geode1);
grp1->addChild(geode2);//geode2的第一个父节点
grp2->addChild(geode2);//geode2的第二个父节点
root->addChild( grp1 );
root->addChild( grp2 );
root->addChild(geode2);//geode2的第三个父节点
osgDB::writeNodeFile( *root, "test.osg" );
osgViewer::Viewer viewer;
viewer.setSceneData( root.get() );
return viewer.run();
}
- 观察osg格式文件中如何处理多个节点共享一个子节点
- TreeView中如何选中一个父节点同时选中所有的子节点和孙节点。。。
- xml中如何读取一个子节点有特定值的节点
- OSG::节点
- OSG在同一视图中显示来自不同来源的多个模型节点文件
- 树形多选框,选中/取消父节点子节点全选中/取消,选中一个子节点父节点选中,子节点全取消父节点取消
- bootstrap-treeview中关于勾选父节点全选子节点,以及勾选一个子节点自动勾选父节点
- 工作流中有条件判断节点时有必要的,可以减少划线,多个审批节点共同使用一个判断节点
- 动态查询一个树形结构表中:某一个节点的所有父节点或者子节点
- 工作流中实现一个节点多个节点的顺序审批
- XStream:Object与Xml字符串 互相转换 多个同名子节点以及节点属性的处理。
- 直接从内存中读取osg节点
- 如何查询子节点和父节点
- DOM中的第一个和最后一个子节点
- 判断一个节点是不是另一个的节点的子节点;
- HTML中父节点和子节点
- mb中compute节点多个out节点的选择
- ZooKeeper观察节点
- 跑出我的未来
- jQuery选择器整理
- ROW_NUMBER() OVER函数的基本用法
- ELFHash算法解释
- HTML5 Audio时代的MIDI音乐文件播放
- 观察osg格式文件中如何处理多个节点共享一个子节点
- Datawindow常使用的内容
- 套接字连接已中止。这可能是由于处理消息时出错或远程主机超过接收超时或者潜在的网络资源问题导致的。本地套接字超时是“00:01:00”
- 三分法(Ternary Search)求解凸(凹)函数的极值问题<方法篇>
- AndEngine----CardinalSplineMoveModifierExample之模仿画<W>
- rule
- Data Transfer Object(数据传输对象)
- Ruby on Rails 书籍推荐
- I,P,B帧和PTS,DTS的关系