mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-11 22:54:34 +00:00
Updated Assimp
Added initial behavior for ImageAssets to hold a list of GFX resources of different texture profiles to avoid mem leaks with incorrect-typed usages Added function to ImageAsset to get best-fit asset, allowing for fallbacks if the requested assetID is not found Added function to ShapeAsset to get best-fit asset, allowing for fallbacks if the requested assetID is not found Disabled fields for dynamic and static shadowmap refresh rates Moved noShape model to core/rendering/shapes to place it in a more logical module position Added an include to avoid undefined type compile error and removed unneeded semicolon from zone code Added call to reload probe textures when a reloadTextures call is made Adjusted default directional light shadowmap settings to not be as extreme Added utility function to probe manager to allow any class to request a 'best fit' list of probes that would affect a given location, allowing other classes such as fog or particles to utilize IBL. Also updated probeManager's forward rendering to utilize same function to reduce code duplication. Shifted shape loader code to utilize assimp for loader consistency and testing Changed render bin used for SSAO postfx so it runs at the right time Made Core_Rendering module scan for assets Updated loose file references to a number of assets to follow proper formatting Refactored asset import code to follow a more consistent object heirarchy structure on importing assets, allowing more reliable cross-referencing between inbound items Updated asset import logic for materials/images so that they properly utilize ImageType. Images correctly save out the assigned image type, materials reference the images' type to know what map slot they should be used in. Importer logic also updated to better find-and-add associated images based on type. Cleaned up a bunch of old, outdated code in the asset importer Added initial handling for in-place importing of files without needing to process them through the UI. Added ability to edit module script from RMB context menu if torsion path is set Updated list field code for variable inspector to utilize correct ownerObject field
This commit is contained in:
parent
2d015bc426
commit
6ade6f08ce
545 changed files with 15077 additions and 8437 deletions
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
@ -45,6 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include "ColladaExporter.h"
|
||||
#include <assimp/Bitmap.h>
|
||||
#include <assimp/commonMetaData.h>
|
||||
#include <assimp/MathFunctions.h>
|
||||
#include <assimp/fast_atof.h>
|
||||
#include <assimp/SceneCombiner.h>
|
||||
|
|
@ -277,7 +278,7 @@ void ColladaExporter::WriteHeader() {
|
|||
mOutput << startstr << "<author>" << XMLEscape(value.C_Str()) << "</author>" << endstr;
|
||||
}
|
||||
|
||||
if (nullptr == meta || !meta->Get("AuthoringTool", value)) {
|
||||
if (nullptr == meta || !meta->Get(AI_METADATA_SOURCE_GENERATOR, value)) {
|
||||
mOutput << startstr << "<authoring_tool>" << "Assimp Exporter" << "</authoring_tool>" << endstr;
|
||||
} else {
|
||||
mOutput << startstr << "<authoring_tool>" << XMLEscape(value.C_Str()) << "</authoring_tool>" << endstr;
|
||||
|
|
@ -287,7 +288,7 @@ void ColladaExporter::WriteHeader() {
|
|||
if (meta->Get("Comments", value)) {
|
||||
mOutput << startstr << "<comments>" << XMLEscape(value.C_Str()) << "</comments>" << endstr;
|
||||
}
|
||||
if (meta->Get("Copyright", value)) {
|
||||
if (meta->Get(AI_METADATA_SOURCE_COPYRIGHT, value)) {
|
||||
mOutput << startstr << "<copyright>" << XMLEscape(value.C_Str()) << "</copyright>" << endstr;
|
||||
}
|
||||
if (meta->Get("SourceData", value)) {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
107
Engine/lib/assimp/code/Collada/ColladaHelper.cpp
Normal file
107
Engine/lib/assimp/code/Collada/ColladaHelper.cpp
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
/** Helper structures for the Collada loader */
|
||||
|
||||
/*
|
||||
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,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
* Neither the name of the assimp team, nor the names of its
|
||||
contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior
|
||||
written permission of the assimp team.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "ColladaHelper.h"
|
||||
|
||||
#include <assimp/commonMetaData.h>
|
||||
#include <assimp/ParsingUtils.h>
|
||||
|
||||
namespace Assimp {
|
||||
namespace Collada {
|
||||
|
||||
const MetaKeyPairVector MakeColladaAssimpMetaKeys() {
|
||||
MetaKeyPairVector result;
|
||||
result.emplace_back("authoring_tool", AI_METADATA_SOURCE_GENERATOR);
|
||||
result.emplace_back("copyright", AI_METADATA_SOURCE_COPYRIGHT);
|
||||
return result;
|
||||
};
|
||||
|
||||
const MetaKeyPairVector &GetColladaAssimpMetaKeys() {
|
||||
static const MetaKeyPairVector result = MakeColladaAssimpMetaKeys();
|
||||
return result;
|
||||
}
|
||||
|
||||
const MetaKeyPairVector MakeColladaAssimpMetaKeysCamelCase() {
|
||||
MetaKeyPairVector result = MakeColladaAssimpMetaKeys();
|
||||
for (auto &val : result)
|
||||
{
|
||||
ToCamelCase(val.first);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
const MetaKeyPairVector &GetColladaAssimpMetaKeysCamelCase()
|
||||
{
|
||||
static const MetaKeyPairVector result = MakeColladaAssimpMetaKeysCamelCase();
|
||||
return result;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Convert underscore_separated to CamelCase: "authoring_tool" becomes "AuthoringTool"
|
||||
void ToCamelCase(std::string &text)
|
||||
{
|
||||
if (text.empty())
|
||||
return;
|
||||
// Capitalise first character
|
||||
auto it = text.begin();
|
||||
(*it) = ToUpper(*it);
|
||||
++it;
|
||||
for (/*started above*/ ; it != text.end(); /*iterated below*/)
|
||||
{
|
||||
if ((*it) == '_')
|
||||
{
|
||||
it = text.erase(it);
|
||||
if (it != text.end())
|
||||
(*it) = ToUpper(*it);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Make lower case
|
||||
(*it) = ToLower(*it);
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Collada
|
||||
} // namespace Assimp
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
@ -47,6 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include <stdint.h>
|
||||
#include <assimp/light.h>
|
||||
#include <assimp/mesh.h>
|
||||
|
|
@ -104,6 +105,17 @@ enum MorphMethod
|
|||
Relative
|
||||
};
|
||||
|
||||
/** Common metadata keys as <Collada, Assimp> */
|
||||
typedef std::pair<std::string, std::string> MetaKeyPair;
|
||||
typedef std::vector<MetaKeyPair> MetaKeyPairVector;
|
||||
|
||||
// Collada as lower_case (native)
|
||||
const MetaKeyPairVector &GetColladaAssimpMetaKeys();
|
||||
// Collada as CamelCase (used by Assimp for consistency)
|
||||
const MetaKeyPairVector &GetColladaAssimpMetaKeysCamelCase();
|
||||
|
||||
/** Convert underscore_separated to CamelCase "authoring_tool" becomes "AuthoringTool" */
|
||||
void ToCamelCase(std::string &text);
|
||||
|
||||
/** Contains all data for one of the different transformation types */
|
||||
struct Transform
|
||||
|
|
@ -647,23 +659,37 @@ struct Animation
|
|||
|
||||
void CombineSingleChannelAnimationsRecursively(Animation *pParent)
|
||||
{
|
||||
std::set<std::string> childrenTargets;
|
||||
bool childrenAnimationsHaveDifferentChannels = true;
|
||||
|
||||
for (std::vector<Animation*>::iterator it = pParent->mSubAnims.begin(); it != pParent->mSubAnims.end();)
|
||||
{
|
||||
Animation *anim = *it;
|
||||
|
||||
CombineSingleChannelAnimationsRecursively(anim);
|
||||
|
||||
if (anim->mChannels.size() == 1)
|
||||
if (childrenAnimationsHaveDifferentChannels && anim->mChannels.size() == 1 &&
|
||||
childrenTargets.find(anim->mChannels[0].mTarget) == childrenTargets.end()) {
|
||||
childrenTargets.insert(anim->mChannels[0].mTarget);
|
||||
} else {
|
||||
childrenAnimationsHaveDifferentChannels = false;
|
||||
}
|
||||
|
||||
++it;
|
||||
}
|
||||
|
||||
// We only want to combine animations if they have different channels
|
||||
if (childrenAnimationsHaveDifferentChannels)
|
||||
{
|
||||
for (std::vector<Animation*>::iterator it = pParent->mSubAnims.begin(); it != pParent->mSubAnims.end();)
|
||||
{
|
||||
Animation *anim = *it;
|
||||
|
||||
pParent->mChannels.push_back(anim->mChannels[0]);
|
||||
|
||||
it = pParent->mSubAnims.erase(it);
|
||||
|
||||
delete anim;
|
||||
}
|
||||
else
|
||||
{
|
||||
++it;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
|
@ -963,18 +963,38 @@ void ColladaLoader::StoreAnimations( aiScene* pScene, const ColladaParser& pPars
|
|||
|
||||
// catch special case: many animations with the same length, each affecting only a single node.
|
||||
// we need to unite all those single-node-anims to a proper combined animation
|
||||
for( size_t a = 0; a < mAnims.size(); ++a) {
|
||||
for(size_t a = 0; a < mAnims.size(); ++a) {
|
||||
aiAnimation* templateAnim = mAnims[a];
|
||||
if( templateAnim->mNumChannels == 1) {
|
||||
|
||||
if (templateAnim->mNumChannels == 1) {
|
||||
// search for other single-channel-anims with the same duration
|
||||
std::vector<size_t> collectedAnimIndices;
|
||||
for( size_t b = a+1; b < mAnims.size(); ++b) {
|
||||
aiAnimation* other = mAnims[b];
|
||||
if (other->mNumChannels == 1 && other->mDuration == templateAnim->mDuration &&
|
||||
other->mTicksPerSecond == templateAnim->mTicksPerSecond)
|
||||
collectedAnimIndices.push_back(b);
|
||||
collectedAnimIndices.push_back(b);
|
||||
}
|
||||
|
||||
// We only want to combine the animations if they have different channels
|
||||
std::set<std::string> animTargets;
|
||||
animTargets.insert(templateAnim->mChannels[0]->mNodeName.C_Str());
|
||||
bool collectedAnimationsHaveDifferentChannels = true;
|
||||
for (size_t b = 0; b < collectedAnimIndices.size(); ++b)
|
||||
{
|
||||
aiAnimation* srcAnimation = mAnims[collectedAnimIndices[b]];
|
||||
std::string channelName = std::string(srcAnimation->mChannels[0]->mNodeName.C_Str());
|
||||
if (animTargets.find(channelName) == animTargets.end()) {
|
||||
animTargets.insert(channelName);
|
||||
} else {
|
||||
collectedAnimationsHaveDifferentChannels = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!collectedAnimationsHaveDifferentChannels)
|
||||
continue;
|
||||
|
||||
// if there are other animations which fit the template anim, combine all channels into a single anim
|
||||
if (!collectedAnimIndices.empty())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
@ -50,6 +50,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <sstream>
|
||||
#include <stdarg.h>
|
||||
#include "ColladaParser.h"
|
||||
#include <assimp/commonMetaData.h>
|
||||
#include <assimp/fast_atof.h>
|
||||
#include <assimp/ParsingUtils.h>
|
||||
#include <assimp/StringUtils.h>
|
||||
|
|
@ -249,6 +250,9 @@ void ColladaParser::UriDecodePath(aiString& ss)
|
|||
bool ColladaParser::ReadBoolFromTextContent()
|
||||
{
|
||||
const char* cur = GetTextContent();
|
||||
if ( nullptr == cur) {
|
||||
return false;
|
||||
}
|
||||
return (!ASSIMP_strincmp(cur, "true", 4) || '0' != *cur);
|
||||
}
|
||||
|
||||
|
|
@ -257,6 +261,9 @@ bool ColladaParser::ReadBoolFromTextContent()
|
|||
ai_real ColladaParser::ReadFloatFromTextContent()
|
||||
{
|
||||
const char* cur = GetTextContent();
|
||||
if ( nullptr == cur ) {
|
||||
return 0.0;
|
||||
}
|
||||
return fast_atof(cur);
|
||||
}
|
||||
|
||||
|
|
@ -276,6 +283,11 @@ void ColladaParser::ReadContents()
|
|||
if (attrib != -1) {
|
||||
const char* version = mReader->getAttributeValue(attrib);
|
||||
|
||||
// Store declared format version string
|
||||
aiString v;
|
||||
v.Set(version);
|
||||
mAssetMetaData.emplace(AI_METADATA_SOURCE_FORMAT_VERSION, v );
|
||||
|
||||
if (!::strncmp(version, "1.5", 3)) {
|
||||
mFormat = FV_1_5_n;
|
||||
ASSIMP_LOG_DEBUG("Collada schema version is 1.5.n");
|
||||
|
|
@ -434,23 +446,39 @@ void ColladaParser::ReadContributorInfo()
|
|||
}
|
||||
}
|
||||
|
||||
static bool FindCommonKey(const std::string &collada_key, const MetaKeyPairVector &key_renaming, size_t &found_index) {
|
||||
for (size_t i = 0; i < key_renaming.size(); ++i) {
|
||||
if (key_renaming[i].first == collada_key) {
|
||||
found_index = i;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
found_index = std::numeric_limits<size_t>::max();
|
||||
return false;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Reads a single string metadata item
|
||||
void ColladaParser::ReadMetaDataItem(StringMetaData &metadata)
|
||||
{
|
||||
// Metadata such as created, keywords, subject etc
|
||||
const char* key_char = mReader->getNodeName();
|
||||
if (key_char != nullptr)
|
||||
{
|
||||
void ColladaParser::ReadMetaDataItem(StringMetaData &metadata) {
|
||||
const Collada::MetaKeyPairVector &key_renaming = GetColladaAssimpMetaKeysCamelCase();
|
||||
// Metadata such as created, keywords, subject etc
|
||||
const char *key_char = mReader->getNodeName();
|
||||
if (key_char != nullptr) {
|
||||
const std::string key_str(key_char);
|
||||
const char* value_char = TestTextContent();
|
||||
if (value_char != nullptr)
|
||||
{
|
||||
std::string camel_key_str = key_str;
|
||||
ToCamelCase(camel_key_str);
|
||||
const char *value_char = TestTextContent();
|
||||
if (value_char != nullptr) {
|
||||
aiString aistr;
|
||||
aistr.Set(value_char);
|
||||
metadata.emplace(camel_key_str, aistr);
|
||||
aistr.Set(value_char);
|
||||
|
||||
std::string camel_key_str(key_str);
|
||||
ToCamelCase(camel_key_str);
|
||||
|
||||
size_t found_index;
|
||||
if (FindCommonKey(camel_key_str, key_renaming, found_index)) {
|
||||
metadata.emplace(key_renaming[found_index].second, aistr);
|
||||
} else {
|
||||
metadata.emplace(camel_key_str, aistr);
|
||||
}
|
||||
}
|
||||
TestClosing(key_str.c_str());
|
||||
}
|
||||
|
|
@ -458,27 +486,6 @@ void ColladaParser::ReadMetaDataItem(StringMetaData &metadata)
|
|||
SkipElement();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Convert underscore_seperated to CamelCase: "authoring_tool" becomes "AuthoringTool"
|
||||
void ColladaParser::ToCamelCase(std::string &text)
|
||||
{
|
||||
if (text.empty())
|
||||
return;
|
||||
// Capitalise first character
|
||||
text[0] = ToUpper(text[0]);
|
||||
for (auto it = text.begin(); it != text.end(); /*iterated below*/)
|
||||
{
|
||||
if ((*it) == '_')
|
||||
{
|
||||
it = text.erase(it);
|
||||
if (it != text.end())
|
||||
(*it) = ToUpper(*it);
|
||||
}
|
||||
else
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Reads the animation clips
|
||||
void ColladaParser::ReadAnimationClipLibrary()
|
||||
|
|
@ -3234,13 +3241,12 @@ void ColladaParser::ReadScene()
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Aborts the file reading with an exception
|
||||
AI_WONT_RETURN void ColladaParser::ThrowException(const std::string& pError) const
|
||||
{
|
||||
AI_WONT_RETURN void ColladaParser::ThrowException(const std::string& pError) const {
|
||||
throw DeadlyImportError(format() << "Collada: " << mFileName << " - " << pError);
|
||||
}
|
||||
void ColladaParser::ReportWarning(const char* msg, ...)
|
||||
{
|
||||
ai_assert(NULL != msg);
|
||||
|
||||
void ColladaParser::ReportWarning(const char* msg, ...) {
|
||||
ai_assert(nullptr != msg);
|
||||
|
||||
va_list args;
|
||||
va_start(args, msg);
|
||||
|
|
@ -3255,11 +3261,11 @@ void ColladaParser::ReportWarning(const char* msg, ...)
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Skips all data until the end node of the current element
|
||||
void ColladaParser::SkipElement()
|
||||
{
|
||||
void ColladaParser::SkipElement() {
|
||||
// nothing to skip if it's an <element />
|
||||
if (mReader->isEmptyElement())
|
||||
if (mReader->isEmptyElement()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// reroute
|
||||
SkipElement(mReader->getNodeName());
|
||||
|
|
@ -3267,63 +3273,75 @@ void ColladaParser::SkipElement()
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Skips all data until the end node of the given element
|
||||
void ColladaParser::SkipElement(const char* pElement)
|
||||
{
|
||||
void ColladaParser::SkipElement(const char* pElement) {
|
||||
// copy the current node's name because it'a pointer to the reader's internal buffer,
|
||||
// which is going to change with the upcoming parsing
|
||||
std::string element = pElement;
|
||||
while (mReader->read())
|
||||
{
|
||||
if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END)
|
||||
if (mReader->getNodeName() == element)
|
||||
while (mReader->read()) {
|
||||
if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) {
|
||||
if (mReader->getNodeName() == element) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Tests for an opening element of the given name, throws an exception if not found
|
||||
void ColladaParser::TestOpening(const char* pName)
|
||||
{
|
||||
void ColladaParser::TestOpening(const char* pName) {
|
||||
// read element start
|
||||
if (!mReader->read())
|
||||
if (!mReader->read()) {
|
||||
ThrowException(format() << "Unexpected end of file while beginning of <" << pName << "> element.");
|
||||
}
|
||||
// whitespace in front is ok, just read again if found
|
||||
if (mReader->getNodeType() == irr::io::EXN_TEXT)
|
||||
if (!mReader->read())
|
||||
if (mReader->getNodeType() == irr::io::EXN_TEXT) {
|
||||
if (!mReader->read()) {
|
||||
ThrowException(format() << "Unexpected end of file while reading beginning of <" << pName << "> element.");
|
||||
}
|
||||
}
|
||||
|
||||
if (mReader->getNodeType() != irr::io::EXN_ELEMENT || strcmp(mReader->getNodeName(), pName) != 0)
|
||||
if (mReader->getNodeType() != irr::io::EXN_ELEMENT || strcmp(mReader->getNodeName(), pName) != 0) {
|
||||
ThrowException(format() << "Expected start of <" << pName << "> element.");
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Tests for the closing tag of the given element, throws an exception if not found
|
||||
void ColladaParser::TestClosing(const char* pName)
|
||||
{
|
||||
// check if we're already on the closing tag and return right away
|
||||
if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END && strcmp(mReader->getNodeName(), pName) == 0)
|
||||
void ColladaParser::TestClosing(const char* pName) {
|
||||
// check if we have an empty (self-closing) element
|
||||
if (mReader->isEmptyElement()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// check if we're already on the closing tag and return right away
|
||||
if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END && strcmp(mReader->getNodeName(), pName) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// if not, read some more
|
||||
if (!mReader->read())
|
||||
if (!mReader->read()) {
|
||||
ThrowException(format() << "Unexpected end of file while reading end of <" << pName << "> element.");
|
||||
}
|
||||
// whitespace in front is ok, just read again if found
|
||||
if (mReader->getNodeType() == irr::io::EXN_TEXT)
|
||||
if (!mReader->read())
|
||||
if (mReader->getNodeType() == irr::io::EXN_TEXT) {
|
||||
if (!mReader->read()) {
|
||||
ThrowException(format() << "Unexpected end of file while reading end of <" << pName << "> element.");
|
||||
}
|
||||
}
|
||||
|
||||
// but this has the be the closing tag, or we're lost
|
||||
if (mReader->getNodeType() != irr::io::EXN_ELEMENT_END || strcmp(mReader->getNodeName(), pName) != 0)
|
||||
if (mReader->getNodeType() != irr::io::EXN_ELEMENT_END || strcmp(mReader->getNodeName(), pName) != 0) {
|
||||
ThrowException(format() << "Expected end of <" << pName << "> element.");
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Returns the index of the named attribute or -1 if not found. Does not throw, therefore useful for optional attributes
|
||||
int ColladaParser::GetAttribute(const char* pAttr) const
|
||||
{
|
||||
int ColladaParser::GetAttribute(const char* pAttr) const {
|
||||
int index = TestAttribute(pAttr);
|
||||
if (index != -1)
|
||||
if (index != -1) {
|
||||
return index;
|
||||
}
|
||||
|
||||
// attribute not found -> throw an exception
|
||||
ThrowException(format() << "Expected attribute \"" << pAttr << "\" for element <" << mReader->getNodeName() << ">.");
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
@ -94,12 +94,9 @@ namespace Assimp
|
|||
/** Reads contributor information such as author and legal blah */
|
||||
void ReadContributorInfo();
|
||||
|
||||
/** Reads generic metadata into provided map */
|
||||
/** Reads generic metadata into provided map and renames keys for Assimp */
|
||||
void ReadMetaDataItem(StringMetaData &metadata);
|
||||
|
||||
/** Convert underscore_seperated to CamelCase "authoring_tool" becomes "AuthoringTool" */
|
||||
static void ToCamelCase(std::string &text);
|
||||
|
||||
/** Reads the animation library */
|
||||
void ReadAnimationLibrary();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue