View Full Version : Help with tree generation!

11 November 2010, 03:39 PM
Im working on a group project which requires us to procedurally generate trees in Maya. My job is to distribute the leaves throughout the branches. Im trying to create a locator at each branch's vertices (low poly count for the branches) and then randomly building the leaves off each locator. Im having trouble sending out the locators

p, li { white-space: pre-wrap; } int $vtxRand;
string $object = "myObj";
int $i;
int $count[] = `polyEvaluate -v myObj`;

string $counterList[] = `size($count)`;
string $counter = ($object + ".vtx[" + $counterList + "]");
string $vertex[] = `ls $counter`;
for ($currvert in $vertex)

$arraySizeVertex = `size($vertex)`;

int $vetx = `rand 0 $arraySizeVertex`;
float $vtxPos[] = `pointPosition $vertex[$vetx]`;

move ($vtxPos[0] + `rand(2)`) $vtxPos[1] ($vtxPos[2] + `rand(-1)`);

I'm getting the error: p, li { white-space: pre-wrap; } // Error: string $counter = ($object + ".vtx[" + $counterList + "]"); //
// Error: Line 7.53: Illegal operation "+" on data of type string[]. //

Was wondering either what the solution would be or if there is a more elegant way of accomplishing the leaf distribution.

11 November 2010, 03:28 PM
make it

string $counter = ($object + ".vtx[" + $counterList[0] + "]");

11 November 2010, 05:17 PM
or, probably even more sensibly:

int $counterList = `size $count`; // size returns an integeralso Dan, this has been discussed before on the Maya forum, do a search for tree and leaf or something and see if you can find it.

CGTalk Moderation
11 November 2010, 05:17 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.