DirectX Media for Animation Programmer's Guide |
![]() Previous |
![]() TOC |
![]() Index |
![]() Next |
The previous sections on behaviors describes the ways in which time and events can be injected into behaviors of any type. We will now discuss the specific media data types that are included in Direct Animation and the the operations available on these data types.
The Direct Animation runtime provides high-performance support for many common multimedia tasks. We will now give an overview of the different media types and the operations that can be performed on them.
There are operations both for creating and composing animated 2D images. These operationsare described below.
Creating Animated Images
The operations for creating animated 2D images include:
Composing Animated Images
The operations for composing animated 2D images include:
There are operations both for creating and composing animated montages. These are described below.
Creating Animated Montages
The single operation for creating animated montages is:
Combining Montages
The operations for combining montages include:
There are operations both for creating and composing 3D geometric animations. These are described below..
Creating Animated Geometry
The operations for creating animated geometry include:
Composing 3D Geometric Animations
The operations for composing 3D geometric animations include:
There are operations both for creating and composing dynamically animated sounds. These operations include:
Creating Dynamically Animated Sounds
Composing Dynamically Animated Sounds
The operations for composing dynamically animated sounds include:
Note that the phrase "composition of any sequence of the above operations on any source of XXX in any order" appears multiple times in the above categories. This is one of the most important features of the media operations available in Direct Animation. They are completely composable. This provides surprising flexibility, expressiveness, and power even with a relatively small number of base operations.
As an example, because transparency, arbitrary polygonal clipping, overlaying, and transformation are all operations on Images, one can consider taking an image, modifying its opacity, transforming it, overlaying it on top of another transformed image, taking this composition and transforming this, clipping it to a polygonal boundary, making it somewhat more transparent, and so on.
Of course, any and all components of these compositions can be animated and/or interactive.
The following tables summarizes the animation classes available in Direct Animation:
Category | Media type | Description |
2d/3d | image | Animated images, including cel animation, bitmaps in industry-standard formats, vector graphic animations, animated 3D projections, partially transparent images ("alpha blending"), animated rotation and linear deformation, animated textures for 3D animated geometry, adaptive-resolution rendering, etc. The breadth and power of Direct Animation's composition engine are among its greatest competitive strengths. |
2d/3d | color | Animated color values in an abstract color space. The runtime supports all color bit depths. |
2d | matte | Stencils for creating animated cutouts in images. |
2d | montage | 2.5D layered animated images with depth ordering. |
2d | path2 | Animated 2D vector graphics (2D geometry) |
2d | point2, vector2 | Animated 2D points and directed magnitudes |
2d | transform2 | Animated scaling, rotation, shearing and translation in 2D |
3d | transform3 | Animated scaling, rotation, shearing and translation in 3D |
3d | camera | Movie camera to turn a 3D scene into an animated image. All camera attributes may be animated |
3d | geometry | 3D faceted geometry, used for 3D animation. The import of .X files and VRML 1.0 geometry is supported. |
3d | point3, vector3 | Animated 3D points and directed magnitudes |
sound | microphone | Used to spatialize sound in a dynamic 3D environment |
sound, 3d | sound | Audio, which may be spatialized in 3D. Properties of the audio stream such as gain may be animated. Includes MIDI. |
text | Fontfamily | Simple fonts. This will be extended to include full access to the TrueType rasterizer. |
text | string | Strings of characters |
text | text | Strings of characters with animated rendering attributes |
To reiterate, all attributes of all media in the system can be animated and can react to events. This property is one of Direct Animation's distinguishing, fundamental tenets.
In Direct Animation, methods for constructing media values (images, geometry, points, and so on) are typically exposed for using "canonical" versions of the data types. Some examples include:
This approach minimizes the replication of extraneous parameters. We don't need to define image importation, simple text, the light constants, and squarePath to take a position and size parameter. As a result, the interface is both simpler to learn and more consistent.
This section describes the subtypes of behavior and the general operations available on each of them. All of these subtypes support the generic until, untilNotify, snapshot, and run methods.
The following sections discuss each type, and how instances of the types are created. The reason to use a given type may not be apparent upon initial reading, but should become clear as some of the other types are described. For instance, being able to construct a Transform2Bvr isn't too interesting until you know that you can transform an ImageBvr with a Transform2Bvr.
Recall again that each of these behaviors is potentially time-varying and can react to events.
The BooleanBvr is a time-varying, reactive true/false value. Traditional boolean operations such as and, or, and not are available, although, in Direct Animation,they operate on behaviors.
NumberBvr represents a time-varying floating point number. A NumberBvr can be constructed by using the toBvr method on a Java number. Many arithmetic methods are available.: These include, for example,, adding, subtracting, multiplying, dividing, exponentiation, sine, cosine, random number sequences, integral and derivative. Additionally, the time-varying seeds for animation, localTime and globalTime, are NumberBvrs.
StringBvr is a time-varying string. It can be constructed from a Java string. Simple operations such as concatenation are available on it.
ColorBvrs can be constructed by supplying three NumberBvrs that can be interpreted as either Red/Green/Blue or as Hue/Saturation/Lightness. NumberBvr's can be extracted out of colors to access components of the color, either in RGB space or HSL space.
Point2Bvr represents a position in the 2D coordinate system. Vector2Bvr represents a direction and magnitude in the 2D coordinate system. Either can be constructed by supplying two NumberBvrs that can be interpreted either as Cartesian coordinates or polar coordinates. Available operations include subtracting points to yield a vector, adding a vector to a point, determining the distance between points, taking the integral of a vector with respect to time, or the derivative of either a point or a vector.
Transform2Bvr represents a spatial 2D transformation. Transformations can be constructed from translations, uniform and non-uniform scales, rotations, shears, 3x2 matrices, and composition of other Transform2Bvrs.
A Path2Bvr represents a one-dimensional path through two-dimensional space. It is of zero-width, has a direction, and can be open or closed. In essence, it is a curve through 2D space. It can be constructed as a series of connected line segments (polyline), as a b-spline curve, as a concatenation of other paths, or as a 2D transformation of another path.
A MatteBvr represents a 2D stencil used to clip images to arbitrary regions. It can be constructed by filling in a Path2Bvr, by constructing it from a text outline, and by performing logical operations (such as union, intersection, and difference) on other mattes.
The ImageBvr is the primary 2D data type. It is, conceptually, a mapping from 2D-space to a (color, opacity, detectability) tuple. Regions where opacity is 0 are invisible. Regions where detectability is false are not detectable under interaction. Because it is a mapping from 2D-space, it is of infinite extent, and of infinite resolution. It does not inherently contain a notion of pixels.
Note There is a need for a datatype, such as PixelMapBvr, which is inherently discrete, for which pixel-level operations are appropriate.
Images are constructed by importing GIFs, BMPs, JPEGs, and so on. Because, like all behaviors, an ImageBvr can be time-varying, importation of a movie (such as an MPEG or AVI file) constructs an ImageBvr. Java AWT Images can also be used to construct a Direct Animation ImageBvr. ImageBvrs are also constructed as solid color images, by rendering of text into an image, by projecting a 3D geometry with a camera into an image, by stroking a line out of a Path2 behavior, and by creating an image by smoothly varying colors across the face of a polygon.
Images are also created by overlaying two existing images, by applying an opacity value (or alpha-value) to an existing image, by clipping an image to a MatteBvr, by cropping an image to a box, by tiling an image, and by applying a Transform2Bvr to an image.
Note also that any ImageBvr, even if it is time-varying, reactive, and interactive, can serve as a texture on a GeometryBvr.
PickableImageBvr
The PickableImageBvr is a subclass of ImageBvr, is constructed from an ImageBvr, and provides an event that occurs when the mouse is over the underlying image. It returns information about the mouse's intersection point with the image and about the behavior of the mouse subsequent to the intersection. All this information is expressed in the local modeling coordinates of the image.
The MontageBvr is a 21/2-D layering of ImageBvrs. It is constructed by providing an image and a potentially time-varying number as the depth value, and by uniting the montages together. The "render" method on a MontageBvr resolves all the depths and constructs an ImageBvr.
Point3Bvr and Vector3Bvr are the 3D analogs of Point2Bvr and Vector2Bvr.
Transform3Bvr is the 3D analog to Transform2Bvr.
The GeometryBvr is the primary 3D data type. It is a spatially continuous behavior of infinite spatial extent in three dimensions. Conceptually, one can think of a geometry as being a mapping from an (x,y,z) triple representing an arbitary point in 3-space, to a (color, normal, texture coordinate, opacity, detectability) tuple for points on the surface of the geometry.
A geometry value is constructed by importing other VRML or .X files, by applying modeling transformations to existing geometries, by applying material properties to geometries, by aggregating multiple geometries, by embedding sound into 3D, by using specifying 3D lights, by applying ImageBvrs as textures, by varying opacity, and so on.
Furthermore, given a CameraBvr to represent, a GeometryBvr can be projected onto an ImageBvr.
PickableGeometryBvr
The PickableGeometryBvr is a subclass of GeometryBvr, is constructed from a GeometryBvr and provides an event that occurs when the mouse is over the projection of the underlying geometry. It returns information about the intersection point and about the behavior of the mouse subsequent to the intersection, both in the local modeling coordinates of the geometry.
A CameraBvr represents a synthetic camera in 3-space that is used with the render method on GeometryBvr to project a geometry onto an ImageBvr.
The SoundBvr is the primary audio data type. Conceptually, it represents a continuous audio waveform of infinite length. Internally, of course, it is represented with digital waveform data and other audio representations. A SoundBvr is constructed by importing audio files such as WAV and AU files; by importing MIDI files; by applying methods to affect gain, phase, frequency, and pan; by mixing existing SoundBvrs. Also, limited audio synthesis is supported.
A SoundBvr can be embedded into geometry, and geometry can be "rendered" with a microphone to produce a spatialized SoundBvr.
The MicrophoneBvr is a synthetic microphone in 3-space that is used with the render method on a GeometryBvr to extract a spatialized sound from that geometry and produce a SoundBvr.
This very simple enumerated behavior provides for the fonts that are accessible via Direct Animation.
A TextBvr is a string with text rendering attributes. TextBvrs can be concatenated, emboldened, italicized, colored, and have associated FontfamilyBvrs. Of course, all of these attributes can be time-varying behaviors.
The LinestyleBvr provides for dashing, line width, line end, and line join styles when a Path2Bvr is being stroked into an ImageBvr.
Direct Animation also supports behavior splines. These are effectively animation paths for numbers, 2D points and vectors, and 3D points and vectors. The paths can be linear, quadratic, or cubic b-splines, both rational and non-rational. In Direct Animation, a behavior spline is constructed by supplying an array of knots, control points, and, if rational, weights (all of which themselves are behaviors and are potentially time varying). This directly creates either a NumberBvr, Point2Bvr, Point3Bvr, Vector2Bvr, or Vector3Bvr. The resultant behavior is implicitly parameterized by time, meaning that it ties the spline parameter to localTime, starting at 0, increasing at one unit per second. Time substitution canbe used to change this parameterization.
© 1997 Microsoft Corporation. All rights reserved. Legal Notices.