Jump to content


Photo

Cracking W3D


  • Please log in to reply
32 replies to this topic

#1 Bart

Bart

  • Network Admins
  • 8,524 posts
  • Location:The Netherlands
  • Division:Revora
  • Job:Network Leader

Posted 08 May 2007 - 08:25 PM

With JEV3 and Cahik_ trying to find out how the new w3d format works, I kind of got interested in this business. I thought that maybe, if we work together, we can crack the new format, and I could create some kind of tool to do something with it (I can't do MAXScript, so no W3D Importer will be made by me).

So far I have found out this:
- the first 4 bytes contain the filetype. for a mesh, this is 0
- then comes the size of the mesh data, again 4 bytes
- after that come the chunks which make up the mesh
Repeat:
-- 4 bytes: chunk type (e.g. 31 = header, 2 = vertices, 3 = vertex normals)
-- 4 bytes: chunk size
-- <chunk size> bytes: the data in this chunk
bartvh | Join me, make your signature small!
Einstein: "We can’t solve problems by using the same kind of thinking we used when we created them."

#2 Nertea

Nertea

    ...lo sa raptor!

  • Hosted
  • 3,349 posts
  • Location:Vancouver, Canada
  • Projects:Star Villains and Space heroes, The Dwarf Holds
  •  T3A Chamber Member
  • Division:BFME/Unity

Posted 08 May 2007 - 11:31 PM

I know a mediocre amount of MaxScript, so I may be able to help in some way.

sig.png
I really don't do requests and my Arnor Soldier is not fit for BFME. Don't ask me for either.


#3 Nazgûl

Nazgûl

    S.E.E. Team Leader

  • Hosted
  • 10,582 posts
  • Location:Sweden
  • Projects:BFME2 - Nazgûl's Special Extended Edition
  •  Veteran

Posted 08 May 2007 - 11:54 PM

Great initiative guys! I wish you the best of luck! :blink:

// C}{riZpc_punch.gif
"Do not come between the Nazgûl and his mod!"
SEE_Banner_2008.jpg
SEE-Team_Leader.jpg
----------------------------------------------------------------------------------------------------
>>>>>>>>>>>>>>>>>>>>>>> I S.E.E. YOU! <<<<<<<<<<<<<<<<<<<<<<<
----------------------------------------------------------------------------------------------------


#4 GSV

GSV
  • Members
  • 12 posts

Posted 09 May 2007 - 08:30 PM

PLEASE MAKE THIS THING WORKS. KEEP WORKING PLEAASEEE!!!!!!
WE NEED YOU!!
Show EA (AND ESPECIALLY ADAM MCCARTHY, one of the EA animators, WHO PISSED ME OFF ABOUT THE BFME2 W3Ds) that you can break their ******* protocols!!!

Edited by GSV, 09 May 2007 - 08:33 PM.


#5 GothmogtheOrc

GothmogtheOrc

    Ruler of the Morgul Vale

  • Hosted
  • 2,263 posts
  • Location:USA
  • Projects:Kings of the West Mod
  •  T3A Chamber Member - Retired

Posted 09 May 2007 - 09:42 PM

GSV, posts like that really do not help. It does not encourage them to work harder or more often and the EA bashing doesn't help anyone. Not to mention the fact that the caps lock is very annoying.

We (T3A and us modders) are here to make the bfme games better and make our own mods for them, not to show up EA. :dry:

/offtopic

Back on topic, I agree with Nazgul, this is a great idea. Good luck with it :)

-GothmogtheOrc

Nine%20rings.jpg
Click on my Sig to go to my BFME Modding site where you can download my mods.
KotW%20Morgul%20In-game.jpg
Kings of the West Mod Leader
*Retired. PM me if you need to get a hold of me as I'll get an email notification and should reply within a day or so*


#6 JEV3

JEV3

    Mighty Armadillo

  • Hosted
  • 719 posts
  • Location:Pennsylvania
  • Projects:Game Enhancement Mod
  •  Coder, Skinner, Graphics, GEM Mod Leader
  • Job:T3A Chamber Member

Posted 10 May 2007 - 01:08 AM

In my look at it, it appears that the first 64 bytes seem to have patterns across all animations, BFME1 and BFME2... Also similar anims in BFME2 share patterns in the next 64 bytes... also changing the first sixty-four bytes of the BFME2 header to be like the BFME header does not make it work, and likewise it doesn't make the BFME1 anims not work...

Attached are my notes...

2play, do you mind telling us how you managed to tell what that is by looking at the raw code, or do you use something I don't? :)

I will look more into it giving both my patterns, and your stated things consideration...

EDIT: Just so you know, when I first joined, I had not dreamed that I would be examining the raw code of some of the files within a few months...

Attached Files


Edited by JEV3, 10 May 2007 - 01:09 AM.

He who bears skill but lacks effort, makes himself inferior to those who have no skill but try nonetheless.
Posted Image
Posted Image
"There is some good in this world, and its worth fighting for!"
J.M.J.

#7 {IP}Gil-Galad

{IP}Gil-Galad

    ClickerMonkey

  • Hosted
  • 1,122 posts
  • Location:Pennsylvannia, USA
  • Projects:Too many to name.
  •  T3A Team Chamber Member

Posted 10 May 2007 - 03:20 AM

Upload a w3d file if you can, Ive made programs to hack file types and observe them any way I want. I used them to crack the .csf file type and the .big filetype (even though I found out later XCC is opensource and there is source online for .big file format, but they are in c++)

#8 JEV3

JEV3

    Mighty Armadillo

  • Hosted
  • 719 posts
  • Location:Pennsylvania
  • Projects:Game Enhancement Mod
  •  Coder, Skinner, Graphics, GEM Mod Leader
  • Job:T3A Chamber Member

Posted 10 May 2007 - 01:39 PM

Aragorn's BFME1 style 'atnd' animation

Aragorn's BFME2 style 'atnd' animation

EDIT: Are you sure '31' designates a header? and when you say four bytes I am assuming you mean one hexadecimal "slot" (that's what I call them)

Edited by JEV3, 10 May 2007 - 01:44 PM.

He who bears skill but lacks effort, makes himself inferior to those who have no skill but try nonetheless.
Posted Image
Posted Image
"There is some good in this world, and its worth fighting for!"
J.M.J.

#9 Bart

Bart

  • Network Admins
  • 8,524 posts
  • Location:The Netherlands
  • Division:Revora
  • Job:Network Leader

Posted 10 May 2007 - 09:41 PM

1 "slot" = 1 byte (8 bits)

also, i didn't figure it out by reading raw code (seriously, nobody can do that), i read the source of coolfile's w3d importer

In my look at it, it appears that the first 64 bytes seem to have patterns across all animations, BFME1 and BFME2... Also similar anims in BFME2 share patterns in the next 64 bytes... also changing the first sixty-four bytes of the BFME2 header to be like the BFME header does not make it work, and likewise it doesn't make the BFME1 anims not work...

sorry, but that kind of stuff is just too obvious/random, won't ever work :xcahik_:


here's the start of a reader I made (Java)
import java.io.*;public class W3DReader {	public static void main(String[] args) throws Exception {				FileInputStream stream = new FileInputStream(args[0]);				byte[] buf4 = new byte[4];				// read filetype		long fileType = readLong(stream);		if(fileType != 0) {			out("File is not a mesh (type is " + fileType + ")");			System.exit(1);		}				// read filesize		long fileDataSize = readLong(stream) & 0x7FFFFFFF;		out("Mesh chunk size: " + fileDataSize);				while(true) {			long chunkType = readLong(stream);			out("Mesh subchunk type: " + chunkType + "(" + meshChunkType(chunkType) + ")");			if(chunkType == 0) System.exit(0);						long chunkDataSize = readLong(stream) & 0x7FFFFFFF;			out("Mesh subchunk size: " + chunkDataSize);						byte[] chunkBuf = new byte[(int)chunkDataSize];			stream.read(chunkBuf);			out(new String(chunkBuf));		}			}		/**	 * Converts a 4 byte array of unsigned bytes to an long	 * @param b an array of 4 unsigned bytes	 * @return a long representing the unsigned int	 */	public static final long unsignedIntToLong(byte[] b) 	{	    long l = 0;	    l |= b[3] & 0xFF;	    l <<= 8;	    l |= b[2] & 0xFF;	    l <<= 8;	    l |= b[1] & 0xFF;	    l <<= 8;	    l |= b[0] & 0xFF;	    return l;	}		public static final long readLong(InputStream s) throws Exception {		byte[] buf = new byte[4];		s.read(buf);		return unsignedIntToLong(buf);	}	    	/**	 * Converts a two byte array to an integer	 * @param b a byte array of length 2	 * @return an int representing the unsigned short	 */	public static final int unsignedShortToInt(byte[] b) 	{	    int i = 0;	    i |= b[1] & 0xFF;	    i <<= 8;	    i |= b[0] & 0xFF;	    return i;	}		public static void out(String msg) {		System.out.println(msg);	}		public static void out_(String msg) {		System.out.print(msg);	}		public static void reportRead(InputStream s, byte[] buf) throws Exception {		out_("  Read bytes:");		String bytesDec = "";		String bytesHex = "";		for(int i = 0; i < buf.length; i++) {			int b = s.read();			bytesDec += " " + b;			bytesHex += " " + Integer.toHexString(b).toUpperCase();			buf[i] = (byte) b;		}		out(bytesDec + "  - " + bytesHex);	}		public static String meshChunkType(long type) {		if(type == 31) return "W3D_CHUNK_MESH_HEADER3";		if(type == 2) return "W3D_CHUNK_VERTICES";		if(type == 3) return "W3D_CHUNK_VERTEX_NORMALS";		else return "?";	}		public static String bytesToString(byte[] in) {		StringBuffer result = new StringBuffer();		for(int i = 0; i < in.length; i++) {			result.append(" " + Integer.toHexString(in[i])); 		}		return result.toString();	}}

bartvh | Join me, make your signature small!
Einstein: "We can’t solve problems by using the same kind of thinking we used when we created them."

#10 {IP}Gil-Galad

{IP}Gil-Galad

    ClickerMonkey

  • Hosted
  • 1,122 posts
  • Location:Pennsylvannia, USA
  • Projects:Too many to name.
  •  T3A Team Chamber Member

Posted 10 May 2007 - 09:47 PM

Yeah I read the source for the W3D Importer and it's it not that terribly hard to interpret, its just extremely long. I tried writing up a program but some of the conversions I tried from maxscript to vb.net didnt work the way they were supposed to.

#11 Bart

Bart

  • Network Admins
  • 8,524 posts
  • Location:The Netherlands
  • Division:Revora
  • Job:Network Leader

Posted 10 May 2007 - 09:51 PM

note: the numbers are stored in the files as Little-Endian, which means that the number 0x1F5A8802 is stored as "02 88 5A 1F". This was a problem at first because Java uses Big-Endian
bartvh | Join me, make your signature small!
Einstein: "We can’t solve problems by using the same kind of thinking we used when we created them."

#12 {IP}Gil-Galad

{IP}Gil-Galad

    ClickerMonkey

  • Hosted
  • 1,122 posts
  • Location:Pennsylvannia, USA
  • Projects:Too many to name.
  •  T3A Team Chamber Member

Posted 10 May 2007 - 10:46 PM

Yeah a couple of EA's format are Little-Endian and some are Big-Endian, I don't know why they switched around, maybe to throw us off

#13 Bart

Bart

  • Network Admins
  • 8,524 posts
  • Location:The Netherlands
  • Division:Revora
  • Job:Network Leader

Posted 11 May 2007 - 08:29 AM

they were probably made by different programmers
bartvh | Join me, make your signature small!
Einstein: "We can’t solve problems by using the same kind of thinking we used when we created them."

#14 Guest_booto_*

Guest_booto_*
  • Guests

Posted 01 June 2007 - 09:04 AM

Saw this thread in passing, this thread might be useful for you... I would think there would be similarities between the w3d mesg format between c&c3 and bfme2.

#15 Guest_Guest_*

Guest_Guest_*
  • Guests

Posted 01 June 2007 - 09:05 AM

mesh, not mesg

#16 逊Arathorn妻

逊Arathorn妻
  • Members
  • 44 posts
  • Projects:W3D-Importer

Posted 07 December 2011 - 08:58 PM

Guys I did it (See my W3D Importer for Blender)
Dome Basic Informations:
Splittet in Chunks:
-Hierarchy
-Mesh
-Animation
-Compressed Animation
-AABox

#17 Ridder Geel

Ridder Geel

    Master Yelloh

  • T3A Staff
  • 10,852 posts
  • Location:The Netherlands (AKA: Holland)
  • Projects:RC Mod + SEE + RTS Engine
  •  The Dangerous T3A Team Chamber Member
  • Division:BFME
  • Job:T3A Staff

Posted 08 December 2011 - 12:07 AM

Does your importer thing import the BFME 2 animations?
Ridder Geel

#18 逊Arathorn妻

逊Arathorn妻
  • Members
  • 44 posts
  • Projects:W3D-Importer

Posted 08 December 2011 - 04:49 PM

Soon it will, but first off i want to import Meshes without any problems. But i already know how to import all the stuff. Coolfile's importer gave me a lot of informations about W3D-files. There are chunks and in these chunks are chunks again and it goes on like this till it is all imported :-)

#19 ReallyFat

ReallyFat

    title available

  • Project Team
  • 352 posts

Posted 09 December 2011 - 10:06 AM

still cant find something thatll let me export w3d for 3ds max

signature.png


#20 Ridder Geel

Ridder Geel

    Master Yelloh

  • T3A Staff
  • 10,852 posts
  • Location:The Netherlands (AKA: Holland)
  • Projects:RC Mod + SEE + RTS Engine
  •  The Dangerous T3A Team Chamber Member
  • Division:BFME
  • Job:T3A Staff

Posted 09 December 2011 - 01:46 PM

EA's SDK has the w3d exporter script ._.
Ridder Geel




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users