Author |
Message |
Helicon Server Help Squatter
Joined: Dec 03 2002 Posts: 771 Location: GNU Doldrums Offline
|
Posted: Tue Nov 11, 2003 4:59 pm Post subject: Map editor snags and snares |
|
|
|
|
(I am going to use this thread to encapsulate all of my basic (stupid) and not so stupid questions)
Here we go:
1: is there a constant string of data in a map file which will always signify the end of the bitmap (if it has one) which i could use to split a .lvl?
2: Are there any prewritten file parsers (w/ src) for maps available somewhere?
i will probably have some gfx/buffering/performace issues soon... _________________ Signatures just seem so quaint.
|
|
Back to top |
|
|
Mine GO BOOM Hunch Hunch What What
Age:40 Gender: Joined: Aug 01 2002 Posts: 3614 Location: Las Vegas Offline
|
Posted: Tue Nov 11, 2003 5:17 pm Post subject: |
|
|
|
|
1. Use the BITMAPFILEHEADER structure for loading the size of the bmp. I believe there is even a quick hack that I wrote up on skipping past the BMP section somewhere in the Misc User Apps, just do a search for it. But if you are making a map editor, I'd recommend actually learning to read the BMP section correctly.
The bfSize is the full size of the whole BMP section. So just seek that many bits from the beginning of the file, and thats where the LVL data will be placed.
If the first 2 bytes are not BM, then there is no tileset for the map, thus you use the default one, which should be supplied by your map editor.
typedef struct tagBITMAPFILEHEADER {
WORD bfType;
DWORD bfSize;
WORD bfReserved1;
WORD bfReserved2;
DWORD bfOffBits;
} BITMAPFILEHEADER, *PBITMAPFILEHEADER;
Members
bfType
Specifies the file type, must be BM.
bfSize
Specifies the size, in bytes, of the bitmap file.
bfReserved1
Reserved; must be zero.
bfReserved2
Reserved; must be zero.
bfOffBits
Specifies the offset, in bytes, from the beginning of the BITMAPFILEHEADER structure to the bitmap bits. |
2. I'd recommend you creating your own parser. Most of them out there, such as what I wrote up for someone here before, just skip pasted all the good stuff, and may assume that the tile information is correct, and comes in chunks of 4 bytes.
Plus, if you create your own parser, you could support png tilesets and such. If a good map editor came out that is can support different image types natively, it would be very simple for Priitk to add it into continuum. Thus it can decrease the filesizes by a great deal. Could maybe store the tile information compressed.
|
|
Back to top |
|
|
Guest
Offline
|
Posted: Tue Nov 11, 2003 5:49 pm Post subject: |
|
|
|
|
I think they may be something on SSDL (sslvl?) written in VB with source that can read map files and give stats. Although as MGB says it assumes data comes in 4 byte chunks (I think Asss has this problem too), so it can only read the map file up to a certain point (on my machine anyway).
I also think maps are sent zlib compressed, but saving space on the end users machine is always nice.
|
|
Back to top |
|
|
SuSE Me measures good
Joined: Dec 02 2002 Posts: 2307 Offline
|
Posted: Tue Nov 11, 2003 5:58 pm Post subject: |
|
|
|
|
I wouldn't bother with anything at ssdownloads (for taking coding notes )
|
|
Back to top |
|
|
Mine GO BOOM Hunch Hunch What What
Age:40 Gender: Joined: Aug 01 2002 Posts: 3614 Location: Las Vegas Offline
|
Posted: Tue Nov 11, 2003 10:26 pm Post subject: |
|
|
|
|
Anonymous wrote: | it assumes data comes in 4 byte chunks (I think Asss has this problem too) |
For ASSS, it will read it all, but does not error checking if the last chunk is < 4 bytes, it just ignores it. A good map editor should warn the user that the map maybe invalid, and attempt to do error checking on the data, to see where it might have fucked up.
|
|
Back to top |
|
|
SuSE Me measures good
Joined: Dec 02 2002 Posts: 2307 Offline
|
Posted: Tue Nov 11, 2003 10:31 pm Post subject: |
|
|
|
|
ie - it should work
|
|
Back to top |
|
|
Helicon Server Help Squatter
Joined: Dec 03 2002 Posts: 771 Location: GNU Doldrums Offline
|
Posted: Wed Nov 12, 2003 4:04 pm Post subject: |
|
|
|
|
will see what i can do... java has not historically been my choice for handling bit-by-bit filetypes
|
|
Back to top |
|
|
Dustpuppy Server Help Squatter
Age:39 Gender: Joined: Jan 23 2003 Posts: 215 Location: England Offline
|
Posted: Thu Nov 13, 2003 11:03 am Post subject: |
|
|
|
|
MERV loads maps, you could take a look at the source. It's in map.* IIRC
|
|
Back to top |
|
|
Helicon Server Help Squatter
Joined: Dec 03 2002 Posts: 771 Location: GNU Doldrums Offline
|
Posted: Thu Nov 13, 2003 4:22 pm Post subject: |
|
|
|
|
i've been hacking, and so far my only concerns have been dealing with the annoyance of not knowing whether the first bits are bmp are not... java is not very friendly below the Byte size... it will end up being no problem.. though i will undoubtedly have to get someone to look over it.
|
|
Back to top |
|
|
Guest
Offline
|
Posted: Thu Nov 13, 2003 5:00 pm Post subject: |
|
|
|
|
Whether the first bits are bmp or not?
Can't you just do a string check for the 'BM' header?
|
|
Back to top |
|
|
Helicon Server Help Squatter
Joined: Dec 03 2002 Posts: 771 Location: GNU Doldrums Offline
|
Posted: Thu Nov 13, 2003 5:46 pm Post subject: |
|
|
|
|
i can identify, but if i find its not a bmp, i have to concat that data to map data. It's not a serious issue, i was just momentarily frustrated by it
|
|
Back to top |
|
|
Helicon Server Help Squatter
Joined: Dec 03 2002 Posts: 771 Location: GNU Doldrums Offline
|
Posted: Thu Nov 13, 2003 10:03 pm Post subject: |
|
|
|
|
Next Question:
java is a serious pain here... though JNI is going to be a bad idea if this can be done in java:
i have never had to read a 12-bit int.
Java supports bools and bytes, nothing in between
does anyone know how to do the following in java:
split 3 bytes into 2 consecutive 12-bit ints
make an int from 12 booleans
this should get me working(buggy) lvl loader, assuming i know what im doing (i don't)
|
|
Back to top |
|
|
Dr Brain Flip-flopping like a wind surfer
Age:38 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: Thu Nov 13, 2003 10:16 pm Post subject: |
|
|
|
|
int int1 = byte1 << 4 + byte2 >> 4;
int int2 = (byte2 << 8 + byte3) & (0xFFF);
Note: if the compiler doesnt like it, cast the bytes to ints.
int from tweleve bools is harder. You could simply do 12 consecutive OR masks, but thats a real real pain. If you can byte shift bools into ints, it makes it easier. _________________ Hyperspace Owner
Smong> so long as 99% deaths feel lame it will always be hyperspace to me
|
|
Back to top |
|
|
Helicon Server Help Squatter
Joined: Dec 03 2002 Posts: 771 Location: GNU Doldrums Offline
|
Posted: Thu Nov 13, 2003 10:33 pm Post subject: |
|
|
|
|
we non-programmers suck with anything smaller than classes
thanks brain (*poit*)
|
|
Back to top |
|
|
Dr Brain Flip-flopping like a wind surfer
Age:38 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: Thu Nov 13, 2003 11:06 pm Post subject: |
|
|
|
|
Check the API for a bit storage class. It may be able to export to an int.
|
|
Back to top |
|
|
Helicon Server Help Squatter
Joined: Dec 03 2002 Posts: 771 Location: GNU Doldrums Offline
|
Posted: Thu Nov 13, 2003 11:08 pm Post subject: |
|
|
|
|
did so, maybe im looking in the wrong places... but i dont think so
|
|
Back to top |
|
|
Dr Brain Flip-flopping like a wind surfer
Age:38 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: Fri Nov 14, 2003 9:31 am Post subject: |
|
|
|
|
Well, I found a bitset, but that doesnt give you back an integer.
It may be easier to store everything in the integer, and when you need to get the boolean, simply:
boolean myBool = (myBitInt & (1 << x) == (1 << x))
where x is the place you need, starting at 0.
|
|
Back to top |
|
|
Cyan~Fire I'll count you!
Age:36 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Fri Nov 14, 2003 4:12 pm Post subject: |
|
|
|
|
Sorry, I have barely any Java experience, but there isn't a C++ union type thing in Java? It would be easy to form an integer from bits with a union. _________________ This help is informational only. No representation is made or warranty given as to its content. User assumes all risk of use. Cyan~Fire assumes no responsibility for any loss or delay resulting from such use.
Wise men STILL seek Him.
|
|
Back to top |
|
|
Helicon Server Help Squatter
Joined: Dec 03 2002 Posts: 771 Location: GNU Doldrums Offline
|
Posted: Fri Nov 14, 2003 5:07 pm Post subject: |
|
|
|
|
i dont believe there are native unions. what i want is a struct, which isn't supported
thanks brain,but once i get to ints i'm happy. I can just reverse the operation to write 12 - bit ints to files
|
|
Back to top |
|
|
Helicon Server Help Squatter
Joined: Dec 03 2002 Posts: 771 Location: GNU Doldrums Offline
|
Posted: Tue Nov 18, 2003 8:49 pm Post subject: |
|
|
|
|
i've hit a stumbling block on the lvl loader... is there a good (reliable) java bitmap class around that supports conversion to Image object s, clipping subimages, and reading files like lvls without splitting off the ends (just read length in the file)???
|
|
Back to top |
|
|
Dr Brain Flip-flopping like a wind surfer
Age:38 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: Tue Nov 18, 2003 10:57 pm Post subject: |
|
|
|
|
So you need a way to view the tileset as an Image? Is that what you need?
Take a look at the javax.imageio package. It can read a FileStream into a BufferedImage, which you can take and clip and stuff.
Reading the LVL data from the Image is probably impossible. What you will probably have to do is to read the file in twice (or put it into a buffer). Read it once for the tileset using imageio, and once again for the lvl data.
|
|
Back to top |
|
|
Helicon Server Help Squatter
Joined: Dec 03 2002 Posts: 771 Location: GNU Doldrums Offline
|
Posted: Wed Nov 19, 2003 4:47 pm Post subject: |
|
|
|
|
could someone give me a rundown on how to skip over the bitmap with a stream?
also, i'm needing to convert to unsigned int for the file size. i don't want to mess this up. any solutions?
|
|
Back to top |
|
|
Dr Brain Flip-flopping like a wind surfer
Age:38 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: Wed Nov 19, 2003 8:51 pm Post subject: |
|
|
|
|
I don't know specifics of the bitmap format, but all you need to do is read the bitmap stuff until its end, then pass your BufferedReader into your LVL parser.
Unisgned int? How do you mean convert? From what, into what?
|
|
Back to top |
|
|
Helicon Server Help Squatter
Joined: Dec 03 2002 Posts: 771 Location: GNU Doldrums Offline
|
Posted: Wed Nov 19, 2003 10:56 pm Post subject: |
|
|
|
|
here comes a mess...
this has (somewhere) gone very wrong
please take a look.
obviously some of these classes are not completed. I attempted to finish the read/input ones, and wrote a test app for it. That's when things get ugly
any help appreciated.
Thanks
here it is... straight from my eclipse workspace directory
Map.zip - 12.6 KB
File downloaded or viewed 64 time(s)
|
|
Back to top |
|
|
Dr Brain Flip-flopping like a wind surfer
Age:38 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: Thu Nov 20, 2003 9:19 am Post subject: |
|
|
|
|
Ok, looking through your code, the easiest way to do what you want is to pass the two reading functions the same FileStream. That way, when one is done reading the bitmap, the stream is all ready to read in the LVL. You should be careful of missing a single read at the transition, I'm not sure if that will happen, but you should be careful.
I'm not familiar with the BMP format, but a simple google search should yeild BMP reading code (its not included in imageio :<). The only thing you need to watch for is that the code doesn't read the entire stream, but rather stops when its done with the bitmap section.
|
|
Back to top |
|
|
|