Problems with Angles. Math/Pro/Maya guru's needed

Blitz3D Forums/Blitz3D Programming/Problems with Angles. Math/Pro/Maya guru's needed

Vertigo(Posted 2007) [#1]
Hello,

Ive been running into problems with getting usable angle data from maya. I am exporting models from maya in .obj format, and importing them into blitz. See the screen shot below for reference. First off all axis work individually. For example rotating in only X, or only Y, or only Z within blitz matches the angles in maya perfectly. I do however, have to always negate the X value so X is always -X. As you can see in the picture the entire left side is individually manipulated axis rotations(the black background part is from blitz). These are all in orthographic front view for easy of accurate viewing.

If I rotate in both X and Y these values seem consistent. However combing either X and Z, Y and Z, or X Y and Z proves to be difficult. The angles get all out of whack and honestly make no sense. I cant even really get a relationship value between them.

Does anyone have any ideas on how I can get these values to match within a couple of degrees between both applications?



Thanks!


Stevie G(Posted 2007) [#2]
Looks to me that the order of the angles is different in Blitz.

Rotateentity can introduce singularities such as gimbal lock. You could try playing with turnentity ( uses quarternions internally ) by turning the axis' separately in different orders

e.g.

Turnentity Pitch, 0,0
Turnentity 0, Yaw, 0
Turnentity 0,0,Roll

or

Turnentity 0, Yaw, 0
Turnentity 0,0,Roll
Turnentity Pitch, 0,0

Etc....


Instead of ...

Rotateentity Pitch, Yaw, Roll


Vertigo(Posted 2007) [#3]
I will try and give that a shot, thats stevie. But Id really like to be able to fix this with math inside of a MEL script for maya before it even hits blitz. Any ideas?


big10p(Posted 2007) [#4]
Not really sure what's going on here TBH, but it looks like the Z axis direction is reversed, or something. You may be able to fix this using the LoaderMatrix command - not sure...


Vertigo(Posted 2007) [#5]
Is there something similar to LoaderMatrix for meshes that were created manually? Again im importing .obj files here and building them manually. Also it would be nice to fix this on the maya end. I can swap x,y,z order, and negate through script. Its just proving to be near impossible to find the relationship between the two axis.


big10p(Posted 2007) [#6]
If the LoaderMatrix command does fix the problem, you should then be able to use the loaded meshes 'manually' as normal.


Vertigo(Posted 2007) [#7]
The LoaderMatrix command is used against all objects loaded using the loadmesh() command correct? How would this be used to change the matrix coord system for an object made using createmesh()?

Basically I think it comes down to the simple fact that blitz uses a direct x Left handed coordinate system, while maya uses a more standard right handed coordinate system.

Does anyone have any ideas on how I can find the relationship between the two? And a formula to solve them equally?

Stevie's idea about using turn entity instead of rotate entity did seem to solve the loose ends.. ie instead of 0 = 0, 0 would = -3.229384534E03 values on axis that were not being manipulated. But regardless, it still has the same effect, All axis work individually if X is negated, but combining values in more than one axis at a time(besides X + Y for some reason) it will produce off results.

Still banging head on keyboard over here... Google doesnt seem to be that much of a helper either.

Thanks.


Floyd(Posted 2007) [#8]
Warning, my entire knowledge of Maya comes from staring at angles.jpg!

Maya coordinate axes seem to be:

X+ is to the right.
Y+ is up.
Z+ is out of the screen, toward the viewer.

Blitz3D reverses the Z axis, so Z+ is away from the viewer.

Maya rotations appear always to be around the GLOBAL coordinate system.

In Maya, if a turn around X is followed by a turn around Y then the second turn is around the vertical axis.

Blitz3D, by default, uses the local coordinate system. RotateEntity and TurnEntity have a global flag which defaults to False. After a turn around X the entity Y-axis is no longer vertical. The second turn is around the new ( moved ) Y-axis.

The Blitz3D rotation order is yaw then pitch then roll. If you need some other order then do a sequence of three simple turns.


Danny(Posted 2007) [#9]
I don't expect this to be helpfull, and not even 100% sure this is correct (reading from very old crappy code);
But I've been converting Blitz Camera Angles to Maya instead. By doing this:

Pitch = the same
Yaw = Yaw * -1
Roll = the same

And export them to Maya (via MEL) in the same order of Pitch-Yaw-Roll -BUT- MOST importantly I HAD to change the 'rotation order' IN MAYA for it to transform correctly (matching Blitz), using this on a transformation node:
setAttr ".ro" 2;

I can't remember (or check right now) what rotation order '2' was in Maya (I'm guessinng it sets YXZ in stead of the default XYZ)) - but it will be the 2nd in the list if you check the rotation-order pull down menu in the transformation node in maya.

Perhaps you can apply this 'in reverse' to solve your problem?! I'm no maya expert, figured this out by trial & error (lots of it)..

Sub note: In order to convert a Blitz Camera Zoom factor to a Maya, multiply that Blitz Zoom Factor by 22.6730499 and poke that in the Maya camera's FocalLenght..

Hope that helps,
D.


Hujiklo(Posted 2007) [#10]
Just parent your mesh to a standard blitz pivot and manipulate the pivot instead.


Vertigo(Posted 2007) [#11]
Hujiklo, I tried that a while ago with the same effect. Also I really need to have this fixed on the maya end using mel script. Just need to know the relationship between the two. I need to try what floyd and danny stated though.


Hujiklo(Posted 2007) [#12]
Okay - try 3 pivots (each parented to the previous - except for the first of course) and your mesh parented to the last pivot, and only turn each pivot on one axis at a time.

I'll be honest - I'm up to my eyeballs in little awkward work-arounds and have found pivots to be a prime source of bacon-saving.


Vertigo(Posted 2007) [#13]
Hujiklo you crazy son of a b***h... that worked!!!!!!!!!!!!!!!!!!


pivx = CreatePivot()
pivy = CreatePivot()
pivz = CreatePivot()

EntityParent pivy,pivx
EntityParent pivz,pivy
EntityParent box, pivz

TurnEntity pivy, -X#,0,0,True
TurnEntity pivx, 0,Y#,0,True
TurnEntity pivz, 0,0,Z#,True



How on earth.. I mean.. wow... thats nutz... very good to know if anyone is interested in getting external values from specific modelling applications!

Now all I need to do is make my mel script export from maya open a temp file, and send that temp file to a blitz exe converter to export out those rotational values in blitz... all the while changing nothing in either the blitz code or maya.

AWESOME!!!!!!!!!!!!!!!!!!!!!!!!!!!

haha, thanks guys!