Author Topic: y rotation  (Read 2034 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
         translate(new SimpleVector(-3.2, 0, +5.55));
« 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: 12297
    • View Profile
Re: y rotation
« Reply #1 on: October 16, 2012, 07:46:59 am »
Two things:

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

Code: [Select]
rotateMesh(); 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.