ObjModel
final class ObjModel
Implements: IDrawableModel
Package: dev.joid.lib.obj · Module: core · Source: ObjModel.java
A 3D model read from a Wavefront .obj file, drawn with one texture.
Description
Section titled “Description”Load it once and keep it in a field (Load a model); a model node or DrawModel draws it.
The file is read at once, on the calling thread (Know what JOID reads in a .obj file).
Learn more
Section titled “Learn more”Creation
Section titled “Creation”| Returns | Signature | Summary |
|---|---|---|
ObjModel | of(String name, Object handle, Resource texture) factory | Reads the model name from anything Asset.of accepts, as UTF-8 text, drawn with texture. |
Methods
Section titled “Methods”| Returns | Signature | Summary |
|---|---|---|
void | render() | Draws every group with the texture bound and repeated, in model units. |
double | getDepth() | Returns the extent of the vertices along Z, in model units. |
double | getWidth() | Returns the extent of the vertices along X, in model units. |
double | getHeight() | Returns the extent of the vertices along Y, in model units. |
List<ObjVertex> | getVertices() | Returns every vertex of the file, in order, as a list you cannot change. |
List<ObjVertex> | getVertexNormals() | Returns every normal of the file, in order, as a list you cannot change. |
List<ObjTextureCoordinate> | getTextureCoordinates() | Returns every texture coordinate of the file, in order, with V flipped so that 0 is the top of the texture, as a list you cannot change. |
List<ObjGroup> | getGroups() | Returns the groups, in order, as a list you cannot change; faces before the first g or o line form the group Default. |
String | getName() | Returns the name given to of, shown in the error messages. |
Resource | getTexture() | Returns the texture the model draws with. |
Creation details
Section titled “Creation details”ObjModel of(String name, Object handle, Resource texture) factory
Reads the model name from anything Asset.of accepts, as UTF-8 text, drawn with texture.
Throws IllegalArgumentException that names the line when the file is malformed: a line that does not parse, an index out of range, or a group that mixes faces with and without texture coordinates.
Throws UncheckedIOException when the file cannot be read.
Method details
Section titled “Method details”render
Section titled “render”void render()
Draws every group with the texture bound and repeated, in model units.
JOID calls it from DrawModel.drawModel.
getDepth
Section titled “getDepth”double getDepth()
Returns the extent of the vertices along Z, in model units.
getWidth
Section titled “getWidth”double getWidth()
Returns the extent of the vertices along X, in model units.
getHeight
Section titled “getHeight”double getHeight()
Returns the extent of the vertices along Y, in model units.
getVertices
Section titled “getVertices”List<ObjVertex> getVertices()
Returns every vertex of the file, in order, as a list you cannot change.
getVertexNormals
Section titled “getVertexNormals”List<ObjVertex> getVertexNormals()
Returns every normal of the file, in order, as a list you cannot change.
getTextureCoordinates
Section titled “getTextureCoordinates”List<ObjTextureCoordinate> getTextureCoordinates()
Returns every texture coordinate of the file, in order, with V flipped so that 0 is the top of the texture, as a list you cannot change.
getGroups
Section titled “getGroups”List<ObjGroup> getGroups()
Returns the groups, in order, as a list you cannot change; faces before the first g or o line form the group Default.
getName
Section titled “getName”String getName()
Returns the name given to of, shown in the error messages.
getTexture
Section titled “getTexture”Resource getTexture()
Returns the texture the model draws with.
fluent returns the instance, typed for chaining · factory creates an instance · signal also accepts a value that follows signals, as a signal, an expression or a lambda (When does JOID compute this value again?) · hook called by JOID, override it · abstract you implement it · default interface method with a body · static called on the class · protected visible to subclasses
