CariElf CariElf

Ship encoder available

Ship encoder available

Here's a link to a tool to help you make your own ship models. There's docs and sample files included in the zip file. You will need a paint program like Photoshop that can save files as windows bitmaps and as 32 bit targa files. This program is rather rough, but it gets the job done. If you have problems, please post them on this forum instead of the main one.

http://storage.stardock.com/files/gc_ship_encoder_040803.zip
12,407 views 65 replies | Pinned
Reply #26 Top
Well, I guess since there have been no updates, no feedback and no real ship mods released, I guess people aren't using the tool very much :( Hopefully, I'm wrong and new mods are about to pop up all over the place.

Well, I've been experimenting a bit and have had a lot of crashing problems. I've finally isolated it the problem. Either the game or, more likely, mutil has a problem when generating mdl files whose name ends in a number. So, dnot.mdl is OK, but dnot13.mdl is not. The debug file of the game says it cannot find the minor model (35dnot13) when the mdl ends in a number. aargh! This was extremely annoying to track down. The actual file name doesn't seem to matter as I was able to change it afterwards without any problems.

In a related question, am I right when saying that the model name provided to the game is based on the string entered in the library name field, not the string in the individual fields, or the filename for that matter. So, if the output string is dnot.dml while all the race model strings are 0dnot13, 1dnot13, etc., the game will see a dnot model for all the races, not a dnot13. At least that's what I think was happening, when trying to figure out those errors. So, is that right?

And, if possible, please add cut & paste capability. If you want to replace all the ships, you'd need to enter 184 nearly identical strings. I don't mind bare bones, but this is more like jumping through unnecessary and very high hoops. Or perhaps just do a command line version and users can make our own batch files.
Reply #27 Top
I don't think what I said above about the name ending with numbers is accurate. The documentation seemed to suggest that the mdl name does not have to be the same as the source tga files. But I think now that they do have to be identical. All the ones that weren't identical crashed for me. That's probably the real problem I was having.

But I'm still getting some very strange results. I can take the exact same files, rename them, and then regenerate an mdl that is much larger than the first. Both seem to work. Cari, can you tell me more about any naming constraints and why I may be getting these strange results?
Reply #28 Top
I have a problem/question.. :)
just started to try this program...
it's very useful, but how do i change the .mdl files to .ship-files..
And.. What's the use for .bak-file

--thanks..
Reply #29 Top
.ship files are text files that define the characteristics of a ship, like attack, hit points, name, description, etc, while .mdl files contain the graphics. So, you don't convert between them. You need them both.

.bak files are just backup files
Reply #32 Top
Hello, I just got GalCiv and I already want to write some tools (it's my hobby hehe). I know that you dont have the .mdl format written down but can you give us some hints? I'm really slow/not very good at reverse engineering a file format, I've reverse engineered 6 of them max in my life and it's often been a frustrating experience :p

If you can help, I was wondering how are they stored in the mdl? From what I gather, the sprites are stored in the file but how are they stored? Is it a raw bitmap, is it a paletted bitmap? Is the palette in the .mdl file? Is there some form of compression?

As for rotating the model, I guess it depends on your graphic know how but for myself, I'd just slap the texture onto a quad in OpenGL an rotate it ^_^. Oh better, I'd use DevIL, i'm sure there's a rotation function in there somewhere and it doesnt require any 3d knowledge.

Visual Designs : http://www.tauniverse.com/visual-ta/HTML/index.html
Reply #33 Top
MMmm are you using Sybase to save those files? Just wondering because there's a couple of references to "LIBBLK" in the file and it looks like it's a dll related to sybase (googled for it).
Reply #34 Top
You know being slow at reverse engineering is pretty fast from the perspective of people who don't do it at all.

If you wanted to reverse engineer a format, I think the mtd files would be more useful, since there already a serviceable utility for mdl files.

In short, I think mtd files are a more general format than the mdl files. Each mtd file, or library as they call it, can contain any number of four types of component "books": palettes, sprites, incl (?) and Tile (?). I've seen this much just in passing, but if you do a search on "pear tree library" you can find the home page of the guy who originally wrote the stuff.
Reply #36 Top
mmm are you sure it's pear tree library? Its actualy a physical place so google isnt very helpful but I've gone through a lot of them and they dont seem to be computer related.

On another note, you're right, the mtd and mdl file format do seem related from a quick glance at the headers in a hex editor.

About Sybase : well I just said that because in the mdl file there's a reference to libblk and it's a sybase dll apparently but after having checked out more files it doesnt seem to be consistent so I imagine it's something else.
[Message Edited]
Reply #37 Top

The mtd and mdl formats are very similar; they both contain sprites.  The mdls contain animated sprites and the mtds contain non animated sprites. There are also the .tiles files which contain tiles and tile sprites.  Really, though, we could call them anything we want; these are just convenient.  We call these file libraries, and the libraries contain books. 

Reply #38 Top
mmm are you sure it's pear tree library? Its actualy a physical place so google isnt very helpful but I've gone through a lot of them and they dont seem to be computer related.
End of quote


Oops, I don't know why I added the whole tree business. It was just pear library, which, btw, he says is the basis for Galactic Civilizations 3! Man, he really must be in the know ;) Here's the page I saw: http://www.ionet.net/~mduffy/Resume.html

The mtd and mdl formats are very similar; they both contain sprites. The mdls contain animated sprites and the mtds contain non animated sprites. There are also the .tiles files which contain tiles and tile sprites. Really, though, we could call them anything we want; these are just convenient. We call these file libraries, and the libraries contain books.
End of quote


There you have it, straight from the source's mouth. It sounds like you may be one pretty please away from getting some byte offsets.
Reply #39 Top
hehehe. :) I have to figure out the byte offsets myself.  I was going to post the formats for the library and sprite headers, but I wanted to make sure that I had the format correct before posting it.
Reply #40 Top
Well, I think that by Galactic Civilizations 3 he means this current Galactic Civilizations.  There were 2 versions oif GC for OS/2, the IBM operating system.
Reply #41 Top
Thanks CariElf, I'll look into it when I get home tonight.

Mmmm I looked at the website and I dont think there's anyway I can download it or check the file format. Maybe email him and ask for it but since he licenced it to stardock it might not be legal. I think?
Reply #42 Top
Well here's what I found out so far, I'm attacking the pixel data right now : http://www.tauniverse.com/visual-ta/Downloads/GalCiv/gc-mdl-fmt.txt


-----------------------------
Visual Designs : http://www.tauniverse.com/visual-ta/
[Message Edited]
Reply #44 Top
Tell me about it :P

I'm doing some progress with the sprite book, I've identified some of it's structure but I havent pinpointed the pixel data yet ;(. I had hoped it was only a simple 64x2046 raw bitmap sprite for a ship (wishful thinking) but it's more complicated than that. Each frame is a different image and each image has a x, y offset along with a size. Add to that, that some form of SPR1 use compression and I haven't even found what is the compression flag.

Anyway, back to work!
Reply #45 Top
I've updated the file a bit, still have to understand quite a bit of stuff. I'm going to bed for now. I'm too tired to find out more :P
[Message Edited]
Reply #46 Top
If you wanted to, you could wait until Cari feels comfortable posting those header files and probably avoid some of the work you're doing. Or better yet, if she could get the go ahead to post a few select functions from mutil, you'd be set ;)
Reply #48 Top
Alright, I've updated it again. I only have to decode the pixel data now. I think I've found out most of the other useful stuff. Sure there's still some unknown but I dont think it should prevent me from reading SPR1 books.

File Format : http://www.tauniverse.com/visual-ta/Downloads/GalCiv/gc-mdl-fmt.txt

Also, it might be interesting to note that the mdl, mtd, tiles etc all have the same file format, so no work lost there ^_^.
[Message Edited]
Reply #49 Top
I just checked out your results document. Impressive sleuthing, Dark Rain! :)

In terms of decoding the pixel data, I don't know if this matters, but I thought I'd mention it. All the graphics I've encoded into the pear format have included an alpha channel. Although I don't know how this is typically encoded, I couldn't see how it would fit in with the specs you have so far.

btw, I don't think the alpha data is translated into a transparency value or anything like that, since my first iteration of ships seemed to have partial transparency effect. I was trying to make a glowing colored halo to indicate what kind of aliens they're from, but, when you manually scrolled around the map, if the ship went over some of the colored parts of the nebula background, the halo would partially change color. This of course defeating its purpose and I had to redo the ships. Anyway, what I was trying to say is that it appears to retain the real alpha channel data. I'm not sure if it's relevent, but just in case...

btw, great (and fast) work so far :)
Reply #50 Top
Mmm I'm pretty sure the alpha channel is somewhere in what I assume is the pixel data area, mostly because it's bigger than it should be. According to the docs, the alpha channel when loaded from an indexed bmp is based on level of grays, so it's a classic 255 levels alpha channel.

I've read that the bitmaps are compressed all the time, I really, really hope it's some kind of RLE because if it's a kind of zip derivative or what not I'm really screwed :P. I'll poke around a bit tonight before going to bed but I dont expect much because I'm pretty tired ^_^.