xml-migration: migration of XGLImporter.
parent
1a8d5667b6
commit
979153522c
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
|||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
|
@ -90,9 +88,9 @@ void AMFImporter::Clear() {
|
|||
}
|
||||
|
||||
AMFImporter::~AMFImporter() {
|
||||
if (mReader != nullptr) {
|
||||
delete mReader;
|
||||
mReader = nullptr;
|
||||
if (mXmlParser != nullptr) {
|
||||
delete mXmlParser;
|
||||
mXmlParser = nullptr;
|
||||
}
|
||||
|
||||
// Clear() is accounting if data already is deleted. So, just check again if all data is deleted.
|
||||
|
@ -106,7 +104,9 @@ AMFImporter::~AMFImporter() {
|
|||
bool AMFImporter::Find_NodeElement(const std::string &pID, const CAMFImporter_NodeElement::EType pType, CAMFImporter_NodeElement **pNodeElement) const {
|
||||
for (CAMFImporter_NodeElement *ne : mNodeElement_List) {
|
||||
if ((ne->ID == pID) && (ne->Type == pType)) {
|
||||
if (pNodeElement != nullptr) *pNodeElement = ne;
|
||||
if (pNodeElement != nullptr) {
|
||||
*pNodeElement = ne;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -173,10 +173,9 @@ void AMFImporter::Throw_ID_NotFound(const std::string &pID) const {
|
|||
/************************************************************* Functions: XML set ************************************************************/
|
||||
/*********************************************************************************************************************************************/
|
||||
|
||||
void AMFImporter::XML_CheckNode_MustHaveChildren( XmlNode *node ) {
|
||||
//if (mReader->isEmptyElement()) throw DeadlyImportError(std::string("Node <") + mReader->getNodeName() + "> must have children.");
|
||||
if (node->getNode()->children().begin() == node->getNode()->children().end()) {
|
||||
throw DeadlyImportError(std::string("Node <") + std::string(node->getNode()->name()) + "> must have children.");
|
||||
void AMFImporter::XML_CheckNode_MustHaveChildren( XmlNode &node ) {
|
||||
if (node.children().begin() == node.children().end()) {
|
||||
throw DeadlyImportError(std::string("Node <") + std::string(node.name()) + "> must have children.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -221,20 +220,23 @@ casu_cres:
|
|||
}
|
||||
}
|
||||
*/
|
||||
bool AMFImporter::XML_SearchNode(const std::string &pNodeName) {
|
||||
|
||||
mReader->while (mReader->read()) {
|
||||
//if((mReader->getNodeType() == irr::io::EXN_ELEMENT) && XML_CheckNode_NameEqual(pNodeName)) return true;
|
||||
if ((mReader->getNodeType() == pugi::node_element) && XML_CheckNode_NameEqual(pNodeName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
bool AMFImporter::XML_SearchNode(const std::string &nodeName) {
|
||||
XmlNode *root = mXmlParser->getRootNode();
|
||||
if (nullptr == root) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
find_node_by_name_predicate predicate(nodeName);
|
||||
XmlNode node = root->find_node(predicate);
|
||||
if (node.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AMFImporter::XML_ReadNode_GetAttrVal_AsBool(const int pAttrIdx) {
|
||||
std::string val(mReader->getAttributeValue(pAttrIdx));
|
||||
bool AMFImporter::XML_ReadNode_GetAttrVal_AsBool (const int pAttrIdx) {
|
||||
std::string val(mXmlParser->getAttributeValue(pAttrIdx));
|
||||
|
||||
if ((val == "false") || (val == "0"))
|
||||
return false;
|
||||
|
@ -248,42 +250,42 @@ float AMFImporter::XML_ReadNode_GetAttrVal_AsFloat(const int pAttrIdx) {
|
|||
std::string val;
|
||||
float tvalf;
|
||||
|
||||
ParseHelper_FixTruncatedFloatString(mReader->getAttributeValue(pAttrIdx), val);
|
||||
ParseHelper_FixTruncatedFloatString(mXmlParser->getAttributeValue(pAttrIdx), val);
|
||||
fast_atoreal_move(val.c_str(), tvalf, false);
|
||||
|
||||
return tvalf;
|
||||
}
|
||||
|
||||
uint32_t AMFImporter::XML_ReadNode_GetAttrVal_AsU32(const int pAttrIdx) {
|
||||
return strtoul10(mReader->getAttributeValue(pAttrIdx));
|
||||
return strtoul10(mXmlParser->getAttributeValue(pAttrIdx));
|
||||
}
|
||||
|
||||
float AMFImporter::XML_ReadNode_GetVal_AsFloat() {
|
||||
std::string val;
|
||||
float tvalf;
|
||||
|
||||
if (!mReader->read()) throw DeadlyImportError("XML_ReadNode_GetVal_AsFloat. No data, seems file is corrupt.");
|
||||
if (mReader->getNodeType() != irr::io::EXN_TEXT) throw DeadlyImportError("XML_ReadNode_GetVal_AsFloat. Invalid type of XML element, seems file is corrupt.");
|
||||
if (!mXmlParser->read()) throw DeadlyImportError("XML_ReadNode_GetVal_AsFloat. No data, seems file is corrupt.");
|
||||
if (mXmlParser->getNodeType() != irr::io::EXN_TEXT) throw DeadlyImportError("XML_ReadNode_GetVal_AsFloat. Invalid type of XML element, seems file is corrupt.");
|
||||
|
||||
ParseHelper_FixTruncatedFloatString(mReader->getNodeData(), val);
|
||||
ParseHelper_FixTruncatedFloatString(mXmlParser->getNodeData(), val);
|
||||
fast_atoreal_move(val.c_str(), tvalf, false);
|
||||
|
||||
return tvalf;
|
||||
}
|
||||
|
||||
uint32_t AMFImporter::XML_ReadNode_GetVal_AsU32() {
|
||||
if (!mReader->read()) throw DeadlyImportError("XML_ReadNode_GetVal_AsU32. No data, seems file is corrupt.");
|
||||
if (mReader->getNodeType() != irr::io::EXN_TEXT) throw DeadlyImportError("XML_ReadNode_GetVal_AsU32. Invalid type of XML element, seems file is corrupt.");
|
||||
if (!mXmlParser->read()) throw DeadlyImportError("XML_ReadNode_GetVal_AsU32. No data, seems file is corrupt.");
|
||||
if (mXmlParser->getNodeType() != irr::io::EXN_TEXT) throw DeadlyImportError("XML_ReadNode_GetVal_AsU32. Invalid type of XML element, seems file is corrupt.");
|
||||
|
||||
return strtoul10(mReader->getNodeData());
|
||||
return strtoul10(mXmlParser->getNodeData());
|
||||
}
|
||||
|
||||
void AMFImporter::XML_ReadNode_GetVal_AsString(std::string &pValue) {
|
||||
if (!mReader->read()) throw DeadlyImportError("XML_ReadNode_GetVal_AsString. No data, seems file is corrupt.");
|
||||
if (mReader->getNodeType() != irr::io::EXN_TEXT)
|
||||
if (!mXmlParser->read()) throw DeadlyImportError("XML_ReadNode_GetVal_AsString. No data, seems file is corrupt.");
|
||||
if (mXmlParser->getNodeType() != irr::io::EXN_TEXT)
|
||||
throw DeadlyImportError("XML_ReadNode_GetVal_AsString. Invalid type of XML element, seems file is corrupt.");
|
||||
|
||||
pValue = mReader->getNodeData();
|
||||
pValue = mXmlParser->getNodeData();
|
||||
}
|
||||
|
||||
/*********************************************************************************************************************************************/
|
||||
|
@ -383,8 +385,8 @@ void AMFImporter::ParseFile(const std::string &pFile, IOSystem *pIOHandler) {
|
|||
throw DeadlyImportError("Failed to open AMF file " + pFile + ".");
|
||||
}
|
||||
|
||||
mReader = new XmlParser;
|
||||
XmlNode *root = mReader->parse(file.get());
|
||||
mXmlParser = new XmlParser;
|
||||
XmlNode *root = mXmlParser->parse(file.get());
|
||||
if (nullptr == root) {
|
||||
throw DeadlyImportError("Failed to create XML reader for file" + pFile + ".");
|
||||
}
|
||||
|
@ -398,8 +400,8 @@ void AMFImporter::ParseFile(const std::string &pFile, IOSystem *pIOHandler) {
|
|||
|
||||
ParseNode_Root(root);
|
||||
|
||||
delete mReader;
|
||||
mReader = nullptr;
|
||||
delete mXmlParser;
|
||||
mXmlParser = nullptr;
|
||||
}
|
||||
|
||||
// <amf
|
||||
|
@ -502,7 +504,7 @@ void AMFImporter::ParseNode_Constellation() {
|
|||
|
||||
// Read attributes for node <constellation>.
|
||||
MACRO_ATTRREAD_LOOPBEG;
|
||||
MACRO_ATTRREAD_CHECK_RET("id", id, mReader->getAttributeValue);
|
||||
MACRO_ATTRREAD_CHECK_RET("id", id, mXmlParser->getAttributeValue);
|
||||
MACRO_ATTRREAD_LOOPEND;
|
||||
|
||||
// create and if needed - define new grouping object.
|
||||
|
@ -512,7 +514,7 @@ void AMFImporter::ParseNode_Constellation() {
|
|||
|
||||
if (!id.empty()) als.ID = id;
|
||||
// Check for child nodes
|
||||
if (!mReader->isEmptyElement()) {
|
||||
if (!mXmlParser->isEmptyElement()) {
|
||||
ParseHelper_Node_Enter(ne);
|
||||
MACRO_NODECHECK_LOOPBEGIN("constellation");
|
||||
if (XML_CheckNode_NameEqual("instance")) {
|
||||
|
@ -546,7 +548,7 @@ void AMFImporter::ParseNode_Instance() {
|
|||
|
||||
// Read attributes for node <constellation>.
|
||||
MACRO_ATTRREAD_LOOPBEG;
|
||||
MACRO_ATTRREAD_CHECK_RET("objectid", objectid, mReader->getAttributeValue);
|
||||
MACRO_ATTRREAD_CHECK_RET("objectid", objectid, mXmlParser->getAttributeValue);
|
||||
MACRO_ATTRREAD_LOOPEND;
|
||||
|
||||
// used object id must be defined, check that.
|
||||
|
@ -558,7 +560,7 @@ void AMFImporter::ParseNode_Instance() {
|
|||
|
||||
als.ObjectID = objectid;
|
||||
// Check for child nodes
|
||||
if (!mReader->isEmptyElement()) {
|
||||
if (!mXmlParser->isEmptyElement()) {
|
||||
bool read_flag[6] = { false, false, false, false, false, false };
|
||||
|
||||
als.Delta.Set(0, 0, 0);
|
||||
|
@ -625,7 +627,7 @@ void AMFImporter::ParseNode_Object(XmlNode *nodeInst) {
|
|||
ParseNode_Metadata(*it);
|
||||
}
|
||||
}
|
||||
if (!mReader->isEmptyElement()) {
|
||||
if (!mXmlParser->isEmptyElement()) {
|
||||
bool col_read = false;
|
||||
|
||||
ParseHelper_Node_Enter(ne);
|
||||
|
@ -682,10 +684,10 @@ void AMFImporter::ParseNode_Metadata() {
|
|||
|
||||
// read attribute
|
||||
MACRO_ATTRREAD_LOOPBEG;
|
||||
MACRO_ATTRREAD_CHECK_RET("type", type, mReader->getAttributeValue);
|
||||
MACRO_ATTRREAD_CHECK_RET("type", type, mXmlParser->getAttributeValue);
|
||||
MACRO_ATTRREAD_LOOPEND;
|
||||
// and value of node.
|
||||
value = mReader->getNodeData();
|
||||
value = mXmlParser->getNodeData();
|
||||
// Create node element and assign read data.
|
||||
ne = new CAMFImporter_NodeElement_Metadata(mNodeElement_Cur);
|
||||
((CAMFImporter_NodeElement_Metadata *)ne)->Type = type;
|
||||
|
|
|
@ -63,8 +63,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
namespace Assimp {
|
||||
|
||||
class XmlNode;
|
||||
|
||||
/// \class AMFImporter
|
||||
/// Class that holding scene graph which include: geometry, metadata, materials etc.
|
||||
///
|
||||
|
@ -280,7 +278,7 @@ private:
|
|||
void Throw_ID_NotFound(const std::string& pID) const;
|
||||
|
||||
/// Check if current node have children: <node>...</node>. If not then exception will thrown.
|
||||
void XML_CheckNode_MustHaveChildren(XmlNode *node);
|
||||
void XML_CheckNode_MustHaveChildren( XmlNode &node);
|
||||
|
||||
/// Check if current node name is equal to pNodeName.
|
||||
/// \param [in] pNodeName - name for checking.
|
||||
|
@ -345,49 +343,49 @@ private:
|
|||
void ParseHelper_Decode_Base64(const std::string& pInputBase64, std::vector<uint8_t>& pOutputData) const;
|
||||
|
||||
/// Parse <AMF> node of the file.
|
||||
void ParseNode_Root(XmlNode *root);
|
||||
void ParseNode_Root(XmlNode &root);
|
||||
|
||||
/// Parse <constellation> node of the file.
|
||||
void ParseNode_Constellation(XmlNode *node);
|
||||
void ParseNode_Constellation(XmlNode &node);
|
||||
|
||||
/// Parse <instance> node of the file.
|
||||
void ParseNode_Instance(XmlNode *node);
|
||||
void ParseNode_Instance(XmlNode &node);
|
||||
|
||||
/// Parse <material> node of the file.
|
||||
void ParseNode_Material(XmlNode *node);
|
||||
void ParseNode_Material(XmlNode &node);
|
||||
|
||||
/// Parse <metadata> node.
|
||||
void ParseNode_Metadata(XmlNode *node);
|
||||
void ParseNode_Metadata(XmlNode &node);
|
||||
|
||||
/// Parse <object> node of the file.
|
||||
void ParseNode_Object(XmlNode *node);
|
||||
void ParseNode_Object(XmlNode &node);
|
||||
|
||||
/// Parse <texture> node of the file.
|
||||
void ParseNode_Texture(XmlNode *node);
|
||||
void ParseNode_Texture(XmlNode &node);
|
||||
|
||||
/// Parse <coordinates> node of the file.
|
||||
void ParseNode_Coordinates(XmlNode *node);
|
||||
void ParseNode_Coordinates(XmlNode &node);
|
||||
|
||||
/// Parse <edge> node of the file.
|
||||
void ParseNode_Edge(XmlNode *node);
|
||||
void ParseNode_Edge(XmlNode &node);
|
||||
|
||||
/// Parse <mesh> node of the file.
|
||||
void ParseNode_Mesh(XmlNode *node);
|
||||
void ParseNode_Mesh(XmlNode &node);
|
||||
|
||||
/// Parse <triangle> node of the file.
|
||||
void ParseNode_Triangle(XmlNode *node);
|
||||
void ParseNode_Triangle(XmlNode &node);
|
||||
|
||||
/// Parse <vertex> node of the file.
|
||||
void ParseNode_Vertex(XmlNode *node);
|
||||
void ParseNode_Vertex(XmlNode &node);
|
||||
|
||||
/// Parse <vertices> node of the file.
|
||||
void ParseNode_Vertices(XmlNode *node);
|
||||
void ParseNode_Vertices(XmlNode &node);
|
||||
|
||||
/// Parse <volume> node of the file.
|
||||
void ParseNode_Volume(XmlNode *node);
|
||||
void ParseNode_Volume(XmlNode &node);
|
||||
|
||||
/// Parse <color> node of the file.
|
||||
void ParseNode_Color(XmlNode *node);
|
||||
void ParseNode_Color(XmlNode &node);
|
||||
|
||||
/// Parse <texmap> of <map> node of the file.
|
||||
/// \param [in] pUseOldName - if true then use old name of node(and children) - <map>, instead of new name - <texmap>.
|
||||
|
@ -397,7 +395,7 @@ public:
|
|||
/// Default constructor.
|
||||
AMFImporter() AI_NO_EXCEPT
|
||||
: mNodeElement_Cur(nullptr)
|
||||
, mReader(nullptr) {
|
||||
, mXmlParser(nullptr) {
|
||||
// empty
|
||||
}
|
||||
|
||||
|
@ -423,7 +421,7 @@ private:
|
|||
|
||||
CAMFImporter_NodeElement* mNodeElement_Cur;///< Current element.
|
||||
std::list<CAMFImporter_NodeElement*> mNodeElement_List;///< All elements of scene graph.
|
||||
XmlParser *mReader;
|
||||
XmlParser *mXmlParser;
|
||||
//irr::io::IrrXMLReader* mReader;///< Pointer to XML-reader object
|
||||
std::string mUnit;
|
||||
std::list<SPP_Material> mMaterial_Converted;///< List of converted materials for postprocessing step.
|
||||
|
|
|
@ -66,7 +66,7 @@ void AMFImporter::ParseNode_Mesh()
|
|||
// create new mesh object.
|
||||
ne = new CAMFImporter_NodeElement_Mesh(mNodeElement_Cur);
|
||||
// Check for child nodes
|
||||
if(!mReader->isEmptyElement())
|
||||
if(!mXmlParser->isEmptyElement())
|
||||
{
|
||||
bool vert_read = false;
|
||||
|
||||
|
@ -107,7 +107,7 @@ CAMFImporter_NodeElement* ne;
|
|||
// create new mesh object.
|
||||
ne = new CAMFImporter_NodeElement_Vertices(mNodeElement_Cur);
|
||||
// Check for child nodes
|
||||
if(!mReader->isEmptyElement())
|
||||
if(!mXmlParser->isEmptyElement())
|
||||
{
|
||||
ParseHelper_Node_Enter(ne);
|
||||
MACRO_NODECHECK_LOOPBEGIN("vertices");
|
||||
|
@ -135,7 +135,7 @@ CAMFImporter_NodeElement* ne;
|
|||
// create new mesh object.
|
||||
ne = new CAMFImporter_NodeElement_Vertex(mNodeElement_Cur);
|
||||
// Check for child nodes
|
||||
if(!mReader->isEmptyElement())
|
||||
if(!mXmlParser->isEmptyElement())
|
||||
{
|
||||
bool col_read = false;
|
||||
bool coord_read = false;
|
||||
|
@ -196,7 +196,7 @@ CAMFImporter_NodeElement* ne;
|
|||
CAMFImporter_NodeElement_Coordinates& als = *((CAMFImporter_NodeElement_Coordinates*)ne);// alias for convenience
|
||||
|
||||
// Check for child nodes
|
||||
if(!mReader->isEmptyElement())
|
||||
if(!mXmlParser->isEmptyElement())
|
||||
{
|
||||
bool read_flag[3] = { false, false, false };
|
||||
|
||||
|
@ -236,8 +236,8 @@ CAMFImporter_NodeElement* ne;
|
|||
|
||||
// Read attributes for node <color>.
|
||||
MACRO_ATTRREAD_LOOPBEG;
|
||||
MACRO_ATTRREAD_CHECK_RET("materialid", materialid, mReader->getAttributeValue);
|
||||
MACRO_ATTRREAD_CHECK_RET("type", type, mReader->getAttributeValue);
|
||||
MACRO_ATTRREAD_CHECK_RET("materialid", materialid, mXmlParser->getAttributeValue);
|
||||
MACRO_ATTRREAD_CHECK_RET("type", type, mXmlParser->getAttributeValue);
|
||||
MACRO_ATTRREAD_LOOPEND;
|
||||
|
||||
// create new object.
|
||||
|
@ -246,7 +246,7 @@ CAMFImporter_NodeElement* ne;
|
|||
((CAMFImporter_NodeElement_Volume*)ne)->MaterialID = materialid;
|
||||
((CAMFImporter_NodeElement_Volume*)ne)->Type = type;
|
||||
// Check for child nodes
|
||||
if(!mReader->isEmptyElement())
|
||||
if(!mXmlParser->isEmptyElement())
|
||||
{
|
||||
bool col_read = false;
|
||||
|
||||
|
@ -296,7 +296,7 @@ CAMFImporter_NodeElement* ne;
|
|||
CAMFImporter_NodeElement_Triangle& als = *((CAMFImporter_NodeElement_Triangle*)ne);// alias for convenience
|
||||
|
||||
// Check for child nodes
|
||||
if(!mReader->isEmptyElement())
|
||||
if(!mXmlParser->isEmptyElement())
|
||||
{
|
||||
bool col_read = false, tex_read = false;
|
||||
bool read_flag[3] = { false, false, false };
|
||||
|
|
|
@ -74,7 +74,7 @@ void AMFImporter::ParseNode_Color() {
|
|||
|
||||
// Read attributes for node <color>.
|
||||
MACRO_ATTRREAD_LOOPBEG;
|
||||
MACRO_ATTRREAD_CHECK_RET("profile", profile, mReader->getAttributeValue);
|
||||
MACRO_ATTRREAD_CHECK_RET("profile", profile, mXmlParser->getAttributeValue);
|
||||
MACRO_ATTRREAD_LOOPEND;
|
||||
|
||||
// create new color object.
|
||||
|
@ -84,7 +84,7 @@ void AMFImporter::ParseNode_Color() {
|
|||
|
||||
als.Profile = profile;
|
||||
// Check for child nodes
|
||||
if(!mReader->isEmptyElement())
|
||||
if(!mXmlParser->isEmptyElement())
|
||||
{
|
||||
bool read_flag[4] = { false, false, false, false };
|
||||
|
||||
|
@ -128,7 +128,7 @@ void AMFImporter::ParseNode_Material() {
|
|||
|
||||
// Read attributes for node <color>.
|
||||
MACRO_ATTRREAD_LOOPBEG;
|
||||
MACRO_ATTRREAD_CHECK_RET("id", id, mReader->getAttributeValue);
|
||||
MACRO_ATTRREAD_CHECK_RET("id", id, mXmlParser->getAttributeValue);
|
||||
MACRO_ATTRREAD_LOOPEND;
|
||||
|
||||
// create new object.
|
||||
|
@ -138,7 +138,7 @@ void AMFImporter::ParseNode_Material() {
|
|||
((CAMFImporter_NodeElement_Material*)ne)->ID = id;
|
||||
|
||||
// Check for child nodes
|
||||
if(!mReader->isEmptyElement())
|
||||
if(!mXmlParser->isEmptyElement())
|
||||
{
|
||||
bool col_read = false;
|
||||
|
||||
|
@ -183,25 +183,13 @@ void AMFImporter::ParseNode_Material() {
|
|||
// then layer by layer.
|
||||
// Multi elements - Yes.
|
||||
// Parent element - <amf>.
|
||||
void AMFImporter::ParseNode_Texture()
|
||||
{
|
||||
std::string id;
|
||||
uint32_t width = 0;
|
||||
uint32_t height = 0;
|
||||
uint32_t depth = 1;
|
||||
std::string type;
|
||||
bool tiled = false;
|
||||
std::string enc64_data;
|
||||
|
||||
// Read attributes for node <color>.
|
||||
MACRO_ATTRREAD_LOOPBEG;
|
||||
MACRO_ATTRREAD_CHECK_RET("id", id, mReader->getAttributeValue);
|
||||
MACRO_ATTRREAD_CHECK_RET("width", width, XML_ReadNode_GetAttrVal_AsU32);
|
||||
MACRO_ATTRREAD_CHECK_RET("height", height, XML_ReadNode_GetAttrVal_AsU32);
|
||||
MACRO_ATTRREAD_CHECK_RET("depth", depth, XML_ReadNode_GetAttrVal_AsU32);
|
||||
MACRO_ATTRREAD_CHECK_RET("type", type, mReader->getAttributeValue);
|
||||
MACRO_ATTRREAD_CHECK_RET("tiled", tiled, XML_ReadNode_GetAttrVal_AsBool);
|
||||
MACRO_ATTRREAD_LOOPEND;
|
||||
void AMFImporter::ParseNode_Texture(XmlNode &node) {
|
||||
std::string id = node.attribute("id").as_string();
|
||||
uint32_t width = node.attribute("width").as_uint();
|
||||
uint32_t height = node.attribute("height").as_uint();
|
||||
uint32_t depth = node.attribute("depth").as_uint();
|
||||
std::string type = node.attribute("type").as_string();
|
||||
bool tiled = node.attribute("tiled").as_bool();
|
||||
|
||||
// create new texture object.
|
||||
CAMFImporter_NodeElement *ne = new CAMFImporter_NodeElement_Texture(mNodeElement_Cur);
|
||||
|
@ -209,7 +197,7 @@ void AMFImporter::ParseNode_Texture()
|
|||
CAMFImporter_NodeElement_Texture& als = *((CAMFImporter_NodeElement_Texture*)ne);// alias for convenience
|
||||
|
||||
// Check for child nodes
|
||||
if (!mReader->isEmptyElement()) {
|
||||
if (!mXmlParser->isEmptyElement()) {
|
||||
XML_ReadNode_GetVal_AsString(enc64_data);
|
||||
}
|
||||
|
||||
|
@ -268,10 +256,10 @@ void AMFImporter::ParseNode_TexMap(const bool pUseOldName) {
|
|||
|
||||
// Read attributes for node <color>.
|
||||
MACRO_ATTRREAD_LOOPBEG;
|
||||
MACRO_ATTRREAD_CHECK_RET("rtexid", rtexid, mReader->getAttributeValue);
|
||||
MACRO_ATTRREAD_CHECK_RET("gtexid", gtexid, mReader->getAttributeValue);
|
||||
MACRO_ATTRREAD_CHECK_RET("btexid", btexid, mReader->getAttributeValue);
|
||||
MACRO_ATTRREAD_CHECK_RET("atexid", atexid, mReader->getAttributeValue);
|
||||
MACRO_ATTRREAD_CHECK_RET("rtexid", rtexid, mXmlParser->getAttributeValue);
|
||||
MACRO_ATTRREAD_CHECK_RET("gtexid", gtexid, mXmlParser->getAttributeValue);
|
||||
MACRO_ATTRREAD_CHECK_RET("btexid", btexid, mXmlParser->getAttributeValue);
|
||||
MACRO_ATTRREAD_CHECK_RET("atexid", atexid, mXmlParser->getAttributeValue);
|
||||
MACRO_ATTRREAD_LOOPEND;
|
||||
|
||||
// create new texture coordinates object.
|
||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
|||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
|
@ -68,11 +66,8 @@ using namespace Assimp::Formatter;
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Constructor to be privately used by Importer
|
||||
ColladaParser::ColladaParser(IOSystem* pIOHandler, const std::string& pFile)
|
||||
: mFileName(pFile)
|
||||
, mReader(nullptr)
|
||||
, mDataLibrary()
|
||||
, mAccessorLibrary()
|
||||
ColladaParser::ColladaParser(IOSystem* pIOHandler, const std::string& pFile) :
|
||||
mFileName(pFile), mXmlParser(nullptr), mDataLibrary(), mAccessorLibrary()
|
||||
, mMeshLibrary()
|
||||
, mNodeLibrary()
|
||||
, mImageLibrary()
|
||||
|
@ -1532,7 +1527,7 @@ void ColladaParser::ReadLight(Collada::Light& pLight)
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Reads a camera entry into the given light
|
||||
void ColladaParser::ReadCamera(Collada::Camera& pCamera)
|
||||
void ColladaParser::ReadCamera(Collada::Camera& camera)
|
||||
{
|
||||
while (mReader->read())
|
||||
{
|
||||
|
@ -1541,26 +1536,26 @@ void ColladaParser::ReadCamera(Collada::Camera& pCamera)
|
|||
SkipElement();
|
||||
}
|
||||
else if (IsElement("orthographic")) {
|
||||
pCamera.mOrtho = true;
|
||||
camera.mOrtho = true;
|
||||
}
|
||||
else if (IsElement("xfov") || IsElement("xmag")) {
|
||||
pCamera.mHorFov = ReadFloatFromTextContent();
|
||||
TestClosing((pCamera.mOrtho ? "xmag" : "xfov"));
|
||||
camera.mHorFov = ReadFloatFromTextContent();
|
||||
TestClosing((camera.mOrtho ? "xmag" : "xfov"));
|
||||
}
|
||||
else if (IsElement("yfov") || IsElement("ymag")) {
|
||||
pCamera.mVerFov = ReadFloatFromTextContent();
|
||||
TestClosing((pCamera.mOrtho ? "ymag" : "yfov"));
|
||||
camera.mVerFov = ReadFloatFromTextContent();
|
||||
TestClosing((camera.mOrtho ? "ymag" : "yfov"));
|
||||
}
|
||||
else if (IsElement("aspect_ratio")) {
|
||||
pCamera.mAspect = ReadFloatFromTextContent();
|
||||
camera.mAspect = ReadFloatFromTextContent();
|
||||
TestClosing("aspect_ratio");
|
||||
}
|
||||
else if (IsElement("znear")) {
|
||||
pCamera.mZNear = ReadFloatFromTextContent();
|
||||
camera.mZNear = ReadFloatFromTextContent();
|
||||
TestClosing("znear");
|
||||
}
|
||||
else if (IsElement("zfar")) {
|
||||
pCamera.mZFar = ReadFloatFromTextContent();
|
||||
camera.mZFar = ReadFloatFromTextContent();
|
||||
TestClosing("zfar");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
|
@ -55,6 +54,7 @@
|
|||
namespace Assimp
|
||||
{
|
||||
class ZipArchiveIOSystem;
|
||||
class XmlParser;
|
||||
|
||||
// ------------------------------------------------------------------------------------------
|
||||
/** Parser helper class for the Collada loader.
|
||||
|
@ -112,7 +112,7 @@ namespace Assimp
|
|||
/** Reads an animation into the given parent structure */
|
||||
void ReadAnimation( Collada::Animation* pParent);
|
||||
|
||||
/** Reads an animation sampler into the given anim channel */
|
||||
/** Reads an animation sampler into the given animation channel */
|
||||
void ReadAnimationSampler( Collada::AnimationChannel& pChannel);
|
||||
|
||||
/** Reads the skeleton controller library */
|
||||
|
@ -157,16 +157,16 @@ namespace Assimp
|
|||
/** Reads an effect entry into the given effect*/
|
||||
void ReadEffect( Collada::Effect& pEffect);
|
||||
|
||||
/** Reads an COMMON effect profile */
|
||||
/// Reads an COMMON effect profile
|
||||
void ReadEffectProfileCommon( Collada::Effect& pEffect);
|
||||
|
||||
/** Read sampler properties */
|
||||
/// Read sampler properties
|
||||
void ReadSamplerProperties( Collada::Sampler& pSampler);
|
||||
|
||||
/** Reads an effect entry containing a color or a texture defining that color */
|
||||
/// Reads an effect entry containing a color or a texture defining that color
|
||||
void ReadEffectColor( aiColor4D& pColor, Collada::Sampler& pSampler);
|
||||
|
||||
/** Reads an effect entry containing a float */
|
||||
/// Reads an effect entry containing a float
|
||||
void ReadEffectFloat( ai_real& pFloat);
|
||||
|
||||
/** Reads an effect parameter specification of any kind */
|
||||
|
@ -182,7 +182,7 @@ namespace Assimp
|
|||
void ReadMesh( Collada::Mesh* pMesh);
|
||||
|
||||
/** Reads a source element - a combination of raw data and an accessor defining
|
||||
* things that should not be redefinable. Yes, that's another rant.
|
||||
* things that should not be re-definable. Yes, that's another rant.
|
||||
*/
|
||||
void ReadSource();
|
||||
|
||||
|
@ -214,7 +214,7 @@ namespace Assimp
|
|||
Collada::Mesh* pMesh, std::vector<Collada::InputChannel>& pPerIndexChannels,
|
||||
size_t currentPrimitive, const std::vector<size_t>& indices);
|
||||
|
||||
/** Reads one triangle of a tristrip into the mesh */
|
||||
/** Reads one triangle of a triangle-strip into the mesh */
|
||||
void ReadPrimTriStrips(size_t numOffsets, size_t perVertexOffset, Collada::Mesh* pMesh,
|
||||
std::vector<Collada::InputChannel>& pPerIndexChannels, size_t currentPrimitive, const std::vector<size_t>& indices);
|
||||
|
||||
|
@ -298,7 +298,8 @@ namespace Assimp
|
|||
std::string mFileName;
|
||||
|
||||
/** XML reader, member for everyday use */
|
||||
irr::io::IrrXMLReader* mReader;
|
||||
//irr::io::IrrXMLReader* mReader;
|
||||
XmlParser *mXmlParser;
|
||||
|
||||
/** All data arrays found in the file by ID. Might be referred to by actually
|
||||
everyone. Collada, you are a steaming pile of indirection. */
|
||||
|
@ -359,19 +360,24 @@ namespace Assimp
|
|||
/** Size unit: how large compared to a meter */
|
||||
ai_real mUnitSize;
|
||||
|
||||
/** Which is the up vector */
|
||||
enum { UP_X, UP_Y, UP_Z } mUpDirection;
|
||||
/// Which is the up vector.
|
||||
enum {
|
||||
UP_X,
|
||||
UP_Y,
|
||||
UP_Z
|
||||
} mUpDirection;
|
||||
|
||||
/** Asset metadata (global for scene) */
|
||||
/// Asset metadata (global for scene)
|
||||
StringMetaData mAssetMetaData;
|
||||
|
||||
/** Collada file format version */
|
||||
/// Collada file format version
|
||||
Collada::FormatVersion mFormat;
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// 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;
|
||||
|
@ -380,11 +386,11 @@ namespace Assimp
|
|||
// ------------------------------------------------------------------------------------------------
|
||||
// Finds the item in the given library by its reference, throws if not found
|
||||
template <typename Type>
|
||||
const Type& ColladaParser::ResolveLibraryReference( const std::map<std::string, Type>& pLibrary, const std::string& pURL) const
|
||||
const Type& ColladaParser::ResolveLibraryReference( const std::map<std::string, Type>& library, const std::string& url) const
|
||||
{
|
||||
typename std::map<std::string, Type>::const_iterator it = pLibrary.find( pURL);
|
||||
if( it == pLibrary.end())
|
||||
ThrowException( Formatter::format() << "Unable to resolve library reference \"" << pURL << "\"." );
|
||||
typename std::map<std::string, Type>::const_iterator it = library.find( url);
|
||||
if( it == library.end())
|
||||
ThrowException( Formatter::format() << "Unable to resolve library reference \"" << url << "\"." );
|
||||
return it->second;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
|
|||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
|
@ -40,7 +39,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
/** @file IRRLoader.h
|
||||
* @brief Declaration of the .irrMesh (Irrlight Engine Mesh Format)
|
||||
* importer class.
|
||||
|
@ -83,7 +81,7 @@ protected:
|
|||
|
||||
private:
|
||||
|
||||
/** Data structure for a scenegraph node animator
|
||||
/** Data structure for a scene-graph node animator
|
||||
*/
|
||||
struct Animator {
|
||||
// Type of the animator
|
||||
|
@ -129,7 +127,7 @@ private:
|
|||
int timeForWay;
|
||||
};
|
||||
|
||||
/** Data structure for a scenegraph node in an IRR file
|
||||
/** Data structure for a scene-graph node in an IRR file
|
||||
*/
|
||||
struct Node
|
||||
{
|
||||
|
@ -227,8 +225,7 @@ private:
|
|||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Fill the scenegraph recursively
|
||||
*/
|
||||
/// Fill the scene-graph recursively
|
||||
void GenerateGraph(Node* root,aiNode* rootOut ,aiScene* scene,
|
||||
BatchLoader& batch,
|
||||
std::vector<aiMesh*>& meshes,
|
||||
|
@ -237,27 +234,22 @@ private:
|
|||
std::vector<aiMaterial*>& materials,
|
||||
unsigned int& defaultMatIdx);
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Generate a mesh that consists of just a single quad
|
||||
*/
|
||||
/// Generate a mesh that consists of just a single quad
|
||||
aiMesh* BuildSingleQuadMesh(const SkyboxVertex& v1,
|
||||
const SkyboxVertex& v2,
|
||||
const SkyboxVertex& v3,
|
||||
const SkyboxVertex& v4);
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Build a skybox
|
||||
*
|
||||
* @param meshes Receives 6 output meshes
|
||||
* @param materials The last 6 materials are assigned to the newly
|
||||
* created meshes. The names of the materials are adjusted.
|
||||
*/
|
||||
/// Build a sky-box
|
||||
///
|
||||
/// @param meshes Receives 6 output meshes
|
||||
/// @param materials The last 6 materials are assigned to the newly
|
||||
/// created meshes. The names of the materials are adjusted.
|
||||
void BuildSkybox(std::vector<aiMesh*>& meshes,
|
||||
std::vector<aiMaterial*> materials);
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Copy a material for a mesh to the output material list
|
||||
*
|
||||
|
@ -271,7 +263,6 @@ private:
|
|||
unsigned int& defMatIdx,
|
||||
aiMesh* mesh);
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Compute animations for a specific node
|
||||
*
|
||||
|
@ -281,13 +272,11 @@ private:
|
|||
void ComputeAnimations(Node* root, aiNode* real,
|
||||
std::vector<aiNodeAnim*>& anims);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
/** Configuration option: desired output FPS */
|
||||
/// Configuration option: desired output FPS
|
||||
double fps;
|
||||
|
||||
/** Configuration option: speed flag was set? */
|
||||
/// Configuration option: speed flag was set?
|
||||
bool configSpeedFlag;
|
||||
};
|
||||
|
||||
|
|
|
@ -14,23 +14,14 @@
|
|||
#include <assimp/Exporter.hpp>
|
||||
#include <assimp/IOSystem.hpp>
|
||||
|
||||
using namespace std;
|
||||
namespace Assimp {
|
||||
|
||||
namespace Assimp
|
||||
{
|
||||
|
||||
void ExportSceneX3D(const char* pFile, IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* pProperties)
|
||||
{
|
||||
void ExportSceneX3D(const char* pFile, IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* pProperties) {
|
||||
X3DExporter exporter(pFile, pIOSystem, pScene, pProperties);
|
||||
}
|
||||
|
||||
}// namespace Assimp
|
||||
|
||||
namespace Assimp
|
||||
{
|
||||
|
||||
void X3DExporter::IndentationStringSet(const size_t pNewLevel)
|
||||
{
|
||||
void X3DExporter::IndentationStringSet(const size_t pNewLevel) {
|
||||
if(pNewLevel > mIndentationString.size())
|
||||
{
|
||||
if(pNewLevel > mIndentationString.capacity()) mIndentationString.reserve(pNewLevel + 1);
|
||||
|
@ -43,31 +34,33 @@ void X3DExporter::IndentationStringSet(const size_t pNewLevel)
|
|||
}
|
||||
}
|
||||
|
||||
void X3DExporter::XML_Write(const string& pData)
|
||||
{
|
||||
if(pData.size() == 0) return;
|
||||
if(mOutFile->Write((void*)pData.data(), pData.length(), 1) != 1) throw DeadlyExportError("Failed to write scene data!");
|
||||
void X3DExporter::XML_Write(const std::string& pData) {
|
||||
if (pData.empty() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mOutFile->Write((void *)pData.data(), pData.length(), 1) != 1) {
|
||||
throw DeadlyExportError("Failed to write scene data!");
|
||||
}
|
||||
}
|
||||
|
||||
aiMatrix4x4 X3DExporter::Matrix_GlobalToCurrent(const aiNode& pNode) const
|
||||
{
|
||||
aiNode* cur_node;
|
||||
std::list<aiMatrix4x4> matr;
|
||||
aiMatrix4x4 out_matr;
|
||||
aiMatrix4x4 X3DExporter::Matrix_GlobalToCurrent(const aiNode& pNode) const {
|
||||
aiNode *cur_node;
|
||||
std::list<aiMatrix4x4> matr;
|
||||
aiMatrix4x4 out_matr;
|
||||
|
||||
// starting walk from current element to root
|
||||
matr.push_back(pNode.mTransformation);
|
||||
cur_node = pNode.mParent;
|
||||
if(cur_node != nullptr)
|
||||
{
|
||||
do
|
||||
{
|
||||
do {
|
||||
matr.push_back(cur_node->mTransformation);
|
||||
cur_node = cur_node->mParent;
|
||||
} while(cur_node != nullptr);
|
||||
}
|
||||
|
||||
// multiplicate all matrices in reverse order
|
||||
// Multiplication of all matrices in reverse order
|
||||
for(std::list<aiMatrix4x4>::reverse_iterator rit = matr.rbegin(); rit != matr.rend(); ++rit) out_matr = out_matr * (*rit);
|
||||
|
||||
return out_matr;
|
||||
|
@ -142,7 +135,7 @@ void X3DExporter::AttrHelper_Col3DArrToString(const aiColor3D* pArray, const siz
|
|||
|
||||
void X3DExporter::AttrHelper_Color3ToAttrList(std::list<SAttribute>& pList, const std::string& pName, const aiColor3D& pValue, const aiColor3D& pDefaultValue)
|
||||
{
|
||||
string tstr;
|
||||
string tstr;
|
||||
|
||||
if(pValue == pDefaultValue) return;
|
||||
|
||||
|
@ -152,7 +145,7 @@ string tstr;
|
|||
|
||||
void X3DExporter::AttrHelper_FloatToAttrList(std::list<SAttribute>& pList, const string& pName, const float pValue, const float pDefaultValue)
|
||||
{
|
||||
string tstr;
|
||||
string tstr;
|
||||
|
||||
if(pValue == pDefaultValue) return;
|
||||
|
||||
|
@ -183,7 +176,7 @@ void X3DExporter::NodeHelper_OpenNode(const string& pNodeName, const size_t pTab
|
|||
|
||||
void X3DExporter::NodeHelper_OpenNode(const string& pNodeName, const size_t pTabLevel, const bool pEmptyElement)
|
||||
{
|
||||
const list<SAttribute> attr_list;
|
||||
const list<SAttribute> attr_list;
|
||||
|
||||
NodeHelper_OpenNode(pNodeName, pTabLevel, pEmptyElement, attr_list);
|
||||
}
|
||||
|
@ -199,8 +192,8 @@ void X3DExporter::NodeHelper_CloseNode(const string& pNodeName, const size_t pTa
|
|||
|
||||
void X3DExporter::Export_Node(const aiNode *pNode, const size_t pTabLevel)
|
||||
{
|
||||
bool transform = false;
|
||||
list<SAttribute> attr_list;
|
||||
bool transform = false;
|
||||
list<SAttribute> attr_list;
|
||||
|
||||
// In Assimp lights is stored in next way: light source store in mScene->mLights and in node tree must present aiNode with name same as
|
||||
// light source has. Considering it we must compare every aiNode name with light sources names. Why not to look where ligths is present
|
||||
|
@ -303,11 +296,11 @@ list<SAttribute> attr_list;
|
|||
|
||||
void X3DExporter::Export_Mesh(const size_t pIdxMesh, const size_t pTabLevel)
|
||||
{
|
||||
const char* NodeName_IFS = "IndexedFaceSet";
|
||||
const char* NodeName_Shape = "Shape";
|
||||
const char* NodeName_IFS = "IndexedFaceSet";
|
||||
const char* NodeName_Shape = "Shape";
|
||||
|
||||
list<SAttribute> attr_list;
|
||||
aiMesh& mesh = *mScene->mMeshes[pIdxMesh];// create alias for conveniance.
|
||||
list<SAttribute> attr_list;
|
||||
aiMesh& mesh = *mScene->mMeshes[pIdxMesh];// create alias for conveniance.
|
||||
|
||||
// Check if mesh already defined early.
|
||||
if(mDEF_Map_Mesh.find(pIdxMesh) != mDEF_Map_Mesh.end())
|
||||
|
@ -407,10 +400,10 @@ aiMesh& mesh = *mScene->mMeshes[pIdxMesh];// create alias for conveniance.
|
|||
|
||||
void X3DExporter::Export_Material(const size_t pIdxMaterial, const size_t pTabLevel)
|
||||
{
|
||||
const char* NodeName_A = "Appearance";
|
||||
const char* NodeName_A = "Appearance";
|
||||
|
||||
list<SAttribute> attr_list;
|
||||
aiMaterial& material = *mScene->mMaterials[pIdxMaterial];// create alias for conveniance.
|
||||
list<SAttribute> attr_list;
|
||||
aiMaterial& material = *mScene->mMaterials[pIdxMaterial];// create alias for conveniance.
|
||||
|
||||
// Check if material already defined early.
|
||||
if(mDEF_Map_Material.find(pIdxMaterial) != mDEF_Map_Material.end())
|
||||
|
@ -564,7 +557,7 @@ aiMaterial& material = *mScene->mMaterials[pIdxMaterial];// create alias for con
|
|||
|
||||
void X3DExporter::Export_MetadataBoolean(const aiString& pKey, const bool pValue, const size_t pTabLevel)
|
||||
{
|
||||
list<SAttribute> attr_list;
|
||||
list<SAttribute> attr_list;
|
||||
|
||||
attr_list.push_back({"name", pKey.C_Str()});
|
||||
attr_list.push_back({"value", pValue ? "true" : "false"});
|
||||
|
@ -573,7 +566,7 @@ list<SAttribute> attr_list;
|
|||
|
||||
void X3DExporter::Export_MetadataDouble(const aiString& pKey, const double pValue, const size_t pTabLevel)
|
||||
{
|
||||
list<SAttribute> attr_list;
|
||||
list<SAttribute> attr_list;
|
||||
|
||||
attr_list.push_back({"name", pKey.C_Str()});
|
||||
attr_list.push_back({"value", to_string(pValue)});
|
||||
|
@ -582,7 +575,7 @@ list<SAttribute> attr_list;
|
|||
|
||||
void X3DExporter::Export_MetadataFloat(const aiString& pKey, const float pValue, const size_t pTabLevel)
|
||||
{
|
||||
list<SAttribute> attr_list;
|
||||
list<SAttribute> attr_list;
|
||||
|
||||
attr_list.push_back({"name", pKey.C_Str()});
|
||||
attr_list.push_back({"value", to_string(pValue)});
|
||||
|
@ -591,7 +584,7 @@ list<SAttribute> attr_list;
|
|||
|
||||
void X3DExporter::Export_MetadataInteger(const aiString& pKey, const int32_t pValue, const size_t pTabLevel)
|
||||
{
|
||||
list<SAttribute> attr_list;
|
||||
list<SAttribute> attr_list;
|
||||
|
||||
attr_list.push_back({"name", pKey.C_Str()});
|
||||
attr_list.push_back({"value", to_string(pValue)});
|
||||
|
@ -600,7 +593,7 @@ list<SAttribute> attr_list;
|
|||
|
||||
void X3DExporter::Export_MetadataString(const aiString& pKey, const aiString& pValue, const size_t pTabLevel)
|
||||
{
|
||||
list<SAttribute> attr_list;
|
||||
list<SAttribute> attr_list;
|
||||
|
||||
attr_list.push_back({"name", pKey.C_Str()});
|
||||
attr_list.push_back({"value", pValue.C_Str()});
|
||||
|
@ -609,7 +602,7 @@ list<SAttribute> attr_list;
|
|||
|
||||
bool X3DExporter::CheckAndExport_Light(const aiNode& pNode, const size_t pTabLevel)
|
||||
{
|
||||
list<SAttribute> attr_list;
|
||||
list<SAttribute> attr_list;
|
||||
|
||||
auto Vec3ToAttrList = [&](const string& pAttrName, const aiVector3D& pAttrValue, const aiVector3D& pAttrDefaultValue)
|
||||
{
|
||||
|
@ -622,8 +615,8 @@ auto Vec3ToAttrList = [&](const string& pAttrName, const aiVector3D& pAttrValue,
|
|||
}
|
||||
};
|
||||
|
||||
size_t idx_light;
|
||||
bool found = false;
|
||||
size_t idx_light;
|
||||
bool found = false;
|
||||
|
||||
// Name of the light source can not be empty.
|
||||
if(pNode.mName.length == 0) return false;
|
||||
|
@ -699,7 +692,7 @@ bool found = false;
|
|||
X3DExporter::X3DExporter(const char* pFileName, IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* /*pProperties*/)
|
||||
: mScene(pScene)
|
||||
{
|
||||
list<SAttribute> attr_list;
|
||||
list<SAttribute> attr_list;
|
||||
|
||||
mOutFile = pIOSystem->Open(pFileName, "wt");
|
||||
if(mOutFile == nullptr) throw DeadlyExportError("Could not open output .x3d file: " + string(pFileName));
|
||||
|
|
|
@ -47,6 +47,8 @@ namespace Assimp
|
|||
///
|
||||
class X3DExporter
|
||||
{
|
||||
using AttrubuteList = std::list<SAttribute>;
|
||||
|
||||
/***********************************************/
|
||||
/******************** Types ********************/
|
||||
/***********************************************/
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -53,6 +53,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <assimp/Importer.hpp>
|
||||
#include <assimp/mesh.h>
|
||||
#include <assimp/light.h>
|
||||
|
||||
#include <memory>
|
||||
#include <map>
|
||||
|
||||
|
@ -65,16 +66,11 @@ namespace Assimp {
|
|||
*
|
||||
* Spec: http://vizstream.aveva.com/release/vsplatform/XGLSpec.htm
|
||||
*/
|
||||
class XGLImporter : public BaseImporter, public LogFunctions<XGLImporter>
|
||||
{
|
||||
class XGLImporter : public BaseImporter, public LogFunctions<XGLImporter> {
|
||||
public:
|
||||
|
||||
XGLImporter();
|
||||
~XGLImporter();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Returns whether the class can handle the format of the given file.
|
||||
* See BaseImporter::CanRead() for details. */
|
||||
|
@ -95,8 +91,6 @@ protected:
|
|||
IOSystem* pIOHandler);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
struct TempScope
|
||||
{
|
||||
TempScope()
|
||||
|
@ -180,34 +174,30 @@ private:
|
|||
};
|
||||
|
||||
private:
|
||||
|
||||
void Cleanup();
|
||||
|
||||
std::string GetElementName();
|
||||
bool ReadElement();
|
||||
bool ReadElementUpToClosing(const char* closetag);
|
||||
bool SkipToText();
|
||||
unsigned int ReadIDAttr();
|
||||
unsigned int ReadIDAttr(XmlNode &node);
|
||||
|
||||
void ReadWorld(TempScope& scope);
|
||||
void ReadLighting(TempScope& scope);
|
||||
aiLight* ReadDirectionalLight();
|
||||
aiNode* ReadObject(TempScope& scope,bool skipFirst = false,const char* closetag = "object");
|
||||
bool ReadMesh(TempScope& scope);
|
||||
void ReadMaterial(TempScope& scope);
|
||||
aiVector2D ReadVec2();
|
||||
aiVector3D ReadVec3();
|
||||
aiColor3D ReadCol3();
|
||||
aiMatrix4x4 ReadTrafo();
|
||||
unsigned int ReadIndexFromText();
|
||||
float ReadFloat();
|
||||
void ReadLighting(XmlNode &node, TempScope &scope);
|
||||
aiLight *ReadDirectionalLight(XmlNode &node);
|
||||
aiNode *ReadObject(XmlNode &node, TempScope &scope, bool skipFirst = false, const char *closetag = "object");
|
||||
bool ReadMesh(XmlNode &node, TempScope &scope);
|
||||
void ReadMaterial(XmlNode &node, TempScope &scope);
|
||||
aiVector2D ReadVec2(XmlNode &node );
|
||||
aiVector3D ReadVec3(XmlNode &node );
|
||||
aiColor3D ReadCol3(XmlNode &node );
|
||||
aiMatrix4x4 ReadTrafo(XmlNode &node );
|
||||
unsigned int ReadIndexFromText(XmlNode &node);
|
||||
float ReadFloat(XmlNode &node );
|
||||
|
||||
aiMesh* ToOutputMesh(const TempMaterialMesh& m);
|
||||
void ReadFaceVertex(const TempMesh& t, TempFace& out);
|
||||
unsigned int ResolveMaterialRef(TempScope& scope);
|
||||
void ReadFaceVertex(XmlNode &node, const TempMesh &t, TempFace &out);
|
||||
unsigned int ResolveMaterialRef(XmlNode &node, TempScope &scope);
|
||||
|
||||
private:
|
||||
std::shared_ptr<irr::io::IrrXMLReader> m_reader;
|
||||
//std::shared_ptr<irr::io::IrrXMLReader> m_reader;
|
||||
XmlParser *m_xmlParser;
|
||||
aiScene* m_scene;
|
||||
};
|
||||
|
||||
|
|
|
@ -51,96 +51,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
namespace Assimp {
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
/** @brief Utility class to make IrrXML work together with our custom IO system
|
||||
* See the IrrXML docs for more details.
|
||||
*
|
||||
* Construct IrrXML-Reader in BaseImporter::InternReadFile():
|
||||
* @code
|
||||
* // open the file
|
||||
* std::unique_ptr<IOStream> file( pIOHandler->Open( pFile));
|
||||
* if( file.get() == NULL) {
|
||||
* throw DeadlyImportError( "Failed to open file " + pFile + ".");
|
||||
* }
|
||||
*
|
||||
* // generate a XML reader for it
|
||||
* std::unique_ptr<CIrrXML_IOStreamReader> mIOWrapper( new CIrrXML_IOStreamReader( file.get()));
|
||||
* mReader = irr::io::createIrrXMLReader( mIOWrapper.get());
|
||||
* if( !mReader) {
|
||||
* ThrowException( "xxxx: Unable to open file.");
|
||||
* }
|
||||
* @endcode
|
||||
**/
|
||||
/*class CIrrXML_IOStreamReader : public irr::io::IFileReadCallBack {
|
||||
public:
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
//! Construction from an existing IOStream
|
||||
explicit CIrrXML_IOStreamReader(IOStream* _stream)
|
||||
: stream (_stream)
|
||||
, t (0)
|
||||
{
|
||||
|
||||
// Map the buffer into memory and convert it to UTF8. IrrXML provides its
|
||||
// own conversion, which is merely a cast from uintNN_t to uint8_t. Thus,
|
||||
// it is not suitable for our purposes and we have to do it BEFORE IrrXML
|
||||
// gets the buffer. Sadly, this forces us to map the whole file into
|
||||
// memory.
|
||||
|
||||
data.resize(stream->FileSize());
|
||||
stream->Read(&data[0],data.size(),1);
|
||||
|
||||
// Remove null characters from the input sequence otherwise the parsing will utterly fail
|
||||
// std::find is usually much faster than manually iterating
|
||||
// It is very unlikely that there will be any null characters
|
||||
auto null_char_iter = std::find(data.begin(), data.end(), '\0');
|
||||
|
||||
while (null_char_iter != data.end())
|
||||
{
|
||||
null_char_iter = data.erase(null_char_iter);
|
||||
null_char_iter = std::find(null_char_iter, data.end(), '\0');
|
||||
}
|
||||
|
||||
BaseImporter::ConvertToUTF8(data);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
//! Virtual destructor
|
||||
virtual ~CIrrXML_IOStreamReader() {}*/
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
//! Reads an amount of bytes from the file.
|
||||
/** @param buffer: Pointer to output buffer.
|
||||
* @param sizeToRead: Amount of bytes to read
|
||||
* @return Returns how much bytes were read. */
|
||||
/*virtual int read(void* buffer, int sizeToRead) {
|
||||
if(sizeToRead<0) {
|
||||
return 0;
|
||||
}
|
||||
if(t+sizeToRead>data.size()) {
|
||||
sizeToRead = static_cast<int>(data.size()-t);
|
||||
}
|
||||
|
||||
memcpy(buffer,&data.front()+t,sizeToRead);
|
||||
|
||||
t += sizeToRead;
|
||||
return sizeToRead;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
//! Returns size of file in bytes
|
||||
virtual int getSize() {
|
||||
return (int)data.size();
|
||||
}
|
||||
|
||||
private:
|
||||
IOStream* stream;
|
||||
std::vector<char> data;
|
||||
size_t t;
|
||||
|
||||
}; // ! class CIrrXML_IOStreamReader
|
||||
*/
|
||||
|
||||
struct find_node_by_name_predicate {
|
||||
std::string mName;
|
||||
find_node_by_name_predicate(const std::string &name) :
|
||||
|
@ -153,6 +63,14 @@ struct find_node_by_name_predicate {
|
|||
}
|
||||
};
|
||||
|
||||
template<class TNodeType>
|
||||
struct NodeConverter {
|
||||
public:
|
||||
static int to_int(TNodeType &node, const char *attribName ) {
|
||||
ai_assert(nullptr != attribName);
|
||||
return node.attribute(attribName).to_int();
|
||||
}
|
||||
};
|
||||
|
||||
template<class TNodeType>
|
||||
class TXmlParser {
|
||||
|
@ -177,6 +95,7 @@ public:
|
|||
if (name.empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (nullptr == mDoc) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -187,6 +106,7 @@ public:
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
return &node;
|
||||
}
|
||||
|
||||
TNodeType *parse(IOStream *stream) {
|
||||
|
@ -220,6 +140,7 @@ private:
|
|||
};
|
||||
|
||||
using XmlParser = TXmlParser<pugi::xml_node>;
|
||||
using XmlNode = pugi::xml_node;
|
||||
|
||||
} // namespace Assimp
|
||||
|
||||
|
|
Loading…
Reference in New Issue