17 #include <linmath/float3x3.h> 18 #include "assimp/material.h" 20 #include "ShaderProgram.h" 21 #include "GameObject.h" 25 chag::float4x4 convertAiMatrixToFloat4x4(aiMatrix4x4 fromMatrix) {
26 chag::float4x4 newMatrix;
27 newMatrix.c1 = chag::make_vector(fromMatrix.a1, fromMatrix.b1, fromMatrix.c1, fromMatrix.d1);
28 newMatrix.c2 = chag::make_vector(fromMatrix.a2, fromMatrix.b2, fromMatrix.c2, fromMatrix.d2);
29 newMatrix.c3 = chag::make_vector(fromMatrix.a3, fromMatrix.b3, fromMatrix.c3, fromMatrix.d3);
30 newMatrix.c4 = chag::make_vector(fromMatrix.a4, fromMatrix.b4, fromMatrix.c4, fromMatrix.d4);
34 chag::float3x3 convertAiMatrixToFloat3x3(aiMatrix3x3 fromMatrix) {
35 chag::float3x3 newMatrix;
36 newMatrix.c1 = chag::make_vector(fromMatrix.a1, fromMatrix.b1, fromMatrix.c1);
37 newMatrix.c2 = chag::make_vector(fromMatrix.a2, fromMatrix.b2, fromMatrix.c2);
38 newMatrix.c3 = chag::make_vector(fromMatrix.a3, fromMatrix.b3, fromMatrix.c3);
42 bool fequals(
double a,
double b) {
43 return fabs(a - b) < 0.01f;
46 float degreeToRad(
const float degree) {
47 return (
float) (degree * M_PI / 180);
50 float radToDegree(
const float rad) {
51 return (
float) (rad * 180 / M_PI);
54 float getRand(
const float min,
const float max) {
56 const float range = max - min;
57 return (((
float) rand() / (
float) RAND_MAX) * range) + min;
60 template <
typename T,
unsigned S>
61 T getRandomElem(
const T (&ts)[S])
64 int ix = (int) getRand(0.0f, S - 0.1f);
71 void updateMinAndMax(
const float x,
const float y,
const float z, chag::float3* minV, chag::float3* maxV) {
97 chag::float3 createRandomVector(
const float minValue,
const float maxValue){
98 return chag::make_vector(getRand(minValue,maxValue), getRand(minValue,maxValue), getRand(minValue,maxValue));