hy guys,
i succesfully create a hand inside maya linked to a p5glove and acting in realtime.
this is my status
and this is my goal
the hand moves in realtme even in playmode, allowin mee to interact with dynamics in real time. not too bad. its funny.
so i get this hand. and i want to PICK UP object and RELEASE THEM while playing scene.
since i want dynamics i use a rigidbody parented to the hand that collides with the objects (other rigidbody) i want to pick up. when they collide, i have the contactname of the object and i can pick it up by parentcostraint. and thats ok, it works.
the very problem is that my scene plane (the ground) have to be himself a rigidbody, and HE COLLIDES with my hand. make me pick up the plane, thing that i dont want to.
is there a way to create multiple collision layers?
ex: HAND - collision layer 1
OBJECTS - collision layer 1 - 2
GROUND - collision layer 2
thus should make the hand interact with object but not with the ground.
is that possibile?
i read on maya help about a "interpretateWith" hidden attribute in rigidbody, i think it could help me but i cant realize how to use it.
another issue i have:
i CANT RELEASE THEM, but i can fix this, i just have to delete the parent and set the rigid to 1
im not a mel pro, i post my script hoping its useful, i'll be available for any kind of question.
please! is very important to me cause its my thesis degree and i want to propose a new way to design and interact in maya using virtual reality hand.
frensis@frensis.com
-----MEL EXPLAIN---
i control the hand by MIDI, so instead of 0-1 i get 0-127 for on and off.
since im italian i translate something for you.
-------------MEL HERE-----------
// variabili - variables
group1|ContactData.EXPR = 0;
// controlli -controls
setAttr ("piano"+".active") 0;
// variables
string $myRigidBody = "presa_rigid"; // this is the rb i use to collide and get contact data.
int $contactCount;
int $uniqueContactCount;
$contactCount = getAttr($myRigidBody+".contactCount")
;
string $array[] = rigidBody -q -contactName $myRigidBody
;
string $flatArray[] = flattenStringArray($array); // nome rigid $flatArray[0]
print $flatArray[0];
// PROGRAM
if (controlHand.pugno == 127 && $contactCount > 0 ) // if hand is closed and i get contacts ,pickup the contact
{
prendi(); // pickup
} else if( objExists $flatArray[0]
) //else if hand is open (not 127) and exist a contact , release it
{
lascia() ; // release
}
/// funzioni --functions
// PRENDI // pickup
proc prendi()
{
if( objExists preso
) // preso is the name of the parent. since i pickup 1 obj at time i have only a parentconstraint, if it exist before takin something. delete it
{
delete preso;
}
//////////PRENDO OGGETTO//////////////
$uniqueContactCount = size($flatArray); //quanti contatti unici (prendo solo il primo) - how many contacts - i take just the first
//string $parentof = firstParentOf($flatArray[0]); // who is the parent of the obj taken
$parentof = pickWalk -d up ($flatArray[0])
; // go up in hierarchy
$groupof = pickWalk -d up $parentof
; //samehere
parentConstraint -name preso presa $groupof; // Parent PRESA - OGGETTO - here i parent the obj to the hand
setAttr ($flatArray[0]+".active") 0; // disattivazione rigid - disable rigid so the parent rules the obj
CenterPivot $groupof; // centratura parent
warning ("PRESO = " + $groupof + "NOME RIGID:"+$flatArray[0] +"\n");
//
}
// LASCIA // -- release
proc lascia()
{
if (objExists preso
) //as before, if exist a constraint, delete it
{
setAttr ($flatArray[0]+".active") 1; // ENABLE riigidbody
delete preso; //delete parentcostraint
warning ("LIBERATO" +$flatArray[0] +"\n");
}
}
// set interface attributes
group1|ContactData.contactCount = $contactCount;
group1|ContactData.uniqueContactCount = $uniqueContactCount;
-------------------------------END MEL ----------------------