|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--Renderer.ModelLibrary
Maintains a library of models that are available to the system. It indexes a set of Wavefront .obj files and optionally allows each to be normalized to a consistent form. A requested model is returned in the form of a ModelTemplate, which defines a generic template and must be cloned to create an instance that can be configured independently.
Each line of the index file is defined as A B [C] [D] [E] [F] [G] [/S], where
A - unique toy name
B - model filename with extension
C - attitude adjustment: {A:pitch,roll,yaw}
D - dimensions adjustment: {D:height,width,depth}
E - position adjustment: {P:x,y,z}
F - scale adjustment: {S:scale}
G - color {C:red,green,blue}
H - transparency {T:percent}
/S - suppress warning messages for missing textures
Fields C, D, E, F, G, and H are optional, may appear in any order, and
accept negative values if appropriate. No spaces are permitted within the braces. Switch /S is also optional and
should appear last.
Use the optional parameters to adjust the model so that it is facing upright and toward the screen, is scaled appropriately, is centered when positioned at x=z=0, and is located on the ground at y=0.
ModelTemplate| Field Summary | |
private char |
ADJUSTMENT_CODE_ATTITUDE
|
private char |
ADJUSTMENT_CODE_COLOR
|
private char |
ADJUSTMENT_CODE_DIMENSIONS
|
private char |
ADJUSTMENT_CODE_POSITION
|
private char |
ADJUSTMENT_CODE_SCALE
|
private char |
ADJUSTMENT_CODE_TRANSPARENCY
|
private java.lang.String |
FIELD_DELIMITER
|
private java.lang.String |
INDEX_FILENAME
|
private boolean |
IS_LOGGED
|
private java.lang.String |
LEXEME_COMMENT
|
private java.lang.String |
LEXEME_SET_ELEMENT_DELIMITER
|
private java.util.Hashtable |
m_models
|
private java.lang.String |
MODEL_FORMAT_3DS
|
private java.lang.String |
MODEL_FORMAT_OBJ
|
private boolean |
SUPPRESS_NORMALIZATION
|
private java.lang.String |
SWITCH_SUPPRESS_TEXTURE_WARNINGS
|
private java.lang.String |
WARNING_FILENAME
|
| Constructor Summary | |
ModelLibrary()
Creates a new ModelLibrary with all known models available. |
|
ModelLibrary(java.util.ArrayList allocated_models)
Creates a new ModelLibrary with only the requested models available. |
|
| Method Summary | |
private void |
configureModel(ModelTemplate model_template,
java.util.Enumeration elements,
java.lang.String toy_identifier,
boolean is_wireframe,
float transparency,
javax.vecmath.Color3f override_color)
Configures a model as specified by recursively processing each branch of its Java3D node structure. |
ModelTemplate |
getModel(java.lang.String model_name,
java.lang.String toy_identifier,
boolean is_wireframe,
float transparency,
javax.vecmath.Color3f override_color)
Returns a derived instance of a model that has been configured as specified. |
private void |
loadModelLibrary(java.util.ArrayList allocated_models)
Loads all or part of the model library. |
java.lang.String |
toString()
Returns a string representation of this object. |
private void |
writeStatus(java.lang.String message)
Conditionally writes a status message to stdout. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
private final boolean SUPPRESS_NORMALIZATION
private final java.lang.String INDEX_FILENAME
private final java.lang.String WARNING_FILENAME
private final java.lang.String MODEL_FORMAT_OBJ
private final java.lang.String MODEL_FORMAT_3DS
private final java.lang.String LEXEME_COMMENT
private final java.lang.String LEXEME_SET_ELEMENT_DELIMITER
private final java.lang.String FIELD_DELIMITER
private final char ADJUSTMENT_CODE_ATTITUDE
private final char ADJUSTMENT_CODE_DIMENSIONS
private final char ADJUSTMENT_CODE_POSITION
private final char ADJUSTMENT_CODE_SCALE
private final char ADJUSTMENT_CODE_COLOR
private final char ADJUSTMENT_CODE_TRANSPARENCY
private final java.lang.String SWITCH_SUPPRESS_TEXTURE_WARNINGS
private java.util.Hashtable m_models
private final boolean IS_LOGGED
| Constructor Detail |
public ModelLibrary()
throws java.lang.Exception
java.lang.Exception - - if the library cannot be created or loaded
public ModelLibrary(java.util.ArrayList allocated_models)
throws java.lang.Exception
allocated_models - - the models to load, specified by model name
java.lang.Exception - - if the library cannot be created or loaded| Method Detail |
private void configureModel(ModelTemplate model_template,
java.util.Enumeration elements,
java.lang.String toy_identifier,
boolean is_wireframe,
float transparency,
javax.vecmath.Color3f override_color)
model_template - - the model templateelements - - the nodel elements, acquired via Node.getAllChildren()toy_identifier - - the name of the toy that will be using this modelis_wireframe - - whether the model is rendered in wireframetransparency - - the model transparencyoverride_color - - the optional color overriding the defined color of this model; otherwise null
private void loadModelLibrary(java.util.ArrayList allocated_models)
throws java.lang.Exception
Side Effect: optionally pretty-prints details of load process to stdout.
allocated_models - - the models to load, or all if null
java.lang.Exception - - if the load fails for any reason
public ModelTemplate getModel(java.lang.String model_name,
java.lang.String toy_identifier,
boolean is_wireframe,
float transparency,
javax.vecmath.Color3f override_color)
throws java.lang.Exception
model_name - - the model nametoy_identifier - - the name of the toy that will be using this modelis_wireframe - - whether the model is rendered in wireframetransparency - - the model transparencyoverride_color - - the optional color overriding the defined color of this model; otherwise null
java.lang.Exception - - if the model does not exist or was not requested to be available in the constructorpublic java.lang.String toString()
toString in class java.lang.ObjectSupport.toPrettyString(java.lang.String)private void writeStatus(java.lang.String message)
message - - the message, which is responsible for its own newline
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||