some minor refactorings.
parent
f93ee9dace
commit
950496c351
|
@ -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.
|
* Copy a 4x4 matrix from struct aiMatrix to typedef mat4.
|
||||||
* Also converts from row-major to column-major storage.
|
* 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[ 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[ 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[ 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;
|
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.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.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.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;
|
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[ 0] = 1; o[ 1] = 0; o[ 2] = 0; o[ 3] = 0;
|
||||||
o[ 4] = 0; o[ 5] = 1; o[ 6] = 0; o[ 7] = 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;
|
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,
|
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)
|
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 numCompsIn = AttribType::GetNumComponents(typeIn);
|
||||||
unsigned int numCompsOut = AttribType::GetNumComponents(typeOut);
|
unsigned int numCompsOut = AttribType::GetNumComponents(typeOut);
|
||||||
|
|
|
@ -87,28 +87,15 @@ namespace Assimp
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
/** Helper class to export a given scene to an glTF file. */
|
/** Helper class to export a given scene to an glTF file. */
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
class glTF2Exporter
|
class glTF2Exporter {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
/// Constructor for a specific scene to export
|
/// Constructor for a specific scene to export
|
||||||
glTF2Exporter(const char* filename, IOSystem* pIOSystem, const aiScene* pScene,
|
glTF2Exporter(const char* filename, IOSystem* pIOSystem, const aiScene* pScene,
|
||||||
const ExportProperties* pProperties, bool binary);
|
const ExportProperties* pProperties, bool binary);
|
||||||
|
~glTF2Exporter();
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
void WriteBinaryData(IOStream* outfile, std::size_t sceneLength);
|
void WriteBinaryData(IOStream* outfile, std::size_t sceneLength);
|
||||||
|
|
||||||
void GetTexSampler(const aiMaterial* mat, glTF2::Ref<glTF2::Texture> texture, aiTextureType tt, unsigned int slot);
|
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, 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);
|
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);
|
unsigned int ExportNode(const aiNode* node, glTF2::Ref<glTF2::Node>& parent);
|
||||||
void ExportScene();
|
void ExportScene();
|
||||||
void ExportAnimations();
|
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;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,4 +89,5 @@ TEST_F( utglTF2ImportExport, importBinaryglTF2FromFileTest ) {
|
||||||
TEST_F( utglTF2ImportExport, exportglTF2FromFileTest ) {
|
TEST_F( utglTF2ImportExport, exportglTF2FromFileTest ) {
|
||||||
EXPECT_TRUE( exporterTest() );
|
EXPECT_TRUE( exporterTest() );
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // ASSIMP_BUILD_NO_EXPORT
|
#endif // ASSIMP_BUILD_NO_EXPORT
|
||||||
|
|
Loading…
Reference in New Issue