Skip to content

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.

ReturnsSignatureSummary
ObjFaceof(ObjVertex[] vertices, ObjTextureCoordinate[] textureCoordinates, ObjVertex[] vertexNormals) factoryCreates 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.

ReturnsSignatureSummary
voidrender(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.
ObjVertexgetFaceNormal()Returns the unit normal of the plane of the triangle, from the winding of its vertices.

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

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.

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.


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