15 #ifndef FPLBASE_FLATBUFFER_UTILS_H
16 #define FPLBASE_FLATBUFFER_UTILS_H
18 #include "fplbase/config.h"
20 #include "common_generated.h"
21 #include "mathfu/constants.h"
22 #include "mathfu/glsl_mappings.h"
38 #if FLATBUFFERS_LITTLEENDIAN
39 #define FPLBASE_FLATBUFFER_AND_MATHFU_PACKED_TYPES_EQUIVALENT 1
47 #if FPLBASE_FLATBUFFER_AND_MATHFU_PACKED_TYPES_EQUIVALENT
48 return mathfu::vec2::FromType(*v);
55 return mathfu::vec2(v->x(), v->y());
64 #if FPLBASE_FLATBUFFER_AND_MATHFU_PACKED_TYPES_EQUIVALENT
68 return mathfu::vec3::FromType(*v);
70 return mathfu::vec3(v->x(), v->y(), v->z());
79 #if FPLBASE_FLATBUFFER_AND_MATHFU_PACKED_TYPES_EQUIVALENT
80 return mathfu::vec4::FromType(*v);
82 return mathfu::vec4(v->x(), v->y(), v->z(), v->w());
91 #if FPLBASE_FLATBUFFER_AND_MATHFU_PACKED_TYPES_EQUIVALENT
92 return mathfu::vec2i::FromType(*v);
94 return mathfu::vec2i(v->x(), v->y());
103 #if FPLBASE_FLATBUFFER_AND_MATHFU_PACKED_TYPES_EQUIVALENT
104 return mathfu::vec3i::FromType(*v);
106 return mathfu::vec3i(v->x(), v->y(), v->z());
115 #if FPLBASE_FLATBUFFER_AND_MATHFU_PACKED_TYPES_EQUIVALENT
116 return mathfu::vec4i::FromType(*v);
118 return mathfu::vec4i(v->x(), v->y(), v->z(), v->w());
127 return axis == Axis_X ? mathfu::kAxisX3f : axis == Axis_Y ? mathfu::kAxisY3f
136 #if FPLBASE_FLATBUFFER_AND_MATHFU_PACKED_TYPES_EQUIVALENT
137 return mathfu::vec4::FromType(*c);
139 return mathfu::vec4(c->r(), c->g(), c->b(), c->a());
148 #if FPLBASE_FLATBUFFER_AND_MATHFU_PACKED_TYPES_EQUIVALENT
149 return mathfu::vec4::ToType<ColorRGBA>(v);
151 return ColorRGBA(v.x(), v.y(), v.z(), v.w());
164 #if FPLBASE_FLATBUFFER_AND_MATHFU_PACKED_TYPES_EQUIVALENT
165 return mathfu::AffineTransform::FromType(*m);
167 const mathfu::vec4 c0 =
LoadVec4(&m->c0());
168 const mathfu::vec4 c1 =
LoadVec4(&m->c1());
169 const mathfu::vec4 c2 =
LoadVec4(&m->c2());
170 return mathfu::mat4::ToAffineTransform(
171 mathfu::mat4(c0, c1, c2, mathfu::kAxisW4f).Transpose());
178 #endif // FPLBASE_FLATBUFFER_UTILS_H
mathfu::vec3i LoadVec3i(const Vec3i *v)
Converts a Vec3i.
Definition: flatbuffer_utils.h:102
mathfu::vec2i LoadVec2i(const Vec2i *v)
Converts a Vec2i.
Definition: flatbuffer_utils.h:90
mathfu::vec4i LoadVec4i(const Vec4i *v)
Converts a Vec4i.
Definition: flatbuffer_utils.h:114
mathfu::vec2 LoadVec2(const Vec2 *v)
Converts a Vec2.
Definition: flatbuffer_utils.h:46
mathfu::vec4 LoadColorRGBA(const ColorRGBA *c)
Converts a ColorRGBA to a vec4.
Definition: flatbuffer_utils.h:135
mathfu::AffineTransform LoadAffine(const Mat3x4 *m)
Converts a Mat3x4 to a mat4.
Definition: flatbuffer_utils.h:163
mathfu::vec3 LoadAxis(Axis axis)
Converts a Axis to the corresponding vec3.
Definition: flatbuffer_utils.h:126
mathfu::vec4 LoadVec4(const Vec4 *v)
Converts a Vec4.
Definition: flatbuffer_utils.h:78
mathfu::vec3 LoadVec3(const Vec3 *v)
Converts a Vec3.
Definition: flatbuffer_utils.h:63
ColorRGBA Vec4ToColorRGBA(const mathfu::vec4 &v)
Converts a vec4 to a ColorRGBA.
Definition: flatbuffer_utils.h:147