Commit 67b31578 authored by hybrid's avatar hybrid

Some more texture loading updates.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1632 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 3d78d2a9
...@@ -191,10 +191,20 @@ IAnimatedMesh* CDMFLoader::createMesh(io::IReadFile* file) ...@@ -191,10 +191,20 @@ IAnimatedMesh* CDMFLoader::createMesh(io::IReadFile* file)
SMeshBufferLightMap* buffer = (SMeshBufferLightMap*)mesh->getMeshBuffer(i); SMeshBufferLightMap* buffer = (SMeshBufferLightMap*)mesh->getMeshBuffer(i);
//Primary texture is normal //Primary texture is normal
if ((materiali[i].textureFlag==0) || (materiali[i].textureBlend==4)) if (materiali[i].textureFlag==0)
{ {
if (materiali[i].textureBlend==4)
driver->setTextureCreationFlag(ETCF_ALWAYS_32_BIT,true); driver->setTextureCreationFlag(ETCF_ALWAYS_32_BIT,true);
if (FileSystem->existFile(path+materiali[i].textureName))
tex = driver->getTexture((path+materiali[i].textureName).c_str()); tex = driver->getTexture((path+materiali[i].textureName).c_str());
else if (FileSystem->existFile(path+FileSystem->getFileBasename(materiali[i].textureName)))
tex = driver->getTexture((path+FileSystem->getFileBasename(materiali[i].textureName)).c_str());
else if (FileSystem->existFile(materiali[i].textureName))
tex = driver->getTexture(materiali[i].textureName.c_str());
else if (FileSystem->existFile(FileSystem->getFileBasename(materiali[i].textureName)))
tex = driver->getTexture(FileSystem->getFileBasename(materiali[i].textureName).c_str());
else
os::Printer::log("Could not load texture", materiali[i].textureName.c_str());
} }
//Primary texture is just a colour //Primary texture is just a colour
else if(materiali[i].textureFlag==1) else if(materiali[i].textureFlag==1)
...@@ -225,7 +235,6 @@ IAnimatedMesh* CDMFLoader::createMesh(io::IReadFile* file) ...@@ -225,7 +235,6 @@ IAnimatedMesh* CDMFLoader::createMesh(io::IReadFile* file)
lig = driver->getTexture((path+materiali[i].lightmapName).c_str()); lig = driver->getTexture((path+materiali[i].lightmapName).c_str());
else //no lightmap else //no lightmap
{ {
lig = 0;
buffer->Material.MaterialType = video::EMT_SOLID; buffer->Material.MaterialType = video::EMT_SOLID;
const f32 mult = 100.0f - header.dmfShadow; const f32 mult = 100.0f - header.dmfShadow;
buffer->Material.AmbientColor=header.dmfAmbient.getInterpolated(SColor(255,0,0,0),mult/100.f); buffer->Material.AmbientColor=header.dmfAmbient.getInterpolated(SColor(255,0,0,0),mult/100.f);
......
...@@ -30,8 +30,8 @@ This structure contains data about DeleD level file like: version, ambient colou ...@@ -30,8 +30,8 @@ This structure contains data about DeleD level file like: version, ambient colou
struct dmfHeader struct dmfHeader
{ {
//main file header //main file header
f32 dmfVersion; //!<File version
core::stringc dmfName; //!<Scene name core::stringc dmfName; //!<Scene name
f32 dmfVersion; //!<File version
SColor dmfAmbient; //!<Ambient color SColor dmfAmbient; //!<Ambient color
f32 dmfShadow; //!<Shadow intensity f32 dmfShadow; //!<Shadow intensity
u32 numObjects; //!<Number of objects in this scene u32 numObjects; //!<Number of objects in this scene
...@@ -62,7 +62,7 @@ struct dmfMaterial ...@@ -62,7 +62,7 @@ struct dmfMaterial
This structure contains first vertice index, number of vertices and the material used.*/ This structure contains first vertice index, number of vertices and the material used.*/
struct dmfFace struct dmfFace
{ {
u32 firstVert;//!<First vertice index. u32 firstVert;//!<First vertex index.
u32 numVerts;//!<Number of vertices for this face. u32 numVerts;//!<Number of vertices for this face.
u32 materialID;//!<Material used for this face. u32 materialID;//!<Material used for this face.
}; };
...@@ -72,9 +72,9 @@ struct dmfFace ...@@ -72,9 +72,9 @@ struct dmfFace
This structure contains vertice position coordinates and texture an lightmap UV.*/ This structure contains vertice position coordinates and texture an lightmap UV.*/
struct dmfVert struct dmfVert
{ {
core::vector3df pos;//!<Position of vertice x,y,z core::vector3df pos;//!<Position of vertex
core::vector2df tc;//!<Texture UV coords. core::vector2df tc;//!<Texture UV coords
core::vector2df lc;//!<Lightmap UV coords. core::vector2df lc;//!<Lightmap UV coords
}; };
...@@ -82,7 +82,7 @@ struct dmfVert ...@@ -82,7 +82,7 @@ struct dmfVert
This structure contains light position coordinates, diffuse colour, specular colour and maximum radius of light.*/ This structure contains light position coordinates, diffuse colour, specular colour and maximum radius of light.*/
struct dmfLight struct dmfLight
{ {
f32 pos[3];//!<Position of this light. core::vector3df pos;//!<Position of this light.
SColorf diffuseColor;//!<Diffuse color. SColorf diffuseColor;//!<Diffuse color.
SColorf specularColor;//!<Specular color. SColorf specularColor;//!<Specular color.
f32 radius;//!<Maximum radius of light. f32 radius;//!<Maximum radius of light.
...@@ -90,7 +90,7 @@ struct dmfLight ...@@ -90,7 +90,7 @@ struct dmfLight
/** A structure rapresenting a single water plane. /** A structure rapresenting a single water plane.
This structure contains light position coordinates, diffuse colour, specular colour and maximum radius of light.*/ This structure contains light position coordinates, diffuse colour, specular colour and maximum radius of light.*/
struct dmfWaterPlain struct dmfWaterPlane
{ {
u32 waterID;//!<ID of specified water plane. u32 waterID;//!<ID of specified water plane.
u32 numFaces;//!<number of faces that make this plain.Owing to the fact that this is a rectangle you'll have 1 every time. u32 numFaces;//!<number of faces that make this plain.Owing to the fact that this is a rectangle you'll have 1 every time.
...@@ -356,14 +356,8 @@ bool GetDMFMaterials(const StringList& RawFile, ...@@ -356,14 +356,8 @@ bool GetDMFMaterials(const StringList& RawFile,
temp1=SubdivideString(temp[5],","); temp1=SubdivideString(temp[5],",");
materials[i].textureFlag = atoi(temp1[0].c_str()); materials[i].textureFlag = atoi(temp1[0].c_str());
if(!use_material_dirs && !materials[i].textureFlag)
{
temp2=SubdivideString(temp1[1],"\\");
materials[i].textureName=temp2.getLast();
}
else
materials[i].textureName=temp1[1]; materials[i].textureName=temp1[1];
materials[i].textureName.replace('\\','/');
materials[i].textureBlend = atoi(temp1[2].c_str()); materials[i].textureBlend = atoi(temp1[2].c_str());
temp1.clear(); temp1.clear();
temp2.clear(); temp2.clear();
...@@ -534,6 +528,7 @@ bool GetDMFVerticesFaces(const StringList& RawFile/**<StringList representing a ...@@ -534,6 +528,7 @@ bool GetDMFVerticesFaces(const StringList& RawFile/**<StringList representing a
return true; return true;
} }
/**This function extract an array of dmfLights from a DMF file. /**This function extract an array of dmfLights from a DMF file.
You must give in input a StringList representing a DMF file loaded with You must give in input a StringList representing a DMF file loaded with
LoadFromFile and one array long enough. Please use GetDMFHeader() before this LoadFromFile and one array long enough. Please use GetDMFHeader() before this
...@@ -596,9 +591,9 @@ bool GetDMFLights(const StringList& RawFile/**<StringList representing a DMF fil ...@@ -596,9 +591,9 @@ bool GetDMFLights(const StringList& RawFile/**<StringList representing a DMF fil
if(temp1[0]==String("dynamic")) if(temp1[0]==String("dynamic"))
{ {
lights[d_lit].radius = (float)atof(temp[4].c_str()); lights[d_lit].radius = (float)atof(temp[4].c_str());
lights[d_lit].pos[0] = (float)atof(temp[5].c_str()); lights[d_lit].pos.set((float)atof(temp[5].c_str()),
lights[d_lit].pos[1] = (float)atof(temp[6].c_str()); (float)atof(temp[6].c_str()),
lights[d_lit].pos[2] = (float)-atof(temp[7].c_str()); (float)-atof(temp[7].c_str()));
lights[d_lit].diffuseColor = SColorf( lights[d_lit].diffuseColor = SColorf(
SColor(255, atoi(temp[10].c_str()), atoi(temp[11].c_str()), SColor(255, atoi(temp[10].c_str()), atoi(temp[11].c_str()),
...@@ -618,12 +613,13 @@ bool GetDMFLights(const StringList& RawFile/**<StringList representing a DMF fil ...@@ -618,12 +613,13 @@ bool GetDMFLights(const StringList& RawFile/**<StringList representing a DMF fil
return true; return true;
} }
/**This function extracts an array of dmfWaterPlain,dmfVert and dmfFace from a DMF file.
/**This function extracts an array of dmfWaterPlane,dmfVert and dmfFace from a DMF file.
You must give in input a StringList representing a DMF file loaded with LoadFromFile and three arrays long enough. You must give in input a StringList representing a DMF file loaded with LoadFromFile and three arrays long enough.
Please use GetDMFHeader() before this function to know number of water plains and water faces as well as water vertices. Please use GetDMFHeader() before this function to know number of water plains and water faces as well as water vertices.
\return true if function succeed or false on fail.*/ \return true if function succeed or false on fail.*/
bool GetDMFWaterPlains(const StringList& RawFile/**<StringList representing a DMF file.*/, bool GetDMFWaterPlanes(const StringList& RawFile/**<StringList representing a DMF file.*/,
dmfWaterPlain wat_planes[]/**<Water planes returned.*/, dmfWaterPlane wat_planes[]/**<Water planes returned.*/,
dmfVert vertices[]/**<Vertices returned*/, dmfVert vertices[]/**<Vertices returned*/,
dmfFace faces[]/**Faces returned*/ dmfFace faces[]/**Faces returned*/
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment