Candy
|
The FiniteStateMachine node provides state machine functionality through programmable states and transitions. More...
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 () |
![]() | |
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::SFInt32 > | stateId |
![]() | |
std::auto_ptr< H3D::MFInt32 > | stateIds |
![]() | |
std::auto_ptr< H3D::SFString > | stateName |
![]() | |
std::auto_ptr< H3D::MFString > | stateNames |
![]() | |
std::auto_ptr< H3D::SFBool > | deterministic |
![]() | |
std::auto_ptr< H3D::SFBool > | persistent |
![]() | |
Static Public Attributes | |
static H3D::H3DNodeDatabase | database |
Friends | |
struct | StateNames |
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.
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.
automation
, the root, containing instances of state
and transition
state
, specifies a state, requires an id
or name
attribute. May contain one or several event
tagstype
, the type of the state. One of: normal (default), start (the initial state) or accept (final state)id
, a numerical identificationname
, a string identificationtransition
, a (conditioned) transition from one state to another. Should contain a condition and may contain an event
. If there is no condition, this transition will always be activefrom
, the id or name of the state this transition is fromto
, the id or name of the state this transition is toevent
, an event producing some output, must have at least field
and type
, and either field2
or value
specifiedtrigger
, the trigger that activates the output. One of: entry (activated when the state is entered, default), exit (triggered when the state is left), start (triggered if the state is born), or accept (triggered if the state dies)field
, the output field that is set to a value by this eventfield2
, the value of this field is copied to the output field, if presentvalue
, this value is copied to the output field, if field2 is not specifiedtype
, the type of the output (and input) field(s). One of: "string", "int", "float", "double" or "bool"and
, or
, xor
, not
eq
(equal), leq
(less or equal), geq
(greater or equal), gt
(greater than), lt
(less than)type
, the type of the field(s) to be compared. One of: string, int, float, double or boolfield
, the field to comparefield2
, the field to compare with (optional)value
, the value to compare with (optional)timer
, provides a delay controlled conditiondelay
, the delay before this condition becomes truefield
, an SFFloat
field with output value between zero and one over the delay of this timerX3D Interface | ||||
Name | Type | Default value | Description | |
![]() | 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. |
std::auto_ptr< H3D::SFBool > Candy::FiniteStateMachine::deterministic |
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 |
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 |
The id of the first active state.
Use this for a deterministic state-machine.
std::auto_ptr< H3D::MFInt32 > Candy::FiniteStateMachine::stateIds |
The id of all active state.
std::auto_ptr< H3D::SFString > Candy::FiniteStateMachine::stateName |
The name of the first active state.
Use this for a deterministic state-machine.
std::auto_ptr< H3D::MFString > Candy::FiniteStateMachine::stateNames |
The names of all active states.