www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: 9kaywun on October 15, 2012, 11:08:54 pm

Title: y rotation
Post by: 9kaywun on October 15, 2012, 11:08:54 pm
Tryin to setup a 12 directional movement system in a game I've been developing..

When I walk around in the game, let's say I am going east.. my character rotates in a circle the entire time instead of JUST face east.. I've read the javadocs for Object3D and I'm still very lost as to how I can do this properly.. I need a way to either reset rotation before each directional face update, or something because it increments the new rotation request into the old one, and over rotates..

Here's a snippet:

      switch (direction) {
      case 2: // north west
         rotateY(-45f);
         rotateMesh();
         translate(new SimpleVector(-3.2, 0, +5.55));
         break;
Title: Re: y rotation
Post by: EgonOlsen on October 16, 2012, 07:46:59 am
Two things:

This...
Code: [Select]
rotateY(-45f);
...most likely isn't what you want. You have to give the angle in radians, not in degrees. In this case, -PI/4.

This...
Code: [Select]
rotateMesh();
...is not needed here and actually hurts. It's meant to make the rotation permanent to the mesh. You don't want that here. It's actual purpose is to setup your mesh after loading, in case the orientation isn't correct. It's not meant to be used or needed at runtime in almost every case.