Class ObjModel
.obj file: triangles with positions, texture coordinates and normals, in
named parts. Get one from ObjModels.get(Identifier) (a resource, cached and reloaded with resource
packs) or parse(String) (any text).
What is read: v, vt, vn and f (faces of any number of corners, cut into
triangles as a fan; indices counted from the end; corners with no texture coordinate or no normal), and o,
g and usemtl, which begin a new part. A face with no normals gets its own flat one. Materials
(.mtl) are not read: a part carries its material's name and the caller picks the texture, so one model can
be drawn in any render type. Everything else in the file is passed over.
Units are the file's own: one unit is one block unless the pose is scaled. Texture coordinates are turned to
the game's (the file's v runs up, the game's down).
Drawing goes through the game's own renderers, so a model is lit, fogged and sorted as anything else is:
submit(PoseStack, SubmitNodeCollector, RenderType, int) from an entity or block entity renderer, or render(PoseStack.Pose, VertexConsumer, int, int, int) into any vertex consumer. Both are made
for render types that draw quads with the entity vertex format (RenderTypes.entityCutout(texture),
entityTranslucent, eyes...): each triangle is sent as a quad with its last corner twice.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA stretch of a model drawn as one: the faces under oneo,gorusemtlline. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionbooleanisEmpty()org.joml.Vector3fmax()The greatest corner of the box the model fills.org.joml.Vector3fmin()The least corner of the box the model fills.static ObjModelReads a model from an.objfile.static ObjModelReads a model from the text of an.objfile.The first part of this name (anoorgline's), or null.parts()The model's parts, in the file's order.voidrender(com.mojang.blaze3d.vertex.PoseStack.Pose pose, com.mojang.blaze3d.vertex.VertexConsumer consumer, int light, int overlay, int argb) Writes every part into a vertex consumer.voidsubmit(com.mojang.blaze3d.vertex.PoseStack pose, net.minecraft.client.renderer.SubmitNodeCollector collector, net.minecraft.client.renderer.rendertype.RenderType type, int light) Every part, white, with no overlay.voidsubmit(com.mojang.blaze3d.vertex.PoseStack pose, net.minecraft.client.renderer.SubmitNodeCollector collector, net.minecraft.client.renderer.rendertype.RenderType type, int light, int overlay, int argb) Hands every part to the game to draw in one render type, from a renderer'ssubmit.int
-
Field Details
-
EMPTY
A model with nothing in it: what a missing or broken file gives.
-
-
Method Details
-
parts
The model's parts, in the file's order. -
part
The first part of this name (anoorgline's), or null. -
isEmpty
public boolean isEmpty() -
triangles
public int triangles() -
min
public org.joml.Vector3f min()The least corner of the box the model fills. -
max
public org.joml.Vector3f max()The greatest corner of the box the model fills. -
submit
public void submit(com.mojang.blaze3d.vertex.PoseStack pose, net.minecraft.client.renderer.SubmitNodeCollector collector, net.minecraft.client.renderer.rendertype.RenderType type, int light) Every part, white, with no overlay. -
submit
public void submit(com.mojang.blaze3d.vertex.PoseStack pose, net.minecraft.client.renderer.SubmitNodeCollector collector, net.minecraft.client.renderer.rendertype.RenderType type, int light, int overlay, int argb) Hands every part to the game to draw in one render type, from a renderer'ssubmit.- Parameters:
light- packed light, as renderers are given it (0xF000F0for a thing that glows)overlay- packed overlay (OverlayTexture.NO_OVERLAY)argb- a tint,0xAARRGGBB; alpha only shows in a translucent render type
-
render
public void render(com.mojang.blaze3d.vertex.PoseStack.Pose pose, com.mojang.blaze3d.vertex.VertexConsumer consumer, int light, int overlay, int argb) Writes every part into a vertex consumer. -
parse
-
parse
Reads a model from an.objfile.- Throws:
IllegalArgumentException- if a line that is read cannot be understood (the message names the line)IOException
-