[F] Flag comp_allow did not reset when mesh can not be encoded.
../contrib/Open3DGC/o3dgcDynamicVectorEncoder.cpp
../contrib/Open3DGC/o3dgcTools.cpp
../contrib/Open3DGC/o3dgcTriangleFans.cpp
+ ../contrib/Open3DGC/o3dgcTimer.h
)
SOURCE_GROUP( open3dgc FILES ${open3dgc_SRCS})
+# Check dependencies for glTF importer with Open3DGC-compression.
+# RT-extensions is used in "contrib/Open3DGC/o3dgcTimer.h" for collecting statistics. Pointed file
+# has implementation for different platforms: WIN32, __MACH__ and other ("else" block).
+FIND_PACKAGE(RT QUIET)
+IF (RT_FOUND OR MSVC)
+ ADD_DEFINITIONS( -DASSIMP_IMPORTER_GLTF_USE_OPEN3DGC )
+ IF (NOT RT_FOUND)
+ SET (RT_LIBRARY "")
+ ENDIF (NOT RT_FOUND)
+ELSE ()
+ SET (open3dgc_SRCS "")
+ SET (RT_LIBRARY "")
+ MESSAGE (INFO " RT-extension not found. glTF import/export will be built without Open3DGC-compression.")
+ #!TODO: off course is better to remove statistics timers from o3dgc codec. Or propose to choose what to use.
+ENDIF ()
INCLUDE_DIRECTORIES( "../contrib/rapidjson/include" )
INCLUDE_DIRECTORIES( "../contrib" )
)
ADD_DEFINITIONS( -DOPENDDLPARSER_BUILD )
-if (open3dgc_SRCS)
- SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -lrt")
-endif (open3dgc_SRCS)
-
INCLUDE_DIRECTORIES(
../contrib/openddlparser/include
)
INCLUDE_DIRECTORIES("../")
endif (UNZIP_FOUND)
+# Add RT-extension library for glTF importer with Open3DGC-compression.
+IF (RT_FOUND AND ASSIMP_IMPORTER_GLTF_USE_OPEN3DGC)
+ TARGET_LINK_LIBRARIES(assimp ${RT_LIBRARY})
+ENDIF (RT_FOUND AND ASSIMP_IMPORTER_GLTF_USE_OPEN3DGC)
+
INSTALL( TARGETS assimp
LIBRARY DESTINATION ${ASSIMP_LIB_INSTALL_DIR}
ARCHIVE DESTINATION ${ASSIMP_LIB_INSTALL_DIR}
{
/// \enum EType
/// Type of extension.
- enum class EType
+ enum EType
{
- Compression_Open3DGC ///< Compression of mesh data using Open3DGC algorythm.
+ #ifdef ASSIMP_IMPORTER_GLTF_USE_OPEN3DGC
+ Compression_Open3DGC,///< Compression of mesh data using Open3DGC algorythm.
+ #endif
+
+ Unknown
};
EType Type;///< Type of extension.
{}
};
- /// \struct SCompression_Open3DGC
- /// Compression of mesh data using Open3DGC algorythm.
- struct SCompression_Open3DGC : public SExtension
- {
- using SExtension::Type;
-
- std::string Buffer;///< ID of "buffer" used for storing compressed data.
- size_t Offset;///< Offset in "bufferView" where compressed data are stored.
- size_t Count;///< Count of elements in compressed data. Is always equivalent to size in bytes: look comments for "Type" and "Component_Type".
- bool Binary;///< If true then "binary" mode is used for coding, if false - "ascii" mode.
- size_t IndicesCount;///< Count of indices in mesh.
- size_t VerticesCount;///< Count of vertices in mesh.
- // AttribType::Value Type;///< Is always "SCALAR".
- // ComponentType Component_Type;///< Is always "ComponentType_UNSIGNED_BYTE" (5121).
-
- /// \fn SCompression_Open3DGC
- /// Constructor.
- SCompression_Open3DGC()
- : SExtension(EType::Compression_Open3DGC)
- {}
- };
+ #ifdef ASSIMP_IMPORTER_GLTF_USE_OPEN3DGC
+ /// \struct SCompression_Open3DGC
+ /// Compression of mesh data using Open3DGC algorythm.
+ struct SCompression_Open3DGC : public SExtension
+ {
+ using SExtension::Type;
+
+ std::string Buffer;///< ID of "buffer" used for storing compressed data.
+ size_t Offset;///< Offset in "bufferView" where compressed data are stored.
+ size_t Count;///< Count of elements in compressed data. Is always equivalent to size in bytes: look comments for "Type" and "Component_Type".
+ bool Binary;///< If true then "binary" mode is used for coding, if false - "ascii" mode.
+ size_t IndicesCount;///< Count of indices in mesh.
+ size_t VerticesCount;///< Count of vertices in mesh.
+ // AttribType::Value Type;///< Is always "SCALAR".
+ // ComponentType Component_Type;///< Is always "ComponentType_UNSIGNED_BYTE" (5121).
+
+ /// \fn SCompression_Open3DGC
+ /// Constructor.
+ SCompression_Open3DGC()
+ : SExtension(Compression_Open3DGC)
+ {}
+ };
+ #endif
std::vector<Primitive> primitives;
std::list<SExtension*> Extension;///< List of extensions used in mesh.
/// \fn ~Mesh()
/// Destructor.
- ~Mesh() { for(auto e : Extension) { delete e; }; }
+ ~Mesh() { for(std::list<SExtension*>::iterator it = Extension.begin(), it_end = Extension.end(); it != it_end; it++) { delete *it; }; }
/// \fn void Read(Value& pJSON_Object, Asset& pAsset_Root)
/// Get mesh data from JSON-object and place them to root asset.
/// \param [out] pAsset_Root - reference to root assed where data will be stored.
void Read(Value& pJSON_Object, Asset& pAsset_Root);
- /// \fn void Decode_O3DGC(const SCompression_Open3DGC& pCompression_Open3DGC, Asset& pAsset_Root)
- /// Decode part of "buffer" which encoded with Open3DGC algorithm.
- /// \param [in] pCompression_Open3DGC - reference to structure which describe encoded region.
- /// \param [out] pAsset_Root - reference to root assed where data will be stored.
- void Decode_O3DGC(const SCompression_Open3DGC& pCompression_Open3DGC, Asset& pAsset_Root);
+ #ifdef ASSIMP_IMPORTER_GLTF_USE_OPEN3DGC
+ /// \fn void Decode_O3DGC(const SCompression_Open3DGC& pCompression_Open3DGC, Asset& pAsset_Root)
+ /// Decode part of "buffer" which encoded with Open3DGC algorithm.
+ /// \param [in] pCompression_Open3DGC - reference to structure which describe encoded region.
+ /// \param [out] pAsset_Root - reference to root assed where data will be stored.
+ void Decode_O3DGC(const SCompression_Open3DGC& pCompression_Open3DGC, Asset& pAsset_Root);
+ #endif
};
struct Node : public Object
// Header files, Assimp
#include <assimp/DefaultLogger.hpp>
-// Header files, Open3DGC.
-#include <Open3DGC/o3dgcSC3DMCDecoder.h>
+#ifdef ASSIMP_IMPORTER_GLTF_USE_OPEN3DGC
+ // Header files, Open3DGC.
+# include <Open3DGC/o3dgcSC3DMCDecoder.h>
+#endif
namespace glTF {
for(Value::MemberIterator it_memb = json_extensions->MemberBegin(); it_memb != json_extensions->MemberEnd(); it_memb++)
{
- if(it_memb->name.GetString() == std::string("Open3DGC-compression"))
+#ifdef ASSIMP_IMPORTER_GLTF_USE_OPEN3DGC
+ if(it_memb->name.GetString() == std::string("Open3DGC-compression"))
{
// Search for compressed data.
// Compressed data contain description of part of "buffer" which is encoded. This part must be decoded and
Extension.push_back(ext_o3dgc);// store info in mesh extensions list.
}// if(it_memb->name.GetString() == "Open3DGC-compression")
else
+#endif
{
throw DeadlyImportError(std::string("GLTF: Unknown mesh extension: \"") + it_memb->name.GetString() + "\".");
}
return;// After label some operators must be present.
}
+#ifdef ASSIMP_IMPORTER_GLTF_USE_OPEN3DGC
inline void Mesh::Decode_O3DGC(const SCompression_Open3DGC& pCompression_Open3DGC, Asset& pAsset_Root)
{
typedef unsigned short IndicesType;///< \sa glTFExporter::ExportMeshes.
// No. Do not delete "output_data". After calling "EncodedRegion_Mark" bufferView is owner of "output_data".
// "delete [] output_data;"
}
+#endif
inline void Camera::Read(Value& obj, Asset& r)
{
val.PushBack(r[i], al);
}
return val;
- };
+ }
template<class T>
inline void AddRefsVector(Value& obj, const char* fieldId, std::vector< Ref<T> >& v, MemoryPoolAllocator<>& al) {
lst.PushBack(StringRef(v[i]->id), al);
}
obj.AddMember(StringRef(fieldId), lst, al);
- };
+ }
}
{
switch(ptr_ext->Type)
{
+#ifdef ASSIMP_IMPORTER_GLTF_USE_OPEN3DGC
case Mesh::SExtension::EType::Compression_Open3DGC:
{
Value json_comp_data;
}
break;
+#endif
default:
throw DeadlyImportError("GLTF: Can not write mesh: unknown mesh extension, only Open3DGC is supported.");
}// switch(ptr_ext->Type)
#include "glTFAssetWriter.h"
-// Header files, Open3DGC.
-#include <Open3DGC/o3dgcSC3DMCEncoder.h>
+#ifdef ASSIMP_IMPORTER_GLTF_USE_OPEN3DGC
+ // Header files, Open3DGC.
+# include <Open3DGC/o3dgcSC3DMCEncoder.h>
+#endif
using namespace rapidjson;
const aiMesh* aim = mScene->mMeshes[idx_mesh];
// Check if compressing requested and mesh can be encoded.
+#ifdef ASSIMP_IMPORTER_GLTF_USE_OPEN3DGC
comp_allow = mProperties->GetPropertyBool("extensions.Open3DGC.use", false);
+#else
+ comp_allow = false;
+#endif
+
if(comp_allow && (aim->mPrimitiveTypes == aiPrimitiveType_TRIANGLE) && (aim->mNumVertices > 0) && (aim->mNumFaces > 0))
{
idx_srcdata_tc.clear();
msg = "mesh must has vertices and faces.";
DefaultLogger::get()->warn("GLTF: can not use Open3DGC-compression: " + msg);
+ comp_allow = false;
}
std::string meshId = mAsset->FindUniqueID(aim->mName.C_Str(), "mesh");
///TODO: animation: weights, joints.
if(comp_allow)
{
+#ifdef ASSIMP_IMPORTER_GLTF_USE_OPEN3DGC
// Only one type of compression supported at now - Open3DGC.
//
o3dgc::BinaryStream bs;
ext->VerticesCount = comp_o3dgc_ifs.GetNCoord();
// And assign to mesh.
m->Extension.push_back(ext);
+#endif
}// if(comp_allow)
}// for (unsigned int i = 0; i < mScene->mNumMeshes; ++i) {
}
{
for(Mesh::SExtension* cur_ext : mesh.Extension)
{
+#ifdef ASSIMP_IMPORTER_GLTF_USE_OPEN3DGC
if(cur_ext->Type == Mesh::SExtension::EType::Compression_Open3DGC)
{
// Limitations for meshes when using Open3DGC-compression.
buf->EncodedRegion_SetCurrent(mesh.id);
}
else
+#endif
{
- throw DeadlyImportError("GLTF: Can not import mesh: unknown mesh extension, only Open3DGC is supported.");
+ throw DeadlyImportError("GLTF: Can not import mesh: unknown mesh extension (code: \"" + std::to_string(cur_ext->Type) +
+ "\"), only Open3DGC is supported.");
}
}
}// if(mesh.Extension.size() > 0)