PDA

View Full Version : Mel: Clusters on Curves


KingFarrukh
11-10-2010, 06:56 PM
///hey guys
///i'm sure there's a faster way of going about what i'm trying to do, can ///someone tell me how =)

///i have created a curve - now i'm building clusters on each cv on the ///curve

///code:
///splineCrv = my curve

select -r splineCrv.cv[5];
newCLuster "-envelope 1";

select -r splineCrv.cv[4];
newCLuster "-envelope 1"; etc...

///Is there a for loop i can write that would say
///for each cv's in my curve - create cluster -

skealeye
11-10-2010, 07:17 PM
u have to find the number of cv's on the curve first.
then just create a loop if u want a cluster per cv.
cv = degree + spans

ex.

string $curve = "myCurve";

int $degree = `getAttr ($curve + ".degree")`;
int $spans = `getAttr ($curve + ".spans")`;
int $cvs = ($degree + $spans);

for ($x = 0; $x < $cvs; $x++)
{
cluster ($curve + ".cv[" + $x + "]") ;
}



hope this helps!

KingFarrukh
11-10-2010, 07:50 PM
///Thanks a bunch! That worked like a charm///

Kobes
11-10-2010, 10:44 PM
Is that method any different to the command
clusterCurve;
?

skealeye
11-10-2010, 10:57 PM
That is the maya embedded command which techincally will achive the same thing that KingFarrukh was asking to do in his situation, but scripting it out directly is a much cleaner method. This way you have the option to name your clusters and store them in strings, also u can select multiple cv's to be in one cluster.
ex:

string $cl[] = `cluster -n "myCluster" ($curve + ".cv[" + $x + "]") ($curve + ".cv[" + ($x + 1) + "]") `;


I highly recommend taking the extra few steps and scripting it out.

KingFarrukh
11-11-2010, 06:39 PM
say I make a joint chain
i'd like to make a curve on that joint chain with one cv / each joint
you've all been super helpful so far =)

thanks a bunch

skealeye
11-11-2010, 09:18 PM
basically what you could do it get the world position of each joint and put that vector (x,y,z value) into the curve command.

example:

string $jnt[] = {"exampleJntA","exampleJntB","exampleJntC"}; // <-- there are better ways to get the jnt list but this is for the example


// this stores each jnts worldPosition
vector $storePositions[];
int $x = 0;

for ($i in $jnt)
{
$storePositions[$x] = `xform -query -worldSpace -translation $i`;
$x++;
}

//this creates the curve command
int $degree = 1; //<-- incase u want to change the degree type

string $buildCurve = ("curve -d " + $degree);

for ($each in $storePositions)
{
$buildCurve += (" -p " + $each);
}

eval $buildCurve;

KingFarrukh
11-12-2010, 02:20 AM
This type of education should is priceless I tellz ya!

Thank you so much.

I wanted to ask you one more things =)
I wanted create a simple JOINT chaine along the z-axis....
- my code works with polyPlanes but when i try it with joints it doesnt. I understand it has something to do with orientations and etc.

code: (with planes)
--------------------------------------------------------------------------------
global proc kF2010_createPlanes() {
for ($i=0; $i<10; $i++)
{
///create planes

string $createPlane[]= `polyPlane -w 1 -h 1 -sx 1 -sy 1 -ax 0 0 1 -cuv 2 -ch 1`;
select -r $createPlane;
string $duplicatePlane[]=`duplicate -rr $createPlane`;
xform -translation 0 0 (2*-($i));
}

};kF2010_createPlanes;
-------------------------------------------------------------------------------------------


code: (with Joints)

global proc kF2010_createPlanes() {
for ($i=0; $i<10; $i++)
{
///CREATE A PLANE
string $createPlane = `joint`;
string $duplicatePlane[]=`duplicate`;
xform -translation 0 1 (2*-($i));
}
};kF2010_createPlanes

---------------------------------------------------------------
I see whats its doing. Can you help me to fix it pls.
I just want simple chain =) evenly spaced

skealeye
11-12-2010, 06:00 PM
This is a very basic example of what you could do, for jnt orientation and jnt rotate order and so on, u should read up on the maya help for the proper flags needed in the `joint` command.

Basically what i have in the example below is a very simple prodedure that will draw joints down the z axis. I am doing this by putting a value inside the z position when i create my joints. If i wanted them to be going the reverse way in z i can do this : -position 0 0 ($i *-1)

To make the script more dynamic instead of putting the amount of joints you want in your "for loop", you can easily make an argument so u can input the amount of joints you want every time you run the procedure.
So when i run the script jntChain(10) will give me 10 joints... jntChain(20) will give me 20 joints and so on...

global proc jntChain(int $jntCount)
{
for ($i=0; $i<$jntCount; $i++)
{
string $joint = `joint -name ("example_" + $i + "_Jnt") -position 0 0 $i`;
}
}


also if u wanted the joint to not be connected you just need to clear your selection after each joint is created.

global proc floatingJnts(int $jntCount)
{
for ($i=0; $i<$jntCount; $i++)
{
string $joint = `joint -name ("example_" + $i + "_Jnt") -position 0 0 $i`;
select -cl;
}
}

KingFarrukh
11-16-2010, 01:32 PM
Thank you once again.
sorry I've been occupied with other work. But this works like a charm.


Anymore questions, I'll send em your way, Sean.

=)

ps. Are you on LinkedIn?
and I went to the "Useful" button on your post and it gave me a messege saying I should spread some reputation.

How does that work?????

CGTalk Moderation
11-16-2010, 01:32 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.