JCHub

  • Home
  • Category
    • A/V
    • WebRTC
    • Beauty of Programming
    • Linux
    • Windows
    • Moments of Life
    • Campus Life
  • Reference
    • API Reference
    • Utilities
    • AV Test
    • Doc
  • Message Board
  • About
JCHub
Code as My Sword, Lost in Obsession
  1. Main page
  2. Beauty of Programming
  3. Main content

Ogre中的场景文件

2014年4月25日 1818hotness 0likes 0comments

在Ogre中,要构建一个较复杂场景,如果通过手工一个个设置坐标,将会十分麻烦,这时我们就可以利用场景文件直接导入场景。

简介
场景文件(.scene)其实就是一个标准的xml文件,包含了描述场景所需要的元素,场景文件内容示例:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<scene formatVersion="">
    <nodes>
        <node name="Robot" id="3">
            <position x="10.0" y="5" z="10.5" />
            <scale x="1" y="1" z="1" />
            <entity name="Robot" meshFile="robot.mesh" static="false" />
        </node>
        <node name="Omni01" id="5">
            <position x="-23" y="49" z="18" />
            <rotation qx="0" qy="0" qz="0" qw="1" />
            <scale x="1" y="1" z="1" />
            <light name="Omni01" type="point" intensity="0.01" contrast="0">
                <colourDiffuse r="0.4" g="0.4" b="0.5" />
                <colourSpecular r="0.5" g="0.5" b="0.5" />
            </light>
        </node>
    </nodes>
</scene>

Advanced Ogre Framework中带有3个与场景文件解析有关的类:DotSceneLoader.hpp,DotSceneLoader.cpp以及rapidxml.hpp,可以参考下该框架,了解下场景文件使用,同时该框架对Ogre学习也很有帮助。

工具
导出场景文件有很多工具,比如我开发的漫游系统用的是3Dsmax的OgreMax插件,在3Dsmax中建模好后使用OgreMax插件导出为场景文件。
Ogremaxexportscene

由于场景复杂时,3Dsmax的渲染速度很慢,所以我才用分区域建模,地面与地面物体分开建模,地面导出为一个场景文件,地面物体导出为另一个场景文件,然后在程序中导入这两个场景文件即可(要注意各个场景文件中模型名称不能重复,即不能拥有相同模型名称,否则程序进入时报错)。

参考:
Ogre DotScene
Advanced Ogre Framework

This article is licensed with Creative Commons Attribution-NonCommercial-No Derivatives 4.0 International License
Tag: OGRE
Last updated:2018年12月23日

Jeff

管理员——代码为剑,如痴如醉

Tip the author Like
< Last article
Next article >

Comments

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
Cancel

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Related Posts
  • Ogre中阴影设置问题
  • Ogre中加入声音
  • Ogre中的粒子系统(Particle System)
  • Ogre中简单的AABB碰撞检测
  • Ogre中移植Sample_Character到Advanced Ogre Framework
Categories

COPYRIGHT © 2026 jianchihu.net. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang