Processing OBJ Loader version 013
What is this?
This is the polymonkey mirror to the processing obj loader. The obj loader was started by Tatsuya Saito, all fame / credit / vast donations should go to him. I got involved because I needed to extend some functionality so all hate mail and error complaints can be thrown my way.
Where can I get this?
Saito's site is the true home of the obj loader. So go there and get the official release. But Saito is a busy man (that's why I'm helping out) so I'm keeping a copy of the latest version below. That's why it's called a mirror.
Processing OBJ Loader version 013 - 22/07/2007
The Library
The Sample
The Source
How do I do this?
This is a list of all current functions in the obj loader. Example use can be seen in the above sample project.
- void load(String filename)
- example -> model.load(filename.obj)
- description -> loads a model file.
- void draw()
- example -> model.draw()
- description -> draws the model.
- void drawMode(int mode)
- example -> model.drawMode(mode)
- description -> set render mode (ex. TRIANGLES, POLYGON, LINES etc.) Basically the argument to this function is same as the one given to beginShape(). POINTS mode isn't reliable in OPENGL. And you've got to turn stroke on to see LINES. TRIANGLES and QUADS are the most reliable but it depends on your export setting.
- void setTexture(PImage)
- example -> model.setTexture(PImage)
- description -> swap the model texture with the specified PImage.
- void enableTexture()
- example -> model.enableTexture()
- description -> enable texture rendering. This is on by default.
- void disableTexture()
- example -> model.disableTexture()
- description -> disable texture rendering.
- void originalTexture()
- example -> model.originalTexture()
- description -> turns on the original texture that is mentioned in the mtl file. This is a useful function once you've gone a little crazy with the setTexture function.
- void enableLocalTexture()
- example -> model.enableLocalTexture()
- description -> Use this function before the load function to get the texture from the DATA folder. Some packages (like XSI) save absolute paths into the texture name of the mtl file. This helper function removes the text before the texture filename. At the moment it uses the windows '/' as a separator. I don't have a Mac or run Linux so if anyone would like to throw an exported mtl file my way I'd be happy to make them work too.
- void enableMaterial()
- example -> model.enableMaterial()
- description -> enables the use of the exported material this is on by default.
- void disableMaterial()
- example -> model.disableMaterial()
- description -> disables the use of the exported material. Using this means that you can use fill() before the model draw to set the material to any crazy color.
- void clear()
- example -> model.clear()
- description -> clears all model data from the model. This way you can get rid of the loaded obj and reload another one.
- int getVertexsize()
- example -> model.getVertexsize()
- description -> returns the number of vertexes that the model contains.
- Vertex getVertex(int index)
- example -> model.getVertex(pickNumber)
- description -> returns the vertex data specified by array index.
Why the hell did it do this?
These two commands are for debugging, they are off by default. But if weird things are happening they can help.
- void debugMode()
- example -> model.debugMode()
- description -> Set debug mode. Once this function is called the library outputs debug messages. This function works as a toggle and is off by default.
- void showModelInfo()
- example -> model.showModelInfo()
- description -> call debugMode() before using this function. Outputs model information, such as vertex data, facets structure and material info, in the debug window.
Can I tell you all about my problems?
Yes you can. In fact I'd love you too. It's the only way I can make sure that all the bugs are ironed out. So feel free to drop me an email. You can also send massive praise or calls for help to Saito. You can find him at his site. If all this fails you can try the hive mind over at the processing forums.