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.

DFF mesh format loader

Postby loki1985 » Fri Sep 26, 2008 4:33 pm

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/CDFFMeshFileLoader_20081201.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/CGTASceneNode_20081201.zip
(also zlib/libpng license)
Last edited by loki1985 on Tue Dec 02, 2008 3:14 pm, edited 10 times in total.
loki1985
 
Posts: 214
Joined: Thu Mar 31, 2005 2:36 pm

Postby kingdutch » Fri Sep 26, 2008 4:49 pm

Which version is that screeny made of?
if (msg.getRubbishFactor() > rubbishLimit) { ignorePost(); cout << how it should be done << "\n"; }
User avatar
kingdutch
 
Posts: 76
Joined: Tue Sep 02, 2008 7:01 am

Postby loki1985 » Fri Sep 26, 2008 6:24 pm

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).
loki1985
 
Posts: 214
Joined: Thu Mar 31, 2005 2:36 pm

Postby kingdutch » Fri Sep 26, 2008 6:53 pm

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"; }
User avatar
kingdutch
 
Posts: 76
Joined: Tue Sep 02, 2008 7:01 am

Postby hybrid » Fri Sep 26, 2008 8:01 pm

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).
hybrid
Admin
 
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany

Postby sio2 » Fri Sep 26, 2008 9:53 pm

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...
sio2
Competition winner
 
Posts: 1003
Joined: Thu Sep 21, 2006 5:33 pm
Location: UK

Postby BlindSide » Fri Sep 26, 2008 10:55 pm

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
BlindSide
Admin
 
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Postby Halifax » Sat Sep 27, 2008 3:22 am

Wow, that's some great work loki. And yeah, sio2, that would be pretty insane; I can't wait.
TheQuestion = 2B || !2B
User avatar
Halifax
 
Posts: 1424
Joined: Sun Apr 29, 2007 10:40 pm
Location: $9D95

Postby loki1985 » Sat Sep 27, 2008 9:00 pm

@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....
loki1985
 
Posts: 214
Joined: Thu Mar 31, 2005 2:36 pm

Postby Mag-got » Sun Sep 28, 2008 4:21 pm

The bug is, every GTA has it's own DFF version. (Your distortion)
Mag-got
 
Posts: 42
Joined: Tue Dec 04, 2007 5:53 pm

Postby Virion » Sun Sep 28, 2008 5:10 pm

this is interesting :o
User avatar
Virion
Competition winner
 
Posts: 2141
Joined: Mon Dec 18, 2006 5:04 am

Postby loki1985 » Sun Sep 28, 2008 7:31 pm

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).
loki1985
 
Posts: 214
Joined: Thu Mar 31, 2005 2:36 pm

Postby xray » Mon Sep 29, 2008 3:27 pm

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!
User avatar
xray
 
Posts: 231
Joined: Fri Feb 02, 2007 1:06 pm
Location: Germany, Munich

Postby loki1985 » Tue Sep 30, 2008 12:03 pm

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/CDFFMeshFileLoader_20080930.zip
loki1985
 
Posts: 214
Joined: Thu Mar 31, 2005 2:36 pm

Postby kingdutch » Tue Sep 30, 2008 1:55 pm

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"; }
User avatar
kingdutch
 
Posts: 76
Joined: Tue Sep 02, 2008 7:01 am

Next

Return to Code Snippets

Who is online

Users browsing this forum: No registered users and 1 guest