Fix xml-migration bild.
parent
6f77d2e06d
commit
582a8b1887
|
@ -121,6 +121,14 @@ ColladaParser::ColladaParser(IOSystem *pIOHandler, const std::string &pFile) :
|
|||
if (nullptr == root) {
|
||||
ThrowException("Unable to read file, malformed XML");
|
||||
}
|
||||
bool res = root->empty();
|
||||
if (!res) {
|
||||
for (XmlNode &n : root->children()) {
|
||||
const std::string nm = n.name();
|
||||
}
|
||||
XmlNode node = root->first_child();
|
||||
std::string name = node.name();
|
||||
}
|
||||
|
||||
// start reading
|
||||
ReadContents(*root);
|
||||
|
@ -2256,7 +2264,6 @@ void ColladaParser::ReadNodeGeometry(XmlNode &node, Node *pNode) {
|
|||
|
||||
s.mMatName = urlMat;
|
||||
|
||||
|
||||
// store the association
|
||||
instance.mMaterials[group] = s;
|
||||
}
|
||||
|
|
|
@ -75,7 +75,9 @@ using namespace std;
|
|||
// ------------------------------------------------------------------------------------------------
|
||||
// Default constructor
|
||||
ObjFileImporter::ObjFileImporter() :
|
||||
m_Buffer(), m_pRootObject(nullptr), m_strAbsPath(std::string(1, DefaultIOSystem().getOsSeparator())) {}
|
||||
m_Buffer(),
|
||||
m_pRootObject(nullptr),
|
||||
m_strAbsPath(std::string(1, DefaultIOSystem().getOsSeparator())) {}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Destructor.
|
||||
|
|
|
@ -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,
|
||||
|
@ -48,16 +47,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "OgreStructs.h"
|
||||
#include <assimp/StreamReader.h>
|
||||
|
||||
namespace Assimp
|
||||
{
|
||||
namespace Ogre
|
||||
{
|
||||
namespace Assimp {
|
||||
namespace Ogre {
|
||||
|
||||
typedef Assimp::StreamReaderLE MemoryStreamReader;
|
||||
typedef std::shared_ptr<MemoryStreamReader> MemoryStreamReaderPtr;
|
||||
|
||||
class OgreBinarySerializer
|
||||
{
|
||||
class OgreBinarySerializer {
|
||||
public:
|
||||
/// Imports mesh and returns the result.
|
||||
/** @note Fatal unrecoverable errors will throw a DeadlyImportError. */
|
||||
|
@ -71,8 +67,7 @@ public:
|
|||
static bool ImportSkeleton(Assimp::IOSystem *pIOHandler, MeshXml *mesh);
|
||||
|
||||
private:
|
||||
enum AssetMode
|
||||
{
|
||||
enum AssetMode {
|
||||
AM_Mesh,
|
||||
AM_Skeleton
|
||||
};
|
||||
|
@ -80,8 +75,7 @@ private:
|
|||
OgreBinarySerializer(MemoryStreamReader *reader, AssetMode mode) :
|
||||
m_currentLen(0),
|
||||
m_reader(reader),
|
||||
assetMode(mode)
|
||||
{
|
||||
assetMode(mode) {
|
||||
}
|
||||
|
||||
static MemoryStreamReaderPtr OpenReader(Assimp::IOSystem *pIOHandler, const std::string &filename);
|
||||
|
@ -158,8 +152,7 @@ private:
|
|||
AssetMode assetMode;
|
||||
};
|
||||
|
||||
enum MeshChunkId
|
||||
{
|
||||
enum MeshChunkId {
|
||||
M_HEADER = 0x1000,
|
||||
// char* version : Version number check
|
||||
M_MESH = 0x3000,
|
||||
|
@ -353,8 +346,7 @@ static std::string MeshHeaderToString(MeshChunkId id)
|
|||
}
|
||||
*/
|
||||
|
||||
enum SkeletonChunkId
|
||||
{
|
||||
enum SkeletonChunkId {
|
||||
SKELETON_HEADER = 0x1000,
|
||||
// char* version : Version number check
|
||||
SKELETON_BLENDMODE = 0x1010, // optional
|
||||
|
@ -416,8 +408,8 @@ static std::string SkeletonHeaderToString(SkeletonChunkId id)
|
|||
return "Unknown_SkeletonChunkId";
|
||||
}
|
||||
*/
|
||||
} // Ogre
|
||||
} // Assimp
|
||||
} // namespace Ogre
|
||||
} // namespace Assimp
|
||||
|
||||
#endif // ASSIMP_BUILD_NO_OGRE_IMPORTER
|
||||
#endif // AI_OGREBINARYSERIALIZER_H_INC
|
||||
|
|
|
@ -56,7 +56,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
namespace Assimp {
|
||||
namespace Ogre {
|
||||
|
||||
AI_WONT_RETURN void ThrowAttibuteError(const XmlParser *reader, const std::string &name, const std::string &error = "") AI_WONT_RETURN_SUFFIX;
|
||||
//AI_WONT_RETURN void ThrowAttibuteError(const XmlParser *reader, const std::string &name, const std::string &error = "") AI_WONT_RETURN_SUFFIX;
|
||||
|
||||
AI_WONT_RETURN void ThrowAttibuteError(const std::string &nodeName, const std::string &name, const std::string &error) {
|
||||
if (!error.empty()) {
|
||||
|
@ -69,7 +69,7 @@ AI_WONT_RETURN void ThrowAttibuteError(const std::string &nodeName, const std::s
|
|||
template <>
|
||||
int32_t OgreXmlSerializer::ReadAttribute<int32_t>(XmlNode &xmlNode, const char *name) const {
|
||||
if (!XmlParser::hasAttribute(xmlNode, name)) {
|
||||
ThrowAttibuteError(mParser, name);
|
||||
ThrowAttibuteError(xmlNode.name(), name, "Not found");
|
||||
}
|
||||
pugi::xml_attribute attr = xmlNode.attribute(name);
|
||||
return static_cast<int32_t>(attr.as_int());
|
||||
|
@ -78,14 +78,14 @@ int32_t OgreXmlSerializer::ReadAttribute<int32_t>(XmlNode &xmlNode, const char *
|
|||
template <>
|
||||
uint32_t OgreXmlSerializer::ReadAttribute<uint32_t>(XmlNode &xmlNode, const char *name) const {
|
||||
if (!XmlParser::hasAttribute(xmlNode, name)) {
|
||||
ThrowAttibuteError(mParser, name);
|
||||
ThrowAttibuteError(xmlNode.name(), name, "Not found");
|
||||
}
|
||||
|
||||
// @note This is hackish. But we are never expecting unsigned values that go outside the
|
||||
// int32_t range. Just monitor for negative numbers and kill the import.
|
||||
int32_t temp = ReadAttribute<int32_t>(xmlNode, name);
|
||||
if (temp < 0) {
|
||||
ThrowAttibuteError(mParser, name, "Found a negative number value where expecting a uint32_t value");
|
||||
ThrowAttibuteError(xmlNode.name(), name, "Found a negative number value where expecting a uint32_t value");
|
||||
}
|
||||
|
||||
return static_cast<uint32_t>(temp);
|
||||
|
@ -94,7 +94,7 @@ uint32_t OgreXmlSerializer::ReadAttribute<uint32_t>(XmlNode &xmlNode, const char
|
|||
template <>
|
||||
uint16_t OgreXmlSerializer::ReadAttribute<uint16_t>(XmlNode &xmlNode, const char *name) const {
|
||||
if (!XmlParser::hasAttribute(xmlNode, name)) {
|
||||
ThrowAttibuteError(mParser, name);
|
||||
ThrowAttibuteError(xmlNode.name(), name, "Not found");
|
||||
}
|
||||
|
||||
return static_cast<uint16_t>(xmlNode.attribute(name).as_int());
|
||||
|
@ -103,7 +103,7 @@ uint16_t OgreXmlSerializer::ReadAttribute<uint16_t>(XmlNode &xmlNode, const char
|
|||
template <>
|
||||
float OgreXmlSerializer::ReadAttribute<float>(XmlNode &xmlNode, const char *name) const {
|
||||
if (!XmlParser::hasAttribute(xmlNode, name)) {
|
||||
ThrowAttibuteError(mParser, name);
|
||||
ThrowAttibuteError(xmlNode.name(), name, "Not found");
|
||||
}
|
||||
|
||||
return xmlNode.attribute(name).as_float();
|
||||
|
@ -112,7 +112,7 @@ float OgreXmlSerializer::ReadAttribute<float>(XmlNode &xmlNode, const char *name
|
|||
template <>
|
||||
std::string OgreXmlSerializer::ReadAttribute<std::string>(XmlNode &xmlNode, const char *name) const {
|
||||
if (!XmlParser::hasAttribute(xmlNode, name)) {
|
||||
ThrowAttibuteError(mParser, name);
|
||||
ThrowAttibuteError(xmlNode.name(), name, "Not found");
|
||||
}
|
||||
|
||||
return xmlNode.attribute(name).as_string();
|
||||
|
@ -127,7 +127,7 @@ bool OgreXmlSerializer::ReadAttribute<bool>(XmlNode &xmlNode, const char *name)
|
|||
return false;
|
||||
}
|
||||
|
||||
ThrowAttibuteError(mParser, name, "Boolean value is expected to be 'true' or 'false', encountered '" + value + "'");
|
||||
ThrowAttibuteError(xmlNode.name(), name, "Boolean value is expected to be 'true' or 'false', encountered '" + value + "'");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -147,6 +147,16 @@ void X3DImporter::Clear() {
|
|||
}
|
||||
}
|
||||
|
||||
void X3DImporter::ParseFile(const std::string &file, IOSystem *pIOHandler) {
|
||||
ai_assert(nullptr != pIOHandler);
|
||||
|
||||
static const std::string mode = "rb";
|
||||
std::unique_ptr<IOStream> fileStream(pIOHandler->Open(file, mode));
|
||||
if (!fileStream.get()) {
|
||||
throw DeadlyImportError("Failed to open file " + file + ".");
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************************************************************************************/
|
||||
/************************************************************ Functions: find set ************************************************************/
|
||||
/*********************************************************************************************************************************************/
|
||||
|
@ -154,7 +164,9 @@ void X3DImporter::Clear() {
|
|||
bool X3DImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool pCheckSig) const {
|
||||
const std::string extension = GetExtension(pFile);
|
||||
|
||||
if ((extension == "x3d") || (extension == "x3db")) return true;
|
||||
if ((extension == "x3d") || (extension == "x3db")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!extension.length() || pCheckSig) {
|
||||
const char *tokens[] = { "DOCTYPE X3D PUBLIC", "http://www.web3d.org/specifications/x3d" };
|
||||
|
|
|
@ -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,
|
||||
|
@ -119,6 +118,7 @@ public:
|
|||
}
|
||||
|
||||
TNodeType *parse(IOStream *stream) {
|
||||
mRoot = nullptr;
|
||||
if (nullptr == stream) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -126,10 +126,9 @@ public:
|
|||
mData.resize(stream->FileSize());
|
||||
stream->Read(&mData[0], mData.size(), 1);
|
||||
mDoc = new pugi::xml_document();
|
||||
pugi::xml_parse_result result = mDoc->load_string(&mData[0]);
|
||||
pugi::xml_parse_result result = mDoc->load_string(&mData[0], pugi::parse_default | pugi::parse_declaration);
|
||||
if (result.status == pugi::status_ok) {
|
||||
pugi::xml_node root = *(mDoc->children().begin());
|
||||
|
||||
pugi::xml_node root = mDoc->document_element();
|
||||
mRoot = &root;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,8 +2,7 @@
|
|||
# ----------------------------------------------------------------------
|
||||
#
|
||||
# Copyright (c) 2006-2020, assimp team
|
||||
|
||||
|
||||
#
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use of this software in source and binary forms,
|
||||
|
@ -88,6 +87,7 @@ SET( COMMON
|
|||
unit/Common/utLineSplitter.cpp
|
||||
unit/Common/utSpatialSort.cpp
|
||||
unit/Common/utAssertHandler.cpp
|
||||
unit/Common/utXmlParser.cpp
|
||||
)
|
||||
|
||||
SET( IMPORTERS
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue