DFF mesh format loader

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
loki1985
Posts: 214
Joined: Thu Mar 31, 2005 2:36 pm

DFF mesh format loader

Post by loki1985 »

hi folks.

as already promised in another thread i release my DFF format loader for Irrlicht.

- currently developed with/for Irrlicht 1.4.2
- loading of GTA3 DFFs works pretty well in most cases (minor glitches could occur i guess, after all the format is not well documented)
- no animations are supported at the moment
- for some more details take a look at the header file

// EDIT:
- - GTAVC and GTASA meshes work OK now
- - tested ManHunt models work OK too.

i am planning to find and fix the GTAVC problem and then hopefully fix support for GTASA files. but since i am unsure about when and if this will happen, i release it so others can use the code and hopefully even improve it.

i appreciate any comments, ideas and (most of all) bugfixes to this code.

download source:
http://b66883.com/projects/dffloader/CD ... 081201.zip
(zlib/libpng license)

screenshot:

Image


regards,

---loki

//EDIT:

also, here are my script parsing routines combined into one SceneNode. using this, you can add the entires game world to your scene using a few simple calls:

http://b66883.com/projects/dffloader/CG ... 081201.zip
(also zlib/libpng license)
Last edited by loki1985 on Tue Dec 02, 2008 3:14 pm, edited 10 times in total.
kingdutch
Posts: 76
Joined: Tue Sep 02, 2008 7:01 am

Post by kingdutch »

Which version is that screeny made of?
if (msg.getRubbishFactor() > rubbishLimit) { ignorePost(); cout << how it should be done << "\n"; }
loki1985
Posts: 214
Joined: Thu Mar 31, 2005 2:36 pm

Post by loki1985 »

kingdutch wrote:Which version is that screeny made of?
since i don't know what exactly you mean:
the screenshot is of complete GTA3 PC LOD data, latest source version of my DFF loader, running in Irrlicht 1.4.2 (Burnings Video or OpenGL, not sure).
kingdutch
Posts: 76
Joined: Tue Sep 02, 2008 7:01 am

Post by kingdutch »

Yeh, I meant what version of GTA it was made off. But yeh looks good, some things are choppy, but I have no idea of how hard it is to make a custom format loader. So looks very promising :D
if (msg.getRubbishFactor() > rubbishLimit) { ignorePost(); cout << how it should be done << "\n"; }
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

The code looks quite usable, just a few things: You should get rid of the std:: things (I didn't see anythings left, maybe just the using namespace?) and the many this-> references, because it's definitely not necessary. The Irrlicht coding style with capital letters for member attributes are enough to know if it's an attribute or a local variable.
And finally an optimization hint: Irrlicht arrays don't resize expoentially, but reallocate for each additional element. So better reallocate manually in front of a loop that contains push_backs. This will improve the loading times by orders of magnitudes (the .x loader became 20x faster just by adding some rellocates).
sio2
Competition winner
Posts: 1003
Joined: Thu Sep 21, 2006 5:33 pm
Location: UK

Post by sio2 »

Oh boy. I already have a game engine and a driving module for it (see my website). It sure would be interesting to load up one of those levels and have a drive around it. 8) I'll give this a try when I get the chance...
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Irrlicht arrays don't resize expoentially, but reallocate for each additional element.
:shock:
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Halifax
Posts: 1424
Joined: Sun Apr 29, 2007 10:40 pm
Location: $9D95

Post by Halifax »

Wow, that's some great work loki. And yeah, sio2, that would be pretty insane; I can't wait.
TheQuestion = 2B || !2B
loki1985
Posts: 214
Joined: Thu Mar 31, 2005 2:36 pm

Post by loki1985 »

@hybrid:
i reworked the code like you mentioned. writing members first letter uppercase was a somewhat new concept to me, and so i was a bit skeptic, but in the end it looks pretty OK. so also all this-> references are removed.
i had no problem with array speed since i used std::vector. now that i changed to irrlicht arrays i see what you mean, it was really slow. so i implemented the manual reallocate, now works really good again. and no std things needed anymore.
new version is uploaded and link in first post is updated.

@sio2:
sure, this would be cool. was my original intention also for writing this loader.
but, for being able to load complete cities from GTA you have to know: this DFF loader does not load the entire GTA cities at once. GTA cities consist of thousands of models in seperate DFF files.
Some .DAT files in GTA games define which IPL and IDE files must be parsed. The IDE (Item DEfinition) files do the definition for a specific model (e.g. which internal ID it has, which texture subdirectory this model files should load its textures from). The IPL (Item PLacement) files do the placing of the concrete item instances, defining e.g. placement, rotation.
these 3 file types (DAT, IDE, IPL) are simple text files (can be binary for GTASA tho) which are parsed very easily.

maybe, if i find some time, i could re-organize my file parsing classes into another Irrlicht format loader which in return feeds the DFFLoader which files to load and then places these on map. but don't get your hopes up, i am pretty busy with other stuff lately. and parsing those files is pretty straightforward and easy....
Mag-got
Posts: 42
Joined: Tue Dec 04, 2007 5:53 pm

Post by Mag-got »

The bug is, every GTA has it's own DFF version. (Your distortion)
Virion
Competition winner
Posts: 2148
Joined: Mon Dec 18, 2006 5:04 am

Post by Virion »

this is interesting :o
loki1985
Posts: 214
Joined: Thu Mar 31, 2005 2:36 pm

Post by loki1985 »

Mag-got wrote:The bug is, every GTA has it's own DFF version. (Your distortion)
don't wanna appear unappreciative, but thats no news to me. as you can see in the sourcecode, i am recognizing the version of DFF files and do conditional code depending on version.
the problem is that i found no document/forum post/whatever that describes the difference of vertex/index format between GTA3 and GTAVC (and that is where the problem seems to be).
xray
Posts: 231
Joined: Fri Feb 02, 2007 1:06 pm
Location: Germany, Munich
Contact:

Post by xray »

I also think that it was clear from the top post of loki, that his file format loader is currently only for GTA3 DFF files...

Good job so far loki!
loki1985
Posts: 214
Joined: Thu Mar 31, 2005 2:36 pm

Post by loki1985 »

so, one more bug was found and fixed. this improves compatibility with all DFF files, most Vice City meshes look much better now, tho some still have problems.
also fixes some glitches in GTA3:

Image

get updated source here (link in 1st post was also updated):

http://b66883.com/projects/dffloader/CD ... 080930.zip
kingdutch
Posts: 76
Joined: Tue Sep 02, 2008 7:01 am

Post by kingdutch »

Nice job! That was one of the bugs that was eating away most eye candy!
if (msg.getRubbishFactor() > rubbishLimit) { ignorePost(); cout << how it should be done << "\n"; }
Post Reply