OSG中的节点

本文介绍了如何在OSG(OpenSceneGraph)中对节点进行操作,包括将多个模型添加到场景、删除节点、隐藏与显示节点,以及通过矩阵变换实现模型的移动、旋转和缩放。示例代码详细展示了这些操作的实现方式。
摘要由CSDN通过智能技术生成

1.多个模型添加到一个场景中去

#include <osgViewer/Viewer>

#include <osgDB/ReadFile>

#include <osg/Node>  
int main(void)  
{  
    osgViewer::Viewer viewer;  
    osg::Group * root = new osg::Group();  
    root->addChild(osgDB::readNodeFile("sofa.osg"));  
    root->addChild(osgDB::readNodeFile("cow.osg")); 
    viewer.setSceneData(root);  
    viewer.realize();  
    viewer.run();  
    return 0;  

}

出现下面效果:


删除节点:

#include <osgViewer/Viewer>
#include <osgDB/ReadFile>
#include <osg/Node>  
int main(void)  
{  
    osgViewer::Viewer viewer;  
    osg::Group * root = new osg::Group();  
    root->addChild(osgDB::readNodeFile("sofa.osg"));  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值