Jump to content

Recommended Posts

Posted (edited)

Hey, I'm trying to add my own complex models to the game, but I'm not sure how to use the Tessellator, are there any good tutorials/guides/books available for me to read up on? Thanks

Edited by GooberGunter
Posted
On 8/29/2018 at 2:47 AM, GooberGunter said:

Hey, I'm trying to add my own complex models to the game, but I'm not sure how to use the Tessellator, are there any good tutorials/guides/books available for me to read up on? Thanks

Directly interacting with the tesselator & buferbuilder is probably not what you want to do unless your already pretty experienced in OpenGL and advanced 3D rendering. What are you trying to achieve exactly? What do you mean by complex models and why & where & when will they be used?

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted

Specifically, I wanna use Wavefront .obj models for custom mobs. My goal is to get familiar with 3D rendering. All I really need to know is how 3D rendering is done. From what I’ve seen it looks like the tessellator just needs the vertices of the model for correct positioning and then the normals of the faces to render the shape of the model. I’m not sure if that’s how it works, but I haven’t checked out too much code yet. Is this right?

Posted (edited)
35 minutes ago, GooberGunter said:

Specifically, I wanna use Wavefront .obj models for custom mobs. My goal is to get familiar with 3D rendering. All I really need to know is how 3D rendering is done. From what I’ve seen it looks like the tessellator just needs the vertices of the model for correct positioning and then the normals of the faces to render the shape of the model. I’m not sure if that’s how it works, but I haven’t checked out too much code yet. Is this right?

You definitely don't need to deal with the tesselator & bufferbuilder for this, look at the Forge Animation API, or you could just inject the models you need into the model registry & render them normally with an entity renderer.

 

Example of injecting models

https://github.com/Cadiboo/WIPTechAlpha/blob/fbf25447cd02b3dc4fe4fece749c3558f9342f3f/src/main/java/cadiboo/wiptech/EventSubscriber.java#L464-L509 

(Right below that code is a good example of why not to use the tesselator)

 

Example of rendering an entity with the injected models

https://github.com/Cadiboo/WIPTechAlpha/blob/master/src/main/java/cadiboo/wiptech/client/render/entity/EntityPortableGeneratorRenderer.java

Edited by Cadiboo

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted

All im really looking for is a guide to how the buffer builder works. I’ve been looking at some sample code from other mods as well as checking some LWJGL tutorials, but I’m still unsure on how to use it.

Posted

BufferBuilder is just a way to specify a vertex collection for OpenGL to render. A vertex is ultimately just a collection of data OpenGL uses to draw things. At the very minimum it needs the position in world-space to render anything at all.

You start by specifying a format and a draw mode. The draw mode specifies what the vertices mean(ex. 4 means a quad with GL_QUADS) and the format specifies the way the data is aligned in each vertex(ex. POSITION_TEXTURE_COLOR means that each vertex contains 3 floats that specify position, followed by 2 floats that specify the uvs for the texture followed by 4 floats that specify the color). The only thing that might confuse you are BLOCK(3 position, 4 color, 2 texture, 2 lightmap) and ITEM(3 position, 4 color, 2 texture, 3 normal, 1 padding) formats.

Then you specify the vertices based on the format you've selected. You do that by calling the respective methods. For example to specify the position you would call BufferBuilder#pos. Keep in mind that the order must be the same as the order defined by the format(ex. if the format is POSITION_TEXTURE_COLOR the vertex definition would be pos(...).tex(...).color(...)). Then you end the definition of each vertex with BufferBuilder#endVertex similar to how you end sentences with a dot. These methods can conviniently be chained to compact the code. So you can do bufferbuilder.pos(...).tex(...).color(...).normal(....).endVertex();

Once you've specified all the vertices needed for your drawing you finally call Tessellator#draw.

Knowing that you can easily adapt the BufferBuilder to render a wavefront object. Parse your object in a way that gives you a collection of vertices each containing the data you need(position, uvs, normals) and then simply iterate over the collection adding each vertex to the buffer. As an example here is the way I parse the wavefront into a collection of vertices and upload those vertices to the buffer. As a bonus here is the way I use a FastTESR to render the parsed wavefront into the buffer provided by the FastTESR(with matrix transformations). 

I hope my explanation and the examples provided help you.

Posted
23 minutes ago, GooberGunter said:

All im really looking for is a guide to how the buffer builder works. I’ve been looking at some sample code from other mods as well as checking some LWJGL tutorials, but I’m still unsure on how to use it.

You put vertexes into it and that creates a face, which is assigned a texture via the points you specify as floats as a 0-1 scale by the bound texture. Which is bound from

Minecraft.getMinecraft().getRenderManager().renderEngine.bindTexture(resource);

Or an instance of RenderManager/TextureManager that you are provided.

You call BufferBuilder.begin(VertextFormat)

then bufferbuilder.pos().tex().normal().endVertex() for all of the vertexes you need.

Then finally call tesselator.draw.

 

If you need an instance of these, use Tesselator.getInstance() and then to get the BufferBuilder instance use Tesselator#getBuffer().

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hello , when I try to launch the forge installer it just crash with a message for 0,5 secondes. I'm using java 17 to launch it. Here's the link of the error :https://cdn.corenexis.com/view/?img=d/ma24/qs7u4U.jpg  
    • You will find the crash-report or log in your minecraft directory (crash-report or logs folder)
    • Use a modpack which is using these 2 mods as working base:   https://www.curseforge.com/minecraft/modpacks/life-in-the-village-3
    • inicie un mundo donde instale Croptopia y Farmer's Delight, entonces instale el addon Croptopia Delight pero no funciona. es la version 1.18.2
    • Hello all. I'm currently grappling with the updateShape method in a custom class extending Block.  My code currently looks like this: The conditionals in CheckState are there to switch blockstate properties, which is working fine, as it functions correctly every time in getStateForPlacement.  The problem I'm running into is that when I update a state, the blocks seem to call CheckState with the position of the block which was changed updated last.  If I build a wall I can see the same change propagate across. My question thus is this: is updateShape sending its return to the neighbouring block?  Is each block not independently executing the updateShape method, thus inserting its own current position?  The first statement appears to be true, and the second false (each block is not independently executing the method). I have tried to fix this by saving the block's own position to a variable myPos at inception, and then feeding this in as CheckState(myPos) but this causes a worse outcome, where all blocks take the update of the first modified block, rather than just their neighbour.  This raises more questions than it answers, obviously: how is a different instance's variable propagating here?  I also tried changing it so that CheckState did not take a BlockPos, but had myPos built into the body - same problem. I have previously looked at neighbourUpdate and onNeighbourUpdate, but could not find a way to get this to work at all.  One post on here about updatePostPlacement and other methods has proven itself long superceded.  All other sources on the net seem to be out of date. Many thanks in advance for any help you might offer me, it's been several days now of trying to get this work and several weeks of generally trying to get round this roadblock.  - Sandermall
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.