Jump to content

rotating model?


memcallen

Recommended Posts

I have a techne model but I was wondering how I could rotate it

 

 

DLRt32h.png

 

thats the picture of the model so far, I want to add a miniature jet engine onto the top of the pole-like thing but I want to be able to set the direction of it. I haven't found any tutorials or posts about this topic so far.

The proud(ish) developer of Ancients

Link to comment
Share on other sites

If it is a model, you have a rendering class for it, registered in your ClientProxy, If you don't have this, I don't quite know how or what you are doing, and you should look into setting it up like that.

 

So, in your renderTileEntityAt method, put the GL11.glRotatef method after your first GL11.glPushMatrix. The first parameter is the angle you want to rotate it, and the second, third, and fourth are the x, y, and z axis.

 

So for example, to rotate it -90 degrees on the y axis, you would have:

GL11.glRotatef(-90, 0.0F, 1.0F, 0.0F);

 

The numbers for the x, y, z axis are a bit like a percentage of how much it will affect that axis. So 1, is like 100% and will rotate it for the full -90 degrees on that axis, and 0 will not affect the axis at all. You can do something like 0.5F to only rotate it 50% so the result will be -45 degrees.

 

In your case, you want to use metadata to determine this rotation. So in your block, set the blocks metadata depending on the players rotationYaw (see the vanilla furnace to understand how this is done, if you don't already understand it. You would want to look at the methods onBlockPlacedBy, and onBlockAdded), and in the renderTileEntityAt method, you can use the TileEntity parameter to retrieve the metadata.

I ask complicated questions, and apparently like to write really long detailed posts. But I also help others when I can.

Link to comment
Share on other sites

I'm rendering it properly with the TESR but I want to make it so that you can have it rotate any direction on the x y and z kind of like a player head, I'm gonna make it power a turbine and the rotation determines the power output. It's a bit over complex but I think it would be a cool idea for a power system.

The proud(ish) developer of Ancients

Link to comment
Share on other sites

Okay, do you understand GL11.glRotatef now? if so, all you really need to achieve that then is some variable in the tileentity that stores the rotation, and on what axis, then in renderTileEntityAt, just do a check to make sure this is the right tileentity, then cast the tileentity variable to your tileentity, and then you can access those variables from your renderer.

I ask complicated questions, and apparently like to write really long detailed posts. But I also help others when I can.

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.

Announcements



×
×
  • Create New...

Important Information

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