Merge branch 'master' into develop
This commit is contained in:
@@ -329,8 +329,8 @@ void AMFImporter::Postprocess_AddMetadata(const AMFMetaDataArray &metadataList,
|
||||
sceneNode.mMetaData = aiMetadata::Alloc(static_cast<unsigned int>(metadataList.size()));
|
||||
size_t meta_idx(0);
|
||||
|
||||
for (const AMFMetadata &metadata : metadataList) {
|
||||
sceneNode.mMetaData->Set(static_cast<unsigned int>(meta_idx++), metadata.Type, aiString(metadata.Value));
|
||||
for (const AMFMetadata *metadata : metadataList) {
|
||||
sceneNode.mMetaData->Set(static_cast<unsigned int>(meta_idx++), metadata->Type, aiString(metadata->Value));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -334,7 +334,7 @@ void ColladaParser::ReadAssetInfo(XmlNode &node) {
|
||||
const std::string ¤tName = currentNode.name();
|
||||
if (currentName == "unit") {
|
||||
mUnitSize = 1.f;
|
||||
XmlParser::getFloatAttribute(node, "meter", mUnitSize);
|
||||
XmlParser::getFloatAttribute(currentNode, "meter", mUnitSize);
|
||||
} else if (currentName == "up_axis") {
|
||||
std::string v;
|
||||
if (!XmlParser::getValueAsString(currentNode, v)) {
|
||||
@@ -459,7 +459,6 @@ void ColladaParser::PostProcessRootAnimations() {
|
||||
|
||||
if (animation != mAnimationLibrary.end()) {
|
||||
Animation *pSourceAnimation = animation->second;
|
||||
|
||||
pSourceAnimation->CollectChannelsRecursively(clip->mChannels);
|
||||
}
|
||||
}
|
||||
@@ -1738,14 +1737,16 @@ size_t ColladaParser::ReadPrimitives(XmlNode &node, Mesh &pMesh, std::vector<Inp
|
||||
|
||||
// and read all indices into a temporary array
|
||||
std::vector<size_t> indices;
|
||||
if (expectedPointCount > 0)
|
||||
if (expectedPointCount > 0) {
|
||||
indices.reserve(expectedPointCount * numOffsets);
|
||||
}
|
||||
|
||||
if (pNumPrimitives > 0) // It is possible to not contain any indices
|
||||
{
|
||||
// It is possible to not contain any indices
|
||||
if (pNumPrimitives > 0) {
|
||||
std::string v;
|
||||
XmlParser::getValueAsString(node, v);
|
||||
const char *content = v.c_str();
|
||||
SkipSpacesAndLineEnd(&content);
|
||||
while (*content != 0) {
|
||||
// read a value.
|
||||
// Hack: (thom) Some exporters put negative indices sometimes. We just try to carry on anyways.
|
||||
@@ -1772,21 +1773,24 @@ size_t ColladaParser::ReadPrimitives(XmlNode &node, Mesh &pMesh, std::vector<Inp
|
||||
// find the data for all sources
|
||||
for (std::vector<InputChannel>::iterator it = pMesh.mPerVertexData.begin(); it != pMesh.mPerVertexData.end(); ++it) {
|
||||
InputChannel &input = *it;
|
||||
if (input.mResolved)
|
||||
if (input.mResolved) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// find accessor
|
||||
input.mResolved = &ResolveLibraryReference(mAccessorLibrary, input.mAccessor);
|
||||
// resolve accessor's data pointer as well, if necessary
|
||||
const Accessor *acc = input.mResolved;
|
||||
if (!acc->mData)
|
||||
if (!acc->mData) {
|
||||
acc->mData = &ResolveLibraryReference(mDataLibrary, acc->mSource);
|
||||
}
|
||||
}
|
||||
// and the same for the per-index channels
|
||||
for (std::vector<InputChannel>::iterator it = pPerIndexChannels.begin(); it != pPerIndexChannels.end(); ++it) {
|
||||
InputChannel &input = *it;
|
||||
if (input.mResolved)
|
||||
if (input.mResolved) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// ignore vertex pointer, it doesn't refer to an accessor
|
||||
if (input.mType == IT_Vertex) {
|
||||
@@ -1801,8 +1805,9 @@ size_t ColladaParser::ReadPrimitives(XmlNode &node, Mesh &pMesh, std::vector<Inp
|
||||
input.mResolved = &ResolveLibraryReference(mAccessorLibrary, input.mAccessor);
|
||||
// resolve accessor's data pointer as well, if necessary
|
||||
const Accessor *acc = input.mResolved;
|
||||
if (!acc->mData)
|
||||
if (!acc->mData) {
|
||||
acc->mData = &ResolveLibraryReference(mDataLibrary, acc->mSource);
|
||||
}
|
||||
}
|
||||
|
||||
// For continued primitives, the given count does not come all in one <p>, but only one primitive per <p>
|
||||
@@ -1884,11 +1889,13 @@ void ColladaParser::CopyVertex(size_t currentVertex, size_t numOffsets, size_t n
|
||||
ai_assert((baseOffset + numOffsets - 1) < indices.size());
|
||||
|
||||
// extract per-vertex channels using the global per-vertex offset
|
||||
for (std::vector<InputChannel>::iterator it = pMesh.mPerVertexData.begin(); it != pMesh.mPerVertexData.end(); ++it)
|
||||
for (std::vector<InputChannel>::iterator it = pMesh.mPerVertexData.begin(); it != pMesh.mPerVertexData.end(); ++it) {
|
||||
ExtractDataObjectFromChannel(*it, indices[baseOffset + perVertexOffset], pMesh);
|
||||
}
|
||||
// and extract per-index channels using there specified offset
|
||||
for (std::vector<InputChannel>::iterator it = pPerIndexChannels.begin(); it != pPerIndexChannels.end(); ++it)
|
||||
for (std::vector<InputChannel>::iterator it = pPerIndexChannels.begin(); it != pPerIndexChannels.end(); ++it) {
|
||||
ExtractDataObjectFromChannel(*it, indices[baseOffset + it->mOffset], pMesh);
|
||||
}
|
||||
|
||||
// store the vertex-data index for later assignment of bone vertex weights
|
||||
pMesh.mFacePosIndices.push_back(indices[baseOffset + perVertexOffset]);
|
||||
@@ -1912,8 +1919,9 @@ void ColladaParser::ReadPrimTriStrips(size_t numOffsets, size_t perVertexOffset,
|
||||
// Extracts a single object from an input channel and stores it in the appropriate mesh data array
|
||||
void ColladaParser::ExtractDataObjectFromChannel(const InputChannel &pInput, size_t pLocalIndex, Mesh &pMesh) {
|
||||
// ignore vertex referrer - we handle them that separate
|
||||
if (pInput.mType == IT_Vertex)
|
||||
if (pInput.mType == IT_Vertex) {
|
||||
return;
|
||||
}
|
||||
|
||||
const Accessor &acc = *pInput.mResolved;
|
||||
if (pLocalIndex >= acc.mCount) {
|
||||
@@ -1926,86 +1934,93 @@ void ColladaParser::ExtractDataObjectFromChannel(const InputChannel &pInput, siz
|
||||
// assemble according to the accessors component sub-offset list. We don't care, yet,
|
||||
// what kind of object exactly we're extracting here
|
||||
ai_real obj[4];
|
||||
for (size_t c = 0; c < 4; ++c)
|
||||
for (size_t c = 0; c < 4; ++c) {
|
||||
obj[c] = dataObject[acc.mSubOffset[c]];
|
||||
}
|
||||
|
||||
// now we reinterpret it according to the type we're reading here
|
||||
switch (pInput.mType) {
|
||||
case IT_Position: // ignore all position streams except 0 - there can be only one position
|
||||
if (pInput.mIndex == 0)
|
||||
pMesh.mPositions.push_back(aiVector3D(obj[0], obj[1], obj[2]));
|
||||
else
|
||||
ASSIMP_LOG_ERROR("Collada: just one vertex position stream supported");
|
||||
break;
|
||||
case IT_Normal:
|
||||
// pad to current vertex count if necessary
|
||||
if (pMesh.mNormals.size() < pMesh.mPositions.size() - 1)
|
||||
pMesh.mNormals.insert(pMesh.mNormals.end(), pMesh.mPositions.size() - pMesh.mNormals.size() - 1, aiVector3D(0, 1, 0));
|
||||
|
||||
// ignore all normal streams except 0 - there can be only one normal
|
||||
if (pInput.mIndex == 0)
|
||||
pMesh.mNormals.push_back(aiVector3D(obj[0], obj[1], obj[2]));
|
||||
else
|
||||
ASSIMP_LOG_ERROR("Collada: just one vertex normal stream supported");
|
||||
break;
|
||||
case IT_Tangent:
|
||||
// pad to current vertex count if necessary
|
||||
if (pMesh.mTangents.size() < pMesh.mPositions.size() - 1)
|
||||
pMesh.mTangents.insert(pMesh.mTangents.end(), pMesh.mPositions.size() - pMesh.mTangents.size() - 1, aiVector3D(1, 0, 0));
|
||||
|
||||
// ignore all tangent streams except 0 - there can be only one tangent
|
||||
if (pInput.mIndex == 0)
|
||||
pMesh.mTangents.push_back(aiVector3D(obj[0], obj[1], obj[2]));
|
||||
else
|
||||
ASSIMP_LOG_ERROR("Collada: just one vertex tangent stream supported");
|
||||
break;
|
||||
case IT_Bitangent:
|
||||
// pad to current vertex count if necessary
|
||||
if (pMesh.mBitangents.size() < pMesh.mPositions.size() - 1)
|
||||
pMesh.mBitangents.insert(pMesh.mBitangents.end(), pMesh.mPositions.size() - pMesh.mBitangents.size() - 1, aiVector3D(0, 0, 1));
|
||||
|
||||
// ignore all bitangent streams except 0 - there can be only one bitangent
|
||||
if (pInput.mIndex == 0)
|
||||
pMesh.mBitangents.push_back(aiVector3D(obj[0], obj[1], obj[2]));
|
||||
else
|
||||
ASSIMP_LOG_ERROR("Collada: just one vertex bitangent stream supported");
|
||||
break;
|
||||
case IT_Texcoord:
|
||||
// up to 4 texture coord sets are fine, ignore the others
|
||||
if (pInput.mIndex < AI_MAX_NUMBER_OF_TEXTURECOORDS) {
|
||||
// pad to current vertex count if necessary
|
||||
if (pMesh.mTexCoords[pInput.mIndex].size() < pMesh.mPositions.size() - 1)
|
||||
pMesh.mTexCoords[pInput.mIndex].insert(pMesh.mTexCoords[pInput.mIndex].end(),
|
||||
pMesh.mPositions.size() - pMesh.mTexCoords[pInput.mIndex].size() - 1, aiVector3D(0, 0, 0));
|
||||
|
||||
pMesh.mTexCoords[pInput.mIndex].push_back(aiVector3D(obj[0], obj[1], obj[2]));
|
||||
if (0 != acc.mSubOffset[2] || 0 != acc.mSubOffset[3]) /* hack ... consider cleaner solution */
|
||||
pMesh.mNumUVComponents[pInput.mIndex] = 3;
|
||||
} else {
|
||||
ASSIMP_LOG_ERROR("Collada: too many texture coordinate sets. Skipping.");
|
||||
}
|
||||
break;
|
||||
case IT_Color:
|
||||
// up to 4 color sets are fine, ignore the others
|
||||
if (pInput.mIndex < AI_MAX_NUMBER_OF_COLOR_SETS) {
|
||||
// pad to current vertex count if necessary
|
||||
if (pMesh.mColors[pInput.mIndex].size() < pMesh.mPositions.size() - 1)
|
||||
pMesh.mColors[pInput.mIndex].insert(pMesh.mColors[pInput.mIndex].end(),
|
||||
pMesh.mPositions.size() - pMesh.mColors[pInput.mIndex].size() - 1, aiColor4D(0, 0, 0, 1));
|
||||
|
||||
aiColor4D result(0, 0, 0, 1);
|
||||
for (size_t i = 0; i < pInput.mResolved->mSize; ++i) {
|
||||
result[static_cast<unsigned int>(i)] = obj[pInput.mResolved->mSubOffset[i]];
|
||||
case IT_Position: // ignore all position streams except 0 - there can be only one position
|
||||
if (pInput.mIndex == 0) {
|
||||
pMesh.mPositions.push_back(aiVector3D(obj[0], obj[1], obj[2]));
|
||||
} else {
|
||||
ASSIMP_LOG_ERROR("Collada: just one vertex position stream supported");
|
||||
}
|
||||
pMesh.mColors[pInput.mIndex].push_back(result);
|
||||
} else {
|
||||
ASSIMP_LOG_ERROR("Collada: too many vertex color sets. Skipping.");
|
||||
}
|
||||
break;
|
||||
case IT_Normal:
|
||||
// pad to current vertex count if necessary
|
||||
if (pMesh.mNormals.size() < pMesh.mPositions.size() - 1)
|
||||
pMesh.mNormals.insert(pMesh.mNormals.end(), pMesh.mPositions.size() - pMesh.mNormals.size() - 1, aiVector3D(0, 1, 0));
|
||||
|
||||
break;
|
||||
default:
|
||||
// IT_Invalid and IT_Vertex
|
||||
ai_assert(false && "shouldn't ever get here");
|
||||
// ignore all normal streams except 0 - there can be only one normal
|
||||
if (pInput.mIndex == 0) {
|
||||
pMesh.mNormals.push_back(aiVector3D(obj[0], obj[1], obj[2]));
|
||||
} else {
|
||||
ASSIMP_LOG_ERROR("Collada: just one vertex normal stream supported");
|
||||
}
|
||||
break;
|
||||
case IT_Tangent:
|
||||
// pad to current vertex count if necessary
|
||||
if (pMesh.mTangents.size() < pMesh.mPositions.size() - 1)
|
||||
pMesh.mTangents.insert(pMesh.mTangents.end(), pMesh.mPositions.size() - pMesh.mTangents.size() - 1, aiVector3D(1, 0, 0));
|
||||
|
||||
// ignore all tangent streams except 0 - there can be only one tangent
|
||||
if (pInput.mIndex == 0) {
|
||||
pMesh.mTangents.push_back(aiVector3D(obj[0], obj[1], obj[2]));
|
||||
} else {
|
||||
ASSIMP_LOG_ERROR("Collada: just one vertex tangent stream supported");
|
||||
}
|
||||
break;
|
||||
case IT_Bitangent:
|
||||
// pad to current vertex count if necessary
|
||||
if (pMesh.mBitangents.size() < pMesh.mPositions.size() - 1) {
|
||||
pMesh.mBitangents.insert(pMesh.mBitangents.end(), pMesh.mPositions.size() - pMesh.mBitangents.size() - 1, aiVector3D(0, 0, 1));
|
||||
}
|
||||
|
||||
// ignore all bitangent streams except 0 - there can be only one bitangent
|
||||
if (pInput.mIndex == 0) {
|
||||
pMesh.mBitangents.push_back(aiVector3D(obj[0], obj[1], obj[2]));
|
||||
} else {
|
||||
ASSIMP_LOG_ERROR("Collada: just one vertex bitangent stream supported");
|
||||
}
|
||||
break;
|
||||
case IT_Texcoord:
|
||||
// up to 4 texture coord sets are fine, ignore the others
|
||||
if (pInput.mIndex < AI_MAX_NUMBER_OF_TEXTURECOORDS) {
|
||||
// pad to current vertex count if necessary
|
||||
if (pMesh.mTexCoords[pInput.mIndex].size() < pMesh.mPositions.size() - 1)
|
||||
pMesh.mTexCoords[pInput.mIndex].insert(pMesh.mTexCoords[pInput.mIndex].end(),
|
||||
pMesh.mPositions.size() - pMesh.mTexCoords[pInput.mIndex].size() - 1, aiVector3D(0, 0, 0));
|
||||
|
||||
pMesh.mTexCoords[pInput.mIndex].push_back(aiVector3D(obj[0], obj[1], obj[2]));
|
||||
if (0 != acc.mSubOffset[2] || 0 != acc.mSubOffset[3]) {
|
||||
pMesh.mNumUVComponents[pInput.mIndex] = 3;
|
||||
}
|
||||
} else {
|
||||
ASSIMP_LOG_ERROR("Collada: too many texture coordinate sets. Skipping.");
|
||||
}
|
||||
break;
|
||||
case IT_Color:
|
||||
// up to 4 color sets are fine, ignore the others
|
||||
if (pInput.mIndex < AI_MAX_NUMBER_OF_COLOR_SETS) {
|
||||
// pad to current vertex count if necessary
|
||||
if (pMesh.mColors[pInput.mIndex].size() < pMesh.mPositions.size() - 1)
|
||||
pMesh.mColors[pInput.mIndex].insert(pMesh.mColors[pInput.mIndex].end(),
|
||||
pMesh.mPositions.size() - pMesh.mColors[pInput.mIndex].size() - 1, aiColor4D(0, 0, 0, 1));
|
||||
|
||||
aiColor4D result(0, 0, 0, 1);
|
||||
for (size_t i = 0; i < pInput.mResolved->mSize; ++i) {
|
||||
result[static_cast<unsigned int>(i)] = obj[pInput.mResolved->mSubOffset[i]];
|
||||
}
|
||||
pMesh.mColors[pInput.mIndex].push_back(result);
|
||||
} else {
|
||||
ASSIMP_LOG_ERROR("Collada: too many vertex color sets. Skipping.");
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
// IT_Invalid and IT_Vertex
|
||||
ai_assert(false && "shouldn't ever get here");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -54,18 +54,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <assimp/ByteSwapper.h>
|
||||
#include <assimp/ParsingUtils.h>
|
||||
|
||||
#include <algorithm> // std::transform
|
||||
#include "FBXUtil.h"
|
||||
|
||||
namespace Assimp {
|
||||
namespace FBX {
|
||||
|
||||
using namespace Util;
|
||||
using namespace Util;
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Material::Material(uint64_t id, const Element& element, const Document& doc, const std::string& name)
|
||||
: Object(id,element,name)
|
||||
{
|
||||
Material::Material(uint64_t id, const Element& element, const Document& doc, const std::string& name) :
|
||||
Object(id,element,name) {
|
||||
const Scope& sc = GetRequiredScope(element);
|
||||
|
||||
const Element* const ShadingModel = sc["ShadingModel"];
|
||||
@@ -77,23 +75,21 @@ Material::Material(uint64_t id, const Element& element, const Document& doc, con
|
||||
|
||||
if(ShadingModel) {
|
||||
shading = ParseTokenAsString(GetRequiredToken(*ShadingModel,0));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
DOMWarning("shading mode not specified, assuming phong",&element);
|
||||
shading = "phong";
|
||||
}
|
||||
|
||||
std::string templateName;
|
||||
|
||||
// lower-case shading because Blender (for example) writes "Phong"
|
||||
std::transform(shading.data(), shading.data() + shading.size(), std::addressof(shading[0]), Assimp::ToLower<char>);
|
||||
for (size_t i = 0; i < shading.length(); ++i) {
|
||||
shading[i] = static_cast<char>(tolower(shading[i]));
|
||||
}
|
||||
std::string templateName;
|
||||
if(shading == "phong") {
|
||||
templateName = "Material.FbxSurfacePhong";
|
||||
}
|
||||
else if(shading == "lambert") {
|
||||
} else if(shading == "lambert") {
|
||||
templateName = "Material.FbxSurfaceLambert";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
DOMWarning("shading mode not recognized: " + shading,&element);
|
||||
}
|
||||
|
||||
@@ -102,20 +98,19 @@ Material::Material(uint64_t id, const Element& element, const Document& doc, con
|
||||
// resolve texture links
|
||||
const std::vector<const Connection*>& conns = doc.GetConnectionsByDestinationSequenced(ID());
|
||||
for(const Connection* con : conns) {
|
||||
|
||||
// texture link to properties, not objects
|
||||
if (!con->PropertyName().length()) {
|
||||
if ( 0 == con->PropertyName().length()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const Object* const ob = con->SourceObject();
|
||||
if(!ob) {
|
||||
if(nullptr == ob) {
|
||||
DOMWarning("failed to read source object for texture link, ignoring",&element);
|
||||
continue;
|
||||
}
|
||||
|
||||
const Texture* const tex = dynamic_cast<const Texture*>(ob);
|
||||
if(!tex) {
|
||||
if(nullptr == tex) {
|
||||
const LayeredTexture* const layeredTexture = dynamic_cast<const LayeredTexture*>(ob);
|
||||
if(!layeredTexture) {
|
||||
DOMWarning("source object for texture link is not a texture or layered texture, ignoring",&element);
|
||||
@@ -128,9 +123,7 @@ Material::Material(uint64_t id, const Element& element, const Document& doc, con
|
||||
|
||||
layeredTextures[prop] = layeredTexture;
|
||||
((LayeredTexture*)layeredTexture)->fillTexture(doc);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
const std::string& prop = con->PropertyName();
|
||||
if (textures.find(prop) != textures.end()) {
|
||||
DOMWarning("duplicate texture link: " + prop,&element);
|
||||
@@ -138,23 +131,20 @@ Material::Material(uint64_t id, const Element& element, const Document& doc, con
|
||||
|
||||
textures[prop] = tex;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Material::~Material()
|
||||
{
|
||||
Material::~Material() {
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Texture::Texture(uint64_t id, const Element& element, const Document& doc, const std::string& name)
|
||||
: Object(id,element,name)
|
||||
, uvScaling(1.0f,1.0f)
|
||||
, media(0)
|
||||
{
|
||||
Texture::Texture(uint64_t id, const Element& element, const Document& doc, const std::string& name) :
|
||||
Object(id,element,name),
|
||||
uvScaling(1.0f,1.0f),
|
||||
media(0) {
|
||||
const Scope& sc = GetRequiredScope(element);
|
||||
|
||||
const Element* const Type = sc["Type"];
|
||||
@@ -194,8 +184,7 @@ Texture::Texture(uint64_t id, const Element& element, const Document& doc, const
|
||||
crop[1] = ParseTokenAsInt(GetRequiredToken(*Cropping,1));
|
||||
crop[2] = ParseTokenAsInt(GetRequiredToken(*Cropping,2));
|
||||
crop[3] = ParseTokenAsInt(GetRequiredToken(*Cropping,3));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// vc8 doesn't support the crop() syntax in initialization lists
|
||||
// (and vc9 WARNS about the new (i.e. compliant) behaviour).
|
||||
crop[0] = crop[1] = crop[2] = crop[3] = 0;
|
||||
@@ -226,7 +215,7 @@ Texture::Texture(uint64_t id, const Element& element, const Document& doc, const
|
||||
const std::vector<const Connection*>& conns = doc.GetConnectionsByDestinationSequenced(ID());
|
||||
for(const Connection* con : conns) {
|
||||
const Object* const ob = con->SourceObject();
|
||||
if(!ob) {
|
||||
if (nullptr == ob) {
|
||||
DOMWarning("failed to read source object for texture link, ignoring",&element);
|
||||
continue;
|
||||
}
|
||||
@@ -240,46 +229,38 @@ Texture::Texture(uint64_t id, const Element& element, const Document& doc, const
|
||||
}
|
||||
|
||||
|
||||
Texture::~Texture()
|
||||
{
|
||||
|
||||
Texture::~Texture() {
|
||||
// empty
|
||||
}
|
||||
|
||||
LayeredTexture::LayeredTexture(uint64_t id, const Element& element, const Document& /*doc*/, const std::string& name)
|
||||
: Object(id,element,name)
|
||||
,blendMode(BlendMode_Modulate)
|
||||
,alpha(1)
|
||||
{
|
||||
LayeredTexture::LayeredTexture(uint64_t id, const Element& element, const Document& /*doc*/, const std::string& name) :
|
||||
Object(id,element,name),
|
||||
blendMode(BlendMode_Modulate),
|
||||
alpha(1) {
|
||||
const Scope& sc = GetRequiredScope(element);
|
||||
|
||||
const Element* const BlendModes = sc["BlendModes"];
|
||||
const Element* const Alphas = sc["Alphas"];
|
||||
|
||||
|
||||
if(BlendModes!=0)
|
||||
{
|
||||
if (nullptr != BlendModes) {
|
||||
blendMode = (BlendMode)ParseTokenAsInt(GetRequiredToken(*BlendModes,0));
|
||||
}
|
||||
if(Alphas!=0)
|
||||
{
|
||||
if (nullptr != Alphas) {
|
||||
alpha = ParseTokenAsFloat(GetRequiredToken(*Alphas,0));
|
||||
}
|
||||
}
|
||||
|
||||
LayeredTexture::~LayeredTexture()
|
||||
{
|
||||
|
||||
LayeredTexture::~LayeredTexture() {
|
||||
// empty
|
||||
}
|
||||
|
||||
void LayeredTexture::fillTexture(const Document& doc)
|
||||
{
|
||||
void LayeredTexture::fillTexture(const Document& doc) {
|
||||
const std::vector<const Connection*>& conns = doc.GetConnectionsByDestinationSequenced(ID());
|
||||
for(size_t i = 0; i < conns.size();++i)
|
||||
{
|
||||
for(size_t i = 0; i < conns.size();++i) {
|
||||
const Connection* con = conns.at(i);
|
||||
|
||||
const Object* const ob = con->SourceObject();
|
||||
if(!ob) {
|
||||
if (nullptr == ob) {
|
||||
DOMWarning("failed to read source object for texture link, ignoring",&element);
|
||||
continue;
|
||||
}
|
||||
@@ -290,13 +271,11 @@ void LayeredTexture::fillTexture(const Document& doc)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Video::Video(uint64_t id, const Element& element, const Document& doc, const std::string& name)
|
||||
: Object(id,element,name)
|
||||
, contentLength(0)
|
||||
, content(0)
|
||||
{
|
||||
Video::Video(uint64_t id, const Element& element, const Document& doc, const std::string& name) :
|
||||
Object(id,element,name),
|
||||
contentLength(0),
|
||||
content(0) {
|
||||
const Scope& sc = GetRequiredScope(element);
|
||||
|
||||
const Element* const Type = sc["Type"];
|
||||
@@ -324,52 +303,43 @@ Video::Video(uint64_t id, const Element& element, const Document& doc, const std
|
||||
if (!token.IsBinary()) {
|
||||
if (*data != '"') {
|
||||
DOMError("embedded content is not surrounded by quotation marks", &element);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
size_t targetLength = 0;
|
||||
auto numTokens = Content->Tokens().size();
|
||||
// First time compute size (it could be large like 64Gb and it is good to allocate it once)
|
||||
for (uint32_t tokenIdx = 0; tokenIdx < numTokens; ++tokenIdx)
|
||||
{
|
||||
for (uint32_t tokenIdx = 0; tokenIdx < numTokens; ++tokenIdx) {
|
||||
const Token& dataToken = GetRequiredToken(*Content, tokenIdx);
|
||||
size_t tokenLength = dataToken.end() - dataToken.begin() - 2; // ignore double quotes
|
||||
const char* base64data = dataToken.begin() + 1;
|
||||
const size_t outLength = Util::ComputeDecodedSizeBase64(base64data, tokenLength);
|
||||
if (outLength == 0)
|
||||
{
|
||||
if (outLength == 0) {
|
||||
DOMError("Corrupted embedded content found", &element);
|
||||
}
|
||||
targetLength += outLength;
|
||||
}
|
||||
if (targetLength == 0)
|
||||
{
|
||||
if (targetLength == 0) {
|
||||
DOMError("Corrupted embedded content found", &element);
|
||||
}
|
||||
content = new uint8_t[targetLength];
|
||||
contentLength = static_cast<uint64_t>(targetLength);
|
||||
size_t dst_offset = 0;
|
||||
for (uint32_t tokenIdx = 0; tokenIdx < numTokens; ++tokenIdx)
|
||||
{
|
||||
for (uint32_t tokenIdx = 0; tokenIdx < numTokens; ++tokenIdx) {
|
||||
const Token& dataToken = GetRequiredToken(*Content, tokenIdx);
|
||||
size_t tokenLength = dataToken.end() - dataToken.begin() - 2; // ignore double quotes
|
||||
const char* base64data = dataToken.begin() + 1;
|
||||
dst_offset += Util::DecodeBase64(base64data, tokenLength, content + dst_offset, targetLength - dst_offset);
|
||||
}
|
||||
if (targetLength != dst_offset)
|
||||
{
|
||||
if (targetLength != dst_offset) {
|
||||
delete[] content;
|
||||
contentLength = 0;
|
||||
DOMError("Corrupted embedded content found", &element);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (static_cast<size_t>(token.end() - data) < 5) {
|
||||
} else if (static_cast<size_t>(token.end() - data) < 5) {
|
||||
DOMError("binary data array is too short, need five (5) bytes for type signature and element count", &element);
|
||||
}
|
||||
else if (*data != 'R') {
|
||||
} else if (*data != 'R') {
|
||||
DOMWarning("video content is not raw binary data, ignoring", &element);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// read number of elements
|
||||
uint32_t len = 0;
|
||||
::memcpy(&len, data + 1, sizeof(len));
|
||||
@@ -380,8 +350,7 @@ Video::Video(uint64_t id, const Element& element, const Document& doc, const std
|
||||
content = new uint8_t[len];
|
||||
::memcpy(content, data + 5, len);
|
||||
}
|
||||
} catch (const runtime_error& runtimeError)
|
||||
{
|
||||
} catch (const runtime_error& runtimeError) {
|
||||
//we don't need the content data for contents that has already been loaded
|
||||
ASSIMP_LOG_VERBOSE_DEBUG_F("Caught exception in FBXMaterial (likely because content was already loaded): ",
|
||||
runtimeError.what());
|
||||
@@ -392,14 +361,11 @@ Video::Video(uint64_t id, const Element& element, const Document& doc, const std
|
||||
}
|
||||
|
||||
|
||||
Video::~Video()
|
||||
{
|
||||
if(content) {
|
||||
delete[] content;
|
||||
}
|
||||
Video::~Video() {
|
||||
delete[] content;
|
||||
}
|
||||
|
||||
} //!FBX
|
||||
} //!Assimp
|
||||
|
||||
#endif
|
||||
#endif // ASSIMP_BUILD_NO_FBX_IMPORTER
|
||||
|
||||
@@ -1229,7 +1229,7 @@ unsigned int glTF2Exporter::ExportNode(const aiNode* n, Ref<Node>& parent)
|
||||
node->name = name;
|
||||
|
||||
if (!n->mTransformation.IsIdentity()) {
|
||||
if (mScene->mNumAnimations > 0) {
|
||||
if (mScene->mNumAnimations > 0 || (mProperties && mProperties->HasPropertyBool("GLTF2_NODE_IN_TRS"))) {
|
||||
aiQuaternion quaternion;
|
||||
n->mTransformation.Decompose(*reinterpret_cast<aiVector3D *>(&node->scale.value), quaternion, *reinterpret_cast<aiVector3D *>(&node->translation.value));
|
||||
|
||||
|
||||
@@ -78,6 +78,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <assimp/Profiler.h>
|
||||
#include <assimp/commonMetaData.h>
|
||||
|
||||
#include <exception>
|
||||
#include <set>
|
||||
#include <memory>
|
||||
#include <cctype>
|
||||
|
||||
@@ -44,6 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#ifndef INCLUDED_AI_IMPORTER_H
|
||||
#define INCLUDED_AI_IMPORTER_H
|
||||
|
||||
#include <exception>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
Reference in New Issue
Block a user