Click Here!
home account info subscribe login search My ITKnowledge FAQ/help site map contact us


 
Brief Full
 Advanced
      Search
 Search Tips
To access the contents, click the chapter and section titles.

Cutting Edge Direct 3D Programming
(Publisher: The Coriolis Group)
Author(s): Stan Trujillo
ISBN: 1576100502
Publication Date: 11/01/96

Bookmark It

Search this book:
 
Previous Table of Contents Next


Direct3DRMMesh: The Mesh Interface

The 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 Groups

The 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:

  AddGroup()
  GetGroup()
  GetGroupColor()
  GetGroupCount()
  GetGroupMapping()
  GetGroupMaterial()
  GetGroupQuality()
  GetGroupTexture()
  SetGroupColor()
  SetGroupColorRGB()
  SetGroupMapping()
  SetGroupMaterial()
  SetGroupQuality()
  SetGroupTexture()

These functions are all pretty straightforward to use—once you’ve 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 group’s settings can be changed quickly and easily.

Vertex Access

The 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 Meshbuilders

Meshbuilders 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 Interface

Meshes 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 Textures

Textures can be applied to faces using these Direct3DRMFace member functions. Those functions are as follows:

  GetTexture()
  GetTextureCoordinateIndex()
  GetTextureCoordinates()
  GetTextureTopology()
  SetTexture()
  SetTextureCoordinates()
  SetTextureTopology()

We’ll talk about textures in more detail when we talk about the Direct3DRMTexture interface.

Face Materials

The appearance of a face (shiny, dull, etc.) can be adjusted using the GetMaterial() and SetMaterial() member functions. We’ll talk about materials later in this chapter when we talk about the Direct3DRMMaterial interface.

Face Vertices

The vertex settings can be manipulated with these Direct3DRMFace member functions:

  AddVertex()
  GetVertex()
  GetVertexCount()
  GetVertexIndex()
  GetVertices()

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.


Previous Table of Contents Next


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.