Thanks for all your answers.
[quote]If you want to print the data in hex format, use Integer.toHexString somewhat like this:
Code:
byte[] bytes = …
for (byte b : bytes) {
String hex = Integer.toHexString(b & 0xFF).toUpperCase();
while (hex.length() < 2) {
hex = “0” + hex;
}
System.out.println(hex);
}
[/quote]
Why the while (hex.lenght() < 2)) ? It makes the while infinite and always return 00.
If i remove this “while” it seems to work, i get on each line 2 caracteres (hex). But the while is very long, i had to kill it…
[quote]Hex numbers are numbers written in base 16 number system. We usually use the decimal system wich uses the base 10 number system. Hex has 16 symbols representing the 16 values. The 10 first is the same as the decimal system with 0-9. The last uses the characters A-F to sombolise the values 10-15. “C” written has hex means 12 written as decimal. When you’ve got more than one symbol you’ve got to multiply with 16 instead of 10. So “C4” means (12*16)+4=196. A hex symbol represents a 4 bit number. That is why they are usally written in pairs to represent bytes. “0xC4” represents a single byte, “0xC400” represents 2 bytes etc. Look through your books again to read about hex, oct and binary representation of data. It might be in a appendix named “number formats”.
So when the 3ds docs says “0x4000” it means you need to read 2 bytes, one with the value “0x40” and one "0x00.
[/quote]
Thanks for your little lesson, now it’s clearly in my head. But my two books doesn’t have any explication on number formats, binary, hexadecimal, decimal…and yet they were quite expensive…
[quote]The source code on this page might help you out:
http://www.multi.fi/~mbc/v3ds/Decode3dsApplet.html
If you’re at the stage where binary files are an unknown concept you might want to start somewhere a little easier going. Writing a 3DS loader isn’t the easiest place to start.
Kev
[/quote]
Thanks, but i already know this loader. And someone on this forum are the new maintainer of the loader. But wehre are the sources ? I can’t found them. Not the sources of the applet, but the sources of the 3ds loader.
[quote]In your code you could use the l_bytes array directly, or wrap it in a DataInputStream. In any case you need to know what endian is used by the file format. Be also aware that java bates are signed wich you don’t wan’t. So to check for “0x4000” you could write:
Code:
if ( (l_bytes[0] & 0xff) == 0x00 && (l_bytes[1] & 0xff) == 0x40) {
// marker at index 0 eqals 0x4000
}
[/quote]
What’s the gain if i wrap it in a DataInputStream ? And 3ds files use little-endian. Must i do something particular ?
And great thank tom ! Thanks to your help, i’ve succeeded to find the Main Chunk of my 3ds files :).
Thank to all of you, now i can start my 3ds loader 