Commit 9d1b9404 authored by hybrid's avatar hybrid

Merged from 1.5 branch, revisions 2297:2318. Fixed collada loader for very old...

Merged from 1.5 branch, revisions 2297:2318. Fixed collada loader for very old files, and fixed 3ds shininess.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2319 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 1918be71
...@@ -662,14 +662,36 @@ Changes in version 1.6, TA ...@@ -662,14 +662,36 @@ Changes in version 1.6, TA
------------------------------------- -------------------------------------
Changes in version 1.5.1 (??.?? 2009) Changes in version 1.5.1 (??.?? 2009)
- Update to libpng 1.2.35 - Fix loading of Collada files from irrEdit 1.2
- Update to libpng 1.2.35, fixed issues on 64bit machines with system's libpng.
- Remove texture pointers after texture clear.
- Fix ALPHA_CHANNEL_REF to a fixed check for alpha==127 as expected.
- Fixed OSX device bug where screen size was not set in fullscreen mode. - Fixed OSX device bug where screen size was not set in fullscreen mode.
- OpenGL version calculation fixed.
- OSX device now supports shift and ctrl keys. - OSX device now supports shift and ctrl keys.
- Fixed ambient light issues in bruningsvideo.
- device reset for d3d fixed when using VBOs.
- MD2 mesh loader: Now uses much less memory, reduced number of allocations when loading meshes. - MD2 mesh loader: Now uses much less memory, reduced number of allocations when loading meshes.
- OpenGL render state (texture wrongly cached) fixed.
- Fixed animator removal.
- Fix terrain to use 32bit only when necessary, make terrain use hw buffers. Heightmap loading and height calculation fixed.
- Some mem leaks fixed
- FPS camera resets the cursor better
----------------------------------- -----------------------------------
Changes in version 1.5 (15.12.2008) Changes in version 1.5 (15.12.2008)
......
...@@ -372,6 +372,7 @@ bool C3DSMeshFileLoader::readMaterialChunk(io::IReadFile* file, ChunkData* paren ...@@ -372,6 +372,7 @@ bool C3DSMeshFileLoader::readMaterialChunk(io::IReadFile* file, ChunkData* paren
break; break;
case C3DS_MATSHININESS: case C3DS_MATSHININESS:
readPercentageChunk(file, &data, CurrentMaterial.Material.Shininess); readPercentageChunk(file, &data, CurrentMaterial.Material.Shininess);
CurrentMaterial.Material.Shininess = (1.f-CurrentMaterial.Material.Shininess)*128.f;
break; break;
case C3DS_TRANSPARENCY: case C3DS_TRANSPARENCY:
{ {
......
...@@ -118,6 +118,7 @@ namespace scene ...@@ -118,6 +118,7 @@ namespace scene
const core::stringc falloffExponentNodeName = "falloff_exponent"; const core::stringc falloffExponentNodeName = "falloff_exponent";
const core::stringc profileCOMMONSectionName = "profile_COMMON"; const core::stringc profileCOMMONSectionName = "profile_COMMON";
const core::stringc profileCOMMONAttributeName = "COMMON";
const char* const inputSemanticNames[] = {"POSITION", "VERTEX", "NORMAL", "TEXCOORD", const char* const inputSemanticNames[] = {"POSITION", "VERTEX", "NORMAL", "TEXCOORD",
"UV", "TANGENT", "IMAGE", "TEXTURE", 0}; "UV", "TANGENT", "IMAGE", "TEXTURE", 0};
...@@ -367,7 +368,6 @@ IAnimatedMesh* CColladaFileLoader::createMesh(io::IReadFile* file) ...@@ -367,7 +368,6 @@ IAnimatedMesh* CColladaFileLoader::createMesh(io::IReadFile* file)
if (!Version) if (!Version)
return 0; return 0;
// because this loader loads and creates a complete scene instead of // because this loader loads and creates a complete scene instead of
// a single mesh, return an empty dummy mesh to make the scene manager // a single mesh, return an empty dummy mesh to make the scene manager
// know that everything went well. // know that everything went well.
...@@ -375,6 +375,9 @@ IAnimatedMesh* CColladaFileLoader::createMesh(io::IReadFile* file) ...@@ -375,6 +375,9 @@ IAnimatedMesh* CColladaFileLoader::createMesh(io::IReadFile* file)
DummyMesh = new SAnimatedMesh(); DummyMesh = new SAnimatedMesh();
scene::IAnimatedMesh* returnMesh = DummyMesh; scene::IAnimatedMesh* returnMesh = DummyMesh;
if (Version < 10400)
instantiateNode(SceneManager->getRootSceneNode());
// add the first loaded mesh into the mesh cache too, if more than one // add the first loaded mesh into the mesh cache too, if more than one
// meshes have been loaded from the file // meshes have been loaded from the file
if (LoadedMeshCount>1 && FirstLoadedMesh) if (LoadedMeshCount>1 && FirstLoadedMesh)
...@@ -422,7 +425,7 @@ void CColladaFileLoader::skipSection(io::IXMLReaderUTF8* reader, bool reportSkip ...@@ -422,7 +425,7 @@ void CColladaFileLoader::skipSection(io::IXMLReaderUTF8* reader, bool reportSkip
{ {
#ifdef COLLADA_READER_DEBUG #ifdef COLLADA_READER_DEBUG
if (reportSkipping) if (reportSkipping)
os::Printer::log("Skipping COLLADA unknown element:", core::stringc(reader->getNodeName()).c_str()); os::Printer::log("Skipping COLLADA unknown element", core::stringc(reader->getNodeName()).c_str());
#endif // COLLADA_READER_DEBUG #endif // COLLADA_READER_DEBUG
++tagCounter; ++tagCounter;
...@@ -441,7 +444,7 @@ void CColladaFileLoader::readColladaSection(io::IXMLReaderUTF8* reader) ...@@ -441,7 +444,7 @@ void CColladaFileLoader::readColladaSection(io::IXMLReaderUTF8* reader)
return; return;
const f32 version = core::fast_atof(core::stringc(reader->getAttributeValue("version")).c_str()); const f32 version = core::fast_atof(core::stringc(reader->getAttributeValue("version")).c_str());
Version = core::floor32(version)*10000+core::ceil32(core::fract(version)*1000.0f); Version = core::floor32(version)*10000+core::floor32(core::fract(version)*1000.0f);
// Version 1.4 can be checked for by if (Version >= 10400) // Version 1.4 can be checked for by if (Version >= 10400)
while(reader->read()) while(reader->read())
...@@ -1074,9 +1077,9 @@ core::matrix4 CColladaFileLoader::readTranslateNode(io::IXMLReaderUTF8* reader) ...@@ -1074,9 +1077,9 @@ core::matrix4 CColladaFileLoader::readTranslateNode(io::IXMLReaderUTF8* reader)
} }
//! reads any kind of <instance*> node and creates a scene node from it //! reads any kind of <instance*> node
void CColladaFileLoader::readInstanceNode(io::IXMLReaderUTF8* reader, scene::ISceneNode* parent, void CColladaFileLoader::readInstanceNode(io::IXMLReaderUTF8* reader,
scene::ISceneNode** outNode, CScenePrefab* p) scene::ISceneNode* parent, scene::ISceneNode** outNode, CScenePrefab* p)
{ {
#ifdef COLLADA_READER_DEBUG #ifdef COLLADA_READER_DEBUG
os::Printer::log("COLLADA reading instance"); os::Printer::log("COLLADA reading instance");
...@@ -1103,10 +1106,20 @@ void CColladaFileLoader::readInstanceNode(io::IXMLReaderUTF8* reader, scene::ISc ...@@ -1103,10 +1106,20 @@ void CColladaFileLoader::readInstanceNode(io::IXMLReaderUTF8* reader, scene::ISc
break; break;
} }
} }
instantiateNode(parent, outNode, p, url);
}
void CColladaFileLoader::instantiateNode(scene::ISceneNode* parent,
scene::ISceneNode** outNode, CScenePrefab* p, const core::stringc& url)
{
#ifdef COLLADA_READER_DEBUG
os::Printer::log("COLLADA instantiate node");
#endif
for (u32 i=0; i<Prefabs.size(); ++i) for (u32 i=0; i<Prefabs.size(); ++i)
{ {
if (url == Prefabs[i]->getId()) if (url == "" || url == Prefabs[i]->getId())
{ {
if (p) if (p)
p->Childs.push_back(Prefabs[i]); p->Childs.push_back(Prefabs[i]);
...@@ -1119,7 +1132,7 @@ void CColladaFileLoader::readInstanceNode(io::IXMLReaderUTF8* reader, scene::ISc ...@@ -1119,7 +1132,7 @@ void CColladaFileLoader::readInstanceNode(io::IXMLReaderUTF8* reader, scene::ISc
{ {
*outNode = newNode; *outNode = newNode;
if (*outNode) if (*outNode)
(*outNode)->setName(readId(reader)); (*outNode)->setName(url);
} }
} }
return; return;
...@@ -1724,12 +1737,15 @@ void CColladaFileLoader::readGeometry(io::IXMLReaderUTF8* reader) ...@@ -1724,12 +1737,15 @@ void CColladaFileLoader::readGeometry(io::IXMLReaderUTF8* reader)
} }
else else
// trifans, and tristrips missing // trifans, and tristrips missing
if (extraNodeName == reader->getNodeName()) if (extraNodeName == nodeName)
skipSection(reader, false); skipSection(reader, false);
else else
if (techniqueCommonSectionName != nodeName) // techniqueCommon must not be skipped // techniqueCommon or 'technique profile=common' must not be skipped
if ((techniqueCommonSectionName != nodeName) // Collada 1.4+
&& ((techniqueNodeName != nodeName) ||
(profileCOMMONAttributeName != reader->getAttributeValue("profile")))) // Collada 1.2/1.3
{ {
// os::Printer::log("COLLADA loader warning: Wrong tag usage found", reader->getNodeName(), ELL_WARNING); os::Printer::log("COLLADA loader warning: Wrong tag usage found in geometry", reader->getNodeName(), ELL_WARNING);
skipSection(reader, true); // ignore all other sections skipSection(reader, true); // ignore all other sections
} }
} // end if node type is element } // end if node type is element
...@@ -1957,10 +1973,9 @@ void CColladaFileLoader::readPolygonSection(io::IXMLReaderUTF8* reader, ...@@ -1957,10 +1973,9 @@ void CColladaFileLoader::readPolygonSection(io::IXMLReaderUTF8* reader,
} }
else else
{ {
for (u32 i = 0; i < vCounts.size(); i++) for (u32 i = 0; i < vCounts.size(); i++)
{ {
int polyVCount = vCounts[i]; const int polyVCount = vCounts[i];
core::array<int> polyCorners; core::array<int> polyCorners;
...@@ -2395,7 +2410,10 @@ void CColladaFileLoader::readColladaInput(io::IXMLReaderUTF8* reader) ...@@ -2395,7 +2410,10 @@ void CColladaFileLoader::readColladaInput(io::IXMLReaderUTF8* reader)
// get source // get source
p.Source = reader->getAttributeValue("source"); p.Source = reader->getAttributeValue("source");
p.Offset = (u32)reader->getAttributeValueAsInt("offset"); if (reader->getAttributeValue("offset")) // Collada 1.4+
p.Offset = (u32)reader->getAttributeValueAsInt("offset");
else // Collada 1.2/1.3
p.Offset = (u32)reader->getAttributeValueAsInt("idx");
p.Set = (u32)reader->getAttributeValueAsInt("set"); p.Set = (u32)reader->getAttributeValueAsInt("set");
// add input // add input
......
...@@ -246,10 +246,14 @@ private: ...@@ -246,10 +246,14 @@ private:
//! reads a <float> element //! reads a <float> element
f32 readFloatNode(io::IXMLReaderUTF8* reader); f32 readFloatNode(io::IXMLReaderUTF8* reader);
//! reads a <instance> node and creates a scene node from it //! reads a <instance> node
void readInstanceNode(io::IXMLReaderUTF8* reader, scene::ISceneNode* parent, void readInstanceNode(io::IXMLReaderUTF8* reader, scene::ISceneNode* parent,
scene::ISceneNode** outNode, CScenePrefab* p=0); scene::ISceneNode** outNode, CScenePrefab* p=0);
//! creates a scene node from Prefabs (with name given in 'url')
void instantiateNode(scene::ISceneNode* parent, scene::ISceneNode** outNode=0,
CScenePrefab* p=0, const core::stringc& url="");
//! reads a <light> element and stores it as prefab //! reads a <light> element and stores it as prefab
void readLightPrefab(io::IXMLReaderUTF8* reader); void readLightPrefab(io::IXMLReaderUTF8* reader);
......
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