Posted July 13, 20169 yr 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. https://s32.postimg.org/b0kt202id/image.jpg[/img]
July 13, 20169 yr It is that simple. Use Pre event to rotate and Post event to rotate BACK! Yes you will use 2 events. 1.7.10 is no longer supported by forge, you are on your own.
July 13, 20169 yr Author What? It's actually straightforward!? Impossible. Thanks anyway, I'll start looking into these events a bit more seriously now. https://s32.postimg.org/b0kt202id/image.jpg[/img]
July 14, 20169 yr 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.
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.