// Copyright (C) 2002-2007 Nikolaus Gebhardt // This file is part of the "Irrlicht Engine". // For conditions of distribution and use, see copyright notice in irrlicht.h // // This file was originally written by Salvatore Russo. // I (Nikolaus Gebhardt) did some minor modifications changes to it and integrated // it into Irrlicht: // - removed STL dependency // - removed log file and replaced it with irrlicht logging // - adapted code formatting a bit to Irrlicht style // - removed memory leaks // Thanks a lot to Salvatore for his work on this and that he gave me // his permission to add it into Irrlicht. // This support library has been made by Salvatore Russo and is released under GNU public license for general uses. // For uses in Irrlicht core and only for Irrlicht related uses I release this library under zlib license. // It uses standard template libraries to create String class and StringList class used in DeleD // plugins made by me. #ifndef __DMF_SUPPORT_H_INCLUDED__ #define __DMF_SUPPORT_H_INCLUDED__ using namespace irr; using namespace video; #include "irrString.h" /** A structure representing some DeleD infos. This structure contains data about DeleD level file like: version, ambient colour, number of objects etc...*/ struct dmfHeader { //main file header f32 dmfVersion; //! tileNum;//! { public: /**Basic Constructor*/ StringList() { } /**Constructor based on file loading. Look at LoadFromFile specifications.*/ StringList(io::IReadFile* file) { LoadFromFile(file); } /**Basic destructor.*/ ~StringList() { clear(); } //Adds a String to StringList /** Add a string to this StringList.*/ void Add(String str/*getSize(); char* buf = new char[sz+1]; file->read(buf, sz); buf[sz] = 0; char* p = buf; char* start = p; while(*p) { if (*p == '\n') { core::stringc str(start, p - start - 1); str.trim(); Add(str); start = p+1; } ++p; } if (p - start > 1) { core::stringc str(start, p - start - 1); str.trim(); Add(str); } delete [] buf; } }; //This function subdivides a string in a list of strings /** This function subdivides strings divided by divider in a list of strings. \return A StringList made of all strings divided by divider.*/ StringList SubdivideString(String str, String divider) { StringList strings; //returned StringList strings.clear(); //clear returned stringlist int c=0; int l=str.size(); //process entire string while(c= 0.91 temp=SubdivideString(RawFile[0],String(";"));//file info if ( temp[0] != String("DeleD Map File") ) return false;//not a deled file temp.clear(); temp=SubdivideString(RawFile[1],String(" "));//get version temp1=SubdivideString(temp[1],String(";")); if (atof(temp1[0].c_str()) < 0.91) return false;//not correct version //end checking temp.clear(); temp1.clear(); for(int i=0;i=9) { temp1=SubdivideString(temp[temp.size() - 1],","); materials[i].lightmapFlag=atoi(temp1[0].c_str()); if(!use_material_dirs) { temp2=SubdivideString(temp1[1],"\\"); sprintf(materials[i].lightmapName,"%s",temp2[temp2.size() - 1].c_str()); } else sprintf(materials[i].lightmapName,"%s",temp1[1].c_str()); } else { materials[i].lightmapFlag=1; materials[i].lightmapName[0]=0; } temp1.clear(); temp2.clear(); } return true; } /**This function extract an array of dmfMaterial from a DMF file considering 1st an 2nd layer for water plains. You must give in input a StringList representing a DMF file loaded with LoadFromFile. \return true if function succeed or false on fail.*/ bool GetDMFWaterMaterials(StringList RawFile /**= 0.91 temp=SubdivideString(RawFile[0],String(";"));//file info if ( temp[0] != String("DeleD Map File") ) return false;//not a deled file temp.clear(); temp=SubdivideString(RawFile[1],String(" "));//get version temp1=SubdivideString(temp[1],String(";")); if (atof(temp1[0].c_str()) < 0.91) return false;//not correct version //end checking temp.clear(); temp1.clear(); for(int i=0;i= 0.91 temp=SubdivideString(RawFile[0],String(";"));//file info if ( temp[0] != String("DeleD Map File") ) return false;//not a deled file temp.clear(); temp=SubdivideString(RawFile[1],String(" "));//get version temp1=SubdivideString(temp[1],String(";")); if (atof(temp1[0].c_str()) < 0.91) return false;//not correct version //end checking temp.clear(); temp1.clear(); offs=offs + atoi(RawFile[offs].c_str()); offs++; s32 objs = atoi(RawFile[offs].c_str()); s32 fac=0, vert=0, tmp_sz=0, vert_cnt=0, face_cnt=0; offs++; for (int i=0; i= 0.91 temp=SubdivideString(RawFile[0],String(";"));//file info if ( temp[0] != String("DeleD Map File") ) return false;//not a deled file temp.clear(); temp=SubdivideString(RawFile[1],String(" "));//get version temp1=SubdivideString(temp[1],String(";")); if (atof(temp1[0].c_str()) < 0.91) return false;//not correct version //end checking temp.clear(); temp1.clear(); offs=offs + atoi(RawFile[offs].c_str()); offs++; s32 objs = atoi(RawFile[offs].c_str()); s32 lit=0; s32 d_lit=0; offs++; //let's get position of lights in file int i; for(i=0;i= 0.91 temp=SubdivideString(RawFile[0],String(";"));//file info if ( temp[0] != String("DeleD Map File") ) return false;//not a deled file temp.clear(); temp=SubdivideString(RawFile[1],String(" "));//get version temp1=SubdivideString(temp[1],String(";")); if (atof(temp1[0].c_str()) < 0.91) return false;//not correct version //end checking temp.clear(); temp1.clear(); offs=offs+atoi(RawFile[offs].c_str()); offs++; s32 objs=atoi(RawFile[offs].c_str()); s32 fac=0,vert=0,tmp_sz=0,vert_cnt=0,face_cnt=0,wat_id=0; core::dimension2d tilenum(40,40); f32 waveheight=3.0f; f32 wavespeed=300.0f; f32 wavelength=80.0f; offs++; for(int i=0;i