Package com.ms.com.directX Previous
Previous
Microsoft Packages
Microsoft Packages
Index
Index
Next
Next

Class d3drmMeshBuilder

Applications use the methods of the d3drmMeshBuilder class to interact with mesh objects.

public class d3drmMeshBuilder implements Id3drmMeshBuilder
{
  public void InternalSetObject(IUnknown lpdd);
  public IUnknown InternalGetObject();
  public d3drmMeshBuilder Clone();
  public void AddDestroyCallback(Id3drmCallback fn, IUnknown Arg);
  public void DeleteDestroyCallback(Id3drmCallback fn, IUnknown args);
  public void SetAppData(int data);
  public int GetAppData();
  public void SetName(String name);
  public String GetName();
  public String GetClassName();
  public d3drmMeshBuilder Getd3drmMeshBuilder();
  public void LoadFromFileByPos(String filename, int position, int flags, ILoadTextureCallback c, IUnknown pUser);
  public void Save(String fname, int xFormat, int Save);
  public void Scale(float sx, float sy, float Sz);
  public void Translate(float tx, float ty, float tz);
  public void SetColorSource(int val);
  public void GetBox(d3drmBox retv);
  public void GenerateNormals();
  public int GetColorSource();
  public void AddMesh(d3drmMesh m);
  public void AddMeshBuilder(d3drmMeshBuilder mb);
  public void AddFrame(d3drmFrame f);
  public void AddFace(d3drmFace f);
  public void AddFacesToMesh(int vc, float[] ver, int nc, float[] norm, int[] data);
  public d3drmFaceArray CreateFaceArray(int vcount, float[] vertices, int nCount, float[] normals, int[] data);
  public void ReserveSpace(int v_cnt, int n_cnt, int f_cnt);
  public void SetColorRGB(float red, float green, float blue);
  public void SetColor(int col);
  public void SetTexture(d3drmTexture val);
  public void SetMaterial(d3drmMaterial val);
  public void SetTextureTopology(int wrap_u, int wrap_v);
  public void SetQuality(int q);
  public void SetPerspective(int persp);
  public void SetVertex(int idx, float x, float y, float z);
  public void SetNormal(int idx, float x, float y, float z);
  public void SetTextureCoordinates(int idx, float u, float v);
  public void SetVertexColor(int idx, int c);
  public void SetVertexColorRGB(int idx, float r, float g, float b);
  public d3drmFaceArray GetFaces();
  public int GetVerticesSize();
  public void GetVertices(int[] vc, d3dvector v, int[] nc, d3dvector n, int[] fs, int[] fc);
  public void GetTextureCoordinates(int idx, float[] u, float[] v);
  public void AddVertex(float x, float y, float z);
  public void AddNormal(float x, float y, float z);
  public d3drmFace CreateFace();
  public int GetQuality();
  public int GetPerspective();
  public int GetFaceCount();
  public int GetVertexCount();
  public int GetVertexColor(int index);
  public d3drmMesh CreateMesh();
}

The methods can be organized into the following groups:
Color GetColorSource
SetColor
SetColorRGB
SetColorSource
Creation and information GetBox
Faces AddFace
AddFacesToMesh
CreateFace
CreateFaceArray
GetFaceCount
GetFaces
Loading LoadFromFileByPos
Meshes AddMesh
CreateMesh
Miscellaneous AddFrame
AddMeshBuilder
ReserveSpace
Save
Scale
SetMaterial
Translate
Normals AddNormal
GenerateNormals
SetNormal
Perspective GetPerspective
SetPerspective
Rendering quality GetQuality
SetQuality
Textures GetTextureCoordinates
SetTexture
SetTextureCoordinates
SetTextureTopology
Vertices AddVertex
GetVertexColor
GetVertexCount
GetVertices
GetVerticesSize
SetVertex
SetVertexColor
SetVertexColorRGB

In addition, the d3drmMeshBuilder class inherits the following methods from the d3drmObject class:
AddDestroyCallback
Clone
DeleteDestroyCallback
GetAppData
GetClassName
GetName
SetAppData
SetName

The d3drmMeshBuilder object is obtained by calling the CreateMeshBuilder method.

AddFace

public void AddFace(d3drmFace f);

Adds a face to a d3drmMeshBuilder object.

Return Value:

No return value.

ParameterDescription
f The d3drmFace object to add.

Remarks:

Any one face can exist in only one mesh at a time.


AddFacesToMesh

public void AddFacesToMesh(int vc, float[] ver, int nc, float[] norm, int[] data);

Adds a face to the d3drmMeshBuilder object.

Return Value:

No return value.

ParameterDescription
vc Number of vertices.
ver Array variable that contains the vertices to use to create the face.
nc Number of normals.
norm Array variable that contains the normals to use to create the face.
data Array variable that contains the data associated with the face.


AddFrame

public void AddFrame(d3drmFrame f);

Adds the contents of a frame to a d3drmMeshBuilder object.

Return Value:

No return value.

ParameterDescription
f The d3drmFrame object to add.

Remarks:

The source frame is not modified or referenced by this operation.


AddMesh

public void AddMesh(d3drmMesh m);

Adds a mesh to a d3drmMeshBuilder object.

Return Value:

No return value.

ParameterDescription
m The d3drmMesh object to add.


AddMeshBuilder

public void AddMeshBuilder(d3drmMeshBuilder mb);

Adds the contents of a d3drmMeshBuilder object to another d3drmMeshBuilder object.

Return Value:

No return value.

ParameterDescription
mb The d3drmMeshBuilder object to add.

Remarks:

The source d3drmMeshBuilder object is not modified or referenced by this operation.


AddNormal

public void AddNormal(float x, float y, float z);

Adds a normal to a d3drmMeshBuilder object.

Return Value:

Returns the index of the normal.

ParameterDescription
x, y, and z The x, y, and z components of the direction of the new normal.


AddVertex

public void AddVertex(float x, float y, float z);

Adds a vertex to a d3drmMeshBuilder object.

Return Value:

Returns the index of the vertex.

ParameterDescription
x, y, and z The x, y, and z components of the position of the new vertex.


CreateFace

public d3drmFace CreateFace();

Creates a new face with no vertices and adds it to a d3drmMeshBuilder object.

Return Value:

Returns the d3drmFace object if successful; null otherwise.


CreateFaceArray

public d3drmFaceArray CreateFaceArray(int vcount, float[] vertices, int nCount, float[] normals, int[] data);

Creates a face array for the d3drmMeshBuilder object.

Return Value:

Returns the d3drmFaceArray object if successful; null otherwise.

ParameterDescription
vcount Number of vertices.
vertices Array variable that contains the vertices to use to create the face array.
nCount Number of normals.
normals Array variable that contains the normals to use to create the face array.
data Array variable that contains the data associated with the face array.


CreateMesh

public d3drmMesh CreateMesh();

Creates a new mesh from a d3drmMeshBuilder object.

Return Value:

Returns the d3drmMesh object if successful; null otherwise.


GenerateNormals

public void GenerateNormals();

Processes the d3drmMeshBuilder object and generates vertex normals that are the average of each vertex's adjoining face normals.

Return Value:

No return value.

Remarks:

Averaging the normals of back-to-back faces produces a zero normal.


GetBox

public void GetBox(d3drmBox retv);

Retrieves the bounding box containing a d3drmMeshBuilder object. The bounding box gives the minimum and maximum model coordinates in each dimension.

Return Value:

No return value.

ParameterDescription
retv A d3drmBox object that receives the bounding box coordinates.


GetColorSource

public int GetColorSource();

Retrieves the color source of a d3drmMeshBuilder object. The color source can be either a face or a vertex.

Return Value:

Returns a value of color source type.

See Also: SetColorSource


GetFaceCount

public int GetFaceCount();

Retrieves the number of faces in a d3drmMeshBuilder object.

Return Value:

Returns the number of faces.


GetFaces

public d3drmFaceArray GetFaces();

Retrieves the faces of a d3drmMeshBuilder object.

Return Value:

Returns the d3drmFaceArray object if successful; null otherwise.


GetPerspective

public int GetPerspective();

Determines whether perspective correction is on for a d3drmMeshBuilder object.

Return Value:

Returns TRUE if perspective correction is on, or FALSE otherwise.


GetQuality

public int GetQuality();

Retrieves the rendering quality of a d3drmMeshBuilder object.

Return Value:

Returns a value of render quality type that specifies the rendering quality of the mesh.

See Also: SetQuality


GetTextureCoordinates

public void GetTextureCoordinates(int idx, float[] u, float[] v);

Retrieves the texture coordinates of a specified vertex in a d3drmMeshBuilder object.

Return Value:

No return value.

ParameterDescription
idx Index of the vertex.
u and v Array variables that receive the texture coordinates of the vertex.

See Also: SetTextureCoordinates


GetVertexColor

public int GetVertexColor(int index);

Retrieves the color of a specified vertex in a d3drmMeshBuilder object.

Return Value:

Returns the color.

ParameterDescription
index Index of the vertex.

See Also: SetVertexColor


GetVertexCount

public int GetVertexCount();

Retrieves the number of vertices in a d3drmMeshBuilder object.

Return Value:

Returns the number of vertices.


GetVertices

public void GetVertices(int[] vc, d3dvector v, int[] nc, d3dvector n, int[] fs, int[] fc);

Retrieves the vertices, normals, and face data for a d3drmMeshBuilder object.

Return Value:

No return value.

ParameterDescription
vc Array variable that receives the number of vertices.
v A d3dvector object that receives the vertices for the d3drmMeshBuilder object.
nc Array variable that receives the number of normals.
n A d3dvector object that receives the normals for the d3drmMeshBuilder object.
fs Array variable that receives the length of the array associated with the fc parameter.
fc Array variable that receives the face data for the d3drmMeshBuilder object. This data is in the same format as specified in the AddFaces method except that it is null-terminated.


LoadFromFileByPos

public void LoadFromFileByPos(String filename, int position, int flags, ILoadTextureCallback c, IUnknown pUser);

Loads a d3drmMeshBuilder object.

Return Value:

No return value.

ParameterDescription
filename Name of the file containing the object to be loaded.
position Position of the object to be loaded. The value gives the object's order in the file.
flags Value of load options type.
c Callback interface that contains a load texture callback function called to load any textures used by an object that require special formatting. This parameter can be null.
pUser application-defined data passed to the load texture callback function.

Remarks:

By default, this method loads the first mesh from the file specified in the filename parameter.


ReserveSpace

public void ReserveSpace(int v_cnt, int n_cnt, int f_cnt);

Reserves space within a d3drmMeshBuilder object for the specified number of vertices, normals, and faces. This allows the system to use memory more efficiently.

Return Value:

No return value.

ParameterDescription
v_cnt, n_cnt, and f_cnt Number of vertices, normals, and faces to allocate space for.


Save

public void Save(String fname, int xFormat, int Save);

Saves a d3drmMeshBuilder object.

Return Value:

No return value.

ParameterDescription
fname Name of the created file. This file must have a .X file name extension.
xFormat D3DRMXOF_TEXT.
Save One value of save options type.


Scale

public void Scale(float sx, float sy, float Sz);

Scales a d3drmMeshBuilder object by the given scaling factors, parallel to the x-, y-, and z-axes in model coordinates.

Return Value:

No return value.

ParameterDescription
sx, sy, and Sz Scaling factors that are applied along the x-, y-, and z-axes.


SetColor

public void SetColor(int col);

Sets all the faces of a d3drmMeshBuilder object to a given color.

Return Value:

No return value.

ParameterDescription
col Color of the faces.


SetColorRGB

public void SetColorRGB(float red, float green, float blue);

Sets all the faces of a d3drmMeshBuilder object to a given color.

Return Value:

No return value.

ParameterDescription
red, green, and blue Red, green, and blue components of the color.


SetColorSource

public void SetColorSource(int val);

Sets the color source of a d3drmMeshBuilder object.

Return Value:

No return value.

ParameterDescription
val Value of color source type that specifies the new color source to use.

See Also: GetColorSource


SetMaterial

public void SetMaterial(d3drmMaterial val);

Sets the material of all the faces of a d3drmMeshBuilder object.

Return Value:

No return value.

ParameterDescription
val The d3drmMaterial object to set.


SetNormal

public void SetNormal(int idx, float x, float y, float z);

Sets the normal vector of a specified vertex in a d3drmMeshBuilder object.

Return Value:

No return value.

ParameterDescription
idx Index of the normal to be set.
x, y, and z The x, y, and z components of the vector to assign to the specified normal.


SetPerspective

public void SetPerspective(int persp);

Enables or disables perspective-correct texture-mapping for a d3drmMeshBuilder object.

Return Value:

No return value.

ParameterDescription
persp Specify TRUE if the mesh should be texture-mapped with perspective correction, or FALSE otherwise.


SetQuality

public void SetQuality(int q);

Sets the rendering quality of a d3drmMeshBuilder object.

Return Value:

No return value.

ParameterDescription
q Value of render quality type that specifies the new rendering quality to use.

See Also: GetQuality


SetTexture

public void SetTexture(d3drmTexture val);

Sets the texture of all the faces of a d3drmMeshBuilder object.

Return Value:

No return value.

ParameterDescription
val The d3drmTexture object to set.


SetTextureCoordinates

public void SetTextureCoordinates(int idx, float u, float v);

Sets the texture coordinates of a specified vertex in a d3drmMeshBuilder object.

Return Value:

No return value.

ParameterDescription
idx Index of the vertex to be set.
u and v Texture coordinates to assign to the specified mesh vertex.

See Also: GetTextureCoordinates


SetTextureTopology

public void SetTextureTopology(int wrap_u, int wrap_v);

Sets the texture topology of a d3drmMeshBuilder object.

Return Value:

No return value.

ParameterDescription
wrap_u and wrap_v Specify TRUE for either or both of these parameters if you want the texture to have a cylindrical topology in the u and v dimensions respectively; otherwise, specify FALSE.


SetVertex

public void SetVertex(int idx, float x, float y, float z);

Sets the position of a specified vertex in a d3drmMeshBuilder object.

Return Value:

No return value.

ParameterDescription
idx Index of the vertex to be set.
x, y, and z The x, y, and z components of the position to assign to the specified vertex.


SetVertexColor

public void SetVertexColor(int idx, int c);

Sets the color of a specified vertex in a d3drmMeshBuilder object.

Return Value:

No return value.

ParameterDescription
idx Index of the vertex to be set.
c Color to assign to the specified vertex.

See Also: GetVertexColor


SetVertexColorRGB

public void SetVertexColorRGB(int idx, float r, float g, float b);

Sets the color of a specified vertex in a d3drmMeshBuilder object.

Return Value:

No return value.

ParameterDescription
idx Index of the vertex to be set.
r, g, and b Red, green, and blue components of the color to assign to the specified vertex.


Translate

public void Translate(float tx, float ty, float tz);

Adds the specified offsets to the vertex positions of a d3drmMeshBuilder object.

Return Value:

No return value.

ParameterDescription
tx, ty, and tz Offsets that are added to the x-, y-, and z-coordinates respectively of each vertex position.


Getd3drmMeshBuilder

public d3drmMeshBuilder Getd3drmMeshBuilder();

Retrieves a mesh builder object associated with this object.

Return Value:

Returns the d3drmMeshBuilder object if successful; null otherwise.


GetVerticesSize

public int GetVerticesSize();

Returns the number of vertices.

Return Value:

Returns the number of vertices.

See Also: GetVertices



Top© 1996 Microsoft Corporation. All rights reserved.