Code: Select all
#include <irrlicht.h>
#include <cassert>
using namespace irr;
using namespace core;
bool hasRotation(irr::core::matrix4 & matrix)
{
for (s32 i=0; i<3; ++i)
for (s32 j=0; j<3; ++j)
if ((j != i) && (!iszero(matrix(i,j)))) //check in 3x3 if any value out the diagonal is different from 0
return true;
return false;
}
bool test1()
{
irr::core::vector3df Rot = irr::core::vector3df(0,0,0);
irr::core::vector3df Scl = irr::core::vector3df(1,1,1);
irr::core::vector3df Pos = irr::core::vector3df(0,0,0);
irr::core::matrix4 mat1;
mat1.setRotationDegrees(Rot);
irr::core::matrix4 mat2;
mat2.setScale(Scl);
irr::core::matrix4 mat3;
mat3.setTranslation(Pos);
mat1*= mat2*mat3;
bool test = Rot.equals(irr::core::vector3df(0,0,0),0.001f);
return (hasRotation(mat1)!=test);
}
bool test2()
{
irr::core::vector3df Rot = irr::core::vector3df(90,0,0);
irr::core::vector3df Scl = irr::core::vector3df(1,1,1);
irr::core::vector3df Pos = irr::core::vector3df(0,0,0);
irr::core::matrix4 mat1;
mat1.setRotationRadians(Rot);
irr::core::matrix4 mat2;
mat2.setScale(Scl);
irr::core::matrix4 mat3;
mat3.setTranslation(Pos);
mat1*= mat2*mat3;
bool test = Rot.equals(irr::core::vector3df(0,0,0),0.001f);
return (hasRotation(mat1)!=test);
}
bool test3()
{
irr::core::vector3df Rot = irr::core::vector3df(0,270,0);
irr::core::vector3df Scl = irr::core::vector3df(1,1,1);
irr::core::vector3df Pos = irr::core::vector3df(0,100,0);
irr::core::matrix4 mat1;
mat1.setRotationDegrees(Rot);
irr::core::matrix4 mat2;
mat2.setScale(Scl);
irr::core::matrix4 mat3;
mat3.setTranslation(Pos);
mat1*= mat2*mat3;
bool test = Rot.equals(irr::core::vector3df(0,0,0),0.001f);
return (hasRotation(mat1)!=test);
}
bool test4()
{
irr::core::vector3df Rot = irr::core::vector3df(0,0,-90);
irr::core::vector3df Scl = irr::core::vector3df(1,1,1);
irr::core::vector3df Pos = irr::core::vector3df(1,2,3);
irr::core::matrix4 mat1;
mat1.setRotationRadians(Rot);
irr::core::matrix4 mat2;
mat2.setScale(Scl);
irr::core::matrix4 mat3;
mat3.setTranslation(Pos);
mat1*= mat2*mat3;
bool test = Rot.equals(irr::core::vector3df(0,0,0),0.001f);
return (hasRotation(mat1)!=test);
}
bool test5()
{
irr::core::vector3df Rot = irr::core::vector3df(1,2,3);
irr::core::vector3df Scl = irr::core::vector3df(1,1,1);
irr::core::vector3df Pos = irr::core::vector3df(3,2,1);
irr::core::matrix4 mat1;
mat1.setRotationRadians(Rot);
irr::core::matrix4 mat2;
mat2.setScale(Scl);
irr::core::matrix4 mat3;
mat3.setTranslation(Pos);
mat1*= mat2*mat3;
bool test = Rot.equals(irr::core::vector3df(0,0,0),0.001f);
return (hasRotation(mat1)!=test);
}
bool test6()
{
irr::core::vector3df Rot = irr::core::vector3df(100,90,80);
irr::core::vector3df Scl = irr::core::vector3df(0,0,1);
irr::core::vector3df Pos = irr::core::vector3df(30,5,17);
irr::core::matrix4 mat1;
mat1.setRotationRadians(Rot);
irr::core::matrix4 mat2;
mat2.setScale(Scl);
irr::core::matrix4 mat3;
mat3.setTranslation(Pos);
mat1*= mat2*mat3;
bool test = Rot.equals(irr::core::vector3df(0,0,0),0.001f);
return (hasRotation(mat1)!=test);
}
bool test7()
{
irr::core::vector3df Rot = irr::core::vector3df(0,0,0);
irr::core::vector3df Scl = irr::core::vector3df(1,1,1);
irr::core::vector3df Pos = irr::core::vector3df(0,0,0);
irr::core::matrix4 mat1;
mat1.setRotationDegrees(Rot);
irr::core::matrix4 mat2;
mat2.setScale(Scl);
irr::core::matrix4 mat3;
mat3.setTranslation(Pos);
mat2*= mat1*mat3;
bool test = Rot.equals(irr::core::vector3df(0,0,0),0.001f);
return (hasRotation(mat2)!=test);
}
bool test8()
{
irr::core::vector3df Rot = irr::core::vector3df(90,0,0);
irr::core::vector3df Scl = irr::core::vector3df(1,1,1);
irr::core::vector3df Pos = irr::core::vector3df(0,0,0);
irr::core::matrix4 mat1;
mat1.setRotationDegrees(Rot);
irr::core::matrix4 mat2;
mat2.setScale(Scl);
irr::core::matrix4 mat3;
mat3.setTranslation(Pos);
mat2*= mat1*mat3;
bool test = Rot.equals(irr::core::vector3df(0,0,0),0.001f);
return (hasRotation(mat2)!=test);
}
bool test9()
{
irr::core::vector3df Rot = irr::core::vector3df(0,270,0);
irr::core::vector3df Scl = irr::core::vector3df(1,1,1);
irr::core::vector3df Pos = irr::core::vector3df(0,100,0);
irr::core::matrix4 mat1;
mat1.setRotationRadians(Rot);
irr::core::matrix4 mat2;
mat2.setScale(Scl);
irr::core::matrix4 mat3;
mat3.setTranslation(Pos);
mat2*= mat1*mat3;
bool test = Rot.equals(irr::core::vector3df(0,0,0),0.001f);
return (hasRotation(mat2)!=test);
}
bool test10()
{
irr::core::vector3df Rot = irr::core::vector3df(0,0,-90);
irr::core::vector3df Scl = irr::core::vector3df(1,1,1);
irr::core::vector3df Pos = irr::core::vector3df(1,2,3);
irr::core::matrix4 mat1;
mat1.setRotationDegrees(Rot);
irr::core::matrix4 mat2;
mat2.setScale(Scl);
irr::core::matrix4 mat3;
mat3.setTranslation(Pos);
mat2*= mat1*mat3;
bool test = Rot.equals(irr::core::vector3df(0,0,0),0.001f);
return (hasRotation(mat2)!=test);
}
bool test11()
{
irr::core::vector3df Rot = irr::core::vector3df(1,2,3);
irr::core::vector3df Scl = irr::core::vector3df(1,1,1);
irr::core::vector3df Pos = irr::core::vector3df(3,2,1);
irr::core::matrix4 mat1;
mat1.setRotationDegrees(Rot);
irr::core::matrix4 mat2;
mat2.setScale(Scl);
irr::core::matrix4 mat3;
mat3.setTranslation(Pos);
mat2*= mat1*mat3;
bool test = Rot.equals(irr::core::vector3df(0,0,0),0.001f);
return (hasRotation(mat2)!=test);
}
bool test12()
{
irr::core::vector3df Rot = irr::core::vector3df(100,90,80);
irr::core::vector3df Scl = irr::core::vector3df(0,0,1);
irr::core::vector3df Pos = irr::core::vector3df(30,5,17);
irr::core::matrix4 mat1;
mat1.setRotationRadians(Rot);
irr::core::matrix4 mat2;
mat2.setScale(Scl);
irr::core::matrix4 mat3;
mat3.setTranslation(Pos);
mat2*= mat1*mat3;
bool test = Rot.equals(irr::core::vector3df(0,0,0),0.001f);
return (hasRotation(mat2)!=test);
}
int main()
{
assert(test1());
assert(test2());
assert(test3());
assert(test4());
assert(test5());
assert(test6());
assert(test7());
assert(test8());
assert(test9());
assert(test10());
assert(test11());
assert(test12());
return 0;
}