Posted February 14, 201411 yr Hey, I was having some fun with custom model rendering blocks and stuff and I wanted the center cube of the model to rotate. But however, the way I was doing it, the more blocks you have, the faster the spinning gets. I want to know how I would make that per-block or something. Doing the actual rendering: https://github.com/mrkirby153/StevesBoats/blob/master/src/main/java/me/mrkirby153/StevesBoats/blocks/renderers/TileEntityBlockCrafterRenderer.java Model Class: https://github.com/mrkirby153/StevesBoats/blob/master/src/main/java/me/mrkirby153/StevesBoats/models/ModelBlockCrafter.java Let me know if I forgot something http://i.imgur.com/gWwyMMO.jpg[/img]
February 14, 201411 yr Save the rotation value in the TileEntity. (not static) Have the renderer read the value from the TileEntity, edit it as needed, and save back. In my TileEntity: public float rotation; In my Renderer: tile.rotation += 0.25F; if (tile.rotation > 360) tile.rotation = 0F; GL11.glRotatef(tile.rotation, 1F, 0F, 0F);
February 14, 201411 yr Author Do I need to save it to nbt or should I just add public int rot = 0; Also in my current setup do I rotate the box in the model class or the tile entity class? http://i.imgur.com/gWwyMMO.jpg[/img]
February 14, 201411 yr I would say save it to NBT to be safe @Override public void writeToNBT(NBTTagCompound tag) { tag.setInteger("rot", rot); } @Override public void readFromNBT(NBTTagCompound tag) { rot = tag.getInteger("rot"); }
February 14, 201411 yr No need to save it, its just visual. Now I've long replaced my Techne models with OBJ's so lets see if I can get this from memory. In TileEntityBlockCrafter.java add: public float rotation; // you want this a float for better speed control In ModelBlockCrafter.java add: public void rotateCube(float rotation) { this.CenterCube.rotateAngleY = rotation; } Now in TileEntityBlockCrafterRenderer.java before this.model.render: ((TileEntityBlockCrafter)te).rotation += 0.25F; // Change this number to change speed if (((TileEntityBlockCrafter)te).rotation > 180) ((TileEntityBlockCrafter)te).rotation = -180F; // I believe Techne uses -180 to 180, instead of 0 to 360 this.model.rotateCube(((TileEntityBlockCrafter)te).rotation);
February 14, 201411 yr Author What program makes the obj files? Wait, yes I do I'll give that a shot when I have the chance http://i.imgur.com/gWwyMMO.jpg[/img]
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.