PDA

View Full Version : From Z-up to Y-up



dslamb
07-19-2010, 07:09 PM
I'm parsing a collada file for display using OpenGL. The model was created in Sketchup and has both materials and textures. The collada file uses triangles and lines. Triangles usually have vertex positions and normals, and then texture coordinates. I deindex these so that I can use them in OpenGL. The file uses a z-up coordinate system, and up to this point I've just used RotateF(-90, 1, 0, 0) to orient the model. Unfortunately, my materials are not showing up. I'm using MaterialF for ambient, diffuse, and emmission. The texture is showing up though. I'm thinking it has something to do with my normals, and thought about converting the positions and normals from z-up to y-up. Can anyone provide me with the basic steps to do this? Or can think of other things to check as to why a material might not be showing up.

Thanks for any help.

Cheers,
David

NeXEkho
07-20-2010, 08:38 AM
Don't bother rotating it, just swap the Z and Y. Duh.

dslamb
07-20-2010, 04:51 PM
Cool, thanks NeXEkho.

Also, I found that the collada refinery has a axis swap tool. All it does is swap the Z and Y and multiplies the z by -1 to change the sign. At least that's what it looks like it does.

Cheers,
David

NeXEkho
07-20-2010, 05:05 PM
:]

Mikkel Gjoel
07-22-2010, 02:35 AM
If you don't multiply an axis by -1, you'll end up with mirrored models with all the joys that come with that - inside-out, inverted triangle-winding and normals.

Rotating should be fine, and should not affect your normals. You may have run into an issue of inverted normals though (check by either drawing them, enabling double-sided lighting - or, if you're using shaders, add a abs() to your diffuse-dotproduct).