From a8cafb5969640bd14ed9ba0dd3dfa718124e2101 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Wed, 21 Nov 2012 21:14:49 +0100 Subject: [PATCH] [DEV] Start rework of the basic system ==> simplify --- etk/Debug.h | 6 +- etk/RegExp.h | 2 +- etk/Stream.cpp | 204 +++++++++++++++++++++++++++++ etk/Stream.h | 271 +++++++-------------------------------- etk/Vector.h | 2 +- etk/math/Matrix.h | 2 +- etk/math/Matrix4.cpp | 68 ++-------- etk/math/Matrix4.h | 29 ++--- etk/math/Vector2D.cpp | 30 +++++ etk/math/Vector2D.h | 15 ++- etk/math/Vector3D.cpp | 34 +++++ etk/math/Vector3D.h | 12 ++ etk/math/math.h | 20 --- etk/os/FSNode.cpp | 2 +- etk/os/FSNodeRight.cpp | 2 +- etk/os/Memory.cpp | 2 +- etk/os/Mutex.h | 4 +- etk/os/Semaphore.h | 2 +- etk/tool.h | 2 +- etk/{Types.h => types.h} | 14 -- etk/unicode.cpp | 2 +- etk/unicode.h | 3 +- etk/unicodeTable.cpp | 2 +- file.mk | 4 +- 24 files changed, 387 insertions(+), 347 deletions(-) create mode 100644 etk/math/Vector2D.cpp create mode 100644 etk/math/Vector3D.cpp delete mode 100644 etk/math/math.h rename etk/{Types.h => types.h} (91%) diff --git a/etk/Debug.h b/etk/Debug.h index 6df6fdb..a5a5c12 100644 --- a/etk/Debug.h +++ b/etk/Debug.h @@ -6,12 +6,12 @@ * @license BSD v3 (see license file) */ -#include -#include - #ifndef __ETK_DEBUG_H__ #define __ETK_DEBUG_H__ +#include +#include + // Log Message System For EDN void TOOLS_DisplayFuncName(int32_t ligne, const char* className, const char* funcName, const char* libName); void TOOLS_DisplayTime(void); diff --git a/etk/RegExp.h b/etk/RegExp.h index 9b0bcaf..2f8b543 100644 --- a/etk/RegExp.h +++ b/etk/RegExp.h @@ -9,7 +9,7 @@ #ifndef __TK_REG_EXP_H__ #define __TK_REG_EXP_H__ -#include +#include #include #include #include diff --git a/etk/Stream.cpp b/etk/Stream.cpp index 78a226c..7043de6 100644 --- a/etk/Stream.cpp +++ b/etk/Stream.cpp @@ -6,6 +6,7 @@ * @license BSD v3 (see license file) */ +#include #include etk::CCout etk::cout; @@ -13,3 +14,206 @@ etk::CEndl etk::endl; etk::CHex etk::hex; etk::CStart etk::cstart; + +#if defined(__TARGET_OS__Android) +# include +# define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "EWOL", __VA_ARGS__)) +# define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "EWOL", __VA_ARGS__)) +# define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, "EWOL", __VA_ARGS__)) +#endif + +etk::CCout& etk::operator <<(etk::CCout &os, const etk::logLevel_te obj) +{ + switch (obj) + { + case LOG_LEVEL_CRITICAL: + #if !defined(__TARGET_OS__Windows) + os << ETK_BASH_COLOR_BOLD_RED; + #endif + os << "[C]"; + break; + case LOG_LEVEL_ERROR: + #if !defined(__TARGET_OS__Windows) + os << ETK_BASH_COLOR_RED; + #endif + os << "[E]"; + break; + case LOG_LEVEL_WARNING: + #if !defined(__TARGET_OS__Windows) + os << ETK_BASH_COLOR_MAGENTA; + #endif + os << "[W]"; + break; + case LOG_LEVEL_INFO: + #if !defined(__TARGET_OS__Windows) + os << ETK_BASH_COLOR_CYAN; + #endif + os << "[I]"; + break; + case LOG_LEVEL_DEBUG: + #if !defined(__TARGET_OS__Windows) + os << ETK_BASH_COLOR_YELLOW; + #endif + os << "[D]"; + break; + case LOG_LEVEL_VERBOSE: + #if !defined(__TARGET_OS__Windows) + os << ETK_BASH_COLOR_WHITE; + #endif + os << "[V]"; + break; + default: + os << "[?]"; + break; + } + return os; +} + + + +etk::CCout::CCout() +{ + hex=false; + memset(m_tmpChar, 0, (MAX_LOG_SIZE+1)*sizeof(char)); +}; + + +etk::CCout::~CCout() +{ + +}; + + +etk::CCout& etk::CCout::operator << (CHex t) +{ + hex = true; + return *this; +} + + +etk::CCout& etk::CCout::operator << (int t) +{ + snprintf(tmp, MAX_LOG_SIZE_TMP, "%d", t); + strncat(m_tmpChar, tmp, MAX_LOG_SIZE); + hex = false; + return *this; +} + + +etk::CCout& etk::CCout::operator << (unsigned int t) +{ + snprintf(tmp, MAX_LOG_SIZE_TMP, "%u", t); + strncat(m_tmpChar, tmp, MAX_LOG_SIZE); + hex = false; + return *this; +} + + +etk::CCout& etk::CCout::operator << (long t) +{ + if (true == hex) { + snprintf(tmp, MAX_LOG_SIZE_TMP, "0x%08X", (unsigned int)t); + strncat(m_tmpChar, tmp, MAX_LOG_SIZE); + hex = false; + } else { + snprintf(tmp, MAX_LOG_SIZE_TMP, "%ld", t); + strncat(m_tmpChar, tmp, MAX_LOG_SIZE); + } + return *this; +} + + +etk::CCout& etk::CCout::operator << (long long t) +{ + if (true == hex) { + snprintf(tmp, MAX_LOG_SIZE_TMP, "0x%08X%08X", (unsigned int)(t>>32), (unsigned int)(t)); + strncat(m_tmpChar, tmp, MAX_LOG_SIZE); + hex = false; + } else { + snprintf(tmp, MAX_LOG_SIZE_TMP, "%lld", t); + strncat(m_tmpChar, tmp, MAX_LOG_SIZE); + } + return *this; +} + + +etk::CCout& etk::CCout::operator << (double t) +{ + snprintf(tmp, MAX_LOG_SIZE_TMP, "%f", t); + strncat(m_tmpChar, tmp, MAX_LOG_SIZE); + hex = false; + return *this; +} + + +etk::CCout& etk::CCout::operator << (float t) +{ + snprintf(tmp, MAX_LOG_SIZE_TMP, "%f", t); + strncat(m_tmpChar, tmp, MAX_LOG_SIZE); + hex = false; + return *this; +} + + +etk::CCout& etk::CCout::operator << (char * t) +{ + snprintf(tmp, MAX_LOG_SIZE_TMP, "%s", t); + strncat(m_tmpChar, tmp, MAX_LOG_SIZE); + hex = false; + return *this; +} + + +etk::CCout& etk::CCout::operator << (const char * t) +{ + snprintf(tmp, MAX_LOG_SIZE_TMP, "%s", t); + strncat(m_tmpChar, tmp, MAX_LOG_SIZE); + hex = false; + return *this; +} + + +etk::CCout& etk::CCout::operator << (char t) +{ + snprintf(tmp, MAX_LOG_SIZE_TMP, "%c", t); + strncat(m_tmpChar, tmp, MAX_LOG_SIZE); + hex = false; + return *this; +} + + +etk::CCout& etk::CCout::operator << (bool t) +{ + if (t) { + strncat(m_tmpChar, "true", MAX_LOG_SIZE); + } else { + strncat(m_tmpChar, "false", MAX_LOG_SIZE); + } + return *this; +} + + +etk::CCout& etk::CCout::operator << (CStart ccc) +{ + m_mutex.Lock(); + return *this; +} + + +etk::CCout& etk::CCout::operator << (etk::CEndl t) +{ + strncat(m_tmpChar, ETK_BASH_COLOR_NORMAL, MAX_LOG_SIZE); + strncat(m_tmpChar, "\n", MAX_LOG_SIZE); + m_tmpChar[MAX_LOG_SIZE] = '\0'; +#if defined(__TARGET_OS__Android) + LOGI("%s", m_tmpChar); +#else + printf("%s", m_tmpChar); +#endif + memset(m_tmpChar, 0, (MAX_LOG_SIZE+1)*sizeof(char)); + m_mutex.UnLock(); + return *this; +} + + + diff --git a/etk/Stream.h b/etk/Stream.h index f48c2a0..e5f18df 100644 --- a/etk/Stream.h +++ b/etk/Stream.h @@ -6,10 +6,49 @@ * @license BSD v3 (see license file) */ -#ifndef __ETK_STREAM_DEC_H__ -#define __ETK_STREAM_DEC_H__ +#ifndef __ETK_STREAM_H__ +#define __ETK_STREAM_H__ -namespace etk{ +#include +#include + +namespace etk +{ + #define MAX_LOG_SIZE (16000) + #define MAX_LOG_SIZE_TMP (512) + + class CEndl{}; + class CHex{}; + class CStart{}; + + class CCout{ + private: + bool hex; + char m_tmpChar[MAX_LOG_SIZE+1]; + char tmp[MAX_LOG_SIZE_TMP]; + etk::Mutex m_mutex; + public: + CCout(void); + ~CCout(void); + CCout& operator << (CHex t); + CCout& operator << (int t); + CCout& operator << (unsigned int t); + CCout& operator << (long t); + CCout& operator << (long long t); + CCout& operator << (double t); + CCout& operator << (float t); + CCout& operator << (char * t); + CCout& operator << (const char * t); + CCout& operator << (char t); + CCout& operator << (bool t); + CCout& operator << (CStart ccc); + CCout& operator << (etk::CEndl t); + }; + extern etk::CCout cout; + extern etk::CEndl endl; + extern etk::CHex hex; + extern etk::CStart cstart; + typedef enum { LOG_LEVEL_NONE, LOG_LEVEL_CRITICAL, @@ -19,27 +58,12 @@ namespace etk{ LOG_LEVEL_DEBUG, LOG_LEVEL_VERBOSE } logLevel_te; + + /** + * @brief Debug operator To display the curent element in a Human redeable information + */ + etk::CCout& operator <<(etk::CCout &os, const etk::logLevel_te obj); }; -#endif - -#include -#include -#include - -#ifndef __ETK_STREAM_H__ -#define __ETK_STREAM_H__ - -#if defined(__TARGET_OS__Android) -# include -# define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "EWOL", __VA_ARGS__)) -# define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "EWOL", __VA_ARGS__)) -# define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, "EWOL", __VA_ARGS__)) -#endif - -#define MAX_LOG_SIZE (16000) -#define MAX_LOG_SIZE_TMP (512) - - //regular colors #define ETK_BASH_COLOR_BLACK "\e[0;30m" @@ -74,206 +98,5 @@ namespace etk{ #define ETK_BASH_GO_TOP "\e[0;0f" -namespace etk{ - class CEndl{}; - class CHex{}; - class CStart{}; - class CCout{ - private: - bool hex; - char m_tmpChar[MAX_LOG_SIZE+1]; - char tmp[MAX_LOG_SIZE_TMP]; - etk::Mutex m_mutex; - public: - CCout(){ - hex=false; - memset(m_tmpChar, 0, (MAX_LOG_SIZE+1)*sizeof(char)); - }; - ~CCout() { - - }; - - CCout& operator << (CHex t) { - hex = true; - return *this; - } - CCout& operator << (int t) { - snprintf(tmp, MAX_LOG_SIZE_TMP, "%d", t); - strncat(m_tmpChar, tmp, MAX_LOG_SIZE); - hex = false; - return *this; - } - CCout& operator << (unsigned int t) { - snprintf(tmp, MAX_LOG_SIZE_TMP, "%u", t); - strncat(m_tmpChar, tmp, MAX_LOG_SIZE); - hex = false; - return *this; - } - /* - CCout& operator << (uniChar_t t) { - snprintf(tmp, MAX_LOG_SIZE_TMP, "%c", t); - strncat(m_tmpChar, tmp, MAX_LOG_SIZE); - return *this; - } - */ - CCout& operator << (long t) { - if (true == hex) { - snprintf(tmp, MAX_LOG_SIZE_TMP, "0x%08X", (unsigned int)t); - strncat(m_tmpChar, tmp, MAX_LOG_SIZE); - hex = false; - } else { - snprintf(tmp, MAX_LOG_SIZE_TMP, "%ld", t); - strncat(m_tmpChar, tmp, MAX_LOG_SIZE); - } - return *this; - } - CCout& operator << (long long t) { - if (true == hex) { - snprintf(tmp, MAX_LOG_SIZE_TMP, "0x%08X%08X", (unsigned int)(t>>32), (unsigned int)(t)); - strncat(m_tmpChar, tmp, MAX_LOG_SIZE); - hex = false; - } else { - snprintf(tmp, MAX_LOG_SIZE_TMP, "%lld", t); - strncat(m_tmpChar, tmp, MAX_LOG_SIZE); - } - return *this; - } - CCout& operator << (double t) { - snprintf(tmp, MAX_LOG_SIZE_TMP, "%f", t); - strncat(m_tmpChar, tmp, MAX_LOG_SIZE); - hex = false; - return *this; - } - CCout& operator << (float t) { - snprintf(tmp, MAX_LOG_SIZE_TMP, "%f", t); - strncat(m_tmpChar, tmp, MAX_LOG_SIZE); - hex = false; - return *this; - } - CCout& operator << (char * t) { - snprintf(tmp, MAX_LOG_SIZE_TMP, "%s", t); - strncat(m_tmpChar, tmp, MAX_LOG_SIZE); - hex = false; - return *this; - } - CCout& operator << (const char * t) { - snprintf(tmp, MAX_LOG_SIZE_TMP, "%s", t); - strncat(m_tmpChar, tmp, MAX_LOG_SIZE); - hex = false; - return *this; - } - CCout& operator << (char t) { - snprintf(tmp, MAX_LOG_SIZE_TMP, "%c", t); - strncat(m_tmpChar, tmp, MAX_LOG_SIZE); - hex = false; - return *this; - } - CCout& operator << (bool t) { - if (t) { - strncat(m_tmpChar, "true", MAX_LOG_SIZE); - } else { - strncat(m_tmpChar, "false", MAX_LOG_SIZE); - } - return *this; - } - - CCout& operator << (Vector2D t) { - snprintf(tmp, MAX_LOG_SIZE_TMP, "(%f,%f)", t.x, t.y); - strncat(m_tmpChar, tmp, MAX_LOG_SIZE); - hex = false; - return *this; - } - CCout& operator << (Vector2D t) { - snprintf(tmp, MAX_LOG_SIZE_TMP, "(%i,%i)", t.x, t.y); - strncat(m_tmpChar, tmp, MAX_LOG_SIZE); - hex = false; - return *this; - } - CCout& operator << (Vector3D t) { - snprintf(tmp, MAX_LOG_SIZE_TMP, "(%f,%f,%f)", t.x, t.y, t.z); - strncat(m_tmpChar, tmp, MAX_LOG_SIZE); - hex = false; - return *this; - } - CCout& operator << (Vector3D t) { - snprintf(tmp, MAX_LOG_SIZE_TMP, "(%i,%i,%i)", t.x, t.y, t.z); - strncat(m_tmpChar, tmp, MAX_LOG_SIZE); - hex = false; - return *this; - } - CCout& operator << (clipping_ts t) { - snprintf(tmp, MAX_LOG_SIZE_TMP, "origin=(%f,%f) size=(%f,%f)", t.x, t.y, t.w, t.h); - strncat(m_tmpChar, tmp, MAX_LOG_SIZE); - hex = false; - return *this; - } - CCout& operator << (CStart ccc) { - m_mutex.Lock(); - return *this; - } - CCout& operator << (logLevel_te ccc) { - switch (ccc) - { - case LOG_LEVEL_CRITICAL: - #if !defined(__TARGET_OS__Windows) - strncat(m_tmpChar, ETK_BASH_COLOR_BOLD_RED, MAX_LOG_SIZE); - #endif - strncat(m_tmpChar, "[C]", MAX_LOG_SIZE); - break; - case LOG_LEVEL_ERROR: - #if !defined(__TARGET_OS__Windows) - strncat(m_tmpChar, ETK_BASH_COLOR_RED, MAX_LOG_SIZE); - #endif - strncat(m_tmpChar, "[E]", MAX_LOG_SIZE); - break; - case LOG_LEVEL_WARNING: - #if !defined(__TARGET_OS__Windows) - strncat(m_tmpChar, ETK_BASH_COLOR_MAGENTA, MAX_LOG_SIZE); - #endif - strncat(m_tmpChar, "[W]", MAX_LOG_SIZE); - break; - case LOG_LEVEL_INFO: - #if !defined(__TARGET_OS__Windows) - strncat(m_tmpChar, ETK_BASH_COLOR_CYAN, MAX_LOG_SIZE); - #endif - strncat(m_tmpChar, "[I]", MAX_LOG_SIZE); - break; - case LOG_LEVEL_DEBUG: - #if !defined(__TARGET_OS__Windows) - strncat(m_tmpChar, ETK_BASH_COLOR_YELLOW, MAX_LOG_SIZE); - #endif - strncat(m_tmpChar, "[D]", MAX_LOG_SIZE); - break; - case LOG_LEVEL_VERBOSE: - #if !defined(__TARGET_OS__Windows) - strncat(m_tmpChar, ETK_BASH_COLOR_WHITE, MAX_LOG_SIZE); - #endif - strncat(m_tmpChar, "[V]", MAX_LOG_SIZE); - break; - default: - strncat(m_tmpChar, "[?]", MAX_LOG_SIZE); - break; - } - return *this; - } - CCout& operator << (etk::CEndl t) { - strncat(m_tmpChar, ETK_BASH_COLOR_NORMAL, MAX_LOG_SIZE); - strncat(m_tmpChar, "\n", MAX_LOG_SIZE); - m_tmpChar[MAX_LOG_SIZE] = '\0'; -#if defined(__TARGET_OS__Android) - LOGI("%s", m_tmpChar); -#else - printf("%s", m_tmpChar); -#endif - memset(m_tmpChar, 0, (MAX_LOG_SIZE+1)*sizeof(char)); - m_mutex.UnLock(); - return *this; - } - }; - extern etk::CCout cout; - extern etk::CEndl endl; - extern etk::CHex hex; - extern etk::CStart cstart; -} #endif diff --git a/etk/Vector.h b/etk/Vector.h index 0d059c8..990d457 100644 --- a/etk/Vector.h +++ b/etk/Vector.h @@ -9,8 +9,8 @@ #ifndef __ETK_VECTOR_H__ #define __ETK_VECTOR_H__ +#include #include -#include #include #undef __class__ diff --git a/etk/math/Matrix.h b/etk/math/Matrix.h index f956c82..cd5d4ea 100644 --- a/etk/math/Matrix.h +++ b/etk/math/Matrix.h @@ -9,7 +9,7 @@ #ifndef __ETK_TYPES_MATRIX_H__ #define __ETK_TYPES_MATRIX_H__ -//#include +#include #include #include diff --git a/etk/math/Matrix4.cpp b/etk/math/Matrix4.cpp index 5d29ea5..02b8a58 100644 --- a/etk/math/Matrix4.cpp +++ b/etk/math/Matrix4.cpp @@ -6,12 +6,12 @@ * @license BSD v3 (see license file) */ -#include +#include #include #include #include -etk::Matrix4 etk::matrix::Perspective(float left, float right, float bottom, float top, float nearVal, float farVal) +etk::Matrix4 etk::Matrix4::Perspective(float left, float right, float bottom, float top, float nearVal, float farVal) { etk::Matrix4 tmp; for(int32_t iii=0; iii<4*4 ; iii++) { @@ -29,53 +29,7 @@ etk::Matrix4 etk::matrix::Perspective(float left, float right, float bottom, flo return tmp; } -etk::Matrix4 etk::matrix::Translate(float x, float y, float z) -{ - etk::Matrix4 tmp; - // set translation : - tmp.m_mat[3] = x; - tmp.m_mat[7] = y; - tmp.m_mat[11] = z; - //TK_INFO("Translate :"); - //etk::matrix::Display(tmp); - return tmp; -} - -etk::Matrix4 etk::matrix::Scale(float x, float y, float z) -{ - etk::Matrix4 tmp; - // set scale : - tmp.m_mat[0] = x; - tmp.m_mat[5] = y; - tmp.m_mat[10] = z; - //TK_INFO("Scale :"); - //etk::matrix::Display(tmp); - return tmp; -} - -etk::Matrix4 etk::matrix::rotate(float x, float y, float z, float angleRad) -{ - etk::Matrix4 tmp; - float cosVal = cos(angleRad); - float sinVal = sin(angleRad); - float invVal = 1.0-cosVal; - // set rotation : - tmp.m_mat[0] = x*x*invVal + cosVal; - tmp.m_mat[1] = x*y*invVal - z*cosVal; - tmp.m_mat[2] = x*z*invVal + y*sinVal; - - tmp.m_mat[4] = y*x*invVal + z*sinVal; - tmp.m_mat[5] = y*y*invVal + cosVal; - tmp.m_mat[6] = y*z*invVal - x*sinVal; - - tmp.m_mat[8] = z*x*invVal - y*sinVal; - tmp.m_mat[9] = z*y*invVal + x*sinVal; - tmp.m_mat[10] = z*z*invVal + cosVal; - return tmp; -} - - -etk::Matrix4 etk::matrix::Translate(etk::Vector3D vect) +etk::Matrix4 etk::Matrix4::Translate(etk::Vector3D vect) { etk::Matrix4 tmp; // set translation : @@ -87,7 +41,7 @@ etk::Matrix4 etk::matrix::Translate(etk::Vector3D vect) return tmp; } -etk::Matrix4 etk::matrix::Scale(etk::Vector3D vect) +etk::Matrix4 etk::Matrix4::Scale(etk::Vector3D vect) { etk::Matrix4 tmp; // set scale : @@ -99,7 +53,7 @@ etk::Matrix4 etk::matrix::Scale(etk::Vector3D vect) return tmp; } -etk::Matrix4 etk::matrix::Rotate(etk::Vector3D vect, float angleRad) +etk::Matrix4 etk::Matrix4::Rotate(etk::Vector3D vect, float angleRad) { etk::Matrix4 tmp; float cosVal = cos(angleRad); @@ -120,10 +74,12 @@ etk::Matrix4 etk::matrix::Rotate(etk::Vector3D vect, float angleRad) return tmp; } -void etk::matrix::Display(etk::Matrix4& tmp) +etk::CCout& etk::operator <<(etk::CCout &os, const etk::Matrix4 obj) { - TK_INFO("matrix : (" << tmp.m_mat[0] << " , " << tmp.m_mat[1] << " , " << tmp.m_mat[2] << " , " << tmp.m_mat[3] << " , "); - TK_INFO(" " << tmp.m_mat[4] << " , " << tmp.m_mat[5] << " , " << tmp.m_mat[6] << " , " << tmp.m_mat[7] << " , "); - TK_INFO(" " << tmp.m_mat[8] << " , " << tmp.m_mat[9] << " , " << tmp.m_mat[10] << " , " << tmp.m_mat[11] << " , "); - TK_INFO(" " << tmp.m_mat[12] << " , " << tmp.m_mat[13] << " , " << tmp.m_mat[14] << " , " << tmp.m_mat[15] << " )"); + os << "matrix4 : ("; + for (int32_t iii=0; iii<16; iii++) { + os << obj.m_mat[iii]; + os << ","; + } + return os; } diff --git a/etk/math/Matrix4.h b/etk/math/Matrix4.h index 47f5be8..2f6844d 100644 --- a/etk/math/Matrix4.h +++ b/etk/math/Matrix4.h @@ -9,8 +9,12 @@ #ifndef __ETK_TYPES_MATRIX4_H__ #define __ETK_TYPES_MATRIX4_H__ -namespace etk { +#include +#include +#include +namespace etk +{ class Matrix4 { public: @@ -200,21 +204,16 @@ namespace etk { m_mat[14] = tmpVal; } + public: + Matrix4 Perspective(float left, float right, float bottom, float top, float nearVal, float farVal); + Matrix4 Translate(etk::Vector3D vect); + Matrix4 Scale(etk::Vector3D vect); + Matrix4 Rotate(etk::Vector3D vect, float angleRad=0.0); }; - namespace matrix { - Matrix4 Perspective(float left, float right, float bottom, float top, float nearVal, float farVal); - // TODO : DEPRECATED - Matrix4 Translate(float x=0.0, float y=0.0, float z=0.0); - // TODO : DEPRECATED - Matrix4 Scale(float x=1.0, float y=1.0, float z=1.0); - // TODO : DEPRECATED - Matrix4 rotate(float x, float y, float z, float angleRad=0.0); - - Matrix4 Translate(etk::Vector3D vect); - Matrix4 Scale(etk::Vector3D vect); - Matrix4 Rotate(etk::Vector3D vect, float angleRad=0.0); - void Display(Matrix4& tmp); - }; + /** + * @brief Debug operator To display the curent element in a Human redeable information + */ + etk::CCout& operator <<(etk::CCout &os, const etk::Matrix4 obj); }; #endif diff --git a/etk/math/Vector2D.cpp b/etk/math/Vector2D.cpp new file mode 100644 index 0000000..160267b --- /dev/null +++ b/etk/math/Vector2D.cpp @@ -0,0 +1,30 @@ +/** + * @author Edouard DUPIN + * + * @copyright 2011, Edouard DUPIN, all right reserved + * + * @license BSD v3 (see license file) + */ + +#include + +etk::CCout& etk::operator <<(etk::CCout &os, const etk::Vector2D obj) +{ + os << "("; + os << obj.x; + os << ","; + os << obj.y; + os << ")"; + return os; +} + +etk::CCout& etk::operator <<(etk::CCout &os, const etk::Vector2D obj) +{ + os << "("; + os << obj.x; + os << ","; + os << obj.y; + os << ")"; + return os; +} + diff --git a/etk/math/Vector2D.h b/etk/math/Vector2D.h index bee117d..1a74974 100644 --- a/etk/math/Vector2D.h +++ b/etk/math/Vector2D.h @@ -9,6 +9,9 @@ #ifndef __ETK_MATH_VECTOR2D_H__ #define __ETK_MATH_VECTOR2D_H__ +#include +#include + namespace etk { template class Vector2D @@ -235,8 +238,18 @@ namespace etk */ Vector2D QuadraticInterpolate(const Vector2D & v2, const Vector2D & v3, float factor) const { - return (*this)*(1.0f-factor)*(1.0f-factor) + 2*v2*factor*(1.0f-factor) + v3*factor*factor;} + return (*this)*(1.0f-factor)*(1.0f-factor) + 2*v2*factor*(1.0f-factor) + v3*factor*factor; }; + }; + /** + * @brief Debug operator To display the curent element in a Human redeable information + */ + etk::CCout& operator <<(etk::CCout &os, const etk::Vector2D obj); + /** + * @brief Debug operator To display the curent element in a Human redeable information + */ + etk::CCout& operator <<(etk::CCout &os, const etk::Vector2D obj); + }; #endif diff --git a/etk/math/Vector3D.cpp b/etk/math/Vector3D.cpp new file mode 100644 index 0000000..bd1e29d --- /dev/null +++ b/etk/math/Vector3D.cpp @@ -0,0 +1,34 @@ +/** + * @author Edouard DUPIN + * + * @copyright 2011, Edouard DUPIN, all right reserved + * + * @license BSD v3 (see license file) + */ + +#include + +etk::CCout& etk::operator <<(etk::CCout &os, const etk::Vector3D obj) +{ + os << "("; + os << obj.x; + os << ","; + os << obj.y; + os << ","; + os << obj.z; + os << ")"; + return os; +} + +etk::CCout& etk::operator <<(etk::CCout &os, const etk::Vector3D obj) +{ + os << "("; + os << obj.x; + os << ","; + os << obj.y; + os << ","; + os << obj.z; + os << ")"; + return os; +} + diff --git a/etk/math/Vector3D.h b/etk/math/Vector3D.h index 9b578a5..ceaf8c7 100644 --- a/etk/math/Vector3D.h +++ b/etk/math/Vector3D.h @@ -9,6 +9,10 @@ #ifndef __ETK_MATH_VECTOR3D_H__ #define __ETK_MATH_VECTOR3D_H__ +#include +#include +#include + namespace etk { template class Vector3D @@ -397,6 +401,14 @@ namespace etk return (*this)*(1.0f-factor)*(1.0f-factor) + 2*v2*factor*(1.0f-factor) + v3*factor*factor; }; }; + /** + * @brief Debug operator To display the curent element in a Human redeable information + */ + etk::CCout& operator <<(etk::CCout &os, const etk::Vector3D obj); + /** + * @brief Debug operator To display the curent element in a Human redeable information + */ + etk::CCout& operator <<(etk::CCout &os, const etk::Vector3D obj); }; diff --git a/etk/math/math.h b/etk/math/math.h deleted file mode 100644 index 1d0bbdd..0000000 --- a/etk/math/math.h +++ /dev/null @@ -1,20 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ - -#ifndef EPSILON -#define EPSILON 0.01f -#endif - -#include -#include -#include -#include -#include -#include -#include - diff --git a/etk/os/FSNode.cpp b/etk/os/FSNode.cpp index 5547ef7..faffc91 100644 --- a/etk/os/FSNode.cpp +++ b/etk/os/FSNode.cpp @@ -7,7 +7,7 @@ */ -#include +#include #include #include #include diff --git a/etk/os/FSNodeRight.cpp b/etk/os/FSNodeRight.cpp index 69403df..d1c00bc 100644 --- a/etk/os/FSNodeRight.cpp +++ b/etk/os/FSNodeRight.cpp @@ -7,7 +7,7 @@ */ -#include +#include #include #include diff --git a/etk/os/Memory.cpp b/etk/os/Memory.cpp index 4c4f4a9..82b36ad 100644 --- a/etk/os/Memory.cpp +++ b/etk/os/Memory.cpp @@ -6,7 +6,7 @@ * @license BSD v3 (see license file) */ -#include +#include #include // General diff --git a/etk/os/Mutex.h b/etk/os/Mutex.h index e436153..0338019 100644 --- a/etk/os/Mutex.h +++ b/etk/os/Mutex.h @@ -6,11 +6,11 @@ * @license BSD v3 (see license file) */ -#include - #ifndef __ETK_MUTEX_H__ #define __ETK_MUTEX_H__ +#include + #ifdef __TARGET_OS__Windows #include #else diff --git a/etk/os/Semaphore.h b/etk/os/Semaphore.h index a147119..b5511a1 100644 --- a/etk/os/Semaphore.h +++ b/etk/os/Semaphore.h @@ -9,7 +9,7 @@ #ifndef __ETK_SEMAPHORE_H__ #define __ETK_SEMAPHORE_H__ -#include +#include #ifdef __TARGET_OS__Windows #include diff --git a/etk/tool.h b/etk/tool.h index 0d7e13e..98bf779 100644 --- a/etk/tool.h +++ b/etk/tool.h @@ -9,7 +9,7 @@ #ifndef __ETK_TOOL_H__ #define __ETK_TOOL_H__ -#include +#include #include namespace etk { diff --git a/etk/Types.h b/etk/types.h similarity index 91% rename from etk/Types.h rename to etk/types.h index 585fca5..0d022a0 100644 --- a/etk/Types.h +++ b/etk/types.h @@ -52,18 +52,4 @@ typedef enum { #define etk_max(elemA, elemB) (((elemA)<(elemB)) ? (elemB) : (elemA)) #define etk_avg(minimim, elem, maximum) (((minimim)>(elem)) ? (minimim) : ((maximum)<(elem)) ? (maximum) : (elem)) -typedef struct { - float u; - float v; -}texCoord_ts; - -typedef struct { - float x; - float y; - float w; - float h; -}clipping_ts; - -#include - #endif diff --git a/etk/unicode.cpp b/etk/unicode.cpp index 6e0b82d..2a5385b 100644 --- a/etk/unicode.cpp +++ b/etk/unicode.cpp @@ -8,7 +8,7 @@ // see : http://unicode.org/fr/charts/symbols.html#CombiningDiacriticalMarks -#include +#include #include #include #include diff --git a/etk/unicode.h b/etk/unicode.h index 079eb9e..6430c3d 100644 --- a/etk/unicode.h +++ b/etk/unicode.h @@ -9,8 +9,9 @@ #ifndef __UNICODE_H__ #define __UNICODE_H__ -#include +#include #include + namespace unicode { typedef enum { EDN_CHARSET_UTF8, diff --git a/etk/unicodeTable.cpp b/etk/unicodeTable.cpp index be2d5a7..8f32ff2 100644 --- a/etk/unicodeTable.cpp +++ b/etk/unicodeTable.cpp @@ -6,7 +6,7 @@ * @license BSD v3 (see license file) */ -#include +#include #include #include diff --git a/file.mk b/file.mk index 580e0fb..dc3dd43 100644 --- a/file.mk +++ b/file.mk @@ -13,7 +13,9 @@ FILE_LIST = \ FILE_LIST+= \ - etk/math/Matrix4.cpp + etk/math/Matrix4.cpp \ + etk/math/Vector2D.cpp \ + etk/math/Vector3D.cpp FILE_LIST+= \