RafaMv Posted November 19, 2014 Posted November 19, 2014 Hey guys, I would like to render a mob that will have different modelbases. Just imagine a robot that can change its arms. However, I don't know how to render the models separately (and properly). Does anyone have a good idea how to do that? I tried this: public void renderModel(Entitybot bot, double x, double y, double z, float u, float v) { ModelBase modelPart; ResourceLocation texturePart; GL11.glPushMatrix(); GL11.glTranslatef((float) x, (float) y, (float) z); GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); for (int i = 1; i < 5; i++) { modelPart = (ModelBase) bot.getModelPart(i); if (modelPart != null) { texturePart = bot.getTexturePart(i); bindTexture(texturePart); modelPart.render(bot, 1.0F, 1.0F, 1.0F, 1.0F, 1.0F, 0.1F); } } GL11.glPopMatrix(); super.doRender(bot, x, y, z, u, v); } Quote
Draco18s Posted November 19, 2014 Posted November 19, 2014 See that bit that says "modelPart.render"? Yeah. That's the bit responsible for rendering a given part. Quote 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.
coolAlias Posted November 19, 2014 Posted November 19, 2014 Depending on how drastic the differences are, you could put the different parts in a single model class and render the appropriate part according to the entity's state (which you would need to sync to client with DataWatcher or other means). What I mean is basically this: public class YourModel extends ModelBase { private ModelRenderer arm1; private ModelRenderer arm2; private ModelRenderer everythingElse; @Override public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { super.render(entity, f, f1, f2, f3, f4, f5); setRotationAngles(f, f1, f2, f3, f4, f5, entity); everythingElse.render(f5); if (((YourEntity) entity).useArm1()) { arm1.render(f5); } else { arm2.render(f5); } } Obviously you could make the code look nicer by using an array for all the possible arms and returning the index of the arm to use from your entity's function, but this is the basic gist of it. Quote http://i.imgur.com/NdrFdld.png[/img]
Recommended Posts
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.