Bizarre Orientation

Started by AGP, October 02, 2011, 07:16:30 AM

Previous topic - Next topic

AGP

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.

EgonOlsen

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.

AGP

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()).

EgonOlsen

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.

AGP

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.

EgonOlsen

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?

AGP

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.

EgonOlsen

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:


<obj>.rotateX((float)Math.PI);
<obj>.rotateMesh();
<obj>.clearRotation();


right after loading.

AGP

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.

EgonOlsen

Maybe i'm stupid, but what i still don't get: Are ALL models oriented that way or only SOME while others are correct?

AGP

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).

EgonOlsen

Just make sure that you do the rotateMesh() before calling build(). I see no reason why this should change their relative positions...

AGP

#12
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.