panda3d中Scene Graph的介绍
来源:互联网 发布:圣斗士星矢 知乎 编辑:程序博客网 时间:2024/06/11 21:01
在计算机图形学中,需要用一些基本元素构成一个复杂的场景,因此需要一个数据结构scene graph来存储该场景中的元素的基本关系。每一条边代表两个基本元素之间的相对位置关系等,在一些引擎中scene graph将3d模型存储在线性表中。panda3d存储结构稍微复杂为树状结构,简单的说是自上而下的结构且无回边,即子节点的性质不能影响父节点的性质, panda3d中存储Scene Graph树节点的是PandaNode。他是ModelNode,GeomNode,LightNode三个类的父类,场景中Scene Graph的父节点render根据不同的节点进行渲染,由于三种节点有相同的父节点,所以父节点的一些性质会被子节点继承。注意scene graph中不是只有一棵树,可以有多棵,用attachNewNode语句来完成,读者可以通过下面两个程序显示的结果来更加深入的理解。
代码一:
from direct.showbase.ShowBase import ShowBase
from direct.actor.Actor import Actor
from panda3d.core import Vec3
class Application(ShowBase):
def __init__(self):
ShowBase.__init__(self)
self.sun=loader.loadModel("smiley")
self.sun.reparentTo(render)
self.sun.setScale(4)
self.earth=loader.loadModel("frowney")
self.earthCenter=render.attachNewNode("earthCenter")
self.earth.reparentTo(self.earthCenter)
#self.earth.reparentTo(render)
self.earth.setPos(4,0,0)
self.cam.setPos(0,-100,0)
w=Application()
run()
代码二:
from direct.showbase.ShowBase import ShowBase
from direct.actor.Actor import Actor
from panda3d.core import Vec3
class Application(ShowBase):
def __init__(self):
ShowBase.__init__(self)
self.sun=loader.loadModel("smiley")
self.sun.reparentTo(render)
self.sun.setScale(4)
self.earth=loader.loadModel("frowney")
#self.earthCenter=render.attachNewNode("earthCenter")
#self.earth.reparentTo(self.earthCenter)
self.earth.reparentTo(self.sun)
self.earth.setPos(4,0,0)
self.cam.setPos(0,-100,0)
w=Application()
run()
结果为
代码1:
代码2:
- panda3d中Scene Graph的介绍
- 翻译:Panda3D Manual/V. Programming with Panda/A. The Scene Graph
- Scene Management --- scene graph
- Scene Management - Scene Graph
- Scene Management - Scene Graph
- 4.1 scene graph构建的基本问题
- QML Scene Graph 的文本渲染
- Open Scene Graph
- 4.7 Scene Graph Compilers
- Overlay Scene Graph
- Scene Graph 小记(Qt5)
- Scene Graph 小记(Qt5)
- Scene Graph 小记(Qt5)
- Qt Scene graph画线
- Qt Quick Scene Graph
- Qt Scene Graph渲染方式在不同系统的差异
- QT之 scene graph 的局部刷新尝试(一)
- panda3d 中导入image
- Android 4.1:UI开源、连接、服务与工具得到了改进
- Android帧缓冲区(Frame Buffer)硬件抽象层(HAL)模块Gralloc的实现原理分析
- 编程网站
- QT开发环境搭建 windows and linux
- 软件架构师的特点
- panda3d中Scene Graph的介绍
- 函数调用栈初探
- python获取当前系统的桌面的路径的四种方法
- VC生成的dll中导出函数名三种方法
- Windows----directshow----IBasicVideo接口
- 使用Delphi调用C++编写的DLL
- Fedora回收站路径
- error C2872: ULONG_PTR : ambiguous symbol 问题的解决
- ThreadPoolExecutor使用介绍