DirectX Media for Animation Media Types |
![]() Previous |
![]() TOC |
![]() Index |
![]() Next |
Direct Animation uses continuous temporal and spatial 2D and 3D coordinate systems. The use of continuous coordinate systems provides some key advantages. It removes the difficult problems of device- and resolution-dependence, allows for more portable content, and provides more flexibility to the implementation. However, it doesn't always meet the needs of the programmers. For example, this document later explains how Direct Animation is based on a continuous time model, yet also provides a mechanism with which an application can control the frame generation via application-generated time ticks. Similarly, in spatial coordinates, it is generally the case that the author who imports a GIF or JPEG file would like it to be displayed at the exact resolution at which it was authored and stored. For this reason, the notion of a pixel is supported in Direct Animation, not as part of the model, but as a convenience for situations such as these.
We will begin with the units of measure used for the Direct Animation coordinate systems. The base spatial unit of measure is the meter (It should be pointed out that the physical units described here can only be approximations to what actually appears on the screen. For instance, the implementation of Direct Animation does the best job it can to ensure that 1 unit is actually one meter in physical space, but variables such as monitor curvature and controls on the monitor that change the display area always prevent this from being completely accurate. How is the pixels/inch measure obtained? What happens when the user changes the resolution?) and the temporal unit is the second. Direct Animation also provides a number of pre-defined constants that can be used as multipliers to transition to other units. The complete list of these constants can be found in the DirectX Media for Animation Reference. Here is a sampling:
For example, the following expression translates an image, img, 5 centimeters in x in its local coordinate system:
// mult(toBvr(5), cm) is simply 5cms img.transform(translate(mult(toBvr(5), cm), 0));
This syntax is somewhat complicated because Java doesn't support automatic type casting nor operator overloading. In C++ this expression could be made to look like (5*cm).
To determine the coordinates, in inches, of the bounding box of an image, divide by inch:
Bbox2Bvr bboxMeters = img.boundingBox(); Point2Bvr minInches = Point2Bvr(div(bboxMeters.getMin().getX(), inch), div(bboxMeters.getMin().getY(), inch)); Point2Bvr maxInches = Point2Bvr(div(bboxMeters.getMax().getX(), inch), div(bboxMeters.getMax().getY(), inch));
In general, to convert a value into meters, for consumption by the system, multiply by its unit (for example, mult(toBvr(5), cm). To convert a value from meters for consumption by the application, divide by its unit, as in the example.
Given that pixel size differs from one display to another and even across different settings of the same display device, Direct Animation provides a built-in constant, akin to cm, inch, and foot called pixel, which is the dimension of a pixel in meters. (This constant is a scalar because we have a square pixel.)
This constant allows an author to precisely coordinate synthetic imagery with imported bitmaps regardless of the display resolution. For more information see the section on 2D/3D interplay below.
© 1997 Microsoft Corporation. All rights reserved. Legal Notices.