Scene System
Detailed Description
This page describes the scene system and general rendering process of Nebula.A Nebula2 scene is a collection of scene node hierarchies, each of which normally represents a visible object in the 3-D world.
Scene Nodes is the root class of all objects that can be grouped into such hierarchies. Read Scene Nodes, Visual Nodes, and Scene Node Hierarchies now.
Scene Servers set up and optimize the scene before passing it off to the lower-level graphics API (Graphics System).
If your application is complicated or large, you will probably need to write you own custom scene server. This document should help you understand enough to do so.
SceneRenderingLoop
The rendering loop of Nebula looks roughly like this:
- nSceneServer::BeginScene
- nSceneServer::Attach is invoked on each visual hierarchy root object that wants to be rendered.
- nSceneServer::EndScene
- nSceneServer::RenderScene
- nSceneServer::PresentScene
Step (1) prepares rendering. It contains initializing per frame variables and loading resources if necessary.
Step (2) determines which visual objects are part of ("attached to") the scene this frame and what parameters they are using. The application accomplishes this by passing the Render Context of every (potentially) visible object to nSceneServer::Attach.
A render context contains a pointer to the root of a scene node hierarchy, plus a transform matrix, frame id, shader parameters, user-defined variables, etc. The additional information is necessary because several game objects may share the same scene node hierarchy (see Attaching A Node Multiple Times).
- Note:
- The scene is completely recreated every frame! That is, any object that wishes to be continously visible must be reattached in each render loop iteration.
Step (4) organizes the scene into an optimal form and then renders it to the back buffer. What exactly happens here is entirely up the particular nSceneServer subclass being used, but nStdSceneServer illustrates the basic procedure:
- Validate resources : ensure that all attached nodes have loaded their resources.
- Split and Sort pass : separate nodes into light and geometry (shape) nodes, then sorted them by shader (to minimize shader switches).
- Render pass consists of the following stages, each called separately for each node:
- Shader pass : specify the shader and (render context-based) shader parameters (usually with nMaterialNode::RenderShader).
- Light pass : calculate light data to be passed to the shader.
- Geometry pass : update mesh geometry, usually with nShapeNode::RenderGeometry.
Step (5) finalizes rendering and presents the scene to the user.
- Note:
- nGfxServer2::PresentScene() should be invoked after EndScene().
See below sections for more details of each scene system modules:
Modules | |
| Render Path Subsystem | |
| Lighting | |
| ... | |
| Render Context | |
| Scene Servers | |
| Scene Animators | |
| Scene Cameras | |
| Scene Nodes | |
Classes | |
| class | nRpXmlParser |
| Configure a nRenderPath2 object from an XML file. More... | |
| class | nAbstractShaderNode |
| This is the base class for all shader related scene node classes (for instance material and light nodes). More... | |
| class | nAnimator |
| Animator nodes manipulate properties of other scene objects. More... | |
| class | nAttachmentNode |
| The purpose of nAttachmentNode is to provide an external point of access to a skeleton's joint transformation information. The user specifies either a joint name or joint index, and the nAttachmentNode grabs the specified joint data, its transformation mirroring the joint's. More... | |
| class | nBlendShapeAnimator |
| class | nBlendShapeNode |
| class | nCharacter3Node |
| class | nCharacter3SkinAnimator |
| class | nFloatAnimator |
| Animates a float attribute of a nAbstractShaderNode. More... | |
| class | nIntAnimator |
| Animates a int attribute of a nAbstractShaderNode. More... | |
| class | nLightNode |
| Scene node which provides lighting information. More... | |
| class | nLodNode |
| A lod node switches its child nodes on and off according to its current camera distance to accomplish different representations with different levels of detail. More... | |
| class | nMaterialNode |
| A material node defines a shader resource and associated shader variables. A shader resource is an external file (usually a text file) which defines a surface shader. More... | |
| class | nMultiLayeredNode |
| class | nParticleShapeNode |
| A shape node representing a particle system. More... | |
| class | nParticleShapeNode2 |
| class | nRenderContext |
| A nRenderContext object holds frame persistent data for nSceneNode hierarchies and serves as the central communication point between the client app and nSceneNode hierarchies. More... | |
| class | nSceneNode |
| The nSceneNode is the base class of all objects which can be attached to a scene managed by the nSceneServer class. A scene node object may provide transform, geometry, shader and volume information. More... | |
| class | nSceneServer |
| The scene server builds a scene from nSceneNode objects and then renders it. More... | |
| class | nShadowNode |
| A shadow node is 'visible' object that provide shadow to the scene. More... | |
| class | nShadowSkinShapeNode |
| A shadow skin node is 'visible' object that provide shadow to the scene. More... | |
| class | nSkinAnimator |
| Provide an animated joint skeleton for a nSkinShapeNode. More... | |
| class | nSkinShapeNode |
| A smooth skinned shape node. More... | |
| class | nSkyNode |
| class | nSkyState |
| class | nSubdivShapeNode |
| Takes an input mesh and renders a tesselated mesh (FIXME: for now a pointlist based on subdivision parameters. More... | |
| class | nTextShapeNode |
| class | nTransformAnimator |
| Animate position, orientation and scaling of a nTransformNode from directly defined key arrays. More... | |
| class | nTransformCurveAnimator |
| A transform curve animator controls a scene node's animation from an animation curve of the Animation Subsystem. More... | |
| class | nTransformNode |
| A transform node groups its child nodes and defines position, orientation and scale of a scene node. Transformation hierarchies can be created using the Nebula object name space hierarchy. More... | |
| class | nUvAnimator |
| Animates the UV transform parameters on an nAbstractShaderNode. More... | |
| class | nVectorAnimator |
| Animates a vector attribute of an nAbstractShaderNode. More... | |
| class | nToolkitServer |