[F] Fixed missed break.
[F] Doc changes. [*] Removed Boost dependency. [*] Style changes.pull/1014/head
parent
823003ba9b
commit
9c0de90ede
|
@ -1,18 +1,19 @@
|
||||||
/// \file X3DImporter.hpp
|
/// \file X3DImporter.cpp
|
||||||
/// \brief X3D-format files importer for Assimp: main algorithm implementation.
|
/// \brief X3D-format files importer for Assimp: main algorithm implementation.
|
||||||
/// \date 2015-2016
|
/// \date 2015-2016
|
||||||
/// \author nevorek@gmail.com
|
/// \author smal.root@gmail.com
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_X3D_IMPORTER
|
#ifndef ASSIMP_BUILD_NO_X3D_IMPORTER
|
||||||
|
|
||||||
#include "X3DImporter.hpp"
|
#include "X3DImporter.hpp"
|
||||||
#include "X3DImporter_Macro.hpp"
|
#include "X3DImporter_Macro.hpp"
|
||||||
|
|
||||||
#include "fast_atof.h"
|
// Header files, Assimp.
|
||||||
#include "DefaultIOSystem.h"
|
#include "DefaultIOSystem.h"
|
||||||
|
#include "fast_atof.h"
|
||||||
|
|
||||||
#include <boost/format.hpp>
|
// Header files, stdlib.
|
||||||
#include <boost/scoped_ptr.hpp>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace Assimp
|
namespace Assimp
|
||||||
|
@ -35,6 +36,7 @@ const aiImporterDesc X3DImporter::Description = {
|
||||||
|
|
||||||
void X3DImporter::Clear()
|
void X3DImporter::Clear()
|
||||||
{
|
{
|
||||||
|
NodeElement_Cur = nullptr;
|
||||||
// Delete all elements
|
// Delete all elements
|
||||||
if(NodeElement_List.size())
|
if(NodeElement_List.size())
|
||||||
{
|
{
|
||||||
|
@ -46,7 +48,7 @@ void X3DImporter::Clear()
|
||||||
|
|
||||||
X3DImporter::~X3DImporter()
|
X3DImporter::~X3DImporter()
|
||||||
{
|
{
|
||||||
if(mReader != NULL) delete mReader;
|
if(mReader != nullptr) delete mReader;
|
||||||
// Clear() is accounting if data already is deleted. So, just check again if all data is deleted.
|
// Clear() is accounting if data already is deleted. So, just check again if all data is deleted.
|
||||||
Clear();
|
Clear();
|
||||||
}
|
}
|
||||||
|
@ -61,7 +63,7 @@ bool X3DImporter::FindNodeElement_FromRoot(const std::string& pID, const CX3DImp
|
||||||
{
|
{
|
||||||
if(((*it)->Type == pType) && ((*it)->ID == pID))
|
if(((*it)->Type == pType) && ((*it)->ID == pID))
|
||||||
{
|
{
|
||||||
if(pElement != NULL) *pElement = *it;
|
if(pElement != nullptr) *pElement = *it;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -79,7 +81,7 @@ bool found = false;// flag: true - if requested element is found.
|
||||||
if((pStartNode->Type == pType) && (pStartNode->ID == pID))
|
if((pStartNode->Type == pType) && (pStartNode->ID == pID))
|
||||||
{
|
{
|
||||||
found = true;
|
found = true;
|
||||||
if(pElement != NULL) *pElement = pStartNode;
|
if(pElement != nullptr) *pElement = pStartNode;
|
||||||
|
|
||||||
goto fne_fn_end;
|
goto fne_fn_end;
|
||||||
}// if((pStartNode->Type() == pType) && (pStartNode->ID() == pID))
|
}// if((pStartNode->Type() == pType) && (pStartNode->ID() == pID))
|
||||||
|
@ -102,7 +104,7 @@ CX3DImporter_NodeElement* tnd = NodeElement_Cur;// temporary pointer to node.
|
||||||
bool static_search = false;// flag: true if searching in static node.
|
bool static_search = false;// flag: true if searching in static node.
|
||||||
|
|
||||||
// At first check if we have deal with static node. Go up thru parent nodes and check flag.
|
// At first check if we have deal with static node. Go up thru parent nodes and check flag.
|
||||||
while(tnd != NULL)
|
while(tnd != nullptr)
|
||||||
{
|
{
|
||||||
if(tnd->Type == CX3DImporter_NodeElement::ENET_Group)
|
if(tnd->Type == CX3DImporter_NodeElement::ENET_Group)
|
||||||
{
|
{
|
||||||
|
@ -115,7 +117,7 @@ bool static_search = false;// flag: true if searching in static node.
|
||||||
}
|
}
|
||||||
|
|
||||||
tnd = tnd->Parent;// go up in graph.
|
tnd = tnd->Parent;// go up in graph.
|
||||||
}// while(tnd != NULL)
|
}// while(tnd != nullptr)
|
||||||
|
|
||||||
// at now call appropriate search function.
|
// at now call appropriate search function.
|
||||||
if(static_search)
|
if(static_search)
|
||||||
|
@ -140,23 +142,23 @@ void X3DImporter::Throw_CloseNotFound(const std::string& pNode)
|
||||||
|
|
||||||
void X3DImporter::Throw_ConvertFail_Str2ArrF(const std::string& pAttrValue)
|
void X3DImporter::Throw_ConvertFail_Str2ArrF(const std::string& pAttrValue)
|
||||||
{
|
{
|
||||||
throw DeadlyImportError(boost::str(boost::format("In <%s> failed to convert attribute value \"%s\" from string to array of floats.") %
|
throw DeadlyImportError("In <" + std::string(mReader->getNodeName()) + "> failed to convert attribute value \"" + pAttrValue +
|
||||||
mReader->getNodeName() % pAttrValue));
|
"\" from string to array of floats.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void X3DImporter::Throw_DEF_And_USE()
|
void X3DImporter::Throw_DEF_And_USE()
|
||||||
{
|
{
|
||||||
throw DeadlyImportError(boost::str(boost::format("\"DEF\" and \"USE\" can not be defined both in <%s>.") % mReader->getNodeName()));
|
throw DeadlyImportError("\"DEF\" and \"USE\" can not be defined both in <" + std::string(mReader->getNodeName()) + ">.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void X3DImporter::Throw_IncorrectAttr(const std::string& pAttrName)
|
void X3DImporter::Throw_IncorrectAttr(const std::string& pAttrName)
|
||||||
{
|
{
|
||||||
throw DeadlyImportError(boost::str(boost::format("Node <%s> has incorrect attribute \"%s\".") % mReader->getNodeName() % pAttrName));
|
throw DeadlyImportError("Node <" + std::string(mReader->getNodeName()) + "> has incorrect attribute \"" + pAttrName + "\".");
|
||||||
}
|
}
|
||||||
|
|
||||||
void X3DImporter::Throw_IncorrectAttrValue(const std::string& pAttrName)
|
void X3DImporter::Throw_IncorrectAttrValue(const std::string& pAttrName)
|
||||||
{
|
{
|
||||||
throw DeadlyImportError(boost::str(boost::format("Attribute \"%s\" in node <%s> has incorrect value.") % pAttrName % mReader->getNodeName()));
|
throw DeadlyImportError("Attribute \"" + pAttrName + "\" in node <" + std::string(mReader->getNodeName()) + "> has incorrect value.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void X3DImporter::Throw_MoreThanOnceDefined(const std::string& pNodeType, const std::string& pDescription)
|
void X3DImporter::Throw_MoreThanOnceDefined(const std::string& pNodeType, const std::string& pDescription)
|
||||||
|
@ -171,7 +173,7 @@ void X3DImporter::Throw_TagCountIncorrect(const std::string& pNode)
|
||||||
|
|
||||||
void X3DImporter::Throw_USE_NotFound(const std::string& pAttrValue)
|
void X3DImporter::Throw_USE_NotFound(const std::string& pAttrValue)
|
||||||
{
|
{
|
||||||
throw DeadlyImportError(boost::str(boost::format("Not found node with name \"%s\" in <%s>.") % pAttrValue % mReader->getNodeName()));
|
throw DeadlyImportError("Not found node with name \"" + pAttrValue + "\" in <" + std::string(mReader->getNodeName()) + ">.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************************************************************************************/
|
/*********************************************************************************************************************************************/
|
||||||
|
@ -292,10 +294,10 @@ bool close_found = false;
|
||||||
|
|
||||||
casu_cres:
|
casu_cres:
|
||||||
|
|
||||||
if(!found) throw DeadlyImportError(boost::str(boost::format("Unknown node \"%s\" in %s.") % nn % pParentNodeName));
|
if(!found) throw DeadlyImportError("Unknown node \"" + nn + "\" in " + pParentNodeName + ".");
|
||||||
|
|
||||||
if(close_found)
|
if(close_found)
|
||||||
LogInfo(boost::str(boost::format("Skipping node \"%s\" in %s.") % nn % pParentNodeName));
|
LogInfo("Skipping node \"" + nn + "\" in " + pParentNodeName + ".");
|
||||||
else
|
else
|
||||||
Throw_CloseNotFound(nn);
|
Throw_CloseNotFound(nn);
|
||||||
}
|
}
|
||||||
|
@ -441,9 +443,10 @@ const char* tstr_end = tstr + strlen(tstr);
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
int32_t tval32;
|
|
||||||
const char* ostr;
|
const char* ostr;
|
||||||
|
|
||||||
|
int32_t tval32;
|
||||||
|
|
||||||
tval32 = strtol10(tstr, &ostr);
|
tval32 = strtol10(tstr, &ostr);
|
||||||
if(ostr == tstr) break;
|
if(ostr == tstr) break;
|
||||||
|
|
||||||
|
@ -696,13 +699,13 @@ size_t tok_str_len;
|
||||||
|
|
||||||
// find begin of string(element of string list): "sn".
|
// find begin of string(element of string list): "sn".
|
||||||
tbeg = strstr(tok_str, "\"");
|
tbeg = strstr(tok_str, "\"");
|
||||||
if(tbeg == NULL) Throw_IncorrectAttrValue(mReader->getAttributeName(pAttrIdx));
|
if(tbeg == nullptr) Throw_IncorrectAttrValue(mReader->getAttributeName(pAttrIdx));
|
||||||
|
|
||||||
tbeg++;// forward pointer from '\"' symbol to next after it.
|
tbeg++;// forward pointer from '\"' symbol to next after it.
|
||||||
tok_str = tbeg;
|
tok_str = tbeg;
|
||||||
// find end of string(element of string list): "sn".
|
// find end of string(element of string list): "sn".
|
||||||
tend = strstr(tok_str, "\"");
|
tend = strstr(tok_str, "\"");
|
||||||
if(tend == NULL) Throw_IncorrectAttrValue(mReader->getAttributeName(pAttrIdx));
|
if(tend == nullptr) Throw_IncorrectAttrValue(mReader->getAttributeName(pAttrIdx));
|
||||||
|
|
||||||
tok_str = tend + 1;
|
tok_str = tend + 1;
|
||||||
// create storage for new string
|
// create storage for new string
|
||||||
|
@ -850,10 +853,10 @@ unsigned int prim_type = 0;
|
||||||
switch(ts)
|
switch(ts)
|
||||||
{
|
{
|
||||||
case 0: goto mg_m_err;
|
case 0: goto mg_m_err;
|
||||||
case 1: prim_type |= aiPrimitiveType_POINT;
|
case 1: prim_type |= aiPrimitiveType_POINT; break;
|
||||||
case 2: prim_type |= aiPrimitiveType_LINE;
|
case 2: prim_type |= aiPrimitiveType_LINE; break;
|
||||||
case 3: prim_type |= aiPrimitiveType_TRIANGLE;
|
case 3: prim_type |= aiPrimitiveType_TRIANGLE; break;
|
||||||
default: prim_type |= aiPrimitiveType_POLYGON;
|
default: prim_type |= aiPrimitiveType_POLYGON; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
tface.mNumIndices = ts;
|
tface.mNumIndices = ts;
|
||||||
|
@ -899,8 +902,8 @@ std::list<aiColor4D>::const_iterator col_it = pColors.begin();
|
||||||
{
|
{
|
||||||
if(pColors.size() < pMesh.mNumVertices)
|
if(pColors.size() < pMesh.mNumVertices)
|
||||||
{
|
{
|
||||||
throw DeadlyImportError(boost::str(boost::format("MeshGeometry_AddColor1. Colors count(%s) can not be less than Vertices count(%s).") %
|
throw DeadlyImportError("MeshGeometry_AddColor1. Colors count(" + std::to_string(pColors.size()) + ") can not be less than Vertices count(" +
|
||||||
pColors.size() % pMesh.mNumVertices));
|
std::to_string(pMesh.mNumVertices) + ").");
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy colors to mesh
|
// copy colors to mesh
|
||||||
|
@ -911,8 +914,8 @@ std::list<aiColor4D>::const_iterator col_it = pColors.begin();
|
||||||
{
|
{
|
||||||
if(pColors.size() < pMesh.mNumFaces)
|
if(pColors.size() < pMesh.mNumFaces)
|
||||||
{
|
{
|
||||||
throw DeadlyImportError(boost::str(boost::format("MeshGeometry_AddColor1. Colors count(%s) can not be less than Faces count(%s).") %
|
throw DeadlyImportError("MeshGeometry_AddColor1. Colors count(" + std::to_string(pColors.size()) + ") can not be less than Faces count(" +
|
||||||
pColors.size() % pMesh.mNumFaces));
|
std::to_string(pMesh.mNumFaces) + ").");
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy colors to mesh
|
// copy colors to mesh
|
||||||
|
@ -959,8 +962,8 @@ std::vector<aiColor4D> col_arr_copy;
|
||||||
// check indices array count.
|
// check indices array count.
|
||||||
if(pColorIdx.size() < pCoordIdx.size())
|
if(pColorIdx.size() < pCoordIdx.size())
|
||||||
{
|
{
|
||||||
throw DeadlyImportError(boost::str(boost::format("MeshGeometry_AddColor2. Colors indices count(%s) can not be less than Coords inidces count(%s).") %
|
throw DeadlyImportError("MeshGeometry_AddColor2. Colors indices count(" + std::to_string(pColorIdx.size()) +
|
||||||
pColorIdx.size() % pCoordIdx.size()));
|
") can not be less than Coords inidces count(" + std::to_string(pCoordIdx.size()) + ").");
|
||||||
}
|
}
|
||||||
// create list with colors for every vertex.
|
// create list with colors for every vertex.
|
||||||
col_tgt_arr.resize(pMesh.mNumVertices);
|
col_tgt_arr.resize(pMesh.mNumVertices);
|
||||||
|
@ -979,8 +982,8 @@ std::vector<aiColor4D> col_arr_copy;
|
||||||
// check indices array count.
|
// check indices array count.
|
||||||
if(pColors.size() < pMesh.mNumVertices)
|
if(pColors.size() < pMesh.mNumVertices)
|
||||||
{
|
{
|
||||||
throw DeadlyImportError(boost::str(boost::format("MeshGeometry_AddColor2. Colors count(%s) can not be less than Vertices count(%s).") %
|
throw DeadlyImportError("MeshGeometry_AddColor2. Colors count(" + std::to_string(pColors.size()) + ") can not be less than Vertices count(" +
|
||||||
pColors.size() % pMesh.mNumVertices));
|
std::to_string(pMesh.mNumVertices) + ").");
|
||||||
}
|
}
|
||||||
// create list with colors for every vertex.
|
// create list with colors for every vertex.
|
||||||
col_tgt_arr.resize(pMesh.mNumVertices);
|
col_tgt_arr.resize(pMesh.mNumVertices);
|
||||||
|
@ -994,8 +997,8 @@ std::vector<aiColor4D> col_arr_copy;
|
||||||
// check indices array count.
|
// check indices array count.
|
||||||
if(pColorIdx.size() < pMesh.mNumFaces)
|
if(pColorIdx.size() < pMesh.mNumFaces)
|
||||||
{
|
{
|
||||||
throw DeadlyImportError(boost::str(boost::format("MeshGeometry_AddColor2. Colors indices count(%s) can not be less than Faces count(%s).") %
|
throw DeadlyImportError("MeshGeometry_AddColor2. Colors indices count(" + std::to_string(pColorIdx.size()) +
|
||||||
pColorIdx.size() % pMesh.mNumFaces));
|
") can not be less than Faces count(" + std::to_string(pMesh.mNumFaces) + ").");
|
||||||
}
|
}
|
||||||
// create list with colors for every vertex using faces indices.
|
// create list with colors for every vertex using faces indices.
|
||||||
col_tgt_arr.resize(pMesh.mNumFaces);
|
col_tgt_arr.resize(pMesh.mNumFaces);
|
||||||
|
@ -1014,8 +1017,8 @@ std::vector<aiColor4D> col_arr_copy;
|
||||||
// check indices array count.
|
// check indices array count.
|
||||||
if(pColors.size() < pMesh.mNumFaces)
|
if(pColors.size() < pMesh.mNumFaces)
|
||||||
{
|
{
|
||||||
throw DeadlyImportError(boost::str(boost::format("MeshGeometry_AddColor2. Colors count(%s) can not be less than Faces count(%s).") %
|
throw DeadlyImportError("MeshGeometry_AddColor2. Colors count(" + std::to_string(pColors.size()) + ") can not be less than Faces count(" +
|
||||||
pColors.size() % pMesh.mNumFaces));
|
std::to_string(pMesh.mNumFaces) + ").");
|
||||||
}
|
}
|
||||||
// create list with colors for every vertex using faces indices.
|
// create list with colors for every vertex using faces indices.
|
||||||
col_tgt_arr.resize(pMesh.mNumFaces);
|
col_tgt_arr.resize(pMesh.mNumFaces);
|
||||||
|
@ -1067,8 +1070,8 @@ std::vector<aiVector3D> norm_arr_copy;
|
||||||
for(size_t i = 0; (i < pMesh.mNumVertices) && (i < tind.size()); i++)
|
for(size_t i = 0; (i < pMesh.mNumVertices) && (i < tind.size()); i++)
|
||||||
{
|
{
|
||||||
if(tind[i] >= norm_arr_copy.size())
|
if(tind[i] >= norm_arr_copy.size())
|
||||||
throw DeadlyImportError(boost::str(boost::format("MeshGeometry_AddNormal. Normal index(%s) is out of range. Normals count: %s.") %
|
throw DeadlyImportError("MeshGeometry_AddNormal. Normal index(" + std::to_string(tind[i]) +
|
||||||
tind[i] % norm_arr_copy.size()));
|
") is out of range. Normals count: " + std::to_string(norm_arr_copy.size()) + ".");
|
||||||
|
|
||||||
pMesh.mNormals[i] = norm_arr_copy[tind[i]];
|
pMesh.mNormals[i] = norm_arr_copy[tind[i]];
|
||||||
}
|
}
|
||||||
|
@ -1162,7 +1165,7 @@ unsigned int prim_type;
|
||||||
for(size_t fi = 0, fi_e = faces.size(); fi < fi_e; fi++)
|
for(size_t fi = 0, fi_e = faces.size(); fi < fi_e; fi++)
|
||||||
{
|
{
|
||||||
if(pMesh.mFaces[fi].mNumIndices != faces.at(fi).mNumIndices)
|
if(pMesh.mFaces[fi].mNumIndices != faces.at(fi).mNumIndices)
|
||||||
throw DeadlyImportError(boost::str(boost::format("Number of indices in texture face and mesh face must be equal. Invalid face index: %s") % fi));
|
throw DeadlyImportError("Number of indices in texture face and mesh face must be equal. Invalid face index: " + std::to_string(fi) + ".");
|
||||||
|
|
||||||
for(size_t ii = 0; ii < pMesh.mFaces[fi].mNumIndices; ii++)
|
for(size_t ii = 0; ii < pMesh.mFaces[fi].mNumIndices; ii++)
|
||||||
{
|
{
|
||||||
|
@ -1234,7 +1237,7 @@ void X3DImporter::ParseHelper_Group_Begin(const bool pStatic)
|
||||||
CX3DImporter_NodeElement_Group* new_group = new CX3DImporter_NodeElement_Group(NodeElement_Cur, pStatic);// create new node with current node as parent.
|
CX3DImporter_NodeElement_Group* new_group = new CX3DImporter_NodeElement_Group(NodeElement_Cur, pStatic);// create new node with current node as parent.
|
||||||
|
|
||||||
// if we are adding not the root element then add new element to current element child list.
|
// if we are adding not the root element then add new element to current element child list.
|
||||||
if(NodeElement_Cur != NULL) NodeElement_Cur->Child.push_back(new_group);
|
if(NodeElement_Cur != nullptr) NodeElement_Cur->Child.push_back(new_group);
|
||||||
|
|
||||||
NodeElement_List.push_back(new_group);// it's a new element - add it to list.
|
NodeElement_List.push_back(new_group);// it's a new element - add it to list.
|
||||||
NodeElement_Cur = new_group;// switch current element to new one.
|
NodeElement_Cur = new_group;// switch current element to new one.
|
||||||
|
@ -1249,7 +1252,7 @@ void X3DImporter::ParseHelper_Node_Enter(CX3DImporter_NodeElement* pNode)
|
||||||
void X3DImporter::ParseHelper_Node_Exit()
|
void X3DImporter::ParseHelper_Node_Exit()
|
||||||
{
|
{
|
||||||
// check if we can walk up.
|
// check if we can walk up.
|
||||||
if(NodeElement_Cur != NULL) NodeElement_Cur = NodeElement_Cur->Parent;
|
if(NodeElement_Cur != nullptr) NodeElement_Cur = NodeElement_Cur->Parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
void X3DImporter::ParseHelper_FixTruncatedFloatString(const char* pInStr, std::string& pOutString)
|
void X3DImporter::ParseHelper_FixTruncatedFloatString(const char* pInStr, std::string& pOutString)
|
||||||
|
@ -1282,12 +1285,12 @@ size_t instr_len;
|
||||||
void X3DImporter::ParseFile(const std::string& pFile, IOSystem* pIOHandler)
|
void X3DImporter::ParseFile(const std::string& pFile, IOSystem* pIOHandler)
|
||||||
{
|
{
|
||||||
irr::io::IrrXMLReader* OldReader = mReader;// store current XMLreader.
|
irr::io::IrrXMLReader* OldReader = mReader;// store current XMLreader.
|
||||||
boost::scoped_ptr<IOStream> file(pIOHandler->Open(pFile, "rb"));
|
std::unique_ptr<IOStream> file(pIOHandler->Open(pFile, "rb"));
|
||||||
|
|
||||||
// Check whether we can read from the file
|
// Check whether we can read from the file
|
||||||
if(file.get() == NULL) throw DeadlyImportError("Failed to open X3D file " + pFile + ".");
|
if(file.get() == nullptr) throw DeadlyImportError("Failed to open X3D file " + pFile + ".");
|
||||||
// generate a XML reader for it
|
// generate a XML reader for it
|
||||||
boost::scoped_ptr<CIrrXML_IOStreamReader> mIOWrapper(new CIrrXML_IOStreamReader(file.get()));
|
std::unique_ptr<CIrrXML_IOStreamReader> mIOWrapper(new CIrrXML_IOStreamReader(file.get()));
|
||||||
mReader = irr::io::createIrrXMLReader(mIOWrapper.get());
|
mReader = irr::io::createIrrXMLReader(mIOWrapper.get());
|
||||||
if(!mReader) throw DeadlyImportError("Failed to create XML reader for file" + pFile + ".");
|
if(!mReader) throw DeadlyImportError("Failed to create XML reader for file" + pFile + ".");
|
||||||
// start reading
|
// start reading
|
||||||
|
@ -1346,7 +1349,8 @@ bool close_found = false;// flag: true if close tag of node are found.
|
||||||
{
|
{
|
||||||
ms->Value.push_back(mReader->getAttributeValueSafe("content"));
|
ms->Value.push_back(mReader->getAttributeValueSafe("content"));
|
||||||
NodeElement_List.push_back(ms);
|
NodeElement_List.push_back(ms);
|
||||||
if(NodeElement_Cur != NULL) NodeElement_Cur->Child.push_back(ms);
|
if(NodeElement_Cur != nullptr) NodeElement_Cur->Child.push_back(ms);
|
||||||
|
|
||||||
}
|
}
|
||||||
}// if(XML_CheckNode_NameEqual("meta"))
|
}// if(XML_CheckNode_NameEqual("meta"))
|
||||||
}// if(mReader->getNodeType() == irr::io::EXN_ELEMENT)
|
}// if(mReader->getNodeType() == irr::io::EXN_ELEMENT)
|
||||||
|
@ -1510,11 +1514,11 @@ void X3DImporter::InternReadFile(const std::string& pFile, aiScene* pScene, IOSy
|
||||||
//
|
//
|
||||||
// at first creating root node for aiScene.
|
// at first creating root node for aiScene.
|
||||||
pScene->mRootNode = new aiNode;
|
pScene->mRootNode = new aiNode;
|
||||||
pScene->mRootNode->mParent = NULL;
|
pScene->mRootNode->mParent = nullptr;
|
||||||
|
pScene->mFlags |= AI_SCENE_FLAGS_ALLOW_SHARED;
|
||||||
//search for root node element
|
//search for root node element
|
||||||
NodeElement_Cur = NodeElement_List.front();
|
NodeElement_Cur = NodeElement_List.front();
|
||||||
while(NodeElement_Cur->Parent != NULL) NodeElement_Cur = NodeElement_Cur->Parent;
|
while(NodeElement_Cur->Parent != nullptr) NodeElement_Cur = NodeElement_Cur->Parent;
|
||||||
|
|
||||||
{// fill aiScene with objects.
|
{// fill aiScene with objects.
|
||||||
std::list<aiMesh*> mesh_list;
|
std::list<aiMesh*> mesh_list;
|
||||||
|
|
|
@ -1,25 +1,22 @@
|
||||||
/// \file X3DImporter.hpp
|
/// \file X3DImporter.hpp
|
||||||
/// \brief X3D-format files importer for Assimp.
|
/// \brief X3D-format files importer for Assimp.
|
||||||
/// \date 2015-2016
|
/// \date 2015-2016
|
||||||
/// \author nevorek@gmail.com
|
/// \author smal.root@gmail.com
|
||||||
|
// Thanks to acorn89 for support.
|
||||||
|
|
||||||
#ifndef INCLUDED_AI_X3D_IMPORTER_H
|
#ifndef INCLUDED_AI_X3D_IMPORTER_H
|
||||||
#define INCLUDED_AI_X3D_IMPORTER_H
|
#define INCLUDED_AI_X3D_IMPORTER_H
|
||||||
|
|
||||||
// Pay attention - you must include some files from Assimp before including BaseImporter.h.
|
#include "X3DImporter_Node.hpp"
|
||||||
// magic region begin
|
|
||||||
#include <set>
|
|
||||||
|
|
||||||
#include "../include/assimp/DefaultLogger.hpp"
|
// Header files, Assimp.
|
||||||
#include "../include/assimp/importerdesc.h"
|
#include "assimp/DefaultLogger.hpp"
|
||||||
#include "../include/assimp/ProgressHandler.hpp"
|
#include "assimp/importerdesc.h"
|
||||||
#include "../include/assimp/types.h"
|
#include "assimp/ProgressHandler.hpp"
|
||||||
// magic region end
|
#include "assimp/types.h"
|
||||||
#include "BaseImporter.h"
|
#include "BaseImporter.h"
|
||||||
#include "irrXMLWrapper.h"
|
#include "irrXMLWrapper.h"
|
||||||
|
|
||||||
#include "X3DImporter_Node.hpp"
|
|
||||||
|
|
||||||
namespace Assimp
|
namespace Assimp
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -147,7 +144,7 @@ namespace Assimp
|
||||||
/// duplicates of it )).
|
/// duplicates of it )).
|
||||||
///
|
///
|
||||||
/// Color for faces.
|
/// Color for faces.
|
||||||
/// That's happening when attribute "colorPerVertex" is set to "false". But Assimp do not hold how many colors has mesh and reuire
|
/// That's happening when attribute "colorPerVertex" is set to "false". But Assimp do not hold how many colors has mesh and require
|
||||||
/// equal length for mVertices and mColors. You will see the colors but vertices will use call which last used in "colorIdx".
|
/// equal length for mVertices and mColors. You will see the colors but vertices will use call which last used in "colorIdx".
|
||||||
///
|
///
|
||||||
/// That's all for now. Enjoy
|
/// That's all for now. Enjoy
|
||||||
|
@ -264,19 +261,19 @@ private:
|
||||||
/// Create filled structure with type \ref aiMaterial from \ref CX3DImporter_NodeElement. This function itseld extract
|
/// Create filled structure with type \ref aiMaterial from \ref CX3DImporter_NodeElement. This function itseld extract
|
||||||
/// all needed data from scene graph.
|
/// all needed data from scene graph.
|
||||||
/// \param [in] pNodeElement - reference to material element(<Appearance>).
|
/// \param [in] pNodeElement - reference to material element(<Appearance>).
|
||||||
/// \param [out] pMaterial - pointer to pointer to created material. *pMaterial must be NULL.
|
/// \param [out] pMaterial - pointer to pointer to created material. *pMaterial must be nullptr.
|
||||||
void Postprocess_BuildMaterial(const CX3DImporter_NodeElement& pNodeElement, aiMaterial** pMaterial) const;
|
void Postprocess_BuildMaterial(const CX3DImporter_NodeElement& pNodeElement, aiMaterial** pMaterial) const;
|
||||||
|
|
||||||
/// \fn void Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeElement, aiMesh** pMesh) const
|
/// \fn void Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeElement, aiMesh** pMesh) const
|
||||||
/// Create filled structure with type \ref aiMaterial from \ref CX3DImporter_NodeElement. This function itseld extract
|
/// Create filled structure with type \ref aiMaterial from \ref CX3DImporter_NodeElement. This function itseld extract
|
||||||
/// all needed data from scene graph.
|
/// all needed data from scene graph.
|
||||||
/// \param [in] pNodeElement - reference to geometry object.
|
/// \param [in] pNodeElement - reference to geometry object.
|
||||||
/// \param [out] pMesh - pointer to pointer to created mesh. *pMesh must be NULL.
|
/// \param [out] pMesh - pointer to pointer to created mesh. *pMesh must be nullptr.
|
||||||
void Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeElement, aiMesh** pMesh) const;
|
void Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeElement, aiMesh** pMesh) const;
|
||||||
|
|
||||||
/// \fn void Postprocess_BuildNode(const CX3DImporter_NodeElement& pNodeElement, aiNode& pSceneNode, std::list<aiMesh*>& pSceneMeshList, std::list<aiMaterial*>& pSceneMaterialList, std::list<aiLight*>& pSceneLightList) const
|
/// \fn void Postprocess_BuildNode(const CX3DImporter_NodeElement& pNodeElement, aiNode& pSceneNode, std::list<aiMesh*>& pSceneMeshList, std::list<aiMaterial*>& pSceneMaterialList, std::list<aiLight*>& pSceneLightList) const
|
||||||
/// Create aiNode from CX3DImporter_NodeElement. Also function check children and make recursive call.
|
/// Create aiNode from CX3DImporter_NodeElement. Also function check children and make recursive call.
|
||||||
/// \param [out] pNode - pointer to pointer to created node. *pNode must be NULL.
|
/// \param [out] pNode - pointer to pointer to created node. *pNode must be nullptr.
|
||||||
/// \param [in] pNodeElement - CX3DImporter_NodeElement which read.
|
/// \param [in] pNodeElement - CX3DImporter_NodeElement which read.
|
||||||
/// \param [out] pSceneNode - aiNode for filling.
|
/// \param [out] pSceneNode - aiNode for filling.
|
||||||
/// \param [out] pSceneMeshList - list with aiMesh which belong to scene.
|
/// \param [out] pSceneMeshList - list with aiMesh which belong to scene.
|
||||||
|
@ -920,7 +917,7 @@ public:
|
||||||
/// \fn X3DImporter()
|
/// \fn X3DImporter()
|
||||||
/// Default constructor.
|
/// Default constructor.
|
||||||
X3DImporter()
|
X3DImporter()
|
||||||
: NodeElement_Cur(NULL), mReader(NULL)
|
: NodeElement_Cur(nullptr), mReader(nullptr)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/// \fn ~X3DImporter()
|
/// \fn ~X3DImporter()
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/// \file X3DImporter_Geometry2D.cpp
|
/// \file X3DImporter_Geometry2D.cpp
|
||||||
/// \brief Parsing data from nodes of "Geometry2D" set of X3D.
|
/// \brief Parsing data from nodes of "Geometry2D" set of X3D.
|
||||||
/// \date 2015-2016
|
/// \date 2015-2016
|
||||||
/// \author nevorek@gmail.com
|
/// \author smal.root@gmail.com
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_X3D_IMPORTER
|
#ifndef ASSIMP_BUILD_NO_X3D_IMPORTER
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
/// \file X3DImporter_Geometry3D.cpp
|
/// \file X3DImporter_Geometry3D.cpp
|
||||||
/// \brief Parsing data from nodes of "Geometry3D" set of X3D.
|
/// \brief Parsing data from nodes of "Geometry3D" set of X3D.
|
||||||
/// \date 2015-2016
|
/// \date 2015-2016
|
||||||
/// \author nevorek@gmail.com
|
/// \author smal.root@gmail.com
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_X3D_IMPORTER
|
#ifndef ASSIMP_BUILD_NO_X3D_IMPORTER
|
||||||
|
|
||||||
#include "X3DImporter.hpp"
|
#include "X3DImporter.hpp"
|
||||||
#include "X3DImporter_Macro.hpp"
|
#include "X3DImporter_Macro.hpp"
|
||||||
|
|
||||||
|
// Header files, Assimp.
|
||||||
#include "StandardShapes.h"
|
#include "StandardShapes.h"
|
||||||
|
|
||||||
namespace Assimp
|
namespace Assimp
|
||||||
|
@ -94,6 +96,7 @@ CX3DImporter_NodeElement* ne;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const unsigned int tess = 30;///TODO: IME tesselation factor thru ai_property
|
const unsigned int tess = 30;///TODO: IME tesselation factor thru ai_property
|
||||||
|
|
||||||
std::vector<aiVector3D> tvec;// temp array for vertices.
|
std::vector<aiVector3D> tvec;// temp array for vertices.
|
||||||
|
|
||||||
// create and if needed - define new geometry object.
|
// create and if needed - define new geometry object.
|
||||||
|
@ -166,6 +169,7 @@ CX3DImporter_NodeElement* ne;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const unsigned int tess = 30;///TODO: IME tesselation factor thru ai_property
|
const unsigned int tess = 30;///TODO: IME tesselation factor thru ai_property
|
||||||
|
|
||||||
std::vector<aiVector3D> tside;// temp array for vertices of side.
|
std::vector<aiVector3D> tside;// temp array for vertices of side.
|
||||||
std::vector<aiVector3D> tcir;// temp array for vertices of circle.
|
std::vector<aiVector3D> tcir;// temp array for vertices of circle.
|
||||||
|
|
||||||
|
@ -419,6 +423,7 @@ size_t cur_sz = pCurve.size();
|
||||||
static aiVector3D GeometryHelper_Extrusion_GetNextY(const size_t pSpine_PointIdx, const std::vector<aiVector3D>& pSpine, const bool pSpine_Closed)
|
static aiVector3D GeometryHelper_Extrusion_GetNextY(const size_t pSpine_PointIdx, const std::vector<aiVector3D>& pSpine, const bool pSpine_Closed)
|
||||||
{
|
{
|
||||||
const size_t spine_idx_last = pSpine.size() - 1;
|
const size_t spine_idx_last = pSpine.size() - 1;
|
||||||
|
|
||||||
aiVector3D tvec;
|
aiVector3D tvec;
|
||||||
|
|
||||||
if((pSpine_PointIdx == 0) || (pSpine_PointIdx == spine_idx_last))// at first special cases
|
if((pSpine_PointIdx == 0) || (pSpine_PointIdx == spine_idx_last))// at first special cases
|
||||||
|
@ -453,6 +458,7 @@ static aiVector3D GeometryHelper_Extrusion_GetNextZ(const size_t pSpine_PointIdx
|
||||||
{
|
{
|
||||||
const aiVector3D zero_vec(0);
|
const aiVector3D zero_vec(0);
|
||||||
const size_t spine_idx_last = pSpine.size() - 1;
|
const size_t spine_idx_last = pSpine.size() - 1;
|
||||||
|
|
||||||
aiVector3D tvec;
|
aiVector3D tvec;
|
||||||
|
|
||||||
// at first special cases
|
// at first special cases
|
||||||
|
@ -916,6 +922,7 @@ CX3DImporter_NodeElement* ne;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const unsigned int tess = 3;///TODO: IME tesselation factor thru ai_property
|
const unsigned int tess = 3;///TODO: IME tesselation factor thru ai_property
|
||||||
|
|
||||||
std::vector<aiVector3D> tlist;
|
std::vector<aiVector3D> tlist;
|
||||||
|
|
||||||
// create and if needed - define new geometry object.
|
// create and if needed - define new geometry object.
|
||||||
|
@ -941,7 +948,6 @@ CX3DImporter_NodeElement* ne;
|
||||||
}// if(!use.empty()) else
|
}// if(!use.empty()) else
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}// namespace Assimp
|
}// namespace Assimp
|
||||||
|
|
||||||
#endif // !ASSIMP_BUILD_NO_X3D_IMPORTER
|
#endif // !ASSIMP_BUILD_NO_X3D_IMPORTER
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/// \file X3DImporter_Group.cpp
|
/// \file X3DImporter_Group.cpp
|
||||||
/// \brief Parsing data from nodes of "Grouping" set of X3D.
|
/// \brief Parsing data from nodes of "Grouping" set of X3D.
|
||||||
/// \date 2015-2016
|
/// \date 2015-2016
|
||||||
/// \author nevorek@gmail.com
|
/// \author smal.root@gmail.com
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_X3D_IMPORTER
|
#ifndef ASSIMP_BUILD_NO_X3D_IMPORTER
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
/// \file X3DImporter_Light.cpp
|
/// \file X3DImporter_Light.cpp
|
||||||
/// \brief Parsing data from nodes of "Lighting" set of X3D.
|
/// \brief Parsing data from nodes of "Lighting" set of X3D.
|
||||||
/// \date 2015-2016
|
/// \date 2015-2016
|
||||||
/// \author nevorek@gmail.com
|
/// \author smal.root@gmail.com
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_X3D_IMPORTER
|
#ifndef ASSIMP_BUILD_NO_X3D_IMPORTER
|
||||||
|
|
||||||
#include "X3DImporter.hpp"
|
#include "X3DImporter.hpp"
|
||||||
#include "X3DImporter_Macro.hpp"
|
#include "X3DImporter_Macro.hpp"
|
||||||
|
|
||||||
#include <boost/format.hpp>
|
|
||||||
|
|
||||||
namespace Assimp
|
namespace Assimp
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -58,7 +56,7 @@ CX3DImporter_NodeElement* ne;
|
||||||
if(!def.empty())
|
if(!def.empty())
|
||||||
ne->ID = def;
|
ne->ID = def;
|
||||||
else
|
else
|
||||||
ne->ID = boost::str(boost::format("DirectionalLight_%s") % (size_t)ne);// make random name
|
ne->ID = "DirectionalLight_" + std::to_string((size_t)ne);// make random name
|
||||||
|
|
||||||
((CX3DImporter_NodeElement_Light*)ne)->AmbientIntensity = ambientIntensity;
|
((CX3DImporter_NodeElement_Light*)ne)->AmbientIntensity = ambientIntensity;
|
||||||
((CX3DImporter_NodeElement_Light*)ne)->Color = color;
|
((CX3DImporter_NodeElement_Light*)ne)->Color = color;
|
||||||
|
@ -141,7 +139,7 @@ CX3DImporter_NodeElement* ne;
|
||||||
// Assimp want a node with name similar to a light. "Why? I don't no." )
|
// Assimp want a node with name similar to a light. "Why? I don't no." )
|
||||||
ParseHelper_Group_Begin(false);
|
ParseHelper_Group_Begin(false);
|
||||||
// make random name
|
// make random name
|
||||||
if(ne->ID.empty()) ne->ID = boost::str(boost::format("PointLight_%s") % (size_t)ne);
|
if(ne->ID.empty()) ne->ID = "PointLight_" + std::to_string((size_t)ne);
|
||||||
|
|
||||||
NodeElement_Cur->ID = ne->ID;// assign name to node and return to light element.
|
NodeElement_Cur->ID = ne->ID;// assign name to node and return to light element.
|
||||||
ParseHelper_Node_Exit();
|
ParseHelper_Node_Exit();
|
||||||
|
@ -231,7 +229,7 @@ CX3DImporter_NodeElement* ne;
|
||||||
// Assimp want a node with name similar to a light. "Why? I don't no." )
|
// Assimp want a node with name similar to a light. "Why? I don't no." )
|
||||||
ParseHelper_Group_Begin(false);
|
ParseHelper_Group_Begin(false);
|
||||||
// make random name
|
// make random name
|
||||||
if(ne->ID.empty()) ne->ID = boost::str(boost::format("SpotLight_%s") % (size_t)ne);
|
if(ne->ID.empty()) ne->ID = "SpotLight_" + std::to_string((size_t)ne);
|
||||||
|
|
||||||
NodeElement_Cur->ID = ne->ID;// assign name to node and return to light element.
|
NodeElement_Cur->ID = ne->ID;// assign name to node and return to light element.
|
||||||
ParseHelper_Node_Exit();
|
ParseHelper_Node_Exit();
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/// \file X3DImporter_Metadata.cpp
|
/// \file X3DImporter_Metadata.cpp
|
||||||
/// \brief Parsing data from nodes of "Metadata" set of X3D.
|
/// \brief Parsing data from nodes of "Metadata" set of X3D.
|
||||||
/// \date 2015-2016
|
/// \date 2015-2016
|
||||||
/// \author nevorek@gmail.com
|
/// \author smal.root@gmail.com
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_X3D_IMPORTER
|
#ifndef ASSIMP_BUILD_NO_X3D_IMPORTER
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
/// \file X3DImporter_Rendering.cpp
|
/// \file X3DImporter_Networking.cpp
|
||||||
/// \brief Parsing data from nodes of "Networking" set of X3D.
|
/// \brief Parsing data from nodes of "Networking" set of X3D.
|
||||||
/// \date 2015-2016
|
/// \date 2015-2016
|
||||||
/// \author nevorek@gmail.com
|
/// \author smal.root@gmail.com
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_X3D_IMPORTER
|
#ifndef ASSIMP_BUILD_NO_X3D_IMPORTER
|
||||||
|
|
||||||
#include "X3DImporter.hpp"
|
#include "X3DImporter.hpp"
|
||||||
#include "X3DImporter_Macro.hpp"
|
#include "X3DImporter_Macro.hpp"
|
||||||
|
|
||||||
|
// Header files, Assimp.
|
||||||
#include "DefaultIOSystem.h"
|
#include "DefaultIOSystem.h"
|
||||||
|
|
||||||
namespace Assimp
|
namespace Assimp
|
||||||
|
|
|
@ -1,17 +1,19 @@
|
||||||
/// \file X3DImporter_Node.hpp
|
/// \file X3DImporter_Node.hpp
|
||||||
/// \brief Elements of scene graph.
|
/// \brief Elements of scene graph.
|
||||||
/// \date 2015-2016
|
/// \date 2015-2016
|
||||||
/// \author nevorek@gmail.com
|
/// \author smal.root@gmail.com
|
||||||
|
|
||||||
#ifndef INCLUDED_AI_X3D_IMPORTER_NODE_H
|
#ifndef INCLUDED_AI_X3D_IMPORTER_NODE_H
|
||||||
#define INCLUDED_AI_X3D_IMPORTER_NODE_H
|
#define INCLUDED_AI_X3D_IMPORTER_NODE_H
|
||||||
|
|
||||||
|
// Header files, Assimp.
|
||||||
|
#include "assimp/scene.h"
|
||||||
|
#include "assimp/types.h"
|
||||||
|
|
||||||
|
// Header files, stdlib.
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "../include/assimp/types.h"
|
|
||||||
#include "../include/assimp/scene.h"
|
|
||||||
|
|
||||||
/// \class CX3DImporter_NodeElement
|
/// \class CX3DImporter_NodeElement
|
||||||
/// Base class for elements of nodes.
|
/// Base class for elements of nodes.
|
||||||
class CX3DImporter_NodeElement
|
class CX3DImporter_NodeElement
|
||||||
|
@ -89,7 +91,7 @@ public:
|
||||||
public:
|
public:
|
||||||
|
|
||||||
std::string ID;///< ID of the element. Can be empty. In X3D synonym for "ID" attribute.
|
std::string ID;///< ID of the element. Can be empty. In X3D synonym for "ID" attribute.
|
||||||
CX3DImporter_NodeElement* Parent;///< Parrent element. If NULL then this node is root.
|
CX3DImporter_NodeElement* Parent;///< Parrent element. If nullptr then this node is root.
|
||||||
std::list<CX3DImporter_NodeElement*> Child;///< Child elements.
|
std::list<CX3DImporter_NodeElement*> Child;///< Child elements.
|
||||||
|
|
||||||
/***********************************************/
|
/***********************************************/
|
||||||
|
|
|
@ -1,18 +1,19 @@
|
||||||
/// \file X3DImporter_Postprocess.cpp
|
/// \file X3DImporter_Postprocess.cpp
|
||||||
/// \brief Convert built scenegraph and objects to Assimp scenegraph.
|
/// \brief Convert built scenegraph and objects to Assimp scenegraph.
|
||||||
/// \date 2015-2016
|
/// \date 2015-2016
|
||||||
/// \author nevorek@gmail.com
|
/// \author smal.root@gmail.com
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_X3D_IMPORTER
|
#ifndef ASSIMP_BUILD_NO_X3D_IMPORTER
|
||||||
|
|
||||||
#include "X3DImporter.hpp"
|
#include "X3DImporter.hpp"
|
||||||
|
|
||||||
|
// Header files, Assimp.
|
||||||
#include "StandardShapes.h"
|
#include "StandardShapes.h"
|
||||||
|
|
||||||
#include <boost/format.hpp>
|
// Header files, stdlib.
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace Assimp
|
namespace Assimp
|
||||||
{
|
{
|
||||||
|
@ -25,7 +26,7 @@ aiMatrix4x4 out_matr;
|
||||||
|
|
||||||
// starting walk from current element to root
|
// starting walk from current element to root
|
||||||
cur_node = NodeElement_Cur;
|
cur_node = NodeElement_Cur;
|
||||||
if(cur_node != NULL)
|
if(cur_node != nullptr)
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
@ -33,7 +34,7 @@ aiMatrix4x4 out_matr;
|
||||||
if(cur_node->Type == CX3DImporter_NodeElement::ENET_Group) matr.push_back(((CX3DImporter_NodeElement_Group*)cur_node)->Transformation);
|
if(cur_node->Type == CX3DImporter_NodeElement::ENET_Group) matr.push_back(((CX3DImporter_NodeElement_Group*)cur_node)->Transformation);
|
||||||
|
|
||||||
cur_node = cur_node->Parent;
|
cur_node = cur_node->Parent;
|
||||||
} while(cur_node != NULL);
|
} while(cur_node != nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// multiplicate all matrices in reverse order
|
// multiplicate all matrices in reverse order
|
||||||
|
@ -99,9 +100,9 @@ bool X3DImporter::PostprocessHelper_ElementIsMesh(const CX3DImporter_NodeElement
|
||||||
|
|
||||||
void X3DImporter::Postprocess_BuildLight(const CX3DImporter_NodeElement& pNodeElement, std::list<aiLight*>& pSceneLightList) const
|
void X3DImporter::Postprocess_BuildLight(const CX3DImporter_NodeElement& pNodeElement, std::list<aiLight*>& pSceneLightList) const
|
||||||
{
|
{
|
||||||
aiLight* new_light = new aiLight;
|
|
||||||
const CX3DImporter_NodeElement_Light& ne = *((CX3DImporter_NodeElement_Light*)&pNodeElement);
|
const CX3DImporter_NodeElement_Light& ne = *((CX3DImporter_NodeElement_Light*)&pNodeElement);
|
||||||
aiMatrix4x4 transform_matr = PostprocessHelper_Matrix_GlobalToCurrent();
|
aiMatrix4x4 transform_matr = PostprocessHelper_Matrix_GlobalToCurrent();
|
||||||
|
aiLight* new_light = new aiLight;
|
||||||
|
|
||||||
new_light->mName = ne.ID;
|
new_light->mName = ne.ID;
|
||||||
new_light->mColorAmbient = ne.Color * ne.AmbientIntensity;
|
new_light->mColorAmbient = ne.Color * ne.AmbientIntensity;
|
||||||
|
@ -134,7 +135,7 @@ aiMatrix4x4 transform_matr = PostprocessHelper_Matrix_GlobalToCurrent();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw DeadlyImportError(boost::str(boost::format("Postprocess_BuildLight. Unknown type of light: %s") % pNodeElement.Type));
|
throw DeadlyImportError("Postprocess_BuildLight. Unknown type of light: " + std::to_string(pNodeElement.Type) + ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
pSceneLightList.push_back(new_light);
|
pSceneLightList.push_back(new_light);
|
||||||
|
@ -143,8 +144,8 @@ aiMatrix4x4 transform_matr = PostprocessHelper_Matrix_GlobalToCurrent();
|
||||||
void X3DImporter::Postprocess_BuildMaterial(const CX3DImporter_NodeElement& pNodeElement, aiMaterial** pMaterial) const
|
void X3DImporter::Postprocess_BuildMaterial(const CX3DImporter_NodeElement& pNodeElement, aiMaterial** pMaterial) const
|
||||||
{
|
{
|
||||||
// check argument
|
// check argument
|
||||||
if(pMaterial == NULL) throw DeadlyImportError("Postprocess_BuildMaterial. pMaterial is NULL.");
|
if(pMaterial == nullptr) throw DeadlyImportError("Postprocess_BuildMaterial. pMaterial is nullptr.");
|
||||||
if(*pMaterial != NULL) throw DeadlyImportError("Postprocess_BuildMaterial. *pMaterial must be NULL.");
|
if(*pMaterial != nullptr) throw DeadlyImportError("Postprocess_BuildMaterial. *pMaterial must be nullptr.");
|
||||||
|
|
||||||
*pMaterial = new aiMaterial;
|
*pMaterial = new aiMaterial;
|
||||||
aiMaterial& taimat = **pMaterial;// creating alias for convenience.
|
aiMaterial& taimat = **pMaterial;// creating alias for convenience.
|
||||||
|
@ -196,8 +197,8 @@ void X3DImporter::Postprocess_BuildMaterial(const CX3DImporter_NodeElement& pNod
|
||||||
void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeElement, aiMesh** pMesh) const
|
void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeElement, aiMesh** pMesh) const
|
||||||
{
|
{
|
||||||
// check argument
|
// check argument
|
||||||
if(pMesh == NULL) throw DeadlyImportError("Postprocess_BuildMesh. pMesh is NULL.");
|
if(pMesh == nullptr) throw DeadlyImportError("Postprocess_BuildMesh. pMesh is nullptr.");
|
||||||
if(*pMesh != NULL) throw DeadlyImportError("Postprocess_BuildMesh. *pMesh must be NULL.");
|
if(*pMesh != nullptr) throw DeadlyImportError("Postprocess_BuildMesh. *pMesh must be nullptr.");
|
||||||
|
|
||||||
/************************************************************************************************************************************/
|
/************************************************************************************************************************************/
|
||||||
/************************************************************ Geometry2D ************************************************************/
|
/************************************************************ Geometry2D ************************************************************/
|
||||||
|
@ -256,7 +257,7 @@ void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeEle
|
||||||
else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_TextureCoordinate)
|
else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_TextureCoordinate)
|
||||||
MeshGeometry_AddTexCoord(**pMesh, ((CX3DImporter_NodeElement_TextureCoordinate*)*ch_it)->Value);
|
MeshGeometry_AddTexCoord(**pMesh, ((CX3DImporter_NodeElement_TextureCoordinate*)*ch_it)->Value);
|
||||||
else
|
else
|
||||||
throw DeadlyImportError(boost::str(boost::format("Postprocess_BuildMesh. Unknown child of ElevationGrid: %s.") % (*ch_it)->Type));
|
throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of ElevationGrid: " + std::to_string((*ch_it)->Type) + ".");
|
||||||
}// for(std::list<CX3DImporter_NodeElement*>::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++)
|
}// for(std::list<CX3DImporter_NodeElement*>::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++)
|
||||||
|
|
||||||
return;// mesh is build, nothing to do anymore.
|
return;// mesh is build, nothing to do anymore.
|
||||||
|
@ -293,7 +294,7 @@ void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeEle
|
||||||
else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_TextureCoordinate)
|
else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_TextureCoordinate)
|
||||||
MeshGeometry_AddTexCoord(**pMesh, tnemesh.CoordIndex, tnemesh.TexCoordIndex, ((CX3DImporter_NodeElement_TextureCoordinate*)*ch_it)->Value);
|
MeshGeometry_AddTexCoord(**pMesh, tnemesh.CoordIndex, tnemesh.TexCoordIndex, ((CX3DImporter_NodeElement_TextureCoordinate*)*ch_it)->Value);
|
||||||
else
|
else
|
||||||
throw DeadlyImportError(boost::str(boost::format("Postprocess_BuildMesh. Unknown child of IndexedFaceSet: %s.") % (*ch_it)->Type));
|
throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of IndexedFaceSet: " + std::to_string((*ch_it)->Type) + ".");
|
||||||
}// for(std::list<CX3DImporter_NodeElement*>::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++)
|
}// for(std::list<CX3DImporter_NodeElement*>::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++)
|
||||||
|
|
||||||
return;// mesh is build, nothing to do anymore.
|
return;// mesh is build, nothing to do anymore.
|
||||||
|
@ -323,7 +324,7 @@ void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeEle
|
||||||
else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Coordinate)
|
else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Coordinate)
|
||||||
{} // skip because already read when mesh created.
|
{} // skip because already read when mesh created.
|
||||||
else
|
else
|
||||||
throw DeadlyImportError(boost::str(boost::format("Postprocess_BuildMesh. Unknown child of IndexedLineSet: %s.") % (*ch_it)->Type));
|
throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of IndexedLineSet: " + std::to_string((*ch_it)->Type) + ".");
|
||||||
}// for(std::list<CX3DImporter_NodeElement*>::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++)
|
}// for(std::list<CX3DImporter_NodeElement*>::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++)
|
||||||
|
|
||||||
return;// mesh is build, nothing to do anymore.
|
return;// mesh is build, nothing to do anymore.
|
||||||
|
@ -360,8 +361,8 @@ void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeEle
|
||||||
else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_TextureCoordinate)
|
else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_TextureCoordinate)
|
||||||
MeshGeometry_AddTexCoord(**pMesh, tnemesh.CoordIndex, tnemesh.TexCoordIndex, ((CX3DImporter_NodeElement_TextureCoordinate*)*ch_it)->Value);
|
MeshGeometry_AddTexCoord(**pMesh, tnemesh.CoordIndex, tnemesh.TexCoordIndex, ((CX3DImporter_NodeElement_TextureCoordinate*)*ch_it)->Value);
|
||||||
else
|
else
|
||||||
throw DeadlyImportError(boost::str(boost::format("Postprocess_BuildMesh. Unknown child of IndexedTriangleSet or IndexedTriangleFanSet, or \
|
throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of IndexedTriangleSet or IndexedTriangleFanSet, or \
|
||||||
IndexedTriangleStripSet: %s.") % (*ch_it)->Type));
|
IndexedTriangleStripSet: " + std::to_string((*ch_it)->Type) + ".");
|
||||||
}// for(std::list<CX3DImporter_NodeElement*>::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++)
|
}// for(std::list<CX3DImporter_NodeElement*>::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++)
|
||||||
|
|
||||||
return;// mesh is build, nothing to do anymore.
|
return;// mesh is build, nothing to do anymore.
|
||||||
|
@ -411,7 +412,7 @@ void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeEle
|
||||||
else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Coordinate)
|
else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Coordinate)
|
||||||
{} // skip because already read when mesh created.
|
{} // skip because already read when mesh created.
|
||||||
else
|
else
|
||||||
throw DeadlyImportError(boost::str(boost::format("Postprocess_BuildMesh. Unknown child of PointSet: %s.") % (*ch_it)->Type));
|
throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of PointSet: " + std::to_string((*ch_it)->Type) + ".");
|
||||||
}// for(std::list<CX3DImporter_NodeElement*>::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++)
|
}// for(std::list<CX3DImporter_NodeElement*>::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++)
|
||||||
|
|
||||||
return;// mesh is build, nothing to do anymore.
|
return;// mesh is build, nothing to do anymore.
|
||||||
|
@ -440,7 +441,7 @@ void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeEle
|
||||||
else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Coordinate)
|
else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Coordinate)
|
||||||
{} // skip because already read when mesh created.
|
{} // skip because already read when mesh created.
|
||||||
else
|
else
|
||||||
throw DeadlyImportError(boost::str(boost::format("Postprocess_BuildMesh. Unknown child of LineSet: %s.") % (*ch_it)->Type));
|
throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of LineSet: " + std::to_string((*ch_it)->Type) + ".");
|
||||||
}// for(std::list<CX3DImporter_NodeElement*>::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++)
|
}// for(std::list<CX3DImporter_NodeElement*>::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++)
|
||||||
|
|
||||||
return;// mesh is build, nothing to do anymore.
|
return;// mesh is build, nothing to do anymore.
|
||||||
|
@ -474,7 +475,7 @@ void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeEle
|
||||||
else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_TextureCoordinate)
|
else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_TextureCoordinate)
|
||||||
MeshGeometry_AddTexCoord(**pMesh, tnemesh.CoordIndex, tnemesh.TexCoordIndex, ((CX3DImporter_NodeElement_TextureCoordinate*)*ch_it)->Value);
|
MeshGeometry_AddTexCoord(**pMesh, tnemesh.CoordIndex, tnemesh.TexCoordIndex, ((CX3DImporter_NodeElement_TextureCoordinate*)*ch_it)->Value);
|
||||||
else
|
else
|
||||||
throw DeadlyImportError(boost::str(boost::format("Postprocess_BuildMesh. Unknown child of TrianlgeFanSet: %s.") % (*ch_it)->Type));
|
throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of TrianlgeFanSet: " + std::to_string((*ch_it)->Type) + ".");
|
||||||
}// for(std::list<CX3DImporter_NodeElement*>::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++)
|
}// for(std::list<CX3DImporter_NodeElement*>::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++)
|
||||||
|
|
||||||
return;// mesh is build, nothing to do anymore.
|
return;// mesh is build, nothing to do anymore.
|
||||||
|
@ -517,7 +518,7 @@ void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeEle
|
||||||
else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_TextureCoordinate)
|
else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_TextureCoordinate)
|
||||||
MeshGeometry_AddTexCoord(**pMesh, tnemesh.CoordIndex, tnemesh.TexCoordIndex, ((CX3DImporter_NodeElement_TextureCoordinate*)*ch_it)->Value);
|
MeshGeometry_AddTexCoord(**pMesh, tnemesh.CoordIndex, tnemesh.TexCoordIndex, ((CX3DImporter_NodeElement_TextureCoordinate*)*ch_it)->Value);
|
||||||
else
|
else
|
||||||
throw DeadlyImportError(boost::str(boost::format("Postprocess_BuildMesh. Unknown child of TrianlgeSet: %s.") % (*ch_it)->Type));
|
throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of TrianlgeSet: " + std::to_string((*ch_it)->Type) + ".");
|
||||||
}// for(std::list<CX3DImporter_NodeElement*>::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++)
|
}// for(std::list<CX3DImporter_NodeElement*>::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++)
|
||||||
|
|
||||||
return;// mesh is build, nothing to do anymore.
|
return;// mesh is build, nothing to do anymore.
|
||||||
|
@ -551,13 +552,13 @@ void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeEle
|
||||||
else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_TextureCoordinate)
|
else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_TextureCoordinate)
|
||||||
MeshGeometry_AddTexCoord(**pMesh, tnemesh.CoordIndex, tnemesh.TexCoordIndex, ((CX3DImporter_NodeElement_TextureCoordinate*)*ch_it)->Value);
|
MeshGeometry_AddTexCoord(**pMesh, tnemesh.CoordIndex, tnemesh.TexCoordIndex, ((CX3DImporter_NodeElement_TextureCoordinate*)*ch_it)->Value);
|
||||||
else
|
else
|
||||||
throw DeadlyImportError(boost::str(boost::format("Postprocess_BuildMesh. Unknown child of TriangleStripSet: %s.") % (*ch_it)->Type));
|
throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of TriangleStripSet: " + std::to_string((*ch_it)->Type) + ".");
|
||||||
}// for(std::list<CX3DImporter_NodeElement*>::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++)
|
}// for(std::list<CX3DImporter_NodeElement*>::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++)
|
||||||
|
|
||||||
return;// mesh is build, nothing to do anymore.
|
return;// mesh is build, nothing to do anymore.
|
||||||
}// if(pNodeElement.Type == CX3DImporter_NodeElement::ENET_TriangleStripSet)
|
}// if(pNodeElement.Type == CX3DImporter_NodeElement::ENET_TriangleStripSet)
|
||||||
|
|
||||||
throw DeadlyImportError(boost::str(boost::format("Postprocess_BuildMesh. Unknown mesh type: %s.") % pNodeElement.Type));
|
throw DeadlyImportError("Postprocess_BuildMesh. Unknown mesh type: " + std::to_string(pNodeElement.Type) + ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
void X3DImporter::Postprocess_BuildNode(const CX3DImporter_NodeElement& pNodeElement, aiNode& pSceneNode, std::list<aiMesh*>& pSceneMeshList,
|
void X3DImporter::Postprocess_BuildNode(const CX3DImporter_NodeElement& pNodeElement, aiNode& pSceneNode, std::list<aiMesh*>& pSceneMeshList,
|
||||||
|
@ -566,7 +567,6 @@ void X3DImporter::Postprocess_BuildNode(const CX3DImporter_NodeElement& pNodeEle
|
||||||
std::list<CX3DImporter_NodeElement*>::const_iterator chit_begin = pNodeElement.Child.begin();
|
std::list<CX3DImporter_NodeElement*>::const_iterator chit_begin = pNodeElement.Child.begin();
|
||||||
std::list<CX3DImporter_NodeElement*>::const_iterator chit_end = pNodeElement.Child.end();
|
std::list<CX3DImporter_NodeElement*>::const_iterator chit_end = pNodeElement.Child.end();
|
||||||
std::list<aiNode*> SceneNode_Child;
|
std::list<aiNode*> SceneNode_Child;
|
||||||
std::list<aiLight*> SceneNode_Light;
|
|
||||||
std::list<unsigned int> SceneNode_Mesh;
|
std::list<unsigned int> SceneNode_Mesh;
|
||||||
|
|
||||||
// At first read all metadata
|
// At first read all metadata
|
||||||
|
@ -620,7 +620,7 @@ std::list<unsigned int> SceneNode_Mesh;
|
||||||
}
|
}
|
||||||
else if(!PostprocessHelper_ElementIsMetadata((*it)->Type))// skip metadata
|
else if(!PostprocessHelper_ElementIsMetadata((*it)->Type))// skip metadata
|
||||||
{
|
{
|
||||||
throw DeadlyImportError(boost::str(boost::format("Postprocess_BuildNode. Unknown type: %s.") % (*it)->Type));
|
throw DeadlyImportError("Postprocess_BuildNode. Unknown type: " + std::to_string((*it)->Type) + ".");
|
||||||
}
|
}
|
||||||
}// for(std::list<CX3DImporter_NodeElement*>::const_iterator it = chit_begin; it != chit_end; it++)
|
}// for(std::list<CX3DImporter_NodeElement*>::const_iterator it = chit_begin; it != chit_end; it++)
|
||||||
|
|
||||||
|
@ -649,8 +649,8 @@ std::list<unsigned int> SceneNode_Mesh;
|
||||||
void X3DImporter::Postprocess_BuildShape(const CX3DImporter_NodeElement_Shape& pShapeNodeElement, std::list<unsigned int>& pNodeMeshInd,
|
void X3DImporter::Postprocess_BuildShape(const CX3DImporter_NodeElement_Shape& pShapeNodeElement, std::list<unsigned int>& pNodeMeshInd,
|
||||||
std::list<aiMesh*>& pSceneMeshList, std::list<aiMaterial*>& pSceneMaterialList) const
|
std::list<aiMesh*>& pSceneMeshList, std::list<aiMaterial*>& pSceneMaterialList) const
|
||||||
{
|
{
|
||||||
aiMaterial* tmat = NULL;
|
aiMaterial* tmat = nullptr;
|
||||||
aiMesh* tmesh = NULL;
|
aiMesh* tmesh = nullptr;
|
||||||
CX3DImporter_NodeElement::EType mesh_type = CX3DImporter_NodeElement::ENET_Invalid;
|
CX3DImporter_NodeElement::EType mesh_type = CX3DImporter_NodeElement::ENET_Invalid;
|
||||||
unsigned int mat_ind = 0;
|
unsigned int mat_ind = 0;
|
||||||
|
|
||||||
|
@ -659,7 +659,7 @@ unsigned int mat_ind = 0;
|
||||||
if(PostprocessHelper_ElementIsMesh((*it)->Type))
|
if(PostprocessHelper_ElementIsMesh((*it)->Type))
|
||||||
{
|
{
|
||||||
Postprocess_BuildMesh(**it, &tmesh);
|
Postprocess_BuildMesh(**it, &tmesh);
|
||||||
if(tmesh != NULL)
|
if(tmesh != nullptr)
|
||||||
{
|
{
|
||||||
// if mesh successfully built then add data about it to arrays
|
// if mesh successfully built then add data about it to arrays
|
||||||
pNodeMeshInd.push_back(pSceneMeshList.size());
|
pNodeMeshInd.push_back(pSceneMeshList.size());
|
||||||
|
@ -671,7 +671,7 @@ unsigned int mat_ind = 0;
|
||||||
else if((*it)->Type == CX3DImporter_NodeElement::ENET_Appearance)
|
else if((*it)->Type == CX3DImporter_NodeElement::ENET_Appearance)
|
||||||
{
|
{
|
||||||
Postprocess_BuildMaterial(**it, &tmat);
|
Postprocess_BuildMaterial(**it, &tmat);
|
||||||
if(tmat != NULL)
|
if(tmat != nullptr)
|
||||||
{
|
{
|
||||||
// if material successfully built then add data about it to array
|
// if material successfully built then add data about it to array
|
||||||
mat_ind = pSceneMaterialList.size();
|
mat_ind = pSceneMaterialList.size();
|
||||||
|
@ -681,7 +681,7 @@ unsigned int mat_ind = 0;
|
||||||
}// for(std::list<CX3DImporter_NodeElement*>::const_iterator it = pShapeNodeElement.Child.begin(); it != pShapeNodeElement.Child.end(); it++)
|
}// for(std::list<CX3DImporter_NodeElement*>::const_iterator it = pShapeNodeElement.Child.begin(); it != pShapeNodeElement.Child.end(); it++)
|
||||||
|
|
||||||
// associate read material with read mesh.
|
// associate read material with read mesh.
|
||||||
if((tmesh != NULL) && (tmat != NULL))
|
if((tmesh != nullptr) && (tmat != nullptr))
|
||||||
{
|
{
|
||||||
tmesh->mMaterialIndex = mat_ind;
|
tmesh->mMaterialIndex = mat_ind;
|
||||||
// Check texture mapping. If material has texture but mesh has no texture coordinate then try to ask Assimp to generate texture coordinates.
|
// Check texture mapping. If material has texture but mesh has no texture coordinate then try to ask Assimp to generate texture coordinates.
|
||||||
|
@ -709,25 +709,26 @@ unsigned int mat_ind = 0;
|
||||||
|
|
||||||
tmat->AddProperty(&tm, 1, AI_MATKEY_MAPPING_DIFFUSE(0));
|
tmat->AddProperty(&tm, 1, AI_MATKEY_MAPPING_DIFFUSE(0));
|
||||||
}// if((tmat->GetTextureCount(aiTextureType_DIFFUSE) != 0) && !tmesh->HasTextureCoords(0))
|
}// if((tmat->GetTextureCount(aiTextureType_DIFFUSE) != 0) && !tmesh->HasTextureCoords(0))
|
||||||
}// if((tmesh != NULL) && (tmat != NULL))
|
}// if((tmesh != nullptr) && (tmat != nullptr))
|
||||||
}
|
}
|
||||||
|
|
||||||
void X3DImporter::Postprocess_CollectMetadata(const CX3DImporter_NodeElement& pNodeElement, aiNode& pSceneNode) const
|
void X3DImporter::Postprocess_CollectMetadata(const CX3DImporter_NodeElement& pNodeElement, aiNode& pSceneNode) const
|
||||||
{
|
{
|
||||||
std::list<CX3DImporter_NodeElement*> meta_list;
|
std::list<CX3DImporter_NodeElement*> meta_list;
|
||||||
size_t meta_idx = 0;
|
size_t meta_idx;
|
||||||
|
|
||||||
PostprocessHelper_CollectMetadata(pNodeElement, meta_list);// find metadata in current node element.
|
PostprocessHelper_CollectMetadata(pNodeElement, meta_list);// find metadata in current node element.
|
||||||
if(meta_list.size() > 0)
|
if(meta_list.size() > 0)
|
||||||
{
|
{
|
||||||
if(pSceneNode.mMetaData != NULL) throw DeadlyImportError("Postprocess. MetaData member in node are not NULL. Something went wrong.");
|
if(pSceneNode.mMetaData != nullptr) throw DeadlyImportError("Postprocess. MetaData member in node are not nullptr. Something went wrong.");
|
||||||
|
|
||||||
// copy collected metadata to output node.
|
// copy collected metadata to output node.
|
||||||
pSceneNode.mMetaData = new aiMetadata();
|
pSceneNode.mMetaData = new aiMetadata();
|
||||||
pSceneNode.mMetaData->mNumProperties = meta_list.size();
|
pSceneNode.mMetaData->mNumProperties = meta_list.size();
|
||||||
pSceneNode.mMetaData->mKeys = new aiString[pSceneNode.mMetaData->mNumProperties];
|
pSceneNode.mMetaData->mKeys = new aiString[pSceneNode.mMetaData->mNumProperties];
|
||||||
pSceneNode.mMetaData->mValues = new aiMetadataEntry[pSceneNode.mMetaData->mNumProperties];
|
pSceneNode.mMetaData->mValues = new aiMetadataEntry[pSceneNode.mMetaData->mNumProperties];
|
||||||
for(std::list<CX3DImporter_NodeElement*>::const_iterator it = meta_list.begin(); it != meta_list.end(); it++)
|
meta_idx = 0;
|
||||||
|
for(std::list<CX3DImporter_NodeElement*>::const_iterator it = meta_list.begin(); it != meta_list.end(); it++, meta_idx++)
|
||||||
{
|
{
|
||||||
CX3DImporter_NodeElement_Meta* cur_meta = (CX3DImporter_NodeElement_Meta*)*it;
|
CX3DImporter_NodeElement_Meta* cur_meta = (CX3DImporter_NodeElement_Meta*)*it;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/// \file X3DImporter_Rendering.cpp
|
/// \file X3DImporter_Rendering.cpp
|
||||||
/// \brief Parsing data from nodes of "Rendering" set of X3D.
|
/// \brief Parsing data from nodes of "Rendering" set of X3D.
|
||||||
/// \date 2015-2016
|
/// \date 2015-2016
|
||||||
/// \author nevorek@gmail.com
|
/// \author smal.root@gmail.com
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_X3D_IMPORTER
|
#ifndef ASSIMP_BUILD_NO_X3D_IMPORTER
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/// \file X3DImporter_Shape.cpp
|
/// \file X3DImporter_Shape.cpp
|
||||||
/// \brief Parsing data from nodes of "Shape" set of X3D.
|
/// \brief Parsing data from nodes of "Shape" set of X3D.
|
||||||
/// \date 2015-2016
|
/// \date 2015-2016
|
||||||
/// \author nevorek@gmail.com
|
/// \author smal.root@gmail.com
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_X3D_IMPORTER
|
#ifndef ASSIMP_BUILD_NO_X3D_IMPORTER
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/// \file X3DImporter_Texturing.cpp
|
/// \file X3DImporter_Texturing.cpp
|
||||||
/// \brief Parsing data from nodes of "Texturing" set of X3D.
|
/// \brief Parsing data from nodes of "Texturing" set of X3D.
|
||||||
/// \date 2015-2016
|
/// \date 2015-2016
|
||||||
/// \author nevorek@gmail.com
|
/// \author smal.root@gmail.com
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_X3D_IMPORTER
|
#ifndef ASSIMP_BUILD_NO_X3D_IMPORTER
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue