/* Name: Game Maker 6.1 Model File Exporter for Anim8or v0.95A Copyright: 2007 Author: Tyson Collins && Kyle Smith Date: 04/15/2007 3:10 Description: Add this to your scripts directory and start Anim8or. */ #plugin("object", "export", "Game Maker 6 Model", ".d3d"); #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("100\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(); int $total; $total = ($numFaces * 3) + 2 + ($numFaces / 333); $output.print("%d\n",$total); $output.print("0 4.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000\n"); 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); $mIndex = $data.GetMatIndex($i); $mat = $data.GetMaterial($mIndex); $color = 255 * $mat.diffuse; $gCol = floor($color.x + 0.5) + 256*floor($color.y + 0.5) + 65536*floor($color.z + 0.5); $output.print("9 %.6g %.6g %.6g", $point.x, $point.z, $point.y); $output.print(" %.5f %.5f %.5f", $normal.x, $normal.z, $normal.y); $output.print(" %.5f %.5f %.5f 1.0000\n", $uv.x, 1-$uv.y, $gCol); } $count = $count + 1; if($count >= 333) { $count = 0; /*Start a new primitive*/ $output.print("1 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000\n"); $output.print("0 4.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000\n"); } } $output.print("1 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000"); } $result = 1;