com.microcrowd.loader.java3d.max3ds.chunks
Class FacesDescriptionChunk

java.lang.Object
  extended by com.microcrowd.loader.java3d.max3ds.chunks.Chunk
      extended by com.microcrowd.loader.java3d.max3ds.chunks.FacesDescriptionChunk

public class FacesDescriptionChunk
extends Chunk

This chunk describes all the triangles that make up a mesh. Each triangle is defined in terms of three indexes each of which is a point reference to a vertex in the vertex list loaded by the triangular mesh chunk. After loading the Smoothing chunk the normals for the mesh are generated accordingly.


Field Summary
static Appearance DEFAULT_APPEARANCE
           
 
Constructor Summary
FacesDescriptionChunk()
           
 
Method Summary
 Vector3f averageNormals(Vector3f[] normals)
          Averages the normals provided in order to provide smooth, noncreased appearances for meshes.
 void initialize(ChunkChopper chopper)
          Loads a mesh onto the scene graph with the specified data from subchunks.
 void loadData(ChunkChopper chopper)
          Reads the number of faces from the ChunkChopper.
 Vector3f[] smoothNormals(Vector3f[] currentNormals, com.microcrowd.loader.java3d.max3ds.chunks.FacesDescriptionChunk.PointMapper sharedPoints, int[] smoothGroups)
          Takes all the normals for all the vertices and averages them with normals with which they share a coordinate and at least one smooth group.
 
Methods inherited from class com.microcrowd.loader.java3d.max3ds.chunks.Chunk
addSubChunk, getDescription, getName, getSubChunk, setDescription, setName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_APPEARANCE

public static final Appearance DEFAULT_APPEARANCE
Constructor Detail

FacesDescriptionChunk

public FacesDescriptionChunk()
Method Detail

loadData

public void loadData(ChunkChopper chopper)
Reads the number of faces from the ChunkChopper. For each face read three shorts representing indices of vertices loaded by the TriangularMeshChunk

Overrides:
loadData in class Chunk
Parameters:
chopper - chopper the has the data

initialize

public void initialize(ChunkChopper chopper)
Loads a mesh onto the scene graph with the specified data from subchunks. If there is no material, this will put a default material on the shape.

Overrides:
initialize in class Chunk
Parameters:
chopper - may contain data loaded by subchunks.

smoothNormals

public Vector3f[] smoothNormals(Vector3f[] currentNormals,
                                com.microcrowd.loader.java3d.max3ds.chunks.FacesDescriptionChunk.PointMapper sharedPoints,
                                int[] smoothGroups)
Takes all the normals for all the vertices and averages them with normals with which they share a coordinate and at least one smooth group.

Parameters:
currentNormals - the normals for each face.
sharedPoints - the point mapper that will choose which points are and which are not shared.
smoothGroups - the indexed list of group masks loaded by the smooth chunk.
Returns:
normals averaged among the shared vertices in their smoothing groups.

averageNormals

public Vector3f averageNormals(Vector3f[] normals)
Averages the normals provided in order to provide smooth, noncreased appearances for meshes.

Parameters:
normals - the normals that should be averaged
Returns:
a normalized normal that can be used in place of all the normals provided.


Copyright © 2000-2011 Microcrowd. All Rights Reserved.