newspeoplefor developersdocumentationdownloads

nSceneNode Class Reference
[Scene System]

#include <nscenenode.h>

Inheritance diagram for nSceneNode:

nRoot nObject nNode nReferenced nSignalEmitter nAnimator nTransformNode nBlendShapeAnimator nShaderAnimator nSkinAnimator nTextureAnimator nTransformAnimator nTransformCurveAnimator nUvAnimator nAbstractCameraNode nAbstractShaderNode nAttachmentNode nCharacter3Node nLodNode nShadowNode nShadowSkinShapeNode nSkyNode List of all members.

Detailed Description

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.

See also nSceneNode Script Interface

(C) 2002 RadonLabs GmbH

Definition at line 33 of file nscenenode.h.


Public Types

enum  {
  HierarchyNode = (1<<0),
  LodNode = (1<<1),
  LevelSegment = (1<<2)
}
 scene node hints More...

Public Member Functions

 nSceneNode ()
 constructor
virtual ~nSceneNode ()
 destructor
virtual bool Release ()
 release object
virtual bool SaveCmds (nPersistServer *ps)
 save object to persistent stream
virtual bool LoadResources ()
 load resources for this object
virtual void UnloadResources ()
 unload resources for this object
bool AreResourcesValid () const
 return true if resources for this object are valid
void PreloadResources ()
 recursively preload resources
void AddHints (ushort h)
 set one or more hint flags
void ClearHints (ushort h)
 clear one or more hint flags
ushort GetHints () const
 get all hints
bool HasHints (ushort h) const
 return true if hint is set
virtual void RenderContextCreated (nRenderContext *renderContext)
 called by app when new render context has been created for this object
virtual void RenderContextDestroyed (nRenderContext *renderContext)
 called by app when render context is going to be released
virtual void Attach (nSceneServer *sceneServer, nRenderContext *renderContext)
 called by nSceneServer when object is attached to scene
virtual bool HasTransform () const
 return true if node provides transformation
virtual bool HasGeometry () const
 return true if node provides geometry
virtual bool HasShader () const
 return true if node provides shader
virtual bool HasLight () const
 return true if node provides lighting information
virtual bool HasShadow () const
 return true if node provides shadow
virtual bool HasCamera () const
 return true if node is camera
virtual bool RenderTransform (nSceneServer *sceneServer, nRenderContext *renderContext, const matrix44 &parentMatrix)
 render transformation
virtual bool ApplyGeometry (nSceneServer *sceneServer)
 perform pre-instancing rendering of geometry
virtual bool RenderGeometry (nSceneServer *sceneServer, nRenderContext *renderContext)
 perform per-instance-rendering of geometry
virtual void RenderDebug (nSceneServer *sceneServer, nRenderContext *renderContext, const matrix44 &modelMatrix)
 render debug information
virtual bool ApplyShader (nSceneServer *sceneServer)
 perform pre-instancing rending of shader
virtual bool RenderShader (nSceneServer *sceneServer, nRenderContext *renderContext)
 perform per-instance-rendering of shader
virtual const nLightApplyLight (nSceneServer *sceneServer, nRenderContext *renderContext, const matrix44 &lightTransform, const vector4 &shadowLightMask)
 set per-light states
virtual const nLightRenderLight (nSceneServer *sceneServer, nRenderContext *renderContext, const matrix44 &lightTransform)
 set per-shape-instance light states
virtual bool ApplyShadow (nSceneServer *sceneServer)
 perform pre-instancing rendering of shadow
virtual bool RenderShadow (nSceneServer *sceneServer, nRenderContext *renderContext, const matrix44 &modelMatrix)
 perform per-instance-rendering of shadow
virtual bool RenderCamera (const matrix44 &modelWorldMatrix, const matrix44 &viewMatrix, const matrix44 &projectionMatrix)
 render the scene from the provided camera
void SetLocalBox (const bbox3 &b)
 set the local bounding box
const bbox3GetLocalBox () const
 get the node's bounding box
void SetRenderPri (int pri)
 set render priority
int GetRenderPri () const
 get render priority
void AddAnimator (const char *path)
 add an animator object
void RemoveAnimator (const char *path)
 remove an animator object
int GetNumAnimators () const
 get number of animator objects
const char * GetAnimatorAt (int index)
 get animator object at index
void InvokeAnimators (int animatorType, nRenderContext *renderContext)
 invoke all animators
bool HasAttr (const nString &name) const
 return true if attribute exists
const nAttrGetAttr (const nString &name) const
 generic read access to attribute
void SetIntAttr (const nString &name, int val)
 set int custom attribute
int GetIntAttr (const nString &name) const
 get int custom attribute
void SetFloatAttr (const nString &name, float val)
 set float custom attribute
float GetFloatAttr (const nString &name) const
 get float custom attribute
void SetBoolAttr (const nString &name, bool val)
 set bool custom attribute
bool GetBoolAttr (const nString &name) const
 get bool custom attribute
void SetStringAttr (const nString &name, const nString &val)
 set string custom attribute
nString GetStringAttr (const nString &name) const
 get string custom attribute
void SetVector3Attr (const nString &name, const vector3 &val)
 set vector3 custom attribute
const vector3GetVector3Attr (const nString &name) const
 get vector3 custom attribute
void SetVector4Attr (const nString &name, const vector4 &val)
 set vector4 custom attribute
const vector4GetVector4Attr (const nString &name) const
 get vector4 custom attribute

Protected Member Functions

virtual void UpdateInstStreamDecl (nInstanceStream::Declaration &decl)
 recursively append instance parameters to provided instance stream declaration

Protected Attributes

bbox3 localBox
nArray< nDynAutoRef< nAnimator > > animatorArray
nArray< nAttrattrs
int renderPri
bool resourcesValid
ushort hints

Member Enumeration Documentation

anonymous enum
 

scene node hints

Enumerator:
HierarchyNode 
LodNode 
LevelSegment 

Reimplemented from nRoot.

Definition at line 37 of file nscenenode.h.


Constructor & Destructor Documentation

nSceneNode::nSceneNode  ) 
 

constructor

Definition at line 15 of file nscenenode_main.cc.

nSceneNode::~nSceneNode  )  [virtual]
 

destructor

Definition at line 27 of file nscenenode_main.cc.


Member Function Documentation

bool nSceneNode::Release  )  [virtual]
 

release object

This calls UnloadResources() if the object is going to die (this can't be put into the destructor, because virtual methods don't work when called from the destructor).

Reimplemented from nRoot.

Definition at line 39 of file nscenenode_main.cc.

virtual bool nSceneNode::SaveCmds nPersistServer ps  )  [virtual]
 

save object to persistent stream

Reimplemented from nObject.

Reimplemented in nSwingShapeNode, nAbstractCameraNode, nAbstractShaderNode, nAnimator, nAttachmentNode, nBlendShapeAnimator, nBlendShapeNode, nCharacter3Node, nFloatAnimator, nIntAnimator, nLightNode, nLodNode, nMaterialNode, nMultiLayeredNode, nParticleShapeNode, nParticleShapeNode2, nShaderAnimator, nShadowNode, nShadowSkinShapeNode, nShapeNode, nSkinAnimator, nSkinShapeNode, nSkyNode, nSubdivShapeNode, nTextureAnimator, nTransformAnimator, nTransformCurveAnimator, nTransformNode, nUvAnimator, nVectorAnimator, nCLODShapeNode, nTerrainGrassNode, nTerrainNode, and nMapNode.

bool nSceneNode::LoadResources  )  [virtual]
 

load resources for this object

This method makes sure that all resources needed by this object are loaded. The method does NOT recurse into its children.

Subclasses should expect that the LoadResources() method can be called on them although some or all of their resources are valid. Thus, a check should exist, whether the resource really needs to be reloaded.

Returns:
true, if resource loading was successful

Reimplemented in nSwingShapeNode, nAbstractShaderNode, nBlendShapeAnimator, nBlendShapeNode, nCharacter3Node, nCharacter3SkinAnimator, nMaterialNode, nShadowNode, nShadowSkinShapeNode, nShapeNode, nSkinAnimator, nTextShapeNode, nTransformCurveAnimator, nCLODShapeNode, nTerrainNode, and nMapNode.

Definition at line 61 of file nscenenode_main.cc.

void nSceneNode::UnloadResources  )  [virtual]
 

unload resources for this object

This method makes sure that all resources used by this object are unloaded. The method does NOT recurse into its children.

If you ovverride this method, be sure to call the overridden version in your destructor.

Returns:
true, if resources have actually been unloaded

Reimplemented in nSwingShapeNode, nAbstractShaderNode, nBlendShapeAnimator, nBlendShapeNode, nCharacter3Node, nCharacter3SkinAnimator, nMaterialNode, nShadowNode, nShadowSkinShapeNode, nShapeNode, nSkinAnimator, nTextShapeNode, nTransformCurveAnimator, nCLODShapeNode, and nTerrainNode.

Definition at line 82 of file nscenenode_main.cc.

bool nSceneNode::AreResourcesValid  )  const [inline]
 

return true if resources for this object are valid

Return true if the node's resources are valid.

Definition at line 225 of file nscenenode.h.

void nSceneNode::PreloadResources  ) 
 

recursively preload resources

Recursively preload required resources. Call this method after loading or creation and before the first rendering. It will load all required resources (textures, meshes, animations, ...) from disk and thus prevent stuttering during rendering.

Definition at line 106 of file nscenenode_main.cc.

void nSceneNode::AddHints ushort  h  )  [inline]
 

set one or more hint flags

Set one or more hint flags. Will be or'ed into the current hints.

Definition at line 236 of file nscenenode.h.

void nSceneNode::ClearHints ushort  h  )  [inline]
 

clear one or more hint flags

Clear one or more hint flags.

Definition at line 247 of file nscenenode.h.

ushort nSceneNode::GetHints  )  const [inline]
 

get all hints

Return all hint flags.

Definition at line 258 of file nscenenode.h.

bool nSceneNode::HasHints ushort  h  )  const [inline]
 

return true if hint is set

Return true if one or more hints are set.

Definition at line 269 of file nscenenode.h.

void nSceneNode::RenderContextCreated nRenderContext renderContext  )  [virtual]
 

called by app when new render context has been created for this object

Called by the client app when a new render context has been created for this scene node hierarchy. Scene node hierarchies must not contain frame-persistent data, since one hierarchy can be reused multiple times per frame. All frame-persistent data must be stored in nRenderContext objects, which must be communicated to the scene node hierarchy when it is rendered. nRenderContext objects are the primary way to communicate data from the client app to a scene node hierarchy (i.e. time stamps, velocity, etc...).

The RenderContextCreated() method should be called when a new 'game object' which needs rendering has been created by the application.

Parameters:
renderContext pointer to a nRenderContext object

Reimplemented in nParticleShapeNode, nParticleShapeNode2, and nSkinAnimator.

Definition at line 140 of file nscenenode_main.cc.

void nSceneNode::RenderContextDestroyed nRenderContext renderContext  )  [virtual]
 

called by app when render context is going to be released

Called by the client app when a render context for this scene node hierarchy should be destroyed. This is usually the case when the game object associated with this scene node hierarchy goes away.

The method will be invoked recursively on all child and depend nodes of the scene node object.

Parameters:
renderContext pointer to a nRenderContext object
  • 20-Jul-04 floh oops, recursive routine was calling ClearLocalVars!

Reimplemented in nParticleShapeNode2, and nSkinAnimator.

Definition at line 167 of file nscenenode_main.cc.

void nSceneNode::Attach nSceneServer sceneServer,
nRenderContext renderContext
[virtual]
 

called by nSceneServer when object is attached to scene

Attach the object to the scene if necessary. This method is either called by the nSceneServer, or by another nSceneNode object at scene construction time. If the nSceneNode needs rendering it should call the appropriate nSceneServer method to attach itself to the scene.

The method will be invoked recursively on all child and depend nodes of the scene node object.

Parameters:
sceneServer pointer to the nSceneServer object
renderContext pointer to the nRenderContext object

Reimplemented in nLodNode, nParticleShapeNode, nParticleShapeNode2, nSkyNode, nSkyState, and nTransformNode.

Definition at line 194 of file nscenenode_main.cc.

bool nSceneNode::HasTransform  )  const [virtual]
 

return true if node provides transformation

Return true if this node provides transformation. Should overriden by subclasses.

Reimplemented in nSkyState, and nTransformNode.

Definition at line 338 of file nscenenode_main.cc.

bool nSceneNode::HasGeometry  )  const [virtual]
 

return true if node provides geometry

Return true if this node provides geometry. Should overriden by subclasses.

Reimplemented in nBlendShapeNode, nShapeNode, nCLODShapeNode, nTerrainGrassNode, nTerrainNode, and nMapNode.

Definition at line 349 of file nscenenode_main.cc.

bool nSceneNode::HasShader  )  const [virtual]
 

return true if node provides shader

Return true if this node provides a shader.

Reimplemented in nMaterialNode.

Definition at line 359 of file nscenenode_main.cc.

bool nSceneNode::HasLight  )  const [virtual]
 

return true if node provides lighting information

Return true if this node provides shadow. Should be overriden by subclasses.

Reimplemented in nLightNode.

Definition at line 370 of file nscenenode_main.cc.

bool nSceneNode::HasShadow  )  const [virtual]
 

return true if node provides shadow

Return true if this node provides light information. Should be overriden by subclasses.

Reimplemented in nShadowNode, and nShadowSkinShapeNode.

Definition at line 381 of file nscenenode_main.cc.

bool nSceneNode::HasCamera  )  const [virtual]
 

return true if node is camera

Return true if this node is a camera. Should be overriden by subclasses.

Reimplemented in nAbstractCameraNode.

Definition at line 392 of file nscenenode_main.cc.

bool nSceneNode::RenderTransform nSceneServer sceneServer,
nRenderContext renderContext,
const matrix44 parentMatrix
[virtual]
 

render transformation

Render the node's transformtion. This should be implemented by a subclass. The method will only be called by nSceneServer if the method HasTransform() returns true.

Reimplemented in nAttachmentNode, nCharacter3Node, nParticleShapeNode, nParticleShapeNode2, and nTransformNode.

Definition at line 215 of file nscenenode_main.cc.

bool nSceneNode::ApplyGeometry nSceneServer sceneServer  )  [virtual]
 

perform pre-instancing rendering of geometry

Perform pre-instance rendering of geometry. This method will be called once at the beginning of rendering different instances of the same scene node. Use this method to setup geometry attributes which are constant for a complete instance set.

Reimplemented in nBlendShapeNode, nParticleShapeNode, nParticleShapeNode2, nShapeNode, nSkinShapeNode, nSubdivShapeNode, and nTextShapeNode.

Definition at line 228 of file nscenenode_main.cc.

bool nSceneNode::RenderGeometry nSceneServer sceneServer,
nRenderContext renderContext
[virtual]
 

perform per-instance-rendering of geometry

Perform per-instance-rendering of geometry. This method will be called after ApplyGeometry() once for each instance of the node.

Reimplemented in nBlendShapeNode, nMultiLayeredNode, nParticleShapeNode, nParticleShapeNode2, nShapeNode, nSkinShapeNode, nSubdivShapeNode, nTextShapeNode, nCLODShapeNode, nTerrainGrassNode, nTerrainNode, and nMapNode.

Definition at line 240 of file nscenenode_main.cc.

void nSceneNode::RenderDebug nSceneServer sceneServer,
nRenderContext renderContext,
const matrix44 modelMatrix
[virtual]
 

render debug information

Perform debug-rendering. This method will be called by nSceneServer on each shape node right after RenderGeometry() if debug visualization is enabled.

Reimplemented in nShapeNode, and nSkinShapeNode.

Definition at line 252 of file nscenenode_main.cc.

bool nSceneNode::ApplyShader nSceneServer sceneServer  )  [virtual]
 

perform pre-instancing rending of shader

Perform pre-instance rendering of the shader. This method will be called once at the beginning of rendering different instances of the same scene node. Use this method to setup shader attributes which are constant for a complete instance set.

Reimplemented in nSwingShapeNode, nMaterialNode, and nSubdivShapeNode.

Definition at line 265 of file nscenenode_main.cc.

bool nSceneNode::RenderShader nSceneServer sceneServer,
nRenderContext renderContext
[virtual]
 

perform per-instance-rendering of shader

Perform per-instance-rendering of the shader. This method will be called after ApplyShader() once for each rendered instance. Use this method to set shader attributes which vary from instance to instance.

Reimplemented in nSwingShapeNode, and nMaterialNode.

Definition at line 278 of file nscenenode_main.cc.

const nLight & nSceneNode::ApplyLight nSceneServer sceneServer,
nRenderContext renderContext,
const matrix44 lightTransform,
const vector4 shadowLightMask
[virtual]
 

set per-light states

Perform per-light of the light source. This method will be called for each light.

Reimplemented in nLightNode.

Definition at line 289 of file nscenenode_main.cc.

const nLight & nSceneNode::RenderLight nSceneServer sceneServer,
nRenderContext renderContext,
const matrix44 lightTransform
[virtual]
 

set per-shape-instance light states

Perform per-instance-rendering of the light source. This method will be called once for each scene node which is influenced by this light.

Reimplemented in nLightNode.

Definition at line 301 of file nscenenode_main.cc.

bool nSceneNode::ApplyShadow nSceneServer sceneServer  )  [virtual]
 

perform pre-instancing rendering of shadow

Perform pre-instance rendering of shadow. This method will be called once at the beginning of rendering different instances of the same scene node. Use this method to setup shadow geometry attributes which are constant for a complete instance set.

Definition at line 315 of file nscenenode_main.cc.

bool nSceneNode::RenderShadow nSceneServer sceneServer,
nRenderContext renderContext,
const matrix44 modelMatrix
[virtual]
 

perform per-instance-rendering of shadow

Perform per-instance-rendering of shadow geometry. This method will be called after ApplyShadow() once for each instance of the node.

Reimplemented in nShadowNode, and nShadowSkinShapeNode.

Definition at line 327 of file nscenenode_main.cc.

bool nSceneNode::RenderCamera const matrix44 modelWorldMatrix,
const matrix44 viewMatrix,
const matrix44 projectionMatrix
[virtual]
 

render the scene from the provided camera

Reimplemented in nAbstractCameraNode, nCameraNode, nClippingCameraNode, nOverlookCameraNode, and nReflectionCameraNode.

Definition at line 535 of file nscenenode_main.cc.

void nSceneNode::SetLocalBox const bbox3 b  )  [inline]
 

set the local bounding box

Define the local bounding box. Shape node compute their bounding box automatically at load time. This method can be used to define bounding boxes for other nodes. This may be useful for higher level code like game frameworks. Nebula itself only uses bounding boxes defined on shape nodes.

Definition at line 180 of file nscenenode.h.

const bbox3 & nSceneNode::GetLocalBox  )  const [inline]
 

get the node's bounding box

Definition at line 190 of file nscenenode.h.

void nSceneNode::SetRenderPri int  pri  )  [inline]
 

set render priority

Set the render priority. This should be a number between -127 and +127, the default is 0. Smaller numbers will render first.

Definition at line 202 of file nscenenode.h.

int nSceneNode::GetRenderPri  )  const [inline]
 

get render priority

Get the render priority of this node.

Definition at line 214 of file nscenenode.h.

void nSceneNode::AddAnimator const char *  relPath  ) 
 

add an animator object

Add an animator object to this scene node.

Definition at line 402 of file nscenenode_main.cc.

void nSceneNode::RemoveAnimator const char *  relPath  ) 
 

remove an animator object

Remove an animator object from this scene node.

-23-Nov-06 kims Changed GetName() to getname() cause it should retrieve relevant path not just name of an animator.

Definition at line 419 of file nscenenode_main.cc.

int nSceneNode::GetNumAnimators  )  const
 

get number of animator objects

Get number of animator objects.

Definition at line 441 of file nscenenode_main.cc.

const char * nSceneNode::GetAnimatorAt int  index  ) 
 

get animator object at index

Get path to animator object at given index.

Definition at line 451 of file nscenenode_main.cc.

void nSceneNode::InvokeAnimators int  type,
nRenderContext renderContext
 

invoke all animators

Invoke all shader animators. This method should be called classes which implement the RenderShader() method from inside this method.

Definition at line 462 of file nscenenode_main.cc.

bool nSceneNode::HasAttr const nString name  )  const [inline]
 

return true if attribute exists

Definition at line 298 of file nscenenode.h.

const nAttr & nSceneNode::GetAttr const nString name  )  const [inline]
 

generic read access to attribute

Definition at line 308 of file nscenenode.h.

void nSceneNode::SetIntAttr const nString name,
int  val
[inline]
 

set int custom attribute

Definition at line 318 of file nscenenode.h.

int nSceneNode::GetIntAttr const nString name  )  const [inline]
 

get int custom attribute

Definition at line 328 of file nscenenode.h.

void nSceneNode::SetFloatAttr const nString name,
float  val
[inline]
 

set float custom attribute

Definition at line 338 of file nscenenode.h.

float nSceneNode::GetFloatAttr const nString name  )  const [inline]
 

get float custom attribute

Definition at line 348 of file nscenenode.h.

void nSceneNode::SetBoolAttr const nString name,
bool  val
[inline]
 

set bool custom attribute

Definition at line 358 of file nscenenode.h.

bool nSceneNode::GetBoolAttr const nString name  )  const [inline]
 

get bool custom attribute

Definition at line 368 of file nscenenode.h.

void nSceneNode::SetStringAttr const nString name,
const nString val
[inline]
 

set string custom attribute

Definition at line 378 of file nscenenode.h.

nString nSceneNode::GetStringAttr const nString name  )  const [inline]
 

get string custom attribute

Definition at line 388 of file nscenenode.h.

void nSceneNode::SetVector3Attr const nString name,
const vector3 val
[inline]
 

set vector3 custom attribute

Definition at line 398 of file nscenenode.h.

const vector3 & nSceneNode::GetVector3Attr const nString name  )  const [inline]
 

get vector3 custom attribute

Definition at line 408 of file nscenenode.h.

void nSceneNode::SetVector4Attr const nString name,
const vector4 val
[inline]
 

set vector4 custom attribute

Definition at line 418 of file nscenenode.h.

const vector4 & nSceneNode::GetVector4Attr const nString name  )  const [inline]
 

get vector4 custom attribute

Definition at line 428 of file nscenenode.h.

void nSceneNode::UpdateInstStreamDecl nInstanceStream::Declaration decl  )  [protected, virtual]
 

recursively append instance parameters to provided instance stream declaration

Recursively build an instance stream declaration from the shaders in the scene node hierarchy. Override this method in subclasses with shader handling.

Reimplemented in nMaterialNode.

Definition at line 520 of file nscenenode_main.cc.


Member Data Documentation

bbox3 nSceneNode::localBox [protected]
 

Definition at line 162 of file nscenenode.h.

nArray<nDynAutoRef<nAnimator> > nSceneNode::animatorArray [protected]
 

Definition at line 163 of file nscenenode.h.

nArray<nAttr> nSceneNode::attrs [protected]
 

Definition at line 164 of file nscenenode.h.

int nSceneNode::renderPri [protected]
 

Definition at line 165 of file nscenenode.h.

bool nSceneNode::resourcesValid [protected]
 

Definition at line 166 of file nscenenode.h.

ushort nSceneNode::hints [protected]
 

Definition at line 167 of file nscenenode.h.


The documentation for this class was generated from the following files: