Author Topic: Anim8or modeling software for BZII?  (Read 2177 times)

desertdog

  • Guest
Anim8or modeling software for BZII?
« on: March 22, 2012, 10:46:32 AM »
This modeling software seems to have some potential for use in making models and props for BZII. It supports exporting X, 3DS, OBJ, LWO and now XSI modeling formats. It also supports plain text based scripting to make custom model export plugins for creating export plugins like XSI and other ASCII text based formats. I have a custom X exporter fixed up by another Anim8or user that works with 3DEX to convert A8 made models to XSI for BZII. The software consists of a single executable in a folder for use in storing A8 plugin scripts. The scripts have different functions with the majority being model export, object creation, and A8 command scripts. There is also a separate ASL script editor that supports A8 scripting functions as well as a syntax checker when new an existing scripts are created. The software is well documented and fairly easy to use. It has a user interface similar to Softimage XSI|3D only much more simplifyied.

I'm currently in the process of devloping a customized BZII XSI exporter with the help of another A8 user named Raxx. I basically am modifying an existing X exporter script to write out a version 1 XSI text format. So far I can write out a simple XSI formated file that 3DEX can read. The exporter is not finished yet as I'm still learning how to work with the A8 scripting language.

The exporters current statis is that it can export a single model group of objects with a texture applied. I made a Sabre Tank that works in game. Raxx, has agreed to continue working on the exporter to add support for sub grouping as per BZII engine requirements. Perhaps, animation support will be added down the road. Anim8or, is available online and the XSI exporter script is also available online as well.



« Last Edit: April 12, 2012, 12:54:15 PM by desertdog »

desertdog

  • Guest
Re: Anim8or modeling software for BZII?
« Reply #1 on: March 22, 2012, 01:47:51 PM »
Raxx, is helping me work the bugs out of an Anim8or BZII XSI exporter script; he's revised the script twice now and I've tested it in the map editor and minus the texture the model loads directly in to BZII. I posted a sample XSI model file from the data pack for Raxx to examine and determine if he can revised the XSI ASL script again to write out a more precise XSI format compatible with BZII. Here's a copy of the latest script revision. If anyone with script writing experience wants to help get it done then let me know and I'll work with you to get the project done. I'll keep everyone posted as progress is made.
Code: [Select]
/*
* Original .X plugin pieced together from Joe Cooning and Zaidon's
* .X exporters with a bit of independent work by Raxx.
*
* Originally written by Raxx as a .X exporter, then further
* modified by Raxx and BNG for .XSI compatibility with
* the Battlezone II Combat Commander game engine.
*
* Copyright 2012 Randall Bezant.  Permission granted for
* modification and use, including commercial use.  Source
* distribution must include this copyright.
*/

#plugin("object", "export", "BZ II XSI", ".xsi");
#file($output, "text");
#return($result);

file $output;
int $result;

object $curObject;

$curObject = project.curObject;
$output.print("xsi 0101txt 0032\n\nSI_CoordinateSystem coord\n\n {\n1;\n0;\n1;\n0;\n2;\n5;\n}\n\n");

shape $shape, $shapes[1], $childShapes[1];
tridata $mdata;
int $numPoints, $numFaces, $numMaterials;
int $ii, $jj, $tallyPoints, $index1, $index2, $index3;
point3 $point, $normal, $tr1, $tr2, $tr3, $tr4, $p1, $p2, $p3;
point2 $uv;
float4x4 $transformMat;
string $matName, $texFile, $text;
material $material;
texture $tex;

/* The shapes in $shapes are processed in reverse order so */
/* reverse the array of values that GeetShapes returns:    */

$curObject.GetShapes($childShapes);
$shapes.size = 0;
while ($childShapes.size > 0)
    $shapes.push($childShapes.pop());

while ($shapes.size > 0) {
    $shape = $shapes.pop();
    
$output.print("Frame Frm {\n     FrameTransformMatrix {\n  1.000000,0.000000,0.000000,0.000000,\n  0.000000,1.000000,0.000000,0.000000,\n  0.000000,0.000000,1.000000,0.000000,\n  0.000000,0.000000,0.000000,1.000000;;\n   }\n");

        if ($shape.GetKind() == SHAPE_KIND_GROUP) {
        $shape.GetShapes($childShapes);
        
        while ($childShapes.size > 0) {
            $shapes.push($childShapes.pop());
        }
    } else if ($shape.GetKind() == SHAPE_KIND_PATH ||
               $shape.GetKind() == SHAPE_KIND_MODIFIER ||
               $shape.GetKind() == SHAPE_KIND_TEXT)
    {
        /* No 3D mesh to output. */
    } else {

 $mdata = $shape.GetTriangleData();

 $output.print("Frame %s {\nFrameTransformMatrix {\n", $shape.name);
  
        $transformMat = $shape.GetGlobalTransform();
        $tr4=$transformMat.Project((0.0,0.0,0.0));
        $tr1=$transformMat.Project((1.0,0.0,0.0))-$tr4;
        $tr2=$transformMat.Project((0.0,1.0,0.0))-$tr4;
        $tr3=$transformMat.Project((0.0,0.0,1.0))-$tr4;
        $output.print("  %.6f,%.6f,%.6f,0.000000,\n",$tr1);
        $output.print("  %.6f,%.6f,%.6f,0.000000,\n",$tr2);
        $output.print("  %.6f,%.6f,%.6f,0.000000,\n",$tr3);
        $output.print("  %.6f,%.6f,%.6f,1.000000;;\n }\n",$tr4);
        
                
        $output.print("Mesh %s_mesh {\n", $shape.name);

        $numPoints = $mdata.GetNumPoints();
        $output.print("%d;\n", $numPoints);
        for $ii = 0 to $numPoints-1 do {
            $point = $mdata.GetPoint($ii);
            $output.print("%.6f; %.6f; %.6f;", $point);
if ($ii<$numPoints-1){
 $output.print(",\n");
} else {
 $output.print(";\n");
}
        }

        $numFaces = $mdata.GetNumTriangles();
        $output.print("\n%d;\n", $numFaces);
        for $ii = 0 to $numFaces - 1 do {
$output.print("3;%d,%d,%d;", $mdata.GetIndex($ii*3), $mdata.GetIndex($ii*3+1), $mdata.GetIndex($ii*3+2));
if ($ii<$numFaces-1){
  $output.print(",\n");
} else {
 $output.print(";\n");
}
        }
    $output.print("\nMeshMaterialList {\n");
        $numMaterials = $mdata.GetNumMaterials();
 $output.print("%d;\n", $numMaterials);
 $output.print("%d;\n", $numFaces);
 for $ii = 0 to $numFaces - 1 do {
$output.print("%d", $mdata.GetMatIndex($ii));
if ($ii<$numFaces - 1) {
 $output.print(",\n");
} else {
 $output.print(";\n");
}
 }
        for $ii = 0 to $numMaterials - 1 do {
            $material = $mdata.GetMaterial($ii);
$tex = $material.GetTexture(TEXTURE_DIFFUSE);
            $matName = $material.name;
            if ($matName == " -- default --") {
                $matName = "___default___";
            }
            $output.print("SI_Material %s {\n", $matName);
            $output.print("%.6f; %.6f; %.6f; %.6f;;\n", $material.diffuse, $material.alpha);
$output.print("%.6f;\n", $material.Ks);
            $output.print("%.6f; %.6f; %.6f;;\n", $material.specular);
            $output.print("%.6f; %.6f; %.6f;;\n", $material.emissive);
            $output.print("1;\n");
            $output.print("%.6f; %.6f; %.6f;;\n", $material.ambient);
$texFile = $tex.GetFileName();
            if ($texFile != ""){
   $output.print("TextureFilename {\n\"%s.%s\";\n}\n", $texFile.GetRoot(), $texFile.GetExt());
}
$output.print("}\n");
 }
        $output.print("}\n");
      
        $output.print("SI_MeshNormals {\n%d;\n", $numPoints);
        for $ii = 0 to $numPoints - 1 do {
          $normal = $mdata.GetNormal($ii);

          $output.print("%.6f; %.6f; %.6f;", $normal);
   if ($ii<$numPoints-1){
$output.print(",\n");
   } else {
$output.print(";\n");
   }
        }

$output.print("%d;\n", $numFaces);
        for $ii = 0 to $numFaces - 1 do {
           $output.print("%d;", $ii);
$output.print("3;%d,%d,%d;", $mdata.GetIndex($ii*3), $mdata.GetIndex($ii*3 + 1), $mdata.GetIndex($ii*3+2));
if ($ii<$numFaces-1){
  $output.print(",\n");
} else {
 $output.print(";\n");
}
        }
        $output.print("}\n\n");
        $output.print("SI_MeshTextureCoords {\n%d;\n", $numPoints);
        for $ii = 0 to $numPoints - 1 do {
            $uv = $mdata.GetTexCoord($ii);
          
            $output.print("%.5f; %.5f;", $uv);
if ($ii<$numPoints - 1){
 $output.print(",\n");
} else {
 $output.print(";\n");
}
        }
        
$output.print("%d;\n", $numFaces);
  
        for $ii = 0 to $numFaces - 1 do {

           $output.print("%d;", $ii);
$output.print("3;%d,%d,%d;", $mdata.GetIndex($ii*3),$mdata.GetIndex($ii*3+1),$mdata.GetIndex($ii*3+2));
if ($ii<$numFaces-1){
  $output.print(",\n");
} else {
 $output.print(";\n");
}
        }
        $output.print("}\n");
    $output.print("}\n");
    }
    
$output.print("}\n");
}
$result = 1;        /* Assume export will succeed. */

« Last Edit: March 22, 2012, 01:48:44 PM by desertdog »

desertdog

  • Guest
Re: Anim8or modeling software for BZII?
« Reply #2 on: March 26, 2012, 03:55:53 PM »
Raxx and I are working on script revisions for the BZII XSI exporter for Anim8or. We figured out how to export a usable BZII test cube model that loads in to BZII w/o it crashing. We still can't figure out why the texture won't appear on the models, but basic material colors do show up on the model okay. As usual Raxx does all of the script revisions and I test them in BZII. I've learned enough about script writing to make minor changes in the scripts as Raxx revises them. I think we're up to revision 4 so far. I'll post progress reports for those interested in this project. FYI: We could use some testers to help figure things out. Our XSI format is very similar to the one created by 3DEX 1.5.5; we're clueless as to why it still has an issue with the texture. As per texture porportions I'm using only squared texture sizes like 128x128 etc.

Update: turns out the exporter is fine, but the texture I was using was the actual problem. I created a new 512by512 bmp and used that on the model and wala the texture is viewable now. Raxx, has offered to help out this weekend and will try to modify the existing script to add multiple object grouping similar to that used by BZII. He believes it is possible. Leroy.
 
Code: [Select]
/*
* Original .X plugin pieced together from Joe Cooning and Zaidon's
* .X exporters with a bit of independent work by Raxx.
*
* Originally written by Raxx as a .X exporter, then further
* modified by Raxx and BNG for .XSI compatibility with
* the Battlezone II Combat Commander game engine.
*
* Copyright 2012 Randall Bezant.  Permission granted for
* modification and use, including commercial use.  Source
* distribution must include this copyright.
*/

#plugin("object", "export", "BZ II XSI", ".xsi");
#file($output, "text");
#return($result);

file $output;
int $result;

object $curObject;

$curObject = project.curObject;
$output.print("xsi 0101txt 0032\n\nSI_CoordinateSystem coord {\n1;\n0;\n1;\n0;\n2;\n5;\n}\n\n");

shape $shape, $shapes[1], $childShapes[1];
tridata $mdata;
int $numPoints, $numFaces, $numMaterials;
int $ii, $jj, $tallyPoints, $index1, $index2, $index3;
point3 $point, $normal, $tr1, $tr2, $tr3, $tr4, $p1, $p2, $p3;
point2 $uv;
float4x4 $transformMat;
string $matName, $texFile, $text;
material $material;
texture $tex;

/* The shapes in $shapes are processed in reverse order so */
/* reverse the array of values that GeetShapes returns:    */

$curObject.GetShapes($childShapes);
$shapes.size = 0;
while ($childShapes.size > 0)
    $shapes.push($childShapes.pop());
    
/*$output.print("Frame Frm {\n     FrameTransformMatrix {\n  1.000000,0.000000,0.000000,0.000000,\n  0.000000,1.000000,0.000000,0.000000,\n  0.000000,0.000000,1.000000,0.000000,\n  0.000000,0.000000,0.000000,1.000000;;\n   }\n");*/


while ($shapes.size > 0) {
    $shape = $shapes.pop();
    
        if ($shape.GetKind() == SHAPE_KIND_GROUP) {
        $shape.GetShapes($childShapes);
        
        while ($childShapes.size > 0) {
            $shapes.push($childShapes.pop());
        }
    } else if ($shape.GetKind() == SHAPE_KIND_PATH ||
               $shape.GetKind() == SHAPE_KIND_MODIFIER ||
               $shape.GetKind() == SHAPE_KIND_TEXT)
    {
        /* No 3D mesh to output. */
    } else {

 $mdata = $shape.GetTriangleData();

 $output.print("Frame %s {\nFrameTransformMatrix {\n", $shape.name);
  
        $transformMat = $shape.GetGlobalTransform();
        $tr4=$transformMat.Project((0.0,0.0,0.0));
        $tr1=$transformMat.Project((1.0,0.0,0.0))-$tr4;
        $tr2=$transformMat.Project((0.0,1.0,0.0))-$tr4;
        $tr3=$transformMat.Project((0.0,0.0,1.0))-$tr4;
        $output.print("  %.6f,%.6f,%.6f,0.000000,\n",$tr1);
        $output.print("  %.6f,%.6f,%.6f,0.000000,\n",$tr2);
        $output.print("  %.6f,%.6f,%.6f,0.000000,\n",$tr3);
        $output.print("  %.6f,%.6f,%.6f,1.000000;;\n }\n",$tr4);
        
                
        $output.print("Mesh %sMesh {\n", $shape.name);

        $numPoints = $mdata.GetNumPoints();
        $output.print("%d;\n", $numPoints);
        for $ii = 0 to $numPoints-1 do {
            $point = $mdata.GetPoint($ii);
            $output.print("%.6f; %.6f; %.6f;", $point);
if ($ii<$numPoints-1){
 $output.print(",\n");
} else {
 $output.print(";\n");
}
        }

        $numFaces = $mdata.GetNumTriangles();
        $output.print("\n%d;\n", $numFaces);
        for $ii = 0 to $numFaces - 1 do {
$output.print("3;%d,%d,%d;", $mdata.GetIndex($ii*3), $mdata.GetIndex($ii*3+1), $mdata.GetIndex($ii*3+2));
if ($ii<$numFaces-1){
  $output.print(",\n");
} else {
 $output.print(";\n");
}
        }
    $output.print("\nMeshMaterialList {\n");
        $numMaterials = $mdata.GetNumMaterials();
 $output.print("%d;\n", $numMaterials);
 $output.print("%d;\n", $numFaces);
 for $ii = 0 to $numFaces - 1 do {
$output.print("%d", $mdata.GetMatIndex($ii));
if ($ii<$numFaces - 1) {
 $output.print(",\n");
} else {
 $output.print(";\n");
}
 }
        for $ii = 0 to $numMaterials - 1 do {
            $material = $mdata.GetMaterial($ii);
$tex = $material.GetTexture(TEXTURE_DIFFUSE);
            $matName = $material.name;
            if ($matName == " -- default --") {
                $matName = "___default___";
            }
            $output.print("SI_Material %s {\n", $matName);
            $output.print("%.6f; %.6f; %.6f; %.6f;;\n", $material.diffuse, $material.alpha);
$output.print("%.6f;\n", $material.Ks);
            $output.print("%.6f; %.6f; %.6f;;\n", $material.specular);
            $output.print("%.6f; %.6f; %.6f;;\n", $material.emissive);
            $output.print("1;\n");
            $output.print("%.6f; %.6f; %.6f;;\n", $material.ambient);
$texFile = $tex.GetFileName();
            if ($texFile != ""){
   $output.print("TextureFilename {\n\"%s.%s\";\n}\n", $texFile.GetRoot(), $texFile.GetExt());
}
$output.print("}\n");
 }
        $output.print("}\n\n");
      
        $output.print("SI_MeshNormals {\n%d;\n", $numPoints);
        for $ii = 0 to $numPoints - 1 do {
          $normal = $mdata.GetNormal($ii);

          $output.print("%.6f; %.6f; %.6f;", $normal);
   if ($ii<$numPoints-1){
$output.print(",\n");
   } else {
$output.print(";\n\n");
   }
        }

$output.print("%d;\n", $numFaces);
        for $ii = 0 to $numFaces - 1 do {
           $output.print("%d;", $ii);
$output.print("3;%d,%d,%d;", $mdata.GetIndex($ii*3), $mdata.GetIndex($ii*3 + 1), $mdata.GetIndex($ii*3+2));
if ($ii<$numFaces-1){
  $output.print(",\n");
} else {
 $output.print(";\n");
}
        }
        $output.print("}\n\n");
        $output.print("SI_MeshTextureCoords {\n%d;\n", $numPoints);
        for $ii = 0 to $numPoints - 1 do {
            $uv = $mdata.GetTexCoord($ii);
          
            $output.print("%.5f; %.5f;", $uv);
if ($ii<$numPoints - 1){
 $output.print(",\n");
} else {
 $output.print(";\n\n");
}
        }
        
$output.print("%d;\n", $numFaces);
  
        for $ii = 0 to $numFaces - 1 do {

           $output.print("%d;", $ii);
$output.print("3;%d,%d,%d;", $mdata.GetIndex($ii*3),$mdata.GetIndex($ii*3+1),$mdata.GetIndex($ii*3+2));
if ($ii<$numFaces-1){
  $output.print(",\n");
} else {
 $output.print(";\n");
}
        }
        /*$output.print("}\n");*/
    $output.print("}\n");
    }
    
$output.print("}\n");
}
$output.print("}");
$result = 1;        /* Assume export will succeed. */

« Last Edit: April 09, 2012, 06:28:03 PM by desertdog »