![]() |
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() |
![]() |
To access the contents, click the chapter and section titles.
Cutting Edge Direct 3D Programming
Direct3DRMMesh: The Mesh InterfaceThe Direct3DRMMesh interface is designed for speed. Unfortunately, the mesh interface is not nearly as easy to use as the meshbuilder interface. Meshes can be created with the Direct3DRM CreateMesh() and Direct3DRMMeshBuilder CreateMesh() functions. Mesh GroupsThe Mesh interface is dedicated almost exclusively to the manipulation of groups. A group is a collection of faces within a mesh that can be treated as a single entity. The group creation and modification member functions are:
These functions are all pretty straightforward to useonce youve created one or more groups. Groups are created with the AddGroup() member function. AddGroup() requires that you supply mesh attributes at the vertex level. This means that you must supply vertex locations, normals, and texture coordinates in order to create mesh groups. Once one or more groups have been created in a mesh, each groups settings can be changed quickly and easily. Vertex AccessThe Direct3DRMMesh interface provides GetVertices() and SetVertices() member functions for the manipulation of vertex positions. GetVertices() is used to retrieve the current vertex settings. Once vertex settings are retrieved, the settings can be modified and re-installed using SetVertices(). This is the recommended technique to modify the shape of a mesh in time-critical situations, such as vertex animation and morphing. Like Direct3DRMMeshBuilder, the Direct3DRMMesh interface provides Scale() and Translate() member functions. Creating Meshes With MeshbuildersMeshbuilders can be used to create instances of the Direct3DRMMesh interface. Typically a meshbuilder is used to load a mesh from disk, to assign colors, textures, adjust faces, vertices, and normals. Then the Direct3DRMMeshBuilder CreateMesh() member function is used to create a Direct3DRMMesh object. This technique is convenient, but it means that all of the faces in a mesh belong to one group. Defining a mesh with multiple groups requires that the AddGroup() function be used. Direct3DRMFace: The Face InterfaceMeshes are sets of faces, so creating a mesh means creating faces. Most of the time you will modify existing faces rather than create new faces directly. The MeshBuilder interface, for example, allows access to existing faces with the GetFaces() member function. It is, however, possible to create faces from scratch and add them to a Meshbuilder. In either case, face attributes such as color, texture, and vertices can be adjusted. Faces are represented by the Direct3DRMFace interface. The Direct3DRMFace interface provides GetColor() and SetColor() member functions for inspecting and changing the color of the face. Face TexturesTextures can be applied to faces using these Direct3DRMFace member functions. Those functions are as follows:
Well talk about textures in more detail when we talk about the Direct3DRMTexture interface. Face MaterialsThe appearance of a face (shiny, dull, etc.) can be adjusted using the GetMaterial() and SetMaterial() member functions. Well talk about materials later in this chapter when we talk about the Direct3DRMMaterial interface. Face VerticesThe vertex settings can be manipulated with these Direct3DRMFace member functions:
The ability to add vertices to a face makes is possible to create concave faces. This could cause trouble since the underlying Direct3D rendering levels cannot draw concave faces (or even faces that have more than three vertices). Fortunately, Direct3D Retained-Mode automatically divides faces into triangles.
|
![]() |
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. |