Hi,
As some of you may know I'm doing a wee bit of java programming with wow file types, in my adventures into the land of the .wmo file I have hit a wall, hard!!!
so far I have tested my java wmo class on the following adt files
WMO wmo = new WMO("C:\\wow\\World\\wmo\\Dungeon\\AZ_Subway\\Subway.wmo"); // 19 group files
wmo = new WMO("C:\\wow\\World\\wmo\\Azeroth\\Buildings\\Castle\\Castle01.wmo"); //2 group files
wmo = new WMO("C:\\wow\\World\\wmo\\Azeroth\\Buildings\\Castle\\Castle02.wmo"); //1 group file
wmo = new WMO("C:\\wow\\World\\wmo\\Azeroth\\Buildings\\Castle\\Castle03.wmo"); //1 group file
wmo = new WMO("C:\\wow\\World\\wmo\\Azeroth\\Buildings\\Stormwind\\Stormwind.wmo"); // 285 group files
stormwind is not reporting the correct number of group files, textures or anything, any ideas as to what is wrong, the code to my class is below
Code:
import java.io.*;
import java.util.Vector;
import java.lang.String;
public class WMO {
//public WMOGroup *groups;
public int nTextures, nGroups, nP, nLights, nModels, nDoodads, nDoodadSets, nX;
//public WMOMaterial *mat;
//public Vec3D v1,v2;
public int LiquidType;
public boolean ok;
public Vector<String> textures;
public Vector<String> models;
//public std::vector<ModelInstance> modelis;
//public std::vector<WMOLight> lights;
//public std::vector<WMOPV> pvs;
//public std::vector<WMOPR> prs;
//public std::vector<WMOFog> fogs;
//public std::vector<WMODoodadSet> doodadsets;
//public Model *skybox;
public int sbid;
public WMO(String _filename)
{
File fil = new File(_filename);
if(fil.canRead())
System.out.println("can open"+_filename);
else
System.out.println("cannot open"+_filename);
int nTextures = 0;
try
{
FileReader f = new FileReader(_filename);
char[] fourcc = new char[4];
char[] size = new char[4];
float[] ff = new float[3];
char texbuf = 0;
boolean eof = false;
while (!eof) {
int tmp = f.read(fourcc);
if(tmp == -1)
eof = true;
fourcc = flip(fourcc);
//System.out.print("header: "+String.copyValueOf(fourcc)+" ,");
if((fourcc[0] == 'M') && (fourcc[1] == 'O') && (fourcc[2] == 'H') && (fourcc[3] == 'D'))
{
System.out.println("header: "+String.copyValueOf(fourcc));
f.read();f.read();//need to read this dummy 4bytes
f.read(fourcc);
nTextures = ((fourcc[0]) | (fourcc[1]) | (fourcc[2]) | (fourcc[3]));
f.read(fourcc);
int nGroups = ((fourcc[0]) | (fourcc[1]) | (fourcc[2]) | (fourcc[3]));
f.read(fourcc);
int nPortals = ((fourcc[0]) | (fourcc[1]) | (fourcc[2]) | (fourcc[3]));
f.read(fourcc);
int nLights = ((fourcc[0]) | (fourcc[1]) | (fourcc[2]) | (fourcc[3]));
f.read(fourcc);
int nModels = ((fourcc[0]) | (fourcc[1]) | (fourcc[2]) | (fourcc[3]));
f.read(fourcc);
int nDoodads = ((fourcc[0]) | (fourcc[1]) | (fourcc[2]) | (fourcc[3]));
f.read(fourcc);
int nDoodadSets = ((fourcc[0]) | (fourcc[1]) | (fourcc[2]) | (fourcc[3]));
f.read(fourcc);
int ambColor = ((fourcc[0]) | (fourcc[1]) | (fourcc[2]) | (fourcc[3]));
f.read(fourcc);
int ID = ((fourcc[0]) | (fourcc[1]) | (fourcc[2]) | (fourcc[3]));
f.read(fourcc); // Bounding box corner 1 x
float bb1x = ((fourcc[0]) | (fourcc[1]) | (fourcc[2]) | (fourcc[3]));
f.read(fourcc); // Bounding box corner 1 y
float bb1y = ((fourcc[0]) | (fourcc[1]) | (fourcc[2]) | (fourcc[3]));
f.read(fourcc); // Bounding box corner 1 z
float bb1z = ((fourcc[0]) | (fourcc[1]) | (fourcc[2]) | (fourcc[3]));
f.read(fourcc); // Bounding box corner 2 x
float bb2x = ((fourcc[0]) | (fourcc[1]) | (fourcc[2]) | (fourcc[3]));
f.read(fourcc); // Bounding box corner 2 y
float bb2y = ((fourcc[0]) | (fourcc[1]) | (fourcc[2]) | (fourcc[3]));
f.read(fourcc); // Bounding box corner 2 z
float bb2z = ((fourcc[0]) | (fourcc[1]) | (fourcc[2]) | (fourcc[3]));
f.read(fourcc); // LiquidType related, see below in the MLIQ chunk.
int liquidtype = ((fourcc[0]) | (fourcc[1]) | (fourcc[2]) | (fourcc[3]));
System.out.println("textures: "+nTextures+" Groups: "+nGroups+" Portals: "+nPortals+" Lights: "+nLights+" Models: "+nModels+" Doodads: "+nDoodads+" Sets: "+nDoodadSets+" Ambient Color: "+ambColor+" ID: "+ID);
System.out.println("bb1x: "+bb1x+" bb1y: "+bb1y+" bb1z: "+bb1z+" bb2x: "+bb1x+" bb2y: "+bb1y+" bb2z: "+bb1z+" Liquid Type: "+liquidtype);
}
if((fourcc[0] == 'M') && (fourcc[1] == 'O') && (fourcc[2] == 'T') && (fourcc[3] == 'X'))
{
System.out.println("header: "+String.copyValueOf(fourcc));
String[] strings = new String[nTextures];
int curString = 0;
f.read(fourcc);
while(curString < nTextures) // reads all textures into an array
{
f.read(fourcc);
if(String.copyValueOf(fourcc) == ".BLP")
{
strings[curString] += String.copyValueOf(fourcc);
curString++;
}
else
{
if(strings[curString] == null)
strings[curString] = "";
if( (fourcc[0] != 0) )
{
if( (fourcc[1] != 0) )
{
if( (fourcc[2] != 0) )
{
if( (fourcc[3] != 0) )
{
strings[curString] += String.copyValueOf(fourcc);
}
else
{
char[] tmp_ca = new char[3];
tmp_ca[0] = fourcc[0];
tmp_ca[1] = fourcc[1];
tmp_ca[2] = fourcc[2];
strings[curString] += String.copyValueOf(tmp_ca);
curString++;
}
}
else
{
char[] tmp_ca = new char[2];
tmp_ca[0] = fourcc[0];
tmp_ca[1] = fourcc[1];
strings[curString] += String.copyValueOf(tmp_ca);
curString++;
}
}
else
{
char[] tmp_ca = new char[1];
tmp_ca[0] = fourcc[0];
strings[curString] += String.copyValueOf(tmp_ca);
curString++;
}
}
else
{
if(strings[curString].length() > 5)
curString++;
}
}
}
System.out.println("Done reading "+nTextures+" textures!");
for(int i=0;i<nTextures;i++)
{
System.out.println(strings[i]);
}
}
//System.out.println((fourcc[3]) | (fourcc[2]) | (fourcc[1]) | (fourcc[0]));
//f.read(size);
//System.out.println("size: "+size.toString());
//System.out.println((size[0]) | (size[1]) | (size[2]) | (size[3]));
}
}
catch(IOException ioexc)
{
}
}
private char[] flip(char[] target)
{
char[] tmp = new char[target.length];
for(int i=0;i<target.length;i++)
{
tmp[(tmp.length-i)-1] = target[i];
}
return tmp;
}
//public void draw(int doodadset, const Vec3D& ofs, const float rot);
//public void drawSkybox();
}