3ds max Matrix in Maya


#1

Hi there
I’ve used to work on Maxscript. now shift to Mel and i need to find equivalent command in Mel for Maxscript. one is the Matrix.
In 3ds max we had 3 greate DvDs for beginning and this site to find and share the problems
How about Maya if i want to create such an effectfor my rig (which i made in max)

 http://www.mediafire.com/download/znvbz8lppaspx5q/Matrix_Mirror+hand+pos.mp4

I mean for example a Right hand is in XX position and XX rotation and by pressing a button i like the left hand has the same pose but in a mirrored pose
What should i search and any recommended page is so appreciated

Thanks in Advance


#2

MEL does not have a matrix data structure, Python is better in that regard. You could use the Maya Python API to query matrices/transformations, manipulate them and then set those results to attributes. Maybe check Pymel if that has something that you might find useful in that regard.


#3

That’s not entirely true. MEL supports a matrix data structure. You can do this in the following form:

matrix $test[4][4] = <<1.0, 0.0, 0.0, 0.0;
					   0.0, 1.0, 0.0, 0.0;
					   0.0, 0.0, 1.0, 0.0;
					   0.0, 0.0, 0.0, 1.0>>;
print $test[0][0];

That said, not many commands nor procedures accept the matrix data type in MEL and it is definitely easier to do this in Python using the API, but I did want to point out that MEL does support it.


#4

Thanks, Keilun, that is true and in a faint memory I recall that it is actually possible to do stuff like this. But honestly as much as I still like MEL, I wouldn`t bother and resort to Python for this.


#5

Thanks for your comment guys

i’m fairly new in maya and mel so i try to show what i like to get in maya by Matrix maybe i shouldn’t use Matrix word and you may get this result in another way. in max we can mirror the transform ( position rotaion and scale ) of an object (which turns to a matrix)

this way


  --create our objects
  BoxA = Box  length:10 width:10 height:30 pos:[-40,0,0]
  BoxB = Box  length:10 width:10 height:30 pos:[40,0,0]
  parentObj = Circle radius:10 pos:[0,0,0] 
  --move the BoxA to test
  move BoxA [0,0,20]
  --rotate BoxA in X axis to test
  rotate BoxA (angleaxis -35 [1,0,0])
  rotate BoxA (angleaxis -45 [0,2,0])
  BoxA.transform -- it turns to a Matrix like this "  (matrix3 [0.707107,0,0.707107] [0.40558,0.819152,-0.40558] [-0.579228,0.573576,0.579228] [-40,0,0]) "
  --now i try to mirror BoxA position and rotation to BoxB beased on parentObj pos and rot 
  FinalTm = (scaleMatrix [-1,1,1])*(BoxA.transform*inverse parentObj.transform)*(scaleMatrix [-1,1,1])*parentObj.transform
  BoxB.transform = finalTm
  
  --or if i need pos and Rot separately i do this   
  BoxB.pos = finalTm.pos
  in coordSys (transMatrix BoxB.transform.pos) BoxB.rotation = inverse finalTm.rotation

We can blend transform of two objects as well definately it is possible in Maya i would be greateful if sb show me how to do that or any pages to go further


#6

you should ask that also in the maya TD forum…
www.soup-dev.com


#7

Can anyone help me with this.

Or if it should be done in another way can anyone help me with that.

BTW where is this section I couldn’t find it


#8

I would use the Maya Python API for this, because you can do you matrix math

Here is some code to get you started:

import maya.OpenMaya as om
node = 'locator1'
myDagPath = om.MDagPath()
list = om.MSelectionList()
list.add ( node )
list.getDagPath(0, myDagPath)

print myDagPath.partialPathName()
print myDagPath.fullPathName()

m = myDagPath.inclusiveMatrix()

print m(0,0), m(0,1), m(0,2), m(0,3)
print m(1,0), m(1,1), m(1,2), m(1,3)
print m(2,0), m(2,1), m(2,2), m(2,3)
print m(3,0), m(3,1), m(3,2), m(3,3)