SPIN Framework
Public Types | Public Member Functions | Public Attributes

spin::ModelNode Class Reference

Node for including 3D models of popular formats in the scene. More...

#include <ModelNode.h>

Inheritance diagram for spin::ModelNode:
spin::GroupNode spin::ReferencedNode

List of all members.

Public Types

enum  animationModeType { OFF, SWITCH, SEQUENCE }

Public Member Functions

 ModelNode (SceneManager *sceneManager, const char *initID)
virtual void updateNodePath (bool updateChildren=true)
virtual void setContext (const char *newvalue)
void setModelFromFile (const char *filename)
const char * getModelFromFile () const
void setAttachCentroid (int i)
int getAttachCentroid () const
void makeCentered ()
void setStateRegistration (int i)
int getStateRegistration () const
void setRenderBin (int i)
int getRenderBin () const
void setKeyframe (int index, float keyframe)
float getKeyframe (int index) const
void setPlaying (int index, int playState)
float getPlaying (int index) const
void setStateSet (int index, const char *replacement)
void updateStateSet ()
virtual std::vector< lo_message > getState () const
void setLighting (int i)
int getLighting () const

Public Attributes

std::vector< t_symbol * > _statesetList

Detailed Description

Node for including 3D models of popular formats in the scene.

This class allows us to attach an external 3D model from a file. Popular formats (.3ds, .obj, .osg, etc) are supported as long as an OSG plugin exists to read it. The model can be offset and scaled. Animations are also supported as long as the model has an osg::Switch or osg::Sequence node inside. Texture and shader information can be parsed out (using the StateRegistraion flag), and automatically create referenced statesets controllable by SPIN.


Member Function Documentation

int spin::ModelNode::getAttachCentroid ( ) const [inline]

Returns a boolean indicating whether attachCentroid is enabled.

float spin::ModelNode::getKeyframe ( int  index) const [inline]

Return the keyframe of a particular animation saved within the model (there can be several animations, hence the required index number)

int spin::ModelNode::getLighting ( ) const [inline]

Returns a boolean indicating whether lighting is enabled for the model.

const char* spin::ModelNode::getModelFromFile ( ) const [inline]

Returns the file path of the 3d model attached to this node.

float spin::ModelNode::getPlaying ( int  index) const [inline]

Returns a boolean indicating whether the animation is currently playing.

int spin::ModelNode::getRenderBin ( ) const [inline]

Returns an integer representing the render bin of the node. See setRenderBin for more information.

std::vector< lo_message > spin::ModelNode::getState ( ) const [virtual]

For each subclass of ReferencedNode, we override the getState() method to fill the vector with the correct set of methods for this particular node

Reimplemented from spin::GroupNode.

int spin::ModelNode::getStateRegistration ( ) const [inline]

Returns a boolean indicating whether StateRegistration is set. See setStateRegistration for more information.

void spin::ModelNode::makeCentered ( )

Translate the model so that the centroid is at the local (0,0,0)

void spin::ModelNode::setAttachCentroid ( int  i)

If attachCentroid is enabled, then children will be attached to the centroid of the currently loaded model. If not then it will be attached to this ModelNode's local origin.

void spin::ModelNode::setContext ( const char *  newvalue) [virtual]

The context is an arbitrary keyword that associates this node with a particular behaviour. Currently, it is used to *prevent* display if the context matches the name of a machine. ie, allowing it to be seen on all machines except for the one that is named by setContext.

Reimplemented from spin::ReferencedNode.

void spin::ModelNode::setKeyframe ( int  index,
float  keyframe 
)

Control the keyframe of a particular animation saved within the model (there can be several animations, hence the required index number)

void spin::ModelNode::setLighting ( int  i)

This lets you enable or disable the lighting for the entire model, BUT, really this should be done in individual statesets and can be overridden

void spin::ModelNode::setModelFromFile ( const char *  filename)

Load a 3D model from a file (eg, .osg, .3ds, .obj, .dae, etc). Make sure that StateRegistration flag is set if you want to have control over any textures or shaders withing the model

void spin::ModelNode::setPlaying ( int  index,
int  playState 
)

Set the playing state of a particular animation (paused by default)

void spin::ModelNode::setRenderBin ( int  i)

Render bins allow you to control drawing order, and manage Z-fighting. The higher the number, the later it gets processed (ie, appears on top). Default renderBin = 11

void spin::ModelNode::setStateRegistration ( int  i)

The StateRegistration flag should be set if you want any textures or shaders to be parsed out when loading a model. Any statesets found in the file will generate corresponding ReferencedStateSets for use within SPIN. This way, you'll be able to swap textures, control videos, adjust shader parameters, etc.

void spin::ModelNode::setStateSet ( int  index,
const char *  replacement 
)

For statesets embedded in the model, it is possible to swap with some other (already existing) stateset.

Note: for this to work, stateRegistration must be enabled.

void spin::ModelNode::updateNodePath ( bool  updateChildren = true) [virtual]

We change our attachmentNode (add attachment to the centroid), so we MUST override updateNodePath(), and manually push the centroid transform onto the currentNodePath_.

Reimplemented from spin::GroupNode.

void spin::ModelNode::updateStateSet ( ) [virtual]

This method actually applies the stateset to the subgraph, replacing any existing stateset with this one. The setStateSet and setStateSetFromFile methods just set the stateset_ symbol, while updateStateSet does the actual work.

Override this method in subclasses in order to change how stateset should be applied. For example, to which node in the subgraph it should be attached, or whether it should be merged with the existing stateset (rather than merged).

By default it is applied to the mainTransform_.

Reimplemented from spin::GroupNode.


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