Jump to content

[1.7.10] Pitching/Rolling the player model


PrototypeTheta

Recommended Posts

Quite simply I'm trying to find a way to rotate the player model on the pitch or roll axis (can currently only do yaw). I thought this could be a simple as slapping some gl transformations on the render player event, however I don't fully know how to do that nor do I think it's going to be this simple.

Link to comment
Share on other sites

If you want roll then i highly recommend using quaternions rather than vectors.  Otherwise you will quickly run into problems, the main one being gimbal lock.  That is where vectors effectively break down and don't display the rotation correctly.

 

The problem is quaternions can very difficult to work with as a developer and debugging rotations can be soul destroying.

 

Other tips that I would add:

 

- Minecraft treats zero rotation as the player looking down the z axis, whereas quaternions and math in general treat as the x axis. (Please correct me if that's wrong).  So you'll need to do 90 degree rotation to the left when calling most quaternion library code.

 

- You can change the player's roll by setting the private 'camRoll' field in EntityRenderer class, using reflection.

 

- You should ensure the z axis rotation is capped between -90 and 90 degrees (pitch).  The x and y axis rotations should be between -180 and 180.  The player will still be able to do loops in any direction, but the minecraft code kind of requires these values (speaking roughly).

 

- When converting from Euler angles to quaternion (e.g. when reading current player rotation) you should ensure you use YZX order.  This ensures that roll is done last.  Same for converting from quaternion to Euler.  That will sound confusing if you haven't dealt with it before but it's a problem that caused me over a week of debugging so maybe bookmark this if you choose to go down this path.  Other orders may be ok but the standard XYZ order does roll before it does pitch which is wrong.

 

- If you simply add a 360 degree rotation to the player, the player will spin around quickly in-game.  You would think they would just stay still but the minecraft code interpolates between the two values automatically.  This can be a problem if your rotation formulas decide to add 360 degrees etc..  This is related to the point about keeping the y axis between -90 and 90 degrees.

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.