|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsaito.objloader.OBJModel
public class OBJModel
Field Summary | |
---|---|
static java.lang.String |
ABSOLUTE
|
Debug |
debug
|
static java.lang.String |
RELATIVE
|
Constructor Summary | |
---|---|
OBJModel(PApplet _parent)
Class Constructor to setup an empty obj model |
|
OBJModel(PApplet _parent,
java.lang.String _filename)
Class Constructor, loads the file from the data directory |
|
OBJModel(PApplet _parent,
java.lang.String _fileName,
int _shapeMode)
Class Constructor, loads the string as an obj from the data directory. |
|
OBJModel(PApplet _parent,
java.lang.String _fileName,
java.lang.String _texturePathMode)
Class Constructor, loads the file from the data directory. use String "relative" to search the data folder for the mtl and textures use "absolute" to load the files from the specific path |
|
OBJModel(PApplet _parent,
java.lang.String _fileName,
java.lang.String _texturePathMode,
int _shapeMode)
Class Constructor, loads the string as an obj from the data directory. |
Method Summary | |
---|---|
void |
clampUV()
Helper function to clamp the UV's so they sit within 0-1. |
void |
disableDebug()
|
void |
disableMaterial()
Disables the material completely. With this on you can set the appearance of the model in processing before calling model.draw(); background(32); stroke(255); noFill(); model.draw(); |
void |
disableTexture()
Turns off the use of the textures in mtl file. |
void |
draw()
The draw method of the OBJModel. This method used the standard Processing system of beginShape, endShape to draw the model. |
void |
drawGL()
Draws the obj model using the Vertex Buffers that were made in the setupOPENGL method NOTE: this method is on the way out. |
void |
enableDebug()
Enables the debug mode. Prints version and contact information to the console. |
void |
enableMaterial()
Turns on the use of the material that came from the mtl file |
void |
enableTexture()
Turns on the use of textures that are listed in the mtl file |
int |
getDrawMode()
Gets the drawmode |
int |
getFaceCount()
Gets the total number of faces in the model. This is the total of the index count across all segments This is mostly used when you need raw verts for physics simulation |
Face |
getFaceInSegment(int _segmentIndex,
int _faceIndex)
|
PVector[] |
getFaceVertices(int faceNumber)
Gets an array of PVectors that make up the position co-ordinates of the face. This method needs one int that must be between 0 and the getTotalFaceCount() This is mostly used when you need raw verts for physics simulation Personally I wouldn't do this during draw. |
Group |
getGroup(java.lang.String groupName)
Returns the group via name Until I find a practical use for Groups this feature isn't going anywhere. |
int |
getGroupCount()
Gets the size of the Groups from the obj Model. |
int |
getIndexCountInSegment(int i)
Gets the number of Indexes in the Segment. |
PVector |
getNormal(int i)
Returns a reference to a numbered Normal. |
int |
getNormalCount()
Get's the total number of Normals in the model. |
int[] |
getNormalIndicesInSegment(int i,
int num)
Returns an array of ints. |
Segment |
getSegment(int _index)
|
int |
getSegmentCount()
Gets the number of segments in the model. A segment is a unique material and an array of indexes into the vert, norm and uv Vectors |
int[] |
getTextureIndicesInSegment(int i,
int num)
Returns an array of ints. |
java.lang.String |
getTexturePathMode()
Should return "relative" or "absolute" |
PVector |
getUV(int i)
Returns a reference to a numbered Textured Coordinate. |
int |
getUVCount()
Get's the total number of UVs in the model. |
PVector |
getVertex(int i)
Returns a reference to a numbered Vertex. |
int |
getVertexCount()
Get's the total number of Verts in the model. |
int[] |
getVertexIndicesInSegment(int i,
int num)
Returns an array of ints. |
void |
load(java.lang.String filename)
The manual load method for obj files. |
void |
mapUVToZeroOne()
Helper function to scale the UV's so they sit within 0-1. |
void |
originalTexture()
Sets the override texture back to null. |
void |
printModelInfo()
A Debug method that prints information about the loaded model This method only prints information if the debugMode is true. V Size = The number of vertex positions Vt Size = The number of UV positions Vn Size = The number of normals G Size = the number of Groups in the model S Size = the number of segments in the model, this should directly equate to the number of unique materials in the mtl file |
void |
reset()
Clears all Vectors ready for loading in a new model. Doing something like this OBJModel model = new OBJModel(this, "myobj.obj"); // do something with model model.clear(); model.load("myobj.obj"); is vastly better for memory use than doing something like this OBJModel model = new OBJModel(this, "myobj.obj"); // do something with model model = new OBJModel(this, "myOtherObj.obj"); The second example is really bad because the original model is still in memory but nothing is pointing to it. We would have to wait for the Garbage Collector to do the clean up before freeing the memory. |
void |
scale(float scale)
Scales the vertex positions of the model. |
void |
scale(float scaleX,
float scaleY,
float scaleZ)
Scales the vertex positions of the model. |
void |
setDrawMode(int _drawMode)
Sets the draw mode of the shape drawing |
void |
setNormal(int i,
PVector normal)
Sets the Normal at index i to the PVector supplied |
void |
setTexture(PImage textureName)
Sets an override texture for the drawing of the model. Any PImage supplied will be used over all model segments NOTE: This method is identical to texture(), It has the better syntax. |
void |
setTexturePathMode(java.lang.String _texturePathMode)
Use "relative" or "absolute" to set the texture load method |
void |
setupGL()
Called after loading the obj model. |
void |
setUV(int i,
PVector uv)
Sets the UV at index i to the PVector supplied |
void |
setVertex(int i,
float x,
float y,
float z)
Sets the vert at index i to the x,y,z values supplied |
void |
setVertex(int i,
PVector vertex)
Sets the vert at index i to the PVector supplied |
void |
shapeMode(int mode)
Set's the beginShape mode for drawing the model. |
void |
texture(PImage tex)
Sets an override texture for the drawing of the model. Any PImage supplied will be used over all model segments |
void |
translate(PVector p)
Translates all the verts by the PVector amount |
void |
translateToCenter()
Helper function to move the origin point of the model to the center of the objects BoundingBox |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static java.lang.String RELATIVE
public static java.lang.String ABSOLUTE
public Debug debug
Constructor Detail |
---|
public OBJModel(PApplet _parent)
public OBJModel(PApplet _parent, java.lang.String _filename)
public OBJModel(PApplet _parent, java.lang.String _fileName, int _shapeMode)
public OBJModel(PApplet _parent, java.lang.String _fileName, java.lang.String _texturePathMode)
public OBJModel(PApplet _parent, java.lang.String _fileName, java.lang.String _texturePathMode, int _shapeMode)
Method Detail |
---|
public void setupGL()
public void drawGL()
public void printModelInfo()
public void enableDebug()
public void disableDebug()
public void reset()
public void disableTexture()
public void enableTexture()
public void disableMaterial()
public void enableMaterial()
public void shapeMode(int mode)
int
- public void draw()
public void load(java.lang.String filename)
public void scale(float scale)
scale
- public void scale(float scaleX, float scaleY, float scaleZ)
scaleX
- scaleY
- scaleZ
- public void translate(PVector p)
p
- public void translateToCenter()
public void mapUVToZeroOne()
public void clampUV()
public void setDrawMode(int _drawMode)
_drawMode
- public int getDrawMode()
public void setTexturePathMode(java.lang.String _texturePathMode)
_texturePathMode
- public java.lang.String getTexturePathMode()
public int getGroupCount()
public Group getGroup(java.lang.String groupName)
String
-
public Segment getSegment(int _index)
public Face getFaceInSegment(int _segmentIndex, int _faceIndex)
public int getSegmentCount()
public int getFaceCount()
public PVector[] getFaceVertices(int faceNumber)
public int getIndexCountInSegment(int i)
int
-
public int[] getVertexIndicesInSegment(int i, int num)
int
- int
-
public int[] getNormalIndicesInSegment(int i, int num)
int
- int
-
public int[] getTextureIndicesInSegment(int i, int num)
int
- int
-
public int getVertexCount()
public int getNormalCount()
public int getUVCount()
public PVector getVertex(int i)
int
-
public PVector getNormal(int i)
int
-
public PVector getUV(int i)
int
-
public void setVertex(int i, PVector vertex)
int
- PVector
- public void setVertex(int i, float x, float y, float z)
i
- x
- y
- z
- public void setNormal(int i, PVector normal)
int
- PVector
- public void setUV(int i, PVector uv)
int
- PVector
- public void setTexture(PImage textureName)
PImage
- public void texture(PImage tex)
PImage
- public void originalTexture()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |