Anim8or Community
General Category => ASL Scripts => Topic started by: lppena on March 19, 2012, 08:51:23 am
-
This is what I have so far. 3D Exploration shows these errors.
/*
* This plugin pieced together from Joe Cooning and Zaidon's
* .X exporters with some independent work.
*
* Written by Raxx, this is compatible with the Battlezone II
* Combat Commander game engine and being modified by BNG for use with BZII as an XSI variant of Raxx's X variant.
*
* 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\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;
point3 $point, $normal, $tr1, $tr2, $tr3, $tr4;
point2 $uv;
float4x4 $transformMat;
string $matName, $texFile;
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();
/* If $shape is a group push child shapes onto stack: */
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 Frm-%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);
$point.z =$point.z * -1;
$output.print("%.6f; %.6f; %.6f;", $point);
if ($ii<$numPoints-1){
$output.print(",\n");
} else {
$output.print(";\n");
}
}
$numFaces = $mdata.GetNumTriangles();
$output.print("%d;\n", $numFaces);
for $ii = 0 to $numFaces - 1 do {
$output.print("3;%d,%d,%d;", $mdata.GetIndex($ii*3 + 2), $mdata.GetIndex($ii*3 + 1), $mdata.GetIndex($ii*3));
if ($ii<$numFaces-1){
$output.print(",\n");
} else {
$output.print(";\n");
}
}
$output.print("MeshMaterialList {\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);
$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("}\n}\n");
$output.print("SI_MeshNormals {\n%d;\n", $numPoints);
for $ii = 0 to $numPoints - 1 do {
$normal = $mdata.GetNormal($ii);
$normal.z = $normal.z * -1;
$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("3; %d,%d,%d;", $mdata.GetIndex($ii*3 + 2), $mdata.GetIndex($ii*3 + 1), $mdata.GetIndex($ii*3));
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);
$uv.y = 1.0-$uv.y;
$output.print("%.5f; %.5f;", $uv);
if ($ii<$numPoints - 1){
$output.print(",\n");
} else {
$output.print(";\n");
}
}
$output.print("}\n");
}
}
$result = 1; /* Assume export will succeed. */
-
Sorry I haven't been able to get back to this yet, I've been pretty swamped. Can you attached a simple .xsi file that loads 100% error-free in the game? I'll try to get to it, but it probably won't be until Thursday-Friday (again). Until then maybe I can give you some tips.
-
This sample cube was exported from Truespace as an X model and converted to XSI with 3D Exploration; these models always load correctly in Battlezone II. Thanks Raxx, I could use some pointers on how to rearrange blocks in the X exporter you fixed up for me last week. I've made a backup of the original script and am working on a copy fixed up for use with Anim8or. Leroy. PS: There is no hurry to get it done. I just am working on it in my spare time, so when you have some free time please take a look at what I've done so far.
xsi 0101txt 0032
SI_CoordinateSystem coord {
1;
0;
1;
0;
2;
5;
}
Frame Cube-0 {
FrameTransformMatrix {
1.000000,0.000000,0.000000,0.000000,
0.000000,1.000000,0.000000,0.000000,
0.000000,0.000000,1.000000,0.000000,
0.000000,0.000000,0.000000,1.000000;;
}
Mesh CubeMesh {
8;
1.000000;-1.000000;1.000000;,
1.000000;1.000000;1.000000;,
-1.000000;-1.000000;1.000000;,
-1.000000;1.000000;1.000000;,
1.000000;-1.000000;-1.000000;,
-1.000000;-1.000000;-1.000000;,
-1.000000;1.000000;-1.000000;,
1.000000;1.000000;-1.000000;;
12;
3;1,3,2;,
3;0,1,2;,
3;2,5,4;,
3;0,2,4;,
3;2,3,6;,
3;5,2,6;,
3;1,7,6;,
3;3,1,6;,
3;4,5,6;,
3;7,4,6;,
3;4,7,1;,
3;0,4,1;;
MeshMaterialList {
1;
12;
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0;
SI_Material {
0.168627;0.537255;0.549020;1.000000;;
2.000000;
0.100000;0.100000;0.100000;;
0.000000;0.000000;0.000000;;
1;
0.000000;0.000000;0.000000;;
TextureFilename {
"Gslxtoxsicube_0.bmp";
}
}
}
SI_MeshNormals {
6;
0.000000;0.000000;1.000000;,
0.000000;-1.000000;0.000000;,
-1.000000;0.000000;0.000000;,
0.000000;1.000000;0.000000;,
0.000000;0.000000;-1.000000;,
1.000000;0.000000;0.000000;;
12;
0;3;0,0,0;,
1;3;0,0,0;,
2;3;1,1,1;,
3;3;1,1,1;,
4;3;2,2,2;,
5;3;2,2,2;,
6;3;3,3,3;,
7;3;3,3,3;,
8;3;4,4,4;,
9;3;4,4,4;,
10;3;5,5,5;,
11;3;5,5,5;;
}
SI_MeshTextureCoords {
14;
0.000000;-0.333333;,
0.250000;-0.333333;,
0.250000;-0.666667;,
0.000000;-0.666667;,
0.500000;-0.666667;,
0.500000;-1.000000;,
0.250000;-1.000000;,
0.500000;-0.333333;,
0.500000;-1.333333;,
0.250000;-1.333333;,
0.750000;-0.666667;,
0.750000;-0.333333;,
1.000000;-0.333333;,
1.000000;-0.666667;;
12;
0;3;0,1,2;,
1;3;3,0,2;,
2;3;2,4,5;,
3;3;6,2,5;,
4;3;2,1,7;,
5;3;4,2,7;,
6;3;6,5,8;,
7;3;9,6,8;,
8;3;10,4,7;,
9;3;11,10,7;,
10;3;10,11,12;,
11;3;13,10,12;;
}
}
}
-
Ok, this *might* fix it. When you rearrange stuff in code, you have to make sure you have all of the brackets and parenthesis ( { and } ) properly placed.
Also, the XSI file that you included needed the ambient color as well, so I added that to the script.
There is one final discrepancy in that the UV coordinates in the XSI version need an extra set of data. I didn't implement that yet, but go ahead and test it to see if it works without it.
Export script is attached below.
-
Will do and thank you Raxx for taking the time to make the changes for the XSI format. I'm going to compare the changes so that I might see what I need to do as far as modifying the scripts themselves and writing them out more correctly. I guess the task requires more knowledge then I currently understand.
Are there some general guidelines that I can check for as far as placing brackets and pare thesis? In my modified version I basically changed the header entries and moved the material section to above meshnormals entry thinking this would do the trick, but it only made the geometry disappear when viewed in 3DEX. After that the confusion factor took over. Thanks again and I'll DL the script and test it out. Leroy.
-
3DEX is showing these errors now and the geometry is still not visible. I'm thinking that this XSI format is so outdated that more modern features are no longer supported by today's standards. Other people have attempted to make XSI version 1 exporters with software like Blender without success. I have one that prehaps you could take a look at. It was a python script written for version 2.4 of Blender. I know your time is limited so if have some spare time to look at the python script for some clues on how to modify the ASL script. Thanks Raxx, Leroy.
PS: Do you think proper indentation may be an issue? On the 3DEX X to XSI write out it has indentation within the file while the version you and I modified are left jusified. I don't know if this would make any difference, but I thought that I would mention it.
Update: I got the geometry to appear in 3DEX by changing the scripts SI_Material back to just Material. All of the other error messages disappeared as well. Now the only issue appears to be that the texture is not appearing; just hows as a grey material color on the cube. What do you make of this Raxx? Leroy.
-
Ok, I fixed it. I downloaded 3DEX and must have run the xsi and .x files through it a hundred times :P The initial loading errors (including the lack of texture) were mostly caused by the lack of proper UV coord information, but there also turned out to be a ton of transformation problems with both the .xsi and .x exporters, so I fixed it all to where it looks exactly the same in both Anim8or and 3DEX.
However, 3DEX's orientation system is a bit weird, so if you can get an anim8or-exported .xsi model into the game engine to see if the orientation is truly correct, I would appreciate it.
Attached is the updated script. Let me know if it's the final, completely bug-free one so that I can put it in the database (I'm updating the .x one in the database as well).
-
Will do Raxx and thank you for your patience and most valuable effort on this project. You are right about 3DEX 1.5.5., but its the closest model converter I have access to in working with antiquate model formats like version 1 XSI. The current XSI format has changed drastically from earlier versions but is totally incompatible as far using it for Battlezone II which was released in 1999. I sincerely appreciate your taking the time to even work on the project. I'll test the changes to the exporter and report back on the results. Thanks again Raxx. Leroy.
PS: I hope you don't mind but I added the DirectX exporter you fixed up for me so that other Anim8or users can add it to their ASL scripts library. I want to learn how to create ASL scripts as I'm pretty much hooked on Anim8or now. I'm beginning to really get off on using A8 as a really cool modeling software. Cheers, Leroy.
-
Wow! Raxx the model loads in to BZII; usually my models would crash the game, but your version loads without errors. The only issue I notice is the texture is not showing as displayed in this BZII screen grab, but I suspect the issue may lie with the texture itself as I've seen it before in some of my own XSI models created in Truespace using the X exporter and 3DEX to convert them to XSI. I'll try using some different textures and post the results. You truly are a gifted person in terms of understanding how to fix things up in Anim8or. Leroy.
-
Raxx, I found this XSI model that was originally created for BZII using Softimage XSI|3D. When you have time could you take a look at the file and determine if the XSI exporter script could be modified to write out this format? It contains some extra SI entries that I attempted to add to the existing script but I get some errors when I try to add them to the header area of the script; something to do with a token error reported when I run a syntax check in the ASL Editor. Thanks Leroy.
xsi 0101txt 0032
SI_CoordinateSystem coord {
1;
0;
1;
0;
2;
5;
}
SI_Angle {
0;
}
SI_Camera Camera1 {
-1.668501; 1.033439; -3.593543;;
0.469189; 0.000000; 0.383656;;
0.000000;
65.000000;
0.100000;
32768.000000;
}
SI_Ambience {
0.300000; 0.300000; 0.300000;;
}
Frame frm-sphere1 {
FrameTransformMatrix {
1.000000,0.000000,0.000000,0.000000,
0.000000,1.000000,0.000000,0.000000,
0.000000,0.000000,1.000000,0.000000,
0.000000,0.000000,0.000000,1.000000;;
}
Mesh sphere1 {
17;
-0.000000;-0.000000;0.003000;,
-0.571733;-0.000000;0.290717;,
-0.404277;-0.404277;0.290717;,
-0.281138;-0.000000;0.116157;,
0.281138;-0.000000;0.116157;,
-0.404277;0.404277;0.290717;,
-0.198795;-0.198795;0.116157;,
-0.198795;0.198795;0.116157;,
0.404277;-0.404277;0.290717;,
-0.000000;0.571734;0.290717;,
0.198795;-0.198795;0.116157;,
-0.000000;0.281138;0.116157;,
0.571733;-0.000000;0.290717;,
0.404277;0.404277;0.290717;,
-0.000000;-0.571734;0.290717;,
0.198795;0.198795;0.116157;,
-0.000000;-0.281138;0.116157;;
16;
3;6,3,0;,
4;2,1,3,6;,
4;1,5,7,3;,
3;3,7,0;,
3;16,6,0;,
4;14,2,6,16;,
4;5,9,11,7;,
3;7,11,0;,
3;10,16,0;,
4;8,14,16,10;,
4;9,13,15,11;,
3;11,15,0;,
3;4,10,0;,
4;12,8,10,4;,
4;13,12,4,15;,
3;15,4,0;;
MeshMaterialList {
1;
16;
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0;
SI_Material {
0.700000;0.700000;0.700000;1.000000;;
0.000000;
0.000000;0.000000;0.000000;;
0.000000;0.000000;0.000000;;
2;
0.500000;0.500000;0.500000;;
SI_Texture2D {
"Z:/modelsdirectory/misceffects/effects/PICTURES/flash.pic";
4;
256;256;
0;255;0;255;
0;
1;1;
0;0;
1.000000;1.000000;
0.000000;0.000000;
-1.000000,0.000000,-0.000000,0.000000,
0.000000,1.000000,0.000000,0.000000,
0.000000,0.000000,-1.000000,0.000000,
0.000000,0.000000,0.000000,1.000000;;
3;
1.000000;
0.750000;
1.000000;
0.000000;
0.000000;
0.000000;
0.000000;
}
}
}
SI_MeshNormals {
56;
-0.314793;-0.314793;-0.895439;,
-0.445185;-0.000000;-0.895439;,
-0.000000;-0.000000;-1.000000;,
-0.364115;-0.364114;-0.857229;,
-0.514936;-0.000000;-0.857229;,
-0.445185;-0.000000;-0.895439;,
-0.314793;-0.314793;-0.895439;,
-0.514936;-0.000000;-0.857229;,
-0.364115;0.364114;-0.857229;,
-0.314793;0.314793;-0.895439;,
-0.445185;-0.000000;-0.895439;,
-0.445185;-0.000000;-0.895439;,
-0.314793;0.314793;-0.895439;,
-0.000000;-0.000000;-1.000000;,
-0.000000;-0.445185;-0.895439;,
-0.314793;-0.314793;-0.895439;,
-0.000000;-0.000000;-1.000000;,
-0.000000;-0.514935;-0.857229;,
-0.364115;-0.364114;-0.857229;,
-0.314793;-0.314793;-0.895439;,
-0.000000;-0.445185;-0.895439;,
-0.364115;0.364114;-0.857229;,
-0.000000;0.514935;-0.857229;,
-0.000000;0.445185;-0.895439;,
-0.314793;0.314793;-0.895439;,
-0.314793;0.314793;-0.895439;,
-0.000000;0.445185;-0.895439;,
-0.000000;-0.000000;-1.000000;,
0.314793;-0.314793;-0.895439;,
-0.000000;-0.445185;-0.895439;,
-0.000000;-0.000000;-1.000000;,
0.364114;-0.364114;-0.857229;,
-0.000000;-0.514935;-0.857229;,
-0.000000;-0.445185;-0.895439;,
0.314793;-0.314793;-0.895439;,
-0.000000;0.514935;-0.857229;,
0.364114;0.364114;-0.857229;,
0.314793;0.314793;-0.895439;,
-0.000000;0.445185;-0.895439;,
-0.000000;0.445185;-0.895439;,
0.314793;0.314793;-0.895439;,
-0.000000;-0.000000;-1.000000;,
0.445185;-0.000000;-0.895439;,
0.314793;-0.314793;-0.895439;,
-0.000000;-0.000000;-1.000000;,
0.514935;-0.000000;-0.857229;,
0.364114;-0.364114;-0.857229;,
0.314793;-0.314793;-0.895439;,
0.445185;-0.000000;-0.895439;,
0.364114;0.364114;-0.857229;,
0.514935;-0.000000;-0.857229;,
0.445185;-0.000000;-0.895439;,
0.314793;0.314793;-0.895439;,
0.314793;0.314793;-0.895439;,
0.445185;-0.000000;-0.895439;,
-0.000000;-0.000000;-1.000000;;
16;
0;3;0,1,2;,
1;4;3,4,5,6;,
2;4;7,8,9,10;,
3;3;11,12,13;,
4;3;14,15,16;,
5;4;17,18,19,20;,
6;4;21,22,23,24;,
7;3;25,26,27;,
8;3;28,29,30;,
9;4;31,32,33,34;,
10;4;35,36,37,38;,
11;3;39,40,41;,
12;3;42,43,44;,
13;4;45,46,47,48;,
14;4;49,50,51,52;,
15;3;53,54,55;;
}
SI_MeshTextureCoords {
56;
0.739047;0.260953;,
0.838064;0.500000;,
0.500000;0.500000;,
0.986136;0.013864;,
1.187500;0.500000;,
0.838064;0.500000;,
0.739047;0.260953;,
1.187500;0.500000;,
0.986136;0.986136;,
0.739047;0.739047;,
0.838064;0.500000;,
0.838064;0.500000;,
0.739047;0.739047;,
0.500000;0.500000;,
0.500000;0.161936;,
0.739047;0.260953;,
0.500000;0.500000;,
0.500000;-0.187500;,
0.986136;0.013864;,
0.739047;0.260953;,
0.500000;0.161936;,
0.986136;0.986136;,
0.500000;1.187500;,
0.500000;0.838064;,
0.739047;0.739047;,
0.739047;0.739047;,
0.500000;0.838064;,
0.500000;0.500000;,
0.260953;0.260953;,
0.500000;0.161936;,
0.500000;0.500000;,
0.013864;0.013864;,
0.500000;-0.187500;,
0.500000;0.161936;,
0.260953;0.260953;,
0.500000;1.187500;,
0.013864;0.986136;,
0.260953;0.739047;,
0.500000;0.838064;,
0.500000;0.838064;,
0.260953;0.739047;,
0.500000;0.500000;,
0.161936;0.500000;,
0.260953;0.260953;,
0.500000;0.500000;,
-0.187500;0.500000;,
0.013864;0.013864;,
0.260953;0.260953;,
0.161936;0.500000;,
0.013864;0.986136;,
-0.187500;0.500000;,
0.161936;0.500000;,
0.260953;0.739047;,
0.260953;0.739047;,
0.161936;0.500000;,
0.500000;0.500000;;
16;
0;3;0,1,2;,
1;4;3,4,5,6;,
2;4;7,8,9,10;,
3;3;11,12,13;,
4;3;14,15,16;,
5;4;17,18,19,20;,
6;4;21,22,23,24;,
7;3;25,26,27;,
8;3;28,29,30;,
9;4;31,32,33,34;,
10;4;35,36,37,38;,
11;3;39,40,41;,
12;3;42,43,44;,
13;4;45,46,47,48;,
14;4;49,50,51,52;,
15;3;53,54,55;;
}
}
}
-
Raxx, I've started to modify your revised script by adding the entries shown in the XSI|3D model I attached to the previous post. Mostly, I added a bunch of $output.print (""); entries with the entries present in the XSI model file; apparently you can just stack one on top of the others. Here's what I have so far; it's a renamed copy of your script so I don't screw up all the work you did already. I'll keep going and post updates as I do more modifications. I appreciate your help Raxx. Leroy.
-
Is there any particular reason to add those entries? I doubt that SI_Angle (which defaults to degrees if not present, which is what we want), SI_Camera, or SI_Ambience are even utilized by the video game, and is probably ignored completely. At this point, I wouldn't try fixing what's not broken.
If the only thing that's wrong with it is the texture, then it might be because it needs the SI_Texture2D block of information. Unfortunately, the only 2D texture info that can be pulled from Anim8or is the file name, so I changed the block name to SI_Texture2D and added a parameter that indicates that it's wrapped. If this doesn't fix it then perhaps there was a problem with your odf file that links everything together, since I'm assuming you specify the texture there anyways, which makes the SI_Texture2D block redundant and therefore ignored by the game anyways.
There was also a problem with the frame and some of the brackets. Attached is the fixed version. I didn't modify your version of the script where you added all of the extraneous info, for the sake of my sanity ;)
-
Thanks Raxx, I have a feeling your right about the extra entries in the SI|3D version. The texture however is not referenced in the models ODF. BZII converts the XSI model to a binary MSH format that the game uses. I looked at the few text entries in the binary file and the problem seems to be caused by the lack of the full texture name in the binary file; it should read texture name.bmp but it only shows the texture name minus the bmp extension.
I will test the changes you made and report back with the results. The stuff I did was just an effort to make the file more complete for 3DEX and the BZII game engine. Other, people who have created XSI converted variants have included these extra entries; they are actually fixed dummy entries in the variants that I've worked with in the past.
Most of them are hacks as they lack support for animation or are problematic when folks edit XSI models with cut and paste operations. The version you are working on is the most accurate variant that I have seen. Thanks again Raxx. Leroy.
-
Hi Raxx. I tested the latest XSI exporter, but the textures are still not showing up on the cube model when I load it in to BZII. It does not make any sense as it looks fine in 3DEX including showing the texture and no file errors at all. Do you have any thoughts on what to try next?
I'm going to try using only material colors on several objects grouped together and see is they show up in BZII. I'll report back as soon as I can test another model. Leroy.
Update: Material colors appear okay on my test cube just hope I can figure out why the texture doesn't. I wonder if and SI_Ambience entry would do the trick? Will try a few modifications to a copy of the script and see what happens. I just wanted to thank Raxx again for all of his efforts so far. Leroy.
-
I may be wrong but, from the screenshot, it looks like the texture is being shrunk a lot, giving it that very gridy look to it.
I know when I was using an arb function in opengl (it sucked so its switched now :P) for textures, the texture coordinates had to be the size of the texture.
so the texture coordinates of a square was like...
point 1 (1024,768)
point 2 (1024,0)
point 3 (0,0)
point 4 (0,768)
however when i switched to the opengl's core texture function (which still supported rectangle images!), everything work in normalized coordinates (the only thing that is normalized in my engine :P )
and it looked something like this...
point 1 (0.7401,0.3801)
point 2 (0.7401,0)
point 3 (0,0)
point 4 (0,0.3801)
it may be the same case for this?
-
Ippena, this is somewhat uncharted territory for me now, since I don't have access to the game and can only act as an observer. There could be any number of things that's causing it. All I can suggest is to take the model and export it with 3DEX so that it loads the texture properly in the game, and then slowly plug in blocks of Anim8or's version into it until it the textures disappear.
cooldude234, not sure if that's actual shrinkage or just noise. I don't know what texture is being tested on it, or the UVs, and I'm not sure if that's the kind of effect that non-normalized coordinates would have. However, the UVs exported seem to already be normalized. That is, between 0 and 1, so I doubt that's the issue.
-
Ippena, perhaps the attached script will work. I only made a minor change to it, but I have no way of testing it.
-
You both have good points. I'll try the revised script with and w/o textures. It's odd though as the cube has zero issues in 3DEX. The old XSI format is a strange beast and many variants have evolved from 3rd party efforts to replicate a usable variant that that will work with the older BZII game engine. Raxx's XSI variant is on e of the best versions I've seen to date. As I've mentioned the BZII engine handles the processing of the XSI model and converts that to a binary .MSH model that also must hold true for the processing of the textures as well. BZII, supports BMP, PNG, JPG, TGA, and a Softimage version of PIC. The latest beta of BZII now only uses a modified DXT version called BZ2DXT; however, I use the older BZII version that does not use BZ2DXT. Also, the X to XSI models I normally use that are converted with 3DEX oddly work in BZII even thought the XSI model does not use the SI_Texture2D entry; it reuses the TextureFilename like the X format uses. Also, because Anim8or models are grouped rather then linked in hierchal tree form there may limited usefulness of Anim8or other then creating the geometry itself; don't know for sure though. What I may start doing is creating the model parts in Anim8or grouping the object together and exporting them to Truespace as X models where I can UV map, and link the model parts for BZII in TS and export that as X for converting to XSI with 3DEX. Unless, I can figure out how to get the A8 XSI model exporter to display the texture properly in BZII; the convert A8 XSI to 3DEX XSI will probably work for single objects models only; BZII uses these for simple terrestrial props like trees. Thanks for the XSI revision I'll test it out throughly and repoert back on the results. Leroy.
-
The revision seem to make no differences as far as showing the texture, and using 3DEX to reconvert the A8 XSI to 3DEX XSI was no good as BZII just crashed. However, using the BZII X exporter you fixed up for me seems to convert well using 3DEX to convert the X model to XSI. Here's what the converted BZII X to XSI model looks like. I can live with this solution if issues can not be sorted out with the BZII XSI exporter Raxx. Perhaps using this as a reference could help sort out issues with the XSI exporter you are attempting to modify will yield some clues on what to change? If not no biggy Raxx. You've spent quite some valuable time, so I don't want to push anymore then you feel comfortable with. Leroy. PS: I zipped up the X and XSI models for you to examine if you want.
xsi 0101txt 0032
SI_CoordinateSystem coord {
1;
0;
1;
0;
2;
5;
}
Frame mesh01 {
FrameTransformMatrix {
1.000000,0.000000,0.000000,0.000000,
0.000000,1.000000,0.000000,0.000000,
0.000000,0.000000,1.000000,0.000000,
0.000001,0.000000,0.000000,1.000000;;
}
Mesh mesh01_mesh {
20;
-9.166700;15.877000;-20.497000;,
3.501400;25.690001;-9.166700;,
20.497000;15.877000;-9.166700;,
18.333000;0.000000;-20.497000;,
0.000000;0.000000;-27.500000;,
-9.166700;-15.877000;-20.497000;,
-23.999001;-9.812600;-9.166700;,
-23.999001;9.812500;-9.166700;,
20.497000;-15.877000;-9.166700;,
3.501400;-25.690001;-9.166700;,
23.999001;9.812600;9.166700;,
23.999001;-9.812600;9.166700;,
-20.497000;15.877000;9.166700;,
-3.501400;25.690001;9.166700;,
-3.501400;-25.690001;9.166700;,
-20.497000;-15.877000;9.166700;,
9.166700;15.877000;20.497000;,
9.166700;-15.877000;20.497000;,
-18.333000;0.000000;20.497000;,
0.000000;0.000000;27.500000;;
36;
3;1,2,0;,
3;2,3,0;,
3;3,4,0;,
3;6,7,5;,
3;7,0,5;,
3;0,4,5;,
3;8,9,3;,
3;9,5,3;,
3;5,4,3;,
3;10,11,2;,
3;11,8,2;,
3;8,3,2;,
3;12,13,7;,
3;13,1,7;,
3;1,0,7;,
3;14,15,9;,
3;15,6,9;,
3;6,5,9;,
3;13,16,1;,
3;16,10,1;,
3;10,2,1;,
3;17,14,11;,
3;14,9,11;,
3;9,8,11;,
3;15,18,6;,
3;18,12,6;,
3;12,7,6;,
3;19,17,16;,
3;17,11,16;,
3;11,10,16;,
3;19,16,18;,
3;16,13,18;,
3;13,12,18;,
3;19,18,17;,
3;18,15,17;,
3;15,14,17;;
MeshMaterialList {
1;
36;
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0;
SI_Material {
0.878431;0.878431;0.878431;1.000000;;
0.200000;
1.000000;1.000000;1.000000;;
0.000000;0.000000;0.000000;;
1;
0.000000;0.000000;0.000000;;
TextureFilename {
"Raxsiblob_0.bmp";
}
}
}
SI_MeshNormals {
57;
0.303532;0.525702;-0.794673;,
0.303530;0.525713;-0.794667;,
0.303534;0.525725;-0.794657;,
0.303535;0.525737;-0.794649;,
0.303543;0.525750;-0.794638;,
-0.607043;0.000000;-0.794669;,
-0.607054;0.000000;-0.794661;,
-0.607060;0.000000;-0.794656;,
-0.607076;0.000000;-0.794643;,
0.303542;-0.525719;-0.794658;,
0.303532;-0.525716;-0.794664;,
0.303535;-0.525727;-0.794655;,
0.303532;-0.525731;-0.794654;,
0.303543;-0.525750;-0.794638;,
0.982241;0.000000;-0.187625;,
0.982242;0.000000;-0.187617;,
0.982243;0.000000;-0.187613;,
0.982245;0.000000;-0.187601;,
-0.491148;0.850643;-0.187566;,
-0.491137;0.850646;-0.187581;,
-0.491133;0.850645;-0.187593;,
-0.491125;0.850647;-0.187607;,
-0.491124;0.850645;-0.187618;,
-0.491145;-0.850636;-0.187602;,
-0.491136;-0.850645;-0.187586;,
-0.491131;-0.850645;-0.187598;,
-0.491124;-0.850650;-0.187595;,
-0.491122;-0.850646;-0.187622;,
0.491138;0.850641;0.187600;,
0.491126;0.850647;0.187604;,
0.491133;0.850646;0.187590;,
0.491131;0.850648;0.187585;,
0.491148;0.850643;0.187561;,
0.491122;-0.850645;0.187621;,
0.491123;-0.850648;0.187608;,
0.491131;-0.850646;0.187592;,
0.491136;-0.850647;0.187578;,
0.491148;-0.850643;0.187561;,
-0.982242;-0.000014;0.187621;,
-0.982242;-0.000003;0.187617;,
-0.982242;-0.000002;0.187620;,
-0.982242;0.000004;0.187619;,
-0.982241;0.000000;0.187625;,
0.607076;0.000000;0.794643;,
0.607060;0.000000;0.794656;,
0.607054;0.000000;0.794661;,
0.607043;0.000000;0.794669;,
-0.303543;0.525750;0.794638;,
-0.303532;0.525731;0.794654;,
-0.303535;0.525727;0.794655;,
-0.303532;0.525716;0.794664;,
-0.303542;0.525719;0.794658;,
-0.303543;-0.525750;0.794638;,
-0.303535;-0.525737;0.794649;,
-0.303534;-0.525725;0.794657;,
-0.303530;-0.525713;0.794667;,
-0.303532;-0.525702;0.794673;;
36;
0;3;0,1,2;,
1;3;1,3,2;,
2;3;3,4,2;,
3;3;5,5,6;,
4;3;5,7,6;,
5;3;7,8,6;,
6;3;9,10,11;,
7;3;10,12,11;,
8;3;12,13,11;,
9;3;14,14,15;,
10;3;14,16,15;,
11;3;16,17,15;,
12;3;18,19,20;,
13;3;19,21,20;,
14;3;21,22,20;,
15;3;23,24,25;,
16;3;24,26,25;,
17;3;26,27,25;,
18;3;28,29,30;,
19;3;29,31,30;,
20;3;31,32,30;,
21;3;33,34,35;,
22;3;34,36,35;,
23;3;36,37,35;,
24;3;38,39,40;,
25;3;39,41,40;,
26;3;41,42,40;,
27;3;43,44,45;,
28;3;44,46,45;,
29;3;46,46,45;,
30;3;47,48,49;,
31;3;48,50,49;,
32;3;50,51,49;,
33;3;52,53,54;,
34;3;53,55,54;,
35;3;55,56,54;;
}
SI_MeshTextureCoords {
44;
0.636290;-0.500000;,
1.297900;-0.882000;,
0.143180;-0.882000;,
1.213600;-1.500000;,
0.500000;-1.500000;,
0.565830;-0.881970;,
0.565830;-0.118040;,
1.143180;-1.118030;,
0.565830;-1.118040;,
1.143180;-0.882000;,
1.143180;-2.118030;,
0.143180;-2.118030;,
1.297900;-1.118030;,
0.636290;-1.500000;,
1.213600;-0.500000;,
0.143180;-1.118030;,
0.500000;-0.500000;,
0.434200;-1.118030;,
0.434200;-1.881970;,
0.297900;-0.882000;,
0.297900;-2.118030;,
0.213600;-1.500000;,
0.702120;-0.882000;,
1.363710;-0.500000;,
1.636290;-0.500000;,
0.702120;-0.118030;,
0.702120;-1.118030;,
1.636290;-1.500000;,
0.363710;-0.500000;,
0.856820;-0.882000;,
1.434200;-1.118030;,
0.856820;-1.118030;,
0.363710;-1.500000;,
1.434200;-0.881970;,
0.786360;-0.500000;,
0.786360;-1.500000;,
0.565830;-1.881970;,
0.856820;-2.118030;,
1.434200;-1.881970;,
1.500000;-1.500000;,
1.856820;-0.882000;,
1.500000;-0.500000;,
1.856820;-1.118030;,
1.856820;-0.118030;;
36;
0;3;0,1,2;,
1;3;1,3,2;,
2;3;3,4,2;,
3;3;5,6,7;,
4;3;8,9,10;,
5;3;2,4,11;,
6;3;12,13,14;,
7;3;13,15,14;,
8;3;15,16,14;,
9;3;17,18,19;,
10;3;18,20,19;,
11;3;20,21,19;,
12;3;22,23,8;,
13;3;23,24,8;,
14;3;24,9,8;,
15;3;23,25,24;,
16;3;26,5,27;,
17;3;5,7,27;,
18;3;28,29,0;,
19;3;29,30,0;,
20;3;30,1,0;,
21;3;31,32,33;,
22;3;32,13,33;,
23;3;13,12,33;,
24;3;26,34,5;,
25;3;35,22,36;,
26;3;22,8,36;,
27;3;4,37,29;,
28;3;37,38,29;,
29;3;38,30,29;,
30;3;39,40,35;,
31;3;40,23,35;,
32;3;23,22,35;,
33;3;41,34,42;,
34;3;34,26,42;,
35;3;25,23,43;;
}
}
}
-
The next thing I would test would be to go into Anim8or's exported .xsi file and replace the SI_Texture2D block of code with the TextureFilename one. SI_Texture2D is used in the sample XSI files I found online that supposedly work in the game engine, but since the block output by the script is incomplete, that may be causing the problem.
I went ahead and adjusted it in the script attached.
By the way, there is a way to link everything together. If you can point me to a guide that shows the exact kind of linking for more complex models that use different parts of the mesh for different things, I can go ahead and implement it in the script.
-
Thanks Raxx, I'll check out the revised script and report back the results. I've attached a zip file with both an X and XSI animated model group that I know works in BZII for you to take a look at in 3DEX to view the object animation in the models; BZII requires multiple models to do animations in the game. BZII, primarily uses the skel_model and takes the animations from the other models in the group. Leroy
-
I found one issue with the texture in that BZII only supports sizes that are squared 2x2, i.e., 64x64, 128x128, etc. I'll try using only textures in this size and report back. Question, can Anim8or, adjust the texture size in the material editor? If the answer is yes then the problem may be solved. I also edited the script the a bit and will post a revised script after some testing in BZII. Leroy.
-
Sorry, Anim8or doesn't adjust the actual texture file. It resamples it internally to the nearest squared number, but it doesn't affect the file itself. Most game engines only support those kinds of texture sizes.
-
Resizing textures outside of Anim8or is easy enough to do with other utilities, so I just need to keep this in mind when making models using Anim8or. It seems to be another issue though as I tried using a 64x64 bmp texture applied to my sub divided cube. Still no luck seeing the texture in the game. It must have something to do with the numbers in the file itself. I compared my model with one created in TS using the same texture then exported as X then converted to XSI with 3DEX and they seem virtually the same with the exception of numerical values being different from one model to the other. I just don't don't get it Raxx; the A8 XSI model should work fine in BZII? I Modified the script a bit. When you have time could you take a look at the changes? Thanks, Leroy. PS: I renamed it as I have several revised script and I needed a logical way to make them uniquely unidentifiable.
Update: There is an issue with multiple objects grouped together; only one object appears in BZII and the other objects are not present in the resulting BZII created .MSH model file. It looks like part of the problem is the way Anim8or links model parts together; everything is grouped in a single stack rather then in several groups of objects. Raxx, you mentioned that there are several ways to do this in Anim8or. Could you or someone else describe how it's done in A8? Thanks, Leroy.
-
Is there a way to add a dummy frame to an A8 script and have other objects grouped to it? This is the way that BZII reads objects in grouped models. For example, a typical BZII model has a main body object and under that object are sub groups of the main body and some sub groups have objects linked under other sub groups. Here's a screen grab showing this file structure.
-
Raxx, I think the XSI exporter is more work then it's worth. I'm using the X exporter you fixed up for me and it converts the X model to XSI beautifully with 3D Exploration. Here's a screen grab from BZII showing an object complete with the texture on it. What I plan to do is create the geometry in Anim8or, group everything together and import it all into Truespace to properly link all of the parts together for BZII and export that with my TS X exporters and convert that to XSI with 3DEX. It works well as I can do animations and edit the UV map all in TS.
PS: I plan to continue monkeying around with the existing XSI exporter you created and attempt to get it working someday as I learn more about writing ASL scripts. Thank you for all off the time you spent working on the XSI script, just to let you know your work was not just a waste of time. I think the problem itself is with the old version 1 XSI format in general rather then issues with Anim8or.
-
It's possible to automate all of the linking when exporting the file, by making it organize the frames based on the names of each object. However, unless the textures start working then there's not much point in implementing it.
If you ever get the XSI export script working with textures then the linking would be the next step, so then you'd have a one-click solution for everything. Unfortunately I don't have the time to learn the ins and outs of modding this particular game so that I can do it myself, so at this point the progress of the XSI script is all on you now. Good luck!
-
Thanks Raxx. Do you think the same thing can be done on the working BZII X exporter you fixed up for me? That would work for me and the textures are working on that script. Also, can the X script be revised to export the animation keys out of Anim8or? I still fiddle with the XSI exporter script but the X script is a better option at this point. I'm sure that other A8 users could use an X script that supports proper object linking and one that can export animation. I looked at all of the existing X export scripts, but none of them support animation in their current form.
I could do most of the work and testing if you could post some code examples for me to paste in the existing BZII X exporter. Are there any existing A8 exporters that currently support exporting animation? I've started making models in Anim8or grouping objects, exporting them to X and importing them into Truespace for linking, texturing, and animation.
I plan to modify an existing script for exporting Caligari COB or SCN model files when I get a hang for modifying existing scripts. If it's okay I mostly want to ask questions as I progress in my knowledge of how to write scripts for Anim8or. The best source of basic script information seems to be the HTML scripting language link, but your feedback has been very valuable in terms of answering questions about what A8 is capable of doing. To date the X format has served me well in terms of Battlezone II model creation. I've tried making plugins for Truespace, but it's even harder then Anim8or because I need a C++ compiler and more programming knowledge then I currently have. Anim8or rocks with it's use of the ASL text based scripting. Leroy.
-
I think I figured out how to link objects together in a hierarchal form that BZII can read properly. I attached a copy of the revised XSI script. All I did was copy a section from under $childshapes to an extra entry under $shapes. Could someone take alook at the script and help me understand what I just did? Thanks, Leroy. I still need to test it out in BZII though.
-
The XSI exporter seems to work minus the missing texture issue. Here's a screen grab of my first tank model with working weapons. The tank is rather simple and a bit large, but she works good in game. Special thanks to Raxx for making it happen. Leroy.
-
Turns out the issue with the texture was related to the one I was using. I went into MS Paint and created a new 512x512 bmp and saved that and applied that to my Tank model and exported this with Raxx's XSI exporter and wala my model texture now shows on the model in BZII. The issue may have been related to BZII requiring all textures be squared in powers of two?
Now the issue seems to be how to link models parts together properly. Anim8or, currently can export a single group of objects, but BZII needs several groups, so that is the next issue to resolve. Here's a screen grab of the model with texture in the BZII map editor.
-
;) One interesting side note is that a Blender 2.62 user named Kbarter ported an old XSI exporter made for Blender 2.42. The original script exports a version 1 XSI model. My thanks to the both of you for taking the time to help out some weary BZII model makers. PS: Another user named Tsvetan also created an XSI exporter for GMAX/3DS as well. I mostly posted this additional information for wandering Battlezone 2 Combat Commander model and prop makers. Including Raxx's original XSI exporter there are now 3 different scripts depending on what software you happen to prefer. Visit my modleling forum to get a copy of any or all of them. Various XSI exporters for BZII by some very cool people. (http://gamespacelite.freeforums.org/activision-s-battlezone-2-combat-commander-f41.html) My humble thanks to each and every one of you folks.