ObjFace
final class ObjFace
Package: dev.joid.lib.obj.data · Module: core · Source: ObjFace.java
One triangle of an ObjModel, with its vertices, its optional texture coordinates and normals, and the normal of its plane.
Learn more
Section titled “Learn more”Creation
Section titled “Creation”| Returns | Signature | Summary |
|---|---|---|
ObjFace | of(ObjVertex[] vertices, ObjTextureCoordinate[] textureCoordinates, ObjVertex[] vertexNormals) factory | Creates a triangle from 3 vertices, and 3 texture coordinates and 3 normals or null for none; an empty array of texture coordinates also means none. |
Methods
Section titled “Methods”| Returns | Signature | Summary |
|---|---|---|
void | render(Tessellator tessellator) | Adds the triangle to tessellator, which must be started in DrawMode.TRIANGLES: with its vertex normals when it has some, otherwise with the normal of its plane. |
ObjVertex[] | getVertices() | Returns a copy of the 3 vertices. |
ObjVertex[] | getVertexNormals() | Returns a copy of the 3 normals, or null when the face has none. |
ObjTextureCoordinate[] | getTextureCoordinates() | Returns a copy of the 3 texture coordinates, or null when the face has none. |
ObjVertex | getFaceNormal() | Returns the unit normal of the plane of the triangle, from the winding of its vertices. |
Creation details
Section titled “Creation details”ObjFace of(ObjVertex[] vertices, ObjTextureCoordinate[] textureCoordinates, ObjVertex[] vertexNormals) factory
Throws:
IllegalArgumentException: An ObjFace has 3 vertices, got …: split the polygon into triangles (ObjModel does it for OBJ files)IllegalArgumentException: An ObjFace has 3 texture coordinates or none, got …IllegalArgumentException: An ObjFace has 3 vertex normals or none, got …
Creates a triangle from 3 vertices, and 3 texture coordinates and 3 normals or null for none; an empty array of texture coordinates also means none.
Throws IllegalArgumentException for any other count.
The normal of the plane is computed at once; a degenerate triangle gets (0, 0, 1).
Method details
Section titled “Method details”render
Section titled “render”void render(Tessellator tessellator)
Adds the triangle to tessellator, which must be started in DrawMode.TRIANGLES: with its vertex normals when it has some, otherwise with the normal of its plane.
Texture coordinates move by 0.0005 toward the middle of the triangle, so that a texture atlas does not bleed at the edges.
getVertices
Section titled “getVertices”ObjVertex[] getVertices()
Returns a copy of the 3 vertices.
getVertexNormals
Section titled “getVertexNormals”ObjVertex[] getVertexNormals()
Returns a copy of the 3 normals, or null when the face has none.
getTextureCoordinates
Section titled “getTextureCoordinates”ObjTextureCoordinate[] getTextureCoordinates()
Returns a copy of the 3 texture coordinates, or null when the face has none.
getFaceNormal
Section titled “getFaceNormal”ObjVertex getFaceNormal()
Returns the unit normal of the plane of the triangle, from the winding of its vertices.
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
