» Back To Index
Demoniak3D/LUA API: Motion-paths Management library
The
HYP_MotionPath library performs general operations on motion-paths.
HYP_MotionPath.GetValueByTime
HYP_MotionPath.GetObjectCurrentTime
HYP_MotionPath.Attach
Attach
Attach allows to attach a motion-path to an object (model, mesh, light, gizmo, camera).
Syntax
HYP_MotionPath.Attach( object_name, motion_path_name, time_offset, time_step );
- object_name - [STR127] - name of the object to which you wish to attach a motion-path.
- motion_path_name - [STR127] - name of the motion path.
- time_offset - [CLAMPED_REAL] - initial value of the time offset. Put 0.0 to start at the beginning of the motion-path (1.0 corresponds to the end of the motion-path).
- time_step - [CLAMPED_REAL] - value of the increment along the motion-path.
With each frame, the object moves time_step on motion-path.
Example
-- test de HYP_SetMotionPath.
HYP_MotionPath.Attach( "light01", "main_motion_path", 0.0, 0.0001 );
Remark
To detach a motion-path from an object, just replace the name of the motion-path by the "NULL" character string
HYP_SetMotionPath( "light01", "NULL", 0.0 );
GetValueByTime
GetValueByTime makes it possible to get the 3d position of a point on the motion-path for a "t"
standardized time (ranging between 0.0 and 1.0).
This function is useful because it is not necessary to attach a motion-path to an object
so that it moves along the motion-path.
This can apply to any object whose position can be changed (via LUA), just by declaring a motion_path node
in the XML script.
Syntax
x, y, z = HYP_MotionPath.GetValueByTime( motion_path_name, time );
- motion_path_name - [STR127] - name of the motion path.
- time - [CLAMPED_REAL] - time value. 0.0 is the beginning of the motion-path and 1.0 is the end.
- x - [REAL] - X coordinate of the position
- y - [REAL] - Y coordinate of the position
- z - [REAL] - Z coordinate of the position
Example
time = 0.26;
x, y, z = HYP_MotionPath.GetValueByTime( "main_motion_path", time );
GetObjectCurrentTime
GetObjectCurrentTime makes it possible to get the temporal current position of an object on a motion-path.
This function is useful to know for example the end of the trajectory when a motion path has been attached
with the object.
Syntax
time = HYP_MotionPath.GetObjectCurrentTime( object_name );
- object_name - [STR127] - name of the object.
- time - [CLAMPED_REAL] - time value. 0.0 is the beginning of the motion-path and 1.0 is the end.