summaryrefslogtreecommitdiff
path: root/source/libs/asura-lib-utils
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2019-03-19 23:06:27 +0800
committerchai <chaifix@163.com>2019-03-19 23:06:27 +0800
commit1497dccd63a84b7ee2b229b1ad9c5c02718f2a78 (patch)
treef8d1bff50da13e126d08c7345653e002e293202d /source/libs/asura-lib-utils
parent5e2a973516e0729b225da9de0b03015dc5854ac4 (diff)
*rename
Diffstat (limited to 'source/libs/asura-lib-utils')
-rw-r--r--source/libs/asura-lib-utils/exceptions/exception.cpp47
-rw-r--r--source/libs/asura-lib-utils/exceptions/exception.h43
-rw-r--r--source/libs/asura-lib-utils/filesystem/binding/data_buffer.binding.cpp68
-rw-r--r--source/libs/asura-lib-utils/filesystem/data_buffer.cpp29
-rw-r--r--source/libs/asura-lib-utils/filesystem/data_buffer.h45
-rw-r--r--source/libs/asura-lib-utils/filesystem/decoded_data.cpp20
-rw-r--r--source/libs/asura-lib-utils/filesystem/decoded_data.h42
-rw-r--r--source/libs/asura-lib-utils/filesystem/reloadable.h27
-rw-r--r--source/libs/asura-lib-utils/filesystem/resource_manager.cpp0
-rw-r--r--source/libs/asura-lib-utils/filesystem/resource_manager.h44
-rw-r--r--source/libs/asura-lib-utils/math/curve.cpp0
-rw-r--r--source/libs/asura-lib-utils/math/curve.h0
-rw-r--r--source/libs/asura-lib-utils/math/functions.cpp0
-rw-r--r--source/libs/asura-lib-utils/math/functions.h0
-rw-r--r--source/libs/asura-lib-utils/math/matrix44.cpp0
-rw-r--r--source/libs/asura-lib-utils/math/matrix44.h24
-rw-r--r--source/libs/asura-lib-utils/math/ranged_value.cpp0
-rw-r--r--source/libs/asura-lib-utils/math/ranged_value.h0
-rw-r--r--source/libs/asura-lib-utils/math/rect.hpp32
-rw-r--r--source/libs/asura-lib-utils/math/rect.inl19
-rw-r--r--source/libs/asura-lib-utils/math/transform.cpp0
-rw-r--r--source/libs/asura-lib-utils/math/transform.h30
-rw-r--r--source/libs/asura-lib-utils/math/vector2.hpp70
-rw-r--r--source/libs/asura-lib-utils/math/vector2.inl114
-rw-r--r--source/libs/asura-lib-utils/math/vector3.hpp233
-rw-r--r--source/libs/asura-lib-utils/math/vector3.inl145
-rw-r--r--source/libs/asura-lib-utils/math/vector4.h234
-rw-r--r--source/libs/asura-lib-utils/math/vector4.inl152
-rw-r--r--source/libs/asura-lib-utils/module.h32
-rw-r--r--source/libs/asura-lib-utils/scripting/luax.hpp13
-rw-r--r--source/libs/asura-lib-utils/scripting/portable.hpp22
-rw-r--r--source/libs/asura-lib-utils/scripting/portable.inl0
-rw-r--r--source/libs/asura-lib-utils/type.h70
-rw-r--r--source/libs/asura-lib-utils/utils.h0
-rw-r--r--source/libs/asura-lib-utils/utils_module.cpp20
-rw-r--r--source/libs/asura-lib-utils/utils_module.h24
36 files changed, 1599 insertions, 0 deletions
diff --git a/source/libs/asura-lib-utils/exceptions/exception.cpp b/source/libs/asura-lib-utils/exceptions/exception.cpp
new file mode 100644
index 0000000..dbb36ca
--- /dev/null
+++ b/source/libs/asura-lib-utils/exceptions/exception.cpp
@@ -0,0 +1,47 @@
+#include "Exception.h"
+
+#include <cstdarg>
+#include <iostream>
+
+namespace AsuraEngine
+{
+
+ Exception::Exception(const char *fmt, ...)
+ {
+ va_list args;
+ int size_buffer = 256, size_out;
+ char *buffer;
+ while (true)
+ {
+ buffer = new char[size_buffer];
+ memset(buffer, 0, size_buffer);
+
+ va_start(args, fmt);
+ size_out = vsnprintf(buffer, size_buffer, fmt, args);
+ va_end(args);
+
+ // see http://perfec.to/vsnprintf/pasprintf.c
+ // if size_out ...
+ // == -1 --> output was truncated
+ // == size_buffer --> output was truncated
+ // == size_buffer-1 --> ambiguous, /may/ have been truncated
+ // > size_buffer --> output was truncated, and size_out
+ // bytes would have been written
+ if (size_out == size_buffer || size_out == -1 || size_out == size_buffer - 1)
+ size_buffer *= 2;
+ else if (size_out > size_buffer)
+ size_buffer = size_out + 2; // to avoid the ambiguous case
+ else
+ break;
+
+ delete[] buffer;
+ }
+ message = std::string(buffer);
+ delete[] buffer;
+ }
+
+ Exception::~Exception() throw()
+ {
+ }
+
+}
diff --git a/source/libs/asura-lib-utils/exceptions/exception.h b/source/libs/asura-lib-utils/exceptions/exception.h
new file mode 100644
index 0000000..bed8a9a
--- /dev/null
+++ b/source/libs/asura-lib-utils/exceptions/exception.h
@@ -0,0 +1,43 @@
+#ifndef __ASURA_ENGINE_EXCEPTION_H__
+#define __ASURA_ENGINE_EXCEPTION_H__
+
+#include <exception>
+
+namespace AsuraEngine
+{
+
+ /**
+ * A convenient vararg-enabled exception class.
+ **/
+ class Exception : public std::exception
+ {
+ public:
+
+ /**
+ * Creates a new Exception according to printf-rules.
+ *
+ * See: http://www.cplusplus.com/reference/clibrary/cstdio/printf/
+ *
+ * @param fmt The format string (see printf).
+ **/
+ Exception(const char *fmt, ...);
+ virtual ~Exception() throw();
+
+ /**
+ * Returns a string containing reason for the exception.
+ * @return A description of the exception.
+ **/
+ inline virtual const char *what() const throw()
+ {
+ return message.c_str();
+ }
+
+ private:
+
+ std::string message;
+
+ }; // Exception
+
+}
+
+#endif \ No newline at end of file
diff --git a/source/libs/asura-lib-utils/filesystem/binding/data_buffer.binding.cpp b/source/libs/asura-lib-utils/filesystem/binding/data_buffer.binding.cpp
new file mode 100644
index 0000000..a9113a7
--- /dev/null
+++ b/source/libs/asura-lib-utils/filesystem/binding/data_buffer.binding.cpp
@@ -0,0 +1,68 @@
+#include "../data_buffer.h"
+
+using namespace Luax;
+
+namespace AsuraEngine
+{
+ namespace Filesystem
+ {
+
+ LUAX_REGISTRY(DataBuffer)
+ {
+ luaL_Reg f[] = {
+ { "New", _New },
+ { "SetContent", _SetContent },
+ { "GetContent", _GetContent },
+ { "GetContentLength", _GetContentLength },
+ {0, 0}
+ };
+
+ state.RegisterMethods(f);
+ }
+
+ LUAX_POSTPROCESS(DataBuffer)
+ {
+
+ }
+
+ LUAX_IMPL_METHOD(DataBuffer, _New)
+ {
+
+ }
+
+ // SetContent(dataBuffer, lString)
+ LUAX_IMPL_METHOD(DataBuffer, _SetContent)
+ {
+ LUAX_SETUP(L, "US");
+ // params:
+ // 1: data buffer
+ // 2: lstring
+
+ DataBuffer* self = state.GetLuaUserdata<DataBuffer>(1);
+ size_t size = 0;
+ const char* str = lua_tolstring(L, 2, &size);
+ void* data = new char[size];
+ memcpy(data, str, size);
+ self->SetContent(data, size);
+ return 0;
+ }
+
+ LUAX_IMPL_METHOD(DataBuffer, _GetContent)
+ {
+ LUAX_SETUP(L, "U");
+
+ DataBuffer* self = state.GetLuaUserdata<DataBuffer>(1);
+ lua_pushlstring(L, (const char*)self->data, self->size);
+ return 1;
+ }
+
+ LUAX_IMPL_METHOD(DataBuffer, _GetContentLength)
+ {
+ LUAX_SETUP(L, "U");
+ DataBuffer* self = state.GetLuaUserdata<DataBuffer>(1);
+ lua_pushinteger(L, self->size);
+ return 1;
+ }
+
+ }
+} \ No newline at end of file
diff --git a/source/libs/asura-lib-utils/filesystem/data_buffer.cpp b/source/libs/asura-lib-utils/filesystem/data_buffer.cpp
new file mode 100644
index 0000000..629dc92
--- /dev/null
+++ b/source/libs/asura-lib-utils/filesystem/data_buffer.cpp
@@ -0,0 +1,29 @@
+#include "data_buffer.h"
+
+namespace AsuraEngine
+{
+ namespace Filesystem
+ {
+
+ DataBuffer::DataBuffer(const void* data, std::size_t size)
+ {
+ this->data = (const byte*)data;
+ this->size = size;
+ }
+
+ DataBuffer::~DataBuffer()
+ {
+ delete[] data;
+ }
+
+ void DataBuffer::SetContent(const void* data, std::size_t siez)
+ {
+ if (this->data != nullptr)
+ delete[] this->data;
+
+ this->data = (const byte*)data;
+ this->size = size;
+ }
+
+ }
+} \ No newline at end of file
diff --git a/source/libs/asura-lib-utils/filesystem/data_buffer.h b/source/libs/asura-lib-utils/filesystem/data_buffer.h
new file mode 100644
index 0000000..4b013ed
--- /dev/null
+++ b/source/libs/asura-lib-utils/filesystem/data_buffer.h
@@ -0,0 +1,45 @@
+#ifndef __ASURA_ENGINE_DATABUFFER_H__
+#define __ASURA_ENGINE_DATABUFFER_H__
+
+#include <cstdlib>
+
+#include "../scripting/Luax.hpp"
+#include "../scripting/portable.hpp"
+
+namespace AsuraEngine
+{
+ namespace Filesystem
+ {
+
+ ///
+ /// ڴݵķװеʹData bufferװֱʹconst void*ͨresource managerȡ
+ ///
+ class DataBuffer ASURA_FINAL
+ : public Scripting::Portable<DataBuffer>
+ {
+ public:
+
+ DataBuffer(const void* data, std::size_t size);
+
+ ~DataBuffer();
+
+ void SetContent(const void* data, std::size_t siez);
+
+ const byte* data;
+ size_t size;
+
+ //----------------------------------------------------------------------------------------------------------
+
+ LUAX_DECL_FACTORY(DataBuffer);
+
+ LUAX_DECL_METHOD(_New);
+ LUAX_DECL_METHOD(_SetContent);
+ LUAX_DECL_METHOD(_GetContent);
+ LUAX_DECL_METHOD(_GetContentLength);
+
+ };
+
+ }
+}
+
+#endif \ No newline at end of file
diff --git a/source/libs/asura-lib-utils/filesystem/decoded_data.cpp b/source/libs/asura-lib-utils/filesystem/decoded_data.cpp
new file mode 100644
index 0000000..125c652
--- /dev/null
+++ b/source/libs/asura-lib-utils/filesystem/decoded_data.cpp
@@ -0,0 +1,20 @@
+#include "DecodedData.h"
+#include "Exceptions/Exception.h"
+
+namespace AsuraEngine
+{
+ namespace Filesystem
+ {
+
+ DecodedData::DecodedData(const DataBuffer* databuffer)
+ {
+ Decode(databuffer);
+ }
+
+ DecodedData::~DecodedData()
+ {
+
+ }
+
+ }
+}
diff --git a/source/libs/asura-lib-utils/filesystem/decoded_data.h b/source/libs/asura-lib-utils/filesystem/decoded_data.h
new file mode 100644
index 0000000..49b5815
--- /dev/null
+++ b/source/libs/asura-lib-utils/filesystem/decoded_data.h
@@ -0,0 +1,42 @@
+#ifndef __ASURA_ENGINE_DATA_H__
+#define __ASURA_ENGINE_DATA_H__
+
+#include <cstdlib>
+
+#include "../scripting/portable.hpp"
+
+#include "data_buffer.h"
+
+namespace AsuraEngine
+{
+ namespace Filesystem
+ {
+
+ ///
+ /// һ̹߳data̳дࡣͼƬݡƵݵȣһ߳нԭļڲݸʽ
+ /// ȡ
+ ///
+ ASURA_ABSTRACT class DecodedData
+ {
+ public:
+
+ ///
+ /// ڴйdataԷһ߳棬Դϵͳء
+ ///
+ DecodedData(const DataBuffer& databuffer);
+
+ virtual ~DecodedData();
+
+ protected:
+
+ ///
+ /// ڴеݡ
+ ///
+ virtual void Decode(const DataBuffer& buffer) = 0;
+
+ };
+
+ }
+}
+
+#endif \ No newline at end of file
diff --git a/source/libs/asura-lib-utils/filesystem/reloadable.h b/source/libs/asura-lib-utils/filesystem/reloadable.h
new file mode 100644
index 0000000..7c4ea52
--- /dev/null
+++ b/source/libs/asura-lib-utils/filesystem/reloadable.h
@@ -0,0 +1,27 @@
+#ifndef __ASURA_ENGINE_RELOADABLE_H__
+#define __ASURA_ENGINE_RELOADABLE_H__
+
+#include "../scripting/portable.hpp"
+
+namespace AsuraEngine
+{
+ namespace Filesystem
+ {
+
+ ///
+ /// ¹ݽṹͼƬƵ֣ⲿݿֱӹڱ༭¹ڲıhandleԴ
+ ///
+ ASURA_ABSTRACT class Reloadable
+ {
+ public:
+ Reloadable();
+ virtual ~Reloadable();
+
+ // ̳ReloadableҪṩһload
+
+ };
+
+ }
+}
+
+#endif \ No newline at end of file
diff --git a/source/libs/asura-lib-utils/filesystem/resource_manager.cpp b/source/libs/asura-lib-utils/filesystem/resource_manager.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/source/libs/asura-lib-utils/filesystem/resource_manager.cpp
diff --git a/source/libs/asura-lib-utils/filesystem/resource_manager.h b/source/libs/asura-lib-utils/filesystem/resource_manager.h
new file mode 100644
index 0000000..c5d8f06
--- /dev/null
+++ b/source/libs/asura-lib-utils/filesystem/resource_manager.h
@@ -0,0 +1,44 @@
+#ifndef __ASURA_ENGINE_RESOURCE_MANAGER_H__
+#define __ASURA_ENGINE_RESOURCE_MANAGER_H__
+
+#include <string>
+
+#include "../scripting/portable.hpp"
+#include "data_buffer.h"
+
+namespace AsuraEngine
+{
+ namespace Filesystem
+ {
+
+ ///
+ /// Դء洢ԴָĿ¼ȡ
+ ///
+ class ResourceManager ASURA_FINAL
+ {
+ public:
+
+ ResourceManager();
+ ~ResourceManager();
+
+ ///
+ /// װظĿ¼
+ ///
+ void Mount(const std::string& root);
+
+ ///
+ /// ȡļһdata bufferעҪȷȷڴ棬ڵôʹunique_ptr
+ ///
+ DataBuffer* LoadFile(const std::string& path);
+
+ ///
+ /// data buffer
+ ///
+ void SaveFile(const std::string& path, const DataBuffer* buffer);
+
+ };
+
+ }
+}
+
+#endif \ No newline at end of file
diff --git a/source/libs/asura-lib-utils/math/curve.cpp b/source/libs/asura-lib-utils/math/curve.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/source/libs/asura-lib-utils/math/curve.cpp
diff --git a/source/libs/asura-lib-utils/math/curve.h b/source/libs/asura-lib-utils/math/curve.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/source/libs/asura-lib-utils/math/curve.h
diff --git a/source/libs/asura-lib-utils/math/functions.cpp b/source/libs/asura-lib-utils/math/functions.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/source/libs/asura-lib-utils/math/functions.cpp
diff --git a/source/libs/asura-lib-utils/math/functions.h b/source/libs/asura-lib-utils/math/functions.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/source/libs/asura-lib-utils/math/functions.h
diff --git a/source/libs/asura-lib-utils/math/matrix44.cpp b/source/libs/asura-lib-utils/math/matrix44.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/source/libs/asura-lib-utils/math/matrix44.cpp
diff --git a/source/libs/asura-lib-utils/math/matrix44.h b/source/libs/asura-lib-utils/math/matrix44.h
new file mode 100644
index 0000000..4ab3c0b
--- /dev/null
+++ b/source/libs/asura-lib-utils/math/matrix44.h
@@ -0,0 +1,24 @@
+#ifndef __ASURA_ENGINE_MATRIX44_H__
+#define __ASURA_ENGINE_MATRIX44_H__
+
+namespace AsuraEngine
+{
+ namespace Math
+ {
+
+ ///
+ /// 4x4
+ ///
+ class Matrix44
+ {
+ public:
+
+ private:
+
+
+ };
+
+ }
+}
+
+#endif \ No newline at end of file
diff --git a/source/libs/asura-lib-utils/math/ranged_value.cpp b/source/libs/asura-lib-utils/math/ranged_value.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/source/libs/asura-lib-utils/math/ranged_value.cpp
diff --git a/source/libs/asura-lib-utils/math/ranged_value.h b/source/libs/asura-lib-utils/math/ranged_value.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/source/libs/asura-lib-utils/math/ranged_value.h
diff --git a/source/libs/asura-lib-utils/math/rect.hpp b/source/libs/asura-lib-utils/math/rect.hpp
new file mode 100644
index 0000000..f635007
--- /dev/null
+++ b/source/libs/asura-lib-utils/math/rect.hpp
@@ -0,0 +1,32 @@
+#ifndef __ASURA_ENGINE_RECT_H__
+#define __ASURA_ENGINE_RECT_H__
+
+namespace AsuraEngine
+{
+ namespace Math
+ {
+
+ template<typename T>
+ struct Rect
+ {
+ public:
+ Rect();
+ ~Rect(T x, T y, T w, T h);
+
+ template <typename U>
+ explicit Rect(const Rect<U>& rect);
+
+ T x, y, w, h;
+ };
+
+#include "Rect.inl"
+
+ // Define the most common types
+ typedef Rect<int> Recti;
+ typedef Rect<unsigned int> Rectu;
+ typedef Rect<float> Rectf;
+
+ }
+}
+
+#endif \ No newline at end of file
diff --git a/source/libs/asura-lib-utils/math/rect.inl b/source/libs/asura-lib-utils/math/rect.inl
new file mode 100644
index 0000000..891a3f8
--- /dev/null
+++ b/source/libs/asura-lib-utils/math/rect.inl
@@ -0,0 +1,19 @@
+template <typename T>
+inline Rect<T>::Rect()
+ : x(0)
+ , y(0)
+ , w(0)
+ , h(0)
+{
+
+}
+
+template <typename T>
+inline Rect<T>::Rect(T X, T Y, T W, T H)
+ : x(X)
+ , y(Y)
+ , w(W)
+ , h(H)
+{
+
+}
diff --git a/source/libs/asura-lib-utils/math/transform.cpp b/source/libs/asura-lib-utils/math/transform.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/source/libs/asura-lib-utils/math/transform.cpp
diff --git a/source/libs/asura-lib-utils/math/transform.h b/source/libs/asura-lib-utils/math/transform.h
new file mode 100644
index 0000000..be4c850
--- /dev/null
+++ b/source/libs/asura-lib-utils/math/transform.h
@@ -0,0 +1,30 @@
+#ifndef __ASURA_ENGINE_TRANSFORM_H__
+#define __ASURA_ENGINE_TRANSFORM_H__
+
+#include "../scripting/portable.hpp"
+
+namespace AsuraEngine
+{
+ namespace Math
+ {
+
+ class Transform
+ {
+ public:
+
+ void Set(float x, float y, float sx, float sy, float ox, float oy, float r);
+
+ void LoadIdentity();
+
+ void Move(float dx = 0, float dy = 0);
+ void Rotate(float r);
+ void Scale(float sx, float sy);
+
+ float m[16]; //4x4 matrix
+
+ };
+
+ }
+}
+
+#endif \ No newline at end of file
diff --git a/source/libs/asura-lib-utils/math/vector2.hpp b/source/libs/asura-lib-utils/math/vector2.hpp
new file mode 100644
index 0000000..df78255
--- /dev/null
+++ b/source/libs/asura-lib-utils/math/vector2.hpp
@@ -0,0 +1,70 @@
+#ifndef __ASURA_ENGINE_VECTOR2_H__
+#define __ASURA_ENGINE_VECTOR2_H__
+
+namespace AsuraEngine
+{
+ namespace Math
+ {
+ template <typename T>
+ class Vector2
+ {
+ public:
+ Vector2();
+ Vector2(T X, T Y);
+
+ template <typename U>
+ explicit Vector2(const Vector2<U>& vector);
+
+ Set(T X, T Y);
+
+ T x; ///< X coordinate of the vector
+ T y; ///< Y coordinate of the vector
+ };
+
+ template <typename T>
+ Vector2<T> operator -(const Vector2<T>& right);
+
+ template <typename T>
+ Vector2<T>& operator +=(Vector2<T>& left, const Vector2<T>& right);
+
+ template <typename T>
+ Vector2<T>& operator -=(Vector2<T>& left, const Vector2<T>& right);
+
+ template <typename T>
+ Vector2<T> operator +(const Vector2<T>& left, const Vector2<T>& right);
+
+ template <typename T>
+ Vector2<T> operator -(const Vector2<T>& left, const Vector2<T>& right);
+
+ template <typename T>
+ Vector2<T> operator *(const Vector2<T>& left, T right);
+
+ template <typename T>
+ Vector2<T> operator *(T left, const Vector2<T>& right);
+
+ template <typename T>
+ Vector2<T>& operator *=(Vector2<T>& left, T right);
+
+ template <typename T>
+ Vector2<T> operator /(const Vector2<T>& left, T right);
+
+ template <typename T>
+ Vector2<T>& operator /=(Vector2<T>& left, T right);
+
+ template <typename T>
+ bool operator ==(const Vector2<T>& left, const Vector2<T>& right);
+
+ template <typename T>
+ bool operator !=(const Vector2<T>& left, const Vector2<T>& right);
+
+#include "Vector2.inl"
+
+ // Define the most common types
+ typedef Vector2<int> Vector2i;
+ typedef Vector2<unsigned int> Vector2u;
+ typedef Vector2<float> Vector2f;
+
+ }
+}
+
+#endif \ No newline at end of file
diff --git a/source/libs/asura-lib-utils/math/vector2.inl b/source/libs/asura-lib-utils/math/vector2.inl
new file mode 100644
index 0000000..9e131a7
--- /dev/null
+++ b/source/libs/asura-lib-utils/math/vector2.inl
@@ -0,0 +1,114 @@
+template <typename T>
+inline Vector2<T>::Vector2() :
+ x(0),
+ y(0)
+{
+
+}
+
+template <typename T>
+inline Vector2<T>::Vector2(T X, T Y) :
+ x(X),
+ y(Y)
+{
+
+}
+
+template <typename T>
+template <typename U>
+inline Vector2<T>::Vector2(const Vector2<U>& vector) :
+ x(static_cast<T>(vector.x)),
+ y(static_cast<T>(vector.y))
+{
+}
+
+template <typename T>
+inline Vector2<T>::Set(T X, T Y)
+{
+ x = X;
+ y = Y;
+}
+
+template <typename T>
+inline Vector2<T> operator -(const Vector2<T>& right)
+{
+ return Vector2<T>(-right.x, -right.y);
+}
+
+template <typename T>
+inline Vector2<T>& operator +=(Vector2<T>& left, const Vector2<T>& right)
+{
+ left.x += right.x;
+ left.y += right.y;
+
+ return left;
+}
+
+template <typename T>
+inline Vector2<T>& operator -=(Vector2<T>& left, const Vector2<T>& right)
+{
+ left.x -= right.x;
+ left.y -= right.y;
+
+ return left;
+}
+
+template <typename T>
+inline Vector2<T> operator +(const Vector2<T>& left, const Vector2<T>& right)
+{
+ return Vector2<T>(left.x + right.x, left.y + right.y);
+}
+
+template <typename T>
+inline Vector2<T> operator -(const Vector2<T>& left, const Vector2<T>& right)
+{
+ return Vector2<T>(left.x - right.x, left.y - right.y);
+}
+
+template <typename T>
+inline Vector2<T> operator *(const Vector2<T>& left, T right)
+{
+ return Vector2<T>(left.x * right, left.y * right);
+}
+
+template <typename T>
+inline Vector2<T> operator *(T left, const Vector2<T>& right)
+{
+ return Vector2<T>(right.x * left, right.y * left);
+}
+
+template <typename T>
+inline Vector2<T>& operator *=(Vector2<T>& left, T right)
+{
+ left.x *= right;
+ left.y *= right;
+
+ return left;
+}
+
+template <typename T>
+inline Vector2<T> operator /(const Vector2<T>& left, T right)
+{
+ return Vector2<T>(left.x / right, left.y / right);
+}
+
+template <typename T>
+inline Vector2<T>& operator /=(Vector2<T>& left, T right)
+{
+ left.x /= right;
+ left.y /= right;
+
+ return left;
+}
+
+template <typename T>
+inline bool operator ==(const Vector2<T>& left, const Vector2<T>& right)
+{
+ return (left.x == right.x) && (left.y == right.y);
+}
+
+template <typename T>
+inline bool operator !=(const Vector2<T>& left, const Vector2<T>& right)
+{
+ return (left.x != right.x) || (left.y != right.y);
+}
diff --git a/source/libs/asura-lib-utils/math/vector3.hpp b/source/libs/asura-lib-utils/math/vector3.hpp
new file mode 100644
index 0000000..2b23406
--- /dev/null
+++ b/source/libs/asura-lib-utils/math/vector3.hpp
@@ -0,0 +1,233 @@
+#ifndef __ASURA_ENGINE_VECTOR3_H__
+#define __ASURA_ENGINE_VECTOR3_H__
+
+namespace AsuraEngine
+{
+ namespace Math
+ {
+ template <typename T>
+ class Vector3
+ {
+ public:
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Default constructor
+ ///
+ /// Creates a Vector3(0, 0, 0).
+ ///
+ ////////////////////////////////////////////////////////////
+ Vector3();
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Construct the vector from its coordinates
+ ///
+ /// \param X X coordinate
+ /// \param Y Y coordinate
+ /// \param Z Z coordinate
+ ///
+ ////////////////////////////////////////////////////////////
+ Vector3(T X, T Y, T Z);
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Construct the vector from another type of vector
+ ///
+ /// This constructor doesn't replace the copy constructor,
+ /// it's called only when U != T.
+ /// A call to this constructor will fail to compile if U
+ /// is not convertible to T.
+ ///
+ /// \param vector Vector to convert
+ ///
+ ////////////////////////////////////////////////////////////
+ template <typename U>
+ explicit Vector3(const Vector3<U>& vector);
+
+ ////////////////////////////////////////////////////////////
+ // Member data
+ ////////////////////////////////////////////////////////////
+ T x; ///< X coordinate of the vector
+ T y; ///< Y coordinate of the vector
+ T z; ///< Z coordinate of the vector
+ };
+
+ ////////////////////////////////////////////////////////////
+ /// \relates Vector3
+ /// \brief Overload of unary operator -
+ ///
+ /// \param left Vector to negate
+ ///
+ /// \return Memberwise opposite of the vector
+ ///
+ ////////////////////////////////////////////////////////////
+ template <typename T>
+ Vector3<T> operator -(const Vector3<T>& left);
+
+ ////////////////////////////////////////////////////////////
+ /// \relates Vector3
+ /// \brief Overload of binary operator +=
+ ///
+ /// This operator performs a memberwise addition of both vectors,
+ /// and assigns the result to \a left.
+ ///
+ /// \param left Left operand (a vector)
+ /// \param right Right operand (a vector)
+ ///
+ /// \return Reference to \a left
+ ///
+ ////////////////////////////////////////////////////////////
+ template <typename T>
+ Vector3<T>& operator +=(Vector3<T>& left, const Vector3<T>& right);
+
+ ////////////////////////////////////////////////////////////
+ /// \relates Vector3
+ /// \brief Overload of binary operator -=
+ ///
+ /// This operator performs a memberwise subtraction of both vectors,
+ /// and assigns the result to \a left.
+ ///
+ /// \param left Left operand (a vector)
+ /// \param right Right operand (a vector)
+ ///
+ /// \return Reference to \a left
+ ///
+ ////////////////////////////////////////////////////////////
+ template <typename T>
+ Vector3<T>& operator -=(Vector3<T>& left, const Vector3<T>& right);
+
+ ////////////////////////////////////////////////////////////
+ /// \relates Vector3
+ /// \brief Overload of binary operator +
+ ///
+ /// \param left Left operand (a vector)
+ /// \param right Right operand (a vector)
+ ///
+ /// \return Memberwise addition of both vectors
+ ///
+ ////////////////////////////////////////////////////////////
+ template <typename T>
+ Vector3<T> operator +(const Vector3<T>& left, const Vector3<T>& right);
+
+ ////////////////////////////////////////////////////////////
+ /// \relates Vector3
+ /// \brief Overload of binary operator -
+ ///
+ /// \param left Left operand (a vector)
+ /// \param right Right operand (a vector)
+ ///
+ /// \return Memberwise subtraction of both vectors
+ ///
+ ////////////////////////////////////////////////////////////
+ template <typename T>
+ Vector3<T> operator -(const Vector3<T>& left, const Vector3<T>& right);
+
+ ////////////////////////////////////////////////////////////
+ /// \relates Vector3
+ /// \brief Overload of binary operator *
+ ///
+ /// \param left Left operand (a vector)
+ /// \param right Right operand (a scalar value)
+ ///
+ /// \return Memberwise multiplication by \a right
+ ///
+ ////////////////////////////////////////////////////////////
+ template <typename T>
+ Vector3<T> operator *(const Vector3<T>& left, T right);
+
+ ////////////////////////////////////////////////////////////
+ /// \relates Vector3
+ /// \brief Overload of binary operator *
+ ///
+ /// \param left Left operand (a scalar value)
+ /// \param right Right operand (a vector)
+ ///
+ /// \return Memberwise multiplication by \a left
+ ///
+ ////////////////////////////////////////////////////////////
+ template <typename T>
+ Vector3<T> operator *(T left, const Vector3<T>& right);
+
+ ////////////////////////////////////////////////////////////
+ /// \relates Vector3
+ /// \brief Overload of binary operator *=
+ ///
+ /// This operator performs a memberwise multiplication by \a right,
+ /// and assigns the result to \a left.
+ ///
+ /// \param left Left operand (a vector)
+ /// \param right Right operand (a scalar value)
+ ///
+ /// \return Reference to \a left
+ ///
+ ////////////////////////////////////////////////////////////
+ template <typename T>
+ Vector3<T>& operator *=(Vector3<T>& left, T right);
+
+ ////////////////////////////////////////////////////////////
+ /// \relates Vector3
+ /// \brief Overload of binary operator /
+ ///
+ /// \param left Left operand (a vector)
+ /// \param right Right operand (a scalar value)
+ ///
+ /// \return Memberwise division by \a right
+ ///
+ ////////////////////////////////////////////////////////////
+ template <typename T>
+ Vector3<T> operator /(const Vector3<T>& left, T right);
+
+ ////////////////////////////////////////////////////////////
+ /// \relates Vector3
+ /// \brief Overload of binary operator /=
+ ///
+ /// This operator performs a memberwise division by \a right,
+ /// and assigns the result to \a left.
+ ///
+ /// \param left Left operand (a vector)
+ /// \param right Right operand (a scalar value)
+ ///
+ /// \return Reference to \a left
+ ///
+ ////////////////////////////////////////////////////////////
+ template <typename T>
+ Vector3<T>& operator /=(Vector3<T>& left, T right);
+
+ ////////////////////////////////////////////////////////////
+ /// \relates Vector3
+ /// \brief Overload of binary operator ==
+ ///
+ /// This operator compares strict equality between two vectors.
+ ///
+ /// \param left Left operand (a vector)
+ /// \param right Right operand (a vector)
+ ///
+ /// \return True if \a left is equal to \a right
+ ///
+ ////////////////////////////////////////////////////////////
+ template <typename T>
+ bool operator ==(const Vector3<T>& left, const Vector3<T>& right);
+
+ ////////////////////////////////////////////////////////////
+ /// \relates Vector3
+ /// \brief Overload of binary operator !=
+ ///
+ /// This operator compares strict difference between two vectors.
+ ///
+ /// \param left Left operand (a vector)
+ /// \param right Right operand (a vector)
+ ///
+ /// \return True if \a left is not equal to \a right
+ ///
+ ////////////////////////////////////////////////////////////
+ template <typename T>
+ bool operator !=(const Vector3<T>& left, const Vector3<T>& right);
+
+#include "Vector3.inl"
+
+ // Define the most common types
+ typedef Vector3<int> Vector3i;
+ typedef Vector3<float> Vector3f;
+
+ }
+}
+
+#endif \ No newline at end of file
diff --git a/source/libs/asura-lib-utils/math/vector3.inl b/source/libs/asura-lib-utils/math/vector3.inl
new file mode 100644
index 0000000..3a2aa93
--- /dev/null
+++ b/source/libs/asura-lib-utils/math/vector3.inl
@@ -0,0 +1,145 @@
+
+
+////////////////////////////////////////////////////////////
+template <typename T>
+inline Vector3<T>::Vector3() :
+ x(0),
+ y(0),
+ z(0)
+{
+
+}
+
+
+////////////////////////////////////////////////////////////
+template <typename T>
+inline Vector3<T>::Vector3(T X, T Y, T Z) :
+ x(X),
+ y(Y),
+ z(Z)
+{
+
+}
+
+
+////////////////////////////////////////////////////////////
+template <typename T>
+template <typename U>
+inline Vector3<T>::Vector3(const Vector3<U>& vector) :
+ x(static_cast<T>(vector.x)),
+ y(static_cast<T>(vector.y)),
+ z(static_cast<T>(vector.z))
+{
+}
+
+
+////////////////////////////////////////////////////////////
+template <typename T>
+inline Vector3<T> operator -(const Vector3<T>& left)
+{
+ return Vector3<T>(-left.x, -left.y, -left.z);
+}
+
+
+////////////////////////////////////////////////////////////
+template <typename T>
+inline Vector3<T>& operator +=(Vector3<T>& left, const Vector3<T>& right)
+{
+ left.x += right.x;
+ left.y += right.y;
+ left.z += right.z;
+
+ return left;
+}
+
+
+////////////////////////////////////////////////////////////
+template <typename T>
+inline Vector3<T>& operator -=(Vector3<T>& left, const Vector3<T>& right)
+{
+ left.x -= right.x;
+ left.y -= right.y;
+ left.z -= right.z;
+
+ return left;
+}
+
+
+////////////////////////////////////////////////////////////
+template <typename T>
+inline Vector3<T> operator +(const Vector3<T>& left, const Vector3<T>& right)
+{
+ return Vector3<T>(left.x + right.x, left.y + right.y, left.z + right.z);
+}
+
+
+////////////////////////////////////////////////////////////
+template <typename T>
+inline Vector3<T> operator -(const Vector3<T>& left, const Vector3<T>& right)
+{
+ return Vector3<T>(left.x - right.x, left.y - right.y, left.z - right.z);
+}
+
+
+////////////////////////////////////////////////////////////
+template <typename T>
+inline Vector3<T> operator *(const Vector3<T>& left, T right)
+{
+ return Vector3<T>(left.x * right, left.y * right, left.z * right);
+}
+
+
+////////////////////////////////////////////////////////////
+template <typename T>
+inline Vector3<T> operator *(T left, const Vector3<T>& right)
+{
+ return Vector3<T>(right.x * left, right.y * left, right.z * left);
+}
+
+
+////////////////////////////////////////////////////////////
+template <typename T>
+inline Vector3<T>& operator *=(Vector3<T>& left, T right)
+{
+ left.x *= right;
+ left.y *= right;
+ left.z *= right;
+
+ return left;
+}
+
+
+////////////////////////////////////////////////////////////
+template <typename T>
+inline Vector3<T> operator /(const Vector3<T>& left, T right)
+{
+ return Vector3<T>(left.x / right, left.y / right, left.z / right);
+}
+
+
+////////////////////////////////////////////////////////////
+template <typename T>
+inline Vector3<T>& operator /=(Vector3<T>& left, T right)
+{
+ left.x /= right;
+ left.y /= right;
+ left.z /= right;
+
+ return left;
+}
+
+
+////////////////////////////////////////////////////////////
+template <typename T>
+inline bool operator ==(const Vector3<T>& left, const Vector3<T>& right)
+{
+ return (left.x == right.x) && (left.y == right.y) && (left.z == right.z);
+}
+
+
+////////////////////////////////////////////////////////////
+template <typename T>
+inline bool operator !=(const Vector3<T>& left, const Vector3<T>& right)
+{
+ return (left.x != right.x) || (left.y != right.y) || (left.z != right.z);
+}
diff --git a/source/libs/asura-lib-utils/math/vector4.h b/source/libs/asura-lib-utils/math/vector4.h
new file mode 100644
index 0000000..13a9d8a
--- /dev/null
+++ b/source/libs/asura-lib-utils/math/vector4.h
@@ -0,0 +1,234 @@
+#ifndef __ASURA_ENGINE_VECTOR4_H__
+#define __ASURA_ENGINE_VECTOR4_H__
+
+namespace AsuraEngine
+{
+ namespace Math
+ {
+ template <typename T>
+ class Vector4
+ {
+ public:
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Default constructor
+ ///
+ /// Creates a Vector4(0, 0, 0).
+ ///
+ ////////////////////////////////////////////////////////////
+ Vector4();
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Construct the vector from its coordinates
+ ///
+ /// \param X X coordinate
+ /// \param Y Y coordinate
+ /// \param Z Z coordinate
+ ///
+ ////////////////////////////////////////////////////////////
+ Vector4(T X, T Y, T Z, T W);
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Construct the vector from another type of vector
+ ///
+ /// This constructor doesn't replace the copy constructor,
+ /// it's called only when U != T.
+ /// A call to this constructor will fail to compile if U
+ /// is not convertible to T.
+ ///
+ /// \param vector Vector to convert
+ ///
+ ////////////////////////////////////////////////////////////
+ template <typename U>
+ explicit Vector4(const Vector4<U>& vector);
+
+ ////////////////////////////////////////////////////////////
+ // Member data
+ ////////////////////////////////////////////////////////////
+ T x; ///< X coordinate of the vector
+ T y; ///< Y coordinate of the vector
+ T z; ///< Z coordinate of the vector
+ T w; ///< W coordinate of the vector
+ };
+
+ ////////////////////////////////////////////////////////////
+ /// \relates Vector4
+ /// \brief Overload of unary operator -
+ ///
+ /// \param left Vector to negate
+ ///
+ /// \return Memberwise opposite of the vector
+ ///
+ ////////////////////////////////////////////////////////////
+ template <typename T>
+ Vector4<T> operator -(const Vector4<T>& left);
+
+ ////////////////////////////////////////////////////////////
+ /// \relates Vector4
+ /// \brief Overload of binary operator +=
+ ///
+ /// This operator performs a memberwise addition of both vectors,
+ /// and assigns the result to \a left.
+ ///
+ /// \param left Left operand (a vector)
+ /// \param right Right operand (a vector)
+ ///
+ /// \return Reference to \a left
+ ///
+ ////////////////////////////////////////////////////////////
+ template <typename T>
+ Vector4<T>& operator +=(Vector4<T>& left, const Vector4<T>& right);
+
+ ////////////////////////////////////////////////////////////
+ /// \relates Vector4
+ /// \brief Overload of binary operator -=
+ ///
+ /// This operator performs a memberwise subtraction of both vectors,
+ /// and assigns the result to \a left.
+ ///
+ /// \param left Left operand (a vector)
+ /// \param right Right operand (a vector)
+ ///
+ /// \return Reference to \a left
+ ///
+ ////////////////////////////////////////////////////////////
+ template <typename T>
+ Vector4<T>& operator -=(Vector4<T>& left, const Vector4<T>& right);
+
+ ////////////////////////////////////////////////////////////
+ /// \relates Vector4
+ /// \brief Overload of binary operator +
+ ///
+ /// \param left Left operand (a vector)
+ /// \param right Right operand (a vector)
+ ///
+ /// \return Memberwise addition of both vectors
+ ///
+ ////////////////////////////////////////////////////////////
+ template <typename T>
+ Vector4<T> operator +(const Vector4<T>& left, const Vector4<T>& right);
+
+ ////////////////////////////////////////////////////////////
+ /// \relates Vector4
+ /// \brief Overload of binary operator -
+ ///
+ /// \param left Left operand (a vector)
+ /// \param right Right operand (a vector)
+ ///
+ /// \return Memberwise subtraction of both vectors
+ ///
+ ////////////////////////////////////////////////////////////
+ template <typename T>
+ Vector4<T> operator -(const Vector4<T>& left, const Vector4<T>& right);
+
+ ////////////////////////////////////////////////////////////
+ /// \relates Vector4
+ /// \brief Overload of binary operator *
+ ///
+ /// \param left Left operand (a vector)
+ /// \param right Right operand (a scalar value)
+ ///
+ /// \return Memberwise multiplication by \a right
+ ///
+ ////////////////////////////////////////////////////////////
+ template <typename T>
+ Vector4<T> operator *(const Vector4<T>& left, T right);
+
+ ////////////////////////////////////////////////////////////
+ /// \relates Vector4
+ /// \brief Overload of binary operator *
+ ///
+ /// \param left Left operand (a scalar value)
+ /// \param right Right operand (a vector)
+ ///
+ /// \return Memberwise multiplication by \a left
+ ///
+ ////////////////////////////////////////////////////////////
+ template <typename T>
+ Vector4<T> operator *(T left, const Vector4<T>& right);
+
+ ////////////////////////////////////////////////////////////
+ /// \relates Vector4
+ /// \brief Overload of binary operator *=
+ ///
+ /// This operator performs a memberwise multiplication by \a right,
+ /// and assigns the result to \a left.
+ ///
+ /// \param left Left operand (a vector)
+ /// \param right Right operand (a scalar value)
+ ///
+ /// \return Reference to \a left
+ ///
+ ////////////////////////////////////////////////////////////
+ template <typename T>
+ Vector4<T>& operator *=(Vector4<T>& left, T right);
+
+ ////////////////////////////////////////////////////////////
+ /// \relates Vector4
+ /// \brief Overload of binary operator /
+ ///
+ /// \param left Left operand (a vector)
+ /// \param right Right operand (a scalar value)
+ ///
+ /// \return Memberwise division by \a right
+ ///
+ ////////////////////////////////////////////////////////////
+ template <typename T>
+ Vector4<T> operator /(const Vector4<T>& left, T right);
+
+ ////////////////////////////////////////////////////////////
+ /// \relates Vector4
+ /// \brief Overload of binary operator /=
+ ///
+ /// This operator performs a memberwise division by \a right,
+ /// and assigns the result to \a left.
+ ///
+ /// \param left Left operand (a vector)
+ /// \param right Right operand (a scalar value)
+ ///
+ /// \return Reference to \a left
+ ///
+ ////////////////////////////////////////////////////////////
+ template <typename T>
+ Vector4<T>& operator /=(Vector4<T>& left, T right);
+
+ ////////////////////////////////////////////////////////////
+ /// \relates Vector4
+ /// \brief Overload of binary operator ==
+ ///
+ /// This operator compares strict equality between two vectors.
+ ///
+ /// \param left Left operand (a vector)
+ /// \param right Right operand (a vector)
+ ///
+ /// \return True if \a left is equal to \a right
+ ///
+ ////////////////////////////////////////////////////////////
+ template <typename T>
+ bool operator ==(const Vector4<T>& left, const Vector4<T>& right);
+
+ ////////////////////////////////////////////////////////////
+ /// \relates Vector4
+ /// \brief Overload of binary operator !=
+ ///
+ /// This operator compares strict difference between two vectors.
+ ///
+ /// \param left Left operand (a vector)
+ /// \param right Right operand (a vector)
+ ///
+ /// \return True if \a left is not equal to \a right
+ ///
+ ////////////////////////////////////////////////////////////
+ template <typename T>
+ bool operator !=(const Vector4<T>& left, const Vector4<T>& right);
+
+#include "Vector4.inl"
+
+ // Define the most common types
+ typedef Vector4<int> Vector4i;
+ typedef Vector4<float> Vector4f;
+
+ }
+}
+
+#endif \ No newline at end of file
diff --git a/source/libs/asura-lib-utils/math/vector4.inl b/source/libs/asura-lib-utils/math/vector4.inl
new file mode 100644
index 0000000..025bfcc
--- /dev/null
+++ b/source/libs/asura-lib-utils/math/vector4.inl
@@ -0,0 +1,152 @@
+
+
+////////////////////////////////////////////////////////////
+template <typename T>
+inline Vector4<T>::Vector4() :
+ x(0),
+ y(0),
+ z(0),
+ w(0)
+{
+
+}
+
+
+////////////////////////////////////////////////////////////
+template <typename T>
+inline Vector4<T>::Vector4(T X, T Y, T Z) :
+ x(X),
+ y(Y),
+ z(Z),
+ w(0)
+{
+
+}
+
+
+////////////////////////////////////////////////////////////
+template <typename T>
+template <typename U>
+inline Vector4<T>::Vector4(const Vector4<U>& vector) :
+ x(static_cast<T>(vector.x)),
+ y(static_cast<T>(vector.y)),
+ z(static_cast<T>(vector.z))
+ w(static_cast<T>(vector.w))
+{
+}
+
+
+////////////////////////////////////////////////////////////
+template <typename T>
+inline Vector4<T> operator -(const Vector4<T>& left)
+{
+ return Vector4<T>(-left.x, -left.y, -left.z, -left.w);
+}
+
+
+////////////////////////////////////////////////////////////
+template <typename T>
+inline Vector4<T>& operator +=(Vector4<T>& left, const Vector4<T>& right)
+{
+ left.x += right.x;
+ left.y += right.y;
+ left.z += right.z;
+ left.w += right.w;
+
+ return left;
+}
+
+
+////////////////////////////////////////////////////////////
+template <typename T>
+inline Vector4<T>& operator -=(Vector4<T>& left, const Vector4<T>& right)
+{
+ left.x -= right.x;
+ left.y -= right.y;
+ left.z -= right.z;
+ left.w -= right.w;
+
+ return left;
+}
+
+
+////////////////////////////////////////////////////////////
+template <typename T>
+inline Vector4<T> operator +(const Vector4<T>& left, const Vector4<T>& right)
+{
+ return Vector4<T>(left.x + right.x, left.y + right.y, left.z + right.z, left.w + right.w);
+}
+
+
+////////////////////////////////////////////////////////////
+template <typename T>
+inline Vector4<T> operator -(const Vector4<T>& left, const Vector4<T>& right)
+{
+ return Vector4<T>(left.x - right.x, left.y - right.y, left.z - right.z, left.w - right.w);
+}
+
+
+////////////////////////////////////////////////////////////
+template <typename T>
+inline Vector4<T> operator *(const Vector4<T>& left, T right)
+{
+ return Vector4<T>(left.x * right, left.y * right, left.z * right, left.w * right);
+}
+
+
+////////////////////////////////////////////////////////////
+template <typename T>
+inline Vector4<T> operator *(T left, const Vector4<T>& right)
+{
+ return Vector4<T>(right.x * left, right.y * left, right.z * left, right.w * left);
+}
+
+
+////////////////////////////////////////////////////////////
+template <typename T>
+inline Vector4<T>& operator *=(Vector4<T>& left, T right)
+{
+ left.x *= right;
+ left.y *= right;
+ left.z *= right;
+ left.w *= right;
+
+ return left;
+}
+
+
+////////////////////////////////////////////////////////////
+template <typename T>
+inline Vector4<T> operator /(const Vector4<T>& left, T right)
+{
+ return Vector4<T>(left.x / right, left.y / right, left.z / right, left.w / right);
+}
+
+
+////////////////////////////////////////////////////////////
+template <typename T>
+inline Vector4<T>& operator /=(Vector4<T>& left, T right)
+{
+ left.x /= right;
+ left.y /= right;
+ left.z /= right;
+ left.w /= right;
+
+ return left;
+}
+
+
+////////////////////////////////////////////////////////////
+template <typename T>
+inline bool operator ==(const Vector4<T>& left, const Vector4<T>& right)
+{
+ return (left.x == right.x) && (left.y == right.y) && (left.z == right.z) && (left.w == right.w);
+}
+
+
+////////////////////////////////////////////////////////////
+template <typename T>
+inline bool operator !=(const Vector4<T>& left, const Vector4<T>& right)
+{
+ return (left.x != right.x) || (left.y != right.y) || (left.z != right.z) || (left.w != right.w);
+}
diff --git a/source/libs/asura-lib-utils/module.h b/source/libs/asura-lib-utils/module.h
new file mode 100644
index 0000000..b22c68c
--- /dev/null
+++ b/source/libs/asura-lib-utils/module.h
@@ -0,0 +1,32 @@
+#ifndef __ASURA_MODULE_H__
+#define __ASURA_MODULE_H__
+
+#include "type.h"
+#include "scripting/portable.hpp"
+
+namespace AsuraEngine
+{
+
+ ///
+ /// Asura libs Ҫ̳д࣬Կעᡣģа˳Щģ飬Ȼ˳InitializeFinalizeʼ
+ /// رЩģ顣
+ ///
+ ASURA_ABSTRACT class Module
+ {
+ public:
+
+ ///
+ /// ʼģ顣
+ ///
+ virtual void Initialize(Luax::LuaxState& state) = 0;
+
+ ///
+ /// رģ顣
+ ///
+ virtual void Finalize(Luax::LuaxState& state) = 0;
+
+ };
+
+}
+
+#endif \ No newline at end of file
diff --git a/source/libs/asura-lib-utils/scripting/luax.hpp b/source/libs/asura-lib-utils/scripting/luax.hpp
new file mode 100644
index 0000000..cca26e2
--- /dev/null
+++ b/source/libs/asura-lib-utils/scripting/luax.hpp
@@ -0,0 +1,13 @@
+#ifndef __ASURA_ENGINE_LUAX_H__
+#define __ASURA_ENGINE_LUAX_H__
+
+///
+/// Scripting with Lua.
+///
+extern "C" {
+#include <Lua51/lua.h>
+#include <Lua51/lauxlib.h>
+}
+#include <Luax/luax.h>
+
+#endif \ No newline at end of file
diff --git a/source/libs/asura-lib-utils/scripting/portable.hpp b/source/libs/asura-lib-utils/scripting/portable.hpp
new file mode 100644
index 0000000..7f780d1
--- /dev/null
+++ b/source/libs/asura-lib-utils/scripting/portable.hpp
@@ -0,0 +1,22 @@
+#ifndef __ASURA_ENGINE_PORTABLE_H__
+#define __ASURA_ENGINE_PORTABLE_H__
+
+#include "../type.h"
+
+#include "Luax.hpp"
+
+namespace AsuraEngine
+{
+ namespace Scripting
+ {
+
+ ///
+ /// ҪעluanativeҪ̳дģ塣
+ ///
+ template<typename T>
+ using Portable = Luax::LuaxNativeClass<T>;
+
+ }
+}
+
+#endif \ No newline at end of file
diff --git a/source/libs/asura-lib-utils/scripting/portable.inl b/source/libs/asura-lib-utils/scripting/portable.inl
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/source/libs/asura-lib-utils/scripting/portable.inl
diff --git a/source/libs/asura-lib-utils/type.h b/source/libs/asura-lib-utils/type.h
new file mode 100644
index 0000000..25b52fe
--- /dev/null
+++ b/source/libs/asura-lib-utils/type.h
@@ -0,0 +1,70 @@
+#ifndef __ASURA_UTILS_TYPE_H__
+#define __ASURA_UTILS_TYPE_H__
+
+#include <cstdlib>
+#include <stdint.h>
+
+namespace AsuraEngine
+{
+
+ //----------------------------------------------------------------------------------------------------------------
+
+ typedef int8_t int8;
+ typedef uint8_t uint8;
+ typedef uint8 byte;
+ typedef int16_t int16;
+ typedef uint16_t uint16;
+ typedef int32_t int32;
+ typedef uint32_t uint32;
+ typedef int64_t int64;
+ typedef uint64_t uint64;
+
+ typedef uint32_t uint;
+ typedef int32_t sint;
+
+ typedef std::size_t size_t;
+
+ //----------------------------------------------------------------------------------------------------------------
+
+#ifndef ASSERT
+ #ifdef NDEBUG
+ #define ASSERT(x) { false ? (void)(x) : (void)0; }
+ #else
+ #ifdef _WIN32
+ #define ASURA_DEBUG_BREAK() __debugbreak()
+ #else
+ #define ASURA_DEBUG_BREAK() raise(SIGTRAP)
+ #endif
+ #define ASSERT(x) do { const volatile bool asura_assert_b____ = !(x); if(asura_assert_b____) ASURA_DEBUG_BREAK(); } while (false)
+ #endif
+#endif
+
+ //----------------------------------------------------------------------------------------------------------------
+
+#ifdef _WIN32
+ #define ASURA_FINAL final
+ #define ASURA_LIBRARY_EXPORT __declspec(dllexport)
+ #define ASURA_LIBRARY_IMPORT __declspec(dllimport)
+ #define ASURA_FORCE_INLINE __forceinline
+ #define ASURA_RESTRICT __restrict
+ #define ASURA_ATTRIBUTE_USED
+ #define ASURA_ABSTRACT
+ #define ASURA_API ASURA_LIBRARY_EXPORT
+#else
+ #define ASURA_FINAL final
+ #define ASURA_LIBRARY_EXPORT __attribute__((visibility("default")))
+ #define ASURA_LIBRARY_IMPORT
+ #define ASURA_FORCE_INLINE __attribute__((always_inline)) inline
+ #define ASURA_RESTRICT __restrict__
+ #define ASURA_ATTRIBUTE_USED __attribute__((used))
+ #define ASURA_ABSTRACT
+ #define ASURA_API ASURA_LIBRARY_EXPORT
+#endif
+
+ //----------------------------------------------------------------------------------------------------------------
+
+#define ASURA_SDL_HOST 1
+
+} // namespace AsuraEngine
+
+#endif // __ASURA_CONFIG_H__ \ No newline at end of file
diff --git a/source/libs/asura-lib-utils/utils.h b/source/libs/asura-lib-utils/utils.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/source/libs/asura-lib-utils/utils.h
diff --git a/source/libs/asura-lib-utils/utils_module.cpp b/source/libs/asura-lib-utils/utils_module.cpp
new file mode 100644
index 0000000..7fe3612
--- /dev/null
+++ b/source/libs/asura-lib-utils/utils_module.cpp
@@ -0,0 +1,20 @@
+#include "utils_module.h"
+#include "./filesystem/data_buffer.h"
+
+using namespace AsuraEngine::Filesystem;
+
+namespace AsuraEngine
+{
+
+ void UtilsModule::Initialize(Luax::LuaxState& state)
+ {
+ LUAX_REGISTER_FACTORY(state, DataBuffer);
+
+ }
+
+ void UtilsModule::Finalize(Luax::LuaxState& state)
+ {
+
+ }
+
+} \ No newline at end of file
diff --git a/source/libs/asura-lib-utils/utils_module.h b/source/libs/asura-lib-utils/utils_module.h
new file mode 100644
index 0000000..0b5d076
--- /dev/null
+++ b/source/libs/asura-lib-utils/utils_module.h
@@ -0,0 +1,24 @@
+#ifndef __ASURA_LIBS_UTIL_MODULE_H__
+#define __ASURA_LIBS_UTIL_MODULE_H__
+
+#include "module.h"
+
+namespace AsuraEngine
+{
+
+ ///
+ /// Asuraģ
+ ///
+ class UtilsModule : public Module
+ {
+ public:
+
+ void Initialize(Luax::LuaxState& state) override;
+
+ void Finalize(Luax::LuaxState& state) override;
+
+ };
+
+}
+
+#endif \ No newline at end of file