Merge branch 'master' of https://github.com/assimp/assimp
commit
65653edf88
|
@ -638,6 +638,7 @@ struct Base : ElemBase {
|
||||||
|
|
||||||
Base()
|
Base()
|
||||||
: ElemBase()
|
: ElemBase()
|
||||||
|
, prev( nullptr )
|
||||||
, next()
|
, next()
|
||||||
, object() {
|
, object() {
|
||||||
// empty
|
// empty
|
||||||
|
@ -784,10 +785,12 @@ struct Tex : ElemBase {
|
||||||
//char use_nodes;
|
//char use_nodes;
|
||||||
|
|
||||||
Tex()
|
Tex()
|
||||||
: ElemBase() {
|
: ElemBase()
|
||||||
|
, imaflag( ImageFlags_INTERPOL )
|
||||||
|
, type( Type_CLOUDS )
|
||||||
|
, ima() {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------
|
||||||
|
|
|
@ -87,28 +87,40 @@ namespace XmlTag {
|
||||||
static const std::string transform = "transform";
|
static const std::string transform = "transform";
|
||||||
}
|
}
|
||||||
|
|
||||||
class XmlSerializer {
|
|
||||||
|
class XmlSerializer
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
XmlSerializer(XmlReader* xmlReader)
|
XmlSerializer(XmlReader* xmlReader)
|
||||||
: xmlReader(xmlReader) {
|
: xmlReader(xmlReader)
|
||||||
// empty
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImportXml(aiScene* scene) {
|
void ImportXml(aiScene* scene)
|
||||||
|
{
|
||||||
|
|
||||||
|
scene->mFlags |= AI_SCENE_FLAGS_NON_VERBOSE_FORMAT;
|
||||||
|
|
||||||
scene->mRootNode = new aiNode();
|
scene->mRootNode = new aiNode();
|
||||||
std::vector<aiNode*> children;
|
std::vector<aiNode*> children;
|
||||||
|
|
||||||
while(ReadToEndElement(D3MF::XmlTag::model)) {
|
while(ReadToEndElement(D3MF::XmlTag::model))
|
||||||
if(xmlReader->getNodeName() == D3MF::XmlTag::object) {
|
{
|
||||||
|
|
||||||
|
if(xmlReader->getNodeName() == D3MF::XmlTag::object)
|
||||||
|
{
|
||||||
children.push_back(ReadObject(scene));
|
children.push_back(ReadObject(scene));
|
||||||
} else if(xmlReader->getNodeName() == D3MF::XmlTag::build) {
|
}
|
||||||
// ???
|
else if(xmlReader->getNodeName() == D3MF::XmlTag::build)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( scene->mRootNode->mName.length == 0 ) {
|
if(scene->mRootNode->mName.length == 0)
|
||||||
scene->mRootNode->mName.Set( "3MF" );
|
scene->mRootNode->mName.Set("3MF");
|
||||||
}
|
|
||||||
|
|
||||||
scene->mNumMeshes = static_cast<unsigned int>(meshes.size());
|
scene->mNumMeshes = static_cast<unsigned int>(meshes.size());
|
||||||
scene->mMeshes = new aiMesh*[scene->mNumMeshes]();
|
scene->mMeshes = new aiMesh*[scene->mNumMeshes]();
|
||||||
|
@ -119,10 +131,12 @@ public:
|
||||||
scene->mRootNode->mChildren = new aiNode*[scene->mRootNode->mNumChildren]();
|
scene->mRootNode->mChildren = new aiNode*[scene->mRootNode->mNumChildren]();
|
||||||
|
|
||||||
std::copy(children.begin(), children.end(), scene->mRootNode->mChildren);
|
std::copy(children.begin(), children.end(), scene->mRootNode->mChildren);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
aiNode* ReadObject(aiScene* scene) {
|
aiNode* ReadObject(aiScene* scene)
|
||||||
|
{
|
||||||
ScopeGuard<aiNode> node(new aiNode());
|
ScopeGuard<aiNode> node(new aiNode());
|
||||||
|
|
||||||
std::vector<unsigned long> meshIds;
|
std::vector<unsigned long> meshIds;
|
||||||
|
@ -143,14 +157,17 @@ private:
|
||||||
|
|
||||||
size_t meshIdx = meshes.size();
|
size_t meshIdx = meshes.size();
|
||||||
|
|
||||||
while(ReadToEndElement(D3MF::XmlTag::object)) {
|
while(ReadToEndElement(D3MF::XmlTag::object))
|
||||||
if(xmlReader->getNodeName() == D3MF::XmlTag::mesh) {
|
{
|
||||||
|
if(xmlReader->getNodeName() == D3MF::XmlTag::mesh)
|
||||||
|
{
|
||||||
auto mesh = ReadMesh();
|
auto mesh = ReadMesh();
|
||||||
|
|
||||||
mesh->mName.Set(name);
|
mesh->mName.Set(name);
|
||||||
meshes.push_back(mesh);
|
meshes.push_back(mesh);
|
||||||
meshIds.push_back(static_cast<unsigned long>(meshIdx));
|
meshIds.push_back(static_cast<unsigned long>(meshIdx));
|
||||||
meshIdx++;
|
meshIdx++;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,35 +178,49 @@ private:
|
||||||
std::copy(meshIds.begin(), meshIds.end(), node->mMeshes);
|
std::copy(meshIds.begin(), meshIds.end(), node->mMeshes);
|
||||||
|
|
||||||
return node.dismiss();
|
return node.dismiss();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
aiMesh* ReadMesh() {
|
aiMesh* ReadMesh()
|
||||||
|
{
|
||||||
aiMesh* mesh = new aiMesh();
|
aiMesh* mesh = new aiMesh();
|
||||||
while(ReadToEndElement(D3MF::XmlTag::mesh)) {
|
|
||||||
if(xmlReader->getNodeName() == D3MF::XmlTag::vertices) {
|
while(ReadToEndElement(D3MF::XmlTag::mesh))
|
||||||
|
{
|
||||||
|
if(xmlReader->getNodeName() == D3MF::XmlTag::vertices)
|
||||||
|
{
|
||||||
ImportVertices(mesh);
|
ImportVertices(mesh);
|
||||||
} else if(xmlReader->getNodeName() == D3MF::XmlTag::triangles) {
|
}
|
||||||
|
else if(xmlReader->getNodeName() == D3MF::XmlTag::triangles)
|
||||||
|
{
|
||||||
ImportTriangles(mesh);
|
ImportTriangles(mesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return mesh;
|
return mesh;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImportVertices(aiMesh* mesh) {
|
void ImportVertices(aiMesh* mesh)
|
||||||
|
{
|
||||||
std::vector<aiVector3D> vertices;
|
std::vector<aiVector3D> vertices;
|
||||||
|
|
||||||
while ( ReadToEndElement(D3MF::XmlTag::vertices) ) {
|
while(ReadToEndElement(D3MF::XmlTag::vertices))
|
||||||
if(xmlReader->getNodeName() == D3MF::XmlTag::vertex) {
|
{
|
||||||
|
if(xmlReader->getNodeName() == D3MF::XmlTag::vertex)
|
||||||
|
{
|
||||||
vertices.push_back(ReadVertex());
|
vertices.push_back(ReadVertex());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mesh->mNumVertices = static_cast<unsigned int>(vertices.size());
|
mesh->mNumVertices = static_cast<unsigned int>(vertices.size());
|
||||||
mesh->mVertices = new aiVector3D[mesh->mNumVertices];
|
mesh->mVertices = new aiVector3D[mesh->mNumVertices];
|
||||||
std::copy(vertices.begin(), vertices.end(), mesh->mVertices);
|
|
||||||
}
|
|
||||||
|
|
||||||
aiVector3D ReadVertex() {
|
std::copy(vertices.begin(), vertices.end(), mesh->mVertices);
|
||||||
|
|
||||||
|
}
|
||||||
|
aiVector3D ReadVertex()
|
||||||
|
{
|
||||||
aiVector3D vertex;
|
aiVector3D vertex;
|
||||||
|
|
||||||
vertex.x = ai_strtof(xmlReader->getAttributeValue(D3MF::XmlTag::x.c_str()), nullptr);
|
vertex.x = ai_strtof(xmlReader->getAttributeValue(D3MF::XmlTag::x.c_str()), nullptr);
|
||||||
|
@ -199,11 +230,15 @@ private:
|
||||||
return vertex;
|
return vertex;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImportTriangles(aiMesh* mesh) {
|
void ImportTriangles(aiMesh* mesh)
|
||||||
|
{
|
||||||
std::vector<aiFace> faces;
|
std::vector<aiFace> faces;
|
||||||
|
|
||||||
while(ReadToEndElement(D3MF::XmlTag::triangles)) {
|
|
||||||
if(xmlReader->getNodeName() == D3MF::XmlTag::triangle) {
|
while(ReadToEndElement(D3MF::XmlTag::triangles))
|
||||||
|
{
|
||||||
|
if(xmlReader->getNodeName() == D3MF::XmlTag::triangle)
|
||||||
|
{
|
||||||
faces.push_back(ReadTriangle());
|
faces.push_back(ReadTriangle());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -212,12 +247,13 @@ private:
|
||||||
mesh->mFaces = new aiFace[mesh->mNumFaces];
|
mesh->mFaces = new aiFace[mesh->mNumFaces];
|
||||||
mesh->mPrimitiveTypes = aiPrimitiveType_TRIANGLE;
|
mesh->mPrimitiveTypes = aiPrimitiveType_TRIANGLE;
|
||||||
|
|
||||||
|
|
||||||
std::copy(faces.begin(), faces.end(), mesh->mFaces);
|
std::copy(faces.begin(), faces.end(), mesh->mFaces);
|
||||||
}
|
}
|
||||||
|
|
||||||
aiFace ReadTriangle() {
|
aiFace ReadTriangle()
|
||||||
|
{
|
||||||
aiFace face;
|
aiFace face;
|
||||||
|
|
||||||
face.mNumIndices = 3;
|
face.mNumIndices = 3;
|
||||||
face.mIndices = new unsigned int[face.mNumIndices];
|
face.mIndices = new unsigned int[face.mNumIndices];
|
||||||
face.mIndices[0] = static_cast<unsigned int>(std::atoi(xmlReader->getAttributeValue(D3MF::XmlTag::v1.c_str())));
|
face.mIndices[0] = static_cast<unsigned int>(std::atoi(xmlReader->getAttributeValue(D3MF::XmlTag::v1.c_str())));
|
||||||
|
@ -228,25 +264,35 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool ReadToStartElement(const std::string& startTag) {
|
|
||||||
while(xmlReader->read()) {
|
bool ReadToStartElement(const std::string& startTag)
|
||||||
if (xmlReader->getNodeType() == irr::io::EXN_ELEMENT && xmlReader->getNodeName() == startTag) {
|
{
|
||||||
|
while(xmlReader->read())
|
||||||
|
{
|
||||||
|
if (xmlReader->getNodeType() == irr::io::EXN_ELEMENT && xmlReader->getNodeName() == startTag)
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
} else if (xmlReader->getNodeType() == irr::io::EXN_ELEMENT_END &&
|
}
|
||||||
xmlReader->getNodeName() == startTag) {
|
else if (xmlReader->getNodeType() == irr::io::EXN_ELEMENT_END &&
|
||||||
|
xmlReader->getNodeName() == startTag)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// DefaultLogger::get()->error("unexpected EOF, expected closing <" + closeTag + "> tag");
|
//DefaultLogger::get()->error("unexpected EOF, expected closing <" + closeTag + "> tag");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ReadToEndElement(const std::string& closeTag) {
|
bool ReadToEndElement(const std::string& closeTag)
|
||||||
while(xmlReader->read()) {
|
{
|
||||||
|
while(xmlReader->read())
|
||||||
|
{
|
||||||
if (xmlReader->getNodeType() == irr::io::EXN_ELEMENT) {
|
if (xmlReader->getNodeType() == irr::io::EXN_ELEMENT) {
|
||||||
return true;
|
return true;
|
||||||
} else if (xmlReader->getNodeType() == irr::io::EXN_ELEMENT_END
|
}
|
||||||
&& xmlReader->getNodeName() == closeTag) {
|
else if (xmlReader->getNodeType() == irr::io::EXN_ELEMENT_END
|
||||||
|
&& xmlReader->getNodeName() == closeTag)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -254,6 +300,7 @@ private:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<aiMesh*> meshes;
|
std::vector<aiMesh*> meshes;
|
||||||
XmlReader* xmlReader;
|
XmlReader* xmlReader;
|
||||||
|
@ -261,6 +308,7 @@ private:
|
||||||
|
|
||||||
} //namespace D3MF
|
} //namespace D3MF
|
||||||
|
|
||||||
|
|
||||||
static const aiImporterDesc desc = {
|
static const aiImporterDesc desc = {
|
||||||
"3mf Importer",
|
"3mf Importer",
|
||||||
"",
|
"",
|
||||||
|
@ -274,15 +322,19 @@ static const aiImporterDesc desc = {
|
||||||
"3mf"
|
"3mf"
|
||||||
};
|
};
|
||||||
|
|
||||||
D3MFImporter::D3MFImporter() {
|
|
||||||
// empty
|
D3MFImporter::D3MFImporter()
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
D3MFImporter::~D3MFImporter() {
|
D3MFImporter::~D3MFImporter()
|
||||||
// empty
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool D3MFImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool checkSig) const {
|
bool D3MFImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool checkSig) const
|
||||||
|
{
|
||||||
const std::string extension = GetExtension(pFile);
|
const std::string extension = GetExtension(pFile);
|
||||||
if(extension == "3mf") {
|
if(extension == "3mf") {
|
||||||
return true;
|
return true;
|
||||||
|
@ -295,15 +347,18 @@ bool D3MFImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void D3MFImporter::SetupProperties(const Importer *pImp) {
|
void D3MFImporter::SetupProperties(const Importer *pImp)
|
||||||
// empty
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const aiImporterDesc *D3MFImporter::GetInfo() const {
|
const aiImporterDesc *D3MFImporter::GetInfo() const
|
||||||
|
{
|
||||||
return &desc;
|
return &desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void D3MFImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) {
|
void D3MFImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler)
|
||||||
|
{
|
||||||
D3MF::D3MFOpcPackage opcPackage(pIOHandler, pFile);
|
D3MF::D3MFOpcPackage opcPackage(pIOHandler, pFile);
|
||||||
|
|
||||||
std::unique_ptr<CIrrXML_IOStreamReader> xmlStream(new CIrrXML_IOStreamReader(opcPackage.RootStream()));
|
std::unique_ptr<CIrrXML_IOStreamReader> xmlStream(new CIrrXML_IOStreamReader(opcPackage.RootStream()));
|
||||||
|
|
|
@ -99,27 +99,24 @@ ObjFile::Model *ObjFileParser::GetModel() const {
|
||||||
}
|
}
|
||||||
void ignoreNewLines(IOStreamBuffer<char> &streamBuffer, std::vector<char> &buffer)
|
void ignoreNewLines(IOStreamBuffer<char> &streamBuffer, std::vector<char> &buffer)
|
||||||
{
|
{
|
||||||
std::vector<char> buf(buffer);
|
auto curPosition = buffer.begin();
|
||||||
auto copyPosition = buffer.begin();
|
do
|
||||||
auto curPosition = buf.cbegin();
|
{
|
||||||
do
|
while (*curPosition!='\n'&&*curPosition!='\\')
|
||||||
{
|
{
|
||||||
while (*curPosition != '\n'&&*curPosition != '\\')
|
++curPosition;
|
||||||
{
|
}
|
||||||
++curPosition;
|
if (*curPosition=='\\')
|
||||||
}
|
{
|
||||||
if (*curPosition == '\\')
|
std::vector<char> tempBuf;
|
||||||
{
|
do
|
||||||
copyPosition = std::copy(buf.cbegin(), curPosition, copyPosition);
|
{
|
||||||
*(copyPosition++) = ' ';
|
streamBuffer.getNextLine(tempBuf);
|
||||||
do
|
} while (tempBuf[0]=='\n');
|
||||||
{
|
*curPosition = ' ';
|
||||||
streamBuffer.getNextLine(buf);
|
std::copy(tempBuf.cbegin(), tempBuf.cend(), ++curPosition);
|
||||||
} while (buf[0] == '\n');
|
}
|
||||||
curPosition = buf.cbegin();
|
} while (*curPosition!='\n');
|
||||||
}
|
|
||||||
} while (*curPosition != '\n');
|
|
||||||
std::copy(buf.cbegin(), curPosition, copyPosition);
|
|
||||||
}
|
}
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// File parsing method.
|
// File parsing method.
|
||||||
|
|
|
@ -511,7 +511,7 @@ void glTFExporter::ExportMeshes()
|
||||||
// Variables needed for compression. END.
|
// Variables needed for compression. END.
|
||||||
|
|
||||||
std::string fname = std::string(mFilename);
|
std::string fname = std::string(mFilename);
|
||||||
std::string bufferIdPrefix = fname.substr(0, fname.find("."));
|
std::string bufferIdPrefix = fname.substr(0, fname.rfind(".gltf"));
|
||||||
std::string bufferId = mAsset->FindUniqueID("", bufferIdPrefix.c_str());
|
std::string bufferId = mAsset->FindUniqueID("", bufferIdPrefix.c_str());
|
||||||
|
|
||||||
Ref<Buffer> b = mAsset->GetBodyBuffer();
|
Ref<Buffer> b = mAsset->GetBodyBuffer();
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2016, assimp team
|
Copyright (c) 2006-2017, assimp team
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
@ -377,8 +377,10 @@ struct aiAnimMesh
|
||||||
* from language bindings.
|
* from language bindings.
|
||||||
*/
|
*/
|
||||||
unsigned int mNumVertices;
|
unsigned int mNumVertices;
|
||||||
|
|
||||||
/** Weight of the AnimMesh. */
|
/**
|
||||||
|
* Weight of the AnimMesh.
|
||||||
|
*/
|
||||||
float mWeight;
|
float mWeight;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -389,6 +391,7 @@ struct aiAnimMesh
|
||||||
, mTangents( NULL )
|
, mTangents( NULL )
|
||||||
, mBitangents( NULL )
|
, mBitangents( NULL )
|
||||||
, mNumVertices( 0 )
|
, mNumVertices( 0 )
|
||||||
|
, mWeight( 0.0f )
|
||||||
{
|
{
|
||||||
// fixme consider moving this to the ctor initializer list as well
|
// fixme consider moving this to the ctor initializer list as well
|
||||||
for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; a++){
|
for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; a++){
|
||||||
|
@ -633,7 +636,9 @@ struct aiMesh
|
||||||
* Note! Currently only works with Collada loader.*/
|
* Note! Currently only works with Collada loader.*/
|
||||||
C_STRUCT aiAnimMesh** mAnimMeshes;
|
C_STRUCT aiAnimMesh** mAnimMeshes;
|
||||||
|
|
||||||
/** Method of morphing when animeshes are specified. */
|
/**
|
||||||
|
* Method of morphing when animeshes are specified.
|
||||||
|
*/
|
||||||
unsigned int mMethod;
|
unsigned int mMethod;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -653,6 +658,7 @@ struct aiMesh
|
||||||
, mMaterialIndex( 0 )
|
, mMaterialIndex( 0 )
|
||||||
, mNumAnimMeshes( 0 )
|
, mNumAnimMeshes( 0 )
|
||||||
, mAnimMeshes( NULL )
|
, mAnimMeshes( NULL )
|
||||||
|
, mMethod( 0 )
|
||||||
{
|
{
|
||||||
for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; a++)
|
for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; a++)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue