PDA

View Full Version : [MEL] connect follicles to a nurbs plane


Leffler
04-28-2009, 06:30 PM
Hey guys!

Need help with connecting follicles to a nurbs plane, donīt really know what connections I need to make!

For polygons I found a script on HighEnd3d and he connects outMesh, inputMesh, worldMatrix, inputWorldMatrix, outTranslate etc ....

... but what about Nurbs? What do I connect to? Nurbs dont have "outMesh", right?

Thanks!
Otto

Leffler
05-04-2009, 07:25 PM
no ideas out there?

_stev_
05-04-2009, 10:10 PM
I don't have Maya Unlimited, so I can't verify this, but I think it should be something like this:


string $inputSurface[] = `nurbsPlane`;
string $follicleShape = `createNode follicle`;
string $follicle[] = `listRelatives -p $follicleShape`;

connectAttr ($follicleShape + ".outRotate") ($follicle[0] + ".rotate");
connectAttr ($follicleShape + ".outTranslate") ($follicle[0] + ".translate");
connectAttr ($inputSurface[0] + ".worldMatrix[0]") ($follicleShape + ".inputWorldMatrix");
connectAttr ($inputSurface[0] + ".worldSpace") ($follicleShape + ".inputSurface");

setAttr ($follicleShape + ".parameterU") 0.5;
setAttr ($follicleShape + ".parameterV") 0.5;


I hope that helps point you in the right direction at least.

Stev

Leffler
05-05-2009, 09:20 AM
Hey Stev, thanks! Got me in the correct direction for sure, but still some problems of course :D

What if I want one follicle to be positioned in the middle position of 4 CVs? Like if you create a cluster from that selection, that position.
I couldnīt figure out how to do that ... :/

I can get the result I want by create it with the hair system, see the attached image for the result I want. But the code I put together is ugly as hell and not very "bulletproof" with the pickwalking and the wildcard-selections ....

Well, here is what I put together



$Plane = `nurbsPlane -p 0 0 0 -ax 0 0 1 -w 1 -lr 5 -d 3 -u 1 -v 5 -ch 0`;
rebuildSurface -ch 0 -rpo 1 -rt 0 -end 1 -kr 2 -kcp 0 -kc 0 -su 1 -du 1 -sv 4 -dv 3 -tol 0.01 -fr 0 -dir 0 $Plane[0];
select -r $Plane[0];
createHair 1 5 10 0 0 0 0 1 0 2 2 1;

select -r ($Plane[0] + "*");
select -d $Plane[0];
string $sel[] = `ls -sl -s -fl`;

for($x=0;$x<size($sel);$x++)
{
select -r $sel[$x];
$folPar = `pickWalk -d up`;
parent -w $folPar;
select -r $sel[$x];
pickWalk -d down;
$child = `pickWalk -d right`;
delete $child[0];
$folPar[0] = `rename ($folPar[0]) ("follicle" + $x)`;
}
select -r ("*hair*");
delete;

_stev_
05-05-2009, 06:03 PM
You can use the "closestPointOnSurface" node to get the UV value from a world space position. Here is a procedure which shows you how to get it.


global proc float[] getUVfromPosition(string $surface, string $cluster) {
string $cposInfo = `createNode closestPointOnSurface`;
float $worldPos[] = `xform -q -ws -rp $cluster`;
float $uvValue[];

connectAttr ($surface+".worldSpace") ($cposInfo+".inputSurface");
setAttr ($cposInfo+".inPosition") $worldPos[0] $worldPos[1] $worldPos[2];

$uvValue[0] = `getAttr ($cposInfo+".parameterU")`;
$uvValue[1] = `getAttr ($cposInfo+".parameterV")`;

delete $cposInfo;

return $uvValue;
}

getUVfromPosition( "nurbsPlane1", "cluster1Handle" );



Stev

Leffler
05-06-2009, 07:46 AM
Cool, thanks a bunch Stev!

Otto

Kecal
04-03-2010, 02:14 PM
direct solution without createHair command:

string $nurbs[] = `nurbsPlane`;
string $nurbsShape[] = `listTransforms $nurbs[0]`;

string $follicleShape = `createNode follicle`;
string $follicle[] = `listRelatives -p $follicleShape`;

connectAttr ($nurbsShape[0] + ".worldMatrix[0]") ($follicleShape + ".inputWorldMatrix");
connectAttr ($nurbsShape[0] + ".local") ($follicleShape + ".inputSurface");
connectAttr ($follicleShape + ".outTranslate") ($follicle[0] + ".translate");
connectAttr ($follicleShape + ".outRotate") ($follicle[0] + ".rotate");

setAttr ($follicleShape + ".parameterU") 0.5;
setAttr ($follicleShape + ".parameterV") 0.5;


sorry for useless post. I miss that _stev_ already write exactly the same thing.

CGTalk Moderation
04-03-2010, 02:14 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.