#Render 3d Box
103 messages · Page 1 of 1 (latest)
same question here :D
This question has surely been answered previously. One option is to use WoldRenderer.drawBox
if you find anything let me know and i'll let you know if I find anything
I need to be able to render cyl too though
cyl?
cylinder most likely
Impossible, in minecraft?!?!
with gl its not
That was a joke :8

yes
how do I do that
Use Tesselator and supply vertices in the correct order
wait what
i thought tesselator was for
like
hud elements
?
can i have an example
of like a box or something
Doesnt WorlderRenderer.drawbox use Tesselator
not sure
public static void drawBox(Vector3d cam, VertexConsumer vertexConsumer, Box box, float red, float green, float blue, float alpha) {
float minX = (float) (box.minX - cam.x);
float minY = (float) (box.minY - cam.y);
float minZ = (float) (box.minZ - cam.z);
float maxX = (float) (box.maxX - cam.x);
float maxY = (float) (box.maxY - cam.y);
float maxZ = (float) (box.maxZ - cam.z);
...
}
vertexConsumer.vertex(minX, minY, minZ).color(red, green, blue, alpha);
vertexConsumer.vertex(maxX, minY, minZ).color(red, green, blue, alpha);
vertexConsumer.vertex(minX, minY, minZ).color(red, green, blue, alpha);
vertexConsumer.vertex(minX, maxY, minZ).color(red, green, blue, alpha);
vertexConsumer.vertex(minX, minY, minZ).color(red, green, blue, alpha);
vertexConsumer.vertex(minX, minY, maxZ).color(red, green, blue, alpha);
vertexConsumer.vertex(maxX, minY, minZ).color(red, green, blue, alpha);
vertexConsumer.vertex(maxX, maxY, minZ).color(red, green, blue, alpha);
vertexConsumer.vertex(maxX, maxY, minZ).color(red, green, blue, alpha);
vertexConsumer.vertex(minX, maxY, minZ).color(red, green, blue, alpha);
vertexConsumer.vertex(minX, maxY, minZ).color(red, green, blue, alpha);
vertexConsumer.vertex(minX, maxY, maxZ).color(red, green, blue, alpha);
vertexConsumer.vertex(minX, maxY, maxZ).color(red, green, blue, alpha);
vertexConsumer.vertex(minX, minY, maxZ).color(red, green, blue, alpha);
vertexConsumer.vertex(minX, minY, maxZ).color(red, green, blue, alpha);
vertexConsumer.vertex(maxX, minY, maxZ).color(red, green, blue, alpha);
vertexConsumer.vertex(maxX, minY, maxZ).color(red, green, blue, alpha);
vertexConsumer.vertex(maxX, minY, minZ).color(red, green, blue, alpha);
vertexConsumer.vertex(minX, maxY, maxZ).color(red, green, blue, alpha);
vertexConsumer.vertex(maxX, maxY, maxZ).color(red, green, blue, alpha);
vertexConsumer.vertex(maxX, minY, maxZ).color(red, green, blue, alpha);
vertexConsumer.vertex(maxX, maxY, maxZ).color(red, green, blue, alpha);
vertexConsumer.vertex(maxX, maxY, minZ).color(red, green, blue, alpha);
vertexConsumer.vertex(maxX, maxY, maxZ).color(red, green, blue, alpha);
Didn't fit in one message
Yea more or less
You can call that function like so:
BufferBuilder vertices = Tessellator.getInstance().begin(VertexFormat.DrawMode.DEBUG_LINES, VertexFormats.POSITION_COLOR);
RenderSystem.setShader(GameRenderer::getPositionColorProgram);
drawBox(cam, vertices, box, 0.6f, 1f, 0.5f, 1f);
BufferRenderer.drawWithGlobalProgram(vertices.end());
It seems that 1.21.3 doesnt have WorldRenderer#drawBox anymore
So just copy this function
Yeah its the camera position
MinecraftClient.getInstance().getCameraEntity().getCameraPosVec(tickDelta)
ok
But you get it passed as a parameter in most rendering functions
couldnt I put vertex consumer and camera in the rendering file
Not sure what you mean by that
like
instead of passing it into the function
why dont I just
not pass it in
and have it in the function
Yes you can do that
okay
But if you want to draw a lot of boxes this method isn't very efficent
how do I get tick delta
what should I put
since I dont have tick delta
in my render function
ok
how can we make this function not have Box, but x, y, z, width, height
Just change the parameters?
yeah, but for things like box.maxX or whatever it wouldn't work
maxX is just x + width
Well unless you want x,y,z to specify the center
Then minX is x - width/2 and maxX is x + width/2
ThreeDimRenderer.drawBox(5, 5, 5, 2, 2, 2, 255, 255, 255, 255);
doesn't seem to draw anything
You're calling it every frame?
yes
Make a void world and go to 0,0,0, see if you see anything
okay nevermind I had to make it bigger
but uh
its not really..
boxing
it's just a two dim square on my screen and sometimes moves when i turn my camera
moves when I move my player*
You're probably drawing at a time which isn't suited for 3d rendering
The RenderSystem state must be set up correctly
Such as the view and projection matrix
It's simplest to just move your draw call elsewhere
For example one of the fapi render callbacks
oh
uhhh
that's where I activate it