3#include <assimp/color4.h>
4#include <assimp/matrix4x4.h>
5#include <assimp/quaternion.h>
6#include <assimp/types.h>
7#include <assimp/vector3.h>
10#include <Core/Utils/Color.hpp>
16struct AssimpTypeWrapper {};
19struct AssimpTypeWrapper<aiVector3D> {
20 using Type = Core::Vector3;
24struct AssimpTypeWrapper<aiQuaternion> {
25 using Type = Core::Quaternion;
29struct AssimpTypeWrapper<aiMatrix4x4> {
30 using Type = Core::Transform;
34struct AssimpTypeWrapper<aiColor3D> {
35 using Type = Core::Utils::Color;
39struct AssimpTypeWrapper<aiColor4D> {
40 using Type = Core::Utils::Color;
44struct AssimpTypeWrapper<aiString> {
48inline Core::Vector3 assimpToCore(
const aiVector3D& v ) {
49 return Core::Vector3( v.x, v.y, v.z );
52inline aiVector3D coreToAssimp(
const Core::Vector3& v ) {
53 return aiVector3D( v.x(), v.y(), v.z() );
56inline Core::Quaternion assimpToCore(
const aiQuaternion& q ) {
57 return Core::Quaternion( q.w, q.x, q.y, q.z );
60inline Core::Transform assimpToCore(
const aiMatrix4x4& M ) {
61 Core::Matrix4 m( Core::Matrix4::Identity() );
62 for ( uint i = 0; i < 4; ++i ) {
63 for ( uint j = 0; j < 4; ++j ) {
67 return Core::Transform( m );
71assimpToCore(
const aiVector3D& T,
const aiQuaternion& R,
const aiVector3D& S ) {
72 Core::Vector3 t = assimpToCore( T );
73 Core::Quaternion r = assimpToCore( R );
74 Core::Vector3 s = assimpToCore( S );
76 M.fromPositionOrientationScale( t, r, s );
80inline Core::Utils::Color assimpToCore(
const aiColor3D& c ) {
81 return Core::Utils::Color( c.r, c.g, c.b );
84inline Core::Utils::Color assimpToCore(
const aiColor4D& c ) {
85 return Core::Utils::Color( c.r, c.g, c.b, c.a );
88inline std::string assimpToCore(
const aiString&
string ) {
90 std::transform( result.begin(), result.end(), result.begin(), [](
char in ) {
91 if ( in ==
'\\' ) return
'/';
94 return result.empty() ?
"default" : result;
97inline Core::VectorNui assimpToCore(
const uint* index,
const uint size ) {
98 Core::VectorNui v( size );
99 for ( uint i = 0; i < size; ++i ) {
107inline T assimpToCore(
const uint* index,
const uint size ) {
109 for ( uint i = 0; i < size; ++i ) {
hepler function to manage enum as underlying types in VariableSet