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.
/*
* 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. */