35 #include <libFreeWRL.h>
37 #include "../vrml_parser/Structs.h"
38 #include "../vrml_parser/CRoutes.h"
39 #include "../main/headers.h"
40 #include "../input/SensInterps.h"
80 void do_TimeSensorTick (
void *ptr) {
90 if(node->__inittime == 0.0)
91 node->__inittime = TickTime();
93 if (node->__oldEnabled != node->enabled) {
94 node->__oldEnabled = node->enabled;
95 MARK_EVENT(X3D_NODE(node),offsetof (
struct X3D_TimeSensor, enabled));
106 if(TickTime() < node->startTime) {
110 oldstatus = node->isActive;
111 duration = node->cycleInterval;
137 &node->isActive, &node->__inittime, &node->startTime,
138 &node->stopTime,node->loop,duration, 1.0,node->elapsedTime);
143 if (oldstatus != node->isActive) {
144 if (node->isActive == 1) {
146 node->__ctflag = 10.0;
147 node->__lasttime = TickTime();
148 node->elapsedTime = 0.0;
156 if(node->pauseTime > node->startTime){
157 if( node->resumeTime < node->pauseTime && !node->isPaused){
158 node->isPaused = TRUE;
159 MARK_EVENT (X3D_NODE(node), offsetof(
struct X3D_TimeSensor, isPaused));
160 }
else if(node->resumeTime > node->pauseTime && node->isPaused){
161 node->isPaused = FALSE;
162 node->__lasttime = TickTime();
163 MARK_EVENT (X3D_NODE(node), offsetof(
struct X3D_TimeSensor, isPaused));
168 if(node->isActive == 1 && node->isPaused == FALSE) {
170 node->time = TickTime();
172 node->elapsedTime += node->time - node->__lasttime;
173 node->__lasttime = node->time;
176 myFrac = node->elapsedTime / duration;
178 frac = myFrac - (int) myFrac;
180 frac = (myFrac > 1 ? 1 : myFrac);
184 printf (
"TimeSensor myFrac %f frac %f dur %f\n", myFrac,frac,duration);
188 if (frac < node->__ctflag) {
190 node->cycleTime = TickTime();
193 node->__ctflag = frac;
195 node->fraction_changed = (float) frac;
196 MARK_EVENT (ptr, offsetof(
struct X3D_TimeSensor, fraction_changed));