Author Topic: y rotation  (Read 679 times)

Offline 9kaywun

  • byte
  • *
  • Posts: 20
  • Java Programmer
    • View Profile
y rotation
« 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;
« Last Edit: October 15, 2012, 11:17:21 pm by 9kaywun »
Developing a 3D multiplayer engine using jPCT:
Deleted, will return soon..

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: y rotation
« Reply #1 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.