The track view of 3ds Max provides a view into time. Track view is organized as a nested hierarchy showing both parent/child relationships, and sub-anim (parameter) relationships.
Many different plugin types may participate in track view. For example, system plugins, sound object plugins, and many controller types all may have interfaces in track view. The methods of the Animatable
class allow a developer to participate. This section is an overview of the concepts of track view, and an outline of the specific methods involved in providing an interface.
The track view provides a hierarchical view of the scene. All controllers appear in the track view as children of the objects they control. For example, every node has a transform controller and this controller appears under the node in the track view. Also, procedural objects and modifiers appear in the track view. If these have animatable parameters, the controllers plugged in to those parameters appear underneath the object or modifier. If a controller itself has animatable parameters, then any controllers plugged into those parameters would be found underneath it in the track view.
On the right side of each item in the track view there is a long horizontal track window. In this window, a controller can represent the track it controls. For example, a keyframe controller draws marks in the track representing points in time that have keyframes. Other procedural controllers may only present a time line displaying the duration of the animation.
Each controller is also able to display a function curve. This may or may not be editable by the user depending on the type of controller. For example, the standard keyframe controllers allow the user to edit the function curve while the expression controller simply displays a graph of the function that the user specified. The user has the ability to overlay function curves for different controllers on top of each other, regardless of the types of the controllers. For example, the user could place a function curve that represents the red component of a spotlight on top of the function curve that represents the position along a path of one of the nodes in the scene and edit the two.
In addition to function curves and tracks, a modal dialog may be brought up by the controller that contains additional parameters which the user can edit.
By default an animatable (controller, parameter, etc.) will appear in track view. If the animatable should not, the method Animatable::BypassTreeView()
can be overridden to return TRUE
This method indicates to the system that this item should not appear in the track view. Note: Track View was formally referred to as Tree View. The default implementation returns FALSE, so items will appear unless this method is implemented to return TRUE.
There are two types of copy and paste in track view. These are available using two buttons in track view dialog. There is the Copy Controller button, and in Edit Time Mode, there is the Copy Tracks button.
Copy Controller lets the user copy the entire controller plugin. A method of Animatable
is available to prevent an item from being copied.
virtual BOOL CanCopyAnim()
If an animatable doesn't want to be copied in track view it can return FALSE from this method, otherwise it can return TRUE.
Copy Tracks lets the user select a block of time and copy keys. An item (usually a controller) can participate in the copy and pasting of tracks. To indicate that it will participate in copying, a controller implements the following method and returns TRUE:
virtual BOOL CanCopyTrack(Interval iv, DWORD flags)
Returns TRUE if this item can copy its data over the specified range; otherwise returns FALSE.
If a plugin can copy its track data, the following method will be called to allow the item to do so:
virtual TrackClipObject *CopyTrack(Interval iv, DWORD flags)
This method is called to copy the item's track data over the specified interval. A plugin should derive a class from the TrackClipObject
base class to store the data associated with the objects tracks, and implement the methods that identify the creator of the clip object.
When the user has asked to paste the track, the system will call the following method to see if the track data can be pasted to the item.
virtual BOOL CanPasteTrack(TrackClipObject *cobj,Interval iv, DWORD flags)
Returns TRUE if this item can paste its data over the specified range; otherwise returns FALSE. The item can check the TrackClipObject
creator and see if the data is appropriate for it to accept.
If the data is okay, the following method will be called to paste the data from the TrackClipObject
to the item.
virtual void PasteTrack(TrackClipObject *cobj,Interval iv, DWORD flags)
This method is called to paste the specified clip object to this track. This method will not be called unless CanPasteTrack()
returned TRUE.
This section shows several of the methods of Animatable
that relate to the manipulation of time in track view:
Animatable::SupportTimeOperations()
- If an item supports time operations in the track view (cut, copy, paste, etc.), it should implement this method to return TRUE. When it is FALSE the user cannot select blocks of time in the item's track.
Animatable::DeleteTime()
- This method is called to delete the specified interval of time (or the keys within the interval).
Animatable::ReverseTime()
- This method is called to reverse the data within the specified interval.
Animatable::ScaleTime()
- This method is called to scale an interval of time by the specified scale factor.
Animatable::InsertTime()
- This method is called to insert the specified amount of time at the specified insertion point.
This section discusses how an item may display and hit test itself in the track and function curve modes of track view.
To indicate the amount of space it needs to draw itself, the item implements the following method:
virtual int GetTrackVSpace(int lineHeight) - Returns the vertical space occupied by the track in units of one line.
An item may have a custom appearance for itself in the track view. It does this custom drawing in its implementation of the following method:
virtual int PaintTrack(HDC hdc,Rect& rcTrack, Rect& rcPaint, float zoom, int scroll, DWORD flags) - This method is called to display the item in the track view. If an item needs to draw itself in a special fashion, it implements this method to do so. For example, a sound plugin may draw its waveform using this method. If an item does not need to draw itself, the default implementation may be used. This draws the range bar for the item in the track instead.
virtual int HitTestTrack(TrackHitTab& hits, Rect& rcHit,Rect& rcTrack, float zoom,int scroll,DWORD flags) -
The next method is used to hit test a track. Hit testing is checking to see which keys have been selected by the user. This selection may be a single pick point or a dragged rectangular region. This method is passed a table of TrackHitRecords
to update. Each key that lies within the hit rectangle (is hit) should be added to this table.
This method is called to determine which keys lie within the rcHit
rectangle. Keys that are hit are added to the hits
table.
When the user has selected Function Curve mode, 3ds Max displays the item in a graph with time along the horizontal axis and the value of the item along the vertical axis. An item can draw itself in track view in any way it wishes. It does so by implementing the following method:
virtual int PaintFCurves(ParamDimensionBase *dim, HDC hdc, Rect& rcGraph, Rect& rcPaint, float tzoom,int tscroll, float vzoom, int vscroll, DWORD flags)
This method is called to draw the function curve of the item.
There are a set of macros that are handy for scaling time and values into and out of screen space. These are often used in the implementations of PaintFCurve()
and HitTestFCurves()
. See Screen-Time-Value Macros
.
When the user executes zoom extents on the item, this method is called:
virtual int GetFCurveExtents(ParamDimensionBase *dim, float &min, float &max, DWORD flags)
This method is called to calculate the largest and smallest values of the item.
The next method is used to hit test the keys of a function curve. This selection may be a single pick point or a dragged rectangular region. This method is passed a table of TrackHitRecords
to update. Each key that lies within the hit rectangle (is hit) should be added to this table.
virtual int HitTestFCurves(ParamDimensionBase *dim, TrackHitTab& hits, Rect& rcHit, Rect& rcGraph, float tzoom, int scroll, float vzoom,int vscroll, DWORD flags)
This method is called to hit test the item's function curves. It is called to determine which keys on the curve lie within the rcHit
rectangle. Keys that are hit are added to the hits
table.
3ds Max maintains a reference to every sub-anim in the track view. This is how track view monitors if the sub-anim is changing. This reference is created when the sub-anim appears in track view, and is deleted when the sub-anim is no longer shown.
This section has provided an overview of many of the methods related to participating in track view. The main methods developers must use to work with keys, time ranges, function curves, and copying/pasting operations were discussed. The primary methods associated with track view are from class Animatable
. See this class for more detailed information on the methods presented above as well as the others associated with track view.
-