Merge branch 'master' into fix_gltf2_export_componentType_error
This commit is contained in:
@@ -71,7 +71,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
}
|
||||
|
||||
/// \def MACRO_ATTRREAD_CHECK_REF
|
||||
/// Check curent attribute name and if it equal to requested then read value. Result write to output variable by reference. If result was read then
|
||||
/// Check current attribute name and if it equal to requested then read value. Result write to output variable by reference. If result was read then
|
||||
/// "continue" will called.
|
||||
/// \param [in] pAttrName - attribute name.
|
||||
/// \param [out] pVarName - output variable name.
|
||||
@@ -84,7 +84,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
}
|
||||
|
||||
/// \def MACRO_ATTRREAD_CHECK_RET
|
||||
/// Check curent attribute name and if it equal to requested then read value. Result write to output variable using return value of \ref pFunction.
|
||||
/// Check current attribute name and if it equal to requested then read value. Result write to output variable using return value of \ref pFunction.
|
||||
/// If result was read then "continue" will called.
|
||||
/// \param [in] pAttrName - attribute name.
|
||||
/// \param [out] pVarName - output variable name.
|
||||
@@ -130,7 +130,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
} while(false)
|
||||
|
||||
/// \def MACRO_NODECHECK_READCOMP_F
|
||||
/// Check curent node name and if it equal to requested then read value. Result write to output variable of type "float".
|
||||
/// Check current node name and if it equal to requested then read value. Result write to output variable of type "float".
|
||||
/// If result was read then "continue" will called. Also check if node data already read then raise exception.
|
||||
/// \param [in] pNodeName - node name.
|
||||
/// \param [in, out] pReadFlag - read flag.
|
||||
@@ -147,7 +147,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
}
|
||||
|
||||
/// \def MACRO_NODECHECK_READCOMP_U32
|
||||
/// Check curent node name and if it equal to requested then read value. Result write to output variable of type "uint32_t".
|
||||
/// Check current node name and if it equal to requested then read value. Result write to output variable of type "uint32_t".
|
||||
/// If result was read then "continue" will called. Also check if node data already read then raise exception.
|
||||
/// \param [in] pNodeName - node name.
|
||||
/// \param [in, out] pReadFlag - read flag.
|
||||
|
||||
@@ -99,7 +99,7 @@ CAMFImporter_NodeElement* ne;
|
||||
ParseHelper_Node_Exit();
|
||||
// check that all components was defined
|
||||
if(!(read_flag[0] && read_flag[1] && read_flag[2])) throw DeadlyImportError("Not all color components are defined.");
|
||||
// check if <a> is absent. Then manualy add "a == 1".
|
||||
// check if <a> is absent. Then manually add "a == 1".
|
||||
if(!read_flag[3]) als.Color.a = 1;
|
||||
|
||||
}// if(!mReader->isEmptyElement())
|
||||
|
||||
@@ -770,7 +770,7 @@ std::list<aiNode*> ch_node;
|
||||
// find referenced object
|
||||
if(!Find_ConvertedNode(als.ObjectID, pNodeList, &found_node)) Throw_ID_NotFound(als.ObjectID);
|
||||
|
||||
// create node for apllying transformation
|
||||
// create node for applying transformation
|
||||
t_node = new aiNode;
|
||||
t_node->mParent = con_node;
|
||||
// apply transformation
|
||||
|
||||
+1
-1
@@ -427,7 +427,7 @@ public:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
//! Construct a parser from a given input file which is
|
||||
//! guaranted to be terminated with zero.
|
||||
//! guaranteed to be terminated with zero.
|
||||
//! @param szFile Input file
|
||||
//! @param fileFormatDefault Assumed file format version. If the
|
||||
//! file format is specified in the file the new value replaces
|
||||
|
||||
+1
-1
@@ -227,7 +227,7 @@ void DNAParser::Parse ()
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void DNA :: DumpToFile()
|
||||
{
|
||||
// we dont't bother using the VFS here for this is only for debugging.
|
||||
// we don't bother using the VFS here for this is only for debugging.
|
||||
// (and all your bases are belong to us).
|
||||
|
||||
std::ofstream f("dna.txt");
|
||||
|
||||
+1
-1
@@ -663,7 +663,7 @@ public:
|
||||
/** Check whether a specific item is in the cache.
|
||||
* @param s Data type of the item
|
||||
* @param out Output pointer. Unchanged if the
|
||||
* cache doens't know the item yet.
|
||||
* cache doesn't know the item yet.
|
||||
* @param ptr Item address to look for. */
|
||||
template <typename T> void get (
|
||||
const Structure& s,
|
||||
|
||||
@@ -47,7 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#define INCLUDED_AI_BLEND_TESSELLATOR_H
|
||||
|
||||
// Use these to toggle between GLU Tessellate or poly2tri
|
||||
// Note (acg) keep GLU Tesselate disabled by default - if it is turned on,
|
||||
// Note (acg) keep GLU Tessellate disabled by default - if it is turned on,
|
||||
// assimp needs to be linked against GLU, which is currently not yet
|
||||
// made configurable in CMake and potentially not wanted by most users
|
||||
// as it requires a Gl environment.
|
||||
|
||||
@@ -189,7 +189,7 @@ protected:
|
||||
{}
|
||||
};
|
||||
|
||||
// summarize a material in an convinient way.
|
||||
// summarize a material in an convenient way.
|
||||
struct Material
|
||||
{
|
||||
std::string name;
|
||||
|
||||
@@ -956,7 +956,7 @@ void ColladaLoader::StoreSceneMaterials( aiScene* pScene)
|
||||
// Stores all animations
|
||||
void ColladaLoader::StoreAnimations( aiScene* pScene, const ColladaParser& pParser)
|
||||
{
|
||||
// recursivly collect all animations from the collada scene
|
||||
// recursively collect all animations from the collada scene
|
||||
StoreAnimations( pScene, pParser, &pParser.mAnims, "");
|
||||
|
||||
// catch special case: many animations with the same length, each affecting only a single node.
|
||||
@@ -1784,7 +1784,7 @@ aiString ColladaLoader::FindFilenameForEffectTexture( const ColladaParser& pPars
|
||||
|
||||
// TODO: check the possibility of using the flag "AI_CONFIG_IMPORT_FBX_EMBEDDED_TEXTURES_LEGACY_NAMING"
|
||||
// In FBX files textures are now stored internally by Assimp with their filename included
|
||||
// Now Assimp can lookup thru the loaded textures after all data is processed
|
||||
// Now Assimp can lookup through the loaded textures after all data is processed
|
||||
// We need to load all textures before referencing them, as FBX file format order may reference a texture before loading it
|
||||
// This may occur on this case too, it has to be studied
|
||||
// setup texture reference string
|
||||
@@ -1819,9 +1819,12 @@ void ColladaLoader::ConvertPath (aiString& ss)
|
||||
|
||||
// Maxon Cinema Collada Export writes "file:///C:\andsoon" with three slashes...
|
||||
// I need to filter it without destroying linux paths starting with "/somewhere"
|
||||
if( ss.data[0] == '/' && isalpha( ss.data[1]) && ss.data[2] == ':' )
|
||||
{
|
||||
ss.length--;
|
||||
#if defined( _MSC_VER )
|
||||
if( ss.data[0] == '/' && isalpha( (unsigned char) ss.data[1]) && ss.data[2] == ':' ) {
|
||||
#else
|
||||
if (ss.data[ 0 ] == '/' && isalpha( ss.data[ 1 ] ) && ss.data[ 2 ] == ':') {
|
||||
#endif
|
||||
--ss.length;
|
||||
::memmove( ss.data, ss.data+1, ss.length);
|
||||
ss.data[ss.length] = 0;
|
||||
}
|
||||
|
||||
@@ -448,8 +448,8 @@ void TokenizeBinary(TokenList& output_tokens, const char* input, unsigned int le
|
||||
/*Result ignored*/ ReadByte(input, cursor, input + length);
|
||||
const uint32_t version = ReadWord(input, cursor, input + length);
|
||||
const bool is64bits = version >= 7500;
|
||||
while (cursor < input + length)
|
||||
{
|
||||
const char *end = input + length;
|
||||
while (cursor < end ) {
|
||||
if (!ReadScope(output_tokens, input, cursor, input + length, is64bits)) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1564,7 +1564,7 @@ void Converter::TrySetTextureProperties( aiMaterial* out_mat, const TextureMap&
|
||||
if (textureReady) {
|
||||
// TODO: check the possibility of using the flag "AI_CONFIG_IMPORT_FBX_EMBEDDED_TEXTURES_LEGACY_NAMING"
|
||||
// In FBX files textures are now stored internally by Assimp with their filename included
|
||||
// Now Assimp can lookup thru the loaded textures after all data is processed
|
||||
// Now Assimp can lookup through the loaded textures after all data is processed
|
||||
// We need to load all textures before referencing them, as FBX file format order may reference a texture before loading it
|
||||
// This may occur on this case too, it has to be studied
|
||||
path.data[0] = '*';
|
||||
|
||||
@@ -575,11 +575,11 @@ std::vector<const Connection*> Document::GetConnectionsSequenced(uint64_t id, bo
|
||||
ai_assert( count != 0 );
|
||||
ai_assert( count <= MAX_CLASSNAMES);
|
||||
|
||||
size_t lenghts[MAX_CLASSNAMES];
|
||||
size_t lengths[MAX_CLASSNAMES];
|
||||
|
||||
const size_t c = count;
|
||||
for (size_t i = 0; i < c; ++i) {
|
||||
lenghts[ i ] = strlen(classnames[i]);
|
||||
lengths[ i ] = strlen(classnames[i]);
|
||||
}
|
||||
|
||||
std::vector<const Connection*> temp;
|
||||
@@ -597,7 +597,7 @@ std::vector<const Connection*> Document::GetConnectionsSequenced(uint64_t id, bo
|
||||
|
||||
for (size_t i = 0; i < c; ++i) {
|
||||
ai_assert(classnames[i]);
|
||||
if(static_cast<size_t>(std::distance(key.begin(),key.end())) == lenghts[i] && !strncmp(classnames[i],obtype,lenghts[i])) {
|
||||
if(static_cast<size_t>(std::distance(key.begin(),key.end())) == lengths[i] && !strncmp(classnames[i],obtype,lengths[i])) {
|
||||
obtype = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
+11
-11
@@ -450,7 +450,7 @@ void FBXExporter::WriteDocuments ()
|
||||
p.AddP70string("ActiveAnimStackName", ""); // should do this properly?
|
||||
doc.AddChild(p);
|
||||
|
||||
// UID for root node in scene heirarchy.
|
||||
// UID for root node in scene hierarchy.
|
||||
// always set to 0 in the case of a single document.
|
||||
// not sure what happens if more than one document exists,
|
||||
// but that won't matter to us as we're exporting a single scene.
|
||||
@@ -650,7 +650,7 @@ void FBXExporter::WriteDefinitions ()
|
||||
}
|
||||
|
||||
// Model / FbxNode
|
||||
// <~~ node heirarchy
|
||||
// <~~ node hierarchy
|
||||
count = int32_t(count_nodes(mScene->mRootNode)) - 1; // (not counting root node)
|
||||
if (count) {
|
||||
n = FBX::Node("ObjectType", "Model");
|
||||
@@ -1223,7 +1223,7 @@ void FBXExporter::WriteObjects ()
|
||||
// it's all about this material
|
||||
aiMaterial* m = mScene->mMaterials[i];
|
||||
|
||||
// these are used to recieve material data
|
||||
// these are used to receive material data
|
||||
float f; aiColor3D c;
|
||||
|
||||
// start the node record
|
||||
@@ -1311,7 +1311,7 @@ void FBXExporter::WriteObjects ()
|
||||
// Now the legacy system.
|
||||
// For safety let's include it.
|
||||
// thrse values don't exist in the property template,
|
||||
// and usualy are completely ignored when loading.
|
||||
// and usually are completely ignored when loading.
|
||||
// One notable exception is the "Opacity" property,
|
||||
// which Blender uses as (1.0 - alpha).
|
||||
c.r = 0.0f; c.g = 0.0f; c.b = 0.0f;
|
||||
@@ -1532,7 +1532,7 @@ void FBXExporter::WriteObjects ()
|
||||
// bones.
|
||||
//
|
||||
// output structure:
|
||||
// subset of node heirarchy that are "skeleton",
|
||||
// subset of node hierarchy that are "skeleton",
|
||||
// i.e. do not have meshes but only bones.
|
||||
// but.. i'm not sure how anyone could guarantee that...
|
||||
//
|
||||
@@ -1544,7 +1544,7 @@ void FBXExporter::WriteObjects ()
|
||||
//
|
||||
// well. we can assume a sane input, i suppose.
|
||||
//
|
||||
// so input is the bone node heirarchy,
|
||||
// so input is the bone node hierarchy,
|
||||
// with an extra thing for the transformation of the MESH in BONE space.
|
||||
//
|
||||
// output is a set of bone nodes,
|
||||
@@ -1556,7 +1556,7 @@ void FBXExporter::WriteObjects ()
|
||||
// and represents the influence of that bone on the grandparent mesh.
|
||||
// the subdeformer has a list of indices, and weights,
|
||||
// with indices specifying vertex indices,
|
||||
// and weights specifying the correspoding influence of this bone.
|
||||
// and weights specifying the corresponding influence of this bone.
|
||||
// it also has Transform and TransformLink elements,
|
||||
// specifying the transform of the MESH in BONE space,
|
||||
// and the transformation of the BONE in WORLD space,
|
||||
@@ -1806,7 +1806,7 @@ void FBXExporter::WriteObjects ()
|
||||
// and a correct skeleton would still be output.
|
||||
|
||||
// transformlink should be the position of the bone in world space.
|
||||
// if the bone is in the bind pose (or nonexistant),
|
||||
// if the bone is in the bind pose (or nonexistent),
|
||||
// we can just use the matrix we already calculated
|
||||
if (bone_xform_okay) {
|
||||
sdnode.AddChild("TransformLink", bone_xform);
|
||||
@@ -1945,7 +1945,7 @@ void FBXExporter::WriteObjects ()
|
||||
|
||||
// TODO: cameras, lights
|
||||
|
||||
// write nodes (i.e. model heirarchy)
|
||||
// write nodes (i.e. model hierarchy)
|
||||
// start at root node
|
||||
WriteModelNodes(
|
||||
outstream, mScene->mRootNode, 0, limbnodes
|
||||
@@ -2203,8 +2203,8 @@ void FBXExporter::WriteModelNode(
|
||||
} else {
|
||||
// apply the transformation chain.
|
||||
// these transformation elements are created when importing FBX,
|
||||
// which has a complex transformation heirarchy for each node.
|
||||
// as such we can bake the heirarchy back into the node on export.
|
||||
// which has a complex transformation hierarchy for each node.
|
||||
// as such we can bake the hierarchy back into the node on export.
|
||||
for (auto &item : transform_chain) {
|
||||
auto elem = transform_types.find(item.first);
|
||||
if (elem == transform_types.end()) {
|
||||
|
||||
+1
-1
@@ -90,7 +90,7 @@ namespace Assimp
|
||||
const ExportProperties* mProperties; // currently unused
|
||||
std::shared_ptr<IOStream> outfile; // file to write to
|
||||
|
||||
std::vector<FBX::Node> connections; // conection storage
|
||||
std::vector<FBX::Node> connections; // connection storage
|
||||
|
||||
std::vector<int64_t> mesh_uids;
|
||||
std::vector<int64_t> material_uids;
|
||||
|
||||
@@ -302,7 +302,7 @@ Video::Video(uint64_t id, const Element& element, const Document& doc, const std
|
||||
}
|
||||
|
||||
if(Content) {
|
||||
//this field is ommited when the embedded texture is already loaded, let's ignore if it's not found
|
||||
//this field is omitted when the embedded texture is already loaded, let's ignore if it's not found
|
||||
try {
|
||||
const Token& token = GetRequiredToken(*Content, 0);
|
||||
const char* data = token.begin();
|
||||
|
||||
+54
-12
@@ -54,6 +54,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
//remove mesh at position 'index' from the scene
|
||||
static void removeMesh(aiScene* pScene, unsigned const index);
|
||||
//correct node indices to meshes and remove references to deleted mesh
|
||||
static void updateSceneGraph(aiNode* pNode, unsigned const index);
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Constructor to be privately used by Importer
|
||||
FindDegeneratesProcess::FindDegeneratesProcess()
|
||||
@@ -87,11 +92,50 @@ void FindDegeneratesProcess::SetupProperties(const Importer* pImp) {
|
||||
void FindDegeneratesProcess::Execute( aiScene* pScene) {
|
||||
ASSIMP_LOG_DEBUG("FindDegeneratesProcess begin");
|
||||
for (unsigned int i = 0; i < pScene->mNumMeshes;++i){
|
||||
ExecuteOnMesh( pScene->mMeshes[ i ] );
|
||||
if (ExecuteOnMesh(pScene->mMeshes[i])) {
|
||||
removeMesh(pScene, i);
|
||||
--i; //the current i is removed, do not skip the next one
|
||||
}
|
||||
}
|
||||
ASSIMP_LOG_DEBUG("FindDegeneratesProcess finished");
|
||||
}
|
||||
|
||||
static void removeMesh(aiScene* pScene, unsigned const index) {
|
||||
//we start at index and copy the pointers one position forward
|
||||
//save the mesh pointer to delete it later
|
||||
auto delete_me = pScene->mMeshes[index];
|
||||
for (unsigned i = index; i < pScene->mNumMeshes - 1; ++i) {
|
||||
pScene->mMeshes[i] = pScene->mMeshes[i+1];
|
||||
}
|
||||
pScene->mMeshes[pScene->mNumMeshes - 1] = nullptr;
|
||||
--(pScene->mNumMeshes);
|
||||
delete delete_me;
|
||||
|
||||
//removing a mesh also requires updating all references to it in the scene graph
|
||||
updateSceneGraph(pScene->mRootNode, index);
|
||||
}
|
||||
|
||||
static void updateSceneGraph(aiNode* pNode, unsigned const index) {
|
||||
for (unsigned i = 0; i < pNode->mNumMeshes; ++i) {
|
||||
if (pNode->mMeshes[i] > index) {
|
||||
--(pNode->mMeshes[i]);
|
||||
continue;
|
||||
}
|
||||
if (pNode->mMeshes[i] == index) {
|
||||
for (unsigned j = i; j < pNode->mNumMeshes -1; ++j) {
|
||||
pNode->mMeshes[j] = pNode->mMeshes[j+1];
|
||||
}
|
||||
--(pNode->mNumMeshes);
|
||||
--i;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
//recurse to all children
|
||||
for (unsigned i = 0; i < pNode->mNumChildren; ++i) {
|
||||
updateSceneGraph(pNode->mChildren[i], index);
|
||||
}
|
||||
}
|
||||
|
||||
static ai_real heron( ai_real a, ai_real b, ai_real c ) {
|
||||
ai_real s = (a + b + c) / 2;
|
||||
ai_real area = pow((s * ( s - a ) * ( s - b ) * ( s - c ) ), (ai_real)0.5 );
|
||||
@@ -125,7 +169,7 @@ static ai_real calculateAreaOfTriangle( const aiFace& face, aiMesh* mesh ) {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Executes the post processing step on the given imported mesh
|
||||
void FindDegeneratesProcess::ExecuteOnMesh( aiMesh* mesh) {
|
||||
bool FindDegeneratesProcess::ExecuteOnMesh( aiMesh* mesh) {
|
||||
mesh->mPrimitiveTypes = 0;
|
||||
|
||||
std::vector<bool> remove_me;
|
||||
@@ -161,7 +205,7 @@ void FindDegeneratesProcess::ExecuteOnMesh( aiMesh* mesh) {
|
||||
|
||||
// NOTE: we set the removed vertex index to an unique value
|
||||
// to make sure the developer gets notified when his
|
||||
// application attemps to access this data.
|
||||
// application attempts to access this data.
|
||||
face.mIndices[ face.mNumIndices ] = 0xdeadbeef;
|
||||
|
||||
if(first) {
|
||||
@@ -227,30 +271,28 @@ evil_jump_outside:
|
||||
if (&face_src != &face_dest) {
|
||||
// clear source
|
||||
face_src.mNumIndices = 0;
|
||||
face_src.mIndices = NULL;
|
||||
face_src.mIndices = nullptr;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Otherwise delete it if we don't need this face
|
||||
delete[] face_src.mIndices;
|
||||
face_src.mIndices = NULL;
|
||||
face_src.mIndices = nullptr;
|
||||
face_src.mNumIndices = 0;
|
||||
}
|
||||
}
|
||||
// Just leave the rest of the array unreferenced, we don't care for now
|
||||
mesh->mNumFaces = n;
|
||||
if (!mesh->mNumFaces) {
|
||||
// WTF!?
|
||||
// OK ... for completeness and because I'm not yet tired,
|
||||
// let's write code that will hopefully never be called
|
||||
// (famous last words)
|
||||
|
||||
// OK ... bad idea.
|
||||
throw DeadlyImportError("Mesh is empty after removal of degenerated primitives ... WTF!?");
|
||||
//The whole mesh consists of degenerated faces
|
||||
//signal upward, that this mesh should be deleted.
|
||||
ASSIMP_LOG_DEBUG("FindDegeneratesProcess removed a mesh full of degenerated primitives");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (deg && !DefaultLogger::isNullLogger()) {
|
||||
ASSIMP_LOG_WARN_F( "Found ", deg, " degenerated primitives");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -74,7 +74,8 @@ public:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Execute step on a given mesh
|
||||
void ExecuteOnMesh( aiMesh* mesh);
|
||||
///@returns true if the current mesh should be deleted, false otherwise
|
||||
bool ExecuteOnMesh( aiMesh* mesh);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/// @brief Enable the instant removal of degenerated primitives
|
||||
|
||||
+1
-1
@@ -91,7 +91,7 @@ protected:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Read a property of the specified type from the current XML element.
|
||||
* @param out Recives output data
|
||||
* @param out Receives output data
|
||||
*/
|
||||
void ReadHexProperty (HexProperty& out);
|
||||
void ReadStringProperty (StringProperty& out);
|
||||
|
||||
+9
-9
@@ -997,33 +997,33 @@ bool Importer::SetPropertyInteger(const char* szName, int iValue)
|
||||
// Set a configuration property
|
||||
bool Importer::SetPropertyFloat(const char* szName, ai_real iValue)
|
||||
{
|
||||
bool exising;
|
||||
bool existing;
|
||||
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||
exising = SetGenericProperty<ai_real>(pimpl->mFloatProperties, szName,iValue);
|
||||
existing = SetGenericProperty<ai_real>(pimpl->mFloatProperties, szName,iValue);
|
||||
ASSIMP_END_EXCEPTION_REGION(bool);
|
||||
return exising;
|
||||
return existing;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Set a configuration property
|
||||
bool Importer::SetPropertyString(const char* szName, const std::string& value)
|
||||
{
|
||||
bool exising;
|
||||
bool existing;
|
||||
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||
exising = SetGenericProperty<std::string>(pimpl->mStringProperties, szName,value);
|
||||
existing = SetGenericProperty<std::string>(pimpl->mStringProperties, szName,value);
|
||||
ASSIMP_END_EXCEPTION_REGION(bool);
|
||||
return exising;
|
||||
return existing;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Set a configuration property
|
||||
bool Importer::SetPropertyMatrix(const char* szName, const aiMatrix4x4& value)
|
||||
{
|
||||
bool exising;
|
||||
bool existing;
|
||||
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||
exising = SetGenericProperty<aiMatrix4x4>(pimpl->mMatrixProperties, szName,value);
|
||||
existing = SetGenericProperty<aiMatrix4x4>(pimpl->mMatrixProperties, szName,value);
|
||||
ASSIMP_END_EXCEPTION_REGION(bool);
|
||||
return exising;
|
||||
return existing;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -317,7 +317,7 @@ void TempMesh::FixupFaceOrientation()
|
||||
IfcVector3 farthestCenter = std::accumulate(mVerts.begin() + faceStartIndices[farthestIndex],
|
||||
mVerts.begin() + faceStartIndices[farthestIndex] + mVertcnt[farthestIndex], IfcVector3(0.0))
|
||||
/ IfcFloat(mVertcnt[farthestIndex]);
|
||||
// We accapt a bit of negative orientation without reversing. In case of doubt, prefer the orientation given in
|
||||
// We accept a bit of negative orientation without reversing. In case of doubt, prefer the orientation given in
|
||||
// the file.
|
||||
if( (farthestNormal * (farthestCenter - vavg).Normalize()) < -0.4 )
|
||||
{
|
||||
|
||||
@@ -118,7 +118,7 @@ bool areVerticesEqual(const Vertex &lhs, const Vertex &rhs, bool complex)
|
||||
// Squared because we check against squared length of the vector difference
|
||||
static const float squareEpsilon = epsilon * epsilon;
|
||||
|
||||
// Square compare is useful for animeshes vertexes compare
|
||||
// Square compare is useful for animeshes vertices compare
|
||||
if ((lhs.position - rhs.position).SquareLength() > squareEpsilon) {
|
||||
return false;
|
||||
}
|
||||
|
||||
+1
-1
@@ -410,7 +410,7 @@ void LWSImporter::BuildGraph(aiNode* nd, LWS::NodeDesc& src, std::vector<Attachm
|
||||
// name to attach light to node -> unique due to LWs indexing system
|
||||
lit->mName = nd->mName;
|
||||
|
||||
// detemine light type and setup additional members
|
||||
// determine light type and setup additional members
|
||||
if (src.lightType == 2) { /* spot light */
|
||||
|
||||
lit->mType = aiLightSource_SPOT;
|
||||
|
||||
+2
-2
@@ -141,7 +141,7 @@ void MDLImporter::SetupProperties(const Importer* pImp)
|
||||
configFrameID = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_GLOBAL_KEYFRAME,0);
|
||||
}
|
||||
|
||||
// AI_CONFIG_IMPORT_MDL_COLORMAP - pallette file
|
||||
// AI_CONFIG_IMPORT_MDL_COLORMAP - palette file
|
||||
configPalette = pImp->GetPropertyString(AI_CONFIG_IMPORT_MDL_COLORMAP,"colormap.lmp");
|
||||
}
|
||||
|
||||
@@ -1496,7 +1496,7 @@ void MDLImporter::InternReadFile_3DGS_MDL7( )
|
||||
groupData.vTextureCoords1.resize(iNumVertices,aiVector3D());
|
||||
|
||||
// check whether the triangle data structure is large enough
|
||||
// to contain a second UV coodinate set
|
||||
// to contain a second UV coordinate set
|
||||
if (pcHeader->triangle_stc_size >= AI_MDL7_TRIANGLE_STD_SIZE_TWO_UV) {
|
||||
groupData.vTextureCoords2.resize(iNumVertices,aiVector3D());
|
||||
groupData.bNeed2UV = true;
|
||||
|
||||
@@ -217,7 +217,7 @@ aiMesh *MMDImporter::CreateMesh(const pmx::PmxModel *pModel,
|
||||
pMesh->mNumFaces = indexCount / 3;
|
||||
pMesh->mFaces = new aiFace[pMesh->mNumFaces];
|
||||
|
||||
const int numIndices = 3; // trianglular face
|
||||
const int numIndices = 3; // triangular face
|
||||
for (unsigned int index = 0; index < pMesh->mNumFaces; index++) {
|
||||
pMesh->mFaces[index].mNumIndices = numIndices;
|
||||
unsigned int *indices = new unsigned int[numIndices];
|
||||
|
||||
+2
-2
@@ -271,7 +271,7 @@ void NFFImporter::InternReadFile( const std::string& pFile,
|
||||
|
||||
ShadingInfo s; // current material info
|
||||
|
||||
// degree of tesselation
|
||||
// degree of tessellation
|
||||
unsigned int iTesselation = 4;
|
||||
|
||||
// some temporary variables we need to parse the file
|
||||
@@ -988,7 +988,7 @@ void NFFImporter::InternReadFile( const std::string& pFile,
|
||||
::ai_snprintf(currentMesh.name,128,"cone_%i",cone++);
|
||||
else ::ai_snprintf(currentMesh.name,128,"cylinder_%i",cylinder++);
|
||||
}
|
||||
// 'tess' - tesselation
|
||||
// 'tess' - tessellation
|
||||
else if (TokenMatch(sz,"tess",4))
|
||||
{
|
||||
SkipSpaces(&sz);
|
||||
|
||||
@@ -691,7 +691,7 @@ void OpenGEXImporter::handleTransformNode( ODDLParser::DDLNode *node, aiScene *
|
||||
void OpenGEXImporter::handleMeshNode( ODDLParser::DDLNode *node, aiScene *pScene ) {
|
||||
m_currentMesh = new aiMesh;
|
||||
const size_t meshidx( m_meshCache.size() );
|
||||
// ownership is transfered but a reference remains in m_currentMesh
|
||||
// ownership is transferred but a reference remains in m_currentMesh
|
||||
m_meshCache.emplace_back( m_currentMesh );
|
||||
|
||||
Property *prop = node->getProperties();
|
||||
|
||||
@@ -102,7 +102,7 @@ public:
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** @brief Rmeove a node from the list of locked nodes.
|
||||
/** @brief Remove a node from the list of locked nodes.
|
||||
* @param name Name to be unlocked
|
||||
*/
|
||||
inline void RemoveLockedNode(std::string& name)
|
||||
|
||||
@@ -212,7 +212,7 @@ template <> struct MinMaxChooser<aiVertexWeight> {
|
||||
// -------------------------------------------------------------------------------
|
||||
/** @brief Find the min/max values of an array of Ts
|
||||
* @param in Input array
|
||||
* @param size Numebr of elements to process
|
||||
* @param size Number of elements to process
|
||||
* @param[out] min minimum value
|
||||
* @param[out] max maximum value
|
||||
*/
|
||||
|
||||
@@ -104,7 +104,7 @@ void ScenePreprocessor::ProcessMesh (aiMesh* mesh)
|
||||
|
||||
aiVector3D* p = mesh->mTextureCoords[i], *end = p+mesh->mNumVertices;
|
||||
|
||||
// Ensure unsued components are zeroed. This will make 1D texture channels work
|
||||
// Ensure unused components are zeroed. This will make 1D texture channels work
|
||||
// as if they were 2D channels .. just in case an application doesn't handle
|
||||
// this case
|
||||
if (2 == mesh->mNumUVComponents[i]) {
|
||||
|
||||
@@ -377,7 +377,7 @@ void StandardShapes::MakeSphere(unsigned int tess,
|
||||
MakeIcosahedron(positions);
|
||||
|
||||
// ... and subdivide it until the requested output
|
||||
// tesselation is reached
|
||||
// tessellation is reached
|
||||
for (unsigned int i = 0; i<tess;++i)
|
||||
Subdivide(positions);
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ void StepExporter::WriteFile()
|
||||
// see http://shodhganga.inflibnet.ac.in:8080/jspui/bitstream/10603/14116/11/11_chapter%203.pdf
|
||||
// note, that all realnumber values must be comma separated in x files
|
||||
mOutput.setf(std::ios::fixed);
|
||||
// precission for double
|
||||
// precision for double
|
||||
// see http://stackoverflow.com/questions/554063/how-do-i-print-a-double-value-with-full-precision-using-cout
|
||||
mOutput.precision(16);
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ void TextureTransformStep::PreProcessUVTransform(STransformVecInfo& info)
|
||||
{
|
||||
/* This function tries to simplify the input UV transformation.
|
||||
* That's very important as it allows us to reduce the number
|
||||
* of output UV channels. The oder in which the transformations
|
||||
* of output UV channels. The order in which the transformations
|
||||
* are applied is - as always - scaling, rotation, translation.
|
||||
*/
|
||||
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ static const unsigned int MajorVersion = 4;
|
||||
static const unsigned int MinorVersion = 1;
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
// Legal information string - dont't remove this.
|
||||
// Legal information string - don't remove this.
|
||||
static const char* LEGAL_INFORMATION =
|
||||
|
||||
"Open Asset Import Library (Assimp).\n"
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Assimp
|
||||
/// Limitations.
|
||||
///
|
||||
/// Pay attention that X3D is format for interactive graphic and simulations for web browsers. aiScene can not contain all features of the X3D format.
|
||||
/// Also, aiScene contain rasterized-like data. For example, X3D can describe circle all cylinder with one tag, but aiScene contain result of tesselation:
|
||||
/// Also, aiScene contain rasterized-like data. For example, X3D can describe circle all cylinder with one tag, but aiScene contain result of tessellation:
|
||||
/// vertices, faces etc. Yes, you can use algorithm for detecting figures or shapes, but that's not a good idea at all.
|
||||
///
|
||||
/// Supported nodes:
|
||||
|
||||
@@ -522,7 +522,7 @@ private:
|
||||
/// \param [in] pStartAngle - angle in radians of start of the arc.
|
||||
/// \param [in] pEndAngle - angle in radians of end of the arc.
|
||||
/// \param [in] pRadius - radius of the arc.
|
||||
/// \param [out] pNumSegments - number of segments in arc. In other words - tesselation factor.
|
||||
/// \param [out] pNumSegments - number of segments in arc. In other words - tessellation factor.
|
||||
/// \param [out] pVertices - generated vertices.
|
||||
void GeometryHelper_Make_Arc2D(const float pStartAngle, const float pEndAngle, const float pRadius, size_t pNumSegments, std::list<aiVector3D>& pVertices);
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ void X3DImporter::ParseNode_Geometry3D_Cone()
|
||||
}
|
||||
else
|
||||
{
|
||||
const unsigned int tess = 30;///TODO: IME tesselation factor through ai_property
|
||||
const unsigned int tess = 30;///TODO: IME tessellation factor through ai_property
|
||||
|
||||
std::vector<aiVector3D> tvec;// temp array for vertices.
|
||||
|
||||
@@ -209,7 +209,7 @@ void X3DImporter::ParseNode_Geometry3D_Cylinder()
|
||||
}
|
||||
else
|
||||
{
|
||||
const unsigned int tess = 30;///TODO: IME tesselation factor through ai_property
|
||||
const unsigned int tess = 30;///TODO: IME tessellation factor through ai_property
|
||||
|
||||
std::vector<aiVector3D> tside;// temp array for vertices of side.
|
||||
std::vector<aiVector3D> tcir;// temp array for vertices of circle.
|
||||
@@ -480,7 +480,7 @@ static aiVector3D GeometryHelper_Extrusion_GetNextY(const size_t pSpine_PointIdx
|
||||
tvec = pSpine[1] - pSpine[0];
|
||||
}
|
||||
else
|
||||
{// The Y-axis used for the last point it is the vector from spine[n-2] to spine[n-1]. In our case(see above about droping tail) spine[n - 1] is
|
||||
{// The Y-axis used for the last point it is the vector from spine[n-2] to spine[n-1]. In our case(see above about dropping tail) spine[n - 1] is
|
||||
// the spine[0].
|
||||
tvec = pSpine[spine_idx_last] - pSpine[spine_idx_last - 1];
|
||||
}
|
||||
@@ -967,7 +967,7 @@ void X3DImporter::ParseNode_Geometry3D_Sphere()
|
||||
}
|
||||
else
|
||||
{
|
||||
const unsigned int tess = 3;///TODO: IME tesselation factor through ai_property
|
||||
const unsigned int tess = 3;///TODO: IME tessellation factor through ai_property
|
||||
|
||||
std::vector<aiVector3D> tlist;
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
}
|
||||
|
||||
/// \def MACRO_ATTRREAD_CHECK_REF
|
||||
/// Check curent attribute name and if it equal to requested then read value. Result write to output variable by reference. If result was read then
|
||||
/// Check current attribute name and if it equal to requested then read value. Result write to output variable by reference. If result was read then
|
||||
/// "continue" will called.
|
||||
/// \param [in] pAttrName - attribute name.
|
||||
/// \param [out] pVarName - output variable name.
|
||||
@@ -89,7 +89,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
}
|
||||
|
||||
/// \def MACRO_ATTRREAD_CHECK_RET
|
||||
/// Check curent attribute name and if it equal to requested then read value. Result write to output variable using return value of \ref pFunction.
|
||||
/// Check current attribute name and if it equal to requested then read value. Result write to output variable using return value of \ref pFunction.
|
||||
/// If result was read then "continue" will called.
|
||||
/// \param [in] pAttrName - attribute name.
|
||||
/// \param [out] pVarName - output variable name.
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace Assimp
|
||||
if(!mReader->isEmptyElement()) \
|
||||
ParseNode_Metadata(pNE, pMetaName);/* in that case node element will be added to child elements list of current node. */ \
|
||||
else \
|
||||
NodeElement_Cur->Child.push_back(pNE);/* else - add element to child list manualy */ \
|
||||
NodeElement_Cur->Child.push_back(pNE);/* else - add element to child list manually */ \
|
||||
\
|
||||
NodeElement_List.push_back(pNE);/* add new element to elements list. */ \
|
||||
}/* if(!pUSE_Var.empty()) else */ \
|
||||
|
||||
@@ -132,7 +132,7 @@ void XFileExporter::WriteFile()
|
||||
{
|
||||
// note, that all realnumber values must be comma separated in x files
|
||||
mOutput.setf(std::ios::fixed);
|
||||
mOutput.precision(16); // precission for double
|
||||
mOutput.precision(16); // precision for double
|
||||
|
||||
// entry of writing the file
|
||||
WriteHeader();
|
||||
|
||||
+1
-1
@@ -498,7 +498,7 @@ aiMatrix4x4 XGLImporter::ReadTrafo()
|
||||
right = forward ^ up;
|
||||
if (std::fabs(up * forward) > 1e-4) {
|
||||
// this is definitely wrong - a degenerate coordinate space ruins everything
|
||||
// so subtitute identity transform.
|
||||
// so substitute identity transform.
|
||||
LogError("<forward> and <up> vectors in <transform> are skewing, ignoring trafo");
|
||||
return m;
|
||||
}
|
||||
|
||||
+6
-1
@@ -45,6 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* glTF Extensions Support:
|
||||
* KHR_materials_pbrSpecularGlossiness full
|
||||
* KHR_materials_unlit full
|
||||
*/
|
||||
#ifndef GLTF2ASSET_H_INC
|
||||
#define GLTF2ASSET_H_INC
|
||||
@@ -386,7 +387,7 @@ namespace glTF2
|
||||
};
|
||||
|
||||
|
||||
//! Base classe for all glTF top-level objects
|
||||
//! Base class for all glTF top-level objects
|
||||
struct Object
|
||||
{
|
||||
int index; //!< The index of this object within its property container
|
||||
@@ -741,6 +742,9 @@ namespace glTF2
|
||||
//extension: KHR_materials_pbrSpecularGlossiness
|
||||
Nullable<PbrSpecularGlossiness> pbrSpecularGlossiness;
|
||||
|
||||
//extension: KHR_materials_unlit
|
||||
bool unlit;
|
||||
|
||||
Material() { SetDefaults(); }
|
||||
void Read(Value& obj, Asset& r);
|
||||
void SetDefaults();
|
||||
@@ -1037,6 +1041,7 @@ namespace glTF2
|
||||
struct Extensions
|
||||
{
|
||||
bool KHR_materials_pbrSpecularGlossiness;
|
||||
bool KHR_materials_unlit;
|
||||
|
||||
} extensionsUsed;
|
||||
|
||||
|
||||
@@ -860,6 +860,8 @@ inline void Material::Read(Value& material, Asset& r)
|
||||
this->pbrSpecularGlossiness = Nullable<PbrSpecularGlossiness>(pbrSG);
|
||||
}
|
||||
}
|
||||
|
||||
unlit = nullptr != FindObject(*extensions, "KHR_materials_unlit");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -882,6 +884,7 @@ inline void Material::SetDefaults()
|
||||
alphaMode = "OPAQUE";
|
||||
alphaCutoff = 0.5;
|
||||
doubleSided = false;
|
||||
unlit = false;
|
||||
}
|
||||
|
||||
inline void PbrSpecularGlossiness::SetDefaults()
|
||||
@@ -1253,6 +1256,7 @@ inline void Asset::ReadExtensionsUsed(Document& doc)
|
||||
if (exts.find(#EXT) != exts.end()) extensionsUsed.EXT = true;
|
||||
|
||||
CHECK_EXT(KHR_materials_pbrSpecularGlossiness);
|
||||
CHECK_EXT(KHR_materials_unlit);
|
||||
|
||||
#undef CHECK_EXT
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* glTF Extensions Support:
|
||||
* KHR_materials_pbrSpecularGlossiness: full
|
||||
* KHR_materials_unlit: full
|
||||
*/
|
||||
#ifndef GLTF2ASSETWRITER_H_INC
|
||||
#define GLTF2ASSETWRITER_H_INC
|
||||
|
||||
@@ -343,6 +343,12 @@ namespace glTF2 {
|
||||
}
|
||||
}
|
||||
|
||||
if (m.unlit) {
|
||||
Value unlit;
|
||||
unlit.SetObject();
|
||||
exts.AddMember("KHR_materials_unlit", unlit, w.mAl);
|
||||
}
|
||||
|
||||
if (!exts.ObjectEmpty()) {
|
||||
obj.AddMember("extensions", exts, w.mAl);
|
||||
}
|
||||
@@ -683,6 +689,10 @@ namespace glTF2 {
|
||||
if (this->mAsset.extensionsUsed.KHR_materials_pbrSpecularGlossiness) {
|
||||
exts.PushBack(StringRef("KHR_materials_pbrSpecularGlossiness"), mAl);
|
||||
}
|
||||
|
||||
if (this->mAsset.extensionsUsed.KHR_materials_unlit) {
|
||||
exts.PushBack(StringRef("KHR_materials_unlit"), mAl);
|
||||
}
|
||||
}
|
||||
|
||||
if (!exts.Empty())
|
||||
|
||||
+20
-9
@@ -138,28 +138,29 @@ glTF2Exporter::glTF2Exporter(const char* filename, IOSystem* pIOSystem, const ai
|
||||
}
|
||||
}
|
||||
|
||||
glTF2Exporter::~glTF2Exporter() {
|
||||
// empty
|
||||
}
|
||||
|
||||
/*
|
||||
* Copy a 4x4 matrix from struct aiMatrix to typedef mat4.
|
||||
* Also converts from row-major to column-major storage.
|
||||
*/
|
||||
static void CopyValue(const aiMatrix4x4& v, mat4& o)
|
||||
{
|
||||
static void CopyValue(const aiMatrix4x4& v, mat4& o) {
|
||||
o[ 0] = v.a1; o[ 1] = v.b1; o[ 2] = v.c1; o[ 3] = v.d1;
|
||||
o[ 4] = v.a2; o[ 5] = v.b2; o[ 6] = v.c2; o[ 7] = v.d2;
|
||||
o[ 8] = v.a3; o[ 9] = v.b3; o[10] = v.c3; o[11] = v.d3;
|
||||
o[12] = v.a4; o[13] = v.b4; o[14] = v.c4; o[15] = v.d4;
|
||||
}
|
||||
|
||||
static void CopyValue(const aiMatrix4x4& v, aiMatrix4x4& o)
|
||||
{
|
||||
static void CopyValue(const aiMatrix4x4& v, aiMatrix4x4& o) {
|
||||
o.a1 = v.a1; o.a2 = v.a2; o.a3 = v.a3; o.a4 = v.a4;
|
||||
o.b1 = v.b1; o.b2 = v.b2; o.b3 = v.b3; o.b4 = v.b4;
|
||||
o.c1 = v.c1; o.c2 = v.c2; o.c3 = v.c3; o.c4 = v.c4;
|
||||
o.d1 = v.d1; o.d2 = v.d2; o.d3 = v.d3; o.d4 = v.d4;
|
||||
}
|
||||
|
||||
static void IdentityMatrix4(mat4& o)
|
||||
{
|
||||
static void IdentityMatrix4(mat4& o) {
|
||||
o[ 0] = 1; o[ 1] = 0; o[ 2] = 0; o[ 3] = 0;
|
||||
o[ 4] = 0; o[ 5] = 1; o[ 6] = 0; o[ 7] = 0;
|
||||
o[ 8] = 0; o[ 9] = 0; o[10] = 1; o[11] = 0;
|
||||
@@ -169,7 +170,9 @@ static void IdentityMatrix4(mat4& o)
|
||||
inline Ref<Accessor> ExportData(Asset& a, std::string& meshName, Ref<Buffer>& buffer,
|
||||
unsigned int count, void* data, AttribType::Value typeIn, AttribType::Value typeOut, ComponentType compType, bool isIndices = false)
|
||||
{
|
||||
if (!count || !data) return Ref<Accessor>();
|
||||
if (!count || !data) {
|
||||
return Ref<Accessor>();
|
||||
}
|
||||
|
||||
unsigned int numCompsIn = AttribType::GetNumComponents(typeIn);
|
||||
unsigned int numCompsOut = AttribType::GetNumComponents(typeOut);
|
||||
@@ -523,6 +526,12 @@ void glTF2Exporter::ExportMaterials()
|
||||
|
||||
m->pbrSpecularGlossiness = Nullable<PbrSpecularGlossiness>(pbrSG);
|
||||
}
|
||||
|
||||
bool unlit;
|
||||
if (mat->Get(AI_MATKEY_GLTF_UNLIT, unlit) == AI_SUCCESS && unlit) {
|
||||
mAsset->extensionsUsed.KHR_materials_unlit = true;
|
||||
m->unlit = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -729,8 +738,10 @@ void glTF2Exporter::ExportMeshes()
|
||||
|
||||
/******************** Normals ********************/
|
||||
// Normalize all normals as the validator can emit a warning otherwise
|
||||
for (auto i = 0u; i < aim->mNumVertices; ++i) {
|
||||
aim->mNormals[i].Normalize();
|
||||
if ( nullptr != aim->mNormals) {
|
||||
for ( auto i = 0u; i < aim->mNumVertices; ++i ) {
|
||||
aim->mNormals[ i ].Normalize();
|
||||
}
|
||||
}
|
||||
|
||||
Ref<Accessor> n = ExportData(*mAsset, meshId, b, aim->mNumVertices, aim->mNormals, AttribType::VEC3, AttribType::VEC3, ComponentType_FLOAT);
|
||||
|
||||
+12
-16
@@ -87,28 +87,15 @@ namespace Assimp
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
/** Helper class to export a given scene to an glTF file. */
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
class glTF2Exporter
|
||||
{
|
||||
class glTF2Exporter {
|
||||
public:
|
||||
/// Constructor for a specific scene to export
|
||||
glTF2Exporter(const char* filename, IOSystem* pIOSystem, const aiScene* pScene,
|
||||
const ExportProperties* pProperties, bool binary);
|
||||
~glTF2Exporter();
|
||||
|
||||
private:
|
||||
|
||||
const char* mFilename;
|
||||
IOSystem* mIOSystem;
|
||||
const aiScene* mScene;
|
||||
const ExportProperties* mProperties;
|
||||
|
||||
std::map<std::string, unsigned int> mTexturesByPath;
|
||||
|
||||
std::shared_ptr<glTF2::Asset> mAsset;
|
||||
|
||||
std::vector<unsigned char> mBodyData;
|
||||
|
||||
protected:
|
||||
void WriteBinaryData(IOStream* outfile, std::size_t sceneLength);
|
||||
|
||||
void GetTexSampler(const aiMaterial* mat, glTF2::Ref<glTF2::Texture> texture, aiTextureType tt, unsigned int slot);
|
||||
void GetMatTexProp(const aiMaterial* mat, unsigned int& prop, const char* propName, aiTextureType tt, unsigned int idx);
|
||||
void GetMatTexProp(const aiMaterial* mat, float& prop, const char* propName, aiTextureType tt, unsigned int idx);
|
||||
@@ -126,6 +113,15 @@ namespace Assimp
|
||||
unsigned int ExportNode(const aiNode* node, glTF2::Ref<glTF2::Node>& parent);
|
||||
void ExportScene();
|
||||
void ExportAnimations();
|
||||
|
||||
private:
|
||||
const char* mFilename;
|
||||
IOSystem* mIOSystem;
|
||||
const aiScene* mScene;
|
||||
const ExportProperties* mProperties;
|
||||
std::map<std::string, unsigned int> mTexturesByPath;
|
||||
std::shared_ptr<glTF2::Asset> mAsset;
|
||||
std::vector<unsigned char> mBodyData;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -281,6 +281,9 @@ static aiMaterial* ImportMaterial(std::vector<int>& embeddedTexIdxs, Asset& r, M
|
||||
|
||||
SetMaterialTextureProperty(embeddedTexIdxs, r, pbrSG.specularGlossinessTexture, aimat, aiTextureType_SPECULAR);
|
||||
}
|
||||
if (mat.unlit) {
|
||||
aimat->AddProperty(&mat.unlit, 1, AI_MATKEY_GLTF_UNLIT);
|
||||
}
|
||||
|
||||
return aimat;
|
||||
}
|
||||
|
||||
+1
-1
@@ -381,7 +381,7 @@ namespace glTF
|
||||
};
|
||||
|
||||
|
||||
//! Base classe for all glTF top-level objects
|
||||
//! Base class for all glTF top-level objects
|
||||
struct Object
|
||||
{
|
||||
std::string id; //!< The globally unique ID used to reference this object
|
||||
|
||||
@@ -703,7 +703,7 @@ void glTFExporter::ExportMeshes()
|
||||
// Coordinates indices
|
||||
comp_o3dgc_ifs.SetNCoordIndex(aim->mNumFaces);
|
||||
comp_o3dgc_ifs.SetCoordIndex((IndicesType* const)&b->GetPointer()[idx_srcdata_ind]);
|
||||
// Prepare to enconding
|
||||
// Prepare to encoding
|
||||
comp_o3dgc_params.SetNumFloatAttributes(comp_o3dgc_ifs.GetNumFloatAttributes());
|
||||
if(mProperties->GetPropertyBool("extensions.Open3DGC.binary", true))
|
||||
comp_o3dgc_params.SetStreamType(o3dgc::O3DGC_STREAM_TYPE_BINARY);
|
||||
|
||||
Reference in New Issue
Block a user