00001 /* 00002 * This file is part of the "Archon" framework. 00003 * (http://files3d.sourceforge.net) 00004 * 00005 * Copyright © 2002 by Kristian Spangsege and Brian Kristiansen. 00006 * 00007 * Permission to use, copy, modify, and distribute this software and 00008 * its documentation under the terms of the GNU General Public License is 00009 * hereby granted. No representations are made about the suitability of 00010 * this software for any purpose. It is provided "as is" without express 00011 * or implied warranty. See the GNU General Public License 00012 * (http://www.gnu.org/copyleft/gpl.html) for more details. 00013 * 00014 * The characters in this file are ISO8859-1 encoded. 00015 * 00016 * The documentation in this file is in "Doxygen" style 00017 * (http://www.doxygen.org). 00018 */ 00019 00020 #ifndef ARCHON_X3D_TIME_H 00021 #define ARCHON_X3D_TIME_H 00022 00029 #include <archon/x3d/server/core.H> 00030 00031 namespace Archon 00032 { 00033 namespace X3D 00034 { 00038 struct TimeDependentNode: virtual ChildNode, FrameDrivenNode 00039 { 00040 static const NodeType *type; 00041 00042 protected: 00043 TimeDependentNode(): isPaused(false), loop(false), numLoops(1) {} 00044 00045 friend void initializeTimeComponent(); 00046 00047 bool isPaused; // [out] 00048 Time elapsedTime; // [out] 00049 bool loop; // [in,out] FALSE 00050 double numLoops; // [in,out] 1 POSITIVE 00051 Time startTime; // [in,out] 0 00052 Time stopTime; // [in,out] 0 00053 Time pauseTime; // [in,out] 0 00054 Time resumeTime; // [in,out] 0 00055 00056 EventSource isPausedChanged; 00057 EventSource elapsedTimeChanged; 00058 EventSource loopChanged; 00059 EventSource numLoopsChanged; 00060 EventSource startTimeChanged; 00061 EventSource stopTimeChanged; 00062 EventSource pauseTimeChanged; 00063 EventSource resumeTimeChanged; 00064 00065 Time loopStamp; 00066 Time numLoopsStamp; 00067 Time startTimeStamp; 00068 Time stopTimeStamp; 00069 Time pauseTimeStamp; 00070 Time resumeTimeStamp; 00071 }; 00072 00076 struct TimeSensor: TimeDependentNode, SensorNode 00077 { 00078 static Ref<NodeBase> instantiate(BackRef<ExecutionContext> c) 00079 { 00080 return new TimeSensor(c); 00081 } 00082 00083 static const NodeType *type; 00084 const NodeType *getType() const { return type; } 00085 00086 TimeSensor(BackRef<ExecutionContext> c): 00087 NodeBase(c), cycleInterval(1.0), fraction(0) {} 00088 00096 void tick(); 00097 00098 private: 00099 friend void initializeTimeComponent(); 00100 00101 Time cycleInterval; // SFTime [in,out] 1 POSITIVE 00102 Time cycleTime; // SFTime [out] 00103 double fraction; // SFFloat [out] 00104 Time time; // SFTime [out] 00105 00106 EventSource cycleIntervalChanged; 00107 EventSource cycleTimeChanged; 00108 EventSource fractionChanged; 00109 EventSource timeChanged; 00110 00111 Time cycleIntervalStamp; 00112 }; 00113 } 00114 } 00115 00116 #endif // ARCHON_X3D_TIME_H