|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.jinx.video.DisplayList net.jinx.video.model.Model
public final class Model
Model objects are collections of MeshElement objects, along with coloration
and per-vertex normal data (if used). They serve as the solid, visible
objects within a rendered scene.
The following are valid MeshElement classes: LineLoop, Lines, LineStrip,
Polygon, Quads, QuadStrip, TriangleFan, Triangles and TriangleStrip.
Models can be colored by any Coloration implementation. See the
setColoration(Coloration) method for more info.
Models are normally unchanging, meaning that they're ideal for use with
OpenGL display lists. That's the reason this class extends DisplayList (and
to work around a texturing bug that only happened with display list wrapped
models). There's almost no reason to not use display lists with Model
objects, except memory requirements.
API Stability: Stable.
Constructor Summary | |
---|---|
Model()
Constructs a Model with no Coloration. |
|
Model(Coloration coloration)
Constructs a Model using the given Coloration object to color it. |
Method Summary | |
---|---|
void |
activateColoration(java.lang.String name)
Activates a secondary Coloration, using it's name to do so. |
void |
addColoration(java.lang.String name,
Coloration coloration)
Adds a secondary Coloration to this Model. |
void |
addMeshElement(MeshElement me)
Adds a MeshElement to the model. |
void |
calcNormals()
Calculates per-vertex normals for this Model by averaging the normals of the faces associated with those vertices. |
java.lang.Object |
clone()
Duplicates this Model object. |
void |
draw(Context opt)
Renders this Model with all of it's default settings. |
Model |
extrude(float dist)
Constructs an extrusion Model from this Model. |
MeshElement[] |
getMeshElements()
Provides an array of MeshElement objects used to construct this Model. |
java.lang.String |
getName()
Provides the name of this Model. |
float[][] |
getNormals()
Provides the array that normal vectors are being stored in. |
java.lang.String |
getSegment(int vertex)
Provides the name of the segment for the given vertex. |
java.lang.String |
getTexture()
Gets the name of the texture that this Model should use. |
float[][] |
getTextureCoordinates()
Gets the texture coordinates for this Model. |
float[][] |
getVertices()
Provides an array containing all of the vertices that are part of this Model. |
void |
nameSegment(int vertex,
java.lang.String name)
Names a segment of the Model. |
void |
setColoration(Coloration coloration)
Sets the "Default" Coloration object used to color this Model and then activates it. |
void |
setName(java.lang.String name)
Sets the name of this Model. |
void |
setNormals(float[][] n)
Sets the array that normal vectors are stored in. |
void |
setTexture(java.lang.String texture)
Sets the name of the texture that this Model should use. |
void |
setTextureCoordinates(float[][] tc)
Sets the texture coordinates for this Model. |
void |
storeToHierarchy(Hierarchy h)
Stores this Model to the given net.jinx.db.Hierarchy object, which can then be stored to XML or a java.util.Properties Object, or used to reconstruct the Model via the ModelUtil class. |
void |
subDraw(Context opt)
The OpenGL calls in this method are what get wrapped in the display list. |
void |
subDraw(Context opt,
Coloration coloration,
boolean texture)
Renders this Model with an arbitrary Coloration. |
Model |
toLineModel(float width)
Produces a line version of this Model. |
int |
vertexCount()
Returns the number of vertices this Model has, totaled from all it's MeshElements. |
Methods inherited from class net.jinx.video.DisplayList |
---|
deinit, dispose, init, isListed, list, refresh |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Model()
public Model(Coloration coloration)
coloration
- the Coloration object.Method Detail |
---|
public java.lang.String getName()
public void setName(java.lang.String name)
name
- the String name.public void setTexture(java.lang.String texture)
texture
- the name. If this is null, no testure will be used.public java.lang.String getTexture()
public void setTextureCoordinates(float[][] tc)
tc
- the texture coordinate array.public float[][] getTextureCoordinates()
public Model toLineModel(float width)
public Model extrude(float dist)
dist
- the scaling distance that will be added to each vertice's
position along it's normal vector.
public java.lang.Object clone()
clone
in class java.lang.Object
public void nameSegment(int vertex, java.lang.String name)
vertex
- the vertex index.name
- the name of the segment.public java.lang.String getSegment(int vertex)
vertex
- the vertex index top check.
public void setColoration(Coloration coloration)
coloration
- the Coloration object to set as default and then
activate.
java.lang.NullPointerException
- if coloration is null.public void addColoration(java.lang.String name, Coloration coloration)
name
- the name of the Coloration; this can be used to activate it
later.coloration
- the Coloration object to name and add.
java.lang.NullPointerException
- if name or coloration are null.public void activateColoration(java.lang.String name)
name
- the name of the Coloration to activate.
java.lang.IllegalArgumentException
- if there is no Coloration with that
name.public void addMeshElement(MeshElement me)
me
- the MeshElement to add.
java.lang.NullPointerException
- if me is null.public void storeToHierarchy(Hierarchy h)
h
- the Hierarchy object to store this Model to.public void draw(Context opt)
draw
in interface Visible
draw
in class DisplayList
opt
- the rendering Context to use for rendering.public void subDraw(Context opt, Coloration coloration, boolean texture)
opt
- the rendering Context to use for rendering.coloration
- the Coloration object to draw with.texture
- should this Model's texture be activated? (If it has one.)public void subDraw(Context opt)
DisplayList
subDraw
in class DisplayList
public int vertexCount()
public MeshElement[] getMeshElements()
public float[][] getVertices()
public void setNormals(float[][] n)
n
- the array of normal vectors. This must be the same length as
the number of vertices in this Model or null (if per-vertex normals are
not desired).public void calcNormals()
public float[][] getNormals()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |