Author Topic: Object space rotation  (Read 2287 times)

Offline Jonas

  • byte
  • *
  • Posts: 41
    • View Profile
Object space rotation
« on: November 14, 2007, 07:29:13 pm »
Hi

Having trouble with what i think is pretty basic ;D. I most probably just dont understand how rotation works.. :).

Im trying to draw some axis arrows..so I made my own arrow object3d and added it to a scene(see picture..the negativ y one is the original).
Now Id like to rotate that arrow to align it with the other axis. When i do the following:

Code: [Select]
o3ds[0] = createArrow();
       
       o3ds[1] = createArrow();
       o3ds[1].rotateZ((float)Math.toRadians(-90));
       
       o3ds[2] = createArrow();
       o3ds[2].rotateX((float)Math.toRadians(90));
       

it looks like this:


Now..is there a way to rotate these arrow so I dont have to translate them back in position(sphere is 0,0,0)? I tried setting the pivot and center of the arrow inside the sphere(which is the origin of the axis arrow too) but it doesent seem to work either.
Simple things should be simple, complex things should be possible - Alan Kay

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Object space rotation
« Reply #1 on: November 14, 2007, 11:29:50 pm »
Pivot should do the job, but be sure to set it after calling build() because build() resets the pivot. Maybe that causes the problem!?

Offline Jonas

  • byte
  • *
  • Posts: 41
    • View Profile
Re: Object space rotation
« Reply #2 on: November 15, 2007, 08:26:01 am »
Hi

Thanks, that helped pin down the error. I actually built the object and reset the pivot, but had another buildAllObjects() in the scene load code, which reset the pivot again ;D.

Works now.
Simple things should be simple, complex things should be possible - Alan Kay