Jump to content

Any tutorials for custom block rendering?


Flenix

Recommended Posts

Hey guys,

 

I'm trying to make my first mod right now. Most of the things in the mod are custom shapes though, not standard blocks.

 

I understand the basics of modding and I've done the tutorial here, but I can't find any help at all on getting a custom rendered block!

 

The few guides I did find were all written for Modloader, not Forge. I also found a guide to port from modloader to forge, but that seems like a very long-winded way of doing it.

 

Also, if possible I want to use data values, not tile entites. The block is designed for decoration, and there will be thousands of them on my server, so I don't want the extra memory usage of a tile entity.

 

So, does anyone know of a tutorial?

width=463 height=200

http://s13.postimg.org/z9mlly2av/siglogo.png[/img]

My mods (Links coming soon)

Cities | Roads | Remula | SilvaniaMod | MoreStats

Link to comment
Share on other sites

try searching for ISimpleBlockRenderingHandler. it's a long time I used it, but I think you get a render id, implement that handler, register your handler and your block should return the registered render id. without TEs you'll have to implementent your block renderer via tesselator. not sure how much this post will help, but at least it's a start :).

mnn.getNativeLang() != English

If I helped you please click on the "thank you" button.

Link to comment
Share on other sites

Tesselators aren't that bad either.  4 corners of 3D space and some texture UV coordinates and you're golden.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Tesselators aren't that bad either.  4 corners of 3D space and some texture UV coordinates and you're golden.

Got any links? Never heard of Tesselators, and google didn't help much either.

 

Also, does anyone know a better modelling program than Techne? It's fine for what I need in this mod, but I want a lot more detail in some ideas I have for other mods...

width=463 height=200

http://s13.postimg.org/z9mlly2av/siglogo.png[/img]

My mods (Links coming soon)

Cities | Roads | Remula | SilvaniaMod | MoreStats

Link to comment
Share on other sites

Recently has beeen added support for obj files into Forge, so you can use any 3d editor that can export to a wavefront obj format (maybe Blender?). For a tessellator usage you can take a look at

net.minecraft.client.renderer.RenderBlocks

class.

mnn.getNativeLang() != English

If I helped you please click on the "thank you" button.

Link to comment
Share on other sites

Recently has beeen added support for obj files into Forge, so you can use any 3d editor that can export to a wavefront obj format (maybe Blender?). For a tessellator usage you can take a look at

net.minecraft.client.renderer.RenderBlocks

class.

This sounds rather interesting, do you know how it is done, and what dimensions and complexity the model needs to be? Also can they be used for entities? If so, how would texture mapping work?
Link to comment
Share on other sites

Recently has beeen added support for obj files into Forge, so you can use any 3d editor that can export to a wavefront obj format (maybe Blender?). For a tessellator usage you can take a look at

net.minecraft.client.renderer.RenderBlocks

class.

 

Source please? If this is true, then anyone can feel free to contact me for any modelling requests and I'll get right on it. I can do that bit, it's Java I'm not so good at!

width=463 height=200

http://s13.postimg.org/z9mlly2av/siglogo.png[/img]

My mods (Links coming soon)

Cities | Roads | Remula | SilvaniaMod | MoreStats

Link to comment
Share on other sites

Tesselators aren't that bad either.  4 corners of 3D space and some texture UV coordinates and you're golden.

Got any links? Never heard of Tesselators, and google didn't help much either.

 

I'm not sure what it is, exactly, but I know what it does.

 

It draws quads (4-sided polygons in 3D space).

 

Example:

 

tessellator.addVertexWithUV(minX, theY, maxZ, minU, maxV);
tessellator.addVertexWithUV(minX, theY, minZ, minU, minV);
tessellator.addVertexWithUV(maxX, theY, minZ, maxU, minV);
tessellator.addVertexWithUV(maxX, theY, maxZ, maxU, maxV);

 

Draws a single plane on the X/Z plane (i.e. the top of a block).  Flipping the points around (reverse order) will render it upside down (i.e. bottom of a block).  Not sure what the orientation is of those four lines offhand, though.  I think it's the underside, based off a comment in the code referencing the "bottom of the bed" where I got it from.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Here are some snippets from how I render one of my blocks. I'll eventually change it to use UVs, but right now it renders a gray block as a placeholder (that's why I'm wastefully creating six new color objects each render pass :P):

 

//Draw monolith
renderPlane(x, y, z, 1, 1, Orientation.North, new Color(128, 128, 128));
renderPlane(x+1, y, z, 1, 1, Orientation.West, new Color(128, 128, 128));
renderPlane(x, y, z, 1, 1, Orientation.East, new Color(128, 128, 128));
renderPlane(x, y, z+1, 1, 1, Orientation.South, new Color(128, 128, 128));
renderPlane(x, y+1, z, 1, 1, Orientation.Up, new Color(128, 128, 128));
renderPlane(x, y, z, 1, 1, Orientation.Down, new Color(128, 128, 128));

 

renderPlane:

private void renderPlane(double x, double y, double z, double width, double height, Orientation orientation, Color color)
{
    tessellator.startDrawingQuads();
    tessellator.setColorRGBA(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha());
    switch(orientation)
    {
    	case Up:
    	    tessellator.setNormal(0, -1.0f, 0);
    	    tessellator.addVertex(x, y, z);
            tessellator.addVertex(x, y, z+height);
            tessellator.addVertex(x+width, y, z+height);
            tessellator.addVertex(x+width, y, z);
            break;
    	case Down:
            tessellator.setNormal(0, 1.0f, 0);
            tessellator.addVertex(x+width, y, z);
            tessellator.addVertex(x+width, y, z+height);
            tessellator.addVertex(x, y, z+height);
            tessellator.addVertex(x, y, z);
    	    break;
    	case North:
    	    tessellator.setNormal(0, 0, -1.0f);
    	    tessellator.addVertex(x, y, z);
            tessellator.addVertex(x, y+height, z);
            tessellator.addVertex(x+width, y+height, z);
            tessellator.addVertex(x+width, y, z);
            break;
    	case South:
            tessellator.setNormal(0, 0, 1.0f);
            tessellator.addVertex(x+width, y, z);
            tessellator.addVertex(x+width, y+height, z);
            tessellator.addVertex(x, y+height, z);
            tessellator.addVertex(x, y, z);
    	    break;
    	case East:
            tessellator.setNormal(1.0f, 0, 0);
            tessellator.addVertex(x, y, z+width);
            tessellator.addVertex(x, y+height, z+width);
            tessellator.addVertex(x, y+height, z);
            tessellator.addVertex(x, y, z);
    	    break;
    	case West:
    	    tessellator.setNormal(-1.0f, 0, 0);
    	    tessellator.addVertex(x, y, z);
            tessellator.addVertex(x, y+height, z);
            tessellator.addVertex(x, y+height, z+width);
            tessellator.addVertex(x, y, z+width);
            break;
    }
    tessellator.draw();
}

 

I'm sure there are better ways to do it, as renderPlane and another method I wrote, renderDoublePlane, weren't actually written to render small cubes, but it shows you the normals and vertex ordering to get them to render in the right direction.

 

Also, as you noticed, most of the planes are rendered from the Block's origin and are oriented from there, which may or may not confuse you. This is because renderPlane renders things in a positive direction. You can provide a negative width/height to flip the plane, but I have a feeling that'll also flip the orientation/normal.

width=336 height=83http://img836.imageshack.us/img836/1237/cooltext624963071.png[/img]

I make games, minecraft mods/plugins, and some graphic art.

 

Current Project: LoECraft - An industrial minecraft server with its own modpack and custom launcher.

Link to comment
Share on other sites

Recently has beeen added support for obj files into Forge, so you can use any 3d editor that can export to a wavefront obj format (maybe Blender?). For a tessellator usage you can take a look at

net.minecraft.client.renderer.RenderBlocks

class.

This sounds rather interesting, do you know how it is done, and what dimensions and complexity the model needs to be? Also can they be used for entities? If so, how would texture mapping work?

I haven't tried it yet, but it's used in EE3 (it's open source, code is available on github) or you can read this tutorial - looks nice. It can definitely be used for entities (not sure about blocks though, maybe just TE).

mnn.getNativeLang() != English

If I helped you please click on the "thank you" button.

Link to comment
Share on other sites

Recently has beeen added support for obj files into Forge, so you can use any 3d editor that can export to a wavefront obj format (maybe Blender?). For a tessellator usage you can take a look at

net.minecraft.client.renderer.RenderBlocks

class.

This sounds rather interesting, do you know how it is done, and what dimensions and complexity the model needs to be? Also can they be used for entities? If so, how would texture mapping work?

I haven't tried it yet, but it's used in EE3 (it's open source, code is available on github) or you can read this tutorial - looks nice. It can definitely be used for entities (not sure about blocks though, maybe just TE).

mnn.getNativeLang() != English

If I helped you please click on the "thank you" button.

Link to comment
Share on other sites

All very useful information, thanks very much!

 

Those tessilators will be great. I did a load of modelling for a Spout-based mod a while back called MoreMaterials which used quads, that'll make it easy to port things from there should I want to. I'll try that obj thing now though!

width=463 height=200

http://s13.postimg.org/z9mlly2av/siglogo.png[/img]

My mods (Links coming soon)

Cities | Roads | Remula | SilvaniaMod | MoreStats

Link to comment
Share on other sites

All very useful information, thanks very much!

 

Those tessilators will be great. I did a load of modelling for a Spout-based mod a while back called MoreMaterials which used quads, that'll make it easy to port things from there should I want to. I'll try that obj thing now though!

width=463 height=200

http://s13.postimg.org/z9mlly2av/siglogo.png[/img]

My mods (Links coming soon)

Cities | Roads | Remula | SilvaniaMod | MoreStats

Link to comment
Share on other sites

Recently has beeen added support for obj files into Forge, so you can use any 3d editor that can export to a wavefront obj format (maybe Blender?). For a tessellator usage you can take a look at

net.minecraft.client.renderer.RenderBlocks

class.

This sounds rather interesting, do you know how it is done, and what dimensions and complexity the model needs to be? Also can they be used for entities? If so, how would texture mapping work?

I haven't tried it yet, but it's used in EE3 (it's open source, code is available on github) or you can read this tutorial - looks nice. It can definitely be used for entities (not sure about blocks though, maybe just TE).

 

In 1.5, both net.minecraftforge.client.model.AdvancedModelLoader and net.minecraftforge.client.model.IModelCustom no longer exist. Is it still possible to import .obj files into minecraft?

Link to comment
Share on other sites

Recently has beeen added support for obj files into Forge, so you can use any 3d editor that can export to a wavefront obj format (maybe Blender?). For a tessellator usage you can take a look at

net.minecraft.client.renderer.RenderBlocks

class.

This sounds rather interesting, do you know how it is done, and what dimensions and complexity the model needs to be? Also can they be used for entities? If so, how would texture mapping work?

I haven't tried it yet, but it's used in EE3 (it's open source, code is available on github) or you can read this tutorial - looks nice. It can definitely be used for entities (not sure about blocks though, maybe just TE).

 

In 1.5, both net.minecraftforge.client.model.AdvancedModelLoader and net.minecraftforge.client.model.IModelCustom no longer exist. Is it still possible to import .obj files into minecraft?

Link to comment
Share on other sites

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.



×
×
  • Create New...

Important Information

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