net.jinx.video.model
Class SegmentColoration

java.lang.Object
  extended by net.jinx.video.model.SegmentColoration
All Implemented Interfaces:
Coloration

public class SegmentColoration
extends java.lang.Object
implements Coloration

Coloration implementation that names pieces of a Model based on vertex indices and then colors them by name. The names are stored in both Model and this class, but if names are specified via this class, the names in the Model will be ignored.

API Stability: Stable.


Constructor Summary
SegmentColoration()
          Constructs a new SegmentColoration.
 
Method Summary
 void draw(Context opt, int number, float[] vertex)
          Causes the Coloration to be drawn.
 Coloration getColoration(int vertex)
          Provides the Coloration associated with the given vertex, or null if there is none.
 Coloration getColoration(java.lang.String segment)
          Provides the Coloration associated with the given segment name.
 java.lang.String getSegment(int vertex)
          Provides the name of the segment for the given vertex.
 void load(net.jinx.db.Hierarchy h)
          Configures this Coloration from the given Hierarchy.
 void nameSegment(int vertex, java.lang.String name)
          Names a segment of the Model.
 void setColoration(java.lang.String segment, Coloration m)
          Sets the Coloration object associated with a given segment name.
 void store(net.jinx.db.Hierarchy h)
          Stores this Coloration to the given Hierarchy.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SegmentColoration

public SegmentColoration()
Constructs a new SegmentColoration.

Method Detail

draw

public void draw(Context opt,
                 int number,
                 float[] vertex)
Description copied from interface: Coloration
Causes the Coloration to be drawn. This should simply setup the OpenGL state according to the color that should be used.

Specified by:
draw in interface Coloration
Parameters:
opt - the rendering options that are being used. Implementatons of this interface should pay attention to the color related flags.
number - the current vertex number.
vertex - the current vertex position (x, y, and z coordinates).

nameSegment

public void nameSegment(int vertex,
                        java.lang.String name)
Names a segment of the Model. Everything between this vertex and the next named segment will be colored the same.

Parameters:
vertex - the vertex index.
name - the name of the segment.

getSegment

public java.lang.String getSegment(int vertex)
Provides the name of the segment for the given vertex. If the given vertex has not been set, this will return null. If you absolutely must know what segment a vertex is in, you'll have to count backwards until you find a named vertex.

Parameters:
vertex - the vertex index top check.
Returns:
the name of the vertex.

setColoration

public void setColoration(java.lang.String segment,
                          Coloration m)
Sets the Coloration object associated with a given segment name.

Parameters:
segment - the name of the segment.
m - the Coloration to associate with the segment name.

getColoration

public Coloration getColoration(java.lang.String segment)
Provides the Coloration associated with the given segment name.

Parameters:
segment - the segment name.
Returns:
the Coloration. This can return null.

getColoration

public Coloration getColoration(int vertex)
Provides the Coloration associated with the given vertex, or null if there is none.

Parameters:
vertex - the vertex index.
Returns:
the Coloration.

load

public void load(net.jinx.db.Hierarchy h)
Description copied from interface: Coloration
Configures this Coloration from the given Hierarchy. This is not meant to be called directly, unless you intend to configure a specific Coloration object.
This method is actually designed to be called by the loadColoration(net.jinx.db.Hierarchy) method of ModelUtil, which will construct and return an instance of any Coloration class. This is the reason that all Coloration classes must have a no argument constructor. ModelUtil.loadColoration(net.jinx.db.Hierarchy) needs that to do it's job. By the time this method is called, the type of the coloration has already been determined and constructed and is now ready to be configured.

Specified by:
load in interface Coloration
Parameters:
h - the Hierarchy to configure this Coloration from.

store

public void store(net.jinx.db.Hierarchy h)
Description copied from interface: Coloration
Stores this Coloration to the given Hierarchy. This is not meant to be called directly, unless you know you're going to be using a specific Coloration implementation.
This method is actually designed to be called by the store(net.jinx.db.Hierarchy, Coloration) method of ModelUtil, which stores the name of the class to use, so that when the loadColoration(net.jinx.db.Hierarchy) method of ModelUtil is used, the class can be instantiated and used.

Specified by:
store in interface Coloration
Parameters:
h - the Hierarchy to store this Coloration to.