2.3 The SceneManager Object
2.3 The SceneManager Object
It is to the SceneManager that you go when you want to create a camera for the scene. It's also
where you go to retrieve a material which is used by an object, or to remove a light from the
scene. There is no need for your application to keep lists of objects, the SceneManager keeps a
named set of all of the scene objects for you to access, should you need them. Look in the main
documentation under the getCamera, getMaterial, getLight etc methods.
The SceneManager also sends the scene to the RenderSystem object when it is time to render the
scene. You never have to call the SceneManager::_renderScene method directly though - it is
called automatically whenever a rendering target is asked to update.
So most of your interaction with the SceneManager is during scene setup. You're likely to call a
great number of methods (perhaps driven by some input file containing the scene data) in order to
set up your scene. You can also modify the contents of the scene dynamically during the rendering
cycle if you create your own FrameListener object (see later).
为了获得比较好的渲染性能,不同的场景类型需要不同的算法来决定哪个对象要送给
RenderSystem。SceneManager 类被设计为不同场景类型的子集。缺省的 SceneManager 对象将
会渲染一个场景,但是它会做很少或是不做场景组织,因此你不能期望在大场景的情况下
有好的性能表现。这样的目的是针对某种类型的场景特化将会起作用,例如派生自
SceneManager 的子类将会通过假定要产生的某种场景类型来对场景组织进行优化,以获得
最优的性能。一个例子是 BspSceneManager 用于优化渲染基于二叉空间划分树的大型室内场
景。
The application using OGRE does not have to know which subclasses are available. The
application simply calls Root::getSceneManager(..) passing as a parameter one of a number of
scene types (e.g. ST_GENERIC, ST_INTERIOR etc). OGRE will automatically use the best
SceneManager subclass available for that scene type, or default to the basic SceneManager if a
specialist one is not available. This allows the developers of OGRE to add new scene
specialisations later and thus optimise previously unoptimised scene types without the user
applications having to change any code.
使 用 OGRE 的 应 用 程 序 不 需 要 知 道 哪 个 子 类 会 被 使 用 。 应 用 程 序 简 单 的 调 用
Root::getSceneManager(..)方法通过场景类型(例如,ST_GENERIC, ST_INTERIOR 等)参
数获得场景管理者。OGRE 将会自动使用针对那种场景类型最好的 SceneManager 子类或是
如果指定的 SceneManager 不存在则缺省的基本 SceneManager 将被应用。这样就可以让用户
的应用程序不需要改变任何代码的情况下,OGRE 的开发者以后添加特定的 SceneManager
来对没有优化的场景类型进行优化。