Intervals

3DS Max Plug-In SDK

Intervals

See Also: Class Interval, Advanced Topics section Time.

An Interval is a class that represents a length of time. It has two private data members, start and end, that are each TimeValues. A TimeValue is a single instant in time. For more information on TimeValues see the Advanced Topics section Time.

Intervals are used throughout 3ds max in describing a range of time. The most common use is to describe a range of time over which an item is said to be 'Valid'. This type of interval is referred to as a Validity Interval. It is normally used in association with some item which is cached. The validity interval describes the range of time over which the cache accurately reflects the state of the item. When comparing a given time to see if the cache is up to date, if the time is inside the interval, the cache is valid at that time. If it is outside the interval, the cache is invalid.

The geometry pipeline system of 3ds max uses intervals as part of its caching scheme. Many of the methods procedural object or modifier plug-ins must call or implement (associated with intervals) are required for use with MAX's caching system. In terms of this cache, the interval represents a period of constancy for an item around a certain time. In other words, given a certain time, how far before and how far after the time is the item constant (not changing). Part of the caching algorithm needs to determine if an item is relatively constant or not.

As an example consider a procedural object which is not animated over an entire 100 frame animation. This object would have a validity interval of FOREVER. It is always up to date since nothing ever changes. Then apply a Bend modifier to this object and animate the angle parameter at frame 50. The bent object is now always changing from frame 0 to 50. After frame 50, it never changes. Any validity intervals computed in the first 50 frames would be instantaneous intervals (the start time equal to the end time). Any validity intervals computed at a time after frame 50 would be from 51 to 100.

3ds max may cache a representation of the bent object from frame 51 to 100. It will then never have to re-compute this bent object over this entire range. 3ds max would not cache a representation from frame 0 to 50 since the object is always changing.

Plug-ins must provide 3ds max with information about when they are changing and when they are not. Below are some examples of methods which plug-in procedural objects or modifiers call or implement that return or modify intervals.

GetValue()

This method of IParamBlock has several parameters, one of which is a C++ reference to an Interval. This method is frequently used by developers to 'whittle' down an interval. When a parameter of a parameter block is animated, for any given time there is an interval over which the parameter is constant. If the parameter is constantly changing the interval is instantaneous. If the parameter does not change for a certain period the interval will be longer. If the parameter never changes the interval will be FOREVER. By passing an interval to the GetValue() method of the parameter block you ask the parameter block to 'intersect' the interval passed in with the interval of the parameter. Intersecting two intervals means returning a new interval whose start value is the greater of the two, and whose end value is smaller of the two. In this way, the resulting interval represents a combined period of constancy for the two intervals.

This technique is used frequently to compute a validity interval for an object. The developer starts an interval off as FOREVER, then intersects this interval with each of its animated parameters (by calling GetValue()). GetValue() 'whittles' down the interval with each call. When all the parameters have been intersected, the result is the overall validity interval of an object at a specific time.

Consider the example shown in the diagram below. A validity interval is computed at time 40 for an object with two animated parameters, Radius, and Segments. The interval is computed by first intersecting an initial interval of FOREVER with the Radius parameter. The Radius interval is from 20 to 100. The result of this intersection is the interval from 20 to 100. This interval is intersected with the Segment parameter interval (from 10 to 50). The result of this intersection is an interval from 20 to 50. Thus the validity interval of the object at time 40 is from 20 to 50.

image\finalint_wmf.gif

ObjectValidity(TimeValue t)

This method, implemented by the plug-in, returns the validity interval of the procedural object around the time passed. This method is computed by the object by starting an interval at FOREVER, and intersecting this interval with the intervals of each of its animated parameters. In this way, an interval is whittled down as it is intersected with each of the parameters. The resulting interval represents a period of constancy about the TimeValue passed. The interval represents how far before the TimeValue and how far after it the object is constant.

LocalValidity(TimeValue t)

This method returns the validity interval of the modifier itself around the time passed. In general, this would be the intersection of the validity intervals of all controllers that the modifier uses to control its parameters, so if a modifier was not animated, this interval would be FOREVER.

As an object flows up the pipeline, the validity interval of each modifier is intersected into the object state's validity interval. When the object gets to the end of the pipeline, its validity interval reflects the intersection of all the elements in the pipeline.

GetValidity(TimeValue t)

The SimpleMod class calls this method to retrieve the validity interval of the modifier. The modifier provides this interval by starting an interval at FOREVER and intersecting each parameter of the modifier with the interval. SimpleMod then intersects the validity intervals of its own controllers with the returned interval in its implementation of LocalValidity().

UpdateValidity(int nchan, Interval v)

A modifier calls the UpdateValidity() method of an object. When a modifier is applied to an object, it needs to include its own validity interval. Frequently this is called by the modifier in its ModifyObject() method.

SetChannelValidity(int nchan, Interval v)

This method is called to specify a validity interval for a certain channel of the pipeline.

See also: Class Interval and Geometry Pipeline System in the Reference section.