2015-08-31 21:27:09 +00:00
|
|
|
#include <iostream>
|
2015-10-12 00:33:42 +00:00
|
|
|
#include <iomanip>
|
2016-03-04 23:03:26 +00:00
|
|
|
#include <zeus/zeus.hpp>
|
2015-08-31 21:27:09 +00:00
|
|
|
|
2015-10-08 00:21:38 +00:00
|
|
|
// This is only for testing, do NOT do this normally
|
2016-03-04 23:03:26 +00:00
|
|
|
using namespace zeus;
|
2015-10-08 00:21:38 +00:00
|
|
|
|
2016-07-08 18:42:42 +00:00
|
|
|
union Color {
|
2018-12-08 05:23:50 +00:00
|
|
|
struct {
|
|
|
|
zeus::Comp8 r, g, b, a;
|
|
|
|
};
|
|
|
|
zeus::Comp32 rgba;
|
2015-11-01 12:04:29 +00:00
|
|
|
};
|
|
|
|
|
2019-06-12 02:04:52 +00:00
|
|
|
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
|
|
|
|
|
2018-12-08 05:23:50 +00:00
|
|
|
int main() {
|
|
|
|
zeus::detectCPU();
|
|
|
|
assert(!CAABox({100, 100, 100}, {100, 100, 100}).invalid());
|
|
|
|
assert(CAABox().invalid());
|
|
|
|
CVector3f vec{320.f, 1.f, 0.66568f};
|
|
|
|
assert(vec.canBeNormalized());
|
|
|
|
assert(!vec.isZero());
|
|
|
|
assert(CVector3f().isZero());
|
|
|
|
assert(!vec.normalized().canBeNormalized());
|
|
|
|
float blarg = 5.f;
|
|
|
|
CVector3f t{100, 100, 200};
|
|
|
|
blarg = clamp(0.f, blarg, 1.f);
|
|
|
|
CAABox test{{-100, -100, -100}, {100, 100, 100}};
|
|
|
|
CAABox test2{{-100, -100, -100}, {100, 100, 100}};
|
|
|
|
CAABox test3{{-50, -50, -50}, {50, 50, 50}};
|
|
|
|
CAABox test4{{-50, -50, -105}, {50, 50, 105}};
|
|
|
|
CVector2f point2(-90, 67);
|
|
|
|
CVector2f point3(-90, 67);
|
|
|
|
CVector3f point4 = point2 + point3;
|
|
|
|
CVector3f point(-90, 67, -105);
|
2020-04-11 22:50:02 +00:00
|
|
|
CVector3f point5 = test.closestPointAlongVector(point);
|
2018-12-08 05:23:50 +00:00
|
|
|
CVector3d(100, -100, -200);
|
|
|
|
zeus::CAABox aabb1{208.9f, -83.9f, 17.7f, 211.9f, -80.9f, 25.7f};
|
2020-04-11 22:50:02 +00:00
|
|
|
CVector3f point6 = aabb1.center();
|
|
|
|
CVector3f point7 = aabb1.extents() * 2.f;
|
2018-12-08 05:23:50 +00:00
|
|
|
zeus::CAABox aabb2{211.8f, -81.4f, 22.3f, 212.8f, -80.4f, 25.0f};
|
2020-04-11 22:50:02 +00:00
|
|
|
CVector3f point8 = aabb2.center();
|
|
|
|
CVector3f point9 = aabb2.extents() * 2.f;
|
2017-01-21 05:57:34 +00:00
|
|
|
|
2020-04-11 22:50:02 +00:00
|
|
|
CAABox aabb3 = aabb1.booleanIntersection(aabb2);
|
|
|
|
CVector3f point10 = aabb2.center();
|
|
|
|
CVector3f point11 = aabb2.extents() * 2.f;
|
2015-08-31 21:27:09 +00:00
|
|
|
|
2018-12-08 05:23:50 +00:00
|
|
|
assert(t.isEqu(t));
|
|
|
|
assert(test.inside(test));
|
|
|
|
assert(test2.inside(test));
|
|
|
|
assert(test3.inside(test));
|
|
|
|
assert(!test4.inside(test));
|
2015-08-31 21:27:09 +00:00
|
|
|
|
2018-12-08 05:23:50 +00:00
|
|
|
CAABox aabb(-1.f, 1.f);
|
|
|
|
CSphere s1(zeus::CVector3f(0.f), 1);
|
|
|
|
CSphere s2(zeus::CVector3f(1.f, 0.f, 0.f), 1);
|
|
|
|
CSphere s3(zeus::CVector3f(3.f, 0.f, 0.f), 1);
|
2015-11-02 18:44:46 +00:00
|
|
|
|
2018-12-08 05:23:50 +00:00
|
|
|
std::cout << min(1, 3) << std::endl;
|
|
|
|
std::cout << min(2, 1) << std::endl;
|
|
|
|
std::cout << max(1, 3) << std::endl;
|
|
|
|
std::cout << max(2, 1) << std::endl;
|
|
|
|
std::cout << clamp(-50, 100, 50) << std::endl;
|
|
|
|
std::cout << clamp(-50, -100, 50) << std::endl;
|
|
|
|
std::cout << invSqrtF(1) << std::endl;
|
|
|
|
std::cout << floorPowerOfTwo(256) << std::endl;
|
|
|
|
std::cout << " Test 1 " << (aabb.intersects(s1) ? "succeeded" : "failed") << std::endl;
|
|
|
|
std::cout << " Test 2 " << (aabb.intersects(s2) ? "succeeded" : "failed") << std::endl;
|
|
|
|
std::cout << " Test 3 " << (aabb.intersects(s3) ? "succeeded" : "failed") << std::endl;
|
|
|
|
CLineSeg({-89.120926f, 59.328712f, 3.265882f}, {-90.120926f, 59.328712f, 3.265882f});
|
2015-10-08 00:21:38 +00:00
|
|
|
|
2018-12-08 05:23:50 +00:00
|
|
|
CColor ctest1;
|
|
|
|
ctest1.fromHSV(0, 255 / 255.f, .5);
|
|
|
|
float h, s, v;
|
|
|
|
ctest1.toHSV(h, s, v);
|
|
|
|
std::cout << (int)ctest1.r() << " " << (int)ctest1.g() << " " << (int)ctest1.b() << " " << (int)ctest1.a()
|
|
|
|
<< std::endl;
|
|
|
|
std::cout << h << " " << s << " " << v << " " << (float)(ctest1.a() / 255.f) << std::endl;
|
|
|
|
return 0;
|
2015-08-31 21:27:09 +00:00
|
|
|
}
|