change world coord system to swap Y & Z

Hi All,

I’m just looking for the best approach to change the world axis to correspond to for example Blender’s system. Blender uses a right handed system but with Y-axis pointing in the depth and Z-axis pointing up.

I’ve found the ofSetCoordHandedness method but that only swaps direction. It calls ofScale(1, 1, -1);. I could use ofRotate instead to swap the axis. I guess I then need to set that before I draw something.

But is this the best approach. Is there any better method which would result in the axis system exactly the same as Blender’s?

Any ideas very welcome.

I am struggling with the same problem and I stumbled across the following post: http://forum.openframeworks.cc/t/quad-warping-an-entire-opengl-view-solved/509/0 Which is old but does explain how to load a custom matrix namely using: glMultMatrixf();

So i tried loading the “default” matrix created by theo as such:

  
  
//lets make a matrix for openGL  
GLfloat myMatrix[16];  
  
//we set it to the default - 0 translation  
//and 1.0 scale for x y z and w  
for(int i = 0; i < 16; i++){  
	if(i % 5 != 0) myMatrix[i] = 0.0;  
	else myMatrix[i] = 1.0;  
}  
  
glMultMatrixf(myMatrix);  
  

And I tried to recreate a custom changed matrix as found here: http://stackoverflow.com/questions/1263072/changing-a-matrix-from-right-handed-to-left-handed-coordinate-system/1264880#1264880

By doing:

  
  
 /*  
     Default matrix:  
     1 0 0 0  
     0 1 0 0  
     0 0 1 0  
     0 0 0 1  
       
     flipped:  
     1 0 0 0  
     0 0 1 0  
     0 1 0 0  
     0 0 0 1  
     */  
  
//lets make a matrix for openGL  
    GLfloat myMatrix[16];  
      
    //we set it to the default - 0 translation  
    //and 1.0 scale for x y z and w  
    for(int i = 0; i < 16; i++){  
        myMatrix[i] = 0.0;  
    }  
    myMatrix[0] = 1.0;  
    myMatrix[6] = 1.0;  
    myMatrix[9] = 1.0;  
    myMatrix[15] = 1.0;  
  
glMultMatrixf(myMatrix);  
  

This I tried both in setup and draw but if I set an object position then it seems the X/Y/Z axis remain exactly the same.
Is OF doing some openGL matrix stuff each frame that I am not aware of ?
Or am I thinking to simply by thinking I can change the matrix like that ?

I think I managed to work with the Blender coord system as it seems it’s actually very simple:

  
    ofQuaternion rotX, rotY, rotZ;  
    //blenderY rot  
    rotY.makeRotate(15, 0, 1, 0);  
    //blenderY  
    rotZ.makeRotate( 19, 0, 0, 1);  
    //blenderZ  
    rotX.makeRotate( 35, 1, 0, 0);  
    cam.setOrientation(rotX * rotY * rotZ);  
    ofLogVerbose() << "rot: " << ofToString(cam.getOrientationEuler());  
    cam.setPosition(0,-5,10);  
  

This works 1 on 1 with blender. So no axis swapping at all :slight_smile: