PDA

View Full Version : how to assign value to vector array


biorhythm
01-03-2008, 10:46 AM
Hi,

How a value can be dynamically assigned to an element in a vector array?

The following loop is supposed to declare a vector array for each selected mesh, and assign each element with the translation value of each vertex within said mesh. But this loop for some reason assigns every value to the first element in the array.

string $meshes[] = `ls -sl` ;

for($i=0;$i<size($meshes);$i++)
{

int $vertCount[] = `polyEvaluate -v $meshes[$i]` ;
eval( "vector $" + $meshes[$i] + "Vct[] ;" ) ;

for($j=0;$j<$vertCount[0];$j++)
{
float $vertCord[] = `pointPosition -w ($meshes[$i] + ".vtx[" + $j + "]")` ;
evalEcho( "vector $" + $meshes[$i] + "Vct[" + $j + "] = {<<" + $vertCord[0] + ", " + $vertCord[1] + ", " + $vertCord[2] + ">>} ;" ) ;
}

};

thanks in advance
:)

GiantG
01-03-2008, 12:48 PM
deleted......

biorhythm
01-18-2008, 04:36 AM
cool, the script seems to work now. i just combined the two commands in the nested loop into one. i cant believe i didn't think of this earlier.

thanks anyways :)

string $mesh[] = `ls -sl` ;

for($i=0;$i<size($mesh);$i++)
{

int $nvert[] = `polyEvaluate -v $mesh[$i]` ;
evalEcho("vector $" + $mesh[$i] + "VCT[] ;" ) ;

for($j=0;$j<$nvert[0];$j++)
{
evalEcho( "$" + $mesh[$i] + "VCT[" + $j + "] = `pointPosition -w " + ($mesh[$i] + ".vtx[" + $i + "]") + " ` ; " ) ;
}

}

CGTalk Moderation
01-18-2008, 04:36 AM
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.