DeleD DMFLoader for Irrlicht

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

Hi ilbuzzo! thnx for replying. I tried to use your loader class to load a level I created but got the following errors:

Code: Select all

C:\Irrlicht\Projects_Relo\deled\CDMFLoader.cpp(119) : error C2057: expected constant expression
C:\Irrlicht\Projects_Relo\deled\CDMFLoader.cpp(119) : error C2466: cannot allocate an array of constant size 0
C:\Irrlicht\Projects_Relo\deled\CDMFLoader.cpp(119) : error C2133: 'materiali' : unknown size
C:\Irrlicht\Projects_Relo\deled\CDMFLoader.cpp(120) : error C2057: expected constant expression
C:\Irrlicht\Projects_Relo\deled\CDMFLoader.cpp(120) : error C2466: cannot allocate an array of constant size 0
C:\Irrlicht\Projects_Relo\deled\CDMFLoader.cpp(120) : error C2133: 'verts' : unknown size
C:\Irrlicht\Projects_Relo\deled\CDMFLoader.cpp(121) : error C2057: expected constant expression
C:\Irrlicht\Projects_Relo\deled\CDMFLoader.cpp(121) : error C2466: cannot allocate an array of constant size 0
C:\Irrlicht\Projects_Relo\deled\CDMFLoader.cpp(121) : error C2133: 'faces' : unknown size
C:\Irrlicht\Projects_Relo\deled\CDMFLoader.cpp(409) : error C2057: expected constant expression
C:\Irrlicht\Projects_Relo\deled\CDMFLoader.cpp(409) : error C2466: cannot allocate an array of constant size 0
C:\Irrlicht\Projects_Relo\deled\CDMFLoader.cpp(409) : error C2133: 'lights' : unknown size
am I missing including something?
laforced
Posts: 39
Joined: Tue Feb 01, 2005 5:07 am
Location: South Carolina,USA
Contact:

Post by laforced »

@afecelis

Hola;
Are you using Visual Studio? :) If so , see the download I have posted
The compiler will complain until you use the sizeof operator and give
it a multiplier large enough to accomodate the largest anticipated
variable. Example:

dmfMaterial materiali[sizeof header.numMaterials*32];
dmfVert verts[sizeof header.numVertices* 6144];
dmfFace faces[sizeof header.numFaces*6144];

I also had trouble with the Irrlicht readfile method and had to change
to use a standard file stream via fstream to read in the file. If you have
problems just shout.
If you're not making GREAT games
you belong in an institute!
The Game Institute.
www.gameinstitute.com
ilbuzzo
Posts: 71
Joined: Sat Mar 05, 2005 4:00 pm
Location: Italy

Post by ilbuzzo »

@afecelis

Hi,
The only thing you have to include is CDMFLoader.cpp in main project, dmfsupport.h and CDMFLoader.h are then included by this file.
The trouble you're pointing out is main due to your compiler, owing to the fact that for some reasons you need a constant (and not a variable) in array definition.
The fact is that header.numMaterials or vertices or faces is a variable filled when you load a file. It's done to avoid the use of too much resources (an array greater than needed).
So you must investigate some flags in your compiler, or use a constant definition like:

Code: Select all

#define MAX_MATERIALS 100
#define MAX_FACES 10000
#define MAX_VERTS 40000
#define MAX_DYNLIGHTS 10
in CDMFLoader.h and then change the indicated definitions in CDMFLoader.cpp from:

Code: Select all

dmfMaterial materiali[header.numMaterials];
dmfVert verts[header.numVertices];
dmfFace faces[header.numFaces];
to:

Code: Select all

dmfMaterial materiali[MAX_MATERIALS];
dmfVert verts[MAX_VERTS];
dmfFace faces[MAX_FACES];
and from:

Code: Select all

dmfLight lights[header.numLights];
to:

Code: Select all

dmfLight lights[MAX_DYNLIGHTS];
Anyway this solution is not really liked by me owing to the fact you must know how many polys you have and also how many vertices.
laforced solution is the same cause when you write (sizeof header.numVerts) compiler gives you 4 and then multiply it for a constant.
@laforced
If you have troubles with loading of file using Irrlicht stream, you can give a look to loadLights new function where I use the standard C stream functions to read the file in a StringList, the function is built in StringList class and it's called LoadFromFile(char *filename), you can use this way:

Code: Select all

// create a stinglist
StringList dmfRawFile;
// load strings from DeleD file
dmfRawFile.LoadFromFile("yourfile.dmf");
//now you can use your dmfRawFile at your needs in main CDMFLoader code
Bye and let me know if you have other problems.
:)
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

many thanx for the help laforced and ilbuzzo.

I'm using MSVC toolkit 2003, which should be the same compiler but I also got MSVC7. So I'll try your fixes to see if things change, although , as ilbuzzo said, the fact that you have to change those values according to your scene's info makes it a bit complicated for me. Specially if you have a lot of scenes and having to code something different for each :cry:

I'll tell you guys how things went then. :D
Guest

Post by Guest »

@afecelis @laforced
Hi guys,
to solve your troubles you could use the following code:

Code: Select all

//let's create the correct number of materials, vertices and faces
       dmfMaterial *materiali=(dmfMaterial *)malloc(header.numMaterials* sizeof(dmfMaterial));
       dmfVert *verts=(dmfVert *)malloc(header.numVertices*sizeof(dmfVert));
       dmfFace *faces=(dmfFace *)malloc(header.numFaces*sizeof(dmfFace));
but remember to free variables when you don't need anymore:

Code: Select all

    free(verts);
    free(faces);
    free(materiali);
the same for lights:

Code: Select all

//create the correct number of lights structures.
       dmfLight *lights=(dmfLight *)malloc( header.numLights * sizeof(dmfLight));
and then free variables when you don't need anymore:

Code: Select all

    free(lights);   
It's a standard method (used in C too) to allocate dynamic memory that must solve your trouble.
If you need a CDMFLoader.cpp file send me an e-mail and I'll send you modified version.
I hope you solved your troubles.
You could also use new and delete operators in C++ (I prefere) but it's not difficult to do.
Bye and let me know.
:D
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

thnx for the info guest. That would be a good solution. Are you having any memory problems with it?

I'd like to get your main.cpp file but you got no email since you're not logged in. Please tell me where to write you or send me a copy at my email :D
ilbuzzo
Posts: 71
Joined: Sat Mar 05, 2005 4:00 pm
Location: Italy

Post by ilbuzzo »

Hi guys,
The guest was me, sorry I've not logged in ;).
bye

@afecelis
I've sent an e-mail to you with both versions (malloc and new&delete).
Let me know.
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

:oops: :oops:

sorry Salvatore, I just checked my email!!! thanks!
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

ok ok, getting better. Less errors;

Code: Select all

main.obj : error LNK2019: unresolved external symbol __imp__GetOpenFileNameA@4 referenced in function _main
C:\Irrlicht\Projects_Relo\deled\deled.exe : fatal error LNK1120: 1 unresolved externals
any ideas, Salvatore?

ps. Final question:

Code: Select all

IAnimatedMesh* mesh = smgr->getMesh(szFile);
where does the szFile come from if it hasn't been declared?
ZDimitor
Posts: 202
Joined: Fri Jul 16, 2004 3:27 am
Location: Russia

Post by ZDimitor »

Hi guys! Please give me a link to the DeleD editor, i want to look at it.
Guest

Post by Guest »

@afecelis

posted by ilbuzzo page 2 of this thread

this error:
[Linker error] undefined reference to `GetOpenFileNameA@4'

is due to the fact you must link to comdlg32.lib library so if you have Dev-Cpp
you must add:
-lcomdlg32


@ZDimitor :

http://www.delgine.com/

@ World:
Byte Me.
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

I got MSVC and the comdlg32.lib library is included, but I'm still getting that error.

edited:
Fixed!!!! I just had to add:
#pragma comment(lib, "comdlg32.lib")
Is this ok?

ok, now I can begin creating some stuff in deled and testing.

Although having Zdimitor around here asking about deled....mmm.....smells like My3d for deled is also coming out.....
:D

thnx for all the help.

2nd edit:
The app compiles ok, but all I'm getting is a black screen without the text and the 3 lights.
ilbuzzo
Posts: 71
Joined: Sat Mar 05, 2005 4:00 pm
Location: Italy

Post by ilbuzzo »

Hi afecelis,
you must try to move back with your arrows, owing to the fact that DeleD scaling is a little bit huge. Do you see the title of window? How many lights are there?
What's the dmflog.txt?
Let me know!!
Bye
Joe_Oliveri
Posts: 448
Joined: Tue Oct 05, 2004 3:24 am
Location: Boston, MA

Post by Joe_Oliveri »

Also try making your grid size smaller, that helps in DeleD, then the scale wont be so big. :)
Irrlicht Moderator || Game Designer
Learn the basics at </dream.in.code>
ilbuzzo
Posts: 71
Joined: Sat Mar 05, 2005 4:00 pm
Location: Italy

Post by ilbuzzo »

Hi Guys,
I've changed a little CDMFLoader.cpp code to let it be loaded with no problems with VCToolkit2003 too.
Changes are those proposed in the previous messages, but if you don't want to do it yourself, please mail me and I'll send you the code, or just be patient until next release (after Easter) when I'll release that code as standard (it works indifferently with MinGW so.. :D ).
Anyway
Bye

@afecelis
why don't you post some screenies of your great FPS values here?

@laforced
this version solved your troubles with Irrlicht file loading routines (I've used mines maden by standard stream functions like in loadLights() function).
If you need let me know.
Post Reply