Author Topic: Working on an Anim8or .dts exporter. (Closed until further notice.)  (Read 1023 times)

Not many people know of Anim8or. I use it for my game projects. And I got to thinking, "I should use this for Blockland.." Then I realized that it doesn't even export to .dts. And since every other modeling system I have is acting up, I have decided to take a whack at making a .dts exporter for Anim8or. I'm still working on it, but If I can get it to work, I'll post it for anyone who wants to use it.
------------------------------------------------
UPDATE: I found a bug in my scripting. I put in convertToDTS(); instead of convertToMesh();. Silly me, trying to name everything DTS.
------------------------------------------------
Another update: I got it to archive onto the Export menu. Now testing...
------------------------------------------------
Updated again: I exported it successfully without getting any errors. I will now put the model into a script and test.
------------------------------------------------
I think something's wrong.
I looked inside the .dts file and saw a bunch of numbers. That's a bit unusual. Still testing it out, though.



Failed. I'll keep trying. I don't think this will go too well.

Here's the code for any geeks out there who may be able to help.

Code: [Select]
#plugin("object", "export", "Torque DTS", ".dts");
#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 = 0 to 2 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;


I'm starting to loose hope. This'll need some major editance before it works.
For instance, it doesn't import animations.
« Last Edit: July 18, 2009, 10:28:03 PM by ottosparks »

Let's see your code for it so far.