demo reel

portfolio

resume

links

contact

 


Tillandsia Usneoides (Spanish Moss) - Process

 

Testing Recursive Procedures

A recursive procedure to generate a spiraling series of spheres that get smaller.
Modified from code found in Mel Scripting for Animators book.



proc makeCurly(string $parentSphereName,
float $parentRadius,
float $rotAngle,
float $scale,
int $firstSphere)
{

if($firstSphere)
{
sphere -n $parentSphereName;
scale $parentRadius $parentRadius $parentRadius;
}

//
select -r $parentSphereName;
string $duplicateName[] = `duplicate`;
string $childSphereName = $duplicateName[0];

select -cl;
select $childSphereName $parentSphereName;

parent;
select $childSphereName;

float $childSize =$scale * $parentRadius;

scale $scale $scale $scale;

move -ls (1 + $scale) (1 + $scale) 0;

select $parentSphereName;
rotate 0 $rotAngle 0;

if ($childSize > 0.05)
{
makeCurly($childSphereName, $childSize, $rotAngle,
$scale, 0);
}
}

makeCurly("firstSphere",1,20,0.95,1);

 

 

The base curve for the moss
I used sin and cos functions to generate the spiraling shape of the curve from a designated point.  I want to continue and try moving the points using the sphrand function.  After that I need to start creating branches.

proc makeSpiral(float $length, vector $beginPnt,
                       int $maxDepth) {
  vector $pntsA[];
  string $lineA = "curve -d 3 ";


//Create Originating Curly Strand
for ($i = 0; $i < $length-1; $i++) {
  if ($i == 0)
    $pntsA[$i] = $beginPnt;
    else {
     $pntsA[$i] = $pntsA[($i-1)] + <<(rand(-2)*
     sin($i*360)), (rand(-5)), (2*      cos($i*360))>>;
     }
   $lineA += " -p " + $pntsA[$i];
  }
eval($lineA);
}

makeSpiral(20, 0, 0, 0, 0);

 

Spanish Moss using branching
This is actually branching from the origin. This problem is resolved in the next step by referencing a separate value for $lineB.


//Create Originating Curly Strand
for ($i = 0; $i < $length-1; $i++) {
if ($i == 0)
$pntsA[$i] = $beginPnt;
else {
$pntsA[$i] = $pntsA[($i-1)] + <<(rand(-2)*
sin($i*360)),
(rand(-5)), (2* cos($i*360))>>;
}
$lineA += " -p " + $pntsA[$i];

makeBranch($lineA,3,$pntsA[$i]);
}
eval($lineA);
print $pntsA;
}

//Procedure for making each branch
proc makeBranch (string $lineB, float $len,
                          vector $firstPnt) {
vector $pntsB[];
for ($x = 0; $x < $len-1; $x++) {
if ($x == 0)
$pntsB[$x] = $firstPnt;
else {
$pntsB[$x] = $pntsB[($x-1)] + <<(rand(-.5)*
sin($x*360)), (rand(-5)), (2* cos($x*360))>>;
}
$lineB += " -p " + $pntsB[$x];
}
eval($lineB);
}

 

Spanish Moss using branching from CV's
Yikes - I need to not reference the cv's and get an actual point on the line.  Also - to do: vary the rotation about the line of the branches, add more than one branch at each point.  Make the branches a
little more curvy and "alive looking".

//Create Originating Curly Strand
for ($i = 0; $i < $length-1; $i++) {
if ($i == 0)
$pntsA[$i] = $beginPnt;
else {
$pntsA[$i] = $pntsA[($i-1)] + <<(rand(-2)*
sin($i*360)), (rand(-5)), (2* cos($i*360))>>;
// makeBranch(3,$pntsA[$i]);
}
$lineA += " -p " + $pntsA[$i];
makeBranch(5,$pntsA[$i]);
}
eval($lineA);
print $pntsA;

string $getName = `ls -selection`;
vector $points[];
for ($i = 0; $i < $length-1; $i++) {
$points[$i] = `pointOnCurve -pr (1/$length) -p
$getName`;
}
print $points;
}

//Procedure for making each branch
proc makeBranch (float $len, vector $firstPnt) {
vector $pntsB[];
string $lineB = "curve -d 3 ";

for ($x = 0; $x < $len-1; $x++) {
if ($x == 0)
$pntsB[$x] = $firstPnt;
else {
$pntsB[$x] = $pntsB[($x-1)] + <<(rand(-.2)*
sin($x*360)), (rand(-5)), (2* cos($x*360))>>;
}
$lineB += " -p " + $pntsB[$x];
}
eval($lineB);
}

 

Branching from points on the line
I have a procedure generating a curved line. Within a for loop findPoint() finds the points on the curve, then stores those points in vector $pVec. Then calls makeBranch() to generate another curve at the point. This repeats for each point found on the line. See Maya Mel file for more information.
TO DO: I still am working on an interface for the user to input data, want to vary the branches more and create smaller subbranching.

Relevant info (see script for more):

//......more before this


//The for loop gets point at $uValue specified
// in findPoint() for ($i = 1; $i < $length/2; $i++) { float $p[] = findPoint($name,$i,$length); $pVec = << $p[0], $p[1], $p[2] >>; makeBranch(5, $pVec); makeBranch(5, $pVec); } } //Procedure for returning one point on the line proc float[] findPoint(string $branchName,int $z, float $brLength) { string $spnCommand = $branchName + ".spans"; int $spans = `getAttr $spnCommand`; float $uValue = ($spans * $z/($brLength))*2; return `pointOnCurve -pr $uValue -p $branchName`; } ///more after this.......





 

 

 

Heading

sideLinks


                             

 

                                   © 2004-2006 by Carrie Jones. All Rights Reserved.