fix merge issues.
parent
839986ca14
commit
77b705048b
|
@ -146,23 +146,19 @@ size_t AMFImporter::PostprocessHelper_GetTextureID_Or_Create(const std::string &
|
|||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Converted texture not found, create it.
|
||||
AMFTexture *src_texture[4] {
|
||||
nullptr
|
||||
};
|
||||
//
|
||||
AMFTexture *src_texture[4]{ nullptr };
|
||||
std::vector<AMFTexture *> src_texture_4check;
|
||||
SPP_Texture converted_texture;
|
||||
|
||||
{ // find all specified source textures
|
||||
AMFNodeElementBase *t_tex;
|
||||
|
||||
AMFNodeElementBase *t_tex = nullptr;
|
||||
|
||||
// R
|
||||
if (!pID_R.empty()) {
|
||||
pugi::xml_node *node = mXmlParser->findNode(pID_R);
|
||||
if (nullptr == node) {
|
||||
throw DeadlyImportError("Id not found " + pID_R + ".");
|
||||
}
|
||||
//if (!Find_NodeElement(pID_R, AMFNodeElementBase::ENET_Texture, &t_tex)) Throw_ID_NotFound(pID_R);
|
||||
if (!Find_NodeElement(pID_R, AMFNodeElementBase::EType::ENET_Texture, &t_tex)) Throw_ID_NotFound(pID_R);
|
||||
|
||||
src_texture[0] = (AMFTexture *)t_tex;
|
||||
src_texture_4check.push_back((AMFTexture *)t_tex);
|
||||
|
@ -172,12 +168,7 @@ size_t AMFImporter::PostprocessHelper_GetTextureID_Or_Create(const std::string &
|
|||
|
||||
// G
|
||||
if (!pID_G.empty()) {
|
||||
pugi::xml_node *node = mXmlParser->findNode(pID_G);
|
||||
if (nullptr == node) {
|
||||
throw DeadlyImportError("Id not found " + pID_G + ".");
|
||||
}
|
||||
|
||||
//if (!Find_NodeElement(pID_G, AMFNodeElementBase::ENET_Texture, &t_tex)) Throw_ID_NotFound(pID_G);
|
||||
if (!Find_NodeElement(pID_G, AMFNodeElementBase::ENET_Texture, &t_tex)) Throw_ID_NotFound(pID_G);
|
||||
|
||||
src_texture[1] = (AMFTexture *)t_tex;
|
||||
src_texture_4check.push_back((AMFTexture *)t_tex);
|
||||
|
@ -187,11 +178,7 @@ size_t AMFImporter::PostprocessHelper_GetTextureID_Or_Create(const std::string &
|
|||
|
||||
// B
|
||||
if (!pID_B.empty()) {
|
||||
//if (!Find_NodeElement(pID_B, AMFNodeElementBase::ENET_Texture, &t_tex)) Throw_ID_NotFound(pID_B);
|
||||
pugi::xml_node *node = mXmlParser->findNode(pID_B);
|
||||
if (nullptr == node) {
|
||||
throw DeadlyImportError("Id not found " + pID_B + ".");
|
||||
}
|
||||
if (!Find_NodeElement(pID_B, AMFNodeElementBase::ENET_Texture, &t_tex)) Throw_ID_NotFound(pID_B);
|
||||
|
||||
src_texture[2] = (AMFTexture *)t_tex;
|
||||
src_texture_4check.push_back((AMFTexture *)t_tex);
|
||||
|
@ -201,12 +188,7 @@ size_t AMFImporter::PostprocessHelper_GetTextureID_Or_Create(const std::string &
|
|||
|
||||
// A
|
||||
if (!pID_A.empty()) {
|
||||
pugi::xml_node *node = mXmlParser->findNode(pID_A);
|
||||
if (nullptr == node) {
|
||||
throw DeadlyImportError("Id not found " + pID_A + ".");
|
||||
}
|
||||
|
||||
//if (!Find_NodeElement(pID_A, AMFNodeElementBase::ENET_Texture, &t_tex)) Throw_ID_NotFound(pID_A);
|
||||
if (!Find_NodeElement(pID_A, AMFNodeElementBase::ENET_Texture, &t_tex)) Throw_ID_NotFound(pID_A);
|
||||
|
||||
src_texture[3] = (AMFTexture *)t_tex;
|
||||
src_texture_4check.push_back((AMFTexture *)t_tex);
|
||||
|
@ -216,7 +198,7 @@ size_t AMFImporter::PostprocessHelper_GetTextureID_Or_Create(const std::string &
|
|||
} // END: find all specified source textures
|
||||
|
||||
// check that all textures has same size
|
||||
if (!src_texture_4check.empty() ) {
|
||||
if (src_texture_4check.size() > 1) {
|
||||
for (size_t i = 0, i_e = (src_texture_4check.size() - 1); i < i_e; i++) {
|
||||
if ((src_texture_4check[i]->Width != src_texture_4check[i + 1]->Width) || (src_texture_4check[i]->Height != src_texture_4check[i + 1]->Height) ||
|
||||
(src_texture_4check[i]->Depth != src_texture_4check[i + 1]->Depth)) {
|
||||
|
@ -241,9 +223,7 @@ size_t AMFImporter::PostprocessHelper_GetTextureID_Or_Create(const std::string &
|
|||
if (!pID_B.empty()) converted_texture.FormatHint[6] = '8';
|
||||
if (!pID_A.empty()) converted_texture.FormatHint[7] = '8';
|
||||
|
||||
//
|
||||
// Сopy data of textures.
|
||||
//
|
||||
size_t tex_size = 0;
|
||||
size_t step = 0;
|
||||
size_t off_g = 0;
|
||||
|
@ -693,7 +673,7 @@ void AMFImporter::Postprocess_BuildConstellation(AMFConstellation &pConstellatio
|
|||
con_node = new aiNode;
|
||||
con_node->mName = pConstellation.ID;
|
||||
// Walk through children and search for instances of another objects, constellations.
|
||||
for (const CAMFImporter_NodeElement *ne : pConstellation.Child) {
|
||||
for (const AMFNodeElementBase *ne : pConstellation.Child) {
|
||||
aiMatrix4x4 tmat;
|
||||
aiNode *t_node;
|
||||
aiNode *found_node;
|
||||
|
@ -702,7 +682,7 @@ void AMFImporter::Postprocess_BuildConstellation(AMFConstellation &pConstellatio
|
|||
if (ne->Type != AMFNodeElementBase::ENET_Instance) throw DeadlyImportError("Only <instance> nodes can be in <constellation>.");
|
||||
|
||||
// create alias for conveniance
|
||||
CAMFImporter_NodeElement_Instance &als = *((CAMFImporter_NodeElement_Instance *)ne);
|
||||
AMFInstance &als = *((AMFInstance *)ne);
|
||||
// find referenced object
|
||||
if (!Find_ConvertedNode(als.ObjectID, pNodeList, &found_node)) Throw_ID_NotFound(als.ObjectID);
|
||||
|
||||
|
@ -739,7 +719,7 @@ void AMFImporter::Postprocess_BuildConstellation(AMFConstellation &pConstellatio
|
|||
void AMFImporter::Postprocess_BuildScene(aiScene *pScene) {
|
||||
std::list<aiNode *> node_list;
|
||||
std::list<aiMesh *> mesh_list;
|
||||
std::list<CAMFImporter_NodeElement_Metadata *> meta_list;
|
||||
std::list<AMFMetadata *> meta_list;
|
||||
|
||||
//
|
||||
// Because for AMF "material" is just complex colors mixing so aiMaterial will not be used.
|
||||
|
@ -752,10 +732,11 @@ void AMFImporter::Postprocess_BuildScene(aiScene *pScene) {
|
|||
AMFNodeElementBase *root_el = nullptr;
|
||||
|
||||
for (AMFNodeElementBase *ne : mNodeElement_List) {
|
||||
if (ne->Type != AMFNodeElementBase::ENET_Root) continue;
|
||||
if (ne->Type != AMFNodeElementBase::ENET_Root) {
|
||||
continue;
|
||||
}
|
||||
|
||||
root_el = ne;
|
||||
|
||||
break;
|
||||
} // for(const CAMFImporter_NodeElement* ne: mNodeElement_List)
|
||||
|
||||
|
@ -769,7 +750,7 @@ void AMFImporter::Postprocess_BuildScene(aiScene *pScene) {
|
|||
// 1. <material>
|
||||
// 2. <texture> will be converted later when processing triangles list. \sa Postprocess_BuildMeshSet
|
||||
for (const AMFNodeElementBase *root_child : root_el->Child) {
|
||||
if (root_child->Type == AMFNodeElementBase::ENET_Material) Postprocess_BuildMaterial(*((CAMFImporter_NodeElement_Material *)root_child));
|
||||
if (root_child->Type == AMFNodeElementBase::ENET_Material) Postprocess_BuildMaterial(*((AMFMaterial *)root_child));
|
||||
}
|
||||
|
||||
// After "appearance" nodes we must read <object> because it will be used in <constellation> -> <instance>.
|
||||
|
@ -780,7 +761,7 @@ void AMFImporter::Postprocess_BuildScene(aiScene *pScene) {
|
|||
aiNode *tnode = nullptr;
|
||||
|
||||
// for <object> mesh and node must be built: object ID assigned to aiNode name and will be used in future for <instance>
|
||||
Postprocess_BuildNodeAndObject(*((CAMFImporter_NodeElement_Object *)root_child), mesh_list, &tnode);
|
||||
Postprocess_BuildNodeAndObject(*((AMFObject *)root_child), mesh_list, &tnode);
|
||||
if (tnode != nullptr) node_list.push_back(tnode);
|
||||
}
|
||||
} // for(const CAMFImporter_NodeElement* root_child: root_el->Child)
|
||||
|
@ -795,7 +776,7 @@ void AMFImporter::Postprocess_BuildScene(aiScene *pScene) {
|
|||
}
|
||||
|
||||
// 5, <metadata>
|
||||
if (root_child->Type == AMFNodeElementBase::ENET_Metadata) meta_list.push_back((CAMFImporter_NodeElement_Metadata *)root_child);
|
||||
if (root_child->Type == AMFNodeElementBase::ENET_Metadata) meta_list.push_back((AMFMetadata *)root_child);
|
||||
} // for(const CAMFImporter_NodeElement* root_child: root_el->Child)
|
||||
|
||||
// at now we can add collected metadata to root node
|
||||
|
|
|
@ -52,6 +52,8 @@
|
|||
#include <assimp/ai_assert.h>
|
||||
#include <assimp/XmlParser.h>
|
||||
|
||||
#include <map>
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
class ZipArchiveIOSystem;
|
||||
|
@ -374,10 +376,10 @@ protected:
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Check for element match
|
||||
inline bool ColladaParser::IsElement(const char *pName) const {
|
||||
/*inline bool ColladaParser::IsElement(const char *pName) const {
|
||||
ai_assert(mReader->getNodeType() == irr::io::EXN_ELEMENT);
|
||||
return ::strcmp(mReader->getNodeName(), pName) == 0;
|
||||
}
|
||||
}*/
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Finds the item in the given library by its reference, throws if not found
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -129,7 +129,6 @@ static void releaseMesh(aiMesh **mesh) {
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Imports the given file into the given scene structure.
|
||||
<<<<<<< HEAD
|
||||
void IRRMeshImporter::InternReadFile(const std::string &pFile,
|
||||
aiScene *pScene, IOSystem *pIOHandler) {
|
||||
std::unique_ptr<IOStream> file(pIOHandler->Open(pFile));
|
||||
|
@ -511,407 +510,6 @@ void IRRMeshImporter::InternReadFile(const std::string &pFile,
|
|||
for (unsigned int i = 0; i < pScene->mNumMeshes; ++i) {
|
||||
pScene->mRootNode->mMeshes[i] = i;
|
||||
}
|
||||
|
||||
=======
|
||||
void IRRMeshImporter::InternReadFile( const std::string& pFile,
|
||||
aiScene* pScene, IOSystem* pIOHandler)
|
||||
{
|
||||
std::unique_ptr<IOStream> file( pIOHandler->Open( pFile));
|
||||
|
||||
// Check whether we can read from the file
|
||||
if (file.get() == nullptr) {
|
||||
throw DeadlyImportError("Failed to open IRRMESH file " + pFile + ".");
|
||||
}
|
||||
|
||||
// Construct the irrXML parser
|
||||
CIrrXML_IOStreamReader st(file.get());
|
||||
reader = createIrrXMLReader((IFileReadCallBack*) &st);
|
||||
|
||||
// final data
|
||||
std::vector<aiMaterial*> materials;
|
||||
std::vector<aiMesh*> meshes;
|
||||
materials.reserve (5);
|
||||
meshes.reserve(5);
|
||||
|
||||
// temporary data - current mesh buffer
|
||||
aiMaterial* curMat = nullptr;
|
||||
aiMesh* curMesh = nullptr;
|
||||
unsigned int curMatFlags = 0;
|
||||
|
||||
std::vector<aiVector3D> curVertices,curNormals,curTangents,curBitangents;
|
||||
std::vector<aiColor4D> curColors;
|
||||
std::vector<aiVector3D> curUVs,curUV2s;
|
||||
|
||||
// some temporary variables
|
||||
int textMeaning = 0;
|
||||
int vertexFormat = 0; // 0 = normal; 1 = 2 tcoords, 2 = tangents
|
||||
bool useColors = false;
|
||||
|
||||
// Parse the XML file
|
||||
while (reader->read()) {
|
||||
switch (reader->getNodeType()) {
|
||||
case EXN_ELEMENT:
|
||||
|
||||
if (!ASSIMP_stricmp(reader->getNodeName(),"buffer") && (curMat || curMesh)) {
|
||||
// end of previous buffer. A material and a mesh should be there
|
||||
if ( !curMat || !curMesh) {
|
||||
ASSIMP_LOG_ERROR("IRRMESH: A buffer must contain a mesh and a material");
|
||||
releaseMaterial( &curMat );
|
||||
releaseMesh( &curMesh );
|
||||
} else {
|
||||
materials.push_back(curMat);
|
||||
meshes.push_back(curMesh);
|
||||
}
|
||||
curMat = nullptr;
|
||||
curMesh = nullptr;
|
||||
|
||||
curVertices.clear();
|
||||
curColors.clear();
|
||||
curNormals.clear();
|
||||
curUV2s.clear();
|
||||
curUVs.clear();
|
||||
curTangents.clear();
|
||||
curBitangents.clear();
|
||||
}
|
||||
|
||||
|
||||
if (!ASSIMP_stricmp(reader->getNodeName(),"material")) {
|
||||
if (curMat) {
|
||||
ASSIMP_LOG_WARN("IRRMESH: Only one material description per buffer, please");
|
||||
releaseMaterial( &curMat );
|
||||
}
|
||||
curMat = ParseMaterial(curMatFlags);
|
||||
}
|
||||
/* no else here! */ if (!ASSIMP_stricmp(reader->getNodeName(),"vertices"))
|
||||
{
|
||||
int num = reader->getAttributeValueAsInt("vertexCount");
|
||||
|
||||
if (!num) {
|
||||
// This is possible ... remove the mesh from the list and skip further reading
|
||||
ASSIMP_LOG_WARN("IRRMESH: Found mesh with zero vertices");
|
||||
|
||||
releaseMaterial( &curMat );
|
||||
releaseMesh( &curMesh );
|
||||
textMeaning = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
curVertices.reserve(num);
|
||||
curNormals.reserve(num);
|
||||
curColors.reserve(num);
|
||||
curUVs.reserve(num);
|
||||
|
||||
// Determine the file format
|
||||
const char* t = reader->getAttributeValueSafe("type");
|
||||
if (!ASSIMP_stricmp("2tcoords", t)) {
|
||||
curUV2s.reserve (num);
|
||||
vertexFormat = 1;
|
||||
|
||||
if (curMatFlags & AI_IRRMESH_EXTRA_2ND_TEXTURE) {
|
||||
// *********************************************************
|
||||
// We have a second texture! So use this UV channel
|
||||
// for it. The 2nd texture can be either a normal
|
||||
// texture (solid_2layer or lightmap_xxx) or a normal
|
||||
// map (normal_..., parallax_...)
|
||||
// *********************************************************
|
||||
int idx = 1;
|
||||
aiMaterial* mat = ( aiMaterial* ) curMat;
|
||||
|
||||
if (curMatFlags & AI_IRRMESH_MAT_lightmap){
|
||||
mat->AddProperty(&idx,1,AI_MATKEY_UVWSRC_LIGHTMAP(0));
|
||||
}
|
||||
else if (curMatFlags & AI_IRRMESH_MAT_normalmap_solid){
|
||||
mat->AddProperty(&idx,1,AI_MATKEY_UVWSRC_NORMALS(0));
|
||||
}
|
||||
else if (curMatFlags & AI_IRRMESH_MAT_solid_2layer) {
|
||||
mat->AddProperty(&idx,1,AI_MATKEY_UVWSRC_DIFFUSE(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!ASSIMP_stricmp("tangents", t)) {
|
||||
curTangents.reserve (num);
|
||||
curBitangents.reserve (num);
|
||||
vertexFormat = 2;
|
||||
}
|
||||
else if (ASSIMP_stricmp("standard", t)) {
|
||||
releaseMaterial( &curMat );
|
||||
ASSIMP_LOG_WARN("IRRMESH: Unknown vertex format");
|
||||
}
|
||||
else vertexFormat = 0;
|
||||
textMeaning = 1;
|
||||
}
|
||||
else if (!ASSIMP_stricmp(reader->getNodeName(),"indices")) {
|
||||
if (curVertices.empty() && curMat) {
|
||||
releaseMaterial( &curMat );
|
||||
throw DeadlyImportError("IRRMESH: indices must come after vertices");
|
||||
}
|
||||
|
||||
textMeaning = 2;
|
||||
|
||||
// start a new mesh
|
||||
curMesh = new aiMesh();
|
||||
|
||||
// allocate storage for all faces
|
||||
curMesh->mNumVertices = reader->getAttributeValueAsInt("indexCount");
|
||||
if (!curMesh->mNumVertices) {
|
||||
// This is possible ... remove the mesh from the list and skip further reading
|
||||
ASSIMP_LOG_WARN("IRRMESH: Found mesh with zero indices");
|
||||
|
||||
// mesh - away
|
||||
releaseMesh( &curMesh );
|
||||
|
||||
// material - away
|
||||
releaseMaterial( &curMat );
|
||||
|
||||
textMeaning = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (curMesh->mNumVertices % 3) {
|
||||
ASSIMP_LOG_WARN("IRRMESH: Number if indices isn't divisible by 3");
|
||||
}
|
||||
|
||||
curMesh->mNumFaces = curMesh->mNumVertices / 3;
|
||||
curMesh->mFaces = new aiFace[curMesh->mNumFaces];
|
||||
|
||||
// setup some members
|
||||
curMesh->mMaterialIndex = (unsigned int)materials.size();
|
||||
curMesh->mPrimitiveTypes = aiPrimitiveType_TRIANGLE;
|
||||
|
||||
// allocate storage for all vertices
|
||||
curMesh->mVertices = new aiVector3D[curMesh->mNumVertices];
|
||||
|
||||
if (curNormals.size() == curVertices.size()) {
|
||||
curMesh->mNormals = new aiVector3D[curMesh->mNumVertices];
|
||||
}
|
||||
if (curTangents.size() == curVertices.size()) {
|
||||
curMesh->mTangents = new aiVector3D[curMesh->mNumVertices];
|
||||
}
|
||||
if (curBitangents.size() == curVertices.size()) {
|
||||
curMesh->mBitangents = new aiVector3D[curMesh->mNumVertices];
|
||||
}
|
||||
if (curColors.size() == curVertices.size() && useColors) {
|
||||
curMesh->mColors[0] = new aiColor4D[curMesh->mNumVertices];
|
||||
}
|
||||
if (curUVs.size() == curVertices.size()) {
|
||||
curMesh->mTextureCoords[0] = new aiVector3D[curMesh->mNumVertices];
|
||||
}
|
||||
if (curUV2s.size() == curVertices.size()) {
|
||||
curMesh->mTextureCoords[1] = new aiVector3D[curMesh->mNumVertices];
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case EXN_TEXT:
|
||||
{
|
||||
const char* sz = reader->getNodeData();
|
||||
if (textMeaning == 1) {
|
||||
textMeaning = 0;
|
||||
|
||||
// read vertices
|
||||
do {
|
||||
SkipSpacesAndLineEnd(&sz);
|
||||
aiVector3D temp;aiColor4D c;
|
||||
|
||||
// Read the vertex position
|
||||
sz = fast_atoreal_move<float>(sz,(float&)temp.x);
|
||||
SkipSpaces(&sz);
|
||||
|
||||
sz = fast_atoreal_move<float>(sz,(float&)temp.y);
|
||||
SkipSpaces(&sz);
|
||||
|
||||
sz = fast_atoreal_move<float>(sz,(float&)temp.z);
|
||||
SkipSpaces(&sz);
|
||||
curVertices.push_back(temp);
|
||||
|
||||
// Read the vertex normals
|
||||
sz = fast_atoreal_move<float>(sz,(float&)temp.x);
|
||||
SkipSpaces(&sz);
|
||||
|
||||
sz = fast_atoreal_move<float>(sz,(float&)temp.y);
|
||||
SkipSpaces(&sz);
|
||||
|
||||
sz = fast_atoreal_move<float>(sz,(float&)temp.z);
|
||||
SkipSpaces(&sz);
|
||||
curNormals.push_back(temp);
|
||||
|
||||
// read the vertex colors
|
||||
uint32_t clr = strtoul16(sz,&sz);
|
||||
ColorFromARGBPacked(clr,c);
|
||||
|
||||
if (!curColors.empty() && c != *(curColors.end()-1))
|
||||
useColors = true;
|
||||
|
||||
curColors.push_back(c);
|
||||
SkipSpaces(&sz);
|
||||
|
||||
|
||||
// read the first UV coordinate set
|
||||
sz = fast_atoreal_move<float>(sz,(float&)temp.x);
|
||||
SkipSpaces(&sz);
|
||||
|
||||
sz = fast_atoreal_move<float>(sz,(float&)temp.y);
|
||||
SkipSpaces(&sz);
|
||||
temp.z = 0.f;
|
||||
temp.y = 1.f - temp.y; // DX to OGL
|
||||
curUVs.push_back(temp);
|
||||
|
||||
// read the (optional) second UV coordinate set
|
||||
if (vertexFormat == 1) {
|
||||
sz = fast_atoreal_move<float>(sz,(float&)temp.x);
|
||||
SkipSpaces(&sz);
|
||||
|
||||
sz = fast_atoreal_move<float>(sz,(float&)temp.y);
|
||||
temp.y = 1.f - temp.y; // DX to OGL
|
||||
curUV2s.push_back(temp);
|
||||
}
|
||||
// read optional tangent and bitangent vectors
|
||||
else if (vertexFormat == 2) {
|
||||
// tangents
|
||||
sz = fast_atoreal_move<float>(sz,(float&)temp.x);
|
||||
SkipSpaces(&sz);
|
||||
|
||||
sz = fast_atoreal_move<float>(sz,(float&)temp.z);
|
||||
SkipSpaces(&sz);
|
||||
|
||||
sz = fast_atoreal_move<float>(sz,(float&)temp.y);
|
||||
SkipSpaces(&sz);
|
||||
temp.y *= -1.0f;
|
||||
curTangents.push_back(temp);
|
||||
|
||||
// bitangents
|
||||
sz = fast_atoreal_move<float>(sz,(float&)temp.x);
|
||||
SkipSpaces(&sz);
|
||||
|
||||
sz = fast_atoreal_move<float>(sz,(float&)temp.z);
|
||||
SkipSpaces(&sz);
|
||||
|
||||
sz = fast_atoreal_move<float>(sz,(float&)temp.y);
|
||||
SkipSpaces(&sz);
|
||||
temp.y *= -1.0f;
|
||||
curBitangents.push_back(temp);
|
||||
}
|
||||
}
|
||||
|
||||
/* IMPORTANT: We assume that each vertex is specified in one
|
||||
line. So we can skip the rest of the line - unknown vertex
|
||||
elements are ignored.
|
||||
*/
|
||||
|
||||
while (SkipLine(&sz));
|
||||
}
|
||||
else if (textMeaning == 2) {
|
||||
textMeaning = 0;
|
||||
|
||||
// read indices
|
||||
aiFace* curFace = curMesh->mFaces;
|
||||
aiFace* const faceEnd = curMesh->mFaces + curMesh->mNumFaces;
|
||||
|
||||
aiVector3D* pcV = curMesh->mVertices;
|
||||
aiVector3D* pcN = curMesh->mNormals;
|
||||
aiVector3D* pcT = curMesh->mTangents;
|
||||
aiVector3D* pcB = curMesh->mBitangents;
|
||||
aiColor4D* pcC0 = curMesh->mColors[0];
|
||||
aiVector3D* pcT0 = curMesh->mTextureCoords[0];
|
||||
aiVector3D* pcT1 = curMesh->mTextureCoords[1];
|
||||
|
||||
unsigned int curIdx = 0;
|
||||
unsigned int total = 0;
|
||||
while(SkipSpacesAndLineEnd(&sz)) {
|
||||
if (curFace >= faceEnd) {
|
||||
ASSIMP_LOG_ERROR("IRRMESH: Too many indices");
|
||||
break;
|
||||
}
|
||||
if (!curIdx) {
|
||||
curFace->mNumIndices = 3;
|
||||
curFace->mIndices = new unsigned int[3];
|
||||
}
|
||||
|
||||
unsigned int idx = strtoul10(sz,&sz);
|
||||
if (idx >= curVertices.size()) {
|
||||
ASSIMP_LOG_ERROR("IRRMESH: Index out of range");
|
||||
idx = 0;
|
||||
}
|
||||
|
||||
curFace->mIndices[curIdx] = total++;
|
||||
|
||||
*pcV++ = curVertices[idx];
|
||||
if (pcN)*pcN++ = curNormals[idx];
|
||||
if (pcT)*pcT++ = curTangents[idx];
|
||||
if (pcB)*pcB++ = curBitangents[idx];
|
||||
if (pcC0)*pcC0++ = curColors[idx];
|
||||
if (pcT0)*pcT0++ = curUVs[idx];
|
||||
if (pcT1)*pcT1++ = curUV2s[idx];
|
||||
|
||||
if (++curIdx == 3) {
|
||||
++curFace;
|
||||
curIdx = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (curFace != faceEnd)
|
||||
ASSIMP_LOG_ERROR("IRRMESH: Not enough indices");
|
||||
|
||||
// Finish processing the mesh - do some small material workarounds
|
||||
if (curMatFlags & AI_IRRMESH_MAT_trans_vertex_alpha && !useColors) {
|
||||
// Take the opacity value of the current material
|
||||
// from the common vertex color alpha
|
||||
aiMaterial* mat = (aiMaterial*)curMat;
|
||||
mat->AddProperty(&curColors[0].a,1,AI_MATKEY_OPACITY);
|
||||
}
|
||||
}}
|
||||
break;
|
||||
|
||||
default:
|
||||
// GCC complains here ...
|
||||
break;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
// End of the last buffer. A material and a mesh should be there
|
||||
if (curMat || curMesh) {
|
||||
if ( !curMat || !curMesh) {
|
||||
ASSIMP_LOG_ERROR("IRRMESH: A buffer must contain a mesh and a material");
|
||||
releaseMaterial( &curMat );
|
||||
releaseMesh( &curMesh );
|
||||
}
|
||||
else {
|
||||
materials.push_back(curMat);
|
||||
meshes.push_back(curMesh);
|
||||
}
|
||||
}
|
||||
|
||||
if (materials.empty())
|
||||
throw DeadlyImportError("IRRMESH: Unable to read a mesh from this file");
|
||||
|
||||
|
||||
// now generate the output scene
|
||||
pScene->mNumMeshes = (unsigned int)meshes.size();
|
||||
pScene->mMeshes = new aiMesh*[pScene->mNumMeshes];
|
||||
for (unsigned int i = 0; i < pScene->mNumMeshes;++i) {
|
||||
pScene->mMeshes[i] = meshes[i];
|
||||
|
||||
// clean this value ...
|
||||
pScene->mMeshes[i]->mNumUVComponents[3] = 0;
|
||||
}
|
||||
|
||||
pScene->mNumMaterials = (unsigned int)materials.size();
|
||||
pScene->mMaterials = new aiMaterial*[pScene->mNumMaterials];
|
||||
::memcpy(pScene->mMaterials,&materials[0],sizeof(void*)*pScene->mNumMaterials);
|
||||
|
||||
pScene->mRootNode = new aiNode();
|
||||
pScene->mRootNode->mName.Set("<IRRMesh>");
|
||||
pScene->mRootNode->mNumMeshes = pScene->mNumMeshes;
|
||||
pScene->mRootNode->mMeshes = new unsigned int[pScene->mNumMeshes];
|
||||
|
||||
for (unsigned int i = 0; i < pScene->mNumMeshes;++i)
|
||||
pScene->mRootNode->mMeshes[i] = i;
|
||||
|
||||
// clean up and return
|
||||
delete reader;
|
||||
AI_DEBUG_INVALIDATE_PTR(reader);
|
||||
>>>>>>> master
|
||||
}
|
||||
|
||||
#endif // !! ASSIMP_BUILD_NO_IRRMESH_IMPORTER
|
||||
|
|
|
@ -47,22 +47,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#define AI_XGLLOADER_H_INCLUDED
|
||||
|
||||
#include <assimp/BaseImporter.h>
|
||||
<<<<<<< HEAD
|
||||
#include <assimp/XmlParser.h>
|
||||
=======
|
||||
>>>>>>> master
|
||||
#include <assimp/LogAux.h>
|
||||
#include <assimp/irrXMLWrapper.h>
|
||||
#include <assimp/light.h>
|
||||
#include <assimp/material.h>
|
||||
#include <assimp/mesh.h>
|
||||
<<<<<<< HEAD
|
||||
#include <assimp/light.h>
|
||||
|
||||
#include <memory>
|
||||
=======
|
||||
#include <assimp/Importer.hpp>
|
||||
>>>>>>> master
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
|
|
Loading…
Reference in New Issue