![]() |
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() |
![]() |
To access the contents, click the chapter and section titles.
Cutting Edge Direct 3D Programming
Direct3DRMAnimationSet: The Animation Set InterfaceAn animation set is a collection of animation objects and is useful for representing entire animated scenes. Typically an animation set is created by importing an animated scene from an animation package such as 3D Studio. Each object in the scene is represented by an animation object, and all of the animation objects make up the animation set. The Direct3DRMAnimationSet interface is used to control animation sets and is created with the Direct3DRM CreateAnimationSet() member function. Loading Animation SetsAnimation sets are loaded using the Direct3DRMAnimationSet Load() member function. The file name used with the Load() function must refer to a file that contains a complete animation scene. Like other file loading member functions in Direct3D, the Load member function can read from files, program resources, or memory. Individual Animation objects can be added and removed from an AnimationSet object using the AddAnimation() and DeleteAnimation() member functions. Setting Time In Animation SetsLike the Direct3DRMAnimation interface, the Direct3DRMAnimationSet interface provides a SetTime() member function. In the case of the AnimationSet, the SetTime() member function sets the time for each animation contained in the animation set. Direct3D Data typesDirect3D defines a number of data types sure to be used again and again in your programs. Well discuss these data types in this section. D3DVALUED3DVALUE is the most fundamental Direct3D data type. D3DVALUE is declared to be of the type float and is used throughout Direct3D to represent vertex coordinates, light intensities, rotation speeds, and so on. In 32-bit C++ environments, such as Visual C++, numbers not explicitly assigned a type are assumed to be of type int (if no decimal point is used) or double (if a decimal point is used). In other words, if you use unspecified floating point values in your programs, the compiler will represent the values with eight bytes (for a double) instead of four (for a float). For this reason, along with the fact that code that uses the D3DVALUE type explicitly is more likely to be portable, the D3DVALUE type is used extensively in Direct3D programs. If you are sure that your program will not need to be ported to a different platform, and you detest the abundance of D3DVALUE casts in your code (quite understandable), you can use an f suffix to indicate the data type to the compiler (you must use a decimal point with this technique). Some examples are shown below: d3dfunction( D3DVALUE( 3 ) ) // typical and safe d3dfunction( D3DVALUE(3.0) ) // typical and safe d3dfunction( 3 ) // assumed to be int--causes compiler warning d3dfunction( 3.0 ) // assumed to be double--causes compiler warning d3dfunction( 3.0f ) // ok but possibly not portable d3dfunction( 3f ) // not legal--decimal point must be used D3DVECTORThe D3DVECTOR structure is defined this way: typedef struct _D3DVECTOR { union { D3DVALUE x; D3DVALUE dvX; }; union { D3DVALUE y; D3DVALUE dvY; }; union { D3DVALUE z; D3DVALUE dvZ; }; } D3DVECTOR, *LPD3DVECTOR; The union keyword is used to allow the tags x and dvX (for example) to be used interchangeably. The D3DVECTOR structure is used throughout Direct3D to express not only vectors but also points. D3DCOLORDirect3D uses the D3DCOLOR type to represent colors. A color has a red, green, blue, and an alpha component. Each of these components can vary in value from zero to onezero being none or off, and one being full or on. Actually, its a little more complicated than that. D3DCOLOR is of type DWORD, so it cant store four floating point values. The values are stored by multiplying each color component by 255 and shifting them into the DWORD. Direct3D supplies macros for this purpose. A D3DCOLOR type can be assigned with the D3DRGB or D3DRGBA macros. For example: D3DCOLOR color=D3DRGB(1,1,1); // creates a white D3DCOLOR // or ... D3DCOLOR color=D3DRGBA(1,1,1,0); // create a white D3DCOLOR with a // zero alpha value The values that are passed to D3DRGB and D3DRGBA should range from zero to one. The macros handle the multiplication and conversion of the values. Also, it isnt necessary to cast the values with D3DVALUE, since the color creation macros also supply casts. Individual color components can be extracted from D3DCOLOR values with the D3DRMColorGetRed(), D3DRMColorGetGreen(), D3DRMColorGetBlue(), and D3DRMColorGetAlpha() functions. D3DRMBOXDirect3D uses the D3DRMBOX structure to describe an objects size. Both the Direct3DRMMesh and the Direct3DRMMeshBuilder interfaces provide GetBox() member functions that can be used to retrieve an objects dimensions. D3DRMBOX contains two D3DVECTOR structures: typedef struct _D3DRMBOX { D3DVECTOR min, max; } D3DRMBOX; Although the D3DVECTOR structure type is used, the data contained in a vector structure is a point and not a vector. The min and max structures are used to indicate opposite corners of the smallest possible box that could contain the object in question.
|
![]() |
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. |