Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

some examples? #16

Closed
bezumnui opened this issue Oct 15, 2022 · 3 comments
Closed

some examples? #16

bezumnui opened this issue Oct 15, 2022 · 3 comments

Comments

@bezumnui
Copy link

Yeap. There is some javadoc.
For example will take Renderer3d#renderFilled
params:
start - The start coordinate of the block
dimensions - The dimensions of the block
color - The color of the filling

so I'm trying to call render by:
var filled = Renderer3d.renderFilled(new Vec3d(0 - .5, 0 - .5, 0 - .5), new Vec3d(1, 1, 1), Color.CYAN);
filled.drawWithVBO(Renderer3d.getEmptyMatrixStack());

and result is:

image

I know that my code is bad. Because I don't know how to use this method. Help me please :)

@0x3C50
Copy link
Owner

0x3C50 commented Oct 15, 2022

you're not passing in the context matrixstack correctly, the matrixstack holds all rotations and transformations, including camera rotation. where are you calling the renderer from?

@bezumnui
Copy link
Author

ok. u are right) thank you. But example will be helpful. Something like:

Drawing cyan block overlay:

@Mixin(WorldRenderer.class)
public class WorldRendererMixin {
    @Inject(method = "drawBlockOutline", at = @At(value = "HEAD", target = "Lnet/minecraft/client/render/WorldRenderer;drawCuboidShapeOutline(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;Lnet/minecraft/util/shape/VoxelShape;DDDFFFF)V"))
    public void drawBlockOutlineMixin(MatrixStack matrices, VertexConsumer vertexConsumer, Entity entity, double cameraX, double cameraY, double cameraZ, BlockPos pos, BlockState state, CallbackInfo ci) {
        //    creating a render object
        var filled = Renderer3d.renderFilled(new Vec3d(pos.getX(), pos.getY(), pos.getZ()), new Vec3d(1, 1, 1), Color.CYAN);
        //    drawing object
        filled.drawWithVBO(matrices);
        //    deleting object from heap
        filled.delete();
    }
}

@0x3C50
Copy link
Owner

0x3C50 commented Oct 15, 2022

ok. u are right) thank you. But example will be helpful. Something like:

Drawing cyan block overlay:

@Mixin(WorldRenderer.class)
public class WorldRendererMixin {
    @Inject(method = "drawBlockOutline", at = @At(value = "HEAD", target = "Lnet/minecraft/client/render/WorldRenderer;drawCuboidShapeOutline(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;Lnet/minecraft/util/shape/VoxelShape;DDDFFFF)V"))
    public void drawBlockOutlineMixin(MatrixStack matrices, VertexConsumer vertexConsumer, Entity entity, double cameraX, double cameraY, double cameraZ, BlockPos pos, BlockState state, CallbackInfo ci) {
        //    creating a render object
        var filled = Renderer3d.renderFilled(new Vec3d(pos.getX(), pos.getY(), pos.getZ()), new Vec3d(1, 1, 1), Color.CYAN);
        //    drawing object
        filled.drawWithVBO(matrices);
        //    deleting object from heap
        filled.delete();
    }
}

I recommend not using drawWithVBO() if you're just drawing it once, that's overkill. VBOs are designed to cache big render actions so they don't have to be regenerated each time. For quick renders, don't use VBOs.

Example: Renderer3d.renderFilled(new Vec3d(pos.getX(), pos.getY(), pos.getZ()), new Vec3d(1, 1, 1), Color.CYAN).drawWithoutVBO(matrices);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants