Anim8tor exporter script

From Legacy Roblox Wiki
Revision as of 20:12, 6 February 2008 by >Gamer3D (Since this will be useful, here it is.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

This is Gamer3D's Anim8or script for exporting to the Roblox *.mesh format. Though it works, it has not been confirmed that the meshes created with this script work in Roblox.

/*
   Description: Add this to your scripts directory and start Anim8or.
*/
 
 
#plugin("object", "export", "Roblox Mesh", ".mesh");
#file($output, "text");
#return($result);
 
file $output;
int $result;
object $obj;
shape $shape, $shapes[1], $childShapes[1];
tridata $data;
material $mat;
int $numFaces;
point3 $point, $normal, $color;
point2 $uv;
int $i;
int $j;
int $index, $mIndex;
int $count;
float $gCol;
string $nm;
string $newName;
float4x4 $tMatrix;

$nm = $output.GetRoot();

$obj = project.curObject;
$output.print("version 1.00\n");
$obj.GetShapes($childShapes);
$shapes.size = 0;
while($childShapes.size > 0)
{
    $shapes.push($childShapes.pop());
}
while($shapes.size > 0)
{
    	$shape = $shapes.pop();
    	$shape = $shape.ConvertToMesh();
	$data = $shape.GetTriangleData();
       	$numFaces = $data.GetNumTriangles();
	$tMatrix = $shape.GetGlobalTransform();
	$output.print("%d\n",$numFaces);
	for $i = 0 to $numFaces - 1 do {
		for $j = 2 to 0 step -1 do {
			$index = $data.GetIndex(($i*3)+$j);
                    	$point = $data.GetPoint($index);
            	    	$point = $tMatrix.Project($point);
                    	$normal = $data.GetNormal($index);
                    	$uv = $data.GetTexCoord($index);
			$output.print("[%.6g, %.6g, %.6g]", $point.x, $point.y, $point.z);
			$output.print("[%.5f, %.5f, %.5f]", $normal.x, $normal.y, $normal.z);
			$output.print("[%.5f, %.5f, 0]", $uv.x, $uv.y);
                }
	}
}


$result = 1;