net.jinx.video.model
Class ModelUtil

java.lang.Object
  extended by net.jinx.video.model.ModelUtil

public class ModelUtil
extends java.lang.Object

Holds a bunch of utility methods for this package.

API Stability: Stable.


Method Summary
static Material colorToMaterial(java.awt.Color c)
          Constructs a Material using a well tested technique to convert a simple color to a Material.
static Material colorToMaterial(java.awt.Color c, float shine)
          Constructs a Material using a well tested technique to convert a simple color to a Material.
static Material colorToMaterial(float r, float g, float b)
          Constructs a Material using a well tested technique to convert a simple color to a Material.
static Material colorToMaterial(float r, float g, float b, float a)
          Constructs a Material using a well tested technique to convert a simple color to a Material.
static Material colorToMaterial(float r, float g, float b, float a, float shine)
          Constructs a Material using a well tested technique to convert a simple color to a Material.
static Camera loadCamera(Hierarchy h)
          Constructs a Camera object from the given Hierarchy.
static Coloration loadColoration(Hierarchy h)
          Constructs a Coloration object from the given Hierarchy.
static DemoRotator loadDemoRotator(Hierarchy h, Visible drawable)
          Constructs a DemoRotator object from the given Hierarchy for the given Visible.
static Light loadLight(Hierarchy h)
          Constructs a Light object from the given Hierarchy.
static Material loadMaterial(Hierarchy h)
          Constructs a Material object from the given Hierarchy.
static MeshElement loadMeshElement(Hierarchy h)
          Constructs a MeshElement object from the given Hierarchy.
static MeshElement loadMeshElement(Hierarchy h, boolean reduce)
          Constructs a MeshElement object from the given Hierarchy.
static Model loadModel(Hierarchy h)
          Constructs a Model object from the given Hierarchy.
static Model[] loadModelPack(java.io.File jar, TextureManager tm)
          Parses a model pack jar file, loading textures and returning the Models.
static Model[] loadModelPack(java.util.jar.JarFile jf, TextureManager tm)
          Parses a model pack jar file, loading textures and returning the Models.
static Sphere loadSphere(Hierarchy h)
          Constructs a Sphere object from the given Hierarchy.
static float[][] loadVertexArray(Hierarchy h)
          Same as loadVertexArray(Hierarchy, 3).
static float[][] loadVertexArray(Hierarchy h, int length)
          Constructs a Vertex array from the given Hierarchy.
static VertexColoration randomColoration(float[][] vertices, Material[] sources, float threshold)
          Constructs a semi-random VertexColoration for the given vertices, using the given sources and threshold.
static VertexColoration randomColoration(Model m, Material[] sources, float threshold)
          Constructs a semi-random VertexColoration for the given Model, using the given sources and threshold.
static void store(Hierarchy h, Coloration coloration)
          Stores a Coloration object to the given Hierarchy.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

colorToMaterial

public static Material colorToMaterial(java.awt.Color c)
Constructs a Material using a well tested technique to convert a simple color to a Material.

Parameters:
c - the java.awt.Color object to convert. return the Material.

colorToMaterial

public static Material colorToMaterial(java.awt.Color c,
                                       float shine)
Constructs a Material using a well tested technique to convert a simple color to a Material.

Parameters:
c - the java.awt.Color object to convert.
shine - the shininess portion of the material. return the Material.

colorToMaterial

public static Material colorToMaterial(float r,
                                       float g,
                                       float b)
Constructs a Material using a well tested technique to convert a simple color to a Material.

Parameters:
r - the red component.
g - the green component.
b - the blue component.
Returns:
the Material.

colorToMaterial

public static Material colorToMaterial(float r,
                                       float g,
                                       float b,
                                       float a)
Constructs a Material using a well tested technique to convert a simple color to a Material.

Parameters:
r - the red component.
g - the green component.
b - the blue component.
a - the alpha component.
Returns:
the Material.

colorToMaterial

public static Material colorToMaterial(float r,
                                       float g,
                                       float b,
                                       float a,
                                       float shine)
Constructs a Material using a well tested technique to convert a simple color to a Material.

Parameters:
r - the red component.
g - the green component.
b - the blue component.
a - the alpha component.
shine - the shininess part of the material.
Returns:
the Material.

randomColoration

public static VertexColoration randomColoration(Model m,
                                                Material[] sources,
                                                float threshold)
Constructs a semi-random VertexColoration for the given Model, using the given sources and threshold. This is supposed to produce a camoflage effect. It doesn't work too well, yet.

Parameters:
m - the Model.
sources - the array of Materials to use as the Materials that are randomly distributed for the Model.
threshold - the probability that a color other than the first one in the source array will be used. This allows the camoflage to be composed of a base color along with patches of other colors.
Returns:
the VertexColoration.

randomColoration

public static VertexColoration randomColoration(float[][] vertices,
                                                Material[] sources,
                                                float threshold)
Constructs a semi-random VertexColoration for the given vertices, using the given sources and threshold. This is supposed to produce a camoflage effect. It doesn't work too well, yet.

Parameters:
vertices - the vertex array. See the VertexUtil class for more information on vertex arrays.
sources - the array of Materials to use as the Materials that are randomly distributed for the vertex array.
threshold - the probability that a color other than the first one in the source array will be used. This allows the camoflage to be composed of a base color along with patches of other colors.

store

public static void store(Hierarchy h,
                         Coloration coloration)
Stores a Coloration object to the given Hierarchy.

Parameters:
h - the Hierarchy to store the Coloration to.

loadModel

public static Model loadModel(Hierarchy h)
Constructs a Model object from the given Hierarchy.

Parameters:
h - the Hierarchy to load the Model from.

loadModelPack

public static Model[] loadModelPack(java.io.File jar,
                                    TextureManager tm)
                             throws java.io.IOException
Parses a model pack jar file, loading textures and returning the Models.

Parameters:
jar - the File to load models and textures from.
tm - the TextureManager to load the images into.
Returns:
the array of loaded Model objects.
Throws:
java.io.IOException - if an I/O error occurs
java.lang.SecurityException - if access is denied to jar.

loadModelPack

public static Model[] loadModelPack(java.util.jar.JarFile jf,
                                    TextureManager tm)
Parses a model pack jar file, loading textures and returning the Models.

Parameters:
jf - the JarFile to load models and textures from.
tm - the TextureManager to load the images into.
Returns:
the array of loaded Model objects.

loadColoration

public static Coloration loadColoration(Hierarchy h)
Constructs a Coloration object from the given Hierarchy.

Parameters:
h - the Hierarchy to load the Coloration from.

loadMeshElement

public static MeshElement loadMeshElement(Hierarchy h)
Constructs a MeshElement object from the given Hierarchy.

Parameters:
h - the Hierarchy to load the MeshElement from.

loadMeshElement

public static MeshElement loadMeshElement(Hierarchy h,
                                          boolean reduce)
Constructs a MeshElement object from the given Hierarchy.

Parameters:
h - the Hierarchy to load the MeshElement from.
reduce - should the vertex array be reduced (as VertexUtil.reduce(float[][]))? If true, this method may take alot of time to complete.

loadVertexArray

public static float[][] loadVertexArray(Hierarchy h)
Same as loadVertexArray(Hierarchy, 3).


loadVertexArray

public static float[][] loadVertexArray(Hierarchy h,
                                        int length)
Constructs a Vertex array from the given Hierarchy. See the VertexUtil class for information on vertex arrays.

Parameters:
h - the Hierarchy to load the array from.

loadSphere

public static Sphere loadSphere(Hierarchy h)
Constructs a Sphere object from the given Hierarchy.

Parameters:
h - the Hierarchy to load the Sphere from.

loadDemoRotator

public static DemoRotator loadDemoRotator(Hierarchy h,
                                          Visible drawable)
Constructs a DemoRotator object from the given Hierarchy for the given Visible.

Parameters:
h - the Hierarchy to load the Light from.
drawable - the Visible.

loadCamera

public static Camera loadCamera(Hierarchy h)
Constructs a Camera object from the given Hierarchy.

Parameters:
h - the Hierarchy to load the Camera from.

loadMaterial

public static Material loadMaterial(Hierarchy h)
Constructs a Material object from the given Hierarchy.

Parameters:
h - the Hierarchy to load the Material from.

loadLight

public static Light loadLight(Hierarchy h)
Constructs a Light object from the given Hierarchy.

Parameters:
h - the Hierarchy to load the Light from.