Jump to content

  • Log In with Google      Sign In   
  • Create Account


Up axis problem with 3d Models [OpenGL]


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 metsfan   Members   -  Reputation: 652

Like
0Likes
Like

Posted 21 July 2012 - 08:27 PM

Hello all,

I am having a problem with a discrepancy between a set of 3D models which I have purchased and the OpenGL coordinate system. All of the models were exported with the Z axis pointing up, while OpenGL by default has the Y axis pointing up. The way I see it there are two options:

1) Modify the OpenGL coordinate system so that the Z axis points up
2) Modify the 3D models so that the Y axis points up

Neither task sounds like fun (option 1 forces me to modify the way OpenGL works by default, which I take no pleasure in doing, option 2 forces me to use a program like Maya, which I know absolutely nothing about). I'm just trying to get a sense of what is more commonplace in the game industry. Is it up to the programming team to make the coordinate system match the 3D models, or is it on the art team to make sure that the 3D models come in the proper coordinate system? Additionally, which of the 2 possibilities is the recommended path to take?

Thanks,
-Adam

Sponsor:

#2 NumberXaero   Prime Members   -  Reputation: 1271

Like
2Likes
Like

Posted 21 July 2012 - 09:04 PM

In my 3D studio max exporter I have a flag that makes Y up because Max's up is +Z. What the flag does is applies a +90 rotation about the +X axis (right handed) to the object (or models skeleton root) transform, this rotates Max's +Y (my Max forward convention) to align with opengl +Y up, and swings the Max -Z (down) up to become the opengl forward (-Z is forward in opengl for me). If the objects transform is translated away from the origin you may have to swap its z and y, and then negate the new z.

There are many places where you can solve it. Flag it on export if you can. Flag it on the model when loading. Manually rotate the object before exporting. I wouldnt mess with opengl, Id rather tweak the data. I do it this way because it doesnt have an impact on animations, its just an additional transform at the root so that objects are not on their side (or face down on floor). Overall its just a pain.

I think maya is Y up by default but can be changed, Max doesnt allow it to be changed, in case you do import into Maya, initially you might have the same problem as with opengl.

#3 metsfan   Members   -  Reputation: 652

Like
0Likes
Like

Posted 21 July 2012 - 09:11 PM

Thank you for the reply, this makes a lot of sense. I wish I knew more about 3D studio max, since I have absolutely no idea how to apply a transformation on export. Are there any resources you recommend that can help me set up this modification to the exporter?

#4 NumberXaero   Prime Members   -  Reputation: 1271

Like
0Likes
Like

Posted 21 July 2012 - 10:12 PM

The exporter is one that I wrote for Max, I added the Y up functionality because Max +Z is up, so of course any transforms or data that comes out of Max by default will be laying on its back, its face or side.
If you have models already made and dont want to or cant re-export, then the simplest way would be to rotate them in code by manipulating the objects world matrix that gets used for rendering. If you have some sort of scene graph like transform hierarchy, you can just apply the transforms i mentioned to the objects local transform then when you calculate the objects world transform for rendering it will draw correctly.
If you decide to re-export, apply the appropriate transforms at the end just before exporting. Which might mean (in the case of 3DS max) rotating the object to be face down (or up or whatever) just before exporting. I doubt anyone working on the models would want to build objects on their side, so do the flip at the end before exporting once the models done.
Which ever way you do it is gonna produce the same result, if you do and 90 degree correction in Max/Maya just before export using the rotate widget after selecting the object, the underlying operation is the same 90 degree rotation you'd be doing in code on the objects local transform.

#5 RobTheBloke   Crossbones+   -  Reputation: 2286

Like
1Likes
Like

Posted 27 July 2012 - 04:42 AM

All of the models were exported with the Z axis pointing up, while OpenGL by default has the Y axis pointing up.

OpenGL does not specify a default up axis. It depends soley on your camera transform.

Is it up to the programming team to make the coordinate system match the 3D models, or is it on the art team to make sure that the 3D models come in the proper coordinate system? Additionally, which of the 2 possibilities is the recommended path to take?


Both. The artists need to make sure they model things the correct way up, however the programmers should make sure that they can transform geometry. We are just talking about a 90 degree rotation around X here, so assuming you have a matrix transform for each mesh, it's not actually a problem. Mind you, writing a tool to rotate some vertices & normals in your files, is something that should only take you a couple of minutes.

I added the Y up functionality because Max +Z is up,

Because the changing the up axis in the 3ds max properties is too hard?

Neither task sounds like fun (option 1 forces me to modify the way OpenGL works by default, which I take no pleasure in doing,

Again, you can use any up axis you want. This is not a limitation of OpenGL.

option 2 forces me to use a program like Maya,

No it doesn't. It means you need to use some trivial matrix maths. Using Maya/Max et al, is just over-complicating a trivial problem.

I'm just trying to get a sense of what is more commonplace in the game industry.

Transformation matrices, and a consistant approach to working.

#6 Geometrian   Crossbones+   -  Reputation: 1415

Like
0Likes
Like

Posted 28 July 2012 - 02:10 PM

glRotated(90.0,1.0,0.0,0.0); or glRotated(-90.0,1.0,0.0,0.0);
And a Unix user said rm -rf *.* and all was null and void...|There's no place like 127.0.0.1|The Application "Programmer" has unexpectedly quit. An error of type A.M. has occurred.

#7 larspensjo   Members   -  Reputation: 1526

Like
0Likes
Like

Posted 29 July 2012 - 01:55 PM

option 2 forces me to use a program like Maya,

No it doesn't. It means you need to use some trivial matrix maths. Using Maya/Max et al, is just over-complicating a trivial problem.

Exactly, I agree.

OpenGL does not specify a default up axis. It depends soley on your camera transform.


Just some nit picking, but you can program OpenGL without any matrices or transforms at all, if you want. OpenGL no longer has a "camera transform" concept, and 'y' is up on the screen as default.

glRotated(90.0,1.0,0.0,0.0); or glRotated(-90.0,1.0,0.0,0.0)


This is deprecated OpenGL functionality, please don't recommend it. And if you would use it anyway, it is not recommended as it use double precision. That may cost a lot of performance.

Edited by larspensjo, 29 July 2012 - 02:03 PM.

Current project: Ephenation.
Sharing OpenGL experiences: http://ephenationopengl.blogspot.com/




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS