Generates events as time passes. More...
#include <Inventor/VRMLnodes/SoVRMLTimeSensor.h>
Public Member Functions | |
SoVRMLTimeSensor () | |
Static Public Member Functions | |
static void | enableEvents (SbBool OnOffFlag) |
static SbBool | isEventsEnabled () |
Public Attributes | |
SoSFTime | cycleInterval |
SoSFBool | enabled |
SoSFBool | loop |
SoSFTime | pauseTime |
SoSFTime | resumeTime |
SoSFTime | startTime |
SoSFTime | stopTime |
SoVRMLTimeSensors generate events as time passes. SoVRMLTimeSensors can be used to drive continuous simulations and animations, periodic activities (e.g., one per minute), and/or single occurrence events such as an alarm clock.
NOTE: This class does not exist in Open Inventor 10.0 and later.This section may reference portions of the VRML97 specification that are not present in this help file. The complete VRML97 spec is available at http://www.web3d.org .
SoVRMLTimeSensors generate events as time passes. SoVRMLTimeSensors can be used to drive continuous simulations and animations, periodic activities (e.g., one per minute), and/or single occurrence events such as an alarm clock. SoVRMLTimeSensor discrete eventOuts include: isActive , which becomes TRUE when the SoVRMLTimeSensor begins running, and FALSE when it stops running, and cycleTime , a time event at startTime and at the beginning of each new cycle (useful for synchronization with other time-based objects). The remaining outputs generate continuous events and consist of fraction_changed , which is an SFFloat in the closed interval [0,1] representing the completed fraction of the current cycle, and time , an SFTime event specifying the absolute time for a given simulation tick.
If the enabled exposedField is TRUE, the SoVRMLTimeSensor is enabled and may be running. If a set_enabled FALSE event is received while the SoVRMLTimeSensor is running, then the sensor should evaluate and send all relevant outputs, send a FALSE value for isActive, and disable itself. However, events on the exposedFields of the SoVRMLTimeSensor (such as set_startTime) are processed and their corresponding eventOuts ( startTime_changed) are sent regardless of the state of enabled. The remaining discussion assumes enabled is TRUE.
The loop, startTime, and stopTime exposedFields, and the isActive eventOut and their affects on the SoVRMLTimeSensor node, are discussed in detail in the "Concepts - Time Dependent Nodes" section. The "cycle" of an SoVRMLTimeSensor lasts for cycleInterval seconds. The value of cycleInterval must be greater than 0 (a value less than or equal to 0 produces undefined results). Because the SoVRMLTimeSensor is more complex than the abstract SoVRMLTimeDep node and generates continuous eventOuts, some of the information in the "Time Dependent Nodes" section is repeated here.
A cycleTime eventOut can be used for synchronization purposes, e.g., sound with animation. The value of a cycleTime eventOut will be equal to the time at the beginning of the current cycle. A cycleTime eventOut is generated at the beginning of every cycle, including the cycle starting at startTime. The first cycleTime eventOut for an SoVRMLTimeSensor node can be used as an alarm (single pulse at a specified time).
When an SoVRMLTimeSensor becomes active it will generate an isActive = TRUE event and begin generating time , fraction_changed, and cycleTime events, which may be routed to other nodes to drive animation or simulated behaviors - (see below for behavior at read time). The time event outputs the absolute time for a given tick of the SoVRMLTimeSensor (time fields and events represent the number of seconds since midnight GMT January 1, 1970). fraction_changed events output a floating point value in the closed interval [0, 1], where 0 corresponds to startTime and 1 corresponds to startTime + N*cycleInterval, where N = 1, 2, ... . That is, the time and fraction_changed eventOuts can be computed as:
time = now f = fmod(now - startTime, cycleInterval) if (f == 0.0 && now > startTime) fraction_changed = 1.0 else fraction_changed = f / cycleInterval
A SoVRMLTimeSensor can be set up to be active at read time by specifying loop TRUE (not the default) and stopTime <= startTime (satisfied by the default values). The time events output absolute times for each tick of the SoVRMLTimeSensor -- times must start at startTime and end with either startTime+cycleInterval, stopTime, or loop forever depending on the values of the other fields. An active SoVRMLTimeSensor must stop at the first simulation tick when time now >= stopTime > startTime.
No guarantees are made with respect to how often an SoVRMLTimeSensor will generate time events, but an SoVRMLTimeSensor should generate events at least at every simulation tick. SoVRMLTimeSensors are guaranteed to generate final time and fraction_changed events. If loop is FALSE, the final time event will be generated with a value of (startTime+cycleInterval) or stopTime (if stopTime > startTime), whichever value is less. If loop is TRUE at the completion of every cycle, then the final event will be generated as evaluated at stopTime (if stopTime > startTime) or never.
An active SoVRMLTimeSensor ignores set_cycleInterval , and set_startTime events. An active SoVRMLTimeSensor also ignores set_stopTime events for set_stopTime < startTime. For example, if a set_startTime event is received while an SoVRMLTimeSensor is active, then that set_startTime event is ignored (the startTime field is not changed, and a startTime_changed eventOut is not generated). If an active SoVRMLTimeSensor receives a set_stopTime event that is less than now and greater than or equal to startTime, it behaves as if the stopTime requested is now and sends the final events based on now (note that stopTime is set as specified in the eventIn).
cycleInterval | 1 |
enabled | TRUE |
loop | FALSE |
pauseTime | 0 |
resumeTime | 0 |
startTime | 0 |
stopTime | 0 |
metadata | NULL |
SoSFTime | set_cycleInterval |
SoSFBool | set_enabled |
SoSFBool | set_loop |
SoSFTime | set_pauseTime (Note: Not implemented) |
SoSFTime | set_resumeTime (Note: Not implemented) |
SoSFTime | set_startTime |
SoSFTime | set_stopTime |
SoSFNode | set_metadata |
SoSFTime | cycleTime |
SoSFFloat | fraction_changed |
SoSFBool | isActive |
SoSFBool | isPaused (Note: Not implemented) |
SoSFTime | time |
SoSFTime | cycleInterval_changed |
SoSFBool | enabled_changed |
SoSFBool | loop_changed |
SoSFTime | pauseTime_changed (Note: Not implemented) |
SoSFTime | resumeTime_changed (Note: Not implemented) |
SoSFTime | startTime_changed |
SoSFTime | stopTime_changed |
SoSFTime | elapsedTime |
SoSFNode | metadata_changed |
SoVRMLTimeSensor::SoVRMLTimeSensor | ( | ) |
Constructor.
static void SoVRMLTimeSensor::enableEvents | ( | SbBool | OnOffFlag | ) | [static] |
Enables/disables events for all SoVRMLTimeSensor objects.
If you have created several objects of this class, you can disable/enable events for all of them with a single call to this method.
static SbBool SoVRMLTimeSensor::isEventsEnabled | ( | ) | [static] |
Queries if events are enabled for all objects of this class.
Time for each cycle in seconds.
Enables (TRUE) or disables (FALSE) the sensor.
Specifies whether a cycle should be repeated (TRUE) or terminated (FALSE) at the end of the cycle.
(Note: Not implemented) Pause time. NOTE: field available since Open Inventor 5.0
NOTE 2: This field is not compatible with VRML97. If you specify a non-default value for this field, when this node is written to a VRML file, the file will contain this incompatible field and standard VRML97 file readers will not be able to read it.
(Note: Not implemented) Resume time. NOTE: field available since Open Inventor 5.0
NOTE 2: This field is not compatible with VRML97. If you specify a non-default value for this field, when this node is written to a VRML file, the file will contain this incompatible field and standard VRML97 file readers will not be able to read it.
Starting time of the cycle.
Stop time of the cycle.