diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..87bf87c --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,26 @@ +cmake_minimum_required (VERSION 2.6) +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) + +project (Kraken) + +macro (add_sources) + file (RELATIVE_PATH _relPath "${PROJECT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}") + foreach (_src ${ARGN}) + if (_relPath) + list (APPEND SRCS "${_relPath}/${_src}") + else() + list (APPEND SRCS "${_src}") + endif() + endforeach() + if (_relPath) + # propagate SRCS to parent directory + set (SRCS ${SRCS} PARENT_SCOPE) + endif() +endmacro() + + +add_subdirectory(kraken) + +add_library(kraken ${SRCS}) diff --git a/kraken/CMakeLists.txt b/kraken/CMakeLists.txt new file mode 100644 index 0000000..611de46 --- /dev/null +++ b/kraken/CMakeLists.txt @@ -0,0 +1,9 @@ +include_directories(public) +add_sources(vector2.cpp) +add_sources(vector3.cpp) +add_sources(vector4.cpp) +add_sources(triangle3.cpp) +add_sources(quaternion.cpp) +add_sources(matrix4.cpp) +add_sources(aabb.cpp) + diff --git a/kraken/KRHelpers.h b/kraken/KRHelpers.h index e58510a..2cedb09 100644 --- a/kraken/KRHelpers.h +++ b/kraken/KRHelpers.h @@ -3,10 +3,12 @@ #if defined(_WIN32) || defined(_WIN64) #include -#include "../3rdparty/tinyxml2/tinyxml2.h" +#elif defined(__linux__) || defined(__unix__) || defined(__posix__) +#include +#include +#include #endif - -#include "KREngine-common.h" +#include "../3rdparty/tinyxml2/tinyxml2.h" #define KRMIN(x,y) ((x) < (y) ? (x) : (y)) #define KRMAX(x,y) ((x) > (y) ? (x) : (y)) @@ -26,4 +28,4 @@ namespace kraken { const Vector3 getXMLAttribute(const std::string &base_name, ::tinyxml2::XMLElement *e, const Vector3 &default_value); } // namespace kraken -#endif \ No newline at end of file +#endif diff --git a/kraken/aabb.cpp b/kraken/aabb.cpp index ca7926f..68e4316 100644 --- a/kraken/aabb.cpp +++ b/kraken/aabb.cpp @@ -10,6 +10,8 @@ #include "assert.h" #include "KRHelpers.h" +namespace kraken { + AABB::AABB() { min = Vector3::Min(); @@ -332,3 +334,6 @@ Vector3 AABB::nearestPoint(const Vector3 & v) const { return Vector3(KRCLAMP(v.x, min.x, max.x), KRCLAMP(v.y, min.y, max.y), KRCLAMP(v.z, min.z, max.z)); } + +} // namespace kraken + diff --git a/kraken/matrix4.cpp b/kraken/matrix4.cpp index 334fea5..4021e62 100644 --- a/kraken/matrix4.cpp +++ b/kraken/matrix4.cpp @@ -29,9 +29,10 @@ // or implied, of Kearwood Gilbert. // -#include "KREngine-common.h" +#include "public/kraken.h" +#include -#include "public/Matrix4.h" +namespace kraken { Matrix4::Matrix4() { // Default constructor - Initialize with an identity matrix @@ -443,3 +444,5 @@ Matrix4 Matrix4::Scaling(const Vector3 &v) return m; } +} // namespace kraken + diff --git a/kraken/public/aabb.h b/kraken/public/aabb.h index 786b3e5..89bd6ce 100644 --- a/kraken/public/aabb.h +++ b/kraken/public/aabb.h @@ -13,8 +13,8 @@ #include // for hash<> -#include "Vector2.h" -#include "Vector3.h" +#include "vector2.h" +#include "vector3.h" namespace kraken { diff --git a/kraken/public/vector2.h b/kraken/public/vector2.h index 7831657..b721107 100644 --- a/kraken/public/vector2.h +++ b/kraken/public/vector2.h @@ -33,6 +33,8 @@ #define KRAKEN_VECTOR2_H #include // for hash<> +#include // for std::numeric_limits<> +#include // for sqrtf namespace kraken { diff --git a/kraken/vector3.cpp b/kraken/vector3.cpp index ec726e4..bfad591 100644 --- a/kraken/vector3.cpp +++ b/kraken/vector3.cpp @@ -29,9 +29,10 @@ // or implied, of Kearwood Gilbert. // -#include "KREngine-common.h" #include "public/kraken.h" +namespace kraken { + const Vector3 Vector3_ZERO(0.0f, 0.0f, 0.0f); //default constructor @@ -412,3 +413,6 @@ bool Vector3::operator <(const Vector3& b) const return false; } } + +} // namespace kraken +