Time Functions

3DS Max Plug-In SDK

Time

See Also: Time Function Reference.

This section discusses the concept of time as used by 3ds max.

Time is stored internally in 3ds max as an integer number of ticks. Each second of an animation is divided into 4800 ticks. This value is chosen in part because it is evenly divisible by the standard frame per second settings in common use (24 -- Film, 25 -- PAL, and 30 -- NTSC).

The data type used to store a specific instance of time is the TimeValue. A TimeValue stores the number of ticks the time represents. When a developer specifies time to almost all the functions in the SDK they use TimeValues.

In MAX, time may be displayed in one of four formats. These are just display formats (the internal representation never changes). The formats are:

Frames - Integer number of frames.

SMPTE - SMPTE time code. This format uses hours:minutes:seconds:frames. 3ds max abbreviates this by not including the hours designation to minutes:seconds.frames.

FRAME:TICKS - Integer number of frames:number of ticks.

MM:SS:TICKS - Minutes:Seconds:Ticks.

A developer may get and set the current time displayed format. The functions to accomplish this are GetTimeDisplayMode() and SetTimeDisplayMode(). When these settings are changed a message is sent throughout 3ds max to handle updating any UI controls that reflect time settings (including plug-in custom controls).

A developer can retrieve the number of ticks per frame using the function GetTicksPerFrame(), and can set this number using SetTicksPerFrame().

A developer can also get and set the current frame rate. This is the number of frames per second. The functions for this are GetFrameRate() and SetFrameRate(). This is just an alternate way to specify the number of ticks per frame.

There are also functions to convert between the numeric and ASCII representations of time. The functions for this are TimeToString() and StringToTime().

To review the methods discussed above see Time Function Reference.

Note that some methods related to time are part of various interface classes. For example Class Interface provides methods to retrieve the current frame slider setting and the current animation range. These methods are GetTime() and GetAnimRange(). You can also set these using SetTime() and SetAnimRange(). There is also a method RegisterTimeChangeCallback() that allows a plug-in to be notified every time the user changes the frame slider.