m3g06
Class EnvironmentMap

java.lang.Object
  extended by m3g06.EnvironmentMap

public class EnvironmentMap
extends java.lang.Object

Calculates environment mapping coordinates by using a mesh's normals as texture coordinates.

Author:
Claus Hoefele
See Also:
EnvironmentMappingSample

Field Summary
private  javax.microedition.m3g.Mesh mesh
          Reference to mesh that has environment mapping applied.
private  javax.microedition.m3g.Transform textureTransform
          Current generic texture transformation.
 
Constructor Summary
EnvironmentMap(javax.microedition.m3g.Mesh mesh)
          Constructs a new environment map for the given mesh with normalization enabled.
EnvironmentMap(javax.microedition.m3g.Mesh mesh, boolean normalize, float scale)
          Constructs a new environment map for the given mesh.
 
Method Summary
 void transform(float cameraX, float cameraY, float cameraZ, float modelX, float modelY, float modelZ)
          Updates the texture coordinates.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mesh

private javax.microedition.m3g.Mesh mesh
Reference to mesh that has environment mapping applied.


textureTransform

private javax.microedition.m3g.Transform textureTransform
Current generic texture transformation.

Constructor Detail

EnvironmentMap

public EnvironmentMap(javax.microedition.m3g.Mesh mesh)
Constructs a new environment map for the given mesh with normalization enabled.

Parameters:
mesh - mesh for environment mapping.
See Also:
EnvironmentMap(Mesh, boolean, float)

EnvironmentMap

public EnvironmentMap(javax.microedition.m3g.Mesh mesh,
                      boolean normalize,
                      float scale)
Constructs a new environment map for the given mesh. If normalization is enabled, the mesh's normals are scaled to unit length. This works for all meshes, but has a performance impact. If the mesh's normals are already unit length, normalization can be switched off.

Parameters:
mesh - mesh for environment mapping.
normalize - enables/disables normalization.
scale - scale of mesh normals.
Method Detail

transform

public void transform(float cameraX,
                      float cameraY,
                      float cameraZ,
                      float modelX,
                      float modelY,
                      float modelZ)
Updates the texture coordinates. Rotation matrices for camera and model are built in the order Rx*Ry*Rz.

Parameters:
cameraX - camera rotation around the x axis.
cameraY - camera rotation around the y axis.
cameraZ - camera rotation around the z axis.
modelX - model rotation around the x axis.
modelY - model rotation around the y axis.
modelZ - model rotation around the z axis.