ScriptSpot

Forum topic · General Scripting

Converting 3ds Left hand to OpenGL Right hand - where did i go wrong?

By falconmick · 2012-09-15

Description

I am using the following script as a part of a level exporter for an OPENGL game


format "\t\t<position> " to:currentFile									
format "% " body.pos.x  to:currentFile
format "% " body.pos.z  to:currentFile
format "% " -body.pos.y  to:currentFile								
format "</position>\n" to:currentFile

format "\t\t<rotation> " to:currentFile									
format "% " body.rotation.x_rotation to:currentFile
format "% " body.rotation.z_rotation to:currentFile
format "% " -body.rotation.y_rotation to:currentFile								
format "</rotation>\n" to:currentFile

format "\t\t<scale> " to:currentFile									
format "% " body.scale[1]  to:currentFile
format "% " body.scale[3]  to:currentFile
format "% " body.scale[2]  to:currentFile								
format "</scale>\n" to:currentFile

but when i rotate the 3ds max scene, the XML once loaded into my opengl game will be slightly out in a weird way if the following axis (right hand system) are both non 0: xy, xyz

I believe it's because the rotation system in 3dsmax isn't simply a x, y, z it's an euclidean, x, y, z, w

but I attempt to read the doco and its just confusing...

is there anyway I can export X/Y/Z rotation from 3dsmax for an OpenGL game or do I need to include X/Y/Z/W?

Comments (3)

falconmick · 2012-09-15

haha you always find stuff I sware to god I look for ages for.. But quad is better anyway because our system uses it, before i was converting the Vector3 into one, it was stupid, but I didn't know we were as that was another members work

falconmick · 2012-09-15

I'm almost certain now that it's somthing to do with missing w, can sombody please just confirm?

Edit:
confirmed, to get full rotation from 3ds max you must use Quaternion's


format "\t\t<rotation> " to:currentFile									
format "% " body.rotation.w to:currentFile -- real
format "% " body.rotation.x to:currentFile -- Complex A
format "% " body.rotation.z to:currentFile -- Complex B
format "% " -body.rotation.y to:currentFile -- Complex C
format "</rotation>\n" to:currentFile