Skip to content

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.

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).

ReturnsSignatureSummary
ObjModelof(String name, Object handle, Resource texture) factoryReads the model name from anything Asset.of accepts, as UTF-8 text, drawn with texture.

ReturnsSignatureSummary
voidrender()Draws every group with the texture bound and repeated, in model units.
doublegetDepth()Returns the extent of the vertices along Z, in model units.
doublegetWidth()Returns the extent of the vertices along X, in model units.
doublegetHeight()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.
StringgetName()Returns the name given to of, shown in the error messages.
ResourcegetTexture()Returns the texture the model draws with.

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.

void render()

Draws every group with the texture bound and repeated, in model units. JOID calls it from DrawModel.drawModel.

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.


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

Report a problem with this page