Notifications
Clear all

[Closed] Achieve the same rotation in max as in openGL

I have 3 eulerangles x, y and z. Now would like to rotate my object by that angles the same way like in an openGL application. In openGL it worcks like this:

glRotatef(x, 1, 0, 0);
glRotatef(y, 0, 1, 0);
glRotatef(z, 0, 0, 1);
//draw the mesh

I tried in max this:

rotate m (eulerangles x y z)

m is my mesh. The result was diferent then in openGL. Itried also this:

m.rotation.controller[1].value=x
m.rotation.controller[2].value=y
m.rotation.controller[3].value=z

but the result was still wrong. Any idea how to archieve the same result as in openGL?

4 Replies

Have you verified that the axis are the same in 3ds Max and OpenGL?

1 Reply
(@gtafan)
Joined: 1 year ago

Posts: 0

Have expected such answer. And yes I know the axis system is diferent in max and openGL, but by placing my camera corectlly in openGL can simulate the same axis system as in max. Since y and z axis are the main diference diference between max and openGL, I tried:

m.rotation.controller[1].value=x
m.rotation.controller[2].value=z
m.rotation.controller[3].value=y

but the result was still wrong. I tried even all 6 posible combinations, but none of them had a satisfiable result.

in our exporter we work to the following

both are right handed

max

X axis goes right
Y Axis goes in
Z Axis goes up
U Tex axis is left
V Tex axis is up

opengl

X axis goes right
Y axis goes up
Z axis goes out
U Tex axis is left
V Tex axis is down

and we use the following to convert rotations

void ConManager::ConvertEuler(Point3& in, Point3& out, int order)		
{ 

	Matrix3 tm;
	EulerToMatrix(&in[0], tm, order);
	tm = XFormMat(xyz, tm);
	MatrixToEuler(tm, &out[0], order);
}

where xyz is space you want the result in eg (max or opengl) created using the following…

   Point3  axis[] = {-Point3::XAxis, /* left */ 
    			Point3::XAxis, /* right */ 
    			Point3::ZAxis, /* up */ 
    			-Point3::ZAxis, /* down */ 
    			Point3::YAxis, /* in */ 
    			-Point3::YAxis /* out */ 
    			};

@Klvnk Thanks for the explanaition, but like mentioned was already aware of the diference between axissystems in OpenGL and max. The 3D engine the models should be displaied in, could use both OpenGL and DX. In Windows it´s using DX, but I used OpenGL example because have no idea how it exactly done in DX.
Looks like my main problem was because of diferent coordsys and also the rotation order was a bit diferent, to be more precise it´s YXZ and not XYZ. So in openGL it would look like this:

glRotatef(y, 0, 1, 0);
glRotatef(x, 1, 0, 0);
glRotatef(z, 0, 0, 1);
//draw the mesh

After some searches on the web looks like I was finally able to find a solution:

in coordsys local (
$.rotation.y_rotation=y
$.rotation.x_rotation=x
$.rotation.z_rotation=z
)

the code could have some typing errors, since I am writing it from memory, but it has the same result like in the 3D engine. This solution have some problems:

  1. I am unable to get the 3 angle values back. I know you have explained the reason in some other thread.
  2. If I want to change rotation manually in max, it geting f***ed up, since other coordsys is used for rotation.