Packages
 In this topic

*Methods

 

Packages   PreviousThis PackageNext
Package com.ms.directX   Previous This
Package
Next

 


Class Direct3dRMMeshBuilder

public class Direct3dRMMeshBuilder implements 
            IDirect3dRMMeshBuilder
{
  // Methods
  public void addFace(Direct3dRMFace f);
  public void addFaces(int vCount, D3dVector[] v, int nCount,
        D3dVector[] n, int[] cones);
  public void addFacesAsFloats(int vc, float[] ver, int nc, float[]
        norm, int[] cones);
  public void addFrame(Direct3dRMFrame f);
  public void addMesh(Direct3dRMMesh m);
  public void addMeshBuilder(Direct3dRMMeshBuilder mb);
  public int addNormal(float x, float y, float z);
  public int addVertex(float x, float y, float z);
  public Direct3dRMFace createFace();
  public Direct3dRMFaceArray createFaceArray(int vCount,
        float[] vertices, int nCount, float[] normals,
        int[] cones);
  public Direct3dRMMesh createMesh();
  public void generateNormals();
  public void getBox(D3dRMBox retv);
  public int getColorSource();
  public Direct3dRMMeshBuilder getd3drmMeshBuilder();
  public int getFaceCount();
  public void getFacedataSize(int[] f_cnt);
  public Direct3dRMFaceArray getFaces();
  public void getNormalsSize(int[] n_cnt);
  public int getPerspective();
  public int getQuality();
  public void getTextureCoordinates(int idx, float[] u, float[] v);
  public int getVertexColor(int index);
  public int getVertexCount();
  public void getVertices(int[] vc, D3dvector v, int[] nc,
        D3dvector n, int[] fs, int[] fc);
  public int getVerticesSize();
  public void loadFromFileByPos(String filename, int position,
        int flags, ILoadTextureCallback c, IUnknown pUser);
  public void reserveSpace(int v_cnt, int n_cnt, int f_cnt);
  public void save(String fname, int xFormat, int save);
  public void scale(float sx, float sy, float sz);
  public void setColor(int col);
  public void setColorRGB(float red, float green, float blue);
  public void setColorSource(int val);
  public void setMaterial(Direct3dRMMaterial val);
  public void setNormal(int idx, float x, float y, float z);
  public void setPerspective(int persp);
  public void setQuality(int q);
  public void setTexture(Direct3dRMTexture val);
  public void setTextureCoordinates(int idx, float u, float v);
  public void setTextureTopology(int wrap_u, int wrap_v);
  public void setVertex(int idx, float x, float y, float z);
  public void setVertexColor(int idx, int c);
  public void setVertexColorRGB(int idx, float r, float g, float b);
  public void translate(float tx, float ty, float tz);
}

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

The Direct3dRMMeshBuilder class inherits the following methods from the Direct3dRMObject class:

addDestroyCallback
duplicate
deleteDestroyCallback
getAppData
getClassName
getName
setAppData
setName

The Direct3dRMMeshBuilder object is obtained by calling the createMeshBuilder method.

There are two ways to add faces to a mesh object.
The recommended way is to use the addFaces method.

// Create a mesh builder.
mb = myd3drm.createMeshBuilder();

// Add faces to the mesh.
mb.addFaces(vCount, v, nCount, n, cones);

// Create a material to set for the whole mesh.
material = myd3drm.createMaterial();
mb.setMaterial(material); // This works.

Another possible way is to use the addVertex and addNormal methods, then use createFace to create a face, and add the vertices and normals to it. Currently, this procedure fails.

// Create a mesh builder.
mb = myd3drm.createMeshBuilder();
// Add four vertices.
mb.addVertex(x, y, x); // ...
// Add four normals.
mb.addNormal(x, y, z); // ...

// Create a face from the mesh builder.
d3drmface = mb.createFace();

// Use the Direct3dRMFace.addVertexAndNormalIndexed method
// to add the vertex and normals to the face.
d3drmface.addVertexAndNormalIndexed(index, index); // ...

// Create a material to set for the whole mesh.
material = myd3drm.createMaterial();
mb.setMaterial(material); // This faults.

Methods

addFace

public void addFace(Direct3dRMFace f);

Adds a face to a Direct3dRMMeshBuilder object.

Return Value:

No return value.

ParameterDescription
f The Direct3dRMFace object to add.

Remarks:

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

addFaces

public void addFaces(int vCount, D3dVector[] v, int nCount, D3dVector[] n,
        int[] cones);

Adds a face to the Direct3dRMMeshBuilder object. This method is very similar to addFaces(int, float[], int, float[], int[]) except that it uses D3dVector array objects instead of simple float arrays.

Return Value:

No return value.

ParameterDescription
vCount The number of vertices to use to create the face.
v An array of vectors that contains the vertices to use to create the face.
nCount The number of normals to use to create the face. If nCount is 0, then the data is formatted as follows:
3, 1, 2, 3 //(v[1], v[2], and v[3] make this triangle)
3, 1, 2, 5 //(v[1], v[2], and v[5] make this triangle)
4, 7, 4, 0, 1 //(v[7], v[4], 4[0], and v[1] make this quadrilateral)

However, if nCount is not 0, then the data is as follows:

3, 1, 1, 2, 2, 3, 3 // normals are interlaced.
3, 1, 1, 2, 2, 5, 5
4, 7, 7, 4, 4, 0, 0, 1, 1
n An array of vectors that contains the normals used to create the face.
cones Array variable that contains the data associated with the face.

addFacesAsFloats

public void addFacesAsFloats(int vc, float[] ver, int nc, float[] norm,
        int[] cones);

Adds a face to the Direct3dRMMeshBuilder object.

Return Value:

No return value.

ParameterDescription
vc Number of vertices. This is one-third the size of the float array.
ver A float array variable that contains the vertices to use to create the face.
nc Number of normals. This is one-third the size of the float array.
norm A float array variable that contains the normals to use to create the face.
cones Array variable that contains the data associated with the face.

addFrame

public void addFrame(Direct3dRMFrame f);

Adds the contents of a frame to a Direct3dRMMeshBuilder object.

Return Value:

No return value.

ParameterDescription
f The Direct3dRMFrame object to add.

Remarks:

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

addMesh

public void addMesh(Direct3dRMMesh m);

Adds a mesh to a Direct3dRMMeshBuilder object.

Return Value:

No return value.

ParameterDescription
m The Direct3dRMMesh object to add.

addMeshBuilder

public void addMeshBuilder(Direct3dRMMeshBuilder mb);

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

Return Value:

No return value.

ParameterDescription
mb The Direct3dRMMeshBuilder object to add.

Remarks:

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

addNormal

public int addNormal(float x, float y, float z);

Adds a normal to a Direct3dRMMeshBuilder object.

Return Value:

Returns the index of the normal.

ParameterDescription
x The x component of the direction of the new normal
y The y component of the direction of the new normal
z The z component of the direction of the new normal.

addVertex

public int addVertex(float x, float y, float z);

Adds a vertex to a Direct3dRMMeshBuilder object.

Return Value:

Returns the index of the vertex.

ParameterDescription
x The x component of the position of the new vertex.
y The y component of the position of the new vertex.
z The z component of the position of the new vertex.

createFace

public Direct3dRMFace createFace();

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

Return Value:

Returns the Direct3dRMFace object if successful; otherwise, returns null

createFaceArray

public Direct3dRMFaceArray createFaceArray(int vCount, float[] vertices,
        int nCount, float[] normals, int[] cones);

Creates a face array for the Direct3dRMMeshBuilder object.

Return Value:

Returns the Direct3dRMFaceArray object if successful; otherwise, null

ParameterDescription
vCount The number of vertices. This is one-third the size of the float array.
vertices the array variable that contains the vertices used to create the face array.
nCount the number of normals. This is one-third the size of the float array.
normals The array variable that contains the normals used to create the face array.
cones The array variable that contains the data associated with the face array.

createMesh

public Direct3dRMMesh createMesh();

Creates a new mesh from a Direct3dRMMeshBuilder object.

Return Value:

Returns the Direct3dRMMesh object if successful; otherwise, returns null

generateNormals

public void generateNormals();

Processes the Direct3dRMMeshBuilder 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 Direct3dRMMeshBuilder 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 Direct3dRMMeshBuilder object. The color source can be either a face or a vertex.

Return Value:

Returns a value of color source type.

See Also: setColorSource

getd3drmMeshBuilder

public Direct3dRMMeshBuilder getd3drmMeshBuilder();

Retrieves a mesh builder object associated with this object.

Return Value:

Returns the Direct3dRMMeshBuilder object if successful; otherwise, returns null

getFaceCount

public int getFaceCount();

Retrieves the number of faces in a Direct3dRMMeshBuilder object.

Return Value:

Returns the number of faces.

getFacedataSize

public void getFacedataSize(int[] f_cnt);

Retrieves the size of the faces in a Direct3dRMFaceArray and stores them in the int array f_cnt.

Return Value:

No return value.

ParameterDescription
f_cnt The array that stores the sizes of the faces that are measured.

getFaces

public Direct3dRMFaceArray getFaces();

Retrieves the faces of a Direct3dRMMeshBuilder object.

Return Value:

Returns the Direct3dRMFaceArray object if successful; otherwise, returns null

getNormalsSize

public void getNormalsSize(int[] n_cnt);

Retrieves the size of the normals in a Direct3dRMFaceArray and stores them in the int array n_cnt.

Return Value:

No return value.

ParameterDescription
n_cnt The array that stores the sizes of the faces that are measured.

getPerspective

public int getPerspective();

Determines whether perspective correction for a Direct3dRMMeshBuilder object is turned on.

Return Value:

Returns true if perspective correction is on, otherwise, returns false.

getQuality

public int getQuality();

Retrieves the rendering quality of a Direct3dRMMeshBuilder object.

Return Value:

Returns a value 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 Direct3dRMMeshBuilder object.

Return Value:

No return value.

ParameterDescription
idx The index of the vertex.
u The array variables that receive the texture coordinates of the vertex.
v The 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 Direct3dRMMeshBuilder object.

Return Value:

Returns the color.

ParameterDescription
index The index of the vertex.

See Also: setVertexColor

getVertexCount

public int getVertexCount();

Retrieves the number of vertices in a Direct3dRMMeshBuilder 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 vertex, normal, and face data for a Direct3dRMMeshBuilder object.

Return Value:

No return value.

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

getVerticesSize

public int getVerticesSize();

Retrieves the number of vertices.

Return Value:

Returns the number of vertices.

See Also: getVertices

loadFromFileByPos

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

Loads a Direct3dRMMeshBuilder object.

Return Value:

No return value.

ParameterDescription
filename The name of the file containing the object to be loaded.
position The position of the object to be loaded. The value gives the object's order in the file.
flags The load options type value.
c The callback interface that contains a load texture callback function called to load 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 by the filename parameter.

reserveSpace

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

Reserves space within a Direct3dRMMeshBuilder 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 The number of vertices to allocate space for.
n_cnt The number of normals to allocate space for.
f_cnt The number of faces to allocate space for.

save

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

Saves a Direct3dRMMeshBuilder object.

Return Value:

No return value.

ParameterDescription
fname The name of the created file. This file must have a .X filename extension.
xFormat D3DRMXOF_TEXT.
save A value of the save options type.

scale

public void scale(float sx, float sy, float sz);

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

Return Value:

No return value.

ParameterDescription
sx The scaling factors that are applied along the x-axis.
sy the scaling factors that are applied along the y-axis.
sz The scaling factors that are applied along the z-axis.

setColor

public void setColor(int col);

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

Return Value:

No return value.

ParameterDescription
col The color of the faces.

setColorRGB

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

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

Return Value:

No return value.

ParameterDescription
red The red component of the color.
green The green component of the color.
blue The blue component of the color.

setColorSource

public void setColorSource(int val);

Sets the color source of a Direct3dRMMeshBuilder object.

Return Value:

No return value.

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

Remarks:

This method does not exhibit expected behavior under certain circumstances. If you use this method to set colors to faces, then it works as expected. But if you try to set colors for individual vertices, it wont, because face data is still used. To set vertice's colors, call the createMesh method and set individual vertex colors with the setVertex method.

See Also: getColorSource

setMaterial

public void setMaterial(Direct3dRMMaterial val);

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

Return Value:

No return value.

ParameterDescription
val The Direct3dRMMaterial 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 Direct3dRMMeshBuilder object.

Return Value:

No return value.

ParameterDescription
idx The index of the normal to be set.
x The x component of the vector to assign to the specified normal.
y The y component of the vector to assign to the specified normal.
z The z component of the vector to assign to the specified normal.

setPerspective

public void setPerspective(int persp);

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

Return Value:

No return value.

ParameterDescription
persp Specify true if the mesh should be texture-mapped with perspective correction, otherwise, specify false.

setQuality

public void setQuality(int q);

Sets the rendering quality of a Direct3dRMMeshBuilder object.

Return Value:

No return value.

ParameterDescription
q The value that specifies the new rendering quality to use.

See Also: getQuality

setTexture

public void setTexture(Direct3dRMTexture val);

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

Return Value:

No return value.

ParameterDescription
val The Direct3dRMTexture object to set.

setTextureCoordinates

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

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

Return Value:

No return value.

ParameterDescription
idx The index of the vertex to be set.
u The texture u coordinate to assign to the specified mesh vertex.
v The texture v coordinate 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 Direct3dRMMeshBuilder object.

Return Value:

No return value.

ParameterDescription
wrap_u Specify true if you want the texture to have a cylindrical topology in the u dimension; otherwise, specify false.
wrap_v Specify true if you want the texture to have a cylindrical topology in the v dimension; otherwise, specify false.

You can use any combination of true and false for these parameters. (Both may be true, both may be false, and so on.)

setVertex

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

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

Return Value:

No return value.

ParameterDescription
idx The index of the vertex to be set.
x The x component of the position to assign to the specified vertex.
y The y component of the position to assign to the specified vertex.
z The z component 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 Direct3dRMMeshBuilder object.

Return Value:

No return value.

ParameterDescription
idx The index of the vertex to be set.
c The 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 Direct3dRMMeshBuilder object.

Return Value:

No return value.

ParameterDescription
idx The index of the vertex to be set.
r The red component of the color assigned to the specified vertex.
g The green component of the color assigned to the specified vertex.
b The blue component of the color assigned to the specified vertex.

translate

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

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

Return Value:

No return value.

ParameterDescription
tx The offset that is added to the x coordinate of each vertex position.
ty The offset that is added to the y coordinate of each vertex position.
tz The offset that is added to the z coordinate of each vertex position.

upnrm.gif © 1998 Microsoft Corporation. All rights reserved. Terms of use.