Merge branch 'master' into master

pull/2969/head
Kim Kulling 2020-02-10 21:37:01 +01:00 committed by GitHub
commit 471f9b23c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 293 additions and 328 deletions

2
.github/FUNDING.yml vendored
View File

@ -1,2 +1,2 @@
patreon: assimp
ko_fi: kimkulling
Paypal: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4JRJVPXC4QJM4

View File

@ -41,13 +41,13 @@ CMAKE_MINIMUM_REQUIRED( VERSION 3.0 )
# Toggles the use of the hunter package manager
option(HUNTER_ENABLED "Enable Hunter package manager support" OFF)
include("cmake/HunterGate.cmake")
HunterGate(
IF(HUNTER_ENABLED)
include("cmake/HunterGate.cmake")
HunterGate(
URL "https://github.com/ruslo/hunter/archive/v0.23.176.tar.gz"
SHA1 "2e9ae973d028660b735ac4c6142725ca36a0048a"
)
)
IF(HUNTER_ENABLED)
add_definitions(-DASSIMP_USE_HUNTER)
ENDIF(HUNTER_ENABLED)
@ -437,7 +437,9 @@ ELSE(HUNTER_ENABLED)
DESTINATION "${ASSIMP_LIB_INSTALL_DIR}/cmake/assimp-${ASSIMP_VERSION_MAJOR}.${ASSIMP_VERSION_MINOR}" COMPONENT ${LIBASSIMP-DEV_COMPONENT})
ENDIF(HUNTER_ENABLED)
FIND_PACKAGE( DirectX )
if (ASSIMP_BUILD_SAMPLES OR ASSIMP_BUILD_SAMPLES)
FIND_PACKAGE(DirectX)
endif(ASSIMP_BUILD_SAMPLES OR ASSIMP_BUILD_SAMPLES)
IF( BUILD_DOCS )
ADD_SUBDIRECTORY(doc)

View File

@ -198,6 +198,7 @@ SET( Common_SRCS
Common/CreateAnimMesh.cpp
Common/simd.h
Common/simd.cpp
Common/material.cpp
)
SOURCE_GROUP(Common FILES ${Common_SRCS})

View File

@ -250,7 +250,7 @@ aiNode* COBImporter::BuildNodes(const Node& root,const Scene& scin,aiScene* fill
const Mesh& ndmesh = (const Mesh&)(root);
if (ndmesh.vertex_positions.size() && ndmesh.texture_coords.size()) {
typedef std::pair<unsigned int,Mesh::FaceRefList> Entry;
typedef std::pair<const unsigned int,Mesh::FaceRefList> Entry;
for(const Entry& reflist : ndmesh.temp_map) {
{ // create mesh
size_t n = 0;

View File

@ -1312,7 +1312,6 @@ void SceneCombiner::Copy(aiMetadata** _dest, const aiMetadata* src) {
aiMetadata* dest = *_dest = aiMetadata::Alloc( src->mNumProperties );
std::copy(src->mKeys, src->mKeys + src->mNumProperties, dest->mKeys);
dest->mValues = new aiMetadataEntry[src->mNumProperties];
for (unsigned int i = 0; i < src->mNumProperties; ++i) {
aiMetadataEntry& in = src->mValues[i];
aiMetadataEntry& out = dest->mValues[i];

View File

@ -37,7 +37,7 @@ The ASSBIN file format is composed of chunks to represent the hierarchical aiSce
This makes the format extensible and allows backward-compatibility with future data structure
versions. The <tt>&lt;root&gt;/code/assbin_chunks.h</tt> header contains some magic constants
for use by stand-alone ASSBIN loaders. Also, Assimp's own file writer can be found
in <tt>&lt;root&gt;/tools/assimp_cmd/WriteDumb.cpp</tt> (yes, the 'b' is no typo ...).
in <tt>&lt;root&gt;/tools/assimp_cmd/WriteDump.cpp</tt> (yes, the 'b' is no typo ...).
@verbatim

View File

@ -0,0 +1,97 @@
/*
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.
----------------------------------------------------------------------
*/
/// @file material.cpp
/** Implement common material related functions. */
#include <assimp/ai_assert.h>
#include <assimp/material.h>
// -------------------------------------------------------------------------------
const char* TextureTypeToString(aiTextureType in)
{
switch (in)
{
case aiTextureType_NONE:
return "n/a";
case aiTextureType_DIFFUSE:
return "Diffuse";
case aiTextureType_SPECULAR:
return "Specular";
case aiTextureType_AMBIENT:
return "Ambient";
case aiTextureType_EMISSIVE:
return "Emissive";
case aiTextureType_OPACITY:
return "Opacity";
case aiTextureType_NORMALS:
return "Normals";
case aiTextureType_HEIGHT:
return "Height";
case aiTextureType_SHININESS:
return "Shininess";
case aiTextureType_DISPLACEMENT:
return "Displacement";
case aiTextureType_LIGHTMAP:
return "Lightmap";
case aiTextureType_REFLECTION:
return "Reflection";
case aiTextureType_BASE_COLOR:
return "BaseColor";
case aiTextureType_NORMAL_CAMERA:
return "NormalCamera";
case aiTextureType_EMISSION_COLOR:
return "EmissionColor";
case aiTextureType_METALNESS:
return "Metalness";
case aiTextureType_DIFFUSE_ROUGHNESS:
return "DiffuseRoughness";
case aiTextureType_AMBIENT_OCCLUSION:
return "AmbientOcclusion";
case aiTextureType_UNKNOWN:
return "Unknown";
default:
break;
}
ai_assert(false);
return "BUG";
}

View File

@ -448,11 +448,11 @@ void ResolveVertexDataArray(std::vector<T>& data_out, const Scope& source,
std::vector<T> tempData;
ParseVectorDataArray(tempData, GetRequiredElement(source, dataElementName));
if (tempData.size() != vertex_count) {
FBXImporter::LogError(Formatter::format("length of input data unexpected for ByVertice mapping: ")
<< tempData.size() << ", expected " << vertex_count);
return;
}
if (tempData.size() != vertex_count) {
FBXImporter::LogError(Formatter::format("length of input data unexpected for ByVertice mapping: ")
<< tempData.size() << ", expected " << vertex_count);
return;
}
data_out.resize(vertex_count);
for (size_t i = 0, e = tempData.size(); i < e; ++i) {
@ -467,22 +467,16 @@ void ResolveVertexDataArray(std::vector<T>& data_out, const Scope& source,
std::vector<T> tempData;
ParseVectorDataArray(tempData, GetRequiredElement(source, dataElementName));
if (tempData.size() != vertex_count) {
FBXImporter::LogError(Formatter::format("length of input data unexpected for ByVertice mapping: ")
<< tempData.size() << ", expected " << vertex_count);
return;
}
std::vector<int> uvIndices;
ParseVectorDataArray(uvIndices,GetRequiredElement(source,indexDataElementName));
if (uvIndices.size() != vertex_count) {
FBXImporter::LogError(Formatter::format("length of input data unexpected for ByVertice mapping: ")
<< uvIndices.size() << ", expected " << vertex_count);
return;
}
if (uvIndices.size() != vertex_count) {
FBXImporter::LogError(Formatter::format("length of input data unexpected for ByVertice mapping: ")
<< uvIndices.size() << ", expected " << vertex_count);
return;
}
data_out.resize(vertex_count);
data_out.resize(vertex_count);
for (size_t i = 0, e = uvIndices.size(); i < e; ++i) {
@ -512,22 +506,16 @@ void ResolveVertexDataArray(std::vector<T>& data_out, const Scope& source,
std::vector<T> tempData;
ParseVectorDataArray(tempData, GetRequiredElement(source, dataElementName));
if (tempData.size() != vertex_count) {
FBXImporter::LogError(Formatter::format("length of input data unexpected for ByPolygonVertex mapping: ")
<< tempData.size() << ", expected " << vertex_count);
return;
}
std::vector<int> uvIndices;
ParseVectorDataArray(uvIndices,GetRequiredElement(source,indexDataElementName));
if (uvIndices.size() != vertex_count) {
FBXImporter::LogError(Formatter::format("length of input data unexpected for ByPolygonVertex mapping: ")
<< uvIndices.size() << ", expected " << vertex_count);
return;
}
if (uvIndices.size() != vertex_count) {
FBXImporter::LogError(Formatter::format("length of input data unexpected for ByPolygonVertex mapping: ")
<< uvIndices.size() << ", expected " << vertex_count);
return;
}
data_out.resize(vertex_count);
data_out.resize(vertex_count);
const T empty;
unsigned int next = 0;

View File

@ -323,7 +323,7 @@ public:
// oh well.
bool have_param = false, have_point = false;
IfcVector3 point;
for(const Entry sel :entity.Trim1) {
for(const Entry& sel :entity.Trim1) {
if (const ::Assimp::STEP::EXPRESS::REAL* const r = sel->ToPtr<::Assimp::STEP::EXPRESS::REAL>()) {
range.first = *r;
have_param = true;
@ -340,7 +340,7 @@ public:
}
}
have_param = false, have_point = false;
for(const Entry sel :entity.Trim2) {
for(const Entry& sel :entity.Trim2) {
if (const ::Assimp::STEP::EXPRESS::REAL* const r = sel->ToPtr<::Assimp::STEP::EXPRESS::REAL>()) {
range.second = *r;
have_param = true;

View File

@ -340,39 +340,13 @@ void HL1MDLLoader::load_sequence_groups_files() {
}
// ------------------------------------------------------------------------------------------------
/** @brief Read an MDL texture.
*
* @note This method is taken from HL1 source code.
* source: file: studio_utils.c
* function(s): UploadTexture
*/
// Read an MDL texture.
void HL1MDLLoader::read_texture(const Texture_HL1 *ptexture,
uint8_t *data, uint8_t *pal, aiTexture *pResult,
aiColor3D &last_palette_color) {
int outwidth, outheight;
int i, j;
static const size_t BuffenLen = 256;
int row1[BuffenLen], row2[BuffenLen], col1[BuffenLen], col2[BuffenLen];
unsigned char *pix1, *pix2, *pix3, *pix4;
// convert texture to power of 2
for (outwidth = 1; outwidth < ptexture->width; outwidth <<= 1)
;
if ( outwidth > static_cast<int>(BuffenLen)) {
outwidth = BuffenLen;
}
for (outheight = 1; outheight < ptexture->height; outheight <<= 1)
;
if (static_cast<size_t>(outheight) > BuffenLen) {
outheight = BuffenLen;
}
pResult->mFilename = ptexture->name;
pResult->mWidth = outwidth;
pResult->mHeight = outheight;
pResult->mWidth = static_cast<unsigned int>(ptexture->width);
pResult->mHeight = static_cast<unsigned int>(ptexture->height);
pResult->achFormatHint[0] = 'r';
pResult->achFormatHint[1] = 'g';
pResult->achFormatHint[2] = 'b';
@ -383,31 +357,15 @@ void HL1MDLLoader::read_texture(const Texture_HL1 *ptexture,
pResult->achFormatHint[7] = '8';
pResult->achFormatHint[8] = '\0';
aiTexel *out = pResult->pcData = new aiTexel[outwidth * outheight];
const size_t num_pixels = pResult->mWidth * pResult->mHeight;
aiTexel *out = pResult->pcData = new aiTexel[num_pixels];
for (i = 0; i < outwidth; i++) {
col1[i] = (int)((i + 0.25) * (ptexture->width / (float)outwidth));
col2[i] = (int)((i + 0.75) * (ptexture->width / (float)outwidth));
}
for (i = 0; i < outheight; i++) {
row1[i] = (int)((i + 0.25) * (ptexture->height / (float)outheight)) * ptexture->width;
row2[i] = (int)((i + 0.75) * (ptexture->height / (float)outheight)) * ptexture->width;
}
// scale down and convert to 32bit RGB
for (i = 0; i < outheight; i++) {
for (j = 0; j < outwidth; j++, out++) {
pix1 = &pal[data[row1[i] + col1[j]] * 3];
pix2 = &pal[data[row1[i] + col2[j]] * 3];
pix3 = &pal[data[row2[i] + col1[j]] * 3];
pix4 = &pal[data[row2[i] + col2[j]] * 3];
out->r = (pix1[0] + pix2[0] + pix3[0] + pix4[0]) >> 2;
out->g = (pix1[1] + pix2[1] + pix3[1] + pix4[1]) >> 2;
out->b = (pix1[2] + pix2[2] + pix3[2] + pix4[2]) >> 2;
out->a = 0xFF;
}
// Convert indexed 8 bit to 32 bit RGBA.
for (size_t i = 0; i < num_pixels; ++i, ++out) {
out->r = pal[data[i] * 3];
out->g = pal[data[i] * 3 + 1];
out->b = pal[data[i] * 3 + 2];
out->a = 255;
}
// Get the last palette color.

View File

@ -1421,11 +1421,11 @@ void MDLImporter::InternReadFile_3DGS_MDL7( )
avOutList[i].reserve(3);
// buffer to held the names of all groups in the file
const size_t buffersize( AI_MDL7_MAX_GROUPNAMESIZE*pcHeader->groups_num );
char* aszGroupNameBuffer = new char[ buffersize ];
const size_t buffersize(AI_MDL7_MAX_GROUPNAMESIZE*pcHeader->groups_num);
char* aszGroupNameBuffer = new char[ buffersize ];
// read all groups
for (unsigned int iGroup = 0; iGroup < (unsigned int)pcHeader->groups_num;++iGroup) {
for (unsigned int iGroup = 0; iGroup < (unsigned int)pcHeader->groups_num; ++iGroup) {
MDL::IntGroupInfo_MDL7 groupInfo((BE_NCONST MDL::Group_MDL7*)szCurrent,iGroup);
szCurrent = (const unsigned char*)(groupInfo.pcGroup+1);

View File

@ -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,
@ -36,7 +35,6 @@ 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 "ArmaturePopulate.h"
@ -50,219 +48,215 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
namespace Assimp {
/// The default class constructor.
ArmaturePopulate::ArmaturePopulate() : BaseProcess()
{}
ArmaturePopulate::ArmaturePopulate() :
BaseProcess() {
// do nothing
}
/// The class destructor.
ArmaturePopulate::~ArmaturePopulate()
{}
ArmaturePopulate::~ArmaturePopulate() {
// do nothing
}
bool ArmaturePopulate::IsActive(unsigned int pFlags) const {
return (pFlags & aiProcess_PopulateArmatureData) != 0;
return (pFlags & aiProcess_PopulateArmatureData) != 0;
}
void ArmaturePopulate::SetupProperties(const Importer *pImp) {
// do nothing
// do nothing
}
void ArmaturePopulate::Execute(aiScene *out) {
// Now convert all bone positions to the correct mOffsetMatrix
std::vector<aiBone *> bones;
std::vector<aiNode *> nodes;
std::map<aiBone *, aiNode *> bone_stack;
BuildBoneList(out->mRootNode, out->mRootNode, out, bones);
BuildNodeList(out->mRootNode, nodes);
// Now convert all bone positions to the correct mOffsetMatrix
std::vector<aiBone *> bones;
std::vector<aiNode *> nodes;
std::map<aiBone *, aiNode *> bone_stack;
BuildBoneList(out->mRootNode, out->mRootNode, out, bones);
BuildNodeList(out->mRootNode, nodes);
BuildBoneStack(out->mRootNode, out->mRootNode, out, bones, bone_stack, nodes);
BuildBoneStack(out->mRootNode, out->mRootNode, out, bones, bone_stack, nodes);
ASSIMP_LOG_DEBUG_F("Bone stack size: ", bone_stack.size());
ASSIMP_LOG_DEBUG_F("Bone stack size: ", bone_stack.size());
for (std::pair<aiBone *, aiNode *> kvp : bone_stack) {
aiBone *bone = kvp.first;
aiNode *bone_node = kvp.second;
ASSIMP_LOG_DEBUG_F("active node lookup: ", bone->mName.C_Str());
// lcl transform grab - done in generate_nodes :)
for (std::pair<aiBone *, aiNode *> kvp : bone_stack) {
aiBone *bone = kvp.first;
aiNode *bone_node = kvp.second;
ASSIMP_LOG_DEBUG_F("active node lookup: ", bone->mName.C_Str());
// lcl transform grab - done in generate_nodes :)
// bone->mOffsetMatrix = bone_node->mTransformation;
aiNode *armature = GetArmatureRoot(bone_node, bones);
// bone->mOffsetMatrix = bone_node->mTransformation;
aiNode *armature = GetArmatureRoot(bone_node, bones);
ai_assert(armature);
ai_assert(armature);
// set up bone armature id
bone->mArmature = armature;
// set up bone armature id
bone->mArmature = armature;
// set this bone node to be referenced properly
ai_assert(bone_node);
bone->mNode = bone_node;
}
// set this bone node to be referenced properly
ai_assert(bone_node);
bone->mNode = bone_node;
}
}
/* Reprocess all nodes to calculate bone transforms properly based on the REAL
* mOffsetMatrix not the local. */
/* Before this would use mesh transforms which is wrong for bone transforms */
/* Before this would work for simple character skeletons but not complex meshes
* with multiple origins */
/* Source: sketch fab log cutter fbx */
// Reprocess all nodes to calculate bone transforms properly based on the REAL
// mOffsetMatrix not the local.
// Before this would use mesh transforms which is wrong for bone transforms
// Before this would work for simple character skeletons but not complex meshes
// with multiple origins
// Source: sketch fab log cutter fbx
void ArmaturePopulate::BuildBoneList(aiNode *current_node,
const aiNode *root_node,
const aiScene *scene,
std::vector<aiBone *> &bones) {
ai_assert(scene);
for (unsigned int nodeId = 0; nodeId < current_node->mNumChildren; ++nodeId) {
aiNode *child = current_node->mChildren[nodeId];
ai_assert(child);
ai_assert(scene);
for (unsigned int nodeId = 0; nodeId < current_node->mNumChildren; ++nodeId) {
aiNode *child = current_node->mChildren[nodeId];
ai_assert(child);
// check for bones
for (unsigned int meshId = 0; meshId < child->mNumMeshes; ++meshId) {
ai_assert(child->mMeshes);
unsigned int mesh_index = child->mMeshes[meshId];
aiMesh *mesh = scene->mMeshes[mesh_index];
ai_assert(mesh);
// check for bones
for (unsigned int meshId = 0; meshId < child->mNumMeshes; ++meshId) {
ai_assert(child->mMeshes);
unsigned int mesh_index = child->mMeshes[meshId];
aiMesh *mesh = scene->mMeshes[mesh_index];
ai_assert(mesh);
for (unsigned int boneId = 0; boneId < mesh->mNumBones; ++boneId) {
aiBone *bone = mesh->mBones[boneId];
ai_assert(bone);
for (unsigned int boneId = 0; boneId < mesh->mNumBones; ++boneId) {
aiBone *bone = mesh->mBones[boneId];
ai_assert(bone);
// duplicate meshes exist with the same bones sometimes :)
// so this must be detected
if (std::find(bones.begin(), bones.end(), bone) == bones.end()) {
// add the element once
bones.push_back(bone);
// duplicate mehes exist with the same bones sometimes :)
// so this must be detected
if (std::find(bones.begin(), bones.end(), bone) == bones.end()) {
// add the element once
bones.push_back(bone);
}
}
// find mesh and get bones
// then do recursive lookup for bones in root node hierarchy
}
}
// find mesh and get bones
// then do recursive lookup for bones in root node hierarchy
BuildBoneList(child, root_node, scene, bones);
}
BuildBoneList(child, root_node, scene, bones);
}
}
/* Prepare flat node list which can be used for non recursive lookups later */
// Prepare flat node list which can be used for non recursive lookups later
void ArmaturePopulate::BuildNodeList(const aiNode *current_node,
std::vector<aiNode *> &nodes) {
ai_assert(current_node);
ai_assert(current_node);
for (unsigned int nodeId = 0; nodeId < current_node->mNumChildren; ++nodeId) {
aiNode *child = current_node->mChildren[nodeId];
ai_assert(child);
for (unsigned int nodeId = 0; nodeId < current_node->mNumChildren; ++nodeId) {
aiNode *child = current_node->mChildren[nodeId];
ai_assert(child);
nodes.push_back(child);
if (child->mNumMeshes == 0) {
nodes.push_back(child);
}
BuildNodeList(child, nodes);
BuildNodeList(child, nodes);
}
}
/* A bone stack allows us to have multiple armatures, with the same bone names
* A bone stack allows us also to retrieve bones true transform even with
* duplicate names :)
*/
// A bone stack allows us to have multiple armatures, with the same bone names
// A bone stack allows us also to retrieve bones true transform even with
// duplicate names :)
void ArmaturePopulate::BuildBoneStack(aiNode *current_node,
const aiNode *root_node,
const aiScene *scene,
const std::vector<aiBone *> &bones,
std::map<aiBone *, aiNode *> &bone_stack,
std::vector<aiNode *> &node_stack) {
ai_assert(scene);
ai_assert(root_node);
ai_assert(!node_stack.empty());
std::vector<aiNode *> &node_stack) {
ai_assert(scene);
ai_assert(root_node);
ai_assert(!node_stack.empty());
for (aiBone *bone : bones) {
ai_assert(bone);
aiNode *node = GetNodeFromStack(bone->mName, node_stack);
if (node == nullptr) {
node_stack.clear();
BuildNodeList(root_node, node_stack);
ASSIMP_LOG_DEBUG_F("Resetting bone stack: nullptr element ", bone->mName.C_Str());
for (aiBone *bone : bones) {
ai_assert(bone);
aiNode *node = GetNodeFromStack(bone->mName, node_stack);
if (node == nullptr) {
node_stack.clear();
BuildNodeList(root_node, node_stack);
ASSIMP_LOG_DEBUG_F("Resetting bone stack: nullptr element ", bone->mName.C_Str());
node = GetNodeFromStack(bone->mName, node_stack);
node = GetNodeFromStack(bone->mName, node_stack);
if (!node) {
ASSIMP_LOG_ERROR("serious import issue node for bone was not detected");
continue;
}
if (!node) {
ASSIMP_LOG_ERROR("serious import issue node for bone was not detected");
continue;
}
}
ASSIMP_LOG_DEBUG_F("Successfully added bone[", bone->mName.C_Str(), "] to stack and bone node is: ", node->mName.C_Str());
bone_stack.insert(std::pair<aiBone *, aiNode *>(bone, node));
}
ASSIMP_LOG_DEBUG_F("Successfully added bone[", bone->mName.C_Str(), "] to stack and bone node is: ", node->mName.C_Str());
bone_stack.insert(std::pair<aiBone *, aiNode *>(bone, node));
}
}
/* Returns the armature root node */
/* This is required to be detected for a bone initially, it will recurse up
* until it cannot find another bone and return the node No known failure
* points. (yet)
*/
// Returns the armature root node
// This is required to be detected for a bone initially, it will recurse up
// until it cannot find another bone and return the node No known failure
// points. (yet)
aiNode *ArmaturePopulate::GetArmatureRoot(aiNode *bone_node,
std::vector<aiBone *> &bone_list) {
while (bone_node) {
if (!IsBoneNode(bone_node->mName, bone_list)) {
ASSIMP_LOG_DEBUG_F("GetArmatureRoot() Found valid armature: ", bone_node->mName.C_Str());
return bone_node;
while (bone_node) {
if (!IsBoneNode(bone_node->mName, bone_list)) {
ASSIMP_LOG_DEBUG_F("GetArmatureRoot() Found valid armature: ", bone_node->mName.C_Str());
return bone_node;
}
bone_node = bone_node->mParent;
}
bone_node = bone_node->mParent;
}
ASSIMP_LOG_ERROR("GetArmatureRoot() can't find armature!");
return nullptr;
ASSIMP_LOG_ERROR("GetArmatureRoot() can't find armature!");
return nullptr;
}
/* Simple IsBoneNode check if this could be a bone */
// Simple IsBoneNode check if this could be a bone
bool ArmaturePopulate::IsBoneNode(const aiString &bone_name,
std::vector<aiBone *> &bones) {
for (aiBone *bone : bones) {
if (bone->mName == bone_name) {
return true;
for (aiBone *bone : bones) {
if (bone->mName == bone_name) {
return true;
}
}
}
return false;
return false;
}
/* Pop this node by name from the stack if found */
/* Used in multiple armature situations with duplicate node / bone names */
/* Known flaw: cannot have nodes with bone names, will be fixed in later release
*/
/* (serious to be fixed) Known flaw: nodes which have more than one bone could
* be prematurely dropped from stack */
// Pop this node by name from the stack if found
// Used in multiple armature situations with duplicate node / bone names
// Known flaw: cannot have nodes with bone names, will be fixed in later release
// (serious to be fixed) Known flaw: nodes which have more than one bone could
// be prematurely dropped from stack
aiNode *ArmaturePopulate::GetNodeFromStack(const aiString &node_name,
std::vector<aiNode *> &nodes) {
std::vector<aiNode *>::iterator iter;
aiNode *found = nullptr;
for (iter = nodes.begin(); iter < nodes.end(); ++iter) {
aiNode *element = *iter;
ai_assert(element);
// node valid and node name matches
if (element->mName == node_name) {
found = element;
break;
std::vector<aiNode *>::iterator iter;
aiNode *found = nullptr;
for (iter = nodes.begin(); iter < nodes.end(); ++iter) {
aiNode *element = *iter;
ai_assert(element);
// node valid and node name matches
if (element->mName == node_name) {
found = element;
break;
}
}
}
if (found != nullptr) {
ASSIMP_LOG_INFO_F("Removed node from stack: ", found->mName.C_Str());
// now pop the element from the node list
nodes.erase(iter);
if (found != nullptr) {
ASSIMP_LOG_INFO_F("Removed node from stack: ", found->mName.C_Str());
// now pop the element from the node list
nodes.erase(iter);
return found;
}
return found;
}
// unique names can cause this problem
ASSIMP_LOG_ERROR("[Serious] GetNodeFromStack() can't find node from stack!");
// unique names can cause this problem
ASSIMP_LOG_ERROR("[Serious] GetNodeFromStack() can't find node from stack!");
return nullptr;
return nullptr;
}
} // Namespace Assimp

View File

@ -230,46 +230,6 @@ VertexWeightTable* ComputeVertexBoneWeightTable(const aiMesh* pMesh)
return avPerVertexWeights;
}
// -------------------------------------------------------------------------------
const char* TextureTypeToString(aiTextureType in)
{
switch (in)
{
case aiTextureType_NONE:
return "n/a";
case aiTextureType_DIFFUSE:
return "Diffuse";
case aiTextureType_SPECULAR:
return "Specular";
case aiTextureType_AMBIENT:
return "Ambient";
case aiTextureType_EMISSIVE:
return "Emissive";
case aiTextureType_OPACITY:
return "Opacity";
case aiTextureType_NORMALS:
return "Normals";
case aiTextureType_HEIGHT:
return "Height";
case aiTextureType_SHININESS:
return "Shininess";
case aiTextureType_DISPLACEMENT:
return "Displacement";
case aiTextureType_LIGHTMAP:
return "Lightmap";
case aiTextureType_REFLECTION:
return "Reflection";
case aiTextureType_UNKNOWN:
return "Unknown";
default:
break;
}
ai_assert(false);
return "BUG";
}
// -------------------------------------------------------------------------------
const char* MappingTypeToString(aiTextureMapping in)
{

View File

@ -316,12 +316,6 @@ typedef std::vector <PerVertexWeight> VertexWeightTable;
// Compute a per-vertex bone weight table
VertexWeightTable* ComputeVertexBoneWeightTable(const aiMesh* pMesh);
// -------------------------------------------------------------------------------
// Get a string for a given aiTextureType
const char* TextureTypeToString(aiTextureType in);
// -------------------------------------------------------------------------------
// Get a string for a given aiTextureMapping
const char* MappingTypeToString(aiTextureMapping in);

View File

@ -685,7 +685,7 @@ bool XGLImporter::ReadMesh(TempScope& scope)
}
// finally extract output meshes and add them to the scope
typedef std::pair<unsigned int, TempMaterialMesh> pairt;
typedef std::pair<const unsigned int, TempMaterialMesh> pairt;
for(const pairt& p : bymat) {
aiMesh* const m = ToOutputMesh(p.second);
scope.meshes_linear.push_back(m);

View File

@ -312,6 +312,10 @@ enum aiTextureType
#define AI_TEXTURE_TYPE_MAX aiTextureType_UNKNOWN
// -------------------------------------------------------------------------------
// Get a string for a given aiTextureType
ASSIMP_API const char* TextureTypeToString(enum aiTextureType in);
// ---------------------------------------------------------------------------
/** @brief Defines all shading models supported by the library
*

View File

@ -54,7 +54,7 @@ ADD_EXECUTABLE( assimp_cmd
Main.cpp
Main.h
resource.h
WriteDumb.cpp
WriteDump.cpp
Info.cpp
Export.cpp
)

View File

@ -444,6 +444,12 @@ int Assimp_Info (const char* const* params, unsigned int num) {
aiTextureType_DISPLACEMENT,
aiTextureType_LIGHTMAP,
aiTextureType_REFLECTION,
aiTextureType_BASE_COLOR,
aiTextureType_NORMAL_CAMERA,
aiTextureType_EMISSION_COLOR,
aiTextureType_METALNESS,
aiTextureType_DIFFUSE_ROUGHNESS,
aiTextureType_AMBIENT_OCCLUSION,
aiTextureType_UNKNOWN
};
for(unsigned int type = 0; type < sizeof(types)/sizeof(types[0]); ++type) {

View File

@ -168,7 +168,7 @@ bool ExportModel(const aiScene* pOut,
// ------------------------------------------------------------------------------
/** assimp_dump utility
* @param params Command line parameters to 'assimp dumb'
* @param params Command line parameters to 'assimp dump'
* @param Number of params
* @return An #AssimpCmdError value.*/
int Assimp_Dump (

View File

@ -41,7 +41,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
/** @file WriteTextDumb.cpp
/** @file WriteDump.cpp
* @brief Implementation of the 'assimp dump' utility
*/
@ -69,44 +69,6 @@ const char* AICMD_MSG_DUMP_HELP =
FILE* out = NULL;
bool shortened = false;
// -------------------------------------------------------------------------------
const char* TextureTypeToString(aiTextureType in)
{
switch (in)
{
case aiTextureType_NONE:
return "n/a";
case aiTextureType_DIFFUSE:
return "Diffuse";
case aiTextureType_SPECULAR:
return "Specular";
case aiTextureType_AMBIENT:
return "Ambient";
case aiTextureType_EMISSIVE:
return "Emissive";
case aiTextureType_OPACITY:
return "Opacity";
case aiTextureType_NORMALS:
return "Normals";
case aiTextureType_HEIGHT:
return "Height";
case aiTextureType_SHININESS:
return "Shininess";
case aiTextureType_DISPLACEMENT:
return "Displacement";
case aiTextureType_LIGHTMAP:
return "Lightmap";
case aiTextureType_REFLECTION:
return "Reflection";
case aiTextureType_UNKNOWN:
return "Unknown";
default:
break;
}
ai_assert(false);
return "BUG";
}
// -----------------------------------------------------------------------------------
int Assimp_Dump (const char* const* params, unsigned int num)
{