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

    • Also add the latest.log from /logs/
    • I was hoping I could get some help with this weird crash. I've hosted many servers before and never had this issue. Now and then the server crashed with "Exception ticking world". Everywhere I looked I rarely found any info on it (usually found ticking entity instead). Any advice I did get (mostly from the modpack owner's discord) was "We don't know and it's near impossible to find out what it is". Here is the crash report:   Description: Exception ticking world java.util.ConcurrentModificationException     at java.util.HashMap$HashIterator.nextNode(Unknown Source)     at java.util.HashMap$KeyIterator.next(Unknown Source)     at net.minecraft.entity.EntityTracker.sendLeashedEntitiesInChunk(EntityTracker.java:386)     at net.minecraft.server.management.PlayerChunkMapEntry.sendToPlayers(PlayerChunkMapEntry.java:162)     at net.minecraft.server.management.PlayerChunkMap.tick(SourceFile:165)     at net.minecraft.world.WorldServer.tick(WorldServer.java:227)     at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:756)     at net.minecraft.server.dedicated.DedicatedServer.updateTimeLightAndEntities(DedicatedServer.java:397)     at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:668)     at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:526)     at java.lang.Thread.run(Unknown Source)   If you want the full version, I can link a pastebin if needed. Modpack link: https://www.curseforge.com/minecraft/modpacks/multiblock-madness Some helpful information is that: It seems to only happen when I leave my void world to enter the overworld. Only happens 5-10% of the time. Only happens when leaving the void world, and only the void world. I know it's a slim chance someone could help, but it'd be greatly appreciated.
    • thanks a lot bro i knew i shouldve gone on the actual website instead of the discord
    • Minecraft Version? Reinstall Java 17 and/or Java 21 If this is still not working, run jarfix https://johann.loefflmann.net/de/software/jarfix/index.html
    • Hallo liebes Forge team, mein forge installer nimmt nicht die Java datei an bzw. zeigt nicht das Symbol und öffnet immer nur kurz die console und schließt sich dann wieder.  Ich habe die neueste java datei und die neueste forge datei und es öffnet trotzdem nichts.  Könntet ihr mir dabei weiterhelfen?
  • Topics

×
×
  • Create New...

Important Information

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