Having problems reading .wmo consistently, not sure whats wrong please help menu

User Tag List

Results 1 to 1 of 1
  1. #1
    danielrhodea's Avatar Master Sergeant
    Reputation
    11
    Join Date
    Apr 2010
    Posts
    107
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Having problems reading .wmo consistently, not sure whats wrong please help

    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();
    }

    Having problems reading .wmo consistently, not sure whats wrong please help

Similar Threads

  1. Guild House Model. Have Model. Needs to be formated for WoW mpq. Please Help.
    By owndapwn in forum WoW ME Questions and Requests
    Replies: 9
    Last Post: 10-04-2008, 07:50 PM
  2. Scammed through Paypal but not sure what to do.
    By Weazel in forum WoW Scams Help
    Replies: 1
    Last Post: 08-01-2008, 09:32 PM
  3. Not sure what this means.. help.
    By Sphen in forum Community Chat
    Replies: 9
    Last Post: 12-27-2007, 07:15 PM
  4. Can not edit post - Mod please help
    By DJRehab in forum Community Chat
    Replies: 3
    Last Post: 08-05-2007, 04:09 PM
All times are GMT -5. The time now is 09:58 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search