Send TimeSensor output events, without actually activating the TimeSensor.
This is useful in situations when you want the X3D scene state to reflect given time, but you do not want to activate sensor and generally you do not want to initialize anything that would continue animating on it's own.
Note: We ignore TimeSensor.loop (FdLoop) field, instead we follow our own ALoop parameter. We also ignore TimeSensor.fractionIncreasing field, instead we follow our own AFractionIncreasing parameter. We also ignore TimeSensor.enabled field, assuming that you always want to behave like it's enabled (in particular, this makes TCastleSceneCore.ForceAnimationPose always working, even if TCastleSceneCore.PlayAnimation set enabled = false on previously-stopped animation).
We take into account TimeSensor.cycleInterval (FdCycleInterval), just like during normal TimeSensor behavior. We send out isActive:=true, fraction_changed, elapsedTime and time X3D output events, and they should drive the rest of animation.
About the TimeOfEvents parameter:
In X3D, if you send a message (which is what happens when various X3D nodes communicate, e.g. TimeSensors send messages to interpolators) the message will be ignored if it already passed through the same route (TX3DRoute) with the timestamp >= than current. This is a simple mechanism to avoid route loops in X3D.
It means you need to use increasing time each time you initiate an X3D event.
The implementation of FakeTime without TimeOfEvents parameter solves it by using an internal, always increasing, time value. It will work, but only if you don't process events in your X3D graphs by any other means than this FakeTime time call.
In general case, when using FakeTime together with TCastleScene that has active events (TCastleSceneCore.ProcessEvents = True ), you should call overloaded TTimeSensorNode.FakeTime with TimeOfEvents parameter. Use MyScene.NextEventTime as the value of TimeOfEvents . NextEventTime internally returns current time, and also increases it by some special epsilon used only for comparison.
|