diff --git a/code/AssetLib/X3D/FIReader.cpp b/code/AssetLib/X3D/FIReader.cpp index d60e1b4d6..6361399ce 100644 --- a/code/AssetLib/X3D/FIReader.cpp +++ b/code/AssetLib/X3D/FIReader.cpp @@ -51,28 +51,28 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Workaround for issue #1361 // https://github.com/assimp/assimp/issues/1361 #ifdef __ANDROID__ -# define _GLIBCXX_USE_C99 1 +#define _GLIBCXX_USE_C99 1 #endif #include -#include -#include #include +#include +#include #ifdef ASSIMP_USE_HUNTER -# include +#include #else -# include "../contrib/utf8cpp/source/utf8.h" +#include "../contrib/utf8cpp/source/utf8.h" #endif #include -#include -#include -#include -#include #include +#include +#include +#include +#include namespace Assimp { -static const std::string parseErrorMessage = "Fast Infoset parse error"; +static const char *parseErrorMessage = "Fast Infoset parse error"; static const char *xmlDeclarations[] = { "", @@ -87,37 +87,41 @@ static const char *xmlDeclarations[] = { }; static size_t parseMagic(const uint8_t *data, const uint8_t *dataEnd) { + ai_assert(nullptr != data); + ai_assert(nullptr != dataEnd); + if (dataEnd - data < 4) { return 0; } + uint32_t magic = (data[0] << 24) | (data[1] << 16) | (data[2] << 8) | data[3]; switch (magic) { case 0xe0000001: return 4; case 0x3c3f786d: // "= xmlDeclarationLength) && (memcmp(xmlDeclaration, data, xmlDeclarationLength) == 0)) { - data += xmlDeclarationLength; - if (dataEnd - data < 4) { - return 0; - } - magic = (data[0] << 24) | (data[1] << 16) | (data[2] << 8) | data[3]; - return magic == 0xe0000001 ? xmlDeclarationLength + 4 : 0; + { + size_t xmlDeclarationsLength = sizeof(xmlDeclarations) / sizeof(xmlDeclarations[0]); + for (size_t i = 0; i < xmlDeclarationsLength; ++i) { + auto xmlDeclaration = xmlDeclarations[i]; + ptrdiff_t xmlDeclarationLength = strlen(xmlDeclaration); + if ((dataEnd - data >= xmlDeclarationLength) && (memcmp(xmlDeclaration, data, xmlDeclarationLength) == 0)) { + data += xmlDeclarationLength; + if (dataEnd - data < 4) { + return 0; } + magic = (data[0] << 24) | (data[1] << 16) | (data[2] << 8) | data[3]; + return magic == 0xe0000001 ? xmlDeclarationLength + 4 : 0; } - return 0; } + return 0; + } default: return 0; } } static std::string parseUTF8String(const uint8_t *data, size_t len) { - return std::string((char*)data, len); + return std::string((char *)data, len); } static std::string parseUTF16String(const uint8_t *data, size_t len) { @@ -137,7 +141,7 @@ static std::string parseUTF16String(const uint8_t *data, size_t len) { return result; } -struct FIStringValueImpl: public FIStringValue { +struct FIStringValueImpl : public FIStringValue { FIStringValueImpl(std::string &&value_) { value = std::move(value_); } @@ -151,12 +155,12 @@ std::shared_ptr FIStringValue::create(std::string &&value) { return std::make_shared(std::move(value)); } -struct FIHexValueImpl: public FIHexValue { +struct FIHexValueImpl : public FIHexValue { mutable std::string strValue; mutable bool strValueValid; - FIHexValueImpl(std::vector &&value_) - : strValueValid( false ) { + FIHexValueImpl(std::vector &&value_) : + strValueValid(false) { value = std::move(value_); } @@ -177,12 +181,12 @@ std::shared_ptr FIHexValue::create(std::vector &&value) { return std::make_shared(std::move(value)); } -struct FIBase64ValueImpl: public FIBase64Value { +struct FIBase64ValueImpl : public FIBase64Value { mutable std::string strValue; mutable bool strValueValid; - FIBase64ValueImpl(std::vector &&value_) - : strValueValid(false) { + FIBase64ValueImpl(std::vector &&value_) : + strValueValid(false) { value = std::move(value_); } @@ -196,28 +200,28 @@ struct FIBase64ValueImpl: public FIBase64Value { for (std::vector::size_type i = 0; i < valueSize; ++i) { c2 = value[i]; switch (imod3) { - case 0: - os << basis_64[c2 >> 2]; - imod3 = 1; - break; - case 1: - os << basis_64[((c1 & 0x03) << 4) | ((c2 & 0xf0) >> 4)]; - imod3 = 2; - break; - case 2: - os << basis_64[((c1 & 0x0f) << 2) | ((c2 & 0xc0) >> 6)] << basis_64[c2 & 0x3f]; - imod3 = 0; - break; - } - c1 = c2; - } - switch (imod3) { + case 0: + os << basis_64[c2 >> 2]; + imod3 = 1; + break; case 1: - os << basis_64[(c1 & 0x03) << 4] << "=="; + os << basis_64[((c1 & 0x03) << 4) | ((c2 & 0xf0) >> 4)]; + imod3 = 2; break; case 2: - os << basis_64[(c1 & 0x0f) << 2] << '='; + os << basis_64[((c1 & 0x0f) << 2) | ((c2 & 0xc0) >> 6)] << basis_64[c2 & 0x3f]; + imod3 = 0; break; + } + c1 = c2; + } + switch (imod3) { + case 1: + os << basis_64[(c1 & 0x03) << 4] << "=="; + break; + case 2: + os << basis_64[(c1 & 0x0f) << 2] << '='; + break; } strValue = os.str(); } @@ -234,12 +238,12 @@ std::shared_ptr FIBase64Value::create(std::vector &&valu return std::make_shared(std::move(value)); } -struct FIShortValueImpl: public FIShortValue { +struct FIShortValueImpl : public FIShortValue { mutable std::string strValue; mutable bool strValueValid; - FIShortValueImpl(std::vector &&value_) - : strValueValid(false) { + FIShortValueImpl(std::vector &&value_) : + strValueValid(false) { value = std::move(value_); } @@ -260,12 +264,12 @@ std::shared_ptr FIShortValue::create(std::vector &&value) return std::make_shared(std::move(value)); } -struct FIIntValueImpl: public FIIntValue { +struct FIIntValueImpl : public FIIntValue { mutable std::string strValue; mutable bool strValueValid; - FIIntValueImpl(std::vector &&value_) - : strValueValid(false) { + FIIntValueImpl(std::vector &&value_) : + strValueValid(false) { value = std::move(value_); } @@ -286,12 +290,12 @@ std::shared_ptr FIIntValue::create(std::vector &&value) { return std::make_shared(std::move(value)); } -struct FILongValueImpl: public FILongValue { +struct FILongValueImpl : public FILongValue { mutable std::string strValue; mutable bool strValueValid; - FILongValueImpl(std::vector &&value_) - : strValueValid(false) { + FILongValueImpl(std::vector &&value_) : + strValueValid(false) { value = std::move(value_); } @@ -312,12 +316,12 @@ std::shared_ptr FILongValue::create(std::vector &&value) { return std::make_shared(std::move(value)); } -struct FIBoolValueImpl: public FIBoolValue { +struct FIBoolValueImpl : public FIBoolValue { mutable std::string strValue; mutable bool strValueValid; - FIBoolValueImpl(std::vector &&value_) - : strValueValid(false) { + FIBoolValueImpl(std::vector &&value_) : + strValueValid(false) { value = std::move(value_); } @@ -328,7 +332,8 @@ struct FIBoolValueImpl: public FIBoolValue { os << std::boolalpha; int n = 0; std::for_each(value.begin(), value.end(), [&](bool b) { - if (++n > 1) os << ' '; os << b; + if (++n > 1) os << ' '; + os << b; }); strValue = os.str(); } @@ -341,12 +346,12 @@ std::shared_ptr FIBoolValue::create(std::vector &&value) { return std::make_shared(std::move(value)); } -struct FIFloatValueImpl: public FIFloatValue { +struct FIFloatValueImpl : public FIFloatValue { mutable std::string strValue; mutable bool strValueValid; - FIFloatValueImpl(std::vector &&value_) - : strValueValid(false) { + FIFloatValueImpl(std::vector &&value_) : + strValueValid(false) { value = std::move(value_); } @@ -367,12 +372,12 @@ std::shared_ptr FIFloatValue::create(std::vector &&value) { return std::make_shared(std::move(value)); } -struct FIDoubleValueImpl: public FIDoubleValue { +struct FIDoubleValueImpl : public FIDoubleValue { mutable std::string strValue; mutable bool strValueValid; - FIDoubleValueImpl(std::vector &&value_) - : strValueValid(false) { + FIDoubleValueImpl(std::vector &&value_) : + strValueValid(false) { value = std::move(value_); } @@ -392,12 +397,12 @@ std::shared_ptr FIDoubleValue::create(std::vector &&value return std::make_shared(std::move(value)); } -struct FIUUIDValueImpl: public FIUUIDValue { +struct FIUUIDValueImpl : public FIUUIDValue { mutable std::string strValue; mutable bool strValueValid; - FIUUIDValueImpl(std::vector &&value_) - : strValueValid(false) { + FIUUIDValueImpl(std::vector &&value_) : + strValueValid(false) { value = std::move(value_); } @@ -446,8 +451,8 @@ std::shared_ptr FIUUIDValue::create(std::vector &&value) { return std::make_shared(std::move(value)); } -struct FICDATAValueImpl: public FICDATAValue { - FICDATAValueImpl(std::string &&value_){ +struct FICDATAValueImpl : public FICDATAValue { + FICDATAValueImpl(std::string &&value_) { value = std::move(value_); } @@ -460,19 +465,19 @@ std::shared_ptr FICDATAValue::create(std::string &&value) { return std::make_shared(std::move(value)); } -struct FIHexDecoder: public FIDecoder { +struct FIHexDecoder : public FIDecoder { std::shared_ptr decode(const uint8_t *data, size_t len) override { return FIHexValue::create(std::vector(data, data + len)); } }; -struct FIBase64Decoder: public FIDecoder { +struct FIBase64Decoder : public FIDecoder { std::shared_ptr decode(const uint8_t *data, size_t len) override { return FIBase64Value::create(std::vector(data, data + len)); } }; -struct FIShortDecoder: public FIDecoder { +struct FIShortDecoder : public FIDecoder { std::shared_ptr decode(const uint8_t *data, size_t len) override { if (len & 1) { throw DeadlyImportError(parseErrorMessage); @@ -489,7 +494,7 @@ struct FIShortDecoder: public FIDecoder { } }; -struct FIIntDecoder: public FIDecoder { +struct FIIntDecoder : public FIDecoder { std::shared_ptr decode(const uint8_t *data, size_t len) override { if (len & 3) { throw DeadlyImportError(parseErrorMessage); @@ -506,7 +511,7 @@ struct FIIntDecoder: public FIDecoder { } }; -struct FILongDecoder: public FIDecoder { +struct FILongDecoder : public FIDecoder { std::shared_ptr decode(const uint8_t *data, size_t len) override { if (len & 7) { throw DeadlyImportError(parseErrorMessage); @@ -524,7 +529,7 @@ struct FILongDecoder: public FIDecoder { } }; -struct FIBoolDecoder: public FIDecoder { +struct FIBoolDecoder : public FIDecoder { virtual std::shared_ptr decode(const uint8_t *data, size_t len) /*override*/ { if (len < 1) { throw DeadlyImportError(parseErrorMessage); @@ -546,7 +551,7 @@ struct FIBoolDecoder: public FIDecoder { } }; -struct FIFloatDecoder: public FIDecoder { +struct FIFloatDecoder : public FIDecoder { virtual std::shared_ptr decode(const uint8_t *data, size_t len) /*override*/ { if (len & 3) { throw DeadlyImportError(parseErrorMessage); @@ -565,7 +570,7 @@ struct FIFloatDecoder: public FIDecoder { } }; -struct FIDoubleDecoder: public FIDecoder { +struct FIDoubleDecoder : public FIDecoder { virtual std::shared_ptr decode(const uint8_t *data, size_t len) /*override*/ { if (len & 7) { throw DeadlyImportError(parseErrorMessage); @@ -585,7 +590,7 @@ struct FIDoubleDecoder: public FIDecoder { } }; -struct FIUUIDDecoder: public FIDecoder { +struct FIUUIDDecoder : public FIDecoder { virtual std::shared_ptr decode(const uint8_t *data, size_t len) /*override*/ { if (len & 15) { throw DeadlyImportError(parseErrorMessage); @@ -594,23 +599,30 @@ struct FIUUIDDecoder: public FIDecoder { } }; -struct FICDATADecoder: public FIDecoder { +struct FICDATADecoder : public FIDecoder { virtual std::shared_ptr decode(const uint8_t *data, size_t len) /*override*/ { return FICDATAValue::create(parseUTF8String(data, len)); } }; -class CFIReaderImpl: public FIReader { +class CFIReaderImpl : public FIReader { public: + CFIReaderImpl(std::unique_ptr data_, size_t size) : + data(std::move(data_)), + dataP(data.get()), + dataEnd(data.get() + size), + currentNodeType(irr::io::EXN_NONE), + emptyElement(false), + headerPending(true), + terminatorPending(false) { + // empty + } - CFIReaderImpl(std::unique_ptr data_, size_t size): - data(std::move(data_)), dataP(data.get()), dataEnd(data.get() + size), currentNodeType(irr::io::EXN_NONE), - emptyElement(false), headerPending(true), terminatorPending(false) - {} + ~CFIReaderImpl() override { + // override + } - virtual ~CFIReaderImpl() {} - - virtual bool read() /*override*/ { + virtual bool read() { if (headerPending) { headerPending = false; parseHeader(); @@ -620,13 +632,12 @@ public: if (elementStack.empty()) { return false; } - else { - nodeName = elementStack.top(); - elementStack.pop(); - currentNodeType = nodeName.empty() ? irr::io::EXN_UNKNOWN : irr::io::EXN_ELEMENT_END; - return true; - } + nodeName = elementStack.top(); + elementStack.pop(); + currentNodeType = nodeName.empty() ? irr::io::EXN_UNKNOWN : irr::io::EXN_ELEMENT_END; + return true; } + if (dataP >= dataEnd) { return false; } @@ -635,55 +646,50 @@ public: // C.3 parseElement(); return true; - } - else if (b < 0xc0) { // Characters (C.3.7.5) + } else if (b < 0xc0) { // Characters (C.3.7.5) // C.7 auto chars = parseNonIdentifyingStringOrIndex3(vocabulary.charactersTable); nodeName = chars->toString(); currentNodeType = irr::io::EXN_TEXT; return true; - } - else if (b < 0xe0) { + } else if (b < 0xe0) { if ((b & 0xfc) == 0xc4) { // DTD (C.2.11.5) // C.9 ++dataP; if (b & 0x02) { - /*const std::string &systemID =*/ parseIdentifyingStringOrIndex(vocabulary.otherURITable); + /*const std::string &systemID =*/parseIdentifyingStringOrIndex(vocabulary.otherURITable); } if (b & 0x01) { - /*const std::string &publicID =*/ parseIdentifyingStringOrIndex(vocabulary.otherURITable); + /*const std::string &publicID =*/parseIdentifyingStringOrIndex(vocabulary.otherURITable); } elementStack.push(EmptyString); currentNodeType = irr::io::EXN_UNKNOWN; return true; - } - else if ((b & 0xfc) == 0xc8) { // Unexpanded entity reference (C.3.7.4) + } else if ((b & 0xfc) == 0xc8) { // Unexpanded entity reference (C.3.7.4) // C.6 ++dataP; - /*const std::string &name =*/ parseIdentifyingStringOrIndex(vocabulary.otherNCNameTable); + /*const std::string &name =*/parseIdentifyingStringOrIndex(vocabulary.otherNCNameTable); if (b & 0x02) { - /*const std::string &systemID =*/ parseIdentifyingStringOrIndex(vocabulary.otherURITable); + /*const std::string &systemID =*/parseIdentifyingStringOrIndex(vocabulary.otherURITable); } if (b & 0x01) { - /*const std::string &publicID =*/ parseIdentifyingStringOrIndex(vocabulary.otherURITable); + /*const std::string &publicID =*/parseIdentifyingStringOrIndex(vocabulary.otherURITable); } currentNodeType = irr::io::EXN_UNKNOWN; return true; } - } - else if (b < 0xf0) { + } else if (b < 0xf0) { if (b == 0xe1) { // Processing instruction (C.2.11.3, C.3.7.3) // C.5 ++dataP; - /*const std::string &target =*/ parseIdentifyingStringOrIndex(vocabulary.otherNCNameTable); + /*const std::string &target =*/parseIdentifyingStringOrIndex(vocabulary.otherNCNameTable); if (dataEnd - dataP < 1) { throw DeadlyImportError(parseErrorMessage); } - /*std::shared_ptr data =*/ parseNonIdentifyingStringOrIndex1(vocabulary.otherStringTable); + /*std::shared_ptr data =*/parseNonIdentifyingStringOrIndex1(vocabulary.otherStringTable); currentNodeType = irr::io::EXN_UNKNOWN; return true; - } - else if (b == 0xe2) { // Comment (C.2.11.4, C.3.7.6) + } else if (b == 0xe2) { // Comment (C.2.11.4, C.3.7.6) // C.8 ++dataP; if (dataEnd - dataP < 1) { @@ -694,16 +700,14 @@ public: currentNodeType = irr::io::EXN_COMMENT; return true; } - } - else { // Terminator (C.2.12, C.3.8) + } else { // Terminator (C.2.12, C.3.8) ++dataP; if (b == 0xff) { terminatorPending = true; } if (elementStack.empty()) { return false; - } - else { + } else { nodeName = elementStack.top(); elementStack.pop(); currentNodeType = nodeName.empty() ? irr::io::EXN_UNKNOWN : irr::io::EXN_ELEMENT_END; @@ -721,38 +725,38 @@ public: return static_cast(attributes.size()); } - virtual const char* getAttributeName(int idx) const /*override*/ { + virtual const char *getAttributeName(int idx) const /*override*/ { if (idx < 0 || idx >= (int)attributes.size()) { return nullptr; } return attributes[idx].name.c_str(); } - virtual const char* getAttributeValue(int idx) const /*override*/ { + virtual const char *getAttributeValue(int idx) const /*override*/ { if (idx < 0 || idx >= (int)attributes.size()) { return nullptr; } return attributes[idx].value->toString().c_str(); } - virtual const char* getAttributeValue(const char* name) const /*override*/ { - const Attribute* attr = getAttributeByName(name); + virtual const char *getAttributeValue(const char *name) const /*override*/ { + const Attribute *attr = getAttributeByName(name); if (!attr) { return nullptr; } return attr->value->toString().c_str(); } - virtual const char* getAttributeValueSafe(const char* name) const /*override*/ { - const Attribute* attr = getAttributeByName(name); + virtual const char *getAttributeValueSafe(const char *name) const /*override*/ { + const Attribute *attr = getAttributeByName(name); if (!attr) { return EmptyString.c_str(); } return attr->value->toString().c_str(); } - virtual int getAttributeValueAsInt(const char* name) const /*override*/ { - const Attribute* attr = getAttributeByName(name); + virtual int getAttributeValueAsInt(const char *name) const /*override*/ { + const Attribute *attr = getAttributeByName(name); if (!attr) { return 0; } @@ -774,8 +778,8 @@ public: return atoi(attributes[idx].value->toString().c_str()); } - virtual float getAttributeValueAsFloat(const char* name) const /*override*/ { - const Attribute* attr = getAttributeByName(name); + virtual float getAttributeValueAsFloat(const char *name) const /*override*/ { + const Attribute *attr = getAttributeByName(name); if (!attr) { return 0; } @@ -798,11 +802,11 @@ public: return fast_atof(attributes[idx].value->toString().c_str()); } - virtual const char* getNodeName() const /*override*/ { + virtual const char *getNodeName() const /*override*/ { return nodeName.c_str(); } - virtual const char* getNodeData() const /*override*/ { + virtual const char *getNodeData() const /*override*/ { return nodeName.c_str(); } @@ -825,8 +829,8 @@ public: return attributes[idx].value; } - virtual std::shared_ptr getAttributeEncodedValue(const char* name) const /*override*/ { - const Attribute* attr = getAttributeByName(name); + virtual std::shared_ptr getAttributeEncodedValue(const char *name) const /*override*/ { + const Attribute *attr = getAttributeByName(name); if (!attr) { return nullptr; } @@ -842,13 +846,13 @@ public: } private: - struct QName { std::string prefix; std::string uri; std::string name; inline QName() {} - inline QName(const FIQName &qname): prefix(qname.prefix ? qname.prefix : ""), uri(qname.uri ? qname.uri : ""), name(qname.name) {} + inline QName(const FIQName &qname) : + prefix(qname.prefix ? qname.prefix : ""), uri(qname.uri ? qname.uri : ""), name(qname.name) {} }; struct Attribute { @@ -876,12 +880,12 @@ private: } }; - const Attribute* getAttributeByName(const char* name) const { + const Attribute *getAttributeByName(const char *name) const { if (!name) { return 0; } std::string n = name; - for (int i=0; i<(int)attributes.size(); ++i) { + for (int i = 0; i < (int)attributes.size(); ++i) { if (attributes[i].name == n) { return &attributes[i]; } @@ -893,13 +897,11 @@ private: uint8_t b = *dataP++; if (!(b & 0x40)) { // x0...... (C.25.2) return b & 0x3f; - } - else if ((b & 0x60) == 0x40) { // x10..... ........ (C.25.3) + } else if ((b & 0x60) == 0x40) { // x10..... ........ (C.25.3) if (dataEnd - dataP > 0) { return (((b & 0x1f) << 8) | *dataP++) + 0x40; } - } - else if ((b & 0x70) == 0x60) { // x110.... ........ ........ (C.25.4) + } else if ((b & 0x70) == 0x60) { // x110.... ........ ........ (C.25.4) if (dataEnd - dataP > 1) { size_t result = (((b & 0x0f) << 16) | (dataP[0] << 8) | dataP[1]) + 0x2040; dataP += 2; @@ -913,20 +915,17 @@ private: uint8_t b = *dataP++; if (!(b & 0x20)) { // xx0..... (C.27.2) return b & 0x1f; - } - else if ((b & 0x38) == 0x20) { // xx100... ........ (C.27.3) + } else if ((b & 0x38) == 0x20) { // xx100... ........ (C.27.3) if (dataEnd - dataP > 0) { return (((b & 0x07) << 8) | *dataP++) + 0x20; } - } - else if ((b & 0x38) == 0x28) { // xx101... ........ ........ (C.27.4) + } else if ((b & 0x38) == 0x28) { // xx101... ........ ........ (C.27.4) if (dataEnd - dataP > 1) { size_t result = (((b & 0x07) << 16) | (dataP[0] << 8) | dataP[1]) + 0x820; dataP += 2; return result; } - } - else if ((b & 0x3f) == 0x30) { // xx110000 0000.... ........ ........ (C.27.5) + } else if ((b & 0x3f) == 0x30) { // xx110000 0000.... ........ ........ (C.27.5) if ((dataEnd - dataP > 2) && !(dataP[0] & 0xf0)) { size_t result = (((dataP[0] & 0x0f) << 16) | (dataP[1] << 8) | dataP[2]) + 0x80820; dataP += 3; @@ -940,20 +939,17 @@ private: uint8_t b = *dataP++; if (!(b & 0x10)) { // xxx0.... (C.28.2) return b & 0x0f; - } - else if ((b & 0x1c) == 0x10) { // xxx100.. ........ (C.28.3) + } else if ((b & 0x1c) == 0x10) { // xxx100.. ........ (C.28.3) if (dataEnd - dataP > 0) { return (((b & 0x03) << 8) | *dataP++) + 0x10; } - } - else if ((b & 0x1c) == 0x14) { // xxx101.. ........ ........ (C.28.4) + } else if ((b & 0x1c) == 0x14) { // xxx101.. ........ ........ (C.28.4) if (dataEnd - dataP > 1) { size_t result = (((b & 0x03) << 16) | (dataP[0] << 8) | dataP[1]) + 0x410; dataP += 2; return result; } - } - else if ((b & 0x1f) == 0x18) { // xxx11000 0000.... ........ ........ (C.28.5) + } else if ((b & 0x1f) == 0x18) { // xxx11000 0000.... ........ ........ (C.28.5) if ((dataEnd - dataP > 2) && !(dataP[0] & 0xf0)) { size_t result = (((dataP[0] & 0x0f) << 16) | (dataP[1] << 8) | dataP[2]) + 0x40410; dataP += 3; @@ -968,8 +964,7 @@ private: uint8_t b = *dataP++; if (b < 0x80) { // 0....... (C.21.2) return b; - } - else if ((b & 0xf0) == 0x80) { // 1000.... ........ ........ (C.21.3) + } else if ((b & 0xf0) == 0x80) { // 1000.... ........ ........ (C.21.3) if (dataEnd - dataP > 1) { size_t result = (((b & 0x0f) << 16) | (dataP[0] << 8) | dataP[1]) + 0x80; dataP += 2; @@ -986,21 +981,18 @@ private: size_t len; if (!(b & 0x40)) { // x0...... (C.22.3.1) len = b + 1; - } - else if (b == 0x40) { // x1000000 ........ (C.22.3.2) + } else if (b == 0x40) { // x1000000 ........ (C.22.3.2) if (dataEnd - dataP < 1) { throw DeadlyImportError(parseErrorMessage); } len = *dataP++ + 0x41; - } - else if (b == 0x60) { // x1100000 ........ ........ ........ ........ (C.22.3.3) + } else if (b == 0x60) { // x1100000 ........ ........ ........ ........ (C.22.3.3) if (dataEnd - dataP < 4) { throw DeadlyImportError(parseErrorMessage); } len = ((dataP[0] << 24) | (dataP[1] << 16) | (dataP[2] << 8) | dataP[3]) + 0x141; dataP += 4; - } - else { + } else { throw DeadlyImportError(parseErrorMessage); } @@ -1019,13 +1011,11 @@ private: size_t b = *dataP++ & 0x0f; if (!(b & 0x08)) { // xxxx0... (C.23.3.1) return b + 1; - } - else if (b == 0x08) { // xxxx1000 ........ (C.23.3.2) + } else if (b == 0x08) { // xxxx1000 ........ (C.23.3.2) if (dataEnd - dataP > 0) { return *dataP++ + 0x09; } - } - else if (b == 0x0c) { // xxxx1100 ........ ........ ........ ........ (C.23.3.3) + } else if (b == 0x0c) { // xxxx1100 ........ ........ ........ ........ (C.23.3.3) if (dataEnd - dataP > 3) { size_t result = ((dataP[0] << 24) | (dataP[1] << 16) | (dataP[2] << 8) | dataP[3]) + 0x109; dataP += 4; @@ -1040,13 +1030,11 @@ private: size_t b = *dataP++ & 0x03; if (!(b & 0x02)) { // xxxxxx0. (C.24.3.1) return b + 1; - } - else if (b == 0x02) { // xxxxxx10 ........ (C.24.3.2) + } else if (b == 0x02) { // xxxxxx10 ........ (C.24.3.2) if (dataEnd - dataP > 0) { return *dataP++ + 0x3; } - } - else if (b == 0x03) { // xxxxxx11 ........ ........ ........ ........ (C.24.3.3) + } else if (b == 0x03) { // xxxxxx11 ........ ........ ........ ........ (C.24.3.3) if (dataEnd - dataP > 3) { size_t result = ((dataP[0] << 24) | (dataP[1] << 16) | (dataP[2] << 8) | dataP[3]) + 0x103; dataP += 4; @@ -1063,8 +1051,7 @@ private: throw DeadlyImportError("Invalid encoding algorithm index " + to_string(index)); } return decoder->decode(dataP, len); - } - else { + } else { if (index - 32 >= vocabulary.encodingAlgorithmTable.size()) { throw DeadlyImportError("Invalid encoding algorithm index " + to_string(index)); } @@ -1072,8 +1059,7 @@ private: auto it = decoderMap.find(uri); if (it == decoderMap.end()) { throw DeadlyImportError("Unsupported encoding algorithm " + uri); - } - else { + } else { return it->second->decode(dataP, len); } } @@ -1092,8 +1078,7 @@ private: default: throw DeadlyImportError("Invalid restricted alphabet index " + to_string(index)); } - } - else { + } else { if (index - 16 >= vocabulary.restrictedAlphabetTable.size()) { throw DeadlyImportError("Invalid restricted alphabet index " + to_string(index)); } @@ -1120,7 +1105,7 @@ private: bitsAvail -= bitsPerCharacter; const size_t charIndex = (bits >> bitsAvail) & mask; if (charIndex < alphabetLength) { - s += (char) alphabetUTF32[charIndex]; + s += (char)alphabetUTF32[charIndex]; } else if (charIndex != mask) { throw DeadlyImportError(parseErrorMessage); } @@ -1146,13 +1131,11 @@ private: if (b & 0x10) { // encoding algorithm (C.19.3.4) result = parseEncodedData(index, len); - } - else { + } else { // Restricted alphabet (C.19.3.3) result = parseRestrictedAlphabet(index, len); } - } - else { + } else { len = parseNonEmptyOctetString5Length(); if (dataEnd - dataP < static_cast(len)) { throw DeadlyImportError(parseErrorMessage); @@ -1163,8 +1146,7 @@ private: throw DeadlyImportError(parseErrorMessage); } result = FIStringValue::create(parseUTF16String(dataP, len)); - } - else { + } else { // UTF-8 (C.19.3.1) result = FIStringValue::create(parseUTF8String(dataP, len)); } @@ -1190,13 +1172,11 @@ private: if (b & 0x04) { // encoding algorithm (C.20.3.4) result = parseEncodedData(index, len); - } - else { + } else { // Restricted alphabet (C.20.3.3) result = parseRestrictedAlphabet(index, len); } - } - else { + } else { len = parseNonEmptyOctetString7Length(); if (dataEnd - dataP < static_cast(len)) { throw DeadlyImportError(parseErrorMessage); @@ -1207,8 +1187,7 @@ private: throw DeadlyImportError(parseErrorMessage); } result = FIStringValue::create(parseUTF16String(dataP, len)); - } - else { + } else { // UTF-8 (C.20.3.1) result = FIStringValue::create(parseUTF8String(dataP, len)); } @@ -1229,8 +1208,7 @@ private: throw DeadlyImportError(parseErrorMessage); } return stringTable[index]; - } - else { + } else { // We have a string (C.13.3) stringTable.push_back(parseNonEmptyOctetString2()); return stringTable.back(); @@ -1293,8 +1271,7 @@ private: result.name = parseIdentifyingStringOrIndex(vocabulary.localNameTable); qNameTable.push_back(result); return qNameTable.back(); - } - else { + } else { // We have an index (C.17.4) size_t index = parseInt2(); if (index >= qNameTable.size()) { @@ -1318,8 +1295,7 @@ private: result.name = parseIdentifyingStringOrIndex(vocabulary.localNameTable); qNameTable.push_back(result); return qNameTable.back(); - } - else { + } else { // We have an index (C.18.4) size_t index = parseInt3(); if (index >= qNameTable.size()) { @@ -1335,16 +1311,14 @@ private: // empty string ++dataP; return EmptyFIString; - } - else if (b & 0x80) { // C.14.4 + } else if (b & 0x80) { // C.14.4 // We have an index size_t index = parseInt2(); if (index >= valueTable.size()) { throw DeadlyImportError(parseErrorMessage); } return valueTable[index]; - } - else { // C.14.3 + } else { // C.14.3 // We have a literal std::shared_ptr result = parseEncodedCharacterString3(); if (b & 0x40) { // C.14.3.1 @@ -1363,8 +1337,7 @@ private: throw DeadlyImportError(parseErrorMessage); } return valueTable[index]; - } - else { // C.15.3 + } else { // C.15.3 // We have a literal std::shared_ptr result = parseEncodedCharacterString5(); if (b & 0x10) { // C.15.3.1 @@ -1429,8 +1402,7 @@ private: } attr.value = parseNonIdentifyingStringOrIndex1(vocabulary.attributeValueTable); attributes.push_back(attr); - } - else { + } else { if ((b & 0xf0) != 0xf0) { // C.3.6.2 throw DeadlyImportError(parseErrorMessage); } @@ -1439,8 +1411,7 @@ private: break; } } - } - else { + } else { if (dataEnd - dataP < 1) { throw DeadlyImportError(parseErrorMessage); } @@ -1483,11 +1454,11 @@ private: if (dataEnd - dataP < 1) { throw DeadlyImportError(parseErrorMessage); } - /*std::string id =*/ parseNonEmptyOctetString2(); + /*std::string id =*/parseNonEmptyOctetString2(); if (dataEnd - dataP < 1) { throw DeadlyImportError(parseErrorMessage); } - /*std::string data =*/ parseNonEmptyOctetString2(); + /*std::string data =*/parseNonEmptyOctetString2(); } } if (b & 0x20) { @@ -1662,12 +1633,12 @@ private: throw DeadlyImportError(parseErrorMessage); } /* C.11 */ - /*const std::string &name =*/ parseIdentifyingStringOrIndex(vocabulary.otherNCNameTable); + /*const std::string &name =*/parseIdentifyingStringOrIndex(vocabulary.otherNCNameTable); if (b1 & 0x02) { - /*const std::string &systemId =*/ parseIdentifyingStringOrIndex(vocabulary.otherURITable); + /*const std::string &systemId =*/parseIdentifyingStringOrIndex(vocabulary.otherURITable); } if (b1 & 0x01) { - /*const std::string &publicId =*/ parseIdentifyingStringOrIndex(vocabulary.otherURITable); + /*const std::string &publicId =*/parseIdentifyingStringOrIndex(vocabulary.otherURITable); } } } @@ -1685,12 +1656,12 @@ private: throw DeadlyImportError(parseErrorMessage); } /* C.10 */ - /*const std::string &name =*/ parseIdentifyingStringOrIndex(vocabulary.otherNCNameTable); - /*const std::string &systemId =*/ parseIdentifyingStringOrIndex(vocabulary.otherURITable); + /*const std::string &name =*/parseIdentifyingStringOrIndex(vocabulary.otherNCNameTable); + /*const std::string &systemId =*/parseIdentifyingStringOrIndex(vocabulary.otherURITable); if (b1 & 0x01) { - /*const std::string &publicId =*/ parseIdentifyingStringOrIndex(vocabulary.otherURITable); + /*const std::string &publicId =*/parseIdentifyingStringOrIndex(vocabulary.otherURITable); } - /*const std::string ¬ationName =*/ parseIdentifyingStringOrIndex(vocabulary.otherNCNameTable); + /*const std::string ¬ationName =*/parseIdentifyingStringOrIndex(vocabulary.otherNCNameTable); } } if (b & 0x04) { @@ -1698,7 +1669,7 @@ private: if (dataEnd - dataP < 1) { throw DeadlyImportError(parseErrorMessage); } - /*std::string characterEncodingScheme =*/ parseNonEmptyOctetString2(); + /*std::string characterEncodingScheme =*/parseNonEmptyOctetString2(); } if (b & 0x02) { // Parse standalone flag (C.2.9) @@ -1716,7 +1687,7 @@ private: if (dataEnd - dataP < 1) { throw DeadlyImportError(parseErrorMessage); } - /*std::shared_ptr version =*/ parseNonIdentifyingStringOrIndex1(vocabulary.otherStringTable); + /*std::shared_ptr version =*/parseNonIdentifyingStringOrIndex1(vocabulary.otherStringTable); } } @@ -1731,7 +1702,7 @@ private: std::stack elementStack; std::string nodeName; std::map> decoderMap; - std::map vocabularyMap; + std::map vocabularyMap; static const std::string EmptyString; static std::shared_ptr EmptyFIString; @@ -1776,14 +1747,11 @@ FIDecoder *CFIReaderImpl::defaultDecoder[32] = { &cdataDecoder }; -class CXMLReaderImpl : public FIReader -{ +class CXMLReaderImpl : public FIReader { public: - //! Constructor - CXMLReaderImpl(std::unique_ptr> reader_) - : reader(std::move(reader_)) - {} + CXMLReaderImpl(std::unique_ptr> reader_) : + reader(std::move(reader_)) {} virtual ~CXMLReaderImpl() {} @@ -1799,23 +1767,23 @@ public: return reader->getAttributeCount(); } - virtual const char* getAttributeName(int idx) const /*override*/ { + virtual const char *getAttributeName(int idx) const /*override*/ { return reader->getAttributeName(idx); } - virtual const char* getAttributeValue(int idx) const /*override*/ { + virtual const char *getAttributeValue(int idx) const /*override*/ { return reader->getAttributeValue(idx); } - virtual const char* getAttributeValue(const char* name) const /*override*/ { + virtual const char *getAttributeValue(const char *name) const /*override*/ { return reader->getAttributeValue(name); } - virtual const char* getAttributeValueSafe(const char* name) const /*override*/ { + virtual const char *getAttributeValueSafe(const char *name) const /*override*/ { return reader->getAttributeValueSafe(name); } - virtual int getAttributeValueAsInt(const char* name) const /*override*/ { + virtual int getAttributeValueAsInt(const char *name) const /*override*/ { return reader->getAttributeValueAsInt(name); } @@ -1823,7 +1791,7 @@ public: return reader->getAttributeValueAsInt(idx); } - virtual float getAttributeValueAsFloat(const char* name) const /*override*/ { + virtual float getAttributeValueAsFloat(const char *name) const /*override*/ { return reader->getAttributeValueAsFloat(name); } @@ -1831,11 +1799,11 @@ public: return reader->getAttributeValueAsFloat(idx); } - virtual const char* getNodeName() const /*override*/ { + virtual const char *getNodeName() const /*override*/ { return reader->getNodeName(); } - virtual const char* getNodeData() const /*override*/ { + virtual const char *getNodeData() const /*override*/ { return reader->getNodeData(); } @@ -1855,17 +1823,15 @@ public: return nullptr; } - virtual std::shared_ptr getAttributeEncodedValue(const char* /*name*/) const /*override*/ { + virtual std::shared_ptr getAttributeEncodedValue(const char * /*name*/) const /*override*/ { return nullptr; } virtual void registerDecoder(const std::string & /*algorithmUri*/, std::unique_ptr /*decoder*/) /*override*/ {} - - virtual void registerVocabulary(const std::string &/*vocabularyUri*/, const FIVocabulary * /*vocabulary*/) /*override*/ {} + virtual void registerVocabulary(const std::string & /*vocabularyUri*/, const FIVocabulary * /*vocabulary*/) /*override*/ {} private: - std::unique_ptr> reader; }; @@ -1880,21 +1846,19 @@ static std::unique_ptr readFile(IOStream *stream, size_t &size, bool return data; } -std::unique_ptr FIReader::create(IOStream *stream) -{ +std::unique_ptr FIReader::create(IOStream *stream) { size_t size; bool isFI; auto data = readFile(stream, size, isFI); if (isFI) { return std::unique_ptr(new CFIReaderImpl(std::move(data), size)); - } - else { + } else { auto memios = std::unique_ptr(new MemoryIOStream(data.release(), size, true)); auto callback = std::unique_ptr(new CIrrXML_IOStreamReader(memios.get())); return std::unique_ptr(new CXMLReaderImpl(std::unique_ptr>(createIrrXMLReader(callback.get())))); } } -}// namespace Assimp +} // namespace Assimp #endif // !ASSIMP_BUILD_NO_X3D_IMPORTER diff --git a/code/AssetLib/X3D/FIReader.hpp b/code/AssetLib/X3D/FIReader.hpp index dba8a69e9..bc7bbb03e 100644 --- a/code/AssetLib/X3D/FIReader.hpp +++ b/code/AssetLib/X3D/FIReader.hpp @@ -3,8 +3,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, @@ -49,10 +47,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef ASSIMP_BUILD_NO_X3D_IMPORTER -#include -#include #include #include +#include +#include #include #include @@ -64,58 +62,58 @@ struct FIValue { virtual ~FIValue() {} }; -struct FIStringValue: public FIValue { +struct FIStringValue : public FIValue { std::string value; static std::shared_ptr create(std::string &&value); }; -struct FIByteValue: public FIValue { +struct FIByteValue : public FIValue { std::vector value; }; -struct FIHexValue: public FIByteValue { +struct FIHexValue : public FIByteValue { static std::shared_ptr create(std::vector &&value); }; -struct FIBase64Value: public FIByteValue { +struct FIBase64Value : public FIByteValue { static std::shared_ptr create(std::vector &&value); }; -struct FIShortValue: public FIValue { +struct FIShortValue : public FIValue { std::vector value; static std::shared_ptr create(std::vector &&value); }; -struct FIIntValue: public FIValue { +struct FIIntValue : public FIValue { std::vector value; static std::shared_ptr create(std::vector &&value); }; -struct FILongValue: public FIValue { +struct FILongValue : public FIValue { std::vector value; static std::shared_ptr create(std::vector &&value); }; -struct FIBoolValue: public FIValue { +struct FIBoolValue : public FIValue { std::vector value; static std::shared_ptr create(std::vector &&value); }; -struct FIFloatValue: public FIValue { +struct FIFloatValue : public FIValue { std::vector value; static std::shared_ptr create(std::vector &&value); }; -struct FIDoubleValue: public FIValue { +struct FIDoubleValue : public FIValue { std::vector value; static std::shared_ptr create(std::vector &&value); }; -struct FIUUIDValue: public FIByteValue { +struct FIUUIDValue : public FIByteValue { static std::shared_ptr create(std::vector &&value); }; -struct FICDATAValue: public FIStringValue { +struct FICDATAValue : public FIStringValue { static std::shared_ptr create(std::string &&value); }; @@ -161,7 +159,7 @@ class IOStream; class FIReader { public: - virtual ~FIReader(); + virtual ~FIReader(); virtual std::shared_ptr getAttributeEncodedValue(int idx) const = 0; @@ -171,16 +169,17 @@ public: virtual void registerVocabulary(const std::string &vocabularyUri, const FIVocabulary *vocabulary) = 0; + virtual bool read() = 0; + static std::unique_ptr create(IOStream *stream); -};// class IFIReader +}; // class IFIReader -inline -FIReader::~FIReader() { - // empty +inline FIReader::~FIReader() { + // empty } -}// namespace Assimp +} // namespace Assimp #endif // #ifndef ASSIMP_BUILD_NO_X3D_IMPORTER diff --git a/code/AssetLib/X3D/X3DImporter.cpp b/code/AssetLib/X3D/X3DImporter.cpp index c9f9a6b6d..f382ea10e 100644 --- a/code/AssetLib/X3D/X3DImporter.cpp +++ b/code/AssetLib/X3D/X3DImporter.cpp @@ -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, @@ -51,64 +50,117 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include // Header files, Assimp. +//#include "FIReader.hpp" #include #include -#include "FIReader.hpp" // Header files, stdlib. +#include #include #include -#include namespace Assimp { -/// \var aiImporterDesc X3DImporter::Description /// Constant which holds the importer description const aiImporterDesc X3DImporter::Description = { - "Extensible 3D(X3D) Importer", - "smalcom", - "", - "See documentation in source code. Chapter: Limitations.", - aiImporterFlags_SupportTextFlavour | aiImporterFlags_SupportBinaryFlavour | aiImporterFlags_LimitedSupport | aiImporterFlags_Experimental, - 0, - 0, - 0, - 0, - "x3d x3db" + "Extensible 3D(X3D) Importer", + "smalcom", + "", + "See documentation in source code. Chapter: Limitations.", + aiImporterFlags_SupportTextFlavour | aiImporterFlags_SupportBinaryFlavour | aiImporterFlags_LimitedSupport | aiImporterFlags_Experimental, + 0, + 0, + 0, + 0, + "x3d x3db" }; //const std::regex X3DImporter::pattern_nws(R"([^, \t\r\n]+)"); //const std::regex X3DImporter::pattern_true(R"(^\s*(?:true|1)\s*$)", std::regex::icase); +namespace { +static void Throw_ArgOutOfRange(const std::string &argument) { + throw DeadlyImportError("Argument value is out of range for: \"" + argument + "\"."); +} + +static void Throw_CloseNotFound(const std::string &node) { + throw DeadlyImportError("Close tag for node <" + node + "> not found. Seems file is corrupt."); +} + +static void Throw_ConvertFail_Str2ArrF(const std::string &nodeName, const std::string &pAttrValue) { + throw DeadlyImportError("In <" + nodeName + "> failed to convert attribute value \"" + pAttrValue + + "\" from string to array of floats."); +} + +static void Throw_DEF_And_USE(const std::string &nodeName) { + throw DeadlyImportError("\"DEF\" and \"USE\" can not be defined both in <" + nodeName + ">."); +} + +static void Throw_IncorrectAttr(const std::string &nodeName, const std::string &pAttrName) { + throw DeadlyImportError("Node <" + nodeName + "> has incorrect attribute \"" + pAttrName + "\"."); +} + +static void Throw_IncorrectAttrValue(const std::string &nodeName, const std::string &pAttrName) { + throw DeadlyImportError("Attribute \"" + pAttrName + "\" in node <" + nodeName + "> has incorrect value."); +} + +static void Throw_MoreThanOnceDefined(const std::string &nodeName, const std::string &pNodeType, const std::string &pDescription) { + throw DeadlyImportError("\"" + pNodeType + "\" node can be used only once in " + nodeName + ". Description: " + pDescription); +} + +static void Throw_TagCountIncorrect(const std::string &pNode) { + throw DeadlyImportError("Count of open and close tags for node <" + pNode + "> are not equivalent. Seems file is corrupt."); +} + +static void Throw_USE_NotFound(const std::string &nodeName, const std::string &pAttrValue) { + throw DeadlyImportError("Not found node with name \"" + pAttrValue + "\" in <" + nodeName + ">."); +} + +static void LogInfo(const std::string &message) { + DefaultLogger::get()->info(message); +} + +} // namespace + struct WordIterator { using iterator_category = std::input_iterator_tag; - using value_type = const char*; + using value_type = const char *; using difference_type = ptrdiff_t; - using pointer = value_type*; - using reference = value_type&; + using pointer = value_type *; + using reference = value_type &; static const char *whitespace; - const char *start_, *end_; - WordIterator(const char *start, const char *end): start_(start), end_(end) { - start_ = start + strspn(start, whitespace); - if (start_ >= end_) { - start_ = 0; + const char *mStart, *mEnd; + + WordIterator(const char *start, const char *end) : + mStart(start), + mEnd(end) { + mStart = start + ::strspn(start, whitespace); + if (mStart >= mEnd) { + mStart = 0; } } - WordIterator(): start_(0), end_(0) {} - WordIterator(const WordIterator &other): start_(other.start_), end_(other.end_) {} + WordIterator() : + mStart(0), + mEnd(0) {} + WordIterator(const WordIterator &other) : + mStart(other.mStart), + mEnd(other.mEnd) {} WordIterator &operator=(const WordIterator &other) { - start_ = other.start_; - end_ = other.end_; + mStart = other.mStart; + mEnd = other.mEnd; return *this; } - bool operator==(const WordIterator &other) const { return start_ == other.start_; } - bool operator!=(const WordIterator &other) const { return start_ != other.start_; } + + bool operator==(const WordIterator &other) const { return mStart == other.mStart; } + + bool operator!=(const WordIterator &other) const { return mStart != other.mStart; } + WordIterator &operator++() { - start_ += strcspn(start_, whitespace); - start_ += strspn(start_, whitespace); - if (start_ >= end_) { - start_ = 0; + mStart += strcspn(mStart, whitespace); + mStart += strspn(mStart, whitespace); + if (mStart >= mEnd) { + mStart = 0; } return *this; } @@ -117,14 +169,13 @@ struct WordIterator { ++(*this); return result; } - const char *operator*() const { return start_; } + const char *operator*() const { return mStart; } }; -const char *WordIterator::whitespace = ", \t\r\n"; +static const char *WordIterator::whitespace = ", \t\r\n"; -X3DImporter::X3DImporter() -: NodeElement_Cur( nullptr ) -, mReader( nullptr ) { +X3DImporter::X3DImporter() : + mNodeElementCur(nullptr), mReader(nullptr) { // empty } @@ -134,96 +185,80 @@ X3DImporter::~X3DImporter() { } void X3DImporter::Clear() { - NodeElement_Cur = nullptr; - // Delete all elements - if(!NodeElement_List.empty()) { - for ( std::list::iterator it = NodeElement_List.begin(); it != NodeElement_List.end(); ++it ) { + mNodeElementCur = nullptr; + // Delete all elements + if (!NodeElement_List.empty()) { + for (std::list::iterator it = NodeElement_List.begin(); it != NodeElement_List.end(); ++it) { delete *it; } - NodeElement_List.clear(); - } + NodeElement_List.clear(); + } } - /*********************************************************************************************************************************************/ /************************************************************ Functions: find set ************************************************************/ /*********************************************************************************************************************************************/ -bool X3DImporter::FindNodeElement_FromRoot(const std::string& pID, const CX3DImporter_NodeElement::EType pType, CX3DImporter_NodeElement** pElement) -{ - for(std::list::iterator it = NodeElement_List.begin(); it != NodeElement_List.end(); ++it) - { - if(((*it)->Type == pType) && ((*it)->ID == pID)) - { - if(pElement != nullptr) *pElement = *it; +bool X3DImporter::FindNodeElement_FromRoot(const std::string &pID, const X3DNodeElementBase::EType pType, X3DNodeElementBase **pElement) { + for (std::list::iterator it = NodeElement_List.begin(); it != NodeElement_List.end(); ++it) { + if (((*it)->Type == pType) && ((*it)->ID == pID)) { + if (pElement != nullptr) *pElement = *it; - return true; - } - }// for(std::list::iterator it = NodeElement_List.begin(); it != NodeElement_List.end(); it++) + return true; + } + } // for(std::list::iterator it = NodeElement_List.begin(); it != NodeElement_List.end(); it++) - return false; + return false; } -bool X3DImporter::FindNodeElement_FromNode(CX3DImporter_NodeElement* pStartNode, const std::string& pID, - const CX3DImporter_NodeElement::EType pType, CX3DImporter_NodeElement** pElement) -{ - bool found = false;// flag: true - if requested element is found. +bool X3DImporter::FindNodeElement_FromNode(X3DNodeElementBase *pStartNode, const std::string &pID, + const X3DNodeElementBase::EType pType, X3DNodeElementBase **pElement) { + bool found = false; // flag: true - if requested element is found. - // Check if pStartNode - this is the element, we are looking for. - if((pStartNode->Type == pType) && (pStartNode->ID == pID)) - { - found = true; - if ( pElement != nullptr ) - { + // Check if pStartNode - this is the element, we are looking for. + if ((pStartNode->Type == pType) && (pStartNode->ID == pID)) { + found = true; + if (pElement != nullptr) { *pElement = pStartNode; } - goto fne_fn_end; - }// if((pStartNode->Type() == pType) && (pStartNode->ID() == pID)) + goto fne_fn_end; + } // if((pStartNode->Type() == pType) && (pStartNode->ID() == pID)) - // Check childs of pStartNode. - for(std::list::iterator ch_it = pStartNode->Child.begin(); ch_it != pStartNode->Child.end(); ++ch_it) - { - found = FindNodeElement_FromNode(*ch_it, pID, pType, pElement); - if ( found ) - { + // Check children of pStartNode. + for (std::list::iterator ch_it = pStartNode->Child.begin(); ch_it != pStartNode->Child.end(); ++ch_it) { + found = FindNodeElement_FromNode(*ch_it, pID, pType, pElement); + if (found) { break; } - }// for(std::list::iterator ch_it = it->Child.begin(); ch_it != it->Child.end(); ch_it++) + } // for(std::list::iterator ch_it = it->Child.begin(); ch_it != it->Child.end(); ch_it++) fne_fn_end: - return found; + return found; } -bool X3DImporter::FindNodeElement(const std::string& pID, const CX3DImporter_NodeElement::EType pType, CX3DImporter_NodeElement** pElement) -{ - CX3DImporter_NodeElement* tnd = NodeElement_Cur;// temporary pointer to node. - bool static_search = false;// flag: true if searching in static node. +bool X3DImporter::FindNodeElement(const std::string &pID, const X3DNodeElementBase::EType pType, X3DNodeElementBase **pElement) { + X3DNodeElementBase *tnd = mNodeElementCur; // temporary pointer to node. + bool static_search = false; // flag: true if searching in static node. // At first check if we have deal with static node. Go up through parent nodes and check flag. - while(tnd != nullptr) - { - if(tnd->Type == CX3DImporter_NodeElement::ENET_Group) - { - if(((CX3DImporter_NodeElement_Group*)tnd)->Static) - { - static_search = true;// Flag found, stop walking up. Node with static flag will holded in tnd variable. - break; - } - } + while (tnd != nullptr) { + if (tnd->Type == X3DNodeElementBase::ENET_Group) { + if (((X3DGroup *)tnd)->Static) { + static_search = true; // Flag found, stop walking up. Node with static flag will holded in tnd variable. + break; + } + } - tnd = tnd->Parent;// go up in graph. - }// while(tnd != nullptr) + tnd = tnd->Parent; // go up in graph. + } // while(tnd != nullptr) // at now call appropriate search function. - if ( static_search ) - { - return FindNodeElement_FromNode( tnd, pID, pType, pElement ); - } - else - { - return FindNodeElement_FromRoot( pID, pType, pElement ); + if (static_search) { + return FindNodeElement_FromNode(tnd, pID, pType, pElement); + } else { + return FindNodeElement_FromRoot(pID, pType, pElement); } } @@ -231,219 +266,160 @@ bool X3DImporter::FindNodeElement(const std::string& pID, const CX3DImporter_Nod /************************************************************ Functions: throw set ***********************************************************/ /*********************************************************************************************************************************************/ -void X3DImporter::Throw_ArgOutOfRange(const std::string& pArgument) -{ - throw DeadlyImportError("Argument value is out of range for: \"" + pArgument + "\"."); -} - -void X3DImporter::Throw_CloseNotFound(const std::string& pNode) -{ - throw DeadlyImportError("Close tag for node <" + pNode + "> not found. Seems file is corrupt."); -} - -void X3DImporter::Throw_ConvertFail_Str2ArrF(const std::string& pAttrValue) -{ - throw DeadlyImportError("In <" + std::string(mReader->getNodeName()) + "> failed to convert attribute value \"" + pAttrValue + - "\" from string to array of floats."); -} - -void X3DImporter::Throw_DEF_And_USE() -{ - throw DeadlyImportError("\"DEF\" and \"USE\" can not be defined both in <" + std::string(mReader->getNodeName()) + ">."); -} - -void X3DImporter::Throw_IncorrectAttr(const std::string& pAttrName) -{ - throw DeadlyImportError("Node <" + std::string(mReader->getNodeName()) + "> has incorrect attribute \"" + pAttrName + "\"."); -} - -void X3DImporter::Throw_IncorrectAttrValue(const std::string& pAttrName) -{ - throw DeadlyImportError("Attribute \"" + pAttrName + "\" in node <" + std::string(mReader->getNodeName()) + "> has incorrect value."); -} - -void X3DImporter::Throw_MoreThanOnceDefined(const std::string& pNodeType, const std::string& pDescription) -{ - throw DeadlyImportError("\"" + pNodeType + "\" node can be used only once in " + mReader->getNodeName() + ". Description: " + pDescription); -} - -void X3DImporter::Throw_TagCountIncorrect(const std::string& pNode) -{ - throw DeadlyImportError("Count of open and close tags for node <" + pNode + "> are not equivalent. Seems file is corrupt."); -} - -void X3DImporter::Throw_USE_NotFound(const std::string& pAttrValue) -{ - throw DeadlyImportError("Not found node with name \"" + pAttrValue + "\" in <" + std::string(mReader->getNodeName()) + ">."); -} - /*********************************************************************************************************************************************/ /************************************************************* Functions: XML set ************************************************************/ /*********************************************************************************************************************************************/ -void X3DImporter::XML_CheckNode_MustBeEmpty() -{ - if(!mReader->isEmptyElement()) throw DeadlyImportError(std::string("Node <") + mReader->getNodeName() + "> must be empty."); +void X3DImporter::XML_CheckNode_MustBeEmpty() { + if (!mReader->isEmptyElement()) throw DeadlyImportError(std::string("Node <") + mReader->getNodeName() + "> must be empty."); } -void X3DImporter::XML_CheckNode_SkipUnsupported(const std::string& pParentNodeName) -{ +void X3DImporter::XML_CheckNode_SkipUnsupported(const std::string &pParentNodeName) { static const size_t Uns_Skip_Len = 192; - const char* Uns_Skip[ Uns_Skip_Len ] = { - // CAD geometry component - "CADAssembly", "CADFace", "CADLayer", "CADPart", "IndexedQuadSet", "QuadSet", - // Core - "ROUTE", "ExternProtoDeclare", "ProtoDeclare", "ProtoInstance", "ProtoInterface", "WorldInfo", - // Distributed interactive simulation (DIS) component - "DISEntityManager", "DISEntityTypeMapping", "EspduTransform", "ReceiverPdu", "SignalPdu", "TransmitterPdu", - // Cube map environmental texturing component - "ComposedCubeMapTexture", "GeneratedCubeMapTexture", "ImageCubeMapTexture", - // Environmental effects component - "Background", "Fog", "FogCoordinate", "LocalFog", "TextureBackground", - // Environmental sensor component - "ProximitySensor", "TransformSensor", "VisibilitySensor", - // Followers component - "ColorChaser", "ColorDamper", "CoordinateChaser", "CoordinateDamper", "OrientationChaser", "OrientationDamper", "PositionChaser", "PositionChaser2D", - "PositionDamper", "PositionDamper2D", "ScalarChaser", "ScalarDamper", "TexCoordChaser2D", "TexCoordDamper2D", - // Geospatial component - "GeoCoordinate", "GeoElevationGrid", "GeoLocation", "GeoLOD", "GeoMetadata", "GeoOrigin", "GeoPositionInterpolator", "GeoProximitySensor", - "GeoTouchSensor", "GeoTransform", "GeoViewpoint", - // Humanoid Animation (H-Anim) component - "HAnimDisplacer", "HAnimHumanoid", "HAnimJoint", "HAnimSegment", "HAnimSite", - // Interpolation component - "ColorInterpolator", "CoordinateInterpolator", "CoordinateInterpolator2D", "EaseInEaseOut", "NormalInterpolator", "OrientationInterpolator", - "PositionInterpolator", "PositionInterpolator2D", "ScalarInterpolator", "SplinePositionInterpolator", "SplinePositionInterpolator2D", - "SplineScalarInterpolator", "SquadOrientationInterpolator", - // Key device sensor component - "KeySensor", "StringSensor", - // Layering component - "Layer", "LayerSet", "Viewport", - // Layout component - "Layout", "LayoutGroup", "LayoutLayer", "ScreenFontStyle", "ScreenGroup", - // Navigation component - "Billboard", "Collision", "LOD", "NavigationInfo", "OrthoViewpoint", "Viewpoint", "ViewpointGroup", - // Networking component - "EXPORT", "IMPORT", "Anchor", "LoadSensor", - // NURBS component - "Contour2D", "ContourPolyline2D", "CoordinateDouble", "NurbsCurve", "NurbsCurve2D", "NurbsOrientationInterpolator", "NurbsPatchSurface", - "NurbsPositionInterpolator", "NurbsSet", "NurbsSurfaceInterpolator", "NurbsSweptSurface", "NurbsSwungSurface", "NurbsTextureCoordinate", - "NurbsTrimmedSurface", - // Particle systems component - "BoundedPhysicsModel", "ConeEmitter", "ExplosionEmitter", "ForcePhysicsModel", "ParticleSystem", "PointEmitter", "PolylineEmitter", "SurfaceEmitter", - "VolumeEmitter", "WindPhysicsModel", - // Picking component - "LinePickSensor", "PickableGroup", "PointPickSensor", "PrimitivePickSensor", "VolumePickSensor", - // Pointing device sensor component - "CylinderSensor", "PlaneSensor", "SphereSensor", "TouchSensor", - // Rendering component - "ClipPlane", - // Rigid body physics - "BallJoint", "CollidableOffset", "CollidableShape", "CollisionCollection", "CollisionSensor", "CollisionSpace", "Contact", "DoubleAxisHingeJoint", - "MotorJoint", "RigidBody", "RigidBodyCollection", "SingleAxisHingeJoint", "SliderJoint", "UniversalJoint", - // Scripting component - "Script", - // Programmable shaders component - "ComposedShader", "FloatVertexAttribute", "Matrix3VertexAttribute", "Matrix4VertexAttribute", "PackagedShader", "ProgramShader", "ShaderPart", - "ShaderProgram", - // Shape component - "FillProperties", "LineProperties", "TwoSidedMaterial", - // Sound component - "AudioClip", "Sound", - // Text component - "FontStyle", "Text", - // Texturing3D Component - "ComposedTexture3D", "ImageTexture3D", "PixelTexture3D", "TextureCoordinate3D", "TextureCoordinate4D", "TextureTransformMatrix3D", "TextureTransform3D", - // Texturing component - "MovieTexture", "MultiTexture", "MultiTextureCoordinate", "MultiTextureTransform", "PixelTexture", "TextureCoordinateGenerator", "TextureProperties", - // Time component - "TimeSensor", - // Event Utilities component - "BooleanFilter", "BooleanSequencer", "BooleanToggle", "BooleanTrigger", "IntegerSequencer", "IntegerTrigger", "TimeTrigger", - // Volume rendering component - "BlendedVolumeStyle", "BoundaryEnhancementVolumeStyle", "CartoonVolumeStyle", "ComposedVolumeStyle", "EdgeEnhancementVolumeStyle", "IsoSurfaceVolumeData", - "OpacityMapVolumeStyle", "ProjectionVolumeStyle", "SegmentedVolumeData", "ShadedVolumeStyle", "SilhouetteEnhancementVolumeStyle", "ToneMappedVolumeStyle", - "VolumeData" + const char *Uns_Skip[Uns_Skip_Len] = { + // CAD geometry component + "CADAssembly", "CADFace", "CADLayer", "CADPart", "IndexedQuadSet", "QuadSet", + // Core + "ROUTE", "ExternProtoDeclare", "ProtoDeclare", "ProtoInstance", "ProtoInterface", "WorldInfo", + // Distributed interactive simulation (DIS) component + "DISEntityManager", "DISEntityTypeMapping", "EspduTransform", "ReceiverPdu", "SignalPdu", "TransmitterPdu", + // Cube map environmental texturing component + "ComposedCubeMapTexture", "GeneratedCubeMapTexture", "ImageCubeMapTexture", + // Environmental effects component + "Background", "Fog", "FogCoordinate", "LocalFog", "TextureBackground", + // Environmental sensor component + "ProximitySensor", "TransformSensor", "VisibilitySensor", + // Followers component + "ColorChaser", "ColorDamper", "CoordinateChaser", "CoordinateDamper", "OrientationChaser", "OrientationDamper", "PositionChaser", "PositionChaser2D", + "PositionDamper", "PositionDamper2D", "ScalarChaser", "ScalarDamper", "TexCoordChaser2D", "TexCoordDamper2D", + // Geospatial component + "GeoCoordinate", "GeoElevationGrid", "GeoLocation", "GeoLOD", "GeoMetadata", "GeoOrigin", "GeoPositionInterpolator", "GeoProximitySensor", + "GeoTouchSensor", "GeoTransform", "GeoViewpoint", + // Humanoid Animation (H-Anim) component + "HAnimDisplacer", "HAnimHumanoid", "HAnimJoint", "HAnimSegment", "HAnimSite", + // Interpolation component + "ColorInterpolator", "CoordinateInterpolator", "CoordinateInterpolator2D", "EaseInEaseOut", "NormalInterpolator", "OrientationInterpolator", + "PositionInterpolator", "PositionInterpolator2D", "ScalarInterpolator", "SplinePositionInterpolator", "SplinePositionInterpolator2D", + "SplineScalarInterpolator", "SquadOrientationInterpolator", + // Key device sensor component + "KeySensor", "StringSensor", + // Layering component + "Layer", "LayerSet", "Viewport", + // Layout component + "Layout", "LayoutGroup", "LayoutLayer", "ScreenFontStyle", "ScreenGroup", + // Navigation component + "Billboard", "Collision", "LOD", "NavigationInfo", "OrthoViewpoint", "Viewpoint", "ViewpointGroup", + // Networking component + "EXPORT", "IMPORT", "Anchor", "LoadSensor", + // NURBS component + "Contour2D", "ContourPolyline2D", "CoordinateDouble", "NurbsCurve", "NurbsCurve2D", "NurbsOrientationInterpolator", "NurbsPatchSurface", + "NurbsPositionInterpolator", "NurbsSet", "NurbsSurfaceInterpolator", "NurbsSweptSurface", "NurbsSwungSurface", "NurbsTextureCoordinate", + "NurbsTrimmedSurface", + // Particle systems component + "BoundedPhysicsModel", "ConeEmitter", "ExplosionEmitter", "ForcePhysicsModel", "ParticleSystem", "PointEmitter", "PolylineEmitter", "SurfaceEmitter", + "VolumeEmitter", "WindPhysicsModel", + // Picking component + "LinePickSensor", "PickableGroup", "PointPickSensor", "PrimitivePickSensor", "VolumePickSensor", + // Pointing device sensor component + "CylinderSensor", "PlaneSensor", "SphereSensor", "TouchSensor", + // Rendering component + "ClipPlane", + // Rigid body physics + "BallJoint", "CollidableOffset", "CollidableShape", "CollisionCollection", "CollisionSensor", "CollisionSpace", "Contact", "DoubleAxisHingeJoint", + "MotorJoint", "RigidBody", "RigidBodyCollection", "SingleAxisHingeJoint", "SliderJoint", "UniversalJoint", + // Scripting component + "Script", + // Programmable shaders component + "ComposedShader", "FloatVertexAttribute", "Matrix3VertexAttribute", "Matrix4VertexAttribute", "PackagedShader", "ProgramShader", "ShaderPart", + "ShaderProgram", + // Shape component + "FillProperties", "LineProperties", "TwoSidedMaterial", + // Sound component + "AudioClip", "Sound", + // Text component + "FontStyle", "Text", + // Texturing3D Component + "ComposedTexture3D", "ImageTexture3D", "PixelTexture3D", "TextureCoordinate3D", "TextureCoordinate4D", "TextureTransformMatrix3D", "TextureTransform3D", + // Texturing component + "MovieTexture", "MultiTexture", "MultiTextureCoordinate", "MultiTextureTransform", "PixelTexture", "TextureCoordinateGenerator", "TextureProperties", + // Time component + "TimeSensor", + // Event Utilities component + "BooleanFilter", "BooleanSequencer", "BooleanToggle", "BooleanTrigger", "IntegerSequencer", "IntegerTrigger", "TimeTrigger", + // Volume rendering component + "BlendedVolumeStyle", "BoundaryEnhancementVolumeStyle", "CartoonVolumeStyle", "ComposedVolumeStyle", "EdgeEnhancementVolumeStyle", "IsoSurfaceVolumeData", + "OpacityMapVolumeStyle", "ProjectionVolumeStyle", "SegmentedVolumeData", "ShadedVolumeStyle", "SilhouetteEnhancementVolumeStyle", "ToneMappedVolumeStyle", + "VolumeData" }; - const std::string nn( mReader->getNodeName() ); + const std::string nn(mReader->getNodeName()); bool found = false; bool close_found = false; - for(size_t i = 0; i < Uns_Skip_Len; i++) - { - if(nn == Uns_Skip[i]) - { - found = true; - if(mReader->isEmptyElement()) - { - close_found = true; + for (size_t i = 0; i < Uns_Skip_Len; i++) { + if (nn == Uns_Skip[i]) { + found = true; + if (mReader->isEmptyElement()) { + close_found = true; - goto casu_cres; - } + goto casu_cres; + } - while(mReader->read()) - { - if((mReader->getNodeType() == irr::io::EXN_ELEMENT_END) && (nn == mReader->getNodeName())) - { - close_found = true; + while (mReader->read()) { + if ((mReader->getNodeType() == irr::io::EXN_ELEMENT_END) && (nn == mReader->getNodeName())) { + close_found = true; - goto casu_cres; - } - } - } - } + goto casu_cres; + } + } + } + } casu_cres: - if(!found) throw DeadlyImportError("Unknown node \"" + nn + "\" in " + pParentNodeName + "."); + if (!found) throw DeadlyImportError("Unknown node \"" + nn + "\" in " + pParentNodeName + "."); - if(close_found) - LogInfo("Skipping node \"" + nn + "\" in " + pParentNodeName + "."); - else - Throw_CloseNotFound(nn); + if (close_found) + LogInfo("Skipping node \"" + nn + "\" in " + pParentNodeName + "."); + else + Throw_CloseNotFound(nn); } -bool X3DImporter::XML_SearchNode(const std::string& pNodeName) -{ - while(mReader->read()) - { - if((mReader->getNodeType() == irr::io::EXN_ELEMENT) && XML_CheckNode_NameEqual(pNodeName)) return true; - } +bool X3DImporter::XML_SearchNode(const std::string &pNodeName) { + while (mReader->read()) { + if ((mReader->getNodeType() == irr::io::EXN_ELEMENT) && XML_CheckNode_NameEqual(pNodeName)) return true; + } - return false; + return false; } -bool X3DImporter::XML_ReadNode_GetAttrVal_AsBool(const int pAttrIdx) -{ +bool X3DImporter::XML_ReadNode_GetAttrVal_AsBool(const int pAttrIdx) { auto boolValue = std::dynamic_pointer_cast(mReader->getAttributeEncodedValue(pAttrIdx)); if (boolValue) { if (boolValue->value.size() == 1) { return boolValue->value.front(); } throw DeadlyImportError("Invalid bool value"); - } - else { + } else { std::string val(mReader->getAttributeValue(pAttrIdx)); - if(val == "false") + if (val == "false") return false; - else if(val == "true") + else if (val == "true") return true; else throw DeadlyImportError("Bool attribute value can contain \"false\" or \"true\" not the \"" + val + "\""); } } -float X3DImporter::XML_ReadNode_GetAttrVal_AsFloat(const int pAttrIdx) -{ +float X3DImporter::XML_ReadNode_GetAttrVal_AsFloat(const int pAttrIdx) { auto floatValue = std::dynamic_pointer_cast(mReader->getAttributeEncodedValue(pAttrIdx)); if (floatValue) { if (floatValue->value.size() == 1) { return floatValue->value.front(); } throw DeadlyImportError("Invalid float value"); - } - else { + } else { std::string val; float tvalf; @@ -454,68 +430,61 @@ float X3DImporter::XML_ReadNode_GetAttrVal_AsFloat(const int pAttrIdx) } } -int32_t X3DImporter::XML_ReadNode_GetAttrVal_AsI32(const int pAttrIdx) -{ +int32_t X3DImporter::XML_ReadNode_GetAttrVal_AsI32(const int pAttrIdx) { auto intValue = std::dynamic_pointer_cast(mReader->getAttributeEncodedValue(pAttrIdx)); if (intValue) { if (intValue->value.size() == 1) { return intValue->value.front(); } throw DeadlyImportError("Invalid int value"); - } - else { + } else { return strtol10(mReader->getAttributeValue(pAttrIdx)); } } -void X3DImporter::XML_ReadNode_GetAttrVal_AsCol3f(const int pAttrIdx, aiColor3D& pValue) -{ +void X3DImporter::XML_ReadNode_GetAttrVal_AsCol3f(const int pAttrIdx, aiColor3D &pValue) { std::vector tlist; std::vector::iterator it; - XML_ReadNode_GetAttrVal_AsArrF(pAttrIdx, tlist); - if(tlist.size() != 3) Throw_ConvertFail_Str2ArrF(mReader->getAttributeValue(pAttrIdx)); + XML_ReadNode_GetAttrVal_AsArrF(pAttrIdx, tlist); + if (tlist.size() != 3) Throw_ConvertFail_Str2ArrF(mReader->getAttributeValue(pAttrIdx)); - it = tlist.begin(); - pValue.r = *it++; - pValue.g = *it++; - pValue.b = *it; + it = tlist.begin(); + pValue.r = *it++; + pValue.g = *it++; + pValue.b = *it; } -void X3DImporter::XML_ReadNode_GetAttrVal_AsVec2f(const int pAttrIdx, aiVector2D& pValue) -{ +void X3DImporter::XML_ReadNode_GetAttrVal_AsVec2f(const int pAttrIdx, aiVector2D &pValue) { std::vector tlist; std::vector::iterator it; - XML_ReadNode_GetAttrVal_AsArrF(pAttrIdx, tlist); - if(tlist.size() != 2) Throw_ConvertFail_Str2ArrF(mReader->getAttributeValue(pAttrIdx)); + XML_ReadNode_GetAttrVal_AsArrF(pAttrIdx, tlist); + if (tlist.size() != 2) Throw_ConvertFail_Str2ArrF(mReader->getAttributeValue(pAttrIdx)); - it = tlist.begin(); - pValue.x = *it++; - pValue.y = *it; + it = tlist.begin(); + pValue.x = *it++; + pValue.y = *it; } -void X3DImporter::XML_ReadNode_GetAttrVal_AsVec3f(const int pAttrIdx, aiVector3D& pValue) -{ +void X3DImporter::XML_ReadNode_GetAttrVal_AsVec3f(const int pAttrIdx, aiVector3D &pValue) { std::vector tlist; std::vector::iterator it; - XML_ReadNode_GetAttrVal_AsArrF(pAttrIdx, tlist); - if(tlist.size() != 3) Throw_ConvertFail_Str2ArrF(mReader->getAttributeValue(pAttrIdx)); + XML_ReadNode_GetAttrVal_AsArrF(pAttrIdx, tlist); + if (tlist.size() != 3) Throw_ConvertFail_Str2ArrF(mReader->getAttributeValue(pAttrIdx)); - it = tlist.begin(); - pValue.x = *it++; - pValue.y = *it++; - pValue.z = *it; + it = tlist.begin(); + pValue.x = *it++; + pValue.y = *it++; + pValue.z = *it; } -void X3DImporter::XML_ReadNode_GetAttrVal_AsArrB(const int pAttrIdx, std::vector& pValue) -{ +void X3DImporter::XML_ReadNode_GetAttrVal_AsArrB(const int pAttrIdx, std::vector &pValue) { auto boolValue = std::dynamic_pointer_cast(mReader->getAttributeEncodedValue(pAttrIdx)); if (boolValue) { pValue = boolValue->value; - } - else { + } else { const char *val = mReader->getAttributeValue(pAttrIdx); pValue.clear(); @@ -529,13 +498,11 @@ void X3DImporter::XML_ReadNode_GetAttrVal_AsArrB(const int pAttrIdx, std::vector } } -void X3DImporter::XML_ReadNode_GetAttrVal_AsArrI32(const int pAttrIdx, std::vector& pValue) -{ +void X3DImporter::XML_ReadNode_GetAttrVal_AsArrI32(const int pAttrIdx, std::vector &pValue) { auto intValue = std::dynamic_pointer_cast(mReader->getAttributeEncodedValue(pAttrIdx)); if (intValue) { pValue = intValue->value; - } - else { + } else { const char *val = mReader->getAttributeValue(pAttrIdx); pValue.clear(); @@ -549,13 +516,11 @@ void X3DImporter::XML_ReadNode_GetAttrVal_AsArrI32(const int pAttrIdx, std::vect } } -void X3DImporter::XML_ReadNode_GetAttrVal_AsArrF(const int pAttrIdx, std::vector& pValue) -{ +void X3DImporter::XML_ReadNode_GetAttrVal_AsArrF(const int pAttrIdx, std::vector &pValue) { auto floatValue = std::dynamic_pointer_cast(mReader->getAttributeEncodedValue(pAttrIdx)); if (floatValue) { pValue = floatValue->value; - } - else { + } else { const char *val = mReader->getAttributeValue(pAttrIdx); pValue.clear(); @@ -569,13 +534,11 @@ void X3DImporter::XML_ReadNode_GetAttrVal_AsArrF(const int pAttrIdx, std::vector } } -void X3DImporter::XML_ReadNode_GetAttrVal_AsArrD(const int pAttrIdx, std::vector& pValue) -{ +void X3DImporter::XML_ReadNode_GetAttrVal_AsArrD(const int pAttrIdx, std::vector &pValue) { auto doubleValue = std::dynamic_pointer_cast(mReader->getAttributeEncodedValue(pAttrIdx)); if (doubleValue) { pValue = doubleValue->value; - } - else { + } else { const char *val = mReader->getAttributeValue(pAttrIdx); pValue.clear(); @@ -589,1147 +552,986 @@ void X3DImporter::XML_ReadNode_GetAttrVal_AsArrD(const int pAttrIdx, std::vector } } -void X3DImporter::XML_ReadNode_GetAttrVal_AsListCol3f(const int pAttrIdx, std::list& pValue) -{ +void X3DImporter::XML_ReadNode_GetAttrVal_AsListCol3f(const int pAttrIdx, std::list &pValue) { std::vector tlist; - XML_ReadNode_GetAttrVal_AsArrF(pAttrIdx, tlist);// read as list - if(tlist.size() % 3) Throw_ConvertFail_Str2ArrF(mReader->getAttributeValue(pAttrIdx)); + XML_ReadNode_GetAttrVal_AsArrF(pAttrIdx, tlist); // read as list + if (tlist.size() % 3) Throw_ConvertFail_Str2ArrF(mReader->getAttributeValue(pAttrIdx)); - // copy data to array - for(std::vector::iterator it = tlist.begin(); it != tlist.end();) - { - aiColor3D tcol; + // copy data to array + for (std::vector::iterator it = tlist.begin(); it != tlist.end();) { + aiColor3D tcol; - tcol.r = *it++; - tcol.g = *it++; - tcol.b = *it++; - pValue.push_back(tcol); - } + tcol.r = *it++; + tcol.g = *it++; + tcol.b = *it++; + pValue.push_back(tcol); + } } -void X3DImporter::XML_ReadNode_GetAttrVal_AsArrCol3f(const int pAttrIdx, std::vector& pValue) -{ +void X3DImporter::XML_ReadNode_GetAttrVal_AsArrCol3f(const int pAttrIdx, std::vector &pValue) { std::list tlist; - XML_ReadNode_GetAttrVal_AsListCol3f(pAttrIdx, tlist);// read as list - // and copy to array - if(!tlist.empty()) - { - pValue.reserve(tlist.size()); - for(std::list::iterator it = tlist.begin(); it != tlist.end(); ++it) pValue.push_back(*it); - } + XML_ReadNode_GetAttrVal_AsListCol3f(pAttrIdx, tlist); // read as list + // and copy to array + if (!tlist.empty()) { + pValue.reserve(tlist.size()); + for (std::list::iterator it = tlist.begin(); it != tlist.end(); ++it) + pValue.push_back(*it); + } } -void X3DImporter::XML_ReadNode_GetAttrVal_AsListCol4f(const int pAttrIdx, std::list& pValue) -{ +void X3DImporter::XML_ReadNode_GetAttrVal_AsListCol4f(const int pAttrIdx, std::list &pValue) { std::vector tlist; - XML_ReadNode_GetAttrVal_AsArrF(pAttrIdx, tlist);// read as list - if(tlist.size() % 4) Throw_ConvertFail_Str2ArrF(mReader->getAttributeValue(pAttrIdx)); + XML_ReadNode_GetAttrVal_AsArrF(pAttrIdx, tlist); // read as list + if (tlist.size() % 4) Throw_ConvertFail_Str2ArrF(mReader->getAttributeValue(pAttrIdx)); - // copy data to array - for(std::vector::iterator it = tlist.begin(); it != tlist.end();) - { - aiColor4D tcol; + // copy data to array + for (std::vector::iterator it = tlist.begin(); it != tlist.end();) { + aiColor4D tcol; - tcol.r = *it++; - tcol.g = *it++; - tcol.b = *it++; - tcol.a = *it++; - pValue.push_back(tcol); - } + tcol.r = *it++; + tcol.g = *it++; + tcol.b = *it++; + tcol.a = *it++; + pValue.push_back(tcol); + } } -void X3DImporter::XML_ReadNode_GetAttrVal_AsArrCol4f(const int pAttrIdx, std::vector& pValue) -{ +void X3DImporter::XML_ReadNode_GetAttrVal_AsArrCol4f(const int pAttrIdx, std::vector &pValue) { std::list tlist; - XML_ReadNode_GetAttrVal_AsListCol4f(pAttrIdx, tlist);// read as list - // and copy to array - if(!tlist.empty()) - { - pValue.reserve(tlist.size()); - for ( std::list::iterator it = tlist.begin(); it != tlist.end(); ++it ) - { - pValue.push_back( *it ); + XML_ReadNode_GetAttrVal_AsListCol4f(pAttrIdx, tlist); // read as list + // and copy to array + if (!tlist.empty()) { + pValue.reserve(tlist.size()); + for (std::list::iterator it = tlist.begin(); it != tlist.end(); ++it) { + pValue.push_back(*it); } - } + } } -void X3DImporter::XML_ReadNode_GetAttrVal_AsListVec2f(const int pAttrIdx, std::list& pValue) -{ +void X3DImporter::XML_ReadNode_GetAttrVal_AsListVec2f(const int pAttrIdx, std::list &pValue) { std::vector tlist; - XML_ReadNode_GetAttrVal_AsArrF(pAttrIdx, tlist);// read as list - if ( tlist.size() % 2 ) - { - Throw_ConvertFail_Str2ArrF( mReader->getAttributeValue( pAttrIdx ) ); + XML_ReadNode_GetAttrVal_AsArrF(pAttrIdx, tlist); // read as list + if (tlist.size() % 2) { + Throw_ConvertFail_Str2ArrF(mReader->getAttributeValue(pAttrIdx)); } - // copy data to array - for(std::vector::iterator it = tlist.begin(); it != tlist.end();) - { - aiVector2D tvec; + // copy data to array + for (std::vector::iterator it = tlist.begin(); it != tlist.end();) { + aiVector2D tvec; - tvec.x = *it++; - tvec.y = *it++; - pValue.push_back(tvec); - } + tvec.x = *it++; + tvec.y = *it++; + pValue.push_back(tvec); + } } -void X3DImporter::XML_ReadNode_GetAttrVal_AsArrVec2f(const int pAttrIdx, std::vector& pValue) -{ +void X3DImporter::XML_ReadNode_GetAttrVal_AsArrVec2f(const int pAttrIdx, std::vector &pValue) { std::list tlist; - XML_ReadNode_GetAttrVal_AsListVec2f(pAttrIdx, tlist);// read as list - // and copy to array - if(!tlist.empty()) - { - pValue.reserve(tlist.size()); - for ( std::list::iterator it = tlist.begin(); it != tlist.end(); ++it ) - { - pValue.push_back( *it ); + XML_ReadNode_GetAttrVal_AsListVec2f(pAttrIdx, tlist); // read as list + // and copy to array + if (!tlist.empty()) { + pValue.reserve(tlist.size()); + for (std::list::iterator it = tlist.begin(); it != tlist.end(); ++it) { + pValue.push_back(*it); } - } + } } -void X3DImporter::XML_ReadNode_GetAttrVal_AsListVec3f(const int pAttrIdx, std::list& pValue) -{ +void X3DImporter::XML_ReadNode_GetAttrVal_AsListVec3f(const int pAttrIdx, std::list &pValue) { std::vector tlist; - XML_ReadNode_GetAttrVal_AsArrF(pAttrIdx, tlist);// read as list - if ( tlist.size() % 3 ) - { - Throw_ConvertFail_Str2ArrF( mReader->getAttributeValue( pAttrIdx ) ); + XML_ReadNode_GetAttrVal_AsArrF(pAttrIdx, tlist); // read as list + if (tlist.size() % 3) { + Throw_ConvertFail_Str2ArrF(mReader->getAttributeValue(pAttrIdx)); } - // copy data to array - for(std::vector::iterator it = tlist.begin(); it != tlist.end();) - { - aiVector3D tvec; + // copy data to array + for (std::vector::iterator it = tlist.begin(); it != tlist.end();) { + aiVector3D tvec; - tvec.x = *it++; - tvec.y = *it++; - tvec.z = *it++; - pValue.push_back(tvec); - } + tvec.x = *it++; + tvec.y = *it++; + tvec.z = *it++; + pValue.push_back(tvec); + } } -void X3DImporter::XML_ReadNode_GetAttrVal_AsArrVec3f(const int pAttrIdx, std::vector& pValue) -{ +void X3DImporter::XML_ReadNode_GetAttrVal_AsArrVec3f(const int pAttrIdx, std::vector &pValue) { std::list tlist; - XML_ReadNode_GetAttrVal_AsListVec3f(pAttrIdx, tlist);// read as list - // and copy to array - if(!tlist.empty()) - { - pValue.reserve(tlist.size()); - for ( std::list::iterator it = tlist.begin(); it != tlist.end(); ++it ) - { - pValue.push_back( *it ); + XML_ReadNode_GetAttrVal_AsListVec3f(pAttrIdx, tlist); // read as list + // and copy to array + if (!tlist.empty()) { + pValue.reserve(tlist.size()); + for (std::list::iterator it = tlist.begin(); it != tlist.end(); ++it) { + pValue.push_back(*it); } - } + } } -void X3DImporter::XML_ReadNode_GetAttrVal_AsListS(const int pAttrIdx, std::list& pValue) -{ - // make copy of attribute value - strings list. - const size_t tok_str_len = strlen(mReader->getAttributeValue(pAttrIdx)); - if ( 0 == tok_str_len ) - { - Throw_IncorrectAttrValue( mReader->getAttributeName( pAttrIdx ) ); +void X3DImporter::XML_ReadNode_GetAttrVal_AsListS(const int pAttrIdx, std::list &pValue) { + // make copy of attribute value - strings list. + const size_t tok_str_len = strlen(mReader->getAttributeValue(pAttrIdx)); + if (0 == tok_str_len) { + Throw_IncorrectAttrValue(mReader->getAttributeName(pAttrIdx)); } - // get pointer to begin of value. - char *tok_str = const_cast(mReader->getAttributeValue(pAttrIdx)); + // get pointer to begin of value. + char *tok_str = const_cast(mReader->getAttributeValue(pAttrIdx)); char *tok_str_end = tok_str + tok_str_len; - // string list has following format: attr_name='"s1" "s2" "sn"'. - do - { - char* tbeg; - char* tend; - size_t tlen; - std::string tstr; + // string list has following format: attr_name='"s1" "s2" "sn"'. + do { + char *tbeg; + char *tend; + size_t tlen; + std::string tstr; - // find begin of string(element of string list): "sn". - tbeg = strstr(tok_str, "\""); - if(tbeg == nullptr) Throw_IncorrectAttrValue(mReader->getAttributeName(pAttrIdx)); + // find begin of string(element of string list): "sn". + tbeg = strstr(tok_str, "\""); + if (tbeg == nullptr) Throw_IncorrectAttrValue(mReader->getAttributeName(pAttrIdx)); - tbeg++;// forward pointer from '\"' symbol to next after it. - tok_str = tbeg; - // find end of string(element of string list): "sn". - tend = strstr(tok_str, "\""); - if(tend == nullptr) Throw_IncorrectAttrValue(mReader->getAttributeName(pAttrIdx)); + tbeg++; // forward pointer from '\"' symbol to next after it. + tok_str = tbeg; + // find end of string(element of string list): "sn". + tend = strstr(tok_str, "\""); + if (tend == nullptr) Throw_IncorrectAttrValue(mReader->getAttributeName(pAttrIdx)); - tok_str = tend + 1; - // create storage for new string - tlen = tend - tbeg; - tstr.resize(tlen);// reserve enough space and copy data - memcpy((void*)tstr.data(), tbeg, tlen);// not strcpy because end of copied string from tok_str has no terminator. - // and store string in output list. - pValue.push_back(tstr); - } while(tok_str < tok_str_end); + tok_str = tend + 1; + // create storage for new string + tlen = tend - tbeg; + tstr.resize(tlen); // reserve enough space and copy data + memcpy((void *)tstr.data(), tbeg, tlen); // not strcpy because end of copied string from tok_str has no terminator. + // and store string in output list. + pValue.push_back(tstr); + } while (tok_str < tok_str_end); } /*********************************************************************************************************************************************/ /****************************************************** Functions: geometry helper set ******************************************************/ /*********************************************************************************************************************************************/ -aiVector3D X3DImporter::GeometryHelper_Make_Point2D(const float pAngle, const float pRadius) -{ - return aiVector3D(pRadius * std::cos(pAngle), pRadius * std::sin(pAngle), 0); +aiVector3D X3DImporter::GeometryHelper_Make_Point2D(const float pAngle, const float pRadius) { + return aiVector3D(pRadius * std::cos(pAngle), pRadius * std::sin(pAngle), 0); } void X3DImporter::GeometryHelper_Make_Arc2D(const float pStartAngle, const float pEndAngle, const float pRadius, size_t pNumSegments, - std::list& pVertices) -{ - // check argument values ranges. - if ( ( pStartAngle < -AI_MATH_TWO_PI_F ) || ( pStartAngle > AI_MATH_TWO_PI_F ) ) - { - Throw_ArgOutOfRange( "GeometryHelper_Make_Arc2D.pStartAngle" ); + std::list &pVertices) { + // check argument values ranges. + if ((pStartAngle < -AI_MATH_TWO_PI_F) || (pStartAngle > AI_MATH_TWO_PI_F)) { + Throw_ArgOutOfRange("GeometryHelper_Make_Arc2D.pStartAngle"); } - if ( ( pEndAngle < -AI_MATH_TWO_PI_F ) || ( pEndAngle > AI_MATH_TWO_PI_F ) ) - { - Throw_ArgOutOfRange( "GeometryHelper_Make_Arc2D.pEndAngle" ); + if ((pEndAngle < -AI_MATH_TWO_PI_F) || (pEndAngle > AI_MATH_TWO_PI_F)) { + Throw_ArgOutOfRange("GeometryHelper_Make_Arc2D.pEndAngle"); } - if ( pRadius <= 0 ) - { - Throw_ArgOutOfRange( "GeometryHelper_Make_Arc2D.pRadius" ); + if (pRadius <= 0) { + Throw_ArgOutOfRange("GeometryHelper_Make_Arc2D.pRadius"); } - // calculate arc angle and check type of arc - float angle_full = std::fabs(pEndAngle - pStartAngle); - if ( ( angle_full > AI_MATH_TWO_PI_F ) || ( angle_full == 0.0f ) ) - { + // calculate arc angle and check type of arc + float angle_full = std::fabs(pEndAngle - pStartAngle); + if ((angle_full > AI_MATH_TWO_PI_F) || (angle_full == 0.0f)) { angle_full = AI_MATH_TWO_PI_F; } - // calculate angle for one step - angle to next point of line. - float angle_step = angle_full / (float)pNumSegments; - // make points - for(size_t pi = 0; pi <= pNumSegments; pi++) - { - float tangle = pStartAngle + pi * angle_step; - pVertices.push_back(GeometryHelper_Make_Point2D(tangle, pRadius)); - }// for(size_t pi = 0; pi <= pNumSegments; pi++) + // calculate angle for one step - angle to next point of line. + float angle_step = angle_full / (float)pNumSegments; + // make points + for (size_t pi = 0; pi <= pNumSegments; pi++) { + float tangle = pStartAngle + pi * angle_step; + pVertices.push_back(GeometryHelper_Make_Point2D(tangle, pRadius)); + } // for(size_t pi = 0; pi <= pNumSegments; pi++) - // if we making full circle then add last vertex equal to first vertex - if(angle_full == AI_MATH_TWO_PI_F) pVertices.push_back(*pVertices.begin()); + // if we making full circle then add last vertex equal to first vertex + if (angle_full == AI_MATH_TWO_PI_F) pVertices.push_back(*pVertices.begin()); } -void X3DImporter::GeometryHelper_Extend_PointToLine(const std::list& pPoint, std::list& pLine) -{ +void X3DImporter::GeometryHelper_Extend_PointToLine(const std::list &pPoint, std::list &pLine) { std::list::const_iterator pit = pPoint.begin(); std::list::const_iterator pit_last = pPoint.end(); - --pit_last; + --pit_last; - if ( pPoint.size() < 2 ) - { - Throw_ArgOutOfRange( "GeometryHelper_Extend_PointToLine.pPoint.size() can not be less than 2." ); + if (pPoint.size() < 2) { + Throw_ArgOutOfRange("GeometryHelper_Extend_PointToLine.pPoint.size() can not be less than 2."); } - // add first point of first line. - pLine.push_back(*pit++); - // add internal points - while(pit != pit_last) - { - pLine.push_back(*pit);// second point of previous line - pLine.push_back(*pit);// first point of next line - ++pit; - } - // add last point of last line - pLine.push_back(*pit); + // add first point of first line. + pLine.push_back(*pit++); + // add internal points + while (pit != pit_last) { + pLine.push_back(*pit); // second point of previous line + pLine.push_back(*pit); // first point of next line + ++pit; + } + // add last point of last line + pLine.push_back(*pit); } -void X3DImporter::GeometryHelper_Extend_PolylineIdxToLineIdx(const std::list& pPolylineCoordIdx, std::list& pLineCoordIdx) -{ +void X3DImporter::GeometryHelper_Extend_PolylineIdxToLineIdx(const std::list &pPolylineCoordIdx, std::list &pLineCoordIdx) { std::list::const_iterator plit = pPolylineCoordIdx.begin(); - while(plit != pPolylineCoordIdx.end()) - { - // add first point of polyline - pLineCoordIdx.push_back(*plit++); - while((*plit != (-1)) && (plit != pPolylineCoordIdx.end())) - { - std::list::const_iterator plit_next; + while (plit != pPolylineCoordIdx.end()) { + // add first point of polyline + pLineCoordIdx.push_back(*plit++); + while ((*plit != (-1)) && (plit != pPolylineCoordIdx.end())) { + std::list::const_iterator plit_next; - plit_next = plit, ++plit_next; - pLineCoordIdx.push_back(*plit);// second point of previous line. - pLineCoordIdx.push_back(-1);// delimiter - if((*plit_next == (-1)) || (plit_next == pPolylineCoordIdx.end())) break;// current polyline is finished + plit_next = plit, ++plit_next; + pLineCoordIdx.push_back(*plit); // second point of previous line. + pLineCoordIdx.push_back(-1); // delimiter + if ((*plit_next == (-1)) || (plit_next == pPolylineCoordIdx.end())) break; // current polyline is finished - pLineCoordIdx.push_back(*plit);// first point of next line. - plit = plit_next; - }// while((*plit != (-1)) && (plit != pPolylineCoordIdx.end())) - }// while(plit != pPolylineCoordIdx.end()) + pLineCoordIdx.push_back(*plit); // first point of next line. + plit = plit_next; + } // while((*plit != (-1)) && (plit != pPolylineCoordIdx.end())) + } // while(plit != pPolylineCoordIdx.end()) } #define MESH_RectParallelepiped_CREATE_VERT \ -aiVector3D vert_set[8]; \ -float x1, x2, y1, y2, z1, z2, hs; \ - \ - hs = pSize.x / 2, x1 = -hs, x2 = hs; \ - hs = pSize.y / 2, y1 = -hs, y2 = hs; \ - hs = pSize.z / 2, z1 = -hs, z2 = hs; \ - vert_set[0].Set(x2, y1, z2); \ - vert_set[1].Set(x2, y2, z2); \ - vert_set[2].Set(x2, y2, z1); \ - vert_set[3].Set(x2, y1, z1); \ - vert_set[4].Set(x1, y1, z2); \ - vert_set[5].Set(x1, y2, z2); \ - vert_set[6].Set(x1, y2, z1); \ - vert_set[7].Set(x1, y1, z1) + aiVector3D vert_set[8]; \ + float x1, x2, y1, y2, z1, z2, hs; \ + \ + hs = pSize.x / 2, x1 = -hs, x2 = hs; \ + hs = pSize.y / 2, y1 = -hs, y2 = hs; \ + hs = pSize.z / 2, z1 = -hs, z2 = hs; \ + vert_set[0].Set(x2, y1, z2); \ + vert_set[1].Set(x2, y2, z2); \ + vert_set[2].Set(x2, y2, z1); \ + vert_set[3].Set(x2, y1, z1); \ + vert_set[4].Set(x1, y1, z2); \ + vert_set[5].Set(x1, y2, z2); \ + vert_set[6].Set(x1, y2, z1); \ + vert_set[7].Set(x1, y1, z1) -void X3DImporter::GeometryHelper_MakeQL_RectParallelepiped(const aiVector3D& pSize, std::list& pVertices) -{ - MESH_RectParallelepiped_CREATE_VERT; - MACRO_FACE_ADD_QUAD_FA(true, pVertices, vert_set, 3, 2, 1, 0);// front - MACRO_FACE_ADD_QUAD_FA(true, pVertices, vert_set, 6, 7, 4, 5);// back - MACRO_FACE_ADD_QUAD_FA(true, pVertices, vert_set, 7, 3, 0, 4);// left - MACRO_FACE_ADD_QUAD_FA(true, pVertices, vert_set, 2, 6, 5, 1);// right - MACRO_FACE_ADD_QUAD_FA(true, pVertices, vert_set, 0, 1, 5, 4);// top - MACRO_FACE_ADD_QUAD_FA(true, pVertices, vert_set, 7, 6, 2, 3);// bottom +void X3DImporter::GeometryHelper_MakeQL_RectParallelepiped(const aiVector3D &pSize, std::list &pVertices) { + MESH_RectParallelepiped_CREATE_VERT; + MACRO_FACE_ADD_QUAD_FA(true, pVertices, vert_set, 3, 2, 1, 0); // front + MACRO_FACE_ADD_QUAD_FA(true, pVertices, vert_set, 6, 7, 4, 5); // back + MACRO_FACE_ADD_QUAD_FA(true, pVertices, vert_set, 7, 3, 0, 4); // left + MACRO_FACE_ADD_QUAD_FA(true, pVertices, vert_set, 2, 6, 5, 1); // right + MACRO_FACE_ADD_QUAD_FA(true, pVertices, vert_set, 0, 1, 5, 4); // top + MACRO_FACE_ADD_QUAD_FA(true, pVertices, vert_set, 7, 6, 2, 3); // bottom } #undef MESH_RectParallelepiped_CREATE_VERT -void X3DImporter::GeometryHelper_CoordIdxStr2FacesArr(const std::vector& pCoordIdx, std::vector& pFaces, unsigned int& pPrimitiveTypes) const -{ +void X3DImporter::GeometryHelper_CoordIdxStr2FacesArr(const std::vector &pCoordIdx, std::vector &pFaces, unsigned int &pPrimitiveTypes) const { std::vector f_data(pCoordIdx); std::vector inds; unsigned int prim_type = 0; - if ( f_data.back() != ( -1 ) ) - { - f_data.push_back( -1 ); + if (f_data.back() != (-1)) { + f_data.push_back(-1); } - // reserve average size. - pFaces.reserve(f_data.size() / 3); - inds.reserve(4); + // reserve average size. + pFaces.reserve(f_data.size() / 3); + inds.reserve(4); //PrintVectorSet("build. ci", pCoordIdx); - for(std::vector::iterator it = f_data.begin(); it != f_data.end(); ++it) - { - // when face is got count how many indices in it. - if(*it == (-1)) - { - aiFace tface; - size_t ts; + for (std::vector::iterator it = f_data.begin(); it != f_data.end(); ++it) { + // when face is got count how many indices in it. + if (*it == (-1)) { + aiFace tface; + size_t ts; - ts = inds.size(); - switch(ts) - { - case 0: goto mg_m_err; - case 1: prim_type |= aiPrimitiveType_POINT; break; - case 2: prim_type |= aiPrimitiveType_LINE; break; - case 3: prim_type |= aiPrimitiveType_TRIANGLE; break; - default: prim_type |= aiPrimitiveType_POLYGON; break; - } + ts = inds.size(); + switch (ts) { + case 0: goto mg_m_err; + case 1: prim_type |= aiPrimitiveType_POINT; break; + case 2: prim_type |= aiPrimitiveType_LINE; break; + case 3: prim_type |= aiPrimitiveType_TRIANGLE; break; + default: prim_type |= aiPrimitiveType_POLYGON; break; + } - tface.mNumIndices = static_cast(ts); - tface.mIndices = new unsigned int[ts]; - memcpy(tface.mIndices, inds.data(), ts * sizeof(unsigned int)); - pFaces.push_back(tface); - inds.clear(); - }// if(*it == (-1)) - else - { - inds.push_back(*it); - }// if(*it == (-1)) else - }// for(std::list::iterator it = f_data.begin(); it != f_data.end(); it++) -//PrintVectorSet("build. faces", pCoordIdx); + tface.mNumIndices = static_cast(ts); + tface.mIndices = new unsigned int[ts]; + memcpy(tface.mIndices, inds.data(), ts * sizeof(unsigned int)); + pFaces.push_back(tface); + inds.clear(); + } // if(*it == (-1)) + else { + inds.push_back(*it); + } // if(*it == (-1)) else + } // for(std::list::iterator it = f_data.begin(); it != f_data.end(); it++) + //PrintVectorSet("build. faces", pCoordIdx); - pPrimitiveTypes = prim_type; + pPrimitiveTypes = prim_type; - return; + return; mg_m_err: - for(size_t i = 0, i_e = pFaces.size(); i < i_e; i++) delete [] pFaces.at(i).mIndices; + for (size_t i = 0, i_e = pFaces.size(); i < i_e; i++) + delete[] pFaces.at(i).mIndices; - pFaces.clear(); + pFaces.clear(); } -void X3DImporter::MeshGeometry_AddColor(aiMesh& pMesh, const std::list& pColors, const bool pColorPerVertex) const -{ -std::list tcol; - - // create RGBA array from RGB. - for(std::list::const_iterator it = pColors.begin(); it != pColors.end(); ++it) tcol.push_back(aiColor4D((*it).r, (*it).g, (*it).b, 1)); - - // call existing function for adding RGBA colors - MeshGeometry_AddColor(pMesh, tcol, pColorPerVertex); -} - -void X3DImporter::MeshGeometry_AddColor(aiMesh& pMesh, const std::list& pColors, const bool pColorPerVertex) const -{ - std::list::const_iterator col_it = pColors.begin(); - - if(pColorPerVertex) - { - if(pColors.size() < pMesh.mNumVertices) - { - throw DeadlyImportError("MeshGeometry_AddColor1. Colors count(" + to_string(pColors.size()) + ") can not be less than Vertices count(" + - to_string(pMesh.mNumVertices) + ")."); - } - - // copy colors to mesh - pMesh.mColors[0] = new aiColor4D[pMesh.mNumVertices]; - for(size_t i = 0; i < pMesh.mNumVertices; i++) pMesh.mColors[0][i] = *col_it++; - }// if(pColorPerVertex) - else - { - if(pColors.size() < pMesh.mNumFaces) - { - throw DeadlyImportError("MeshGeometry_AddColor1. Colors count(" + to_string(pColors.size()) + ") can not be less than Faces count(" + - to_string(pMesh.mNumFaces) + ")."); - } - - // copy colors to mesh - pMesh.mColors[0] = new aiColor4D[pMesh.mNumVertices]; - for(size_t fi = 0; fi < pMesh.mNumFaces; fi++) - { - // apply color to all vertices of face - for ( size_t vi = 0, vi_e = pMesh.mFaces[ fi ].mNumIndices; vi < vi_e; vi++ ) - { - pMesh.mColors[ 0 ][ pMesh.mFaces[ fi ].mIndices[ vi ] ] = *col_it; - } - - ++col_it; - } - }// if(pColorPerVertex) else -} - -void X3DImporter::MeshGeometry_AddColor(aiMesh& pMesh, const std::vector& pCoordIdx, const std::vector& pColorIdx, - const std::list& pColors, const bool pColorPerVertex) const -{ +void X3DImporter::MeshGeometry_AddColor(aiMesh &pMesh, const std::list &pColors, const bool pColorPerVertex) const { std::list tcol; - // create RGBA array from RGB. - for ( std::list::const_iterator it = pColors.begin(); it != pColors.end(); ++it ) - { - tcol.push_back( aiColor4D( ( *it ).r, ( *it ).g, ( *it ).b, 1 ) ); - } + // create RGBA array from RGB. + for (std::list::const_iterator it = pColors.begin(); it != pColors.end(); ++it) + tcol.push_back(aiColor4D((*it).r, (*it).g, (*it).b, 1)); - // call existing function for adding RGBA colors - MeshGeometry_AddColor(pMesh, pCoordIdx, pColorIdx, tcol, pColorPerVertex); + // call existing function for adding RGBA colors + MeshGeometry_AddColor(pMesh, tcol, pColorPerVertex); } -void X3DImporter::MeshGeometry_AddColor(aiMesh& pMesh, const std::vector& pCoordIdx, const std::vector& pColorIdx, - const std::list& pColors, const bool pColorPerVertex) const -{ +void X3DImporter::MeshGeometry_AddColor(aiMesh &pMesh, const std::list &pColors, const bool pColorPerVertex) const { + std::list::const_iterator col_it = pColors.begin(); + + if (pColorPerVertex) { + if (pColors.size() < pMesh.mNumVertices) { + throw DeadlyImportError("MeshGeometry_AddColor1. Colors count(" + to_string(pColors.size()) + ") can not be less than Vertices count(" + + to_string(pMesh.mNumVertices) + ")."); + } + + // copy colors to mesh + pMesh.mColors[0] = new aiColor4D[pMesh.mNumVertices]; + for (size_t i = 0; i < pMesh.mNumVertices; i++) + pMesh.mColors[0][i] = *col_it++; + } // if(pColorPerVertex) + else { + if (pColors.size() < pMesh.mNumFaces) { + throw DeadlyImportError("MeshGeometry_AddColor1. Colors count(" + to_string(pColors.size()) + ") can not be less than Faces count(" + + to_string(pMesh.mNumFaces) + ")."); + } + + // copy colors to mesh + pMesh.mColors[0] = new aiColor4D[pMesh.mNumVertices]; + for (size_t fi = 0; fi < pMesh.mNumFaces; fi++) { + // apply color to all vertices of face + for (size_t vi = 0, vi_e = pMesh.mFaces[fi].mNumIndices; vi < vi_e; vi++) { + pMesh.mColors[0][pMesh.mFaces[fi].mIndices[vi]] = *col_it; + } + + ++col_it; + } + } // if(pColorPerVertex) else +} + +void X3DImporter::MeshGeometry_AddColor(aiMesh &pMesh, const std::vector &pCoordIdx, const std::vector &pColorIdx, + const std::list &pColors, const bool pColorPerVertex) const { + std::list tcol; + + // create RGBA array from RGB. + for (std::list::const_iterator it = pColors.begin(); it != pColors.end(); ++it) { + tcol.push_back(aiColor4D((*it).r, (*it).g, (*it).b, 1)); + } + + // call existing function for adding RGBA colors + MeshGeometry_AddColor(pMesh, pCoordIdx, pColorIdx, tcol, pColorPerVertex); +} + +void X3DImporter::MeshGeometry_AddColor(aiMesh &pMesh, const std::vector &pCoordIdx, const std::vector &pColorIdx, + const std::list &pColors, const bool pColorPerVertex) const { std::vector col_tgt_arr; std::list col_tgt_list; std::vector col_arr_copy; - if ( pCoordIdx.size() == 0 ) - { - throw DeadlyImportError( "MeshGeometry_AddColor2. pCoordIdx can not be empty." ); + if (pCoordIdx.size() == 0) { + throw DeadlyImportError("MeshGeometry_AddColor2. pCoordIdx can not be empty."); } - // copy list to array because we are need indexed access to colors. - col_arr_copy.reserve(pColors.size()); - for ( std::list::const_iterator it = pColors.begin(); it != pColors.end(); ++it ) - { - col_arr_copy.push_back( *it ); + // copy list to array because we are need indexed access to colors. + col_arr_copy.reserve(pColors.size()); + for (std::list::const_iterator it = pColors.begin(); it != pColors.end(); ++it) { + col_arr_copy.push_back(*it); } - if(pColorPerVertex) - { - if(pColorIdx.size() > 0) - { - // check indices array count. - if(pColorIdx.size() < pCoordIdx.size()) - { - throw DeadlyImportError("MeshGeometry_AddColor2. Colors indices count(" + to_string(pColorIdx.size()) + - ") can not be less than Coords inidces count(" + to_string(pCoordIdx.size()) + ")."); - } - // create list with colors for every vertex. - col_tgt_arr.resize(pMesh.mNumVertices); - for(std::vector::const_iterator colidx_it = pColorIdx.begin(), coordidx_it = pCoordIdx.begin(); colidx_it != pColorIdx.end(); ++colidx_it, ++coordidx_it) - { - if ( *colidx_it == ( -1 ) ) - { - continue;// skip faces delimiter - } - if ( ( unsigned int ) ( *coordidx_it ) > pMesh.mNumVertices ) - { - throw DeadlyImportError( "MeshGeometry_AddColor2. Coordinate idx is out of range." ); - } - if ( ( unsigned int ) *colidx_it > pMesh.mNumVertices ) - { - throw DeadlyImportError( "MeshGeometry_AddColor2. Color idx is out of range." ); - } - - col_tgt_arr[*coordidx_it] = col_arr_copy[*colidx_it]; - } - }// if(pColorIdx.size() > 0) - else - { - // when color indices list is absent use CoordIdx. - // check indices array count. - if(pColors.size() < pMesh.mNumVertices) - { - throw DeadlyImportError("MeshGeometry_AddColor2. Colors count(" + to_string(pColors.size()) + ") can not be less than Vertices count(" + - to_string(pMesh.mNumVertices) + ")."); - } - // create list with colors for every vertex. - col_tgt_arr.resize(pMesh.mNumVertices); - for ( size_t i = 0; i < pMesh.mNumVertices; i++ ) - { - col_tgt_arr[ i ] = col_arr_copy[ i ]; + if (pColorPerVertex) { + if (pColorIdx.size() > 0) { + // check indices array count. + if (pColorIdx.size() < pCoordIdx.size()) { + throw DeadlyImportError("MeshGeometry_AddColor2. Colors indices count(" + to_string(pColorIdx.size()) + + ") can not be less than Coords inidces count(" + to_string(pCoordIdx.size()) + ")."); } - }// if(pColorIdx.size() > 0) else - }// if(pColorPerVertex) - else - { - if(pColorIdx.size() > 0) - { - // check indices array count. - if(pColorIdx.size() < pMesh.mNumFaces) - { - throw DeadlyImportError("MeshGeometry_AddColor2. Colors indices count(" + to_string(pColorIdx.size()) + - ") can not be less than Faces count(" + to_string(pMesh.mNumFaces) + ")."); - } - // create list with colors for every vertex using faces indices. - col_tgt_arr.resize(pMesh.mNumFaces); + // create list with colors for every vertex. + col_tgt_arr.resize(pMesh.mNumVertices); + for (std::vector::const_iterator colidx_it = pColorIdx.begin(), coordidx_it = pCoordIdx.begin(); colidx_it != pColorIdx.end(); ++colidx_it, ++coordidx_it) { + if (*colidx_it == (-1)) { + continue; // skip faces delimiter + } + if ((unsigned int)(*coordidx_it) > pMesh.mNumVertices) { + throw DeadlyImportError("MeshGeometry_AddColor2. Coordinate idx is out of range."); + } + if ((unsigned int)*colidx_it > pMesh.mNumVertices) { + throw DeadlyImportError("MeshGeometry_AddColor2. Color idx is out of range."); + } - std::vector::const_iterator colidx_it = pColorIdx.begin(); - for(size_t fi = 0; fi < pMesh.mNumFaces; fi++) - { - if((unsigned int)*colidx_it > pMesh.mNumFaces) throw DeadlyImportError("MeshGeometry_AddColor2. Face idx is out of range."); + col_tgt_arr[*coordidx_it] = col_arr_copy[*colidx_it]; + } + } // if(pColorIdx.size() > 0) + else { + // when color indices list is absent use CoordIdx. + // check indices array count. + if (pColors.size() < pMesh.mNumVertices) { + throw DeadlyImportError("MeshGeometry_AddColor2. Colors count(" + to_string(pColors.size()) + ") can not be less than Vertices count(" + + to_string(pMesh.mNumVertices) + ")."); + } + // create list with colors for every vertex. + col_tgt_arr.resize(pMesh.mNumVertices); + for (size_t i = 0; i < pMesh.mNumVertices; i++) { + col_tgt_arr[i] = col_arr_copy[i]; + } + } // if(pColorIdx.size() > 0) else + } // if(pColorPerVertex) + else { + if (pColorIdx.size() > 0) { + // check indices array count. + if (pColorIdx.size() < pMesh.mNumFaces) { + throw DeadlyImportError("MeshGeometry_AddColor2. Colors indices count(" + to_string(pColorIdx.size()) + + ") can not be less than Faces count(" + to_string(pMesh.mNumFaces) + ")."); + } + // create list with colors for every vertex using faces indices. + col_tgt_arr.resize(pMesh.mNumFaces); - col_tgt_arr[fi] = col_arr_copy[*colidx_it++]; - } - }// if(pColorIdx.size() > 0) - else - { - // when color indices list is absent use CoordIdx. - // check indices array count. - if(pColors.size() < pMesh.mNumFaces) - { - throw DeadlyImportError("MeshGeometry_AddColor2. Colors count(" + to_string(pColors.size()) + ") can not be less than Faces count(" + - to_string(pMesh.mNumFaces) + ")."); - } - // create list with colors for every vertex using faces indices. - col_tgt_arr.resize(pMesh.mNumFaces); - for(size_t fi = 0; fi < pMesh.mNumFaces; fi++) col_tgt_arr[fi] = col_arr_copy[fi]; + std::vector::const_iterator colidx_it = pColorIdx.begin(); + for (size_t fi = 0; fi < pMesh.mNumFaces; fi++) { + if ((unsigned int)*colidx_it > pMesh.mNumFaces) throw DeadlyImportError("MeshGeometry_AddColor2. Face idx is out of range."); - }// if(pColorIdx.size() > 0) else - }// if(pColorPerVertex) else + col_tgt_arr[fi] = col_arr_copy[*colidx_it++]; + } + } // if(pColorIdx.size() > 0) + else { + // when color indices list is absent use CoordIdx. + // check indices array count. + if (pColors.size() < pMesh.mNumFaces) { + throw DeadlyImportError("MeshGeometry_AddColor2. Colors count(" + to_string(pColors.size()) + ") can not be less than Faces count(" + + to_string(pMesh.mNumFaces) + ")."); + } + // create list with colors for every vertex using faces indices. + col_tgt_arr.resize(pMesh.mNumFaces); + for (size_t fi = 0; fi < pMesh.mNumFaces; fi++) + col_tgt_arr[fi] = col_arr_copy[fi]; - // copy array to list for calling function that add colors. - for(std::vector::const_iterator it = col_tgt_arr.begin(); it != col_tgt_arr.end(); ++it) col_tgt_list.push_back(*it); - // add prepared colors list to mesh. - MeshGeometry_AddColor(pMesh, col_tgt_list, pColorPerVertex); + } // if(pColorIdx.size() > 0) else + } // if(pColorPerVertex) else + + // copy array to list for calling function that add colors. + for (std::vector::const_iterator it = col_tgt_arr.begin(); it != col_tgt_arr.end(); ++it) + col_tgt_list.push_back(*it); + // add prepared colors list to mesh. + MeshGeometry_AddColor(pMesh, col_tgt_list, pColorPerVertex); } -void X3DImporter::MeshGeometry_AddNormal(aiMesh& pMesh, const std::vector& pCoordIdx, const std::vector& pNormalIdx, - const std::list& pNormals, const bool pNormalPerVertex) const -{ +void X3DImporter::MeshGeometry_AddNormal(aiMesh &pMesh, const std::vector &pCoordIdx, const std::vector &pNormalIdx, + const std::list &pNormals, const bool pNormalPerVertex) const { std::vector tind; std::vector norm_arr_copy; - // copy list to array because we are need indexed access to normals. - norm_arr_copy.reserve(pNormals.size()); - for ( std::list::const_iterator it = pNormals.begin(); it != pNormals.end(); ++it ) - { - norm_arr_copy.push_back( *it ); + // copy list to array because we are need indexed access to normals. + norm_arr_copy.reserve(pNormals.size()); + for (std::list::const_iterator it = pNormals.begin(); it != pNormals.end(); ++it) { + norm_arr_copy.push_back(*it); } - if(pNormalPerVertex) - { - if(pNormalIdx.size() > 0) - { - // check indices array count. - if(pNormalIdx.size() != pCoordIdx.size()) throw DeadlyImportError("Normals and Coords inidces count must be equal."); + if (pNormalPerVertex) { + if (pNormalIdx.size() > 0) { + // check indices array count. + if (pNormalIdx.size() != pCoordIdx.size()) throw DeadlyImportError("Normals and Coords inidces count must be equal."); - tind.reserve(pNormalIdx.size()); - for(std::vector::const_iterator it = pNormalIdx.begin(); it != pNormalIdx.end(); ++it) - { - if(*it != (-1)) tind.push_back(*it); - } + tind.reserve(pNormalIdx.size()); + for (std::vector::const_iterator it = pNormalIdx.begin(); it != pNormalIdx.end(); ++it) { + if (*it != (-1)) tind.push_back(*it); + } - // copy normals to mesh - pMesh.mNormals = new aiVector3D[pMesh.mNumVertices]; - for(size_t i = 0; (i < pMesh.mNumVertices) && (i < tind.size()); i++) - { - if(tind[i] >= norm_arr_copy.size()) - throw DeadlyImportError("MeshGeometry_AddNormal. Normal index(" + to_string(tind[i]) + - ") is out of range. Normals count: " + to_string(norm_arr_copy.size()) + "."); + // copy normals to mesh + pMesh.mNormals = new aiVector3D[pMesh.mNumVertices]; + for (size_t i = 0; (i < pMesh.mNumVertices) && (i < tind.size()); i++) { + if (tind[i] >= norm_arr_copy.size()) + throw DeadlyImportError("MeshGeometry_AddNormal. Normal index(" + to_string(tind[i]) + + ") is out of range. Normals count: " + to_string(norm_arr_copy.size()) + "."); - pMesh.mNormals[i] = norm_arr_copy[tind[i]]; - } - } - else - { - if(pNormals.size() != pMesh.mNumVertices) throw DeadlyImportError("MeshGeometry_AddNormal. Normals and vertices count must be equal."); + pMesh.mNormals[i] = norm_arr_copy[tind[i]]; + } + } else { + if (pNormals.size() != pMesh.mNumVertices) throw DeadlyImportError("MeshGeometry_AddNormal. Normals and vertices count must be equal."); - // copy normals to mesh - pMesh.mNormals = new aiVector3D[pMesh.mNumVertices]; - std::list::const_iterator norm_it = pNormals.begin(); - for(size_t i = 0; i < pMesh.mNumVertices; i++) pMesh.mNormals[i] = *norm_it++; - } - }// if(pNormalPerVertex) - else - { - if(pNormalIdx.size() > 0) - { - if(pMesh.mNumFaces != pNormalIdx.size()) throw DeadlyImportError("Normals faces count must be equal to mesh faces count."); + // copy normals to mesh + pMesh.mNormals = new aiVector3D[pMesh.mNumVertices]; + std::list::const_iterator norm_it = pNormals.begin(); + for (size_t i = 0; i < pMesh.mNumVertices; i++) + pMesh.mNormals[i] = *norm_it++; + } + } // if(pNormalPerVertex) + else { + if (pNormalIdx.size() > 0) { + if (pMesh.mNumFaces != pNormalIdx.size()) throw DeadlyImportError("Normals faces count must be equal to mesh faces count."); - std::vector::const_iterator normidx_it = pNormalIdx.begin(); + std::vector::const_iterator normidx_it = pNormalIdx.begin(); - tind.reserve(pNormalIdx.size()); - for(size_t i = 0, i_e = pNormalIdx.size(); i < i_e; i++) tind.push_back(*normidx_it++); + tind.reserve(pNormalIdx.size()); + for (size_t i = 0, i_e = pNormalIdx.size(); i < i_e; i++) + tind.push_back(*normidx_it++); - } - else - { - tind.reserve(pMesh.mNumFaces); - for(size_t i = 0; i < pMesh.mNumFaces; i++) tind.push_back(i); + } else { + tind.reserve(pMesh.mNumFaces); + for (size_t i = 0; i < pMesh.mNumFaces; i++) + tind.push_back(i); + } - } + // copy normals to mesh + pMesh.mNormals = new aiVector3D[pMesh.mNumVertices]; + for (size_t fi = 0; fi < pMesh.mNumFaces; fi++) { + aiVector3D tnorm; - // copy normals to mesh - pMesh.mNormals = new aiVector3D[pMesh.mNumVertices]; - for(size_t fi = 0; fi < pMesh.mNumFaces; fi++) - { - aiVector3D tnorm; - - tnorm = norm_arr_copy[tind[fi]]; - for(size_t vi = 0, vi_e = pMesh.mFaces[fi].mNumIndices; vi < vi_e; vi++) pMesh.mNormals[pMesh.mFaces[fi].mIndices[vi]] = tnorm; - } - }// if(pNormalPerVertex) else + tnorm = norm_arr_copy[tind[fi]]; + for (size_t vi = 0, vi_e = pMesh.mFaces[fi].mNumIndices; vi < vi_e; vi++) + pMesh.mNormals[pMesh.mFaces[fi].mIndices[vi]] = tnorm; + } + } // if(pNormalPerVertex) else } -void X3DImporter::MeshGeometry_AddNormal(aiMesh& pMesh, const std::list& pNormals, const bool pNormalPerVertex) const -{ +void X3DImporter::MeshGeometry_AddNormal(aiMesh &pMesh, const std::list &pNormals, const bool pNormalPerVertex) const { std::list::const_iterator norm_it = pNormals.begin(); - if(pNormalPerVertex) - { - if(pNormals.size() != pMesh.mNumVertices) throw DeadlyImportError("MeshGeometry_AddNormal. Normals and vertices count must be equal."); + if (pNormalPerVertex) { + if (pNormals.size() != pMesh.mNumVertices) throw DeadlyImportError("MeshGeometry_AddNormal. Normals and vertices count must be equal."); - // copy normals to mesh - pMesh.mNormals = new aiVector3D[pMesh.mNumVertices]; - for(size_t i = 0; i < pMesh.mNumVertices; i++) pMesh.mNormals[i] = *norm_it++; - }// if(pNormalPerVertex) - else - { - if(pNormals.size() != pMesh.mNumFaces) throw DeadlyImportError("MeshGeometry_AddNormal. Normals and faces count must be equal."); + // copy normals to mesh + pMesh.mNormals = new aiVector3D[pMesh.mNumVertices]; + for (size_t i = 0; i < pMesh.mNumVertices; i++) + pMesh.mNormals[i] = *norm_it++; + } // if(pNormalPerVertex) + else { + if (pNormals.size() != pMesh.mNumFaces) throw DeadlyImportError("MeshGeometry_AddNormal. Normals and faces count must be equal."); - // copy normals to mesh - pMesh.mNormals = new aiVector3D[pMesh.mNumVertices]; - for(size_t fi = 0; fi < pMesh.mNumFaces; fi++) - { - // apply color to all vertices of face - for(size_t vi = 0, vi_e = pMesh.mFaces[fi].mNumIndices; vi < vi_e; vi++) pMesh.mNormals[pMesh.mFaces[fi].mIndices[vi]] = *norm_it; + // copy normals to mesh + pMesh.mNormals = new aiVector3D[pMesh.mNumVertices]; + for (size_t fi = 0; fi < pMesh.mNumFaces; fi++) { + // apply color to all vertices of face + for (size_t vi = 0, vi_e = pMesh.mFaces[fi].mNumIndices; vi < vi_e; vi++) + pMesh.mNormals[pMesh.mFaces[fi].mIndices[vi]] = *norm_it; - ++norm_it; - } - }// if(pNormalPerVertex) else + ++norm_it; + } + } // if(pNormalPerVertex) else } -void X3DImporter::MeshGeometry_AddTexCoord(aiMesh& pMesh, const std::vector& pCoordIdx, const std::vector& pTexCoordIdx, - const std::list& pTexCoords) const -{ +void X3DImporter::MeshGeometry_AddTexCoord(aiMesh &pMesh, const std::vector &pCoordIdx, const std::vector &pTexCoordIdx, + const std::list &pTexCoords) const { std::vector texcoord_arr_copy; std::vector faces; unsigned int prim_type; - // copy list to array because we are need indexed access to normals. - texcoord_arr_copy.reserve(pTexCoords.size()); - for(std::list::const_iterator it = pTexCoords.begin(); it != pTexCoords.end(); ++it) - { - texcoord_arr_copy.push_back(aiVector3D((*it).x, (*it).y, 0)); - } + // copy list to array because we are need indexed access to normals. + texcoord_arr_copy.reserve(pTexCoords.size()); + for (std::list::const_iterator it = pTexCoords.begin(); it != pTexCoords.end(); ++it) { + texcoord_arr_copy.push_back(aiVector3D((*it).x, (*it).y, 0)); + } - if(pTexCoordIdx.size() > 0) - { - GeometryHelper_CoordIdxStr2FacesArr(pTexCoordIdx, faces, prim_type); - if ( faces.empty() ) - { - throw DeadlyImportError( "Failed to add texture coordinates to mesh, faces list is empty." ); + if (pTexCoordIdx.size() > 0) { + GeometryHelper_CoordIdxStr2FacesArr(pTexCoordIdx, faces, prim_type); + if (faces.empty()) { + throw DeadlyImportError("Failed to add texture coordinates to mesh, faces list is empty."); } - if ( faces.size() != pMesh.mNumFaces ) - { - throw DeadlyImportError( "Texture coordinates faces count must be equal to mesh faces count." ); + if (faces.size() != pMesh.mNumFaces) { + throw DeadlyImportError("Texture coordinates faces count must be equal to mesh faces count."); } - } - else - { - GeometryHelper_CoordIdxStr2FacesArr(pCoordIdx, faces, prim_type); - } + } else { + GeometryHelper_CoordIdxStr2FacesArr(pCoordIdx, faces, prim_type); + } - pMesh.mTextureCoords[0] = new aiVector3D[pMesh.mNumVertices]; - pMesh.mNumUVComponents[0] = 2; - for(size_t fi = 0, fi_e = faces.size(); fi < fi_e; fi++) - { - if(pMesh.mFaces[fi].mNumIndices != faces.at(fi).mNumIndices) - throw DeadlyImportError("Number of indices in texture face and mesh face must be equal. Invalid face index: " + to_string(fi) + "."); + pMesh.mTextureCoords[0] = new aiVector3D[pMesh.mNumVertices]; + pMesh.mNumUVComponents[0] = 2; + for (size_t fi = 0, fi_e = faces.size(); fi < fi_e; fi++) { + if (pMesh.mFaces[fi].mNumIndices != faces.at(fi).mNumIndices) + throw DeadlyImportError("Number of indices in texture face and mesh face must be equal. Invalid face index: " + to_string(fi) + "."); - for(size_t ii = 0; ii < pMesh.mFaces[fi].mNumIndices; ii++) - { - size_t vert_idx = pMesh.mFaces[fi].mIndices[ii]; - size_t tc_idx = faces.at(fi).mIndices[ii]; + for (size_t ii = 0; ii < pMesh.mFaces[fi].mNumIndices; ii++) { + size_t vert_idx = pMesh.mFaces[fi].mIndices[ii]; + size_t tc_idx = faces.at(fi).mIndices[ii]; - pMesh.mTextureCoords[0][vert_idx] = texcoord_arr_copy.at(tc_idx); - } - }// for(size_t fi = 0, fi_e = faces.size(); fi < fi_e; fi++) + pMesh.mTextureCoords[0][vert_idx] = texcoord_arr_copy.at(tc_idx); + } + } // for(size_t fi = 0, fi_e = faces.size(); fi < fi_e; fi++) } -void X3DImporter::MeshGeometry_AddTexCoord(aiMesh& pMesh, const std::list& pTexCoords) const -{ +void X3DImporter::MeshGeometry_AddTexCoord(aiMesh &pMesh, const std::list &pTexCoords) const { std::vector tc_arr_copy; - if ( pTexCoords.size() != pMesh.mNumVertices ) - { - throw DeadlyImportError( "MeshGeometry_AddTexCoord. Texture coordinates and vertices count must be equal." ); + if (pTexCoords.size() != pMesh.mNumVertices) { + throw DeadlyImportError("MeshGeometry_AddTexCoord. Texture coordinates and vertices count must be equal."); } - // copy list to array because we are need convert aiVector2D to aiVector3D and also get indexed access as a bonus. - tc_arr_copy.reserve(pTexCoords.size()); - for ( std::list::const_iterator it = pTexCoords.begin(); it != pTexCoords.end(); ++it ) - { - tc_arr_copy.push_back( aiVector3D( ( *it ).x, ( *it ).y, 0 ) ); + // copy list to array because we are need convert aiVector2D to aiVector3D and also get indexed access as a bonus. + tc_arr_copy.reserve(pTexCoords.size()); + for (std::list::const_iterator it = pTexCoords.begin(); it != pTexCoords.end(); ++it) { + tc_arr_copy.push_back(aiVector3D((*it).x, (*it).y, 0)); } - // copy texture coordinates to mesh - pMesh.mTextureCoords[0] = new aiVector3D[pMesh.mNumVertices]; - pMesh.mNumUVComponents[0] = 2; - for ( size_t i = 0; i < pMesh.mNumVertices; i++ ) - { - pMesh.mTextureCoords[ 0 ][ i ] = tc_arr_copy[ i ]; + // copy texture coordinates to mesh + pMesh.mTextureCoords[0] = new aiVector3D[pMesh.mNumVertices]; + pMesh.mNumUVComponents[0] = 2; + for (size_t i = 0; i < pMesh.mNumVertices; i++) { + pMesh.mTextureCoords[0][i] = tc_arr_copy[i]; } } -aiMesh* X3DImporter::GeometryHelper_MakeMesh(const std::vector& pCoordIdx, const std::list& pVertices) const -{ +aiMesh *X3DImporter::GeometryHelper_MakeMesh(const std::vector &pCoordIdx, const std::list &pVertices) const { std::vector faces; unsigned int prim_type = 0; - // create faces array from input string with vertices indices. - GeometryHelper_CoordIdxStr2FacesArr(pCoordIdx, faces, prim_type); - if ( !faces.size() ) - { - throw DeadlyImportError( "Failed to create mesh, faces list is empty." ); + // create faces array from input string with vertices indices. + GeometryHelper_CoordIdxStr2FacesArr(pCoordIdx, faces, prim_type); + if (!faces.size()) { + throw DeadlyImportError("Failed to create mesh, faces list is empty."); } - // - // Create new mesh and copy geometry data. - // + // + // Create new mesh and copy geometry data. + // aiMesh *tmesh = new aiMesh; size_t ts = faces.size(); - // faces - tmesh->mFaces = new aiFace[ts]; - tmesh->mNumFaces = static_cast(ts); - for(size_t i = 0; i < ts; i++) tmesh->mFaces[i] = faces.at(i); + // faces + tmesh->mFaces = new aiFace[ts]; + tmesh->mNumFaces = static_cast(ts); + for (size_t i = 0; i < ts; i++) + tmesh->mFaces[i] = faces.at(i); - // vertices - std::list::const_iterator vit = pVertices.begin(); + // vertices + std::list::const_iterator vit = pVertices.begin(); - ts = pVertices.size(); - tmesh->mVertices = new aiVector3D[ts]; - tmesh->mNumVertices = static_cast(ts); - for ( size_t i = 0; i < ts; i++ ) - { - tmesh->mVertices[ i ] = *vit++; + ts = pVertices.size(); + tmesh->mVertices = new aiVector3D[ts]; + tmesh->mNumVertices = static_cast(ts); + for (size_t i = 0; i < ts; i++) { + tmesh->mVertices[i] = *vit++; } - // set primitives type and return result. - tmesh->mPrimitiveTypes = prim_type; + // set primitives type and return result. + tmesh->mPrimitiveTypes = prim_type; - return tmesh; + return tmesh; } /*********************************************************************************************************************************************/ /************************************************************ Functions: parse set ***********************************************************/ /*********************************************************************************************************************************************/ -void X3DImporter::ParseHelper_Group_Begin(const bool pStatic) -{ - CX3DImporter_NodeElement_Group* new_group = new CX3DImporter_NodeElement_Group(NodeElement_Cur, pStatic);// create new node with current node as parent. +void X3DImporter::ParseHelper_Group_Begin(const bool pStatic) { + X3DGroup *new_group = new X3DGroup(mNodeElementCur, pStatic); // create new node with current node as parent. - // if we are adding not the root element then add new element to current element child list. - if ( NodeElement_Cur != nullptr ) - { - NodeElement_Cur->Child.push_back( new_group ); + // if we are adding not the root element then add new element to current element child list. + if (mNodeElementCur != nullptr) { + mNodeElementCur->Child.push_back(new_group); } - NodeElement_List.push_back(new_group);// it's a new element - add it to list. - NodeElement_Cur = new_group;// switch current element to new one. + NodeElement_List.push_back(new_group); // it's a new element - add it to list. + mNodeElementCur = new_group; // switch current element to new one. } -void X3DImporter::ParseHelper_Node_Enter(CX3DImporter_NodeElement* pNode) -{ - NodeElement_Cur->Child.push_back(pNode);// add new element to current element child list. - NodeElement_Cur = pNode;// switch current element to new one. +void X3DImporter::ParseHelper_Node_Enter(X3DNodeElementBase *pNode) { + mNodeElementCur->Child.push_back(pNode); // add new element to current element child list. + mNodeElementCur = pNode; // switch current element to new one. } -void X3DImporter::ParseHelper_Node_Exit() -{ - // check if we can walk up. - if ( NodeElement_Cur != nullptr ) - { - NodeElement_Cur = NodeElement_Cur->Parent; +void X3DImporter::ParseHelper_Node_Exit() { + // check if we can walk up. + if (mNodeElementCur != nullptr) { + mNodeElementCur = mNodeElementCur->Parent; } } -void X3DImporter::ParseHelper_FixTruncatedFloatString(const char* pInStr, std::string& pOutString) -{ - pOutString.clear(); +void X3DImporter::ParseHelper_FixTruncatedFloatString(const char *pInStr, std::string &pOutString) { + pOutString.clear(); const size_t instr_len = strlen(pInStr); - if ( 0 == instr_len ) - { + if (0 == instr_len) { return; } - pOutString.reserve(instr_len * 3 / 2); - // check and correct floats in format ".x". Must be "x.y". - if ( pInStr[ 0 ] == '.' ) - { - pOutString.push_back( '0' ); + pOutString.reserve(instr_len * 3 / 2); + // check and correct floats in format ".x". Must be "x.y". + if (pInStr[0] == '.') { + pOutString.push_back('0'); } - pOutString.push_back(pInStr[0]); - for(size_t ci = 1; ci < instr_len; ci++) - { - if((pInStr[ci] == '.') && ((pInStr[ci - 1] == ' ') || (pInStr[ci - 1] == '-') || (pInStr[ci - 1] == '+') || (pInStr[ci - 1] == '\t'))) - { - pOutString.push_back('0'); - pOutString.push_back('.'); - } - else - { - pOutString.push_back(pInStr[ci]); - } - } + pOutString.push_back(pInStr[0]); + for (size_t ci = 1; ci < instr_len; ci++) { + if ((pInStr[ci] == '.') && ((pInStr[ci - 1] == ' ') || (pInStr[ci - 1] == '-') || (pInStr[ci - 1] == '+') || (pInStr[ci - 1] == '\t'))) { + pOutString.push_back('0'); + pOutString.push_back('.'); + } else { + pOutString.push_back(pInStr[ci]); + } + } } extern FIVocabulary X3D_vocabulary_3_2; extern FIVocabulary X3D_vocabulary_3_3; -void X3DImporter::ParseFile(const std::string& pFile, IOSystem* pIOHandler) -{ - std::unique_ptr OldReader = std::move(mReader);// store current XMLreader. +void X3DImporter::ParseFile(const std::string &pFile, IOSystem *pIOHandler) { + //std::unique_ptr OldReader = std::move(mReader); // store current XMLreader. std::unique_ptr file(pIOHandler->Open(pFile, "rb")); - // Check whether we can read from the file - if ( file.get() == nullptr ) - { - throw DeadlyImportError( "Failed to open X3D file " + pFile + "." ); + // Check whether we can read from the file + if (file.get() == nullptr) { + throw DeadlyImportError("Failed to open X3D file " + pFile + "."); } - mReader = FIReader::create(file.get()); - if ( !mReader ) - { - throw DeadlyImportError( "Failed to create XML reader for file" + pFile + "." ); + mReader = FIReader::create(file.get()); + if (!mReader) { + throw DeadlyImportError("Failed to create XML reader for file" + pFile + "."); } mReader->registerVocabulary("urn:web3d:x3d:fi-vocabulary-3.2", &X3D_vocabulary_3_2); mReader->registerVocabulary("urn:web3d:x3d:fi-vocabulary-3.3", &X3D_vocabulary_3_3); - // start reading - ParseNode_Root(); + // start reading + ParseNode_Root(); - // restore old XMLreader - mReader = std::move(OldReader); + // restore old XMLreader + mReader = std::move(OldReader); } -void X3DImporter::ParseNode_Root() -{ - // search for root tag - if ( !XML_SearchNode( "X3D" ) ) - { - throw DeadlyImportError( "Root node \"X3D\" not found." ); +void X3DImporter::ParseNode_Root() { + // search for root tag + if (!XML_SearchNode("X3D")) { + throw DeadlyImportError("Root node \"X3D\" not found."); } - ParseHelper_Group_Begin();// create root node element. - // parse other contents - while(mReader->read()) - { - if ( mReader->getNodeType() != irr::io::EXN_ELEMENT ) - { + ParseHelper_Group_Begin(); // create root node element. + // parse other contents + while (mReader->read()) { + if (mReader->getNodeType() != irr::io::EXN_ELEMENT) { continue; } - if(XML_CheckNode_NameEqual("head")) - ParseNode_Head(); - else if(XML_CheckNode_NameEqual("Scene")) - ParseNode_Scene(); - else - XML_CheckNode_SkipUnsupported("Root"); - } + if (XML_CheckNode_NameEqual("head")) + ParseNode_Head(); + else if (XML_CheckNode_NameEqual("Scene")) + ParseNode_Scene(); + else + XML_CheckNode_SkipUnsupported("Root"); + } - // exit from root node element. - ParseHelper_Node_Exit(); + // exit from root node element. + ParseHelper_Node_Exit(); } -void X3DImporter::ParseNode_Head() -{ - bool close_found = false;// flag: true if close tag of node are found. +void X3DImporter::ParseNode_Head() { + bool close_found = false; // flag: true if close tag of node are found. - while(mReader->read()) - { - if(mReader->getNodeType() == irr::io::EXN_ELEMENT) - { - if(XML_CheckNode_NameEqual("meta")) - { - XML_CheckNode_MustBeEmpty(); + while (mReader->read()) { + if (mReader->getNodeType() == irr::io::EXN_ELEMENT) { + if (XML_CheckNode_NameEqual("meta")) { + XML_CheckNode_MustBeEmpty(); - // adding metadata from as MetaString from - bool added( false ); - CX3DImporter_NodeElement_MetaString* ms = new CX3DImporter_NodeElement_MetaString(NodeElement_Cur); + // adding metadata from as MetaString from + bool added(false); + X3DMetaString *ms = new X3DMetaString(mNodeElementCur); - ms->Name = mReader->getAttributeValueSafe("name"); - // name must not be empty - if(!ms->Name.empty()) - { - ms->Value.push_back(mReader->getAttributeValueSafe("content")); - NodeElement_List.push_back(ms); - if ( NodeElement_Cur != nullptr ) - { - NodeElement_Cur->Child.push_back( ms ); + ms->Name = mReader->getAttributeValueSafe("name"); + // name must not be empty + if (!ms->Name.empty()) { + ms->Value.push_back(mReader->getAttributeValueSafe("content")); + NodeElement_List.push_back(ms); + if (mNodeElementCur != nullptr) { + mNodeElementCur->Child.push_back(ms); added = true; } - } + } // if an error has occurred, release instance - if ( !added ) { + if (!added) { delete ms; } - }// if(XML_CheckNode_NameEqual("meta")) - }// if(mReader->getNodeType() == irr::io::EXN_ELEMENT) - else if(mReader->getNodeType() == irr::io::EXN_ELEMENT_END) - { - if(XML_CheckNode_NameEqual("head")) - { - close_found = true; - break; - } - }// if(mReader->getNodeType() == irr::io::EXN_ELEMENT) else - }// while(mReader->read()) + } // if(XML_CheckNode_NameEqual("meta")) + } // if(mReader->getNodeType() == irr::io::EXN_ELEMENT) + else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { + if (XML_CheckNode_NameEqual("head")) { + close_found = true; + break; + } + } // if(mReader->getNodeType() == irr::io::EXN_ELEMENT) else + } // while(mReader->read()) - if ( !close_found ) - { - Throw_CloseNotFound( "head" ); + if (!close_found) { + Throw_CloseNotFound("head"); } } -void X3DImporter::ParseNode_Scene() -{ - auto GroupCounter_Increase = [](size_t& pCounter, const char* pGroupName) -> void - { - pCounter++; - if(pCounter == 0) throw DeadlyImportError("Group counter overflow. Too much groups with type: " + std::string(pGroupName) + "."); -}; +void X3DImporter::ParseNode_Scene() { + auto GroupCounter_Increase = [](size_t &pCounter, const char *pGroupName) -> void { + pCounter++; + if (pCounter == 0) throw DeadlyImportError("Group counter overflow. Too much groups with type: " + std::string(pGroupName) + "."); + }; -auto GroupCounter_Decrease = [&](size_t& pCounter, const char* pGroupName) -> void -{ - if(pCounter == 0) Throw_TagCountIncorrect(pGroupName); + auto GroupCounter_Decrease = [&](size_t &pCounter, const char *pGroupName) -> void { + if (pCounter == 0) Throw_TagCountIncorrect(pGroupName); - pCounter--; -}; + pCounter--; + }; -static const char* GroupName_Group = "Group"; -static const char* GroupName_StaticGroup = "StaticGroup"; -static const char* GroupName_Transform = "Transform"; -static const char* GroupName_Switch = "Switch"; + static const char *GroupName_Group = "Group"; + static const char *GroupName_StaticGroup = "StaticGroup"; + static const char *GroupName_Transform = "Transform"; + static const char *GroupName_Switch = "Switch"; -bool close_found = false; -size_t counter_group = 0; -size_t counter_transform = 0; -size_t counter_switch = 0; + bool close_found = false; + size_t counter_group = 0; + size_t counter_transform = 0; + size_t counter_switch = 0; - // while create static node? Because objects name used deeper in "USE" attribute can be equal to some meta in node. - ParseHelper_Group_Begin(true); - while(mReader->read()) - { - if(mReader->getNodeType() == irr::io::EXN_ELEMENT) - { - if(XML_CheckNode_NameEqual("Shape")) - { - ParseNode_Shape_Shape(); - } - else if(XML_CheckNode_NameEqual(GroupName_Group)) - { - GroupCounter_Increase(counter_group, GroupName_Group); - ParseNode_Grouping_Group(); - // if node is empty then decrease group counter at this place. - if(mReader->isEmptyElement()) GroupCounter_Decrease(counter_group, GroupName_Group); - } - else if(XML_CheckNode_NameEqual(GroupName_StaticGroup)) - { - GroupCounter_Increase(counter_group, GroupName_StaticGroup); - ParseNode_Grouping_StaticGroup(); - // if node is empty then decrease group counter at this place. - if(mReader->isEmptyElement()) GroupCounter_Decrease(counter_group, GroupName_StaticGroup); - } - else if(XML_CheckNode_NameEqual(GroupName_Transform)) - { - GroupCounter_Increase(counter_transform, GroupName_Transform); - ParseNode_Grouping_Transform(); - // if node is empty then decrease group counter at this place. - if(mReader->isEmptyElement()) GroupCounter_Decrease(counter_transform, GroupName_Transform); - } - else if(XML_CheckNode_NameEqual(GroupName_Switch)) - { - GroupCounter_Increase(counter_switch, GroupName_Switch); - ParseNode_Grouping_Switch(); - // if node is empty then decrease group counter at this place. - if(mReader->isEmptyElement()) GroupCounter_Decrease(counter_switch, GroupName_Switch); - } - else if(XML_CheckNode_NameEqual("DirectionalLight")) - { - ParseNode_Lighting_DirectionalLight(); - } - else if(XML_CheckNode_NameEqual("PointLight")) - { - ParseNode_Lighting_PointLight(); - } - else if(XML_CheckNode_NameEqual("SpotLight")) - { - ParseNode_Lighting_SpotLight(); - } - else if(XML_CheckNode_NameEqual("Inline")) - { - ParseNode_Networking_Inline(); - } - else if(!ParseHelper_CheckRead_X3DMetadataObject()) - { - XML_CheckNode_SkipUnsupported("Scene"); - } - }// if(mReader->getNodeType() == irr::io::EXN_ELEMENT) - else if(mReader->getNodeType() == irr::io::EXN_ELEMENT_END) - { - if(XML_CheckNode_NameEqual("Scene")) - { - close_found = true; + // while create static node? Because objects name used deeper in "USE" attribute can be equal to some meta in node. + ParseHelper_Group_Begin(true); + while (mReader->read()) { + if (mReader->getNodeType() == irr::io::EXN_ELEMENT) { + if (XML_CheckNode_NameEqual("Shape")) { + ParseNode_Shape_Shape(); + } else if (XML_CheckNode_NameEqual(GroupName_Group)) { + GroupCounter_Increase(counter_group, GroupName_Group); + ParseNode_Grouping_Group(); + // if node is empty then decrease group counter at this place. + if (mReader->isEmptyElement()) GroupCounter_Decrease(counter_group, GroupName_Group); + } else if (XML_CheckNode_NameEqual(GroupName_StaticGroup)) { + GroupCounter_Increase(counter_group, GroupName_StaticGroup); + ParseNode_Grouping_StaticGroup(); + // if node is empty then decrease group counter at this place. + if (mReader->isEmptyElement()) GroupCounter_Decrease(counter_group, GroupName_StaticGroup); + } else if (XML_CheckNode_NameEqual(GroupName_Transform)) { + GroupCounter_Increase(counter_transform, GroupName_Transform); + ParseNode_Grouping_Transform(); + // if node is empty then decrease group counter at this place. + if (mReader->isEmptyElement()) GroupCounter_Decrease(counter_transform, GroupName_Transform); + } else if (XML_CheckNode_NameEqual(GroupName_Switch)) { + GroupCounter_Increase(counter_switch, GroupName_Switch); + ParseNode_Grouping_Switch(); + // if node is empty then decrease group counter at this place. + if (mReader->isEmptyElement()) GroupCounter_Decrease(counter_switch, GroupName_Switch); + } else if (XML_CheckNode_NameEqual("DirectionalLight")) { + ParseNode_Lighting_DirectionalLight(); + } else if (XML_CheckNode_NameEqual("PointLight")) { + ParseNode_Lighting_PointLight(); + } else if (XML_CheckNode_NameEqual("SpotLight")) { + ParseNode_Lighting_SpotLight(); + } else if (XML_CheckNode_NameEqual("Inline")) { + ParseNode_Networking_Inline(); + } else if (!ParseHelper_CheckRead_X3DMetadataObject()) { + XML_CheckNode_SkipUnsupported("Scene"); + } + } // if(mReader->getNodeType() == irr::io::EXN_ELEMENT) + else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { + if (XML_CheckNode_NameEqual("Scene")) { + close_found = true; - break; - } - else if(XML_CheckNode_NameEqual(GroupName_Group)) - { - GroupCounter_Decrease(counter_group, GroupName_Group); - ParseNode_Grouping_GroupEnd(); - } - else if(XML_CheckNode_NameEqual(GroupName_StaticGroup)) - { - GroupCounter_Decrease(counter_group, GroupName_StaticGroup); - ParseNode_Grouping_StaticGroupEnd(); - } - else if(XML_CheckNode_NameEqual(GroupName_Transform)) - { - GroupCounter_Decrease(counter_transform, GroupName_Transform); - ParseNode_Grouping_TransformEnd(); - } - else if(XML_CheckNode_NameEqual(GroupName_Switch)) - { - GroupCounter_Decrease(counter_switch, GroupName_Switch); - ParseNode_Grouping_SwitchEnd(); - } - }// if(mReader->getNodeType() == irr::io::EXN_ELEMENT) else - }// while(mReader->read()) + break; + } else if (XML_CheckNode_NameEqual(GroupName_Group)) { + GroupCounter_Decrease(counter_group, GroupName_Group); + ParseNode_Grouping_GroupEnd(); + } else if (XML_CheckNode_NameEqual(GroupName_StaticGroup)) { + GroupCounter_Decrease(counter_group, GroupName_StaticGroup); + ParseNode_Grouping_StaticGroupEnd(); + } else if (XML_CheckNode_NameEqual(GroupName_Transform)) { + GroupCounter_Decrease(counter_transform, GroupName_Transform); + ParseNode_Grouping_TransformEnd(); + } else if (XML_CheckNode_NameEqual(GroupName_Switch)) { + GroupCounter_Decrease(counter_switch, GroupName_Switch); + ParseNode_Grouping_SwitchEnd(); + } + } // if(mReader->getNodeType() == irr::io::EXN_ELEMENT) else + } // while(mReader->read()) - ParseHelper_Node_Exit(); - - if(counter_group) Throw_TagCountIncorrect("Group"); - if(counter_transform) Throw_TagCountIncorrect("Transform"); - if(counter_switch) Throw_TagCountIncorrect("Switch"); - if(!close_found) Throw_CloseNotFound("Scene"); + ParseHelper_Node_Exit(); + if (counter_group) Throw_TagCountIncorrect("Group"); + if (counter_transform) Throw_TagCountIncorrect("Transform"); + if (counter_switch) Throw_TagCountIncorrect("Switch"); + if (!close_found) Throw_CloseNotFound("Scene"); } /*********************************************************************************************************************************************/ /******************************************************** Functions: BaseImporter set ********************************************************/ /*********************************************************************************************************************************************/ -bool X3DImporter::CanRead(const std::string& pFile, IOSystem* pIOHandler, bool pCheckSig) const -{ +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" }; + if (!extension.length() || pCheckSig) { + const char *tokens[] = { "DOCTYPE X3D PUBLIC", "http://www.web3d.org/specifications/x3d" }; - return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 2); - } + return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 2); + } - return false; + return false; } -void X3DImporter::GetExtensionList(std::set& pExtensionList) -{ - pExtensionList.insert("x3d"); - pExtensionList.insert("x3db"); +void X3DImporter::GetExtensionList(std::set &pExtensionList) { + pExtensionList.insert("x3d"); + pExtensionList.insert("x3db"); } -const aiImporterDesc* X3DImporter::GetInfo () const -{ - return &Description; +const aiImporterDesc *X3DImporter::GetInfo() const { + return &Description; } -void X3DImporter::InternReadFile(const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler) -{ - mpIOHandler = pIOHandler; +void X3DImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) { + mpIOHandler = pIOHandler; - Clear();// delete old graph. - std::string::size_type slashPos = pFile.find_last_of("\\/"); - pIOHandler->PushDirectory(slashPos == std::string::npos ? std::string() : pFile.substr(0, slashPos + 1)); - ParseFile(pFile, pIOHandler); - pIOHandler->PopDirectory(); - // - // Assimp use static arrays of objects for fast speed of rendering. That's good, but need some additional operations/ - // We know that geometry objects(meshes) are stored in , also in -> materials(in Assimp logical view) - // are stored. So at first we need to count how meshes and materials are stored in scene graph. - // - // at first creating root node for aiScene. - pScene->mRootNode = new aiNode; - pScene->mRootNode->mParent = nullptr; - pScene->mFlags |= AI_SCENE_FLAGS_ALLOW_SHARED; - //search for root node element - NodeElement_Cur = NodeElement_List.front(); - while(NodeElement_Cur->Parent != nullptr) NodeElement_Cur = NodeElement_Cur->Parent; + Clear(); // delete old graph. + std::string::size_type slashPos = pFile.find_last_of("\\/"); + pIOHandler->PushDirectory(slashPos == std::string::npos ? std::string() : pFile.substr(0, slashPos + 1)); + ParseFile(pFile, pIOHandler); + pIOHandler->PopDirectory(); + // + // Assimp use static arrays of objects for fast speed of rendering. That's good, but need some additional operations/ + // We know that geometry objects(meshes) are stored in , also in -> materials(in Assimp logical view) + // are stored. So at first we need to count how meshes and materials are stored in scene graph. + // + // at first creating root node for aiScene. + pScene->mRootNode = new aiNode; + pScene->mRootNode->mParent = nullptr; + pScene->mFlags |= AI_SCENE_FLAGS_ALLOW_SHARED; + //search for root node element + mNodeElementCur = NodeElement_List.front(); + while (mNodeElementCur->Parent != nullptr) + mNodeElementCur = mNodeElementCur->Parent; - {// fill aiScene with objects. - std::list mesh_list; - std::list mat_list; - std::list light_list; + { // fill aiScene with objects. + std::list mesh_list; + std::list mat_list; + std::list light_list; - // create nodes tree - Postprocess_BuildNode(*NodeElement_Cur, *pScene->mRootNode, mesh_list, mat_list, light_list); - // copy needed data to scene - if(!mesh_list.empty()) - { - std::list::const_iterator it = mesh_list.begin(); + // create nodes tree + Postprocess_BuildNode(*mNodeElementCur, *pScene->mRootNode, mesh_list, mat_list, light_list); + // copy needed data to scene + if (!mesh_list.empty()) { + std::list::const_iterator it = mesh_list.begin(); - pScene->mNumMeshes = static_cast(mesh_list.size()); - pScene->mMeshes = new aiMesh*[pScene->mNumMeshes]; - for(size_t i = 0; i < pScene->mNumMeshes; i++) pScene->mMeshes[i] = *it++; - } + pScene->mNumMeshes = static_cast(mesh_list.size()); + pScene->mMeshes = new aiMesh *[pScene->mNumMeshes]; + for (size_t i = 0; i < pScene->mNumMeshes; i++) + pScene->mMeshes[i] = *it++; + } - if(!mat_list.empty()) - { - std::list::const_iterator it = mat_list.begin(); + if (!mat_list.empty()) { + std::list::const_iterator it = mat_list.begin(); - pScene->mNumMaterials = static_cast(mat_list.size()); - pScene->mMaterials = new aiMaterial*[pScene->mNumMaterials]; - for(size_t i = 0; i < pScene->mNumMaterials; i++) pScene->mMaterials[i] = *it++; - } + pScene->mNumMaterials = static_cast(mat_list.size()); + pScene->mMaterials = new aiMaterial *[pScene->mNumMaterials]; + for (size_t i = 0; i < pScene->mNumMaterials; i++) + pScene->mMaterials[i] = *it++; + } - if(!light_list.empty()) - { - std::list::const_iterator it = light_list.begin(); + if (!light_list.empty()) { + std::list::const_iterator it = light_list.begin(); - pScene->mNumLights = static_cast(light_list.size()); - pScene->mLights = new aiLight*[pScene->mNumLights]; - for(size_t i = 0; i < pScene->mNumLights; i++) pScene->mLights[i] = *it++; - } - }// END: fill aiScene with objects. + pScene->mNumLights = static_cast(light_list.size()); + pScene->mLights = new aiLight *[pScene->mNumLights]; + for (size_t i = 0; i < pScene->mNumLights; i++) + pScene->mLights[i] = *it++; + } + } // END: fill aiScene with objects. - ///TODO: IME optimize tree + ///TODO: IME optimize tree } -}// namespace Assimp +} // namespace Assimp #endif // !ASSIMP_BUILD_NO_X3D_IMPORTER diff --git a/code/AssetLib/X3D/X3DImporter.hpp b/code/AssetLib/X3D/X3DImporter.hpp index 66c967a61..e4401f27d 100644 --- a/code/AssetLib/X3D/X3DImporter.hpp +++ b/code/AssetLib/X3D/X3DImporter.hpp @@ -194,7 +194,7 @@ namespace Assimp { class X3DImporter : public BaseImporter { public: - std::list NodeElement_List;///< All elements of scene graph. + std::list NodeElement_List;///< All elements of scene graph. public: /***********************************************/ @@ -246,7 +246,7 @@ private: /// \param [in] pType - type of requested element. /// \param [out] pElement - pointer to pointer to item found. /// \return true - if the element is found, else - false. - bool FindNodeElement_FromRoot(const std::string& pID, const CX3DImporter_NodeElement::EType pType, CX3DImporter_NodeElement** pElement); + bool FindNodeElement_FromRoot(const std::string& pID, const X3DNodeElementBase::EType pType, X3DNodeElementBase** pElement); /// Find requested node element. Search will be made from pointed node down to childs. /// \param [in] pStartNode - pointer to start node. @@ -254,15 +254,15 @@ private: /// \param [in] pType - type of requested element. /// \param [out] pElement - pointer to pointer to item found. /// \return true - if the element is found, else - false. - bool FindNodeElement_FromNode(CX3DImporter_NodeElement* pStartNode, const std::string& pID, const CX3DImporter_NodeElement::EType pType, - CX3DImporter_NodeElement** pElement); + bool FindNodeElement_FromNode(X3DNodeElementBase* pStartNode, const std::string& pID, const X3DNodeElementBase::EType pType, + X3DNodeElementBase** pElement); /// Find requested node element. For "Node"'s accounting flag "Static". /// \param [in] pName - name of requested element. /// \param [in] pType - type of requested element. /// \param [out] pElement - pointer to pointer to item found. /// \return true - if the element is found, else - false. - bool FindNodeElement(const std::string& pName, const CX3DImporter_NodeElement::EType pType, CX3DImporter_NodeElement** pElement); + bool FindNodeElement(const std::string& pName, const X3DNodeElementBase::EType pType, X3DNodeElementBase** pElement); /***********************************************/ /********* Functions: postprocess set **********/ @@ -274,34 +274,34 @@ private: /// Check if child elements of node element is metadata and add it to temporary list. /// \param [in] pNodeElement - node element where metadata is searching. /// \param [out] pList - temporary list for collected metadata. - void PostprocessHelper_CollectMetadata(const CX3DImporter_NodeElement& pNodeElement, std::list& pList) const; + void PostprocessHelper_CollectMetadata(const X3DNodeElementBase& pNodeElement, std::list& pList) const; /// Check if type of node element is metadata. E.g. , . /// \param [in] pType - checked type. /// \return true - if the type corresponds to the metadata. - bool PostprocessHelper_ElementIsMetadata(const CX3DImporter_NodeElement::EType pType) const; + bool PostprocessHelper_ElementIsMetadata(const X3DNodeElementBase::EType pType) const; /// Check if type of node element is geometry object and can be used to build mesh. E.g. , . /// \param [in] pType - checked type. /// \return true - if the type corresponds to the mesh. - bool PostprocessHelper_ElementIsMesh(const CX3DImporter_NodeElement::EType pType) const; + bool PostprocessHelper_ElementIsMesh(const X3DNodeElementBase::EType pType) const; /// Read CX3DImporter_NodeElement_Light, create aiLight and add it to list of the lights. /// \param [in] pNodeElement - reference to lisght element(, , ). /// \param [out] pSceneLightList - reference to list of the lights. - void Postprocess_BuildLight(const CX3DImporter_NodeElement& pNodeElement, std::list& pSceneLightList) const; + void Postprocess_BuildLight(const X3DNodeElementBase& pNodeElement, std::list& pSceneLightList) const; /// Create filled structure with type \ref aiMaterial from \ref CX3DImporter_NodeElement. This function itseld extract /// all needed data from scene graph. /// \param [in] pNodeElement - reference to material element(). /// \param [out] pMaterial - pointer to pointer to created material. *pMaterial must be nullptr. - void Postprocess_BuildMaterial(const CX3DImporter_NodeElement& pNodeElement, aiMaterial** pMaterial) const; + void Postprocess_BuildMaterial(const X3DNodeElementBase& pNodeElement, aiMaterial** pMaterial) const; /// Create filled structure with type \ref aiMaterial from \ref CX3DImporter_NodeElement. This function itseld extract /// all needed data from scene graph. /// \param [in] pNodeElement - reference to geometry object. /// \param [out] pMesh - pointer to pointer to created mesh. *pMesh must be nullptr. - void Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeElement, aiMesh** pMesh) const; + void Postprocess_BuildMesh(const X3DNodeElementBase& pNodeElement, aiMesh** pMesh) const; /// Create aiNode from CX3DImporter_NodeElement. Also function check children and make recursive call. /// \param [out] pNode - pointer to pointer to created node. *pNode must be nullptr. @@ -310,7 +310,7 @@ private: /// \param [out] pSceneMeshList - list with aiMesh which belong to scene. /// \param [out] pSceneMaterialList - list with aiMaterial which belong to scene. /// \param [out] pSceneLightList - list with aiLight which belong to scene. - void Postprocess_BuildNode(const CX3DImporter_NodeElement& pNodeElement, aiNode& pSceneNode, std::list& pSceneMeshList, + void Postprocess_BuildNode(const X3DNodeElementBase& pNodeElement, aiNode& pSceneNode, std::list& pSceneMeshList, std::list& pSceneMaterialList, std::list& pSceneLightList) const; /// To create mesh and material kept in . @@ -318,85 +318,13 @@ private: /// \param pNodeMeshInd - reference to list with mesh indices. When pShapeNodeElement will read new mesh index will be added to this list. /// \param pSceneMeshList - reference to list with meshes. When pShapeNodeElement will read new mesh will be added to this list. /// \param pSceneMaterialList - reference to list with materials. When pShapeNodeElement will read new material will be added to this list. - void Postprocess_BuildShape(const CX3DImporter_NodeElement_Shape& pShapeNodeElement, std::list& pNodeMeshInd, + void Postprocess_BuildShape(const X3DShape& pShapeNodeElement, std::list& pNodeMeshInd, std::list& pSceneMeshList, std::list& pSceneMaterialList) const; /// Check if child elements of node element is metadata and add it to scene node. /// \param [in] pNodeElement - node element where metadata is searching. /// \param [out] pSceneNode - scene node in which metadata will be added. - void Postprocess_CollectMetadata(const CX3DImporter_NodeElement& pNodeElement, aiNode& pSceneNode) const; - - /***********************************************/ - /************* Functions: throw set ************/ - /***********************************************/ - - /// Call that function when argument is out of range and exception must be raised. - /// \throw DeadlyImportError. - /// \param [in] pArgument - argument name. - void Throw_ArgOutOfRange(const std::string& pArgument); - - /// Call that function when close tag of node not found and exception must be raised. - /// E.g.: - /// - /// - /// - /// \throw DeadlyImportError. - /// \param [in] pNode - node name in which exception happened. - void Throw_CloseNotFound(const std::string& pNode); - - /// Call that function when string value can not be converted to floating point value and exception must be raised. - /// \param [in] pAttrValue - attribute value. - /// \throw DeadlyImportError. - void Throw_ConvertFail_Str2ArrF(const std::string& pAttrValue); - - /// Call that function when in node defined attributes "DEF" and "USE" and exception must be raised. - /// E.g.: - /// \throw DeadlyImportError. - void Throw_DEF_And_USE(); - - /// Call that function when attribute name is incorrect and exception must be raised. - /// \param [in] pAttrName - attribute name. - /// \throw DeadlyImportError. - void Throw_IncorrectAttr(const std::string& pAttrName); - - /// Call that function when attribute value is incorrect and exception must be raised. - /// \param [in] pAttrName - attribute name. - /// \throw DeadlyImportError. - void Throw_IncorrectAttrValue(const std::string& pAttrName); - - /// Call that function when some type of nodes are defined twice or more when must be used only once and exception must be raised. - /// E.g.: - /// - /// - /// - /// - /// \throw DeadlyImportError. - /// \param [in] pNodeType - type of node which defined one more time. - /// \param [in] pDescription - message about error. E.g. what the node defined while exception raised. - void Throw_MoreThanOnceDefined(const std::string& pNodeType, const std::string& pDescription); - - /// Call that function when count of opening and closing tags which create group(e.g. ) are not equal and exception must be raised. - /// E.g.: - /// - /// - /// - /// - /// - /// \throw DeadlyImportError. - /// \param [in] pNode - node name in which exception happened. - void Throw_TagCountIncorrect(const std::string& pNode); - - /// Call that function when defined in "USE" element are not found in graph and exception must be raised. - /// \param [in] pAttrValue - "USE" attribute value. - /// \throw DeadlyImportError. - void Throw_USE_NotFound(const std::string& pAttrValue); - - /***********************************************/ - /************** Functions: LOG set *************/ - /***********************************************/ - - /// Short variant for calling \ref DefaultLogger::get()->info() - void LogInfo(const std::string& pMessage) { DefaultLogger::get()->info(pMessage); } + void Postprocess_CollectMetadata(const X3DNodeElementBase& pNodeElement, aiNode& pSceneNode) const; /***********************************************/ /************** Functions: XML set *************/ @@ -408,7 +336,7 @@ private: /// Check if current node name is equal to pNodeName. /// \param [in] pNodeName - name for checking. /// return true if current node name is equal to pNodeName, else - false. - bool XML_CheckNode_NameEqual(const std::string& pNodeName) { return mReader->getNodeName() == pNodeName; } + //bool XML_CheckNode_NameEqual(const std::string& pNodeName) { return mReader->getNodeName() == pNodeName; } /// Skip unsupported node and report about that. Depend on node name can be skipped begin tag of node all whole node. /// \param [in] pParentNodeName - parent node name. Used for reporting. @@ -612,7 +540,7 @@ private: /// Make pNode as current and enter deeper for parsing child nodes. At end \ref ParseHelper_Node_Exit must be called. /// \param [in] pNode - new current node. - void ParseHelper_Node_Enter(CX3DImporter_NodeElement* pNode); + void ParseHelper_Node_Enter(X3DNodeElementBase* pNode); /// This function must be called when exiting from X3D group node(e.g. ). \ref ParseHelper_Group_Begin. void ParseHelper_Node_Exit(); @@ -649,7 +577,7 @@ private: /// \param [in] pNodeName - parsed node name. Must be set because that function is general and name needed for checking the end /// and error reporing. /// \param [in] pParentElement - parent metadata element. - void ParseNode_Metadata(CX3DImporter_NodeElement* pParentElement, const std::string& pNodeName); + void ParseNode_Metadata(X3DNodeElementBase* pParentElement, const std::string& pNodeName); /// Parse node of the file. void ParseNode_MetadataBoolean(); @@ -671,52 +599,52 @@ private: void ParseNode_MetadataString(); /// Parse node of the file. - void ParseNode_Geometry2D_Arc2D(); + void ParseNode_Geometry2D_Arc2D(XmlNode &node); /// Parse node of the file. - void ParseNode_Geometry2D_ArcClose2D(); + void ParseNode_Geometry2D_ArcClose2D(XmlNode &node); /// Parse node of the file. - void ParseNode_Geometry2D_Circle2D(); + void ParseNode_Geometry2D_Circle2D(XmlNode &node); /// Parse node of the file. - void ParseNode_Geometry2D_Disk2D(); + void ParseNode_Geometry2D_Disk2D(XmlNode &node); /// Parse node of the file. - void ParseNode_Geometry2D_Polyline2D(); + void ParseNode_Geometry2D_Polyline2D(XmlNode &node); /// Parse node of the file. - void ParseNode_Geometry2D_Polypoint2D(); + void ParseNode_Geometry2D_Polypoint2D(XmlNode &node); /// Parse node of the file. - void ParseNode_Geometry2D_Rectangle2D(); + void ParseNode_Geometry2D_Rectangle2D(XmlNode &node); /// Parse node of the file. - void ParseNode_Geometry2D_TriangleSet2D(); + void ParseNode_Geometry2D_TriangleSet2D(XmlNode &node); /// Parse node of the file. - void ParseNode_Geometry3D_Box(); + void ParseNode_Geometry3D_Box(XmlNode &node); /// Parse node of the file. - void ParseNode_Geometry3D_Cone(); + void ParseNode_Geometry3D_Cone(XmlNode &node); /// Parse node of the file. - void ParseNode_Geometry3D_Cylinder(); + void ParseNode_Geometry3D_Cylinder(XmlNode &node); /// Parse node of the file. - void ParseNode_Geometry3D_ElevationGrid(); + void ParseNode_Geometry3D_ElevationGrid(XmlNode &node); /// Parse node of the file. - void ParseNode_Geometry3D_Extrusion(); + void ParseNode_Geometry3D_Extrusion(XmlNode &node); /// Parse node of the file. - void ParseNode_Geometry3D_IndexedFaceSet(); + void ParseNode_Geometry3D_IndexedFaceSet(XmlNode &node); /// Parse node of the file. - void ParseNode_Geometry3D_Sphere(); + void ParseNode_Geometry3D_Sphere(XmlNode &node); /// Parse node of the file. And create new node in scene graph. - void ParseNode_Grouping_Group(); + void ParseNode_Grouping_Group(XmlNode &node); /// Doing actions at an exit from . Walk up in scene graph. void ParseNode_Grouping_GroupEnd(); @@ -824,7 +752,7 @@ private: /***********************************************/ /****************** Variables ******************/ /***********************************************/ - CX3DImporter_NodeElement* NodeElement_Cur;///< Current element. + X3DNodeElementBase* mNodeElementCur;///< Current element. std::unique_ptr mReader;///< Pointer to XML-reader object IOSystem *mpIOHandler; };// class X3DImporter diff --git a/code/AssetLib/X3D/X3DImporter_Geometry2D.cpp b/code/AssetLib/X3D/X3DImporter_Geometry2D.cpp index 5879c3d50..15775daef 100644 --- a/code/AssetLib/X3D/X3DImporter_Geometry2D.cpp +++ b/code/AssetLib/X3D/X3DImporter_Geometry2D.cpp @@ -64,20 +64,19 @@ namespace Assimp // towards the positive y-axis. The radius field specifies the radius of the circle of which the arc is a portion. The arc extends from the startAngle // counterclockwise to the endAngle. The values of startAngle and endAngle shall be in the range [-2pi, 2pi] radians (or the equivalent if a different // angle base unit has been specified). If startAngle and endAngle have the same value, a circle is specified. -void X3DImporter::ParseNode_Geometry2D_Arc2D() -{ +void X3DImporter::ParseNode_Geometry2D_Arc2D() { std::string def, use; float endAngle = AI_MATH_HALF_PI_F; float radius = 1; float startAngle = 0; - CX3DImporter_NodeElement* ne( nullptr ); + X3DNodeElementBase* ne = nullptr; - MACRO_ATTRREAD_LOOPBEG; + /*MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); MACRO_ATTRREAD_CHECK_RET("endAngle", endAngle, XML_ReadNode_GetAttrVal_AsFloat); MACRO_ATTRREAD_CHECK_RET("radius", radius, XML_ReadNode_GetAttrVal_AsFloat); MACRO_ATTRREAD_CHECK_RET("startAngle", startAngle, XML_ReadNode_GetAttrVal_AsFloat); - MACRO_ATTRREAD_LOOPEND; + MACRO_ATTRREAD_LOOPEND;*/ // if "USE" defined then find already defined element. if(!use.empty()) @@ -87,20 +86,20 @@ void X3DImporter::ParseNode_Geometry2D_Arc2D() else { // create and if needed - define new geometry object. - ne = new CX3DImporter_NodeElement_Geometry2D(CX3DImporter_NodeElement::ENET_Arc2D, NodeElement_Cur); + ne = new X3DGeometry2D(X3DNodeElementBase::ENET_Arc2D, mNodeElementCur); if(!def.empty()) ne->ID = def; // create point list of geometry object and convert it to line set. std::list tlist; GeometryHelper_Make_Arc2D(startAngle, endAngle, radius, 10, tlist);///TODO: IME - AI_CONFIG for NumSeg - GeometryHelper_Extend_PointToLine(tlist, ((CX3DImporter_NodeElement_Geometry2D*)ne)->Vertices); - ((CX3DImporter_NodeElement_Geometry2D*)ne)->NumIndices = 2; + GeometryHelper_Extend_PointToLine(tlist, ((X3DGeometry2D*)ne)->Vertices); + ((X3DGeometry2D*)ne)->NumIndices = 2; // check for X3DMetadataObject childs. if(!mReader->isEmptyElement()) ParseNode_Metadata(ne, "Arc2D"); else - NodeElement_Cur->Child.push_back(ne);// add made object as child to current element + mNodeElementCur->Child.push_back(ne);// add made object as child to current element NodeElement_List.push_back(ne);// add element to node element list because its a new object in graph }// if(!use.empty()) else @@ -133,7 +132,7 @@ void X3DImporter::ParseNode_Geometry2D_ArcClose2D() float radius = 1; bool solid = false; float startAngle = 0; - CX3DImporter_NodeElement* ne( nullptr ); + X3DNodeElementBase* ne( nullptr ); MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); @@ -152,16 +151,16 @@ void X3DImporter::ParseNode_Geometry2D_ArcClose2D() else { // create and if needed - define new geometry object. - ne = new CX3DImporter_NodeElement_Geometry2D(CX3DImporter_NodeElement::ENET_ArcClose2D, NodeElement_Cur); + ne = new X3DGeometry2D(X3DNodeElementBase::ENET_ArcClose2D, mNodeElementCur); if(!def.empty()) ne->ID = def; - ((CX3DImporter_NodeElement_Geometry2D*)ne)->Solid = solid; + ((X3DGeometry2D*)ne)->Solid = solid; // create point list of geometry object. - GeometryHelper_Make_Arc2D(startAngle, endAngle, radius, 10, ((CX3DImporter_NodeElement_Geometry2D*)ne)->Vertices);///TODO: IME - AI_CONFIG for NumSeg + GeometryHelper_Make_Arc2D(startAngle, endAngle, radius, 10, ((X3DGeometry2D*)ne)->Vertices);///TODO: IME - AI_CONFIG for NumSeg // add chord or two radiuses only if not a circle was defined if(!((std::fabs(endAngle - startAngle) >= AI_MATH_TWO_PI_F) || (endAngle == startAngle))) { - std::list& vlist = ((CX3DImporter_NodeElement_Geometry2D*)ne)->Vertices;// just short alias. + std::list& vlist = ((X3DGeometry2D*)ne)->Vertices;// just short alias. if((closureType == "PIE") || (closureType == "\"PIE\"")) vlist.push_back(aiVector3D(0, 0, 0));// center point - first radial line @@ -171,12 +170,12 @@ void X3DImporter::ParseNode_Geometry2D_ArcClose2D() vlist.push_back(*vlist.begin());// arc first point - chord from first to last point of arc(if CHORD) or second radial line(if PIE). } - ((CX3DImporter_NodeElement_Geometry2D*)ne)->NumIndices = ((CX3DImporter_NodeElement_Geometry2D*)ne)->Vertices.size(); + ((X3DGeometry2D*)ne)->NumIndices = ((X3DGeometry2D*)ne)->Vertices.size(); // check for X3DMetadataObject childs. if(!mReader->isEmptyElement()) ParseNode_Metadata(ne, "ArcClose2D"); else - NodeElement_Cur->Child.push_back(ne);// add made object as child to current element + mNodeElementCur->Child.push_back(ne);// add made object as child to current element NodeElement_List.push_back(ne);// add element to node element list because its a new object in graph }// if(!use.empty()) else @@ -191,7 +190,7 @@ void X3DImporter::ParseNode_Geometry2D_Circle2D() { std::string def, use; float radius = 1; - CX3DImporter_NodeElement* ne( nullptr ); + X3DNodeElementBase* ne( nullptr ); MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); @@ -206,20 +205,20 @@ void X3DImporter::ParseNode_Geometry2D_Circle2D() else { // create and if needed - define new geometry object. - ne = new CX3DImporter_NodeElement_Geometry2D(CX3DImporter_NodeElement::ENET_Circle2D, NodeElement_Cur); + ne = new X3DGeometry2D(X3DNodeElementBase::ENET_Circle2D, mNodeElementCur); if(!def.empty()) ne->ID = def; // create point list of geometry object and convert it to line set. std::list tlist; GeometryHelper_Make_Arc2D(0, 0, radius, 10, tlist);///TODO: IME - AI_CONFIG for NumSeg - GeometryHelper_Extend_PointToLine(tlist, ((CX3DImporter_NodeElement_Geometry2D*)ne)->Vertices); - ((CX3DImporter_NodeElement_Geometry2D*)ne)->NumIndices = 2; + GeometryHelper_Extend_PointToLine(tlist, ((X3DGeometry2D*)ne)->Vertices); + ((X3DGeometry2D*)ne)->NumIndices = 2; // check for X3DMetadataObject childs. if(!mReader->isEmptyElement()) ParseNode_Metadata(ne, "Circle2D"); else - NodeElement_Cur->Child.push_back(ne);// add made object as child to current element + mNodeElementCur->Child.push_back(ne);// add made object as child to current element NodeElement_List.push_back(ne);// add element to node element list because its a new object in graph }// if(!use.empty()) else @@ -244,7 +243,7 @@ void X3DImporter::ParseNode_Geometry2D_Disk2D() float innerRadius = 0; float outerRadius = 1; bool solid = false; - CX3DImporter_NodeElement* ne( nullptr ); + X3DNodeElementBase* ne( nullptr ); MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); @@ -265,7 +264,7 @@ void X3DImporter::ParseNode_Geometry2D_Disk2D() if(innerRadius > outerRadius) Throw_IncorrectAttrValue("innerRadius"); // create and if needed - define new geometry object. - ne = new CX3DImporter_NodeElement_Geometry2D(CX3DImporter_NodeElement::ENET_Disk2D, NodeElement_Cur); + ne = new X3DGeometry2D(X3DNodeElementBase::ENET_Disk2D, mNodeElementCur); if(!def.empty()) ne->ID = def; // create point list of geometry object. @@ -274,18 +273,18 @@ void X3DImporter::ParseNode_Geometry2D_Disk2D() if(innerRadius == 0.0f) {// make filled disk // in tlist_o we already have points of circle. just copy it and sign as polygon. - ((CX3DImporter_NodeElement_Geometry2D*)ne)->Vertices = tlist_o; - ((CX3DImporter_NodeElement_Geometry2D*)ne)->NumIndices = tlist_o.size(); + ((X3DGeometry2D*)ne)->Vertices = tlist_o; + ((X3DGeometry2D*)ne)->NumIndices = tlist_o.size(); } else if(innerRadius == outerRadius) {// make circle // in tlist_o we already have points of circle. convert it to line set. - GeometryHelper_Extend_PointToLine(tlist_o, ((CX3DImporter_NodeElement_Geometry2D*)ne)->Vertices); - ((CX3DImporter_NodeElement_Geometry2D*)ne)->NumIndices = 2; + GeometryHelper_Extend_PointToLine(tlist_o, ((X3DGeometry2D*)ne)->Vertices); + ((X3DGeometry2D*)ne)->NumIndices = 2; } else {// make disk - std::list& vlist = ((CX3DImporter_NodeElement_Geometry2D*)ne)->Vertices;// just short alias. + std::list& vlist = ((X3DGeometry2D*)ne)->Vertices;// just short alias. GeometryHelper_Make_Arc2D(0, 0, innerRadius, 10, tlist_i);// inner circle // @@ -309,15 +308,15 @@ void X3DImporter::ParseNode_Geometry2D_Disk2D() vlist.push_back(*tlist_o.begin());// 3rd point vlist.push_back(*tlist_o.begin());// 4th point - ((CX3DImporter_NodeElement_Geometry2D*)ne)->NumIndices = 4; + ((X3DGeometry2D*)ne)->NumIndices = 4; } - ((CX3DImporter_NodeElement_Geometry2D*)ne)->Solid = solid; + ((X3DGeometry2D*)ne)->Solid = solid; // check for X3DMetadataObject childs. if(!mReader->isEmptyElement()) ParseNode_Metadata(ne, "Disk2D"); else - NodeElement_Cur->Child.push_back(ne);// add made object as child to current element + mNodeElementCur->Child.push_back(ne);// add made object as child to current element NodeElement_List.push_back(ne);// add element to node element list because its a new object in graph }// if(!use.empty()) else @@ -332,7 +331,7 @@ void X3DImporter::ParseNode_Geometry2D_Polyline2D() { std::string def, use; std::list lineSegments; - CX3DImporter_NodeElement* ne( nullptr ); + X3DNodeElementBase* ne( nullptr ); MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); @@ -347,7 +346,7 @@ void X3DImporter::ParseNode_Geometry2D_Polyline2D() else { // create and if needed - define new geometry object. - ne = new CX3DImporter_NodeElement_Geometry2D(CX3DImporter_NodeElement::ENET_Polyline2D, NodeElement_Cur); + ne = new X3DGeometry2D(X3DNodeElementBase::ENET_Polyline2D, mNodeElementCur); if(!def.empty()) ne->ID = def; // @@ -359,13 +358,13 @@ void X3DImporter::ParseNode_Geometry2D_Polyline2D() for(std::list::iterator it2 = lineSegments.begin(); it2 != lineSegments.end(); ++it2) tlist.push_back(aiVector3D(it2->x, it2->y, 0)); // convert point set to line set - GeometryHelper_Extend_PointToLine(tlist, ((CX3DImporter_NodeElement_Geometry2D*)ne)->Vertices); - ((CX3DImporter_NodeElement_Geometry2D*)ne)->NumIndices = 2; + GeometryHelper_Extend_PointToLine(tlist, ((X3DGeometry2D*)ne)->Vertices); + ((X3DGeometry2D*)ne)->NumIndices = 2; // check for X3DMetadataObject childs. if(!mReader->isEmptyElement()) ParseNode_Metadata(ne, "Polyline2D"); else - NodeElement_Cur->Child.push_back(ne);// add made object as child to current element + mNodeElementCur->Child.push_back(ne);// add made object as child to current element NodeElement_List.push_back(ne);// add element to node element list because its a new object in graph }// if(!use.empty()) else @@ -380,7 +379,7 @@ void X3DImporter::ParseNode_Geometry2D_Polypoint2D() { std::string def, use; std::list point; - CX3DImporter_NodeElement* ne( nullptr ); + X3DNodeElementBase* ne( nullptr ); MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); @@ -395,21 +394,21 @@ void X3DImporter::ParseNode_Geometry2D_Polypoint2D() else { // create and if needed - define new geometry object. - ne = new CX3DImporter_NodeElement_Geometry2D(CX3DImporter_NodeElement::ENET_Polypoint2D, NodeElement_Cur); + ne = new X3DGeometry2D(X3DNodeElementBase::ENET_Polypoint2D, mNodeElementCur); if(!def.empty()) ne->ID = def; // convert vec2 to vec3 for(std::list::iterator it2 = point.begin(); it2 != point.end(); ++it2) { - ((CX3DImporter_NodeElement_Geometry2D*)ne)->Vertices.push_back(aiVector3D(it2->x, it2->y, 0)); + ((X3DGeometry2D*)ne)->Vertices.push_back(aiVector3D(it2->x, it2->y, 0)); } - ((CX3DImporter_NodeElement_Geometry2D*)ne)->NumIndices = 1; + ((X3DGeometry2D*)ne)->NumIndices = 1; // check for X3DMetadataObject childs. if(!mReader->isEmptyElement()) ParseNode_Metadata(ne, "Polypoint2D"); else - NodeElement_Cur->Child.push_back(ne);// add made object as child to current element + mNodeElementCur->Child.push_back(ne);// add made object as child to current element NodeElement_List.push_back(ne);// add element to node element list because its a new object in graph }// if(!use.empty()) else @@ -426,7 +425,7 @@ void X3DImporter::ParseNode_Geometry2D_Rectangle2D() std::string def, use; aiVector2D size(2, 2); bool solid = false; - CX3DImporter_NodeElement* ne( nullptr ); + X3DNodeElementBase* ne( nullptr ); MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); @@ -442,26 +441,26 @@ void X3DImporter::ParseNode_Geometry2D_Rectangle2D() else { // create and if needed - define new geometry object. - ne = new CX3DImporter_NodeElement_Geometry2D(CX3DImporter_NodeElement::ENET_Rectangle2D, NodeElement_Cur); + ne = new X3DGeometry2D(X3DNodeElementBase::ENET_Rectangle2D, mNodeElementCur); if(!def.empty()) ne->ID = def; float x1 = -size.x / 2.0f; float x2 = size.x / 2.0f; float y1 = -size.y / 2.0f; float y2 = size.y / 2.0f; - std::list& vlist = ((CX3DImporter_NodeElement_Geometry2D*)ne)->Vertices;// just short alias. + std::list& vlist = ((X3DGeometry2D*)ne)->Vertices;// just short alias. vlist.push_back(aiVector3D(x2, y1, 0));// 1st point vlist.push_back(aiVector3D(x2, y2, 0));// 2nd point vlist.push_back(aiVector3D(x1, y2, 0));// 3rd point vlist.push_back(aiVector3D(x1, y1, 0));// 4th point - ((CX3DImporter_NodeElement_Geometry2D*)ne)->Solid = solid; - ((CX3DImporter_NodeElement_Geometry2D*)ne)->NumIndices = 4; + ((X3DGeometry2D*)ne)->Solid = solid; + ((X3DGeometry2D*)ne)->NumIndices = 4; // check for X3DMetadataObject childs. if(!mReader->isEmptyElement()) ParseNode_Metadata(ne, "Rectangle2D"); else - NodeElement_Cur->Child.push_back(ne);// add made object as child to current element + mNodeElementCur->Child.push_back(ne);// add made object as child to current element NodeElement_List.push_back(ne);// add element to node element list because its a new object in graph }// if(!use.empty()) else @@ -478,7 +477,7 @@ void X3DImporter::ParseNode_Geometry2D_TriangleSet2D() std::string def, use; bool solid = false; std::list vertices; - CX3DImporter_NodeElement* ne( nullptr ); + X3DNodeElementBase* ne( nullptr ); MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); @@ -496,22 +495,22 @@ void X3DImporter::ParseNode_Geometry2D_TriangleSet2D() if(vertices.size() % 3) throw DeadlyImportError("TriangleSet2D. Not enough points for defining triangle."); // create and if needed - define new geometry object. - ne = new CX3DImporter_NodeElement_Geometry2D(CX3DImporter_NodeElement::ENET_TriangleSet2D, NodeElement_Cur); + ne = new X3DGeometry2D(X3DNodeElementBase::ENET_TriangleSet2D, mNodeElementCur); if(!def.empty()) ne->ID = def; // convert vec2 to vec3 for(std::list::iterator it2 = vertices.begin(); it2 != vertices.end(); ++it2) { - ((CX3DImporter_NodeElement_Geometry2D*)ne)->Vertices.push_back(aiVector3D(it2->x, it2->y, 0)); + ((X3DGeometry2D*)ne)->Vertices.push_back(aiVector3D(it2->x, it2->y, 0)); } - ((CX3DImporter_NodeElement_Geometry2D*)ne)->Solid = solid; - ((CX3DImporter_NodeElement_Geometry2D*)ne)->NumIndices = 3; + ((X3DGeometry2D*)ne)->Solid = solid; + ((X3DGeometry2D*)ne)->NumIndices = 3; // check for X3DMetadataObject childs. if(!mReader->isEmptyElement()) ParseNode_Metadata(ne, "TriangleSet2D"); else - NodeElement_Cur->Child.push_back(ne);// add made object as child to current element + mNodeElementCur->Child.push_back(ne);// add made object as child to current element NodeElement_List.push_back(ne);// add element to node element list because its a new object in graph }// if(!use.empty()) else diff --git a/code/AssetLib/X3D/X3DImporter_Geometry3D.cpp b/code/AssetLib/X3D/X3DImporter_Geometry3D.cpp index a6bad981a..46ca54c02 100644 --- a/code/AssetLib/X3D/X3DImporter_Geometry3D.cpp +++ b/code/AssetLib/X3D/X3DImporter_Geometry3D.cpp @@ -69,7 +69,7 @@ void X3DImporter::ParseNode_Geometry3D_Box() std::string def, use; bool solid = true; aiVector3D size(2, 2, 2); - CX3DImporter_NodeElement* ne( nullptr ); + X3DNodeElementBase* ne( nullptr ); MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); @@ -85,17 +85,17 @@ void X3DImporter::ParseNode_Geometry3D_Box() else { // create and if needed - define new geometry object. - ne = new CX3DImporter_NodeElement_Geometry3D(CX3DImporter_NodeElement::ENET_Box, NodeElement_Cur); + ne = new X3DGeometry3D(X3DNodeElementBase::ENET_Box, mNodeElementCur); if(!def.empty()) ne->ID = def; - GeometryHelper_MakeQL_RectParallelepiped(size, ((CX3DImporter_NodeElement_Geometry3D*)ne)->Vertices);// get quad list - ((CX3DImporter_NodeElement_Geometry3D*)ne)->Solid = solid; - ((CX3DImporter_NodeElement_Geometry3D*)ne)->NumIndices = 4; + GeometryHelper_MakeQL_RectParallelepiped(size, ((X3DGeometry3D*)ne)->Vertices);// get quad list + ((X3DGeometry3D*)ne)->Solid = solid; + ((X3DGeometry3D*)ne)->NumIndices = 4; // check for X3DMetadataObject childs. if(!mReader->isEmptyElement()) ParseNode_Metadata(ne, "Box"); else - NodeElement_Cur->Child.push_back(ne);// add made object as child to current element + mNodeElementCur->Child.push_back(ne);// add made object as child to current element NodeElement_List.push_back(ne);// add element to node element list because its a new object in graph }// if(!use.empty()) else @@ -118,7 +118,7 @@ void X3DImporter::ParseNode_Geometry3D_Cone() float height = 2; bool side = true; bool solid = true; - CX3DImporter_NodeElement* ne( nullptr ); + X3DNodeElementBase* ne( nullptr ); MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); @@ -141,7 +141,7 @@ void X3DImporter::ParseNode_Geometry3D_Cone() std::vector tvec;// temp array for vertices. // create and if needed - define new geometry object. - ne = new CX3DImporter_NodeElement_Geometry3D(CX3DImporter_NodeElement::ENET_Cone, NodeElement_Cur); + ne = new X3DGeometry3D(X3DNodeElementBase::ENET_Cone, mNodeElementCur); if(!def.empty()) ne->ID = def; // make cone or parts according to flags. @@ -157,15 +157,15 @@ void X3DImporter::ParseNode_Geometry3D_Cone() } // copy data from temp array - for(std::vector::iterator it = tvec.begin(); it != tvec.end(); ++it) ((CX3DImporter_NodeElement_Geometry3D*)ne)->Vertices.push_back(*it); + for(std::vector::iterator it = tvec.begin(); it != tvec.end(); ++it) ((X3DGeometry3D*)ne)->Vertices.push_back(*it); - ((CX3DImporter_NodeElement_Geometry3D*)ne)->Solid = solid; - ((CX3DImporter_NodeElement_Geometry3D*)ne)->NumIndices = 3; + ((X3DGeometry3D*)ne)->Solid = solid; + ((X3DGeometry3D*)ne)->NumIndices = 3; // check for X3DMetadataObject childs. if(!mReader->isEmptyElement()) ParseNode_Metadata(ne, "Cone"); else - NodeElement_Cur->Child.push_back(ne);// add made object as child to current element + mNodeElementCur->Child.push_back(ne);// add made object as child to current element NodeElement_List.push_back(ne);// add element to node element list because its a new object in graph }// if(!use.empty()) else @@ -190,7 +190,7 @@ void X3DImporter::ParseNode_Geometry3D_Cylinder() bool side = true; bool solid = true; bool top = true; - CX3DImporter_NodeElement* ne( nullptr ); + X3DNodeElementBase* ne( nullptr ); MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); @@ -215,7 +215,7 @@ void X3DImporter::ParseNode_Geometry3D_Cylinder() std::vector tcir;// temp array for vertices of circle. // create and if needed - define new geometry object. - ne = new CX3DImporter_NodeElement_Geometry3D(CX3DImporter_NodeElement::ENET_Cylinder, NodeElement_Cur); + ne = new X3DGeometry3D(X3DNodeElementBase::ENET_Cylinder, mNodeElementCur); if(!def.empty()) ne->ID = def; // make cilynder or parts according to flags. @@ -224,7 +224,7 @@ void X3DImporter::ParseNode_Geometry3D_Cylinder() height /= 2;// height defined for whole cylinder, when creating top and bottom circle we are using just half of height. if(top || bottom) StandardShapes::MakeCircle(radius, tess, tcir); // copy data from temp arrays - std::list& vlist = ((CX3DImporter_NodeElement_Geometry3D*)ne)->Vertices;// just short alias. + std::list& vlist = ((X3DGeometry3D*)ne)->Vertices;// just short alias. for(std::vector::iterator it = tside.begin(); it != tside.end(); ++it) vlist.push_back(*it); @@ -246,13 +246,13 @@ void X3DImporter::ParseNode_Geometry3D_Cylinder() } }// if(top) - ((CX3DImporter_NodeElement_Geometry3D*)ne)->Solid = solid; - ((CX3DImporter_NodeElement_Geometry3D*)ne)->NumIndices = 3; + ((X3DGeometry3D*)ne)->Solid = solid; + ((X3DGeometry3D*)ne)->NumIndices = 3; // check for X3DMetadataObject childs. if(!mReader->isEmptyElement()) ParseNode_Metadata(ne, "Cylinder"); else - NodeElement_Cur->Child.push_back(ne);// add made object as child to current element + mNodeElementCur->Child.push_back(ne);// add made object as child to current element NodeElement_List.push_back(ne);// add element to node element list because its a new object in graph }// if(!use.empty()) else @@ -293,7 +293,7 @@ void X3DImporter::ParseNode_Geometry3D_ElevationGrid() float xSpacing = 1; int32_t zDimension = 0; float zSpacing = 1; - CX3DImporter_NodeElement* ne( nullptr ); + X3DNodeElementBase* ne( nullptr ); MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); @@ -321,10 +321,10 @@ void X3DImporter::ParseNode_Geometry3D_ElevationGrid() if((size_t)(xDimension * zDimension) != height.size()) Throw_IncorrectAttrValue("Heights count must be equal to \"xDimension * zDimension\""); // create and if needed - define new geometry object. - ne = new CX3DImporter_NodeElement_ElevationGrid(CX3DImporter_NodeElement::ENET_ElevationGrid, NodeElement_Cur); + ne = new X3DElevationGrid(X3DNodeElementBase::ENET_ElevationGrid, mNodeElementCur); if(!def.empty()) ne->ID = def; - CX3DImporter_NodeElement_ElevationGrid& grid_alias = *((CX3DImporter_NodeElement_ElevationGrid*)ne);// create alias for conveience + X3DElevationGrid& grid_alias = *((X3DElevationGrid*)ne);// create alias for conveience {// create grid vertices list std::vector::const_iterator he_it = height.begin(); @@ -346,7 +346,7 @@ void X3DImporter::ParseNode_Geometry3D_ElevationGrid() // check if we have quads if((xDimension < 2) || (zDimension < 2))// only one element in dimension is set, create line set. { - ((CX3DImporter_NodeElement_ElevationGrid*)ne)->NumIndices = 2;// will be holded as line set. + ((X3DElevationGrid*)ne)->NumIndices = 2;// will be holded as line set. for(size_t i = 0, i_e = (grid_alias.Vertices.size() - 1); i < i_e; i++) { grid_alias.CoordIdx.push_back(static_cast(i)); @@ -356,7 +356,7 @@ void X3DImporter::ParseNode_Geometry3D_ElevationGrid() } else// two or more elements in every dimension is set. create quad set. { - ((CX3DImporter_NodeElement_ElevationGrid*)ne)->NumIndices = 4; + ((X3DElevationGrid*)ne)->NumIndices = 4; for(int32_t fzi = 0, fzi_e = (zDimension - 1); fzi < fzi_e; fzi++)// rows { for(int32_t fxi = 0, fxi_e = (xDimension - 1); fxi < fxi_e; fxi++)// columns @@ -410,7 +410,7 @@ void X3DImporter::ParseNode_Geometry3D_ElevationGrid() }// if(!mReader->isEmptyElement()) else { - NodeElement_Cur->Child.push_back(ne);// add made object as child to current element + mNodeElementCur->Child.push_back(ne);// add made object as child to current element }// if(!mReader->isEmptyElement()) else NodeElement_List.push_back(ne);// add element to node element list because its a new object in graph @@ -584,7 +584,7 @@ void X3DImporter::ParseNode_Geometry3D_Extrusion() std::vector scale; bool solid = true; std::vector spine; - CX3DImporter_NodeElement* ne( nullptr ); + X3DNodeElementBase* ne( nullptr ); MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); @@ -667,10 +667,10 @@ void X3DImporter::ParseNode_Geometry3D_Extrusion() // // create and if needed - define new geometry object. // - ne = new CX3DImporter_NodeElement_IndexedSet(CX3DImporter_NodeElement::ENET_Extrusion, NodeElement_Cur); + ne = new X3DIndexedSet(X3DNodeElementBase::ENET_Extrusion, mNodeElementCur); if(!def.empty()) ne->ID = def; - CX3DImporter_NodeElement_IndexedSet& ext_alias = *((CX3DImporter_NodeElement_IndexedSet*)ne);// create alias for conveience + X3DIndexedSet& ext_alias = *((X3DIndexedSet*)ne);// create alias for conveience // assign part of input data ext_alias.CCW = ccw; ext_alias.Convex = convex; @@ -834,7 +834,7 @@ void X3DImporter::ParseNode_Geometry3D_Extrusion() if(!mReader->isEmptyElement()) ParseNode_Metadata(ne, "Extrusion"); else - NodeElement_Cur->Child.push_back(ne);// add made object as child to current element + mNodeElementCur->Child.push_back(ne);// add made object as child to current element NodeElement_List.push_back(ne);// add element to node element list because its a new object in graph }// if(!use.empty()) else @@ -873,7 +873,7 @@ void X3DImporter::ParseNode_Geometry3D_IndexedFaceSet() bool normalPerVertex = true; bool solid = true; std::vector texCoordIndex; - CX3DImporter_NodeElement* ne( nullptr ); + X3DNodeElementBase* ne( nullptr ); MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); @@ -900,10 +900,10 @@ void X3DImporter::ParseNode_Geometry3D_IndexedFaceSet() if(coordIndex.size() == 0) throw DeadlyImportError("IndexedFaceSet must contain not empty \"coordIndex\" attribute."); // create and if needed - define new geometry object. - ne = new CX3DImporter_NodeElement_IndexedSet(CX3DImporter_NodeElement::ENET_IndexedFaceSet, NodeElement_Cur); + ne = new X3DIndexedSet(X3DNodeElementBase::ENET_IndexedFaceSet, mNodeElementCur); if(!def.empty()) ne->ID = def; - CX3DImporter_NodeElement_IndexedSet& ne_alias = *((CX3DImporter_NodeElement_IndexedSet*)ne); + X3DIndexedSet& ne_alias = *((X3DIndexedSet*)ne); ne_alias.CCW = ccw; ne_alias.ColorIndex = colorIndex; @@ -934,7 +934,7 @@ void X3DImporter::ParseNode_Geometry3D_IndexedFaceSet() }// if(!mReader->isEmptyElement()) else { - NodeElement_Cur->Child.push_back(ne);// add made object as child to current element + mNodeElementCur->Child.push_back(ne);// add made object as child to current element } NodeElement_List.push_back(ne);// add element to node element list because its a new object in graph @@ -952,7 +952,7 @@ void X3DImporter::ParseNode_Geometry3D_Sphere() std::string use, def; ai_real radius = 1; bool solid = true; - CX3DImporter_NodeElement* ne( nullptr ); + X3DNodeElementBase* ne( nullptr ); MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); @@ -972,23 +972,23 @@ void X3DImporter::ParseNode_Geometry3D_Sphere() std::vector tlist; // create and if needed - define new geometry object. - ne = new CX3DImporter_NodeElement_Geometry3D(CX3DImporter_NodeElement::ENET_Sphere, NodeElement_Cur); + ne = new X3DGeometry3D(X3DNodeElementBase::ENET_Sphere, mNodeElementCur); if(!def.empty()) ne->ID = def; StandardShapes::MakeSphere(tess, tlist); // copy data from temp array and apply scale for(std::vector::iterator it = tlist.begin(); it != tlist.end(); ++it) { - ((CX3DImporter_NodeElement_Geometry3D*)ne)->Vertices.push_back(*it * radius); + ((X3DGeometry3D*)ne)->Vertices.push_back(*it * radius); } - ((CX3DImporter_NodeElement_Geometry3D*)ne)->Solid = solid; - ((CX3DImporter_NodeElement_Geometry3D*)ne)->NumIndices = 3; + ((X3DGeometry3D*)ne)->Solid = solid; + ((X3DGeometry3D*)ne)->NumIndices = 3; // check for X3DMetadataObject childs. if(!mReader->isEmptyElement()) ParseNode_Metadata(ne, "Sphere"); else - NodeElement_Cur->Child.push_back(ne);// add made object as child to current element + mNodeElementCur->Child.push_back(ne);// add made object as child to current element NodeElement_List.push_back(ne);// add element to node element list because its a new object in graph }// if(!use.empty()) else diff --git a/code/AssetLib/X3D/X3DImporter_Group.cpp b/code/AssetLib/X3D/X3DImporter_Group.cpp index d78778928..5409a88b3 100644 --- a/code/AssetLib/X3D/X3DImporter_Group.cpp +++ b/code/AssetLib/X3D/X3DImporter_Group.cpp @@ -76,7 +76,7 @@ void X3DImporter::ParseNode_Grouping_Group() // if "USE" defined then find already defined element. if(!use.empty()) { - CX3DImporter_NodeElement* ne; + X3DNodeElementBase* ne; MACRO_USE_CHECKANDAPPLY(def, use, ENET_Group, ne); } @@ -84,7 +84,7 @@ void X3DImporter::ParseNode_Grouping_Group() { ParseHelper_Group_Begin();// create new grouping element and go deeper if node has children. // at this place new group mode created and made current, so we can name it. - if(!def.empty()) NodeElement_Cur->ID = def; + if(!def.empty()) mNodeElementCur->ID = def; // in grouping set of nodes check X3DMetadataObject is not needed, because it is done in parser function. // for empty element exit from node in that place @@ -122,7 +122,7 @@ void X3DImporter::ParseNode_Grouping_StaticGroup() // if "USE" defined then find already defined element. if(!use.empty()) { - CX3DImporter_NodeElement* ne; + X3DNodeElementBase* ne; MACRO_USE_CHECKANDAPPLY(def, use, ENET_Group, ne); } @@ -130,7 +130,7 @@ void X3DImporter::ParseNode_Grouping_StaticGroup() { ParseHelper_Group_Begin(true);// create new grouping element and go deeper if node has children. // at this place new group mode created and made current, so we can name it. - if(!def.empty()) NodeElement_Cur->ID = def; + if(!def.empty()) mNodeElementCur->ID = def; // in grouping set of nodes check X3DMetadataObject is not needed, because it is done in parser function. // for empty element exit from node in that place @@ -172,7 +172,7 @@ void X3DImporter::ParseNode_Grouping_Switch() // if "USE" defined then find already defined element. if(!use.empty()) { - CX3DImporter_NodeElement* ne; + X3DNodeElementBase* ne; MACRO_USE_CHECKANDAPPLY(def, use, ENET_Group, ne); } @@ -180,11 +180,11 @@ void X3DImporter::ParseNode_Grouping_Switch() { ParseHelper_Group_Begin();// create new grouping element and go deeper if node has children. // at this place new group mode created and made current, so we can name it. - if(!def.empty()) NodeElement_Cur->ID = def; + if(!def.empty()) mNodeElementCur->ID = def; // also set values specific to this type of group - ((CX3DImporter_NodeElement_Group*)NodeElement_Cur)->UseChoice = true; - ((CX3DImporter_NodeElement_Group*)NodeElement_Cur)->Choice = whichChoice; + ((X3DGroup*)mNodeElementCur)->UseChoice = true; + ((X3DGroup*)mNodeElementCur)->Choice = whichChoice; // in grouping set of nodes check X3DMetadataObject is not needed, because it is done in parser function. // for empty element exit from node in that place @@ -266,7 +266,7 @@ void X3DImporter::ParseNode_Grouping_Transform() // if "USE" defined then find already defined element. if(!use.empty()) { - CX3DImporter_NodeElement* ne( nullptr ); + X3DNodeElementBase* ne( nullptr ); MACRO_USE_CHECKANDAPPLY(def, use, ENET_Group, ne); } @@ -276,7 +276,7 @@ void X3DImporter::ParseNode_Grouping_Transform() // at this place new group mode created and made current, so we can name it. if ( !def.empty() ) { - NodeElement_Cur->ID = def; + mNodeElementCur->ID = def; } // @@ -297,7 +297,7 @@ void X3DImporter::ParseNode_Grouping_Transform() aiMatrix4x4::Translation(-center, tmatr);// -C matr *= tmatr; // and assign it - ((CX3DImporter_NodeElement_Group*)NodeElement_Cur)->Transformation = matr; + ((X3DGroup*)mNodeElementCur)->Transformation = matr; // in grouping set of nodes check X3DMetadataObject is not needed, because it is done in parser function. // for empty element exit from node in that place diff --git a/code/AssetLib/X3D/X3DImporter_Light.cpp b/code/AssetLib/X3D/X3DImporter_Light.cpp index 5a482adcd..d56eb5ecf 100644 --- a/code/AssetLib/X3D/X3DImporter_Light.cpp +++ b/code/AssetLib/X3D/X3DImporter_Light.cpp @@ -71,7 +71,7 @@ void X3DImporter::ParseNode_Lighting_DirectionalLight() bool global = false; float intensity = 1; bool on = true; - CX3DImporter_NodeElement* ne( nullptr ); + X3DNodeElementBase* ne( nullptr ); MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); @@ -93,27 +93,27 @@ void X3DImporter::ParseNode_Lighting_DirectionalLight() if(on) { // create and if needed - define new geometry object. - ne = new CX3DImporter_NodeElement_Light(CX3DImporter_NodeElement::ENET_DirectionalLight, NodeElement_Cur); + ne = new X3DLight(X3DNodeElementBase::ENET_DirectionalLight, mNodeElementCur); if(!def.empty()) ne->ID = def; else ne->ID = "DirectionalLight_" + to_string((size_t)ne);// make random name - ((CX3DImporter_NodeElement_Light*)ne)->AmbientIntensity = ambientIntensity; - ((CX3DImporter_NodeElement_Light*)ne)->Color = color; - ((CX3DImporter_NodeElement_Light*)ne)->Direction = direction; - ((CX3DImporter_NodeElement_Light*)ne)->Global = global; - ((CX3DImporter_NodeElement_Light*)ne)->Intensity = intensity; + ((X3DLight*)ne)->AmbientIntensity = ambientIntensity; + ((X3DLight*)ne)->Color = color; + ((X3DLight*)ne)->Direction = direction; + ((X3DLight*)ne)->Global = global; + ((X3DLight*)ne)->Intensity = intensity; // Assimp want a node with name similar to a light. "Why? I don't no." ) ParseHelper_Group_Begin(false); - NodeElement_Cur->ID = ne->ID;// assign name to node and return to light element. + mNodeElementCur->ID = ne->ID;// assign name to node and return to light element. ParseHelper_Node_Exit(); // check for child nodes if(!mReader->isEmptyElement()) ParseNode_Metadata(ne, "DirectionalLight"); else - NodeElement_Cur->Child.push_back(ne);// add made object as child to current element + mNodeElementCur->Child.push_back(ne);// add made object as child to current element NodeElement_List.push_back(ne);// add element to node element list because its a new object in graph }// if(on) @@ -143,7 +143,7 @@ void X3DImporter::ParseNode_Lighting_PointLight() aiVector3D location( 0, 0, 0 ); bool on = true; float radius = 100; - CX3DImporter_NodeElement* ne( nullptr ); + X3DNodeElementBase* ne( nullptr ); MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); @@ -167,28 +167,28 @@ void X3DImporter::ParseNode_Lighting_PointLight() if(on) { // create and if needed - define new geometry object. - ne = new CX3DImporter_NodeElement_Light(CX3DImporter_NodeElement::ENET_PointLight, NodeElement_Cur); + ne = new X3DLight(X3DNodeElementBase::ENET_PointLight, mNodeElementCur); if(!def.empty()) ne->ID = def; - ((CX3DImporter_NodeElement_Light*)ne)->AmbientIntensity = ambientIntensity; - ((CX3DImporter_NodeElement_Light*)ne)->Attenuation = attenuation; - ((CX3DImporter_NodeElement_Light*)ne)->Color = color; - ((CX3DImporter_NodeElement_Light*)ne)->Global = global; - ((CX3DImporter_NodeElement_Light*)ne)->Intensity = intensity; - ((CX3DImporter_NodeElement_Light*)ne)->Location = location; - ((CX3DImporter_NodeElement_Light*)ne)->Radius = radius; + ((X3DLight*)ne)->AmbientIntensity = ambientIntensity; + ((X3DLight*)ne)->Attenuation = attenuation; + ((X3DLight*)ne)->Color = color; + ((X3DLight*)ne)->Global = global; + ((X3DLight*)ne)->Intensity = intensity; + ((X3DLight*)ne)->Location = location; + ((X3DLight*)ne)->Radius = radius; // Assimp want a node with name similar to a light. "Why? I don't no." ) ParseHelper_Group_Begin(false); // make random name if(ne->ID.empty()) ne->ID = "PointLight_" + to_string((size_t)ne); - NodeElement_Cur->ID = ne->ID;// assign name to node and return to light element. + mNodeElementCur->ID = ne->ID;// assign name to node and return to light element. ParseHelper_Node_Exit(); // check for child nodes if(!mReader->isEmptyElement()) ParseNode_Metadata(ne, "PointLight"); else - NodeElement_Cur->Child.push_back(ne);// add made object as child to current element + mNodeElementCur->Child.push_back(ne);// add made object as child to current element NodeElement_List.push_back(ne);// add element to node element list because its a new object in graph }// if(on) @@ -224,7 +224,7 @@ void X3DImporter::ParseNode_Lighting_SpotLight() aiVector3D location( 0, 0, 0 ); bool on = true; float radius = 100; - CX3DImporter_NodeElement* ne( nullptr ); + X3DNodeElementBase* ne( nullptr ); MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); @@ -251,34 +251,34 @@ void X3DImporter::ParseNode_Lighting_SpotLight() if(on) { // create and if needed - define new geometry object. - ne = new CX3DImporter_NodeElement_Light(CX3DImporter_NodeElement::ENET_SpotLight, NodeElement_Cur); + ne = new X3DLight(X3DNodeElementBase::ENET_SpotLight, mNodeElementCur); if(!def.empty()) ne->ID = def; if(beamWidth > cutOffAngle) beamWidth = cutOffAngle; - ((CX3DImporter_NodeElement_Light*)ne)->AmbientIntensity = ambientIntensity; - ((CX3DImporter_NodeElement_Light*)ne)->Attenuation = attenuation; - ((CX3DImporter_NodeElement_Light*)ne)->BeamWidth = beamWidth; - ((CX3DImporter_NodeElement_Light*)ne)->Color = color; - ((CX3DImporter_NodeElement_Light*)ne)->CutOffAngle = cutOffAngle; - ((CX3DImporter_NodeElement_Light*)ne)->Direction = direction; - ((CX3DImporter_NodeElement_Light*)ne)->Global = global; - ((CX3DImporter_NodeElement_Light*)ne)->Intensity = intensity; - ((CX3DImporter_NodeElement_Light*)ne)->Location = location; - ((CX3DImporter_NodeElement_Light*)ne)->Radius = radius; + ((X3DLight*)ne)->AmbientIntensity = ambientIntensity; + ((X3DLight*)ne)->Attenuation = attenuation; + ((X3DLight*)ne)->BeamWidth = beamWidth; + ((X3DLight*)ne)->Color = color; + ((X3DLight*)ne)->CutOffAngle = cutOffAngle; + ((X3DLight*)ne)->Direction = direction; + ((X3DLight*)ne)->Global = global; + ((X3DLight*)ne)->Intensity = intensity; + ((X3DLight*)ne)->Location = location; + ((X3DLight*)ne)->Radius = radius; // Assimp want a node with name similar to a light. "Why? I don't no." ) ParseHelper_Group_Begin(false); // make random name if(ne->ID.empty()) ne->ID = "SpotLight_" + to_string((size_t)ne); - NodeElement_Cur->ID = ne->ID;// assign name to node and return to light element. + mNodeElementCur->ID = ne->ID;// assign name to node and return to light element. ParseHelper_Node_Exit(); // check for child nodes if(!mReader->isEmptyElement()) ParseNode_Metadata(ne, "SpotLight"); else - NodeElement_Cur->Child.push_back(ne);// add made object as child to current element + mNodeElementCur->Child.push_back(ne);// add made object as child to current element NodeElement_List.push_back(ne);// add element to node element list because its a new object in graph }// if(on) diff --git a/code/AssetLib/X3D/X3DImporter_Metadata.cpp b/code/AssetLib/X3D/X3DImporter_Metadata.cpp index 126eddb4c..86916b537 100644 --- a/code/AssetLib/X3D/X3DImporter_Metadata.cpp +++ b/code/AssetLib/X3D/X3DImporter_Metadata.cpp @@ -106,7 +106,7 @@ bool X3DImporter::ParseHelper_CheckRead_X3DMetadataObject() return true; } -void X3DImporter::ParseNode_Metadata(CX3DImporter_NodeElement* pParentElement, const std::string& /*pNodeName*/) +void X3DImporter::ParseNode_Metadata(X3DNodeElementBase* pParentElement, const std::string& /*pNodeName*/) { ParseHelper_Node_Enter(pParentElement); MACRO_NODECHECK_METADATA(mReader->getNodeName()); @@ -125,7 +125,7 @@ void X3DImporter::ParseNode_MetadataBoolean() std::string def, use; std::string name, reference; std::vector value; - CX3DImporter_NodeElement* ne( nullptr ); + X3DNodeElementBase* ne( nullptr ); MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); @@ -134,7 +134,7 @@ void X3DImporter::ParseNode_MetadataBoolean() MACRO_ATTRREAD_CHECK_REF("value", value, XML_ReadNode_GetAttrVal_AsArrB); MACRO_ATTRREAD_LOOPEND; - MACRO_METADATA_FINDCREATE(def, use, reference, value, ne, CX3DImporter_NodeElement_MetaBoolean, "MetadataBoolean", ENET_MetaBoolean); + MACRO_METADATA_FINDCREATE(def, use, reference, value, ne, X3DMetaBoolean, "MetadataBoolean", ENET_MetaBoolean); } // value; - CX3DImporter_NodeElement* ne( nullptr ); + X3DNodeElementBase* ne( nullptr ); MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); @@ -158,7 +158,7 @@ void X3DImporter::ParseNode_MetadataDouble() MACRO_ATTRREAD_CHECK_REF("value", value, XML_ReadNode_GetAttrVal_AsArrD); MACRO_ATTRREAD_LOOPEND; - MACRO_METADATA_FINDCREATE(def, use, reference, value, ne, CX3DImporter_NodeElement_MetaDouble, "MetadataDouble", ENET_MetaDouble); + MACRO_METADATA_FINDCREATE(def, use, reference, value, ne, X3DMetaDouble, "MetadataDouble", ENET_MetaDouble); } // value; - CX3DImporter_NodeElement* ne( nullptr ); + X3DNodeElementBase* ne( nullptr ); MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); @@ -182,7 +182,7 @@ void X3DImporter::ParseNode_MetadataFloat() MACRO_ATTRREAD_CHECK_REF("value", value, XML_ReadNode_GetAttrVal_AsArrF); MACRO_ATTRREAD_LOOPEND; - MACRO_METADATA_FINDCREATE(def, use, reference, value, ne, CX3DImporter_NodeElement_MetaFloat, "MetadataFloat", ENET_MetaFloat); + MACRO_METADATA_FINDCREATE(def, use, reference, value, ne, X3DMetaFloat, "MetadataFloat", ENET_MetaFloat); } // value; - CX3DImporter_NodeElement* ne( nullptr ); + X3DNodeElementBase* ne( nullptr ); MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); @@ -206,7 +206,7 @@ void X3DImporter::ParseNode_MetadataInteger() MACRO_ATTRREAD_CHECK_REF("value", value, XML_ReadNode_GetAttrVal_AsArrI32); MACRO_ATTRREAD_LOOPEND; - MACRO_METADATA_FINDCREATE(def, use, reference, value, ne, CX3DImporter_NodeElement_MetaInteger, "MetadataInteger", ENET_MetaInteger); + MACRO_METADATA_FINDCREATE(def, use, reference, value, ne, X3DMetaInteger, "MetadataInteger", ENET_MetaInteger); } // ID = def; - ((CX3DImporter_NodeElement_MetaSet*)ne)->Reference = reference; + ((X3DMetaSet*)ne)->Reference = reference; // also metadata node can contain childs if(!mReader->isEmptyElement()) ParseNode_Metadata(ne, "MetadataSet"); else - NodeElement_Cur->Child.push_back(ne);// made object as child to current element + mNodeElementCur->Child.push_back(ne);// made object as child to current element NodeElement_List.push_back(ne);// add new element to elements list. }// if(!use.empty()) else @@ -260,7 +260,7 @@ void X3DImporter::ParseNode_MetadataString() std::string def, use; std::string name, reference; std::list value; - CX3DImporter_NodeElement* ne( nullptr ); + X3DNodeElementBase* ne( nullptr ); MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); @@ -269,7 +269,7 @@ void X3DImporter::ParseNode_MetadataString() MACRO_ATTRREAD_CHECK_REF("value", value, XML_ReadNode_GetAttrVal_AsListS); MACRO_ATTRREAD_LOOPEND; - MACRO_METADATA_FINDCREATE(def, use, reference, value, ne, CX3DImporter_NodeElement_MetaString, "MetadataString", ENET_MetaString); + MACRO_METADATA_FINDCREATE(def, use, reference, value, ne, X3DMetaString, "MetadataString", ENET_MetaString); } }// namespace Assimp diff --git a/code/AssetLib/X3D/X3DImporter_Networking.cpp b/code/AssetLib/X3D/X3DImporter_Networking.cpp index 688362ab9..a1428cf86 100644 --- a/code/AssetLib/X3D/X3DImporter_Networking.cpp +++ b/code/AssetLib/X3D/X3DImporter_Networking.cpp @@ -83,7 +83,7 @@ void X3DImporter::ParseNode_Networking_Inline() // if "USE" defined then find already defined element. if(!use.empty()) { - CX3DImporter_NodeElement* ne; + X3DNodeElementBase* ne; MACRO_USE_CHECKANDAPPLY(def, use, ENET_Group, ne); } @@ -91,7 +91,7 @@ void X3DImporter::ParseNode_Networking_Inline() { ParseHelper_Group_Begin(true);// create new grouping element and go deeper if node has children. // at this place new group mode created and made current, so we can name it. - if(!def.empty()) NodeElement_Cur->ID = def; + if(!def.empty()) mNodeElementCur->ID = def; if(load && !url.empty()) { @@ -122,7 +122,7 @@ void X3DImporter::ParseNode_Networking_Inline() } // check for X3DMetadataObject childs. - if(!mReader->isEmptyElement()) ParseNode_Metadata(NodeElement_Cur, "Inline"); + if(!mReader->isEmptyElement()) ParseNode_Metadata(mNodeElementCur, "Inline"); // exit from node in that place ParseHelper_Node_Exit(); diff --git a/code/AssetLib/X3D/X3DImporter_Node.hpp b/code/AssetLib/X3D/X3DImporter_Node.hpp index ebc5200c3..340cf449e 100644 --- a/code/AssetLib/X3D/X3DImporter_Node.hpp +++ b/code/AssetLib/X3D/X3DImporter_Node.hpp @@ -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, @@ -53,728 +52,456 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Header files, stdlib. #include -#include #include +#include -/// \class CX3DImporter_NodeElement /// Base class for elements of nodes. -class CX3DImporter_NodeElement -{ - /***********************************************/ - /******************** Types ********************/ - /***********************************************/ - +class X3DNodeElementBase { public: + /// Define what data type contain node element. + enum EType { + ENET_Group, ///< Element has type "Group". + ENET_MetaBoolean, ///< Element has type "Metadata boolean". + ENET_MetaDouble, ///< Element has type "Metadata double". + ENET_MetaFloat, ///< Element has type "Metadata float". + ENET_MetaInteger, ///< Element has type "Metadata integer". + ENET_MetaSet, ///< Element has type "Metadata set". + ENET_MetaString, ///< Element has type "Metadata string". + ENET_Arc2D, ///< Element has type "Arc2D". + ENET_ArcClose2D, ///< Element has type "ArcClose2D". + ENET_Circle2D, ///< Element has type "Circle2D". + ENET_Disk2D, ///< Element has type "Disk2D". + ENET_Polyline2D, ///< Element has type "Polyline2D". + ENET_Polypoint2D, ///< Element has type "Polypoint2D". + ENET_Rectangle2D, ///< Element has type "Rectangle2D". + ENET_TriangleSet2D, ///< Element has type "TriangleSet2D". + ENET_Box, ///< Element has type "Box". + ENET_Cone, ///< Element has type "Cone". + ENET_Cylinder, ///< Element has type "Cylinder". + ENET_Sphere, ///< Element has type "Sphere". + ENET_ElevationGrid, ///< Element has type "ElevationGrid". + ENET_Extrusion, ///< Element has type "Extrusion". + ENET_Coordinate, ///< Element has type "Coordinate". + ENET_Normal, ///< Element has type "Normal". + ENET_TextureCoordinate, ///< Element has type "TextureCoordinate". + ENET_IndexedFaceSet, ///< Element has type "IndexedFaceSet". + ENET_IndexedLineSet, ///< Element has type "IndexedLineSet". + ENET_IndexedTriangleSet, ///< Element has type "IndexedTriangleSet". + ENET_IndexedTriangleFanSet, ///< Element has type "IndexedTriangleFanSet". + ENET_IndexedTriangleStripSet, ///< Element has type "IndexedTriangleStripSet". + ENET_LineSet, ///< Element has type "LineSet". + ENET_PointSet, ///< Element has type "PointSet". + ENET_TriangleSet, ///< Element has type "TriangleSet". + ENET_TriangleFanSet, ///< Element has type "TriangleFanSet". + ENET_TriangleStripSet, ///< Element has type "TriangleStripSet". + ENET_Color, ///< Element has type "Color". + ENET_ColorRGBA, ///< Element has type "ColorRGBA". + ENET_Shape, ///< Element has type "Shape". + ENET_Appearance, ///< Element has type "Appearance". + ENET_Material, ///< Element has type "Material". + ENET_ImageTexture, ///< Element has type "ImageTexture". + ENET_TextureTransform, ///< Element has type "TextureTransform". + ENET_DirectionalLight, ///< Element has type "DirectionalLight". + ENET_PointLight, ///< Element has type "PointLight". + ENET_SpotLight, ///< Element has type "SpotLight". - /// \enum EType - /// Define what data type contain node element. - enum EType - { - ENET_Group, ///< Element has type "Group". - ENET_MetaBoolean, ///< Element has type "Metadata boolean". - ENET_MetaDouble, ///< Element has type "Metadata double". - ENET_MetaFloat, ///< Element has type "Metadata float". - ENET_MetaInteger, ///< Element has type "Metadata integer". - ENET_MetaSet, ///< Element has type "Metadata set". - ENET_MetaString, ///< Element has type "Metadata string". - ENET_Arc2D, ///< Element has type "Arc2D". - ENET_ArcClose2D, ///< Element has type "ArcClose2D". - ENET_Circle2D, ///< Element has type "Circle2D". - ENET_Disk2D, ///< Element has type "Disk2D". - ENET_Polyline2D, ///< Element has type "Polyline2D". - ENET_Polypoint2D, ///< Element has type "Polypoint2D". - ENET_Rectangle2D, ///< Element has type "Rectangle2D". - ENET_TriangleSet2D, ///< Element has type "TriangleSet2D". - ENET_Box, ///< Element has type "Box". - ENET_Cone, ///< Element has type "Cone". - ENET_Cylinder, ///< Element has type "Cylinder". - ENET_Sphere, ///< Element has type "Sphere". - ENET_ElevationGrid, ///< Element has type "ElevationGrid". - ENET_Extrusion, ///< Element has type "Extrusion". - ENET_Coordinate, ///< Element has type "Coordinate". - ENET_Normal, ///< Element has type "Normal". - ENET_TextureCoordinate, ///< Element has type "TextureCoordinate". - ENET_IndexedFaceSet, ///< Element has type "IndexedFaceSet". - ENET_IndexedLineSet, ///< Element has type "IndexedLineSet". - ENET_IndexedTriangleSet, ///< Element has type "IndexedTriangleSet". - ENET_IndexedTriangleFanSet, ///< Element has type "IndexedTriangleFanSet". - ENET_IndexedTriangleStripSet,///< Element has type "IndexedTriangleStripSet". - ENET_LineSet, ///< Element has type "LineSet". - ENET_PointSet, ///< Element has type "PointSet". - ENET_TriangleSet, ///< Element has type "TriangleSet". - ENET_TriangleFanSet, ///< Element has type "TriangleFanSet". - ENET_TriangleStripSet, ///< Element has type "TriangleStripSet". - ENET_Color, ///< Element has type "Color". - ENET_ColorRGBA, ///< Element has type "ColorRGBA". - ENET_Shape, ///< Element has type "Shape". - ENET_Appearance, ///< Element has type "Appearance". - ENET_Material, ///< Element has type "Material". - ENET_ImageTexture, ///< Element has type "ImageTexture". - ENET_TextureTransform, ///< Element has type "TextureTransform". - ENET_DirectionalLight, ///< Element has type "DirectionalLight". - ENET_PointLight, ///< Element has type "PointLight". - ENET_SpotLight, ///< Element has type "SpotLight". + ENET_Invalid ///< Element has invalid type and possible contain invalid data. + }; - ENET_Invalid ///< Element has invalid type and possible contain invalid data. - }; + const EType Type; - /***********************************************/ - /****************** Constants ******************/ - /***********************************************/ - -public: - - const EType Type; - - /***********************************************/ - /****************** Variables ******************/ - /***********************************************/ - -public: - - std::string ID;///< ID of the element. Can be empty. In X3D synonym for "ID" attribute. - CX3DImporter_NodeElement* Parent;///< Parent element. If nullptr then this node is root. - std::list Child;///< Child elements. - - /***********************************************/ - /****************** Functions ******************/ - /***********************************************/ + std::string ID; ///< ID of the element. Can be empty. In X3D synonym for "ID" attribute. + X3DNodeElementBase *Parent; ///< Parent element. If nullptr then this node is root. + std::list Child; ///< Child elements. /// @brief The destructor, virtual. - virtual ~CX3DImporter_NodeElement() { + virtual ~X3DNodeElementBase() { // empty } -private: - /// Disabled copy constructor. - CX3DImporter_NodeElement(const CX3DImporter_NodeElement& pNodeElement); - - /// Disabled assign operator. - CX3DImporter_NodeElement& operator=(const CX3DImporter_NodeElement& pNodeElement); - - /// Disabled default constructor. - CX3DImporter_NodeElement(); - protected: - /// In constructor inheritor must set element type. - /// \param [in] pType - element type. - /// \param [in] pParent - parent element. - CX3DImporter_NodeElement(const EType pType, CX3DImporter_NodeElement* pParent) - : Type(pType), Parent(pParent) - {} -};// class IX3DImporter_NodeElement + /// In constructor inheritor must set element type. + /// \param [in] pType - element type. + /// \param [in] pParent - parent element. + X3DNodeElementBase(const EType pType, X3DNodeElementBase *pParent) : + Type(pType), Parent(pParent) {} + + X3DNodeElementBase(const X3DNodeElementBase &pNodeElement) = delete; + X3DNodeElementBase &operator=(const X3DNodeElementBase &pNodeElement) = delete; + X3DNodeElementBase() = delete; +}; // class IX3DImporter_NodeElement /// \class CX3DImporter_NodeElement_Group /// Class that define grouping node. Define transformation matrix for children. /// Also can select which child will be kept and others are removed. -class CX3DImporter_NodeElement_Group : public CX3DImporter_NodeElement -{ - /***********************************************/ - /****************** Variables ******************/ - /***********************************************/ +class X3DGroup : public X3DNodeElementBase { +public: + aiMatrix4x4 Transformation; ///< Transformation matrix. + + /// \var bool Static + /// As you know node elements can use already defined node elements when attribute "USE" is defined. + /// Standard search when looking for an element in the whole scene graph, existing at this moment. + /// If a node is marked as static, the children(or lower) can not search for elements in the nodes upper then static. + bool Static; + + bool UseChoice; ///< Flag: if true then use number from \ref Choice to choose what the child will be kept. + int32_t Choice; ///< Number of the child which will be kept. public: + /// Constructor. + /// \param [in] pParent - pointer to parent node. + /// \param [in] pStatic - static node flag. + X3DGroup(X3DNodeElementBase *pParent, const bool pStatic = false) : + X3DNodeElementBase(ENET_Group, pParent), + Static(pStatic), + UseChoice(false) { + // empty + } +}; // class CX3DImporter_NodeElement_Group - aiMatrix4x4 Transformation;///< Transformation matrix. - - /// \var bool Static - /// As you know node elements can use already defined node elements when attribute "USE" is defined. - /// Standard search when looking for an element in the whole scene graph, existing at this moment. - /// If a node is marked as static, the children(or lower) can not search for elements in the nodes upper then static. - bool Static; - - bool UseChoice;///< Flag: if true then use number from \ref Choice to choose what the child will be kept. - int32_t Choice;///< Number of the child which will be kept. - - /***********************************************/ - /****************** Functions ******************/ - /***********************************************/ - -private: - - /// \fn CX3DImporter_NodeElement_Group(const CX3DImporter_NodeElement_Group& pNode) - /// Disabled copy constructor. - CX3DImporter_NodeElement_Group(const CX3DImporter_NodeElement_Group& pNode); - - /// \fn CX3DImporter_NodeElement_Group& operator=(const CX3DImporter_NodeElement_Group& pNode) - /// Disabled assign operator. - CX3DImporter_NodeElement_Group& operator=(const CX3DImporter_NodeElement_Group& pNode); - - /// \fn CX3DImporter_NodeElement_Group() - /// Disabled default constructor. - CX3DImporter_NodeElement_Group(); - +/// This struct describe meta-value. +class X3DMeta : public X3DNodeElementBase { public: + std::string Name; ///< Name of metadata object. - /// \fn CX3DImporter_NodeElement_Group(CX3DImporter_NodeElement_Group* pParent, const bool pStatic = false) - /// Constructor. - /// \param [in] pParent - pointer to parent node. - /// \param [in] pStatic - static node flag. - CX3DImporter_NodeElement_Group(CX3DImporter_NodeElement* pParent, const bool pStatic = false) - : CX3DImporter_NodeElement(ENET_Group, pParent), Static(pStatic), UseChoice(false) - {} + /// If provided, it identifies the metadata standard or other specification that defines the name field. If the reference field is not provided or is + /// empty, the meaning of the name field is considered implicit to the characters in the string. + std::string Reference; -};// class CX3DImporter_NodeElement_Group - -/// \class CX3DImporter_NodeElement_Meta -/// This struct describe metavalue. -class CX3DImporter_NodeElement_Meta : public CX3DImporter_NodeElement -{ - /***********************************************/ - /****************** Variables ******************/ - /***********************************************/ - -public: - - std::string Name;///< Name of metadata object. - /// \var std::string Reference - /// If provided, it identifies the metadata standard or other specification that defines the name field. If the reference field is not provided or is - /// empty, the meaning of the name field is considered implicit to the characters in the string. - std::string Reference; - - /***********************************************/ - /****************** Functions ******************/ - /***********************************************/ - -private: - - /// \fn CX3DImporter_NodeElement_Meta(const CX3DImporter_NodeElement_Meta& pNode) - /// Disabled copy constructor. - CX3DImporter_NodeElement_Meta(const CX3DImporter_NodeElement_Meta& pNode); - - /// \fn CX3DImporter_NodeElement_Meta& operator=(const CX3DImporter_NodeElement_Meta& pNode) - /// Disabled assign operator. - CX3DImporter_NodeElement_Meta& operator=(const CX3DImporter_NodeElement_Meta& pNode); - - /// \fn CX3DImporter_NodeElement_Meta() - /// Disabled default constructor. - CX3DImporter_NodeElement_Meta(); - -public: - - /// \fn CX3DImporter_NodeElement_Meta(const EType pType, CX3DImporter_NodeElement* pParent) - /// In constructor inheritor must set element type. - /// \param [in] pType - element type. - /// \param [in] pParent - pointer to parent node. - CX3DImporter_NodeElement_Meta(const EType pType, CX3DImporter_NodeElement* pParent) - : CX3DImporter_NodeElement(pType, pParent) - {} - -};// class CX3DImporter_NodeElement_Meta + /// In constructor inheritor must set element type. + /// \param [in] pType - element type. + /// \param [in] pParent - pointer to parent node. + X3DMeta(const EType pType, X3DNodeElementBase *pParent) : + X3DNodeElementBase(pType, pParent) {} +}; // class CX3DImporter_NodeElement_Meta /// \struct CX3DImporter_NodeElement_MetaBoolean /// This struct describe metavalue of type boolean. -struct CX3DImporter_NodeElement_MetaBoolean : public CX3DImporter_NodeElement_Meta -{ - std::vector Value;///< Stored value. +struct X3DMetaBoolean : public X3DMeta { + std::vector Value; ///< Stored value. - /// \fn CX3DImporter_NodeElement_MetaBoolean(CX3DImporter_NodeElement* pParent) - /// Constructor - /// \param [in] pParent - pointer to parent node. - CX3DImporter_NodeElement_MetaBoolean(CX3DImporter_NodeElement* pParent) - : CX3DImporter_NodeElement_Meta(ENET_MetaBoolean, pParent) - {} + /// \fn CX3DImporter_NodeElement_MetaBoolean(CX3DImporter_NodeElement* pParent) + /// Constructor + /// \param [in] pParent - pointer to parent node. + X3DMetaBoolean(X3DNodeElementBase *pParent) : + X3DMeta(ENET_MetaBoolean, pParent) {} -};// struct CX3DImporter_NodeElement_MetaBoolean +}; // struct CX3DImporter_NodeElement_MetaBoolean /// \struct CX3DImporter_NodeElement_MetaDouble /// This struct describe metavalue of type double. -struct CX3DImporter_NodeElement_MetaDouble : public CX3DImporter_NodeElement_Meta -{ - std::vector Value;///< Stored value. +struct X3DMetaDouble : public X3DMeta { + std::vector Value; ///< Stored value. - /// \fn CX3DImporter_NodeElement_MetaDouble(CX3DImporter_NodeElement* pParent) - /// Constructor - /// \param [in] pParent - pointer to parent node. - CX3DImporter_NodeElement_MetaDouble(CX3DImporter_NodeElement* pParent) - : CX3DImporter_NodeElement_Meta(ENET_MetaDouble, pParent) - {} + /// Constructor + /// \param [in] pParent - pointer to parent node. + X3DMetaDouble(X3DNodeElementBase *pParent) : + X3DMeta(ENET_MetaDouble, pParent) {} -};// struct CX3DImporter_NodeElement_MetaDouble +}; // struct CX3DImporter_NodeElement_MetaDouble -/// \struct CX3DImporter_NodeElement_MetaFloat /// This struct describe metavalue of type float. -struct CX3DImporter_NodeElement_MetaFloat : public CX3DImporter_NodeElement_Meta -{ - std::vector Value;///< Stored value. +struct X3DMetaFloat : public X3DMeta { + std::vector Value; ///< Stored value. - /// \fn CX3DImporter_NodeElement_MetaFloat(CX3DImporter_NodeElement* pParent) - /// Constructor - /// \param [in] pParent - pointer to parent node. - CX3DImporter_NodeElement_MetaFloat(CX3DImporter_NodeElement* pParent) - : CX3DImporter_NodeElement_Meta(ENET_MetaFloat, pParent) - {} + /// Constructor + /// \param [in] pParent - pointer to parent node. + X3DMetaFloat(X3DNodeElementBase *pParent) : + X3DMeta(ENET_MetaFloat, pParent) {} -};// struct CX3DImporter_NodeElement_MetaFloat +}; // struct CX3DImporter_NodeElement_MetaFloat -/// \struct CX3DImporter_NodeElement_MetaInteger /// This struct describe metavalue of type integer. -struct CX3DImporter_NodeElement_MetaInteger : public CX3DImporter_NodeElement_Meta -{ - std::vector Value;///< Stored value. +struct X3DMetaInteger : public X3DMeta { + std::vector Value; ///< Stored value. - /// \fn CX3DImporter_NodeElement_MetaInteger(CX3DImporter_NodeElement* pParent) - /// Constructor - /// \param [in] pParent - pointer to parent node. - CX3DImporter_NodeElement_MetaInteger(CX3DImporter_NodeElement* pParent) - : CX3DImporter_NodeElement_Meta(ENET_MetaInteger, pParent) - {} + /// Constructor + /// \param [in] pParent - pointer to parent node. + X3DMetaInteger(X3DNodeElementBase *pParent) : + X3DMeta(ENET_MetaInteger, pParent) {} -};// struct CX3DImporter_NodeElement_MetaInteger +}; // struct CX3DImporter_NodeElement_MetaInteger -/// \struct CX3DImporter_NodeElement_MetaSet /// This struct describe container for metaobjects. -struct CX3DImporter_NodeElement_MetaSet : public CX3DImporter_NodeElement_Meta -{ - std::list Value;///< Stored value. +struct X3DMetaSet : public X3DMeta { + std::list Value; ///< Stored value. - /// \fn CX3DImporter_NodeElement_MetaSet(CX3DImporter_NodeElement* pParent) - /// Constructor - /// \param [in] pParent - pointer to parent node. - CX3DImporter_NodeElement_MetaSet(CX3DImporter_NodeElement* pParent) - : CX3DImporter_NodeElement_Meta(ENET_MetaSet, pParent) - {} + /// Constructor + /// \param [in] pParent - pointer to parent node. + X3DMetaSet(X3DNodeElementBase *pParent) : + X3DMeta(ENET_MetaSet, pParent) {} -};// struct CX3DImporter_NodeElement_MetaSet +}; // struct CX3DImporter_NodeElement_MetaSet -/// \struct CX3DImporter_NodeElement_MetaString /// This struct describe metavalue of type string. -struct CX3DImporter_NodeElement_MetaString : public CX3DImporter_NodeElement_Meta -{ - std::list Value;///< Stored value. +struct X3DMetaString : public X3DMeta { + std::list Value; ///< Stored value. - /// \fn CX3DImporter_NodeElement_MetaString(CX3DImporter_NodeElement* pParent) - /// Constructor - /// \param [in] pParent - pointer to parent node. - CX3DImporter_NodeElement_MetaString(CX3DImporter_NodeElement* pParent) - : CX3DImporter_NodeElement_Meta(ENET_MetaString, pParent) - {} + /// Constructor + /// \param [in] pParent - pointer to parent node. + X3DMetaString(X3DNodeElementBase *pParent) : + X3DMeta(ENET_MetaString, pParent) {} -};// struct CX3DImporter_NodeElement_MetaString +}; // struct CX3DImporter_NodeElement_MetaString -/// \struct CX3DImporter_NodeElement_Color /// This struct hold value. -struct CX3DImporter_NodeElement_Color : public CX3DImporter_NodeElement -{ - std::list Value;///< Stored value. +struct X3DColor : public X3DNodeElementBase { + std::list Value; ///< Stored value. - /// \fn CX3DImporter_NodeElement_Color(CX3DImporter_NodeElement* pParent) - /// Constructor - /// \param [in] pParent - pointer to parent node. - CX3DImporter_NodeElement_Color(CX3DImporter_NodeElement* pParent) - : CX3DImporter_NodeElement(ENET_Color, pParent) - {} + /// Constructor + /// \param [in] pParent - pointer to parent node. + X3DColor(X3DNodeElementBase *pParent) : + X3DNodeElementBase(ENET_Color, pParent) {} -};// struct CX3DImporter_NodeElement_Color +}; // struct CX3DImporter_NodeElement_Color -/// \struct CX3DImporter_NodeElement_ColorRGBA /// This struct hold value. -struct CX3DImporter_NodeElement_ColorRGBA : public CX3DImporter_NodeElement -{ - std::list Value;///< Stored value. +struct X3DColorRGBA : public X3DNodeElementBase { + std::list Value; ///< Stored value. - /// \fn CX3DImporter_NodeElement_ColorRGBA(CX3DImporter_NodeElement* pParent) - /// Constructor - /// \param [in] pParent - pointer to parent node. - CX3DImporter_NodeElement_ColorRGBA(CX3DImporter_NodeElement* pParent) - : CX3DImporter_NodeElement(ENET_ColorRGBA, pParent) - {} + /// Constructor + /// \param [in] pParent - pointer to parent node. + X3DColorRGBA(X3DNodeElementBase *pParent) : + X3DNodeElementBase(ENET_ColorRGBA, pParent) {} -};// struct CX3DImporter_NodeElement_ColorRGBA +}; // struct CX3DImporter_NodeElement_ColorRGBA -/// \struct CX3DImporter_NodeElement_Coordinate /// This struct hold value. -struct CX3DImporter_NodeElement_Coordinate : public CX3DImporter_NodeElement -{ - std::list Value;///< Stored value. +struct X3DCoordinate : public X3DNodeElementBase { + std::list Value; ///< Stored value. - /// \fn CX3DImporter_NodeElement_Coordinate(CX3DImporter_NodeElement* pParent) - /// Constructor - /// \param [in] pParent - pointer to parent node. - CX3DImporter_NodeElement_Coordinate(CX3DImporter_NodeElement* pParent) - : CX3DImporter_NodeElement(ENET_Coordinate, pParent) - {} + /// Constructor + /// \param [in] pParent - pointer to parent node. + X3DCoordinate(X3DNodeElementBase *pParent) : + X3DNodeElementBase(ENET_Coordinate, pParent) {} -};// struct CX3DImporter_NodeElement_Coordinate +}; // struct CX3DImporter_NodeElement_Coordinate -/// \struct CX3DImporter_NodeElement_Normal /// This struct hold value. -struct CX3DImporter_NodeElement_Normal : public CX3DImporter_NodeElement -{ - std::list Value;///< Stored value. +struct X3DNormal : public X3DNodeElementBase { + std::list Value; ///< Stored value. - /// \fn CX3DImporter_NodeElement_Normal(CX3DImporter_NodeElement* pParent) - /// Constructor - /// \param [in] pParent - pointer to parent node. - CX3DImporter_NodeElement_Normal(CX3DImporter_NodeElement* pParent) - : CX3DImporter_NodeElement(ENET_Normal, pParent) - {} + /// Constructor + /// \param [in] pParent - pointer to parent node. + X3DNormal(X3DNodeElementBase *pParent) : + X3DNodeElementBase(ENET_Normal, pParent) {} -};// struct CX3DImporter_NodeElement_Normal +}; // struct CX3DImporter_NodeElement_Normal -/// \struct CX3DImporter_NodeElement_TextureCoordinate /// This struct hold value. -struct CX3DImporter_NodeElement_TextureCoordinate : public CX3DImporter_NodeElement -{ - std::list Value;///< Stored value. +struct X3DTextureCoordinate : public X3DNodeElementBase { + std::list Value; ///< Stored value. - /// \fn CX3DImporter_NodeElement_TextureCoordinate(CX3DImporter_NodeElement* pParent) - /// Constructor - /// \param [in] pParent - pointer to parent node. - CX3DImporter_NodeElement_TextureCoordinate(CX3DImporter_NodeElement* pParent) - : CX3DImporter_NodeElement(ENET_TextureCoordinate, pParent) - {} + /// Constructor + /// \param [in] pParent - pointer to parent node. + X3DTextureCoordinate(X3DNodeElementBase *pParent) : + X3DNodeElementBase(ENET_TextureCoordinate, pParent) {} -};// struct CX3DImporter_NodeElement_TextureCoordinate +}; // struct CX3DImporter_NodeElement_TextureCoordinate -/// \class CX3DImporter_NodeElement_Geometry2D /// Two-dimensional figure. -class CX3DImporter_NodeElement_Geometry2D : public CX3DImporter_NodeElement -{ - /***********************************************/ - /****************** Variables ******************/ - /***********************************************/ - +class X3DGeometry2D : public X3DNodeElementBase { public: + std::list Vertices; ///< Vertices list. + size_t NumIndices; ///< Number of indices in one face. + bool Solid; ///< Flag: if true then render must use back-face culling, else render must draw both sides of object. - std::list Vertices;///< Vertices list. - size_t NumIndices;///< Number of indices in one face. - bool Solid;///< Flag: if true then render must use back-face culling, else render must draw both sides of object. + /// Constructor. + /// \param [in] pParent - pointer to parent node. + /// \param [in] pType - type of geometry object. + X3DGeometry2D(const EType pType, X3DNodeElementBase *pParent) : + X3DNodeElementBase(pType, pParent), Solid(true) {} - /***********************************************/ - /****************** Functions ******************/ - /***********************************************/ +}; // class CX3DImporter_NodeElement_Geometry2D -private: - - /// \fn CX3DImporter_NodeElement_Geometry2D(const CX3DImporter_NodeElement_Geometry2D& pNode) - /// Disabled copy constructor. - CX3DImporter_NodeElement_Geometry2D(const CX3DImporter_NodeElement_Geometry2D& pNode); - - /// \fn CX3DImporter_NodeElement_Geometry2D& operator=(const CX3DImporter_NodeElement_Geometry2D& pNode) - /// Disabled assign operator. - CX3DImporter_NodeElement_Geometry2D& operator=(const CX3DImporter_NodeElement_Geometry2D& pNode); - -public: - - /// \fn CX3DImporter_NodeElement_Geometry2D(const EType pType, CX3DImporter_NodeElement* pParent) - /// Constructor. - /// \param [in] pParent - pointer to parent node. - /// \param [in] pType - type of geometry object. - CX3DImporter_NodeElement_Geometry2D(const EType pType, CX3DImporter_NodeElement* pParent) - : CX3DImporter_NodeElement(pType, pParent), Solid(true) - {} - -};// class CX3DImporter_NodeElement_Geometry2D - -/// \class CX3DImporter_NodeElement_Geometry3D /// Three-dimensional body. -class CX3DImporter_NodeElement_Geometry3D : public CX3DImporter_NodeElement { +class X3DGeometry3D : public X3DNodeElementBase { public: - std::list Vertices; ///< Vertices list. - size_t NumIndices;///< Number of indices in one face. - bool Solid; ///< Flag: if true then render must use back-face culling, else render must draw both sides of object. + std::list Vertices; ///< Vertices list. + size_t NumIndices; ///< Number of indices in one face. + bool Solid; ///< Flag: if true then render must use back-face culling, else render must draw both sides of object. - /// Constructor. - /// \param [in] pParent - pointer to parent node. - /// \param [in] pType - type of geometry object. - CX3DImporter_NodeElement_Geometry3D(const EType pType, CX3DImporter_NodeElement* pParent) - : CX3DImporter_NodeElement(pType, pParent) - , Vertices() - , NumIndices( 0 ) - , Solid(true) { - // empty - } - -private: - /// Disabled copy constructor. - CX3DImporter_NodeElement_Geometry3D(const CX3DImporter_NodeElement_Geometry3D& pNode); - - /// Disabled assign operator. - CX3DImporter_NodeElement_Geometry3D& operator=(const CX3DImporter_NodeElement_Geometry3D& pNode); -};// class CX3DImporter_NodeElement_Geometry3D + /// Constructor. + /// \param [in] pParent - pointer to parent node. + /// \param [in] pType - type of geometry object. + X3DGeometry3D(const EType pType, X3DNodeElementBase *pParent) : + X3DNodeElementBase(pType, pParent), Vertices(), NumIndices(0), Solid(true) { + // empty + } +}; // class CX3DImporter_NodeElement_Geometry3D /// \class CX3DImporter_NodeElement_ElevationGrid /// Uniform rectangular grid of varying height. -class CX3DImporter_NodeElement_ElevationGrid : public CX3DImporter_NodeElement_Geometry3D -{ - /***********************************************/ - /****************** Variables ******************/ - /***********************************************/ - +class X3DElevationGrid : public X3DGeometry3D { public: + bool NormalPerVertex; ///< If true then normals are defined for every vertex, else for every face(line). + bool ColorPerVertex; ///< If true then colors are defined for every vertex, else for every face(line). + /// If the angle between the geometric normals of two adjacent faces is less than the crease angle, normals shall be calculated so that the faces are + /// shaded smoothly across the edge; otherwise, normals shall be calculated so that a lighting discontinuity across the edge is produced. + float CreaseAngle; + std::vector CoordIdx; ///< Coordinates list by faces. In X3D format: "-1" - delimiter for faces. - bool NormalPerVertex;///< If true then normals are defined for every vertex, else for every face(line). - bool ColorPerVertex;///< If true then colors are defined for every vertex, else for every face(line). - /// \var CreaseAngle - /// If the angle between the geometric normals of two adjacent faces is less than the crease angle, normals shall be calculated so that the faces are - /// shaded smoothly across the edge; otherwise, normals shall be calculated so that a lighting discontinuity across the edge is produced. - float CreaseAngle; - std::vector CoordIdx;///< Coordinates list by faces. In X3D format: "-1" - delimiter for faces. + /// Constructor. + /// \param [in] pParent - pointer to parent node. + /// \param [in] pType - type of geometry object. + X3DElevationGrid(const EType pType, X3DNodeElementBase *pParent) : + X3DGeometry3D(pType, pParent) {} - /***********************************************/ - /****************** Functions ******************/ - /***********************************************/ +}; // class CX3DImporter_NodeElement_IndexedSet -private: - - /// \fn CX3DImporter_NodeElement_ElevationGrid(const CX3DImporter_NodeElement_ElevationGrid& pNode) - /// Disabled copy constructor. - CX3DImporter_NodeElement_ElevationGrid(const CX3DImporter_NodeElement_ElevationGrid& pNode); - - /// \fn CX3DImporter_NodeElement_ElevationGrid& operator=(const CX3DImporter_NodeElement_ElevationGrid& pNode) - /// Disabled assign operator. - CX3DImporter_NodeElement_ElevationGrid& operator=(const CX3DImporter_NodeElement_ElevationGrid& pNode); - -public: - - /// \fn CX3DImporter_NodeElement_ElevationGrid(const EType pType, CX3DImporter_NodeElement* pParent) - /// Constructor. - /// \param [in] pParent - pointer to parent node. - /// \param [in] pType - type of geometry object. - CX3DImporter_NodeElement_ElevationGrid(const EType pType, CX3DImporter_NodeElement* pParent) - : CX3DImporter_NodeElement_Geometry3D(pType, pParent) - {} - -};// class CX3DImporter_NodeElement_IndexedSet - -/// \class CX3DImporter_NodeElement_IndexedSet /// Shape with indexed vertices. -class CX3DImporter_NodeElement_IndexedSet : public CX3DImporter_NodeElement_Geometry3D -{ - /***********************************************/ - /****************** Variables ******************/ - /***********************************************/ - +class X3DIndexedSet : public X3DGeometry3D { public: + /// The ccw field defines the ordering of the vertex coordinates of the geometry with respect to user-given or automatically generated normal vectors + /// used in the lighting model equations. If ccw is TRUE, the normals shall follow the right hand rule; the orientation of each normal with respect to + /// the vertices (taken in order) shall be such that the vertices appear to be oriented in a counterclockwise order when the vertices are viewed (in the + /// local coordinate system of the Shape) from the opposite direction as the normal. If ccw is FALSE, the normals shall be oriented in the opposite + /// direction. If normals are not generated but are supplied using a Normal node, and the orientation of the normals does not match the setting of the + /// ccw field, results are undefined. + bool CCW; + std::vector ColorIndex; ///< Field to specify the polygonal faces by indexing into the or . + bool ColorPerVertex; ///< If true then colors are defined for every vertex, else for every face(line). + /// The convex field indicates whether all polygons in the shape are convex (TRUE). A polygon is convex if it is planar, does not intersect itself, + /// and all of the interior angles at its vertices are less than 180 degrees. Non planar and self intersecting polygons may produce undefined results + /// even if the convex field is FALSE. + bool Convex; + std::vector CoordIndex; ///< Field to specify the polygonal faces by indexing into the . + /// If the angle between the geometric normals of two adjacent faces is less than the crease angle, normals shall be calculated so that the faces are + /// shaded smoothly across the edge; otherwise, normals shall be calculated so that a lighting discontinuity across the edge is produced. + float CreaseAngle; + std::vector NormalIndex; ///< Field to specify the polygonal faces by indexing into the . + bool NormalPerVertex; ///< If true then normals are defined for every vertex, else for every face(line). + std::vector TexCoordIndex; ///< Field to specify the polygonal faces by indexing into the . - /// \var CCW - /// The ccw field defines the ordering of the vertex coordinates of the geometry with respect to user-given or automatically generated normal vectors - /// used in the lighting model equations. If ccw is TRUE, the normals shall follow the right hand rule; the orientation of each normal with respect to - /// the vertices (taken in order) shall be such that the vertices appear to be oriented in a counterclockwise order when the vertices are viewed (in the - /// local coordinate system of the Shape) from the opposite direction as the normal. If ccw is FALSE, the normals shall be oriented in the opposite - /// direction. If normals are not generated but are supplied using a Normal node, and the orientation of the normals does not match the setting of the - /// ccw field, results are undefined. - bool CCW; - std::vector ColorIndex;///< Field to specify the polygonal faces by indexing into the or . - bool ColorPerVertex;///< If true then colors are defined for every vertex, else for every face(line). - /// \var Convex - /// The convex field indicates whether all polygons in the shape are convex (TRUE). A polygon is convex if it is planar, does not intersect itself, - /// and all of the interior angles at its vertices are less than 180 degrees. Non planar and self intersecting polygons may produce undefined results - /// even if the convex field is FALSE. - bool Convex; - std::vector CoordIndex;///< Field to specify the polygonal faces by indexing into the . - /// \var CreaseAngle - /// If the angle between the geometric normals of two adjacent faces is less than the crease angle, normals shall be calculated so that the faces are - /// shaded smoothly across the edge; otherwise, normals shall be calculated so that a lighting discontinuity across the edge is produced. - float CreaseAngle; - std::vector NormalIndex;///< Field to specify the polygonal faces by indexing into the . - bool NormalPerVertex;///< If true then normals are defined for every vertex, else for every face(line). - std::vector TexCoordIndex;///< Field to specify the polygonal faces by indexing into the . + /// Constructor. + /// \param [in] pParent - pointer to parent node. + /// \param [in] pType - type of geometry object. + X3DIndexedSet(const EType pType, X3DNodeElementBase *pParent) : + X3DGeometry3D(pType, pParent) {} - /***********************************************/ - /****************** Functions ******************/ - /***********************************************/ +}; // class CX3DImporter_NodeElement_IndexedSet -private: - - /// \fn CX3DImporter_NodeElement_IndexedSet(const CX3DImporter_NodeElement_IndexedSet& pNode) - /// Disabled copy constructor. - CX3DImporter_NodeElement_IndexedSet(const CX3DImporter_NodeElement_IndexedSet& pNode); - - /// \fn CX3DImporter_NodeElement_IndexedSet& operator=(const CX3DImporter_NodeElement_IndexedSet& pNode) - /// Disabled assign operator. - CX3DImporter_NodeElement_IndexedSet& operator=(const CX3DImporter_NodeElement_IndexedSet& pNode); - -public: - - /// \fn CX3DImporter_NodeElement_IndexedSet(const EType pType, CX3DImporter_NodeElement* pParent) - /// Constructor. - /// \param [in] pParent - pointer to parent node. - /// \param [in] pType - type of geometry object. - CX3DImporter_NodeElement_IndexedSet(const EType pType, CX3DImporter_NodeElement* pParent) - : CX3DImporter_NodeElement_Geometry3D(pType, pParent) - {} - -};// class CX3DImporter_NodeElement_IndexedSet - -/// \class CX3DImporter_NodeElement_Set /// Shape with set of vertices. -class CX3DImporter_NodeElement_Set : public CX3DImporter_NodeElement_Geometry3D -{ - /***********************************************/ - /****************** Variables ******************/ - /***********************************************/ - +class X3DSet : public X3DGeometry3D { public: + /// The ccw field defines the ordering of the vertex coordinates of the geometry with respect to user-given or automatically generated normal vectors + /// used in the lighting model equations. If ccw is TRUE, the normals shall follow the right hand rule; the orientation of each normal with respect to + /// the vertices (taken in order) shall be such that the vertices appear to be oriented in a counterclockwise order when the vertices are viewed (in the + /// local coordinate system of the Shape) from the opposite direction as the normal. If ccw is FALSE, the normals shall be oriented in the opposite + /// direction. If normals are not generated but are supplied using a Normal node, and the orientation of the normals does not match the setting of the + /// ccw field, results are undefined. + bool CCW; + bool ColorPerVertex; ///< If true then colors are defined for every vertex, else for every face(line). + bool NormalPerVertex; ///< If true then normals are defined for every vertex, else for every face(line). + std::vector CoordIndex; ///< Field to specify the polygonal faces by indexing into the . + std::vector NormalIndex; ///< Field to specify the polygonal faces by indexing into the . + std::vector TexCoordIndex; ///< Field to specify the polygonal faces by indexing into the . + std::vector VertexCount; ///< Field describes how many vertices are to be used in each polyline(polygon) from the field. - /// \var CCW - /// The ccw field defines the ordering of the vertex coordinates of the geometry with respect to user-given or automatically generated normal vectors - /// used in the lighting model equations. If ccw is TRUE, the normals shall follow the right hand rule; the orientation of each normal with respect to - /// the vertices (taken in order) shall be such that the vertices appear to be oriented in a counterclockwise order when the vertices are viewed (in the - /// local coordinate system of the Shape) from the opposite direction as the normal. If ccw is FALSE, the normals shall be oriented in the opposite - /// direction. If normals are not generated but are supplied using a Normal node, and the orientation of the normals does not match the setting of the - /// ccw field, results are undefined. - bool CCW; - bool ColorPerVertex;///< If true then colors are defined for every vertex, else for every face(line). - bool NormalPerVertex;///< If true then normals are defined for every vertex, else for every face(line). - std::vector CoordIndex;///< Field to specify the polygonal faces by indexing into the . - std::vector NormalIndex;///< Field to specify the polygonal faces by indexing into the . - std::vector TexCoordIndex;///< Field to specify the polygonal faces by indexing into the . - std::vector VertexCount;///< Field describes how many vertices are to be used in each polyline(polygon) from the field. + /// Constructor. + /// \param [in] pParent - pointer to parent node. + /// \param [in] pType - type of geometry object. + X3DSet(const EType pType, X3DNodeElementBase *pParent) : + X3DGeometry3D(pType, pParent) {} - /***********************************************/ - /****************** Functions ******************/ - /***********************************************/ +}; // class CX3DImporter_NodeElement_Set -private: - - /// \fn CX3DImporter_NodeElement_Set(const CX3DImporter_NodeElement_Set& pNode) - /// Disabled copy constructor. - CX3DImporter_NodeElement_Set(const CX3DImporter_NodeElement_Set& pNode); - - /// \fn CX3DImporter_NodeElement_Set& operator=(const CX3DImporter_NodeElement_Set& pNode) - /// Disabled assign operator. - CX3DImporter_NodeElement_Set& operator=(const CX3DImporter_NodeElement_Set& pNode); - -public: - - /// \fn CX3DImporter_NodeElement_Set(const EType pType, CX3DImporter_NodeElement* pParent) - /// Constructor. - /// \param [in] pParent - pointer to parent node. - /// \param [in] pType - type of geometry object. - CX3DImporter_NodeElement_Set(const EType pType, CX3DImporter_NodeElement* pParent) - : CX3DImporter_NodeElement_Geometry3D(pType, pParent) - {} - -};// class CX3DImporter_NodeElement_Set - -/// \struct CX3DImporter_NodeElement_Shape /// This struct hold value. -struct CX3DImporter_NodeElement_Shape : public CX3DImporter_NodeElement -{ - /// \fn CX3DImporter_NodeElement_Shape(CX3DImporter_NodeElement_Shape* pParent) - /// Constructor - /// \param [in] pParent - pointer to parent node. - CX3DImporter_NodeElement_Shape(CX3DImporter_NodeElement* pParent) - : CX3DImporter_NodeElement(ENET_Shape, pParent) - {} +struct X3DShape : public X3DNodeElementBase { + /// Constructor + /// \param [in] pParent - pointer to parent node. + X3DShape(X3DNodeElementBase *pParent) : + X3DNodeElementBase(ENET_Shape, pParent) {} -};// struct CX3DImporter_NodeElement_Shape +}; // struct CX3DImporter_NodeElement_Shape -/// \struct CX3DImporter_NodeElement_Appearance /// This struct hold value. -struct CX3DImporter_NodeElement_Appearance : public CX3DImporter_NodeElement -{ - /// \fn CX3DImporter_NodeElement_Appearance(CX3DImporter_NodeElement_Appearance* pParent) - /// Constructor - /// \param [in] pParent - pointer to parent node. - CX3DImporter_NodeElement_Appearance(CX3DImporter_NodeElement* pParent) - : CX3DImporter_NodeElement(ENET_Appearance, pParent) - {} +struct X3DAppearance : public X3DNodeElementBase { + /// Constructor + /// \param [in] pParent - pointer to parent node. + X3DAppearance(X3DNodeElementBase *pParent) : + X3DNodeElementBase(ENET_Appearance, pParent) {} -};// struct CX3DImporter_NodeElement_Appearance +}; // struct CX3DImporter_NodeElement_Appearance -/// \class CX3DImporter_NodeElement_Material /// Material. -class CX3DImporter_NodeElement_Material : public CX3DImporter_NodeElement { +class X3DMaterial : public X3DNodeElementBase { public: - float AmbientIntensity;///< Specifies how much ambient light from light sources this surface shall reflect. - aiColor3D DiffuseColor; ///< Reflects all X3D light sources depending on the angle of the surface with respect to the light source. - aiColor3D EmissiveColor; ///< Models "glowing" objects. This can be useful for displaying pre-lit models. - float Shininess; ///< Lower shininess values produce soft glows, while higher values result in sharper, smaller highlights. - aiColor3D SpecularColor; ///< The specularColor and shininess fields determine the specular highlights. - float Transparency; ///< Specifies how "clear" an object is, with 1.0 being completely transparent, and 0.0 completely opaque. + float AmbientIntensity; ///< Specifies how much ambient light from light sources this surface shall reflect. + aiColor3D DiffuseColor; ///< Reflects all X3D light sources depending on the angle of the surface with respect to the light source. + aiColor3D EmissiveColor; ///< Models "glowing" objects. This can be useful for displaying pre-lit models. + float Shininess; ///< Lower shininess values produce soft glows, while higher values result in sharper, smaller highlights. + aiColor3D SpecularColor; ///< The specularColor and shininess fields determine the specular highlights. + float Transparency; ///< Specifies how "clear" an object is, with 1.0 being completely transparent, and 0.0 completely opaque. - /// Constructor. - /// \param [in] pParent - pointer to parent node. - /// \param [in] pType - type of geometry object. - CX3DImporter_NodeElement_Material(CX3DImporter_NodeElement* pParent) - : CX3DImporter_NodeElement(ENET_Material, pParent) - , AmbientIntensity( 0.0f ) - , DiffuseColor() - , EmissiveColor() - , Shininess( 0.0f ) - , SpecularColor() - , Transparency( 1.0f ) { - // empty - } + /// Constructor. + /// \param [in] pParent - pointer to parent node. + /// \param [in] pType - type of geometry object. + X3DMaterial(X3DNodeElementBase *pParent) : + X3DNodeElementBase(ENET_Material, pParent), + AmbientIntensity(0.0f), + DiffuseColor(), + EmissiveColor(), + Shininess(0.0f), + SpecularColor(), + Transparency(1.0f) { + // empty + } +}; // class CX3DImporter_NodeElement_Material -private: - /// Disabled copy constructor. - CX3DImporter_NodeElement_Material(const CX3DImporter_NodeElement_Material& pNode); - - /// Disabled assign operator. - CX3DImporter_NodeElement_Material& operator=(const CX3DImporter_NodeElement_Material& pNode); -};// class CX3DImporter_NodeElement_Material - -/// \struct CX3DImporter_NodeElement_ImageTexture /// This struct hold value. -struct CX3DImporter_NodeElement_ImageTexture : public CX3DImporter_NodeElement -{ - /// \var RepeatS - /// RepeatS and RepeatT, that specify how the texture wraps in the S and T directions. If repeatS is TRUE (the default), the texture map is repeated - /// outside the [0.0, 1.0] texture coordinate range in the S direction so that it fills the shape. If repeatS is FALSE, the texture coordinates are - /// clamped in the S direction to lie within the [0.0, 1.0] range. The repeatT field is analogous to the repeatS field. - bool RepeatS; - bool RepeatT;///< See \ref RepeatS. - std::string URL;///< URL of the texture. - /// \fn CX3DImporter_NodeElement_ImageTexture(CX3DImporter_NodeElement_ImageTexture* pParent) - /// Constructor - /// \param [in] pParent - pointer to parent node. - CX3DImporter_NodeElement_ImageTexture(CX3DImporter_NodeElement* pParent) - : CX3DImporter_NodeElement(ENET_ImageTexture, pParent) - {} +struct X3DImageTexture : public X3DNodeElementBase { + /// RepeatS and RepeatT, that specify how the texture wraps in the S and T directions. If repeatS is TRUE (the default), the texture map is repeated + /// outside the [0.0, 1.0] texture coordinate range in the S direction so that it fills the shape. If repeatS is FALSE, the texture coordinates are + /// clamped in the S direction to lie within the [0.0, 1.0] range. The repeatT field is analogous to the repeatS field. + bool RepeatS; + bool RepeatT; ///< See \ref RepeatS. + std::string URL; ///< URL of the texture. -};// struct CX3DImporter_NodeElement_ImageTexture + /// Constructor + /// \param [in] pParent - pointer to parent node. + X3DImageTexture(X3DNodeElementBase *pParent) : + X3DNodeElementBase(ENET_ImageTexture, pParent) {} +}; // struct CX3DImporter_NodeElement_ImageTexture -/// \struct CX3DImporter_NodeElement_TextureTransform /// This struct hold value. -struct CX3DImporter_NodeElement_TextureTransform : public CX3DImporter_NodeElement -{ - aiVector2D Center;///< Specifies a translation offset in texture coordinate space about which the rotation and scale fields are applied. - float Rotation;///< Specifies a rotation in angle base units of the texture coordinates about the center point after the scale has been applied. - aiVector2D Scale;///< Specifies a scaling factor in S and T of the texture coordinates about the center point. - aiVector2D Translation;///< Specifies a translation of the texture coordinates. +struct X3DTextureTransform : public X3DNodeElementBase { + aiVector2D Center; ///< Specifies a translation offset in texture coordinate space about which the rotation and scale fields are applied. + float Rotation; ///< Specifies a rotation in angle base units of the texture coordinates about the center point after the scale has been applied. + aiVector2D Scale; ///< Specifies a scaling factor in S and T of the texture coordinates about the center point. + aiVector2D Translation; ///< Specifies a translation of the texture coordinates. - /// \fn CX3DImporter_NodeElement_TextureTransform(CX3DImporter_NodeElement_TextureTransform* pParent) - /// Constructor - /// \param [in] pParent - pointer to parent node. - CX3DImporter_NodeElement_TextureTransform(CX3DImporter_NodeElement* pParent) - : CX3DImporter_NodeElement(ENET_TextureTransform, pParent) - {} + /// Constructor + /// \param [in] pParent - pointer to parent node. + X3DTextureTransform(X3DNodeElementBase *pParent) : + X3DNodeElementBase(ENET_TextureTransform, pParent) {} -};// struct CX3DImporter_NodeElement_TextureTransform +}; // struct CX3DImporter_NodeElement_TextureTransform -/// \struct CX3DImporter_NodeElement_Light /// This struct hold value. -struct CX3DImporter_NodeElement_Light : public CX3DImporter_NodeElement -{ - float AmbientIntensity;///< Specifies the intensity of the ambient emission from the light. - aiColor3D Color;///< specifies the spectral colour properties of both the direct and ambient light emission as an RGB value. - aiVector3D Direction;///< Specifies the direction vector of the illumination emanating from the light source in the local coordinate system. - /// \var Global - /// Field that determines whether the light is global or scoped. Global lights illuminate all objects that fall within their volume of lighting influence. - /// Scoped lights only illuminate objects that are in the same transformation hierarchy as the light. - bool Global; - float Intensity;///< Specifies the brightness of the direct emission from the light. - /// \var Attenuation - /// PointLight node's illumination falls off with distance as specified by three attenuation coefficients. The attenuation factor - /// is: "1 / max(attenuation[0] + attenuation[1] * r + attenuation[2] * r2, 1)", where r is the distance from the light to the surface being illuminated. - aiVector3D Attenuation; - aiVector3D Location;///< Specifies a translation offset of the centre point of the light source from the light's local coordinate system origin. - float Radius;///< Specifies the radial extent of the solid angle and the maximum distance from location that may be illuminated by the light source. - float BeamWidth;///< Specifies an inner solid angle in which the light source emits light at uniform full intensity. - float CutOffAngle;///< The light source's emission intensity drops off from the inner solid angle (beamWidth) to the outer solid angle (cutOffAngle). +struct X3DLight : public X3DNodeElementBase { + float AmbientIntensity; ///< Specifies the intensity of the ambient emission from the light. + aiColor3D Color; ///< specifies the spectral colour properties of both the direct and ambient light emission as an RGB value. + aiVector3D Direction; ///< Specifies the direction vector of the illumination emanating from the light source in the local coordinate system. + /// Field that determines whether the light is global or scoped. Global lights illuminate all objects that fall within their volume of lighting influence. + /// Scoped lights only illuminate objects that are in the same transformation hierarchy as the light. + bool Global; + float Intensity; ///< Specifies the brightness of the direct emission from the light. - /// \fn CX3DImporter_NodeElement_Light(EType pLightType, CX3DImporter_NodeElement* pParent) - /// Constructor - /// \param [in] pParent - pointer to parent node. - /// \param [in] pLightType - type of the light source. - CX3DImporter_NodeElement_Light(EType pLightType, CX3DImporter_NodeElement* pParent) - : CX3DImporter_NodeElement(pLightType, pParent) - {} + /// PointLight node's illumination falls off with distance as specified by three attenuation coefficients. The attenuation factor + /// is: "1 / max(attenuation[0] + attenuation[1] * r + attenuation[2] * r2, 1)", where r is the distance from the light to the surface being illuminated. + aiVector3D Attenuation; + aiVector3D Location; ///< Specifies a translation offset of the centre point of the light source from the light's local coordinate system origin. + float Radius; ///< Specifies the radial extent of the solid angle and the maximum distance from location that may be illuminated by the light source. + float BeamWidth; ///< Specifies an inner solid angle in which the light source emits light at uniform full intensity. + float CutOffAngle; ///< The light source's emission intensity drops off from the inner solid angle (beamWidth) to the outer solid angle (cutOffAngle). -};// struct CX3DImporter_NodeElement_Light + /// Constructor + /// \param [in] pParent - pointer to parent node. + /// \param [in] pLightType - type of the light source. + X3DLight(EType pLightType, X3DNodeElementBase *pParent) : + X3DNodeElementBase(pLightType, pParent) {} + +}; // struct CX3DImporter_NodeElement_Light #endif // INCLUDED_AI_X3D_IMPORTER_NODE_H diff --git a/code/AssetLib/X3D/X3DImporter_Postprocess.cpp b/code/AssetLib/X3D/X3DImporter_Postprocess.cpp index 993aff02c..3bb581d91 100644 --- a/code/AssetLib/X3D/X3DImporter_Postprocess.cpp +++ b/code/AssetLib/X3D/X3DImporter_Postprocess.cpp @@ -63,18 +63,18 @@ namespace Assimp aiMatrix4x4 X3DImporter::PostprocessHelper_Matrix_GlobalToCurrent() const { - CX3DImporter_NodeElement* cur_node; + X3DNodeElementBase* cur_node; std::list matr; aiMatrix4x4 out_matr; // starting walk from current element to root - cur_node = NodeElement_Cur; + cur_node = mNodeElementCur; if(cur_node != nullptr) { do { // if cur_node is group then store group transformation matrix in list. - if(cur_node->Type == CX3DImporter_NodeElement::ENET_Group) matr.push_back(((CX3DImporter_NodeElement_Group*)cur_node)->Transformation); + if(cur_node->Type == X3DNodeElementBase::ENET_Group) matr.push_back(((X3DGroup*)cur_node)->Transformation); cur_node = cur_node->Parent; } while(cur_node != nullptr); @@ -86,29 +86,29 @@ aiMatrix4x4 X3DImporter::PostprocessHelper_Matrix_GlobalToCurrent() const return out_matr; } -void X3DImporter::PostprocessHelper_CollectMetadata(const CX3DImporter_NodeElement& pNodeElement, std::list& pList) const +void X3DImporter::PostprocessHelper_CollectMetadata(const X3DNodeElementBase& pNodeElement, std::list& pList) const { // walk through childs and find for metadata. - for(std::list::const_iterator el_it = pNodeElement.Child.begin(); el_it != pNodeElement.Child.end(); ++el_it) + for(std::list::const_iterator el_it = pNodeElement.Child.begin(); el_it != pNodeElement.Child.end(); ++el_it) { - if(((*el_it)->Type == CX3DImporter_NodeElement::ENET_MetaBoolean) || ((*el_it)->Type == CX3DImporter_NodeElement::ENET_MetaDouble) || - ((*el_it)->Type == CX3DImporter_NodeElement::ENET_MetaFloat) || ((*el_it)->Type == CX3DImporter_NodeElement::ENET_MetaInteger) || - ((*el_it)->Type == CX3DImporter_NodeElement::ENET_MetaString)) + if(((*el_it)->Type == X3DNodeElementBase::ENET_MetaBoolean) || ((*el_it)->Type == X3DNodeElementBase::ENET_MetaDouble) || + ((*el_it)->Type == X3DNodeElementBase::ENET_MetaFloat) || ((*el_it)->Type == X3DNodeElementBase::ENET_MetaInteger) || + ((*el_it)->Type == X3DNodeElementBase::ENET_MetaString)) { pList.push_back(*el_it); } - else if((*el_it)->Type == CX3DImporter_NodeElement::ENET_MetaSet) + else if((*el_it)->Type == X3DNodeElementBase::ENET_MetaSet) { PostprocessHelper_CollectMetadata(**el_it, pList); } }// for(std::list::const_iterator el_it = pNodeElement.Child.begin(); el_it != pNodeElement.Child.end(); el_it++) } -bool X3DImporter::PostprocessHelper_ElementIsMetadata(const CX3DImporter_NodeElement::EType pType) const +bool X3DImporter::PostprocessHelper_ElementIsMetadata(const X3DNodeElementBase::EType pType) const { - if((pType == CX3DImporter_NodeElement::ENET_MetaBoolean) || (pType == CX3DImporter_NodeElement::ENET_MetaDouble) || - (pType == CX3DImporter_NodeElement::ENET_MetaFloat) || (pType == CX3DImporter_NodeElement::ENET_MetaInteger) || - (pType == CX3DImporter_NodeElement::ENET_MetaString) || (pType == CX3DImporter_NodeElement::ENET_MetaSet)) + if((pType == X3DNodeElementBase::ENET_MetaBoolean) || (pType == X3DNodeElementBase::ENET_MetaDouble) || + (pType == X3DNodeElementBase::ENET_MetaFloat) || (pType == X3DNodeElementBase::ENET_MetaInteger) || + (pType == X3DNodeElementBase::ENET_MetaString) || (pType == X3DNodeElementBase::ENET_MetaSet)) { return true; } @@ -118,20 +118,20 @@ bool X3DImporter::PostprocessHelper_ElementIsMetadata(const CX3DImporter_NodeEle } } -bool X3DImporter::PostprocessHelper_ElementIsMesh(const CX3DImporter_NodeElement::EType pType) const +bool X3DImporter::PostprocessHelper_ElementIsMesh(const X3DNodeElementBase::EType pType) const { - if((pType == CX3DImporter_NodeElement::ENET_Arc2D) || (pType == CX3DImporter_NodeElement::ENET_ArcClose2D) || - (pType == CX3DImporter_NodeElement::ENET_Box) || (pType == CX3DImporter_NodeElement::ENET_Circle2D) || - (pType == CX3DImporter_NodeElement::ENET_Cone) || (pType == CX3DImporter_NodeElement::ENET_Cylinder) || - (pType == CX3DImporter_NodeElement::ENET_Disk2D) || (pType == CX3DImporter_NodeElement::ENET_ElevationGrid) || - (pType == CX3DImporter_NodeElement::ENET_Extrusion) || (pType == CX3DImporter_NodeElement::ENET_IndexedFaceSet) || - (pType == CX3DImporter_NodeElement::ENET_IndexedLineSet) || (pType == CX3DImporter_NodeElement::ENET_IndexedTriangleFanSet) || - (pType == CX3DImporter_NodeElement::ENET_IndexedTriangleSet) || (pType == CX3DImporter_NodeElement::ENET_IndexedTriangleStripSet) || - (pType == CX3DImporter_NodeElement::ENET_PointSet) || (pType == CX3DImporter_NodeElement::ENET_LineSet) || - (pType == CX3DImporter_NodeElement::ENET_Polyline2D) || (pType == CX3DImporter_NodeElement::ENET_Polypoint2D) || - (pType == CX3DImporter_NodeElement::ENET_Rectangle2D) || (pType == CX3DImporter_NodeElement::ENET_Sphere) || - (pType == CX3DImporter_NodeElement::ENET_TriangleFanSet) || (pType == CX3DImporter_NodeElement::ENET_TriangleSet) || - (pType == CX3DImporter_NodeElement::ENET_TriangleSet2D) || (pType == CX3DImporter_NodeElement::ENET_TriangleStripSet)) + if((pType == X3DNodeElementBase::ENET_Arc2D) || (pType == X3DNodeElementBase::ENET_ArcClose2D) || + (pType == X3DNodeElementBase::ENET_Box) || (pType == X3DNodeElementBase::ENET_Circle2D) || + (pType == X3DNodeElementBase::ENET_Cone) || (pType == X3DNodeElementBase::ENET_Cylinder) || + (pType == X3DNodeElementBase::ENET_Disk2D) || (pType == X3DNodeElementBase::ENET_ElevationGrid) || + (pType == X3DNodeElementBase::ENET_Extrusion) || (pType == X3DNodeElementBase::ENET_IndexedFaceSet) || + (pType == X3DNodeElementBase::ENET_IndexedLineSet) || (pType == X3DNodeElementBase::ENET_IndexedTriangleFanSet) || + (pType == X3DNodeElementBase::ENET_IndexedTriangleSet) || (pType == X3DNodeElementBase::ENET_IndexedTriangleStripSet) || + (pType == X3DNodeElementBase::ENET_PointSet) || (pType == X3DNodeElementBase::ENET_LineSet) || + (pType == X3DNodeElementBase::ENET_Polyline2D) || (pType == X3DNodeElementBase::ENET_Polypoint2D) || + (pType == X3DNodeElementBase::ENET_Rectangle2D) || (pType == X3DNodeElementBase::ENET_Sphere) || + (pType == X3DNodeElementBase::ENET_TriangleFanSet) || (pType == X3DNodeElementBase::ENET_TriangleSet) || + (pType == X3DNodeElementBase::ENET_TriangleSet2D) || (pType == X3DNodeElementBase::ENET_TriangleStripSet)) { return true; } @@ -141,9 +141,9 @@ bool X3DImporter::PostprocessHelper_ElementIsMesh(const CX3DImporter_NodeElement } } -void X3DImporter::Postprocess_BuildLight(const CX3DImporter_NodeElement& pNodeElement, std::list& pSceneLightList) const +void X3DImporter::Postprocess_BuildLight(const X3DNodeElementBase& pNodeElement, std::list& pSceneLightList) const { - const CX3DImporter_NodeElement_Light& ne = *( ( CX3DImporter_NodeElement_Light* ) &pNodeElement ); + const X3DLight& ne = *( ( X3DLight* ) &pNodeElement ); aiMatrix4x4 transform_matr = PostprocessHelper_Matrix_GlobalToCurrent(); aiLight* new_light = new aiLight; @@ -153,12 +153,12 @@ void X3DImporter::Postprocess_BuildLight(const CX3DImporter_NodeElement& pNodeEl new_light->mColorSpecular = ne.Color * ne.Intensity; switch(pNodeElement.Type) { - case CX3DImporter_NodeElement::ENET_DirectionalLight: + case X3DNodeElementBase::ENET_DirectionalLight: new_light->mType = aiLightSource_DIRECTIONAL; new_light->mDirection = ne.Direction, new_light->mDirection *= transform_matr; break; - case CX3DImporter_NodeElement::ENET_PointLight: + case X3DNodeElementBase::ENET_PointLight: new_light->mType = aiLightSource_POINT; new_light->mPosition = ne.Location, new_light->mPosition *= transform_matr; new_light->mAttenuationConstant = ne.Attenuation.x; @@ -166,7 +166,7 @@ void X3DImporter::Postprocess_BuildLight(const CX3DImporter_NodeElement& pNodeEl new_light->mAttenuationQuadratic = ne.Attenuation.z; break; - case CX3DImporter_NodeElement::ENET_SpotLight: + case X3DNodeElementBase::ENET_SpotLight: new_light->mType = aiLightSource_SPOT; new_light->mPosition = ne.Location, new_light->mPosition *= transform_matr; new_light->mDirection = ne.Direction, new_light->mDirection *= transform_matr; @@ -184,7 +184,7 @@ void X3DImporter::Postprocess_BuildLight(const CX3DImporter_NodeElement& pNodeEl pSceneLightList.push_back(new_light); } -void X3DImporter::Postprocess_BuildMaterial(const CX3DImporter_NodeElement& pNodeElement, aiMaterial** pMaterial) const +void X3DImporter::Postprocess_BuildMaterial(const X3DNodeElementBase& pNodeElement, aiMaterial** pMaterial) const { // check argument if(pMaterial == nullptr) throw DeadlyImportError("Postprocess_BuildMaterial. pMaterial is nullptr."); @@ -194,13 +194,13 @@ void X3DImporter::Postprocess_BuildMaterial(const CX3DImporter_NodeElement& pNod aiMaterial& taimat = **pMaterial;// creating alias for convenience. // at this point pNodeElement point to node. Walk through childs and add all stored data. - for(std::list::const_iterator el_it = pNodeElement.Child.begin(); el_it != pNodeElement.Child.end(); ++el_it) + for(std::list::const_iterator el_it = pNodeElement.Child.begin(); el_it != pNodeElement.Child.end(); ++el_it) { - if((*el_it)->Type == CX3DImporter_NodeElement::ENET_Material) + if((*el_it)->Type == X3DNodeElementBase::ENET_Material) { aiColor3D tcol3; float tvalf; - CX3DImporter_NodeElement_Material& tnemat = *((CX3DImporter_NodeElement_Material*)*el_it); + X3DMaterial& tnemat = *((X3DMaterial*)*el_it); tcol3.r = tnemat.AmbientIntensity, tcol3.g = tnemat.AmbientIntensity, tcol3.b = tnemat.AmbientIntensity; taimat.AddProperty(&tcol3, 1, AI_MATKEY_COLOR_AMBIENT); @@ -213,9 +213,9 @@ void X3DImporter::Postprocess_BuildMaterial(const CX3DImporter_NodeElement& pNod tvalf = 1.0f - tnemat.Transparency; taimat.AddProperty(&tvalf, 1, AI_MATKEY_OPACITY); }// if((*el_it)->Type == CX3DImporter_NodeElement::ENET_Material) - else if((*el_it)->Type == CX3DImporter_NodeElement::ENET_ImageTexture) + else if((*el_it)->Type == X3DNodeElementBase::ENET_ImageTexture) { - CX3DImporter_NodeElement_ImageTexture& tnetex = *((CX3DImporter_NodeElement_ImageTexture*)*el_it); + X3DImageTexture& tnetex = *((X3DImageTexture*)*el_it); aiString url_str(tnetex.URL.c_str()); int mode = aiTextureOp_Multiply; @@ -224,10 +224,10 @@ void X3DImporter::Postprocess_BuildMaterial(const CX3DImporter_NodeElement& pNod taimat.AddProperty(&tnetex.RepeatT, 1, AI_MATKEY_MAPPINGMODE_V_DIFFUSE(0)); taimat.AddProperty(&mode, 1, AI_MATKEY_TEXOP_DIFFUSE(0)); }// else if((*el_it)->Type == CX3DImporter_NodeElement::ENET_ImageTexture) - else if((*el_it)->Type == CX3DImporter_NodeElement::ENET_TextureTransform) + else if((*el_it)->Type == X3DNodeElementBase::ENET_TextureTransform) { aiUVTransform trans; - CX3DImporter_NodeElement_TextureTransform& tnetextr = *((CX3DImporter_NodeElement_TextureTransform*)*el_it); + X3DTextureTransform& tnetextr = *((X3DTextureTransform*)*el_it); trans.mTranslation = tnetextr.Translation - tnetextr.Center; trans.mScaling = tnetextr.Scale; @@ -237,7 +237,7 @@ void X3DImporter::Postprocess_BuildMaterial(const CX3DImporter_NodeElement& pNod }// for(std::list::const_iterator el_it = pNodeElement.Child.begin(); el_it != pNodeElement.Child.end(); el_it++) } -void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeElement, aiMesh** pMesh) const +void X3DImporter::Postprocess_BuildMesh(const X3DNodeElementBase& pNodeElement, aiMesh** pMesh) const { // check argument if(pMesh == nullptr) throw DeadlyImportError("Postprocess_BuildMesh. pMesh is nullptr."); @@ -246,12 +246,12 @@ void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeEle /************************************************************************************************************************************/ /************************************************************ Geometry2D ************************************************************/ /************************************************************************************************************************************/ - if((pNodeElement.Type == CX3DImporter_NodeElement::ENET_Arc2D) || (pNodeElement.Type == CX3DImporter_NodeElement::ENET_ArcClose2D) || - (pNodeElement.Type == CX3DImporter_NodeElement::ENET_Circle2D) || (pNodeElement.Type == CX3DImporter_NodeElement::ENET_Disk2D) || - (pNodeElement.Type == CX3DImporter_NodeElement::ENET_Polyline2D) || (pNodeElement.Type == CX3DImporter_NodeElement::ENET_Polypoint2D) || - (pNodeElement.Type == CX3DImporter_NodeElement::ENET_Rectangle2D) || (pNodeElement.Type == CX3DImporter_NodeElement::ENET_TriangleSet2D)) + if((pNodeElement.Type == X3DNodeElementBase::ENET_Arc2D) || (pNodeElement.Type == X3DNodeElementBase::ENET_ArcClose2D) || + (pNodeElement.Type == X3DNodeElementBase::ENET_Circle2D) || (pNodeElement.Type == X3DNodeElementBase::ENET_Disk2D) || + (pNodeElement.Type == X3DNodeElementBase::ENET_Polyline2D) || (pNodeElement.Type == X3DNodeElementBase::ENET_Polypoint2D) || + (pNodeElement.Type == X3DNodeElementBase::ENET_Rectangle2D) || (pNodeElement.Type == X3DNodeElementBase::ENET_TriangleSet2D)) { - CX3DImporter_NodeElement_Geometry2D& tnemesh = *((CX3DImporter_NodeElement_Geometry2D*)&pNodeElement);// create alias for convenience + X3DGeometry2D& tnemesh = *((X3DGeometry2D*)&pNodeElement);// create alias for convenience std::vector tarr; tarr.reserve(tnemesh.Vertices.size()); @@ -266,10 +266,10 @@ void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeEle // // Predefined figures // - if((pNodeElement.Type == CX3DImporter_NodeElement::ENET_Box) || (pNodeElement.Type == CX3DImporter_NodeElement::ENET_Cone) || - (pNodeElement.Type == CX3DImporter_NodeElement::ENET_Cylinder) || (pNodeElement.Type == CX3DImporter_NodeElement::ENET_Sphere)) + if((pNodeElement.Type == X3DNodeElementBase::ENET_Box) || (pNodeElement.Type == X3DNodeElementBase::ENET_Cone) || + (pNodeElement.Type == X3DNodeElementBase::ENET_Cylinder) || (pNodeElement.Type == X3DNodeElementBase::ENET_Sphere)) { - CX3DImporter_NodeElement_Geometry3D& tnemesh = *((CX3DImporter_NodeElement_Geometry3D*)&pNodeElement);// create alias for convenience + X3DGeometry3D& tnemesh = *((X3DGeometry3D*)&pNodeElement);// create alias for convenience std::vector tarr; tarr.reserve(tnemesh.Vertices.size()); @@ -282,23 +282,23 @@ void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeEle // // Parametric figures // - if(pNodeElement.Type == CX3DImporter_NodeElement::ENET_ElevationGrid) + if(pNodeElement.Type == X3DNodeElementBase::ENET_ElevationGrid) { - CX3DImporter_NodeElement_ElevationGrid& tnemesh = *((CX3DImporter_NodeElement_ElevationGrid*)&pNodeElement);// create alias for convenience + X3DElevationGrid& tnemesh = *((X3DElevationGrid*)&pNodeElement);// create alias for convenience // at first create mesh from existing vertices. *pMesh = GeometryHelper_MakeMesh(tnemesh.CoordIdx, tnemesh.Vertices); // copy additional information from children - for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ++ch_it) + for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ++ch_it) { - if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Color) - MeshGeometry_AddColor(**pMesh, ((CX3DImporter_NodeElement_Color*)*ch_it)->Value, tnemesh.ColorPerVertex); - else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_ColorRGBA) - MeshGeometry_AddColor(**pMesh, ((CX3DImporter_NodeElement_ColorRGBA*)*ch_it)->Value, tnemesh.ColorPerVertex); - else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Normal) - MeshGeometry_AddNormal(**pMesh, ((CX3DImporter_NodeElement_Normal*)*ch_it)->Value, tnemesh.NormalPerVertex); - else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_TextureCoordinate) - MeshGeometry_AddTexCoord(**pMesh, ((CX3DImporter_NodeElement_TextureCoordinate*)*ch_it)->Value); + if((*ch_it)->Type == X3DNodeElementBase::ENET_Color) + MeshGeometry_AddColor(**pMesh, ((X3DColor*)*ch_it)->Value, tnemesh.ColorPerVertex); + else if((*ch_it)->Type == X3DNodeElementBase::ENET_ColorRGBA) + MeshGeometry_AddColor(**pMesh, ((X3DColorRGBA*)*ch_it)->Value, tnemesh.ColorPerVertex); + else if((*ch_it)->Type == X3DNodeElementBase::ENET_Normal) + MeshGeometry_AddNormal(**pMesh, ((X3DNormal*)*ch_it)->Value, tnemesh.NormalPerVertex); + else if((*ch_it)->Type == X3DNodeElementBase::ENET_TextureCoordinate) + MeshGeometry_AddTexCoord(**pMesh, ((X3DTextureCoordinate*)*ch_it)->Value); else throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of ElevationGrid: " + to_string((*ch_it)->Type) + "."); }// for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ++ch_it) @@ -308,34 +308,34 @@ void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeEle // // Indexed primitives sets // - if(pNodeElement.Type == CX3DImporter_NodeElement::ENET_IndexedFaceSet) + if(pNodeElement.Type == X3DNodeElementBase::ENET_IndexedFaceSet) { - CX3DImporter_NodeElement_IndexedSet& tnemesh = *((CX3DImporter_NodeElement_IndexedSet*)&pNodeElement);// create alias for convenience + X3DIndexedSet& tnemesh = *((X3DIndexedSet*)&pNodeElement);// create alias for convenience // at first search for node and create mesh. - for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ++ch_it) + for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ++ch_it) { - if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Coordinate) + if((*ch_it)->Type == X3DNodeElementBase::ENET_Coordinate) { - *pMesh = GeometryHelper_MakeMesh(tnemesh.CoordIndex, ((CX3DImporter_NodeElement_Coordinate*)*ch_it)->Value); + *pMesh = GeometryHelper_MakeMesh(tnemesh.CoordIndex, ((X3DCoordinate*)*ch_it)->Value); } } // copy additional information from children - for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ++ch_it) + for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ++ch_it) { - if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Color) - MeshGeometry_AddColor(**pMesh, tnemesh.CoordIndex, tnemesh.ColorIndex, ((CX3DImporter_NodeElement_Color*)*ch_it)->Value, tnemesh.ColorPerVertex); - else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_ColorRGBA) - MeshGeometry_AddColor(**pMesh, tnemesh.CoordIndex, tnemesh.ColorIndex, ((CX3DImporter_NodeElement_ColorRGBA*)*ch_it)->Value, + if((*ch_it)->Type == X3DNodeElementBase::ENET_Color) + MeshGeometry_AddColor(**pMesh, tnemesh.CoordIndex, tnemesh.ColorIndex, ((X3DColor*)*ch_it)->Value, tnemesh.ColorPerVertex); + else if((*ch_it)->Type == X3DNodeElementBase::ENET_ColorRGBA) + MeshGeometry_AddColor(**pMesh, tnemesh.CoordIndex, tnemesh.ColorIndex, ((X3DColorRGBA*)*ch_it)->Value, tnemesh.ColorPerVertex); - else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Coordinate) + else if((*ch_it)->Type == X3DNodeElementBase::ENET_Coordinate) {} // skip because already read when mesh created. - else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Normal) - MeshGeometry_AddNormal(**pMesh, tnemesh.CoordIndex, tnemesh.NormalIndex, ((CX3DImporter_NodeElement_Normal*)*ch_it)->Value, + else if((*ch_it)->Type == X3DNodeElementBase::ENET_Normal) + MeshGeometry_AddNormal(**pMesh, tnemesh.CoordIndex, tnemesh.NormalIndex, ((X3DNormal*)*ch_it)->Value, tnemesh.NormalPerVertex); - else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_TextureCoordinate) - MeshGeometry_AddTexCoord(**pMesh, tnemesh.CoordIndex, tnemesh.TexCoordIndex, ((CX3DImporter_NodeElement_TextureCoordinate*)*ch_it)->Value); + else if((*ch_it)->Type == X3DNodeElementBase::ENET_TextureCoordinate) + MeshGeometry_AddTexCoord(**pMesh, tnemesh.CoordIndex, tnemesh.TexCoordIndex, ((X3DTextureCoordinate*)*ch_it)->Value); else throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of IndexedFaceSet: " + to_string((*ch_it)->Type) + "."); }// for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ++ch_it) @@ -343,29 +343,29 @@ void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeEle return;// mesh is build, nothing to do anymore. }// if(pNodeElement.Type == CX3DImporter_NodeElement::ENET_IndexedFaceSet) - if(pNodeElement.Type == CX3DImporter_NodeElement::ENET_IndexedLineSet) + if(pNodeElement.Type == X3DNodeElementBase::ENET_IndexedLineSet) { - CX3DImporter_NodeElement_IndexedSet& tnemesh = *((CX3DImporter_NodeElement_IndexedSet*)&pNodeElement);// create alias for convenience + X3DIndexedSet& tnemesh = *((X3DIndexedSet*)&pNodeElement);// create alias for convenience // at first search for node and create mesh. - for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ++ch_it) + for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ++ch_it) { - if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Coordinate) + if((*ch_it)->Type == X3DNodeElementBase::ENET_Coordinate) { - *pMesh = GeometryHelper_MakeMesh(tnemesh.CoordIndex, ((CX3DImporter_NodeElement_Coordinate*)*ch_it)->Value); + *pMesh = GeometryHelper_MakeMesh(tnemesh.CoordIndex, ((X3DCoordinate*)*ch_it)->Value); } } // copy additional information from children - for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ++ch_it) + for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ++ch_it) { ai_assert(*pMesh); - if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Color) - MeshGeometry_AddColor(**pMesh, tnemesh.CoordIndex, tnemesh.ColorIndex, ((CX3DImporter_NodeElement_Color*)*ch_it)->Value, tnemesh.ColorPerVertex); - else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_ColorRGBA) - MeshGeometry_AddColor(**pMesh, tnemesh.CoordIndex, tnemesh.ColorIndex, ((CX3DImporter_NodeElement_ColorRGBA*)*ch_it)->Value, + if((*ch_it)->Type == X3DNodeElementBase::ENET_Color) + MeshGeometry_AddColor(**pMesh, tnemesh.CoordIndex, tnemesh.ColorIndex, ((X3DColor*)*ch_it)->Value, tnemesh.ColorPerVertex); + else if((*ch_it)->Type == X3DNodeElementBase::ENET_ColorRGBA) + MeshGeometry_AddColor(**pMesh, tnemesh.CoordIndex, tnemesh.ColorIndex, ((X3DColorRGBA*)*ch_it)->Value, tnemesh.ColorPerVertex); - else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Coordinate) + else if((*ch_it)->Type == X3DNodeElementBase::ENET_Coordinate) {} // skip because already read when mesh created. else throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of IndexedLineSet: " + to_string((*ch_it)->Type) + "."); @@ -374,37 +374,37 @@ void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeEle return;// mesh is build, nothing to do anymore. }// if(pNodeElement.Type == CX3DImporter_NodeElement::ENET_IndexedLineSet) - if((pNodeElement.Type == CX3DImporter_NodeElement::ENET_IndexedTriangleSet) || - (pNodeElement.Type == CX3DImporter_NodeElement::ENET_IndexedTriangleFanSet) || - (pNodeElement.Type == CX3DImporter_NodeElement::ENET_IndexedTriangleStripSet)) + if((pNodeElement.Type == X3DNodeElementBase::ENET_IndexedTriangleSet) || + (pNodeElement.Type == X3DNodeElementBase::ENET_IndexedTriangleFanSet) || + (pNodeElement.Type == X3DNodeElementBase::ENET_IndexedTriangleStripSet)) { - CX3DImporter_NodeElement_IndexedSet& tnemesh = *((CX3DImporter_NodeElement_IndexedSet*)&pNodeElement);// create alias for convenience + X3DIndexedSet& tnemesh = *((X3DIndexedSet*)&pNodeElement);// create alias for convenience // at first search for node and create mesh. - for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ++ch_it) + for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ++ch_it) { - if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Coordinate) + if((*ch_it)->Type == X3DNodeElementBase::ENET_Coordinate) { - *pMesh = GeometryHelper_MakeMesh(tnemesh.CoordIndex, ((CX3DImporter_NodeElement_Coordinate*)*ch_it)->Value); + *pMesh = GeometryHelper_MakeMesh(tnemesh.CoordIndex, ((X3DCoordinate*)*ch_it)->Value); } } // copy additional information from children - for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ++ch_it) + for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ++ch_it) { ai_assert(*pMesh); - if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Color) - MeshGeometry_AddColor(**pMesh, tnemesh.CoordIndex, tnemesh.ColorIndex, ((CX3DImporter_NodeElement_Color*)*ch_it)->Value, tnemesh.ColorPerVertex); - else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_ColorRGBA) - MeshGeometry_AddColor(**pMesh, tnemesh.CoordIndex, tnemesh.ColorIndex, ((CX3DImporter_NodeElement_ColorRGBA*)*ch_it)->Value, + if((*ch_it)->Type == X3DNodeElementBase::ENET_Color) + MeshGeometry_AddColor(**pMesh, tnemesh.CoordIndex, tnemesh.ColorIndex, ((X3DColor*)*ch_it)->Value, tnemesh.ColorPerVertex); + else if((*ch_it)->Type == X3DNodeElementBase::ENET_ColorRGBA) + MeshGeometry_AddColor(**pMesh, tnemesh.CoordIndex, tnemesh.ColorIndex, ((X3DColorRGBA*)*ch_it)->Value, tnemesh.ColorPerVertex); - else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Coordinate) + else if((*ch_it)->Type == X3DNodeElementBase::ENET_Coordinate) {} // skip because already read when mesh created. - else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Normal) - MeshGeometry_AddNormal(**pMesh, tnemesh.CoordIndex, tnemesh.NormalIndex, ((CX3DImporter_NodeElement_Normal*)*ch_it)->Value, + else if((*ch_it)->Type == X3DNodeElementBase::ENET_Normal) + MeshGeometry_AddNormal(**pMesh, tnemesh.CoordIndex, tnemesh.NormalIndex, ((X3DNormal*)*ch_it)->Value, tnemesh.NormalPerVertex); - else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_TextureCoordinate) - MeshGeometry_AddTexCoord(**pMesh, tnemesh.CoordIndex, tnemesh.TexCoordIndex, ((CX3DImporter_NodeElement_TextureCoordinate*)*ch_it)->Value); + else if((*ch_it)->Type == X3DNodeElementBase::ENET_TextureCoordinate) + MeshGeometry_AddTexCoord(**pMesh, tnemesh.CoordIndex, tnemesh.TexCoordIndex, ((X3DTextureCoordinate*)*ch_it)->Value); else throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of IndexedTriangleSet or IndexedTriangleFanSet, or \ IndexedTriangleStripSet: " + to_string((*ch_it)->Type) + "."); @@ -413,9 +413,9 @@ void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeEle return;// mesh is build, nothing to do anymore. }// if((pNodeElement.Type == CX3DImporter_NodeElement::ENET_IndexedTriangleFanSet) || (pNodeElement.Type == CX3DImporter_NodeElement::ENET_IndexedTriangleStripSet)) - if(pNodeElement.Type == CX3DImporter_NodeElement::ENET_Extrusion) + if(pNodeElement.Type == X3DNodeElementBase::ENET_Extrusion) { - CX3DImporter_NodeElement_IndexedSet& tnemesh = *((CX3DImporter_NodeElement_IndexedSet*)&pNodeElement);// create alias for convenience + X3DIndexedSet& tnemesh = *((X3DIndexedSet*)&pNodeElement);// create alias for convenience *pMesh = GeometryHelper_MakeMesh(tnemesh.CoordIndex, tnemesh.Vertices); @@ -425,20 +425,20 @@ void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeEle // // Primitives sets // - if(pNodeElement.Type == CX3DImporter_NodeElement::ENET_PointSet) + if(pNodeElement.Type == X3DNodeElementBase::ENET_PointSet) { - CX3DImporter_NodeElement_Set& tnemesh = *((CX3DImporter_NodeElement_Set*)&pNodeElement);// create alias for convenience + X3DSet& tnemesh = *((X3DSet*)&pNodeElement);// create alias for convenience // at first search for node and create mesh. - for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ++ch_it) + for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ++ch_it) { - if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Coordinate) + if((*ch_it)->Type == X3DNodeElementBase::ENET_Coordinate) { std::vector vec_copy; - vec_copy.reserve(((CX3DImporter_NodeElement_Coordinate*)*ch_it)->Value.size()); - for(std::list::const_iterator it = ((CX3DImporter_NodeElement_Coordinate*)*ch_it)->Value.begin(); - it != ((CX3DImporter_NodeElement_Coordinate*)*ch_it)->Value.end(); ++it) + vec_copy.reserve(((X3DCoordinate*)*ch_it)->Value.size()); + for(std::list::const_iterator it = ((X3DCoordinate*)*ch_it)->Value.begin(); + it != ((X3DCoordinate*)*ch_it)->Value.end(); ++it) { vec_copy.push_back(*it); } @@ -448,14 +448,14 @@ void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeEle } // copy additional information from children - for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ++ch_it) + for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ++ch_it) { ai_assert(*pMesh); - if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Color) - MeshGeometry_AddColor(**pMesh, ((CX3DImporter_NodeElement_Color*)*ch_it)->Value, true); - else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_ColorRGBA) - MeshGeometry_AddColor(**pMesh, ((CX3DImporter_NodeElement_ColorRGBA*)*ch_it)->Value, true); - else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Coordinate) + if((*ch_it)->Type == X3DNodeElementBase::ENET_Color) + MeshGeometry_AddColor(**pMesh, ((X3DColor*)*ch_it)->Value, true); + else if((*ch_it)->Type == X3DNodeElementBase::ENET_ColorRGBA) + MeshGeometry_AddColor(**pMesh, ((X3DColorRGBA*)*ch_it)->Value, true); + else if((*ch_it)->Type == X3DNodeElementBase::ENET_Coordinate) {} // skip because already read when mesh created. else throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of PointSet: " + to_string((*ch_it)->Type) + "."); @@ -464,28 +464,28 @@ void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeEle return;// mesh is build, nothing to do anymore. }// if(pNodeElement.Type == CX3DImporter_NodeElement::ENET_PointSet) - if(pNodeElement.Type == CX3DImporter_NodeElement::ENET_LineSet) + if(pNodeElement.Type == X3DNodeElementBase::ENET_LineSet) { - CX3DImporter_NodeElement_Set& tnemesh = *((CX3DImporter_NodeElement_Set*)&pNodeElement);// create alias for convenience + X3DSet& tnemesh = *((X3DSet*)&pNodeElement);// create alias for convenience // at first search for node and create mesh. - for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ++ch_it) + for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ++ch_it) { - if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Coordinate) + if((*ch_it)->Type == X3DNodeElementBase::ENET_Coordinate) { - *pMesh = GeometryHelper_MakeMesh(tnemesh.CoordIndex, ((CX3DImporter_NodeElement_Coordinate*)*ch_it)->Value); + *pMesh = GeometryHelper_MakeMesh(tnemesh.CoordIndex, ((X3DCoordinate*)*ch_it)->Value); } } // copy additional information from children - for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ++ch_it) + for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ++ch_it) { ai_assert(*pMesh); - if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Color) - MeshGeometry_AddColor(**pMesh, ((CX3DImporter_NodeElement_Color*)*ch_it)->Value, true); - else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_ColorRGBA) - MeshGeometry_AddColor(**pMesh, ((CX3DImporter_NodeElement_ColorRGBA*)*ch_it)->Value, true); - else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Coordinate) + if((*ch_it)->Type == X3DNodeElementBase::ENET_Color) + MeshGeometry_AddColor(**pMesh, ((X3DColor*)*ch_it)->Value, true); + else if((*ch_it)->Type == X3DNodeElementBase::ENET_ColorRGBA) + MeshGeometry_AddColor(**pMesh, ((X3DColorRGBA*)*ch_it)->Value, true); + else if((*ch_it)->Type == X3DNodeElementBase::ENET_Coordinate) {} // skip because already read when mesh created. else throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of LineSet: " + to_string((*ch_it)->Type) + "."); @@ -494,36 +494,36 @@ void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeEle return;// mesh is build, nothing to do anymore. }// if(pNodeElement.Type == CX3DImporter_NodeElement::ENET_LineSet) - if(pNodeElement.Type == CX3DImporter_NodeElement::ENET_TriangleFanSet) + if(pNodeElement.Type == X3DNodeElementBase::ENET_TriangleFanSet) { - CX3DImporter_NodeElement_Set& tnemesh = *((CX3DImporter_NodeElement_Set*)&pNodeElement);// create alias for convenience + X3DSet& tnemesh = *((X3DSet*)&pNodeElement);// create alias for convenience // at first search for node and create mesh. - for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ++ch_it) + for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ++ch_it) { - if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Coordinate) + if((*ch_it)->Type == X3DNodeElementBase::ENET_Coordinate) { - *pMesh = GeometryHelper_MakeMesh(tnemesh.CoordIndex, ((CX3DImporter_NodeElement_Coordinate*)*ch_it)->Value); + *pMesh = GeometryHelper_MakeMesh(tnemesh.CoordIndex, ((X3DCoordinate*)*ch_it)->Value); } } // copy additional information from children - for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ++ch_it) + for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ++ch_it) { if ( nullptr == *pMesh ) { break; } - if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Color) - MeshGeometry_AddColor(**pMesh, ((CX3DImporter_NodeElement_Color*)*ch_it)->Value,tnemesh.ColorPerVertex); - else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_ColorRGBA) - MeshGeometry_AddColor(**pMesh, ((CX3DImporter_NodeElement_ColorRGBA*)*ch_it)->Value, tnemesh.ColorPerVertex); - else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Coordinate) + if((*ch_it)->Type == X3DNodeElementBase::ENET_Color) + MeshGeometry_AddColor(**pMesh, ((X3DColor*)*ch_it)->Value,tnemesh.ColorPerVertex); + else if((*ch_it)->Type == X3DNodeElementBase::ENET_ColorRGBA) + MeshGeometry_AddColor(**pMesh, ((X3DColorRGBA*)*ch_it)->Value, tnemesh.ColorPerVertex); + else if((*ch_it)->Type == X3DNodeElementBase::ENET_Coordinate) {} // skip because already read when mesh created. - else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Normal) - MeshGeometry_AddNormal(**pMesh, tnemesh.CoordIndex, tnemesh.NormalIndex, ((CX3DImporter_NodeElement_Normal*)*ch_it)->Value, + else if((*ch_it)->Type == X3DNodeElementBase::ENET_Normal) + MeshGeometry_AddNormal(**pMesh, tnemesh.CoordIndex, tnemesh.NormalIndex, ((X3DNormal*)*ch_it)->Value, tnemesh.NormalPerVertex); - else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_TextureCoordinate) - MeshGeometry_AddTexCoord(**pMesh, tnemesh.CoordIndex, tnemesh.TexCoordIndex, ((CX3DImporter_NodeElement_TextureCoordinate*)*ch_it)->Value); + else if((*ch_it)->Type == X3DNodeElementBase::ENET_TextureCoordinate) + MeshGeometry_AddTexCoord(**pMesh, tnemesh.CoordIndex, tnemesh.TexCoordIndex, ((X3DTextureCoordinate*)*ch_it)->Value); else throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of TrianlgeFanSet: " + to_string((*ch_it)->Type) + "."); }// for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ++ch_it) @@ -531,20 +531,20 @@ void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeEle return;// mesh is build, nothing to do anymore. }// if(pNodeElement.Type == CX3DImporter_NodeElement::ENET_TriangleFanSet) - if(pNodeElement.Type == CX3DImporter_NodeElement::ENET_TriangleSet) + if(pNodeElement.Type == X3DNodeElementBase::ENET_TriangleSet) { - CX3DImporter_NodeElement_Set& tnemesh = *((CX3DImporter_NodeElement_Set*)&pNodeElement);// create alias for convenience + X3DSet& tnemesh = *((X3DSet*)&pNodeElement);// create alias for convenience // at first search for node and create mesh. - for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ++ch_it) + for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ++ch_it) { - if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Coordinate) + if((*ch_it)->Type == X3DNodeElementBase::ENET_Coordinate) { std::vector vec_copy; - vec_copy.reserve(((CX3DImporter_NodeElement_Coordinate*)*ch_it)->Value.size()); - for(std::list::const_iterator it = ((CX3DImporter_NodeElement_Coordinate*)*ch_it)->Value.begin(); - it != ((CX3DImporter_NodeElement_Coordinate*)*ch_it)->Value.end(); ++it) + vec_copy.reserve(((X3DCoordinate*)*ch_it)->Value.size()); + for(std::list::const_iterator it = ((X3DCoordinate*)*ch_it)->Value.begin(); + it != ((X3DCoordinate*)*ch_it)->Value.end(); ++it) { vec_copy.push_back(*it); } @@ -554,20 +554,20 @@ void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeEle } // copy additional information from children - for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ++ch_it) + for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ++ch_it) { ai_assert(*pMesh); - if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Color) - MeshGeometry_AddColor(**pMesh, ((CX3DImporter_NodeElement_Color*)*ch_it)->Value, tnemesh.ColorPerVertex); - else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_ColorRGBA) - MeshGeometry_AddColor(**pMesh, ((CX3DImporter_NodeElement_ColorRGBA*)*ch_it)->Value, tnemesh.ColorPerVertex); - else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Coordinate) + if((*ch_it)->Type == X3DNodeElementBase::ENET_Color) + MeshGeometry_AddColor(**pMesh, ((X3DColor*)*ch_it)->Value, tnemesh.ColorPerVertex); + else if((*ch_it)->Type == X3DNodeElementBase::ENET_ColorRGBA) + MeshGeometry_AddColor(**pMesh, ((X3DColorRGBA*)*ch_it)->Value, tnemesh.ColorPerVertex); + else if((*ch_it)->Type == X3DNodeElementBase::ENET_Coordinate) {} // skip because already read when mesh created. - else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Normal) - MeshGeometry_AddNormal(**pMesh, tnemesh.CoordIndex, tnemesh.NormalIndex, ((CX3DImporter_NodeElement_Normal*)*ch_it)->Value, + else if((*ch_it)->Type == X3DNodeElementBase::ENET_Normal) + MeshGeometry_AddNormal(**pMesh, tnemesh.CoordIndex, tnemesh.NormalIndex, ((X3DNormal*)*ch_it)->Value, tnemesh.NormalPerVertex); - else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_TextureCoordinate) - MeshGeometry_AddTexCoord(**pMesh, tnemesh.CoordIndex, tnemesh.TexCoordIndex, ((CX3DImporter_NodeElement_TextureCoordinate*)*ch_it)->Value); + else if((*ch_it)->Type == X3DNodeElementBase::ENET_TextureCoordinate) + MeshGeometry_AddTexCoord(**pMesh, tnemesh.CoordIndex, tnemesh.TexCoordIndex, ((X3DTextureCoordinate*)*ch_it)->Value); else throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of TrianlgeSet: " + to_string((*ch_it)->Type) + "."); }// for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ++ch_it) @@ -575,34 +575,34 @@ void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeEle return;// mesh is build, nothing to do anymore. }// if(pNodeElement.Type == CX3DImporter_NodeElement::ENET_TriangleSet) - if(pNodeElement.Type == CX3DImporter_NodeElement::ENET_TriangleStripSet) + if(pNodeElement.Type == X3DNodeElementBase::ENET_TriangleStripSet) { - CX3DImporter_NodeElement_Set& tnemesh = *((CX3DImporter_NodeElement_Set*)&pNodeElement);// create alias for convenience + X3DSet& tnemesh = *((X3DSet*)&pNodeElement);// create alias for convenience // at first search for node and create mesh. - for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ++ch_it) + for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ++ch_it) { - if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Coordinate) + if((*ch_it)->Type == X3DNodeElementBase::ENET_Coordinate) { - *pMesh = GeometryHelper_MakeMesh(tnemesh.CoordIndex, ((CX3DImporter_NodeElement_Coordinate*)*ch_it)->Value); + *pMesh = GeometryHelper_MakeMesh(tnemesh.CoordIndex, ((X3DCoordinate*)*ch_it)->Value); } } // copy additional information from children - for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ++ch_it) + for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ++ch_it) { ai_assert(*pMesh); - if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Color) - MeshGeometry_AddColor(**pMesh, ((CX3DImporter_NodeElement_Color*)*ch_it)->Value, tnemesh.ColorPerVertex); - else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_ColorRGBA) - MeshGeometry_AddColor(**pMesh, ((CX3DImporter_NodeElement_ColorRGBA*)*ch_it)->Value, tnemesh.ColorPerVertex); - else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Coordinate) + if((*ch_it)->Type == X3DNodeElementBase::ENET_Color) + MeshGeometry_AddColor(**pMesh, ((X3DColor*)*ch_it)->Value, tnemesh.ColorPerVertex); + else if((*ch_it)->Type == X3DNodeElementBase::ENET_ColorRGBA) + MeshGeometry_AddColor(**pMesh, ((X3DColorRGBA*)*ch_it)->Value, tnemesh.ColorPerVertex); + else if((*ch_it)->Type == X3DNodeElementBase::ENET_Coordinate) {} // skip because already read when mesh created. - else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Normal) - MeshGeometry_AddNormal(**pMesh, tnemesh.CoordIndex, tnemesh.NormalIndex, ((CX3DImporter_NodeElement_Normal*)*ch_it)->Value, + else if((*ch_it)->Type == X3DNodeElementBase::ENET_Normal) + MeshGeometry_AddNormal(**pMesh, tnemesh.CoordIndex, tnemesh.NormalIndex, ((X3DNormal*)*ch_it)->Value, tnemesh.NormalPerVertex); - else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_TextureCoordinate) - MeshGeometry_AddTexCoord(**pMesh, tnemesh.CoordIndex, tnemesh.TexCoordIndex, ((CX3DImporter_NodeElement_TextureCoordinate*)*ch_it)->Value); + else if((*ch_it)->Type == X3DNodeElementBase::ENET_TextureCoordinate) + MeshGeometry_AddTexCoord(**pMesh, tnemesh.CoordIndex, tnemesh.TexCoordIndex, ((X3DTextureCoordinate*)*ch_it)->Value); else throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of TriangleStripSet: " + to_string((*ch_it)->Type) + "."); }// for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ++ch_it) @@ -613,20 +613,20 @@ void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeEle throw DeadlyImportError("Postprocess_BuildMesh. Unknown mesh type: " + to_string(pNodeElement.Type) + "."); } -void X3DImporter::Postprocess_BuildNode(const CX3DImporter_NodeElement& pNodeElement, aiNode& pSceneNode, std::list& pSceneMeshList, +void X3DImporter::Postprocess_BuildNode(const X3DNodeElementBase& pNodeElement, aiNode& pSceneNode, std::list& pSceneMeshList, std::list& pSceneMaterialList, std::list& pSceneLightList) const { - std::list::const_iterator chit_begin = pNodeElement.Child.begin(); - std::list::const_iterator chit_end = pNodeElement.Child.end(); + std::list::const_iterator chit_begin = pNodeElement.Child.begin(); + std::list::const_iterator chit_end = pNodeElement.Child.end(); std::list SceneNode_Child; std::list SceneNode_Mesh; // At first read all metadata Postprocess_CollectMetadata(pNodeElement, pSceneNode); // check if we have deal with grouping node. Which can contain transformation or switch - if(pNodeElement.Type == CX3DImporter_NodeElement::ENET_Group) + if(pNodeElement.Type == X3DNodeElementBase::ENET_Group) { - const CX3DImporter_NodeElement_Group& tne_group = *((CX3DImporter_NodeElement_Group*)&pNodeElement);// create alias for convenience + const X3DGroup& tne_group = *((X3DGroup*)&pNodeElement);// create alias for convenience pSceneNode.mTransformation = tne_group.Transformation; if(tne_group.UseChoice) @@ -648,9 +648,9 @@ void X3DImporter::Postprocess_BuildNode(const CX3DImporter_NodeElement& pNodeEle }// if(pNodeElement.Type == CX3DImporter_NodeElement::ENET_Group) // Reserve memory for fast access and check children. - for(std::list::const_iterator it = chit_begin; it != chit_end; ++it) + for(std::list::const_iterator it = chit_begin; it != chit_end; ++it) {// in this loop we do not read metadata because it's already read at begin. - if((*it)->Type == CX3DImporter_NodeElement::ENET_Group) + if((*it)->Type == X3DNodeElementBase::ENET_Group) { // if child is group then create new node and do recursive call. aiNode* new_node = new aiNode; @@ -660,15 +660,15 @@ void X3DImporter::Postprocess_BuildNode(const CX3DImporter_NodeElement& pNodeEle SceneNode_Child.push_back(new_node); Postprocess_BuildNode(**it, *new_node, pSceneMeshList, pSceneMaterialList, pSceneLightList); } - else if((*it)->Type == CX3DImporter_NodeElement::ENET_Shape) + else if((*it)->Type == X3DNodeElementBase::ENET_Shape) { // shape can contain only one geometry and one appearance nodes. - Postprocess_BuildShape(*((CX3DImporter_NodeElement_Shape*)*it), SceneNode_Mesh, pSceneMeshList, pSceneMaterialList); + Postprocess_BuildShape(*((X3DShape*)*it), SceneNode_Mesh, pSceneMeshList, pSceneMaterialList); } - else if(((*it)->Type == CX3DImporter_NodeElement::ENET_DirectionalLight) || ((*it)->Type == CX3DImporter_NodeElement::ENET_PointLight) || - ((*it)->Type == CX3DImporter_NodeElement::ENET_SpotLight)) + else if(((*it)->Type == X3DNodeElementBase::ENET_DirectionalLight) || ((*it)->Type == X3DNodeElementBase::ENET_PointLight) || + ((*it)->Type == X3DNodeElementBase::ENET_SpotLight)) { - Postprocess_BuildLight(*((CX3DImporter_NodeElement_Light*)*it), pSceneLightList); + Postprocess_BuildLight(*((X3DLight*)*it), pSceneLightList); } else if(!PostprocessHelper_ElementIsMetadata((*it)->Type))// skip metadata { @@ -698,15 +698,15 @@ void X3DImporter::Postprocess_BuildNode(const CX3DImporter_NodeElement& pNodeEle // that's all. return to previous deals } -void X3DImporter::Postprocess_BuildShape(const CX3DImporter_NodeElement_Shape& pShapeNodeElement, std::list& pNodeMeshInd, +void X3DImporter::Postprocess_BuildShape(const X3DShape& pShapeNodeElement, std::list& pNodeMeshInd, std::list& pSceneMeshList, std::list& pSceneMaterialList) const { aiMaterial* tmat = nullptr; aiMesh* tmesh = nullptr; - CX3DImporter_NodeElement::EType mesh_type = CX3DImporter_NodeElement::ENET_Invalid; + X3DNodeElementBase::EType mesh_type = X3DNodeElementBase::ENET_Invalid; unsigned int mat_ind = 0; - for(std::list::const_iterator it = pShapeNodeElement.Child.begin(); it != pShapeNodeElement.Child.end(); ++it) + for(std::list::const_iterator it = pShapeNodeElement.Child.begin(); it != pShapeNodeElement.Child.end(); ++it) { if(PostprocessHelper_ElementIsMesh((*it)->Type)) { @@ -720,7 +720,7 @@ void X3DImporter::Postprocess_BuildShape(const CX3DImporter_NodeElement_Shape& p mesh_type = (*it)->Type; } } - else if((*it)->Type == CX3DImporter_NodeElement::ENET_Appearance) + else if((*it)->Type == X3DNodeElementBase::ENET_Appearance) { Postprocess_BuildMaterial(**it, &tmat); if(tmat != nullptr) @@ -744,14 +744,14 @@ void X3DImporter::Postprocess_BuildShape(const CX3DImporter_NodeElement_Shape& p switch(mesh_type) { - case CX3DImporter_NodeElement::ENET_Box: + case X3DNodeElementBase::ENET_Box: tm = aiTextureMapping_BOX; break; - case CX3DImporter_NodeElement::ENET_Cone: - case CX3DImporter_NodeElement::ENET_Cylinder: + case X3DNodeElementBase::ENET_Cone: + case X3DNodeElementBase::ENET_Cylinder: tm = aiTextureMapping_CYLINDER; break; - case CX3DImporter_NodeElement::ENET_Sphere: + case X3DNodeElementBase::ENET_Sphere: tm = aiTextureMapping_SPHERE; break; default: @@ -764,9 +764,9 @@ void X3DImporter::Postprocess_BuildShape(const CX3DImporter_NodeElement_Shape& p }// if((tmesh != nullptr) && (tmat != nullptr)) } -void X3DImporter::Postprocess_CollectMetadata(const CX3DImporter_NodeElement& pNodeElement, aiNode& pSceneNode) const +void X3DImporter::Postprocess_CollectMetadata(const X3DNodeElementBase& pNodeElement, aiNode& pSceneNode) const { - std::list meta_list; + std::list meta_list; size_t meta_idx; PostprocessHelper_CollectMetadata(pNodeElement, meta_list);// find metadata in current node element. @@ -779,39 +779,39 @@ void X3DImporter::Postprocess_CollectMetadata(const CX3DImporter_NodeElement& pN // copy collected metadata to output node. pSceneNode.mMetaData = aiMetadata::Alloc( static_cast(meta_list.size()) ); meta_idx = 0; - for(std::list::const_iterator it = meta_list.begin(); it != meta_list.end(); ++it, ++meta_idx) + for(std::list::const_iterator it = meta_list.begin(); it != meta_list.end(); ++it, ++meta_idx) { - CX3DImporter_NodeElement_Meta* cur_meta = (CX3DImporter_NodeElement_Meta*)*it; + X3DMeta* cur_meta = (X3DMeta*)*it; // due to limitations we can add only first element of value list. // Add an element according to its type. - if((*it)->Type == CX3DImporter_NodeElement::ENET_MetaBoolean) + if((*it)->Type == X3DNodeElementBase::ENET_MetaBoolean) { - if(((CX3DImporter_NodeElement_MetaBoolean*)cur_meta)->Value.size() > 0) { - const bool v = (bool) *( ( (CX3DImporter_NodeElement_MetaBoolean*) cur_meta )->Value.begin()); + if(((X3DMetaBoolean*)cur_meta)->Value.size() > 0) { + const bool v = (bool) *( ( (X3DMetaBoolean*) cur_meta )->Value.begin()); pSceneNode.mMetaData->Set(static_cast(meta_idx), cur_meta->Name, v); } } - else if((*it)->Type == CX3DImporter_NodeElement::ENET_MetaDouble) + else if((*it)->Type == X3DNodeElementBase::ENET_MetaDouble) { - if(((CX3DImporter_NodeElement_MetaDouble*)cur_meta)->Value.size() > 0) - pSceneNode.mMetaData->Set(static_cast(meta_idx), cur_meta->Name, (float)*(((CX3DImporter_NodeElement_MetaDouble*)cur_meta)->Value.begin())); + if(((X3DMetaDouble*)cur_meta)->Value.size() > 0) + pSceneNode.mMetaData->Set(static_cast(meta_idx), cur_meta->Name, (float)*(((X3DMetaDouble*)cur_meta)->Value.begin())); } - else if((*it)->Type == CX3DImporter_NodeElement::ENET_MetaFloat) + else if((*it)->Type == X3DNodeElementBase::ENET_MetaFloat) { - if(((CX3DImporter_NodeElement_MetaFloat*)cur_meta)->Value.size() > 0) - pSceneNode.mMetaData->Set(static_cast(meta_idx), cur_meta->Name, *(((CX3DImporter_NodeElement_MetaFloat*)cur_meta)->Value.begin())); + if(((X3DMetaFloat*)cur_meta)->Value.size() > 0) + pSceneNode.mMetaData->Set(static_cast(meta_idx), cur_meta->Name, *(((X3DMetaFloat*)cur_meta)->Value.begin())); } - else if((*it)->Type == CX3DImporter_NodeElement::ENET_MetaInteger) + else if((*it)->Type == X3DNodeElementBase::ENET_MetaInteger) { - if(((CX3DImporter_NodeElement_MetaInteger*)cur_meta)->Value.size() > 0) - pSceneNode.mMetaData->Set(static_cast(meta_idx), cur_meta->Name, *(((CX3DImporter_NodeElement_MetaInteger*)cur_meta)->Value.begin())); + if(((X3DMetaInteger*)cur_meta)->Value.size() > 0) + pSceneNode.mMetaData->Set(static_cast(meta_idx), cur_meta->Name, *(((X3DMetaInteger*)cur_meta)->Value.begin())); } - else if((*it)->Type == CX3DImporter_NodeElement::ENET_MetaString) + else if((*it)->Type == X3DNodeElementBase::ENET_MetaString) { - if(((CX3DImporter_NodeElement_MetaString*)cur_meta)->Value.size() > 0) + if(((X3DMetaString*)cur_meta)->Value.size() > 0) { - aiString tstr(((CX3DImporter_NodeElement_MetaString*)cur_meta)->Value.begin()->data()); + aiString tstr(((X3DMetaString*)cur_meta)->Value.begin()->data()); pSceneNode.mMetaData->Set(static_cast(meta_idx), cur_meta->Name, tstr); } diff --git a/code/AssetLib/X3D/X3DImporter_Rendering.cpp b/code/AssetLib/X3D/X3DImporter_Rendering.cpp index a574d5549..6b3f2fd34 100644 --- a/code/AssetLib/X3D/X3DImporter_Rendering.cpp +++ b/code/AssetLib/X3D/X3DImporter_Rendering.cpp @@ -61,7 +61,7 @@ void X3DImporter::ParseNode_Rendering_Color() { std::string use, def; std::list color; - CX3DImporter_NodeElement* ne( nullptr ); + X3DNodeElementBase* ne( nullptr ); MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); @@ -76,15 +76,15 @@ void X3DImporter::ParseNode_Rendering_Color() else { // create and if needed - define new geometry object. - ne = new CX3DImporter_NodeElement_Color(NodeElement_Cur); + ne = new X3DColor(mNodeElementCur); if(!def.empty()) ne->ID = def; - ((CX3DImporter_NodeElement_Color*)ne)->Value = color; + ((X3DColor*)ne)->Value = color; // check for X3DMetadataObject childs. if(!mReader->isEmptyElement()) ParseNode_Metadata(ne, "Color"); else - NodeElement_Cur->Child.push_back(ne);// add made object as child to current element + mNodeElementCur->Child.push_back(ne);// add made object as child to current element NodeElement_List.push_back(ne);// add element to node element list because its a new object in graph }// if(!use.empty()) else @@ -99,7 +99,7 @@ void X3DImporter::ParseNode_Rendering_ColorRGBA() { std::string use, def; std::list color; - CX3DImporter_NodeElement* ne( nullptr ); + X3DNodeElementBase* ne( nullptr ); MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); @@ -114,15 +114,15 @@ void X3DImporter::ParseNode_Rendering_ColorRGBA() else { // create and if needed - define new geometry object. - ne = new CX3DImporter_NodeElement_ColorRGBA(NodeElement_Cur); + ne = new X3DColorRGBA(mNodeElementCur); if(!def.empty()) ne->ID = def; - ((CX3DImporter_NodeElement_ColorRGBA*)ne)->Value = color; + ((X3DColorRGBA*)ne)->Value = color; // check for X3DMetadataObject childs. if(!mReader->isEmptyElement()) ParseNode_Metadata(ne, "ColorRGBA"); else - NodeElement_Cur->Child.push_back(ne);// add made object as child to current element + mNodeElementCur->Child.push_back(ne);// add made object as child to current element NodeElement_List.push_back(ne);// add element to node element list because its a new object in graph }// if(!use.empty()) else @@ -137,7 +137,7 @@ void X3DImporter::ParseNode_Rendering_Coordinate() { std::string use, def; std::list point; - CX3DImporter_NodeElement* ne( nullptr ); + X3DNodeElementBase* ne( nullptr ); MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); @@ -152,15 +152,15 @@ void X3DImporter::ParseNode_Rendering_Coordinate() else { // create and if needed - define new geometry object. - ne = new CX3DImporter_NodeElement_Coordinate(NodeElement_Cur); + ne = new X3DCoordinate(mNodeElementCur); if(!def.empty()) ne->ID = def; - ((CX3DImporter_NodeElement_Coordinate*)ne)->Value = point; + ((X3DCoordinate*)ne)->Value = point; // check for X3DMetadataObject childs. if(!mReader->isEmptyElement()) ParseNode_Metadata(ne, "Coordinate"); else - NodeElement_Cur->Child.push_back(ne);// add made object as child to current element + mNodeElementCur->Child.push_back(ne);// add made object as child to current element NodeElement_List.push_back(ne);// add element to node element list because its a new object in graph }// if(!use.empty()) else @@ -184,7 +184,7 @@ void X3DImporter::ParseNode_Rendering_IndexedLineSet() std::vector colorIndex; bool colorPerVertex = true; std::vector coordIndex; - CX3DImporter_NodeElement* ne( nullptr ); + X3DNodeElementBase* ne( nullptr ); MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); @@ -205,10 +205,10 @@ void X3DImporter::ParseNode_Rendering_IndexedLineSet() throw DeadlyImportError("IndexedLineSet must contain not empty \"coordIndex\" attribute."); // create and if needed - define new geometry object. - ne = new CX3DImporter_NodeElement_IndexedSet(CX3DImporter_NodeElement::ENET_IndexedLineSet, NodeElement_Cur); + ne = new X3DIndexedSet(X3DNodeElementBase::ENET_IndexedLineSet, mNodeElementCur); if(!def.empty()) ne->ID = def; - CX3DImporter_NodeElement_IndexedSet& ne_alias = *((CX3DImporter_NodeElement_IndexedSet*)ne); + X3DIndexedSet& ne_alias = *((X3DIndexedSet*)ne); ne_alias.ColorIndex = colorIndex; ne_alias.ColorPerVertex = colorPerVertex; @@ -230,7 +230,7 @@ void X3DImporter::ParseNode_Rendering_IndexedLineSet() }// if(!mReader->isEmptyElement()) else { - NodeElement_Cur->Child.push_back(ne);// add made object as child to current element + mNodeElementCur->Child.push_back(ne);// add made object as child to current element } NodeElement_List.push_back(ne);// add element to node element list because its a new object in graph @@ -260,7 +260,7 @@ void X3DImporter::ParseNode_Rendering_IndexedTriangleFanSet() std::vector index; bool normalPerVertex = true; bool solid = true; - CX3DImporter_NodeElement* ne( nullptr ); + X3DNodeElementBase* ne( nullptr ); MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); @@ -282,10 +282,10 @@ void X3DImporter::ParseNode_Rendering_IndexedTriangleFanSet() if(index.size() == 0) throw DeadlyImportError("IndexedTriangleFanSet must contain not empty \"index\" attribute."); // create and if needed - define new geometry object. - ne = new CX3DImporter_NodeElement_IndexedSet(CX3DImporter_NodeElement::ENET_IndexedTriangleFanSet, NodeElement_Cur); + ne = new X3DIndexedSet(X3DNodeElementBase::ENET_IndexedTriangleFanSet, mNodeElementCur); if(!def.empty()) ne->ID = def; - CX3DImporter_NodeElement_IndexedSet& ne_alias = *((CX3DImporter_NodeElement_IndexedSet*)ne); + X3DIndexedSet& ne_alias = *((X3DIndexedSet*)ne); ne_alias.CCW = ccw; ne_alias.ColorPerVertex = colorPerVertex; @@ -348,7 +348,7 @@ void X3DImporter::ParseNode_Rendering_IndexedTriangleFanSet() }// if(!mReader->isEmptyElement()) else { - NodeElement_Cur->Child.push_back(ne);// add made object as child to current element + mNodeElementCur->Child.push_back(ne);// add made object as child to current element } NodeElement_List.push_back(ne);// add element to node element list because its a new object in graph @@ -378,7 +378,7 @@ void X3DImporter::ParseNode_Rendering_IndexedTriangleSet() std::vector index; bool normalPerVertex = true; bool solid = true; - CX3DImporter_NodeElement* ne( nullptr ); + X3DNodeElementBase* ne( nullptr ); MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); @@ -400,10 +400,10 @@ void X3DImporter::ParseNode_Rendering_IndexedTriangleSet() if(index.size() == 0) throw DeadlyImportError("IndexedTriangleSet must contain not empty \"index\" attribute."); // create and if needed - define new geometry object. - ne = new CX3DImporter_NodeElement_IndexedSet(CX3DImporter_NodeElement::ENET_IndexedTriangleSet, NodeElement_Cur); + ne = new X3DIndexedSet(X3DNodeElementBase::ENET_IndexedTriangleSet, mNodeElementCur); if(!def.empty()) ne->ID = def; - CX3DImporter_NodeElement_IndexedSet& ne_alias = *((CX3DImporter_NodeElement_IndexedSet*)ne); + X3DIndexedSet& ne_alias = *((X3DIndexedSet*)ne); ne_alias.CCW = ccw; ne_alias.ColorPerVertex = colorPerVertex; @@ -454,7 +454,7 @@ void X3DImporter::ParseNode_Rendering_IndexedTriangleSet() }// if(!mReader->isEmptyElement()) else { - NodeElement_Cur->Child.push_back(ne);// add made object as child to current element + mNodeElementCur->Child.push_back(ne);// add made object as child to current element } NodeElement_List.push_back(ne);// add element to node element list because its a new object in graph @@ -484,7 +484,7 @@ void X3DImporter::ParseNode_Rendering_IndexedTriangleStripSet() std::vector index; bool normalPerVertex = true; bool solid = true; - CX3DImporter_NodeElement* ne( nullptr ); + X3DNodeElementBase* ne( nullptr ); MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); @@ -506,10 +506,10 @@ void X3DImporter::ParseNode_Rendering_IndexedTriangleStripSet() if(index.size() == 0) throw DeadlyImportError("IndexedTriangleStripSet must contain not empty \"index\" attribute."); // create and if needed - define new geometry object. - ne = new CX3DImporter_NodeElement_IndexedSet(CX3DImporter_NodeElement::ENET_IndexedTriangleStripSet, NodeElement_Cur); + ne = new X3DIndexedSet(X3DNodeElementBase::ENET_IndexedTriangleStripSet, mNodeElementCur); if(!def.empty()) ne->ID = def; - CX3DImporter_NodeElement_IndexedSet& ne_alias = *((CX3DImporter_NodeElement_IndexedSet*)ne); + X3DIndexedSet& ne_alias = *((X3DIndexedSet*)ne); ne_alias.CCW = ccw; ne_alias.ColorPerVertex = colorPerVertex; @@ -568,7 +568,7 @@ void X3DImporter::ParseNode_Rendering_IndexedTriangleStripSet() }// if(!mReader->isEmptyElement()) else { - NodeElement_Cur->Child.push_back(ne);// add made object as child to current element + mNodeElementCur->Child.push_back(ne);// add made object as child to current element } NodeElement_List.push_back(ne);// add element to node element list because its a new object in graph @@ -589,7 +589,7 @@ void X3DImporter::ParseNode_Rendering_LineSet() { std::string use, def; std::vector vertexCount; - CX3DImporter_NodeElement* ne( nullptr ); + X3DNodeElementBase* ne( nullptr ); MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); @@ -607,10 +607,10 @@ void X3DImporter::ParseNode_Rendering_LineSet() if(vertexCount.size() == 0) throw DeadlyImportError("LineSet must contain not empty \"vertexCount\" attribute."); // create and if needed - define new geometry object. - ne = new CX3DImporter_NodeElement_Set(CX3DImporter_NodeElement::ENET_LineSet, NodeElement_Cur); + ne = new X3DSet(X3DNodeElementBase::ENET_LineSet, mNodeElementCur); if(!def.empty()) ne->ID = def; - CX3DImporter_NodeElement_Set& ne_alias = *((CX3DImporter_NodeElement_Set*)ne); + X3DSet& ne_alias = *((X3DSet*)ne); ne_alias.VertexCount = vertexCount; // create CoordIdx @@ -643,7 +643,7 @@ void X3DImporter::ParseNode_Rendering_LineSet() }// if(!mReader->isEmptyElement()) else { - NodeElement_Cur->Child.push_back(ne);// add made object as child to current element + mNodeElementCur->Child.push_back(ne);// add made object as child to current element } NodeElement_List.push_back(ne);// add element to node element list because its a new object in graph @@ -662,7 +662,7 @@ void X3DImporter::ParseNode_Rendering_LineSet() void X3DImporter::ParseNode_Rendering_PointSet() { std::string use, def; - CX3DImporter_NodeElement* ne( nullptr ); + X3DNodeElementBase* ne( nullptr ); MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); @@ -676,7 +676,7 @@ void X3DImporter::ParseNode_Rendering_PointSet() else { // create and if needed - define new geometry object. - ne = new CX3DImporter_NodeElement_IndexedSet(CX3DImporter_NodeElement::ENET_PointSet, NodeElement_Cur); + ne = new X3DIndexedSet(X3DNodeElementBase::ENET_PointSet, mNodeElementCur); if(!def.empty()) ne->ID = def; // check for child nodes @@ -696,7 +696,7 @@ void X3DImporter::ParseNode_Rendering_PointSet() }// if(!mReader->isEmptyElement()) else { - NodeElement_Cur->Child.push_back(ne);// add made object as child to current element + mNodeElementCur->Child.push_back(ne);// add made object as child to current element } NodeElement_List.push_back(ne);// add element to node element list because its a new object in graph @@ -726,7 +726,7 @@ void X3DImporter::ParseNode_Rendering_TriangleFanSet() std::vector fanCount; bool normalPerVertex = true; bool solid = true; - CX3DImporter_NodeElement* ne( nullptr ); + X3DNodeElementBase* ne( nullptr ); MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); @@ -748,10 +748,10 @@ void X3DImporter::ParseNode_Rendering_TriangleFanSet() if(fanCount.size() == 0) throw DeadlyImportError("TriangleFanSet must contain not empty \"fanCount\" attribute."); // create and if needed - define new geometry object. - ne = new CX3DImporter_NodeElement_Set(CX3DImporter_NodeElement::ENET_TriangleFanSet, NodeElement_Cur); + ne = new X3DSet(X3DNodeElementBase::ENET_TriangleFanSet, mNodeElementCur); if(!def.empty()) ne->ID = def; - CX3DImporter_NodeElement_Set& ne_alias = *((CX3DImporter_NodeElement_Set*)ne); + X3DSet& ne_alias = *((X3DSet*)ne); ne_alias.CCW = ccw; ne_alias.ColorPerVertex = colorPerVertex; @@ -813,7 +813,7 @@ void X3DImporter::ParseNode_Rendering_TriangleFanSet() }// if(!mReader->isEmptyElement()) else { - NodeElement_Cur->Child.push_back(ne);// add made object as child to current element + mNodeElementCur->Child.push_back(ne);// add made object as child to current element } NodeElement_List.push_back(ne);// add element to node element list because its a new object in graph @@ -841,7 +841,7 @@ void X3DImporter::ParseNode_Rendering_TriangleSet() bool colorPerVertex = true; bool normalPerVertex = true; bool solid = true; - CX3DImporter_NodeElement* ne( nullptr ); + X3DNodeElementBase* ne( nullptr ); MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); @@ -859,10 +859,10 @@ void X3DImporter::ParseNode_Rendering_TriangleSet() else { // create and if needed - define new geometry object. - ne = new CX3DImporter_NodeElement_IndexedSet(CX3DImporter_NodeElement::ENET_TriangleSet, NodeElement_Cur); + ne = new X3DIndexedSet(X3DNodeElementBase::ENET_TriangleSet, mNodeElementCur); if(!def.empty()) ne->ID = def; - CX3DImporter_NodeElement_Set& ne_alias = *((CX3DImporter_NodeElement_Set*)ne); + X3DSet& ne_alias = *((X3DSet*)ne); ne_alias.CCW = ccw; ne_alias.ColorPerVertex = colorPerVertex; @@ -887,7 +887,7 @@ void X3DImporter::ParseNode_Rendering_TriangleSet() }// if(!mReader->isEmptyElement()) else { - NodeElement_Cur->Child.push_back(ne);// add made object as child to current element + mNodeElementCur->Child.push_back(ne);// add made object as child to current element } NodeElement_List.push_back(ne);// add element to node element list because its a new object in graph @@ -917,7 +917,7 @@ void X3DImporter::ParseNode_Rendering_TriangleStripSet() std::vector stripCount; bool normalPerVertex = true; bool solid = true; - CX3DImporter_NodeElement* ne( nullptr ); + X3DNodeElementBase* ne( nullptr ); MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); @@ -939,10 +939,10 @@ void X3DImporter::ParseNode_Rendering_TriangleStripSet() if(stripCount.size() == 0) throw DeadlyImportError("TriangleStripSet must contain not empty \"stripCount\" attribute."); // create and if needed - define new geometry object. - ne = new CX3DImporter_NodeElement_Set(CX3DImporter_NodeElement::ENET_TriangleStripSet, NodeElement_Cur); + ne = new X3DSet(X3DNodeElementBase::ENET_TriangleStripSet, mNodeElementCur); if(!def.empty()) ne->ID = def; - CX3DImporter_NodeElement_Set& ne_alias = *((CX3DImporter_NodeElement_Set*)ne); + X3DSet& ne_alias = *((X3DSet*)ne); ne_alias.CCW = ccw; ne_alias.ColorPerVertex = colorPerVertex; @@ -1021,7 +1021,7 @@ void X3DImporter::ParseNode_Rendering_TriangleStripSet() }// if(!mReader->isEmptyElement()) else { - NodeElement_Cur->Child.push_back(ne);// add made object as child to current element + mNodeElementCur->Child.push_back(ne);// add made object as child to current element } NodeElement_List.push_back(ne);// add element to node element list because its a new object in graph @@ -1037,7 +1037,7 @@ void X3DImporter::ParseNode_Rendering_Normal() { std::string use, def; std::list vector; -CX3DImporter_NodeElement* ne; +X3DNodeElementBase* ne; MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); @@ -1052,15 +1052,15 @@ CX3DImporter_NodeElement* ne; else { // create and if needed - define new geometry object. - ne = new CX3DImporter_NodeElement_Normal(NodeElement_Cur); + ne = new X3DNormal(mNodeElementCur); if(!def.empty()) ne->ID = def; - ((CX3DImporter_NodeElement_Normal*)ne)->Value = vector; + ((X3DNormal*)ne)->Value = vector; // check for X3DMetadataObject childs. if(!mReader->isEmptyElement()) ParseNode_Metadata(ne, "Normal"); else - NodeElement_Cur->Child.push_back(ne);// add made object as child to current element + mNodeElementCur->Child.push_back(ne);// add made object as child to current element NodeElement_List.push_back(ne);// add element to node element list because its a new object in graph }// if(!use.empty()) else diff --git a/code/AssetLib/X3D/X3DImporter_Shape.cpp b/code/AssetLib/X3D/X3DImporter_Shape.cpp index a77b0d20c..0572da1e5 100644 --- a/code/AssetLib/X3D/X3DImporter_Shape.cpp +++ b/code/AssetLib/X3D/X3DImporter_Shape.cpp @@ -70,7 +70,7 @@ namespace Assimp void X3DImporter::ParseNode_Shape_Shape() { std::string use, def; - CX3DImporter_NodeElement* ne( nullptr ); + X3DNodeElementBase* ne( nullptr ); MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); @@ -84,7 +84,7 @@ void X3DImporter::ParseNode_Shape_Shape() else { // create and if needed - define new geometry object. - ne = new CX3DImporter_NodeElement_Shape(NodeElement_Cur); + ne = new X3DShape(mNodeElementCur); if(!def.empty()) ne->ID = def; // check for child nodes @@ -127,7 +127,7 @@ void X3DImporter::ParseNode_Shape_Shape() }// if(!mReader->isEmptyElement()) else { - NodeElement_Cur->Child.push_back(ne);// add made object as child to current element + mNodeElementCur->Child.push_back(ne);// add made object as child to current element } NodeElement_List.push_back(ne);// add element to node element list because its a new object in graph @@ -147,7 +147,7 @@ void X3DImporter::ParseNode_Shape_Shape() void X3DImporter::ParseNode_Shape_Appearance() { std::string use, def; - CX3DImporter_NodeElement* ne( nullptr ); + X3DNodeElementBase* ne( nullptr ); MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); @@ -161,7 +161,7 @@ void X3DImporter::ParseNode_Shape_Appearance() else { // create and if needed - define new geometry object. - ne = new CX3DImporter_NodeElement_Appearance(NodeElement_Cur); + ne = new X3DAppearance(mNodeElementCur); if(!def.empty()) ne->ID = def; // check for child nodes @@ -180,7 +180,7 @@ void X3DImporter::ParseNode_Shape_Appearance() }// if(!mReader->isEmptyElement()) else { - NodeElement_Cur->Child.push_back(ne);// add made object as child to current element + mNodeElementCur->Child.push_back(ne);// add made object as child to current element } NodeElement_List.push_back(ne);// add element to node element list because its a new object in graph @@ -206,7 +206,7 @@ void X3DImporter::ParseNode_Shape_Material() aiColor3D diffuseColor(0.8f, 0.8f, 0.8f); aiColor3D emissiveColor(0, 0, 0); aiColor3D specularColor(0, 0, 0); - CX3DImporter_NodeElement* ne( nullptr ); + X3DNodeElementBase* ne( nullptr ); MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); @@ -226,20 +226,20 @@ void X3DImporter::ParseNode_Shape_Material() else { // create and if needed - define new geometry object. - ne = new CX3DImporter_NodeElement_Material(NodeElement_Cur); + ne = new X3DMaterial(mNodeElementCur); if(!def.empty()) ne->ID = def; - ((CX3DImporter_NodeElement_Material*)ne)->AmbientIntensity = ambientIntensity; - ((CX3DImporter_NodeElement_Material*)ne)->Shininess = shininess; - ((CX3DImporter_NodeElement_Material*)ne)->Transparency = transparency; - ((CX3DImporter_NodeElement_Material*)ne)->DiffuseColor = diffuseColor; - ((CX3DImporter_NodeElement_Material*)ne)->EmissiveColor = emissiveColor; - ((CX3DImporter_NodeElement_Material*)ne)->SpecularColor = specularColor; + ((X3DMaterial*)ne)->AmbientIntensity = ambientIntensity; + ((X3DMaterial*)ne)->Shininess = shininess; + ((X3DMaterial*)ne)->Transparency = transparency; + ((X3DMaterial*)ne)->DiffuseColor = diffuseColor; + ((X3DMaterial*)ne)->EmissiveColor = emissiveColor; + ((X3DMaterial*)ne)->SpecularColor = specularColor; // check for child nodes if(!mReader->isEmptyElement()) ParseNode_Metadata(ne, "Material"); else - NodeElement_Cur->Child.push_back(ne);// add made object as child to current element + mNodeElementCur->Child.push_back(ne);// add made object as child to current element NodeElement_List.push_back(ne);// add element to node element list because its a new object in graph }// if(!use.empty()) else diff --git a/code/AssetLib/X3D/X3DImporter_Texturing.cpp b/code/AssetLib/X3D/X3DImporter_Texturing.cpp index 0f8c75c41..99fb78c1d 100644 --- a/code/AssetLib/X3D/X3DImporter_Texturing.cpp +++ b/code/AssetLib/X3D/X3DImporter_Texturing.cpp @@ -66,7 +66,7 @@ void X3DImporter::ParseNode_Texturing_ImageTexture() bool repeatS = true; bool repeatT = true; std::list url; - CX3DImporter_NodeElement* ne( nullptr ); + X3DNodeElementBase* ne( nullptr ); MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); @@ -83,22 +83,22 @@ void X3DImporter::ParseNode_Texturing_ImageTexture() else { // create and if needed - define new geometry object. - ne = new CX3DImporter_NodeElement_ImageTexture(NodeElement_Cur); + ne = new X3DImageTexture(mNodeElementCur); if(!def.empty()) ne->ID = def; - ((CX3DImporter_NodeElement_ImageTexture*)ne)->RepeatS = repeatS; - ((CX3DImporter_NodeElement_ImageTexture*)ne)->RepeatT = repeatT; + ((X3DImageTexture*)ne)->RepeatS = repeatS; + ((X3DImageTexture*)ne)->RepeatT = repeatT; // Attribute "url" can contain list of strings. But we need only one - first. if(!url.empty()) - ((CX3DImporter_NodeElement_ImageTexture*)ne)->URL = url.front(); + ((X3DImageTexture*)ne)->URL = url.front(); else - ((CX3DImporter_NodeElement_ImageTexture*)ne)->URL = ""; + ((X3DImageTexture*)ne)->URL = ""; // check for X3DMetadataObject childs. if(!mReader->isEmptyElement()) ParseNode_Metadata(ne, "ImageTexture"); else - NodeElement_Cur->Child.push_back(ne);// add made object as child to current element + mNodeElementCur->Child.push_back(ne);// add made object as child to current element NodeElement_List.push_back(ne);// add element to node element list because its a new object in graph }// if(!use.empty()) else @@ -113,7 +113,7 @@ void X3DImporter::ParseNode_Texturing_TextureCoordinate() { std::string use, def; std::list point; - CX3DImporter_NodeElement* ne( nullptr ); + X3DNodeElementBase* ne( nullptr ); MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); @@ -128,15 +128,15 @@ void X3DImporter::ParseNode_Texturing_TextureCoordinate() else { // create and if needed - define new geometry object. - ne = new CX3DImporter_NodeElement_TextureCoordinate(NodeElement_Cur); + ne = new X3DTextureCoordinate(mNodeElementCur); if(!def.empty()) ne->ID = def; - ((CX3DImporter_NodeElement_TextureCoordinate*)ne)->Value = point; + ((X3DTextureCoordinate*)ne)->Value = point; // check for X3DMetadataObject childs. if(!mReader->isEmptyElement()) ParseNode_Metadata(ne, "TextureCoordinate"); else - NodeElement_Cur->Child.push_back(ne);// add made object as child to current element + mNodeElementCur->Child.push_back(ne);// add made object as child to current element NodeElement_List.push_back(ne);// add element to node element list because its a new object in graph }// if(!use.empty()) else @@ -157,7 +157,7 @@ void X3DImporter::ParseNode_Texturing_TextureTransform() float rotation = 0; aiVector2D scale(1, 1); aiVector2D translation(0, 0); - CX3DImporter_NodeElement* ne( nullptr ); + X3DNodeElementBase* ne( nullptr ); MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); @@ -175,18 +175,18 @@ void X3DImporter::ParseNode_Texturing_TextureTransform() else { // create and if needed - define new geometry object. - ne = new CX3DImporter_NodeElement_TextureTransform(NodeElement_Cur); + ne = new X3DTextureTransform(mNodeElementCur); if(!def.empty()) ne->ID = def; - ((CX3DImporter_NodeElement_TextureTransform*)ne)->Center = center; - ((CX3DImporter_NodeElement_TextureTransform*)ne)->Rotation = rotation; - ((CX3DImporter_NodeElement_TextureTransform*)ne)->Scale = scale; - ((CX3DImporter_NodeElement_TextureTransform*)ne)->Translation = translation; + ((X3DTextureTransform*)ne)->Center = center; + ((X3DTextureTransform*)ne)->Rotation = rotation; + ((X3DTextureTransform*)ne)->Scale = scale; + ((X3DTextureTransform*)ne)->Translation = translation; // check for X3DMetadataObject childs. if(!mReader->isEmptyElement()) ParseNode_Metadata(ne, "TextureTransform"); else - NodeElement_Cur->Child.push_back(ne);// add made object as child to current element + mNodeElementCur->Child.push_back(ne);// add made object as child to current element NodeElement_List.push_back(ne);// add element to node element list because its a new object in graph }// if(!use.empty()) else diff --git a/code/AssetLib/X3D/X3DVocabulary.cpp b/code/AssetLib/X3D/X3DVocabulary.cpp index b985a0d14..7a251e540 100644 --- a/code/AssetLib/X3D/X3DVocabulary.cpp +++ b/code/AssetLib/X3D/X3DVocabulary.cpp @@ -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,6 +47,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "FIReader.hpp" +#include + namespace Assimp { static const char *encodingAlgorithmTable_3_2[] = { diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index 16d6b79dc..77f111209 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -812,9 +812,9 @@ ADD_ASSIMP_IMPORTER( X3D AssetLib/X3D/X3DImporter_Rendering.cpp AssetLib/X3D/X3DImporter_Shape.cpp AssetLib/X3D/X3DImporter_Texturing.cpp - AssetLib/X3D/FIReader.hpp - AssetLib/X3D/FIReader.cpp - AssetLib/X3D/X3DVocabulary.cpp + #AssetLib/X3D/FIReader.hpp + #AssetLib/X3D/FIReader.cpp + #AssetLib/X3D/X3DVocabulary.cpp ) ADD_ASSIMP_IMPORTER( GLTF