Author Topic: Bizarre Orientation  (Read 1516 times)

Offline AGP

  • quad
  • ******
  • Posts: 1520
    • View Profile
Bizarre Orientation
« on: October 02, 2011, 07:16:30 am »
I started a new car racer loosely based on that old one I wrote a few years ago, with the intention of fixing mistakes of the past (I had, for one thing, because of the 3ds format's incompatible orientation made that game in the X/Y plane, instead of the X/Z). This time I used OBJs. What's odd is that the world is upside down: rotating around the world's +Y axis turns the car right, but translation on +Y goes up (and the SkyBox is upside down). The models are properly oriented on Max, so I really don't know what gives.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11749
    • View Profile
    • http://www.jpct.net
Re: Bizarre Orientation
« Reply #1 on: October 02, 2011, 09:14:36 pm »
No idea what the orientation in the model is there. If it doesn't fit, rotate it after loading so that it does. Don't try to use the camera to compensate rotation issues of the model or the loader but leave the camera alone and rotate all models so that they match.

Offline AGP

  • quad
  • ******
  • Posts: 1520
    • View Profile
Re: Bizarre Orientation
« Reply #2 on: October 02, 2011, 10:03:34 pm »
The models all have the same orientation. I don't want to add a rotation to their matrices and I never get expected results from rotateMesh() and clearRotation() (or rotateMesh() and setRotationMatrix(new Matrix()).

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11749
    • View Profile
    • http://www.jpct.net
Re: Bizarre Orientation
« Reply #3 on: October 03, 2011, 09:29:58 am »
The loader loads everything in the same way. If the orientation differs after loading, then it already differs in the file. I have no idea what your exporter does. If you don't won't to rotate after loading, then i have no solution for this. Also, i don't get your problems with rotateMesh...i'm using it all the time.

Offline AGP

  • quad
  • ******
  • Posts: 1520
    • View Profile
Re: Bizarre Orientation
« Reply #4 on: October 03, 2011, 07:17:44 pm »
I'm using the built-in Max OBJ exporter. The setting "flip Y/Z Plane (Poser-like)" is on. But I don't usually get upside down objects (that I've ever noticed but the truth is that if the Skybox had not been upside down I would very likely not have noticed the problem).

As for rotateMesh(), the problem is that every time I rotate an object the way I want it, rotateMesh() screws up the rotation somehow (changes the axis of the rotation or so). Every time.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11749
    • View Profile
    • http://www.jpct.net
Re: Bizarre Orientation
« Reply #5 on: October 03, 2011, 08:03:58 pm »
rotateMesh() doesn't change rotation axes. It simply makes the rotation permanent by modifying the mesh so that the result is the same as if you would have applied a normal rotation of that kind. You just have to make sure that you clear the rotation matrix afterwards or otherwise, you'll get a combination of the rotated mesh and the matrix rotation.

I don't get the part with the sky box...what does the sky box (i assume it's the one generated by the jPCT class of that name) has to do with the model loading?

Offline AGP

  • quad
  • ******
  • Posts: 1520
    • View Profile
Re: Bizarre Orientation
« Reply #6 on: October 03, 2011, 11:13:48 pm »
Since the camera is rotated relative to the car's rotation, the camera is rightside up regardless of whether the car is. And the SkyBox is upside down relative to both. Like I said, +y is going up.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11749
    • View Profile
    • http://www.jpct.net
Re: Bizarre Orientation
« Reply #7 on: October 03, 2011, 11:30:57 pm »
So all of your models are upside-down or just some?...i've lost track somehow on what the actual problem is here. If that's the case, please try:

Code: [Select]
<obj>.rotateX((float)Math.PI);
<obj>.rotateMesh();
<obj>.clearRotation();

right after loading.

Offline AGP

  • quad
  • ******
  • Posts: 1520
    • View Profile
Re: Bizarre Orientation
« Reply #8 on: October 04, 2011, 03:02:32 am »
That was my code (read above :-). My main problem is that I simply don't get the cause. All models are properly oriented in Max.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11749
    • View Profile
    • http://www.jpct.net
Re: Bizarre Orientation
« Reply #9 on: October 04, 2011, 06:59:55 am »
Maybe i'm stupid, but what i still don't get: Are ALL models oriented that way or only SOME while others are correct?

Offline AGP

  • quad
  • ******
  • Posts: 1520
    • View Profile
Re: Bizarre Orientation
« Reply #10 on: October 04, 2011, 07:09:54 am »
They all have the same orientation (they're all upside down), because they were all placed in the same Max scene and exported from there.

And a note on the rotation: if I were to rotate everything, things would lose their positions relative to each other (there are, for instance, several parts of the city that aren't added to the city itself but directly to the world because I need to do transparency on them).

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11749
    • View Profile
    • http://www.jpct.net
Re: Bizarre Orientation
« Reply #11 on: October 04, 2011, 08:02:16 am »
Just make sure that you do the rotateMesh() before calling build(). I see no reason why this should change their relative positions...

Offline AGP

  • quad
  • ******
  • Posts: 1520
    • View Profile
Re: Bizarre Orientation
« Reply #12 on: October 06, 2011, 09:07:07 pm »
You're right that I was stupidly rotating after calling build(), but I'd still like to know what went wrong in the export/import process. Thanks for your suggestion. And if anyone knows anything wrong with Max's OBJ exporter please let me know.
« Last Edit: October 06, 2011, 09:11:05 pm by AGP »