Candy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Classes | Public Member Functions | Public Attributes | Static Public Attributes | Friends | List of all members
Candy::FiniteStateMachine Class Reference

The FiniteStateMachine node provides state machine functionality through programmable states and transitions. More...

Inheritance diagram for Candy::FiniteStateMachine:
Inheritance graph
[legend]

Classes

struct  StateId
 
struct  StateIds
 
struct  StateName
 
struct  StateNames
 

Public Member Functions

 FiniteStateMachine (H3D::Inst< H3D::SFNode > _metadata=0, H3D::Inst< H3D::MFString > _url=0, H3D::Inst< StateId > stateId=0, H3D::Inst< StateIds > stateIds=0, H3D::Inst< StateName > stateName=0, H3D::Inst< StateNames > stateNames=0, H3D::Inst< H3D::SFBool > deterministic=0, H3D::Inst< H3D::SFBool > persistent=0)
 
void initialize ()
 
- Public Member Functions inherited from H3D::H3DDynamicFieldsObject
virtual bool addField (const string &name, const Field::AccessType &access, Field *field)
 
virtual bool removeField (const string &_name)
 
virtual void clearFields ()
 

Public Attributes

std::auto_ptr< H3D::SFInt32stateId
  (output only) The id of the first active state. More...
 
std::auto_ptr< H3D::MFInt32stateIds
  (output only) The id of all active state. More...
 
std::auto_ptr< H3D::SFStringstateName
  (output only) The name of the first active state. More...
 
std::auto_ptr< H3D::MFStringstateNames
  (output only) The names of all active states. More...
 
std::auto_ptr< H3D::SFBooldeterministic
  (input/output) When true, only one state is active at a time. More...
 
std::auto_ptr< H3D::SFBoolpersistent
  (input/output) When true, a state will continue to be active when no path is active, otherwise it will die. More...
 

Static Public Attributes

static H3D::H3DNodeDatabase database
 

Friends

struct StateNames
 

Detailed Description

The FiniteStateMachine node provides state machine functionality through programmable states and transitions.

A state machine takes care of states in anything from compiler programs, file readers and client/server systems to games and applications. A state can be, for example, 'showing menu', 'running game' or 'game over'. By using a central state machine each functionality of the game or application can be individually programmed in separate scripts or systems and by simply reading of the state value, or even recieve events from the state machine, each script can know what to do, if is should be inactive or start doing something.

This node reads a specified XML file with state and transition specifications. Each state is given a specific number id and a string name. This state id or name can be routed from the stateId and stateName fields. If the state machine is non-deterministic multiple states may be active, in which case the full list of ids and names can be routed from the stateIds and stateNames fields.

XML syntax

Here is a reference manual over the XML syntax of the configuration file read by this node. A strict syntax description can be found in the DTD file.

Conditions

X3D Interface

 NameTypeDefault valueDescription
url MFString   ""    
stateId SFInt32      
stateIds MFInt32      
stateName SFString      
stateNames MFString      
deterministic SFBool   True   In a deterministic state machine only one state is active at a time, but in non-deterministic machines every valid state is active at the same time.  
persistent SFBool   True   If the state machine is persistent, states will not die when no transition is available.  
(varying)   ""|0|false   Every event type connected to a state will provide an outgoing field.  
(varying)   ""|0|false   Every transition condition will provide at least one incoming field. Multiple transitions can also be controlled from the same fields.  

Member Data Documentation

std::auto_ptr< H3D::SFBool > Candy::FiniteStateMachine::deterministic

(input/output) When true, only one state is active at a time.

A non-deterministic state-machine (deterministic = false) will have all valid states active at the same time.

std::auto_ptr< H3D::SFBool > Candy::FiniteStateMachine::persistent

(input/output) When true, a state will continue to be active when no path is active, otherwise it will die.

std::auto_ptr< H3D::SFInt32 > Candy::FiniteStateMachine::stateId

(output only) The id of the first active state.

Use this for a deterministic state-machine.

std::auto_ptr< H3D::MFInt32 > Candy::FiniteStateMachine::stateIds

(output only) The id of all active state.

std::auto_ptr< H3D::SFString > Candy::FiniteStateMachine::stateName

(output only) The name of the first active state.

Use this for a deterministic state-machine.

std::auto_ptr< H3D::MFString > Candy::FiniteStateMachine::stateNames

(output only) The names of all active states.