General Category > Ongoing Anim8or Development

ASL issues

<< < (2/3) > >>

Trevor:
I fixed and added some more "basic" functions above but would still prefer to se language support for them instead including ToUpper, Split, Join, casting (Int/Float), case insensitive attributes and quaternionToPYR

Trev

Trevor:
Steve, would you be able to say if asl function recursion is possible and if so how long it might take to implement?
Just wondering because I would like to parse groups as groups and might have to make a workaround but obviously recursion would be great and an instant fix for my loop.

thanks,
Trev

Steve:
Sorry, Trevor, but adding recursion is a whole lot of work and I don't have plans to add it in the near future. I agree that it would be quite useful, though, so I'll keep it in mind.

Trevor:
ok no probs

trev

Trevor:
YAY, I managed to implement my own recursion in an8 script :)

this is the specific function;

--- Code: ---int $ParseChildren(shape $Shape)
{
// Set up Stacks instead of normal vars
int   $si[0];
shape $sShape[0];
int   $Result, $i, $j;
shape $CurShape, $ChildShapes[0];

//Push Shape to stack
$sShape.push($Shape);
//Push Stacked Counter
$si.push(0);

$Result = true;

//While shapes are on stack and result is still true (No Fail)
while ($sShape.size && $Result)
{
//Get current shape
$CurShape = $sShape.pop;

if ($CurShape.GetKind() == SHAPE_KIND_GROUP)
{
//Recursion would happen here
// $ParseChildren($CurShape)
//… however ...

//Get Children
$CurShape.GetShapes($ChildShapes);
$DebugPrint("getting Children " + $CurShape.name);

$i = $si.pop; //get last i off stack
$DebugPrint(PrintToString("getting i %d, stacksize %d ", $i, $si.size));

if ($i < $ChildShapes.size)
{
$DebugPrint("Parsing Children " + $CurShape.name);
//Has Children, traverse tree
$sShape.push($CurShape); //Push current Node to stack
$sShape.push($ChildShapes[$i]); //push next Node to stack
$DebugPrint("pushing child  " + $ChildShapes[$i].name);

if(!($StringContains($ChildShapes[$i].name, "BSP")))
{
$PrintTree.push("-"+$ChildShapes[$i].name);
for ($j = 1; $j < $sShape.size; $j++)
{
$PrintTree[$PrintTree.size - 1] = "\t|" + $PrintTree[$PrintTree.size - 1];
}
}


$i++;
$si.push($i); //Push(save) current nodes counter to counter stack
$DebugPrint(PrintToString("getting i %d, stacksize %d ", $i, $si.size));
if ($ChildShapes[$i-1].GetKind() == SHAPE_KIND_GROUP)
{
$si.push(0); //Stack new counter
$DebugPrint(PrintToString("accidental infinit group? getting i %d, stacksize %d ", $i, $si.size));
}
}
else
{
$DebugPrint("end of branch");
//reached end of branch
$C_File.print("/*\n");
$C_File.print("* Group: \n");
$C_File.print("*        Name      = %s\n", $CurShape.name);
$C_File.print("*        Objects   = %d\n", $ChildShapes.size);
$C_File.print("*/\n");

$C_File.print("static Gfx %s_dl[] = {\n", $CurShape.name);
for ($i = 0; $i < $ChildShapes.size; $i++)
{
if ($StringContains($ChildShapes[$i].name, "BSP"))
{
$ParseBSPNode($ChildShapes[$i]);
}
else
{
$C_File.print("    gsSPDisplayList(&%s_dl),\n", $ChildShapes[$i].name);
}
}

$C_File.print("    gsSPEndDisplayList(),\n};\n\n");



}
}
else if ($CurShape.GetKind() == SHAPE_KIND_PATH ||
$CurShape.GetKind() == SHAPE_KIND_MODIFIER ||
$CurShape.GetKind() == SHAPE_KIND_TEXT)
{
/* No 3D mesh to output. */
}
else
{
//Print mesh
if ($StringContains($CurShape.name, "BSP"))
{
//Do Nothing
}
else
{
$Result = $GenerateArray($CurShape);
//$PrintTree.push( PrintToString("%s", $CurShape.name));
}
}


}
return $Result;
}
--- End code ---

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version