diff options
Diffstat (limited to 'source/LoG')
-rw-r--r-- | source/LoG/LoG.cpp | 7 | ||||
-rw-r--r-- | source/LoG/ai/ai.h | 0 | ||||
-rw-r--r-- | source/LoG/art/block.cpp | 0 | ||||
-rw-r--r-- | source/LoG/art/block.h | 22 | ||||
-rw-r--r-- | source/LoG/art/lod.cpp | 0 | ||||
-rw-r--r-- | source/LoG/art/lod.h | 0 | ||||
-rw-r--r-- | source/LoG/art/mesh.cpp | 14 | ||||
-rw-r--r-- | source/LoG/art/mesh.h | 18 | ||||
-rw-r--r-- | source/LoG/art/voxel.cpp | 0 | ||||
-rw-r--r-- | source/LoG/art/voxel.h | 12 | ||||
-rw-r--r-- | source/LoG/game/game.h | 0 | ||||
-rw-r--r-- | source/LoG/game/items/item.h | 4 | ||||
-rw-r--r-- | source/LoG/gui/gui.h | 0 | ||||
-rw-r--r-- | source/LoG/map/map_generator.h | 0 | ||||
-rw-r--r-- | source/LoG/math/matrix44.cpp | 220 | ||||
-rw-r--r-- | source/LoG/math/matrix44.h | 94 | ||||
-rw-r--r-- | source/LoG/modding/modding.h | 0 | ||||
-rw-r--r-- | source/LoG/network/socket.h | 0 | ||||
-rw-r--r-- | source/LoG/physics/collision.h | 0 | ||||
-rw-r--r-- | source/LoG/scripting/api/api_list.h | 0 | ||||
-rw-r--r-- | source/LoG/threading/thread.h | 0 | ||||
-rw-r--r-- | source/LoG/utils/exception.h | 17 |
22 files changed, 408 insertions, 0 deletions
diff --git a/source/LoG/LoG.cpp b/source/LoG/LoG.cpp new file mode 100644 index 0000000..40e6842 --- /dev/null +++ b/source/LoG/LoG.cpp @@ -0,0 +1,7 @@ + +// Legend of Galaxy +int main() +{ + + return 0; +}
\ No newline at end of file diff --git a/source/LoG/ai/ai.h b/source/LoG/ai/ai.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/source/LoG/ai/ai.h diff --git a/source/LoG/art/block.cpp b/source/LoG/art/block.cpp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/source/LoG/art/block.cpp diff --git a/source/LoG/art/block.h b/source/LoG/art/block.h new file mode 100644 index 0000000..b081fff --- /dev/null +++ b/source/LoG/art/block.h @@ -0,0 +1,22 @@ +#ifndef __LOG_BLOCK_H__ +#define __LOG_BLOCK_H__ + +namespace Art +{ + + class Block + { + public: + + Block(); + ~Block(); + + private: + + float mMoveSpeed; + + }; + +} + +#endif
\ No newline at end of file diff --git a/source/LoG/art/lod.cpp b/source/LoG/art/lod.cpp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/source/LoG/art/lod.cpp diff --git a/source/LoG/art/lod.h b/source/LoG/art/lod.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/source/LoG/art/lod.h diff --git a/source/LoG/art/mesh.cpp b/source/LoG/art/mesh.cpp new file mode 100644 index 0000000..92111a1 --- /dev/null +++ b/source/LoG/art/mesh.cpp @@ -0,0 +1,14 @@ +#include "mesh.h" + +namespace Art +{ + + Mesh::Mesh() + { + } + + Mesh::~Mesh() + { + } + +}
\ No newline at end of file diff --git a/source/LoG/art/mesh.h b/source/LoG/art/mesh.h new file mode 100644 index 0000000..13aeaed --- /dev/null +++ b/source/LoG/art/mesh.h @@ -0,0 +1,18 @@ +#ifndef __LOG_MESH_H__ +#define __LOG_MESH_H__ + +namespace Art +{ + + class Mesh + { + public: + + Mesh(); + ~Mesh(); + + }; + +} + +#endif
\ No newline at end of file diff --git a/source/LoG/art/voxel.cpp b/source/LoG/art/voxel.cpp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/source/LoG/art/voxel.cpp diff --git a/source/LoG/art/voxel.h b/source/LoG/art/voxel.h new file mode 100644 index 0000000..9e8a24d --- /dev/null +++ b/source/LoG/art/voxel.h @@ -0,0 +1,12 @@ +#ifndef __LOG_VOXEL_H__ +#define __LOG_VOXEL_H__ + +/// +/// voxel模型 +/// +class Voxel +{ + +}; + +#endif
\ No newline at end of file diff --git a/source/LoG/game/game.h b/source/LoG/game/game.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/source/LoG/game/game.h diff --git a/source/LoG/game/items/item.h b/source/LoG/game/items/item.h new file mode 100644 index 0000000..fd479ff --- /dev/null +++ b/source/LoG/game/items/item.h @@ -0,0 +1,4 @@ +#ifndef __FFH_ITEM_H__ +#define __FFH_ITEM_H__ + +#endif
\ No newline at end of file diff --git a/source/LoG/gui/gui.h b/source/LoG/gui/gui.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/source/LoG/gui/gui.h diff --git a/source/LoG/map/map_generator.h b/source/LoG/map/map_generator.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/source/LoG/map/map_generator.h diff --git a/source/LoG/math/matrix44.cpp b/source/LoG/math/matrix44.cpp new file mode 100644 index 0000000..4514feb --- /dev/null +++ b/source/LoG/math/matrix44.cpp @@ -0,0 +1,220 @@ +#include <memory> + +#include "matrix44.h" + +const Matrix44 Matrix44::Identity; + +// | e0 e4 e8 e12 | +// | e1 e5 e9 e13 | +// | e2 e6 e10 e14 | +// | e3 e7 e11 e15 | + +Matrix44::Matrix44() +{ + SetIdentity(); +} + +Matrix44::Matrix44(const Matrix44& m) +{ + memcpy(&e, &m.e, 16 * sizeof(float)); +} + +Matrix44::~Matrix44() +{ +} + +void Matrix44::operator = (const Matrix44& m) +{ + memcpy(&e, &m.e, 16 * sizeof(float)); +} + +void Matrix44::SetOrtho(float l, float r, float b, float t, float n, float f) +{ + SetIdentity(); + float w = r - l; + float h = t - b; + float z = f - n; + e[0] = 2 / w; + e[5] = 2 / h; + e[10] = -2 / z; + e[12] = -(r + l) / w; + e[13] = -(t + b) / h; + e[14] = -(f + n) / z; + e[15] = 1; +} + +// | e0 e4 e8 e12 | +// | e1 e5 e9 e13 | +// | e2 e6 e10 e14 | +// | e3 e7 e11 e15 | +// | e0 e4 e8 e12 | +// | e1 e5 e9 e13 | +// | e2 e6 e10 e14 | +// | e3 e7 e11 e15 | + +Matrix44 Matrix44::operator * (const Matrix44 & m) const +{ + Matrix44 t; + + t.e[0] = (e[0] * m.e[0]) + (e[4] * m.e[1]) + (e[8] * m.e[2]) + (e[12] * m.e[3]); + t.e[4] = (e[0] * m.e[4]) + (e[4] * m.e[5]) + (e[8] * m.e[6]) + (e[12] * m.e[7]); + t.e[8] = (e[0] * m.e[8]) + (e[4] * m.e[9]) + (e[8] * m.e[10]) + (e[12] * m.e[11]); + t.e[12] = (e[0] * m.e[12]) + (e[4] * m.e[13]) + (e[8] * m.e[14]) + (e[12] * m.e[15]); + + t.e[1] = (e[1] * m.e[0]) + (e[5] * m.e[1]) + (e[9] * m.e[2]) + (e[13] * m.e[3]); + t.e[5] = (e[1] * m.e[4]) + (e[5] * m.e[5]) + (e[9] * m.e[6]) + (e[13] * m.e[7]); + t.e[9] = (e[1] * m.e[8]) + (e[5] * m.e[9]) + (e[9] * m.e[10]) + (e[13] * m.e[11]); + t.e[13] = (e[1] * m.e[12]) + (e[5] * m.e[13]) + (e[9] * m.e[14]) + (e[13] * m.e[15]); + + t.e[2] = (e[2] * m.e[0]) + (e[6] * m.e[1]) + (e[10] * m.e[2]) + (e[14] * m.e[3]); + t.e[6] = (e[2] * m.e[4]) + (e[6] * m.e[5]) + (e[10] * m.e[6]) + (e[14] * m.e[7]); + t.e[10] = (e[2] * m.e[8]) + (e[6] * m.e[9]) + (e[10] * m.e[10]) + (e[14] * m.e[11]); + t.e[14] = (e[2] * m.e[12]) + (e[6] * m.e[13]) + (e[10] * m.e[14]) + (e[14] * m.e[15]); + + t.e[3] = (e[3] * m.e[0]) + (e[7] * m.e[1]) + (e[11] * m.e[2]) + (e[15] * m.e[3]); + t.e[7] = (e[3] * m.e[4]) + (e[7] * m.e[5]) + (e[11] * m.e[6]) + (e[15] * m.e[7]); + t.e[11] = (e[3] * m.e[8]) + (e[7] * m.e[9]) + (e[11] * m.e[10]) + (e[15] * m.e[11]); + t.e[15] = (e[3] * m.e[12]) + (e[7] * m.e[13]) + (e[11] * m.e[14]) + (e[15] * m.e[15]); + + return t; +} + +void Matrix44::operator *= (const Matrix44 & m) +{ + Matrix44 t = (*this) * m; + memcpy((void*)this->e, (void*)t.e, sizeof(float) * 16); +} + +const float * Matrix44::GetElements() const +{ + return e; +} + +void Matrix44::SetIdentity() +{ + memset(e, 0, sizeof(float) * 16); + e[0] = e[5] = e[10] = e[15] = 1; +} + +void Matrix44::SetTranslation(float x, float y) +{ + SetIdentity(); + e[12] = x; + e[13] = y; +} + +void Matrix44::SetRotation(float rad) +{ + SetIdentity(); + float c = cos(rad), s = sin(rad); + e[0] = c; e[4] = -s; + e[1] = s; e[5] = c; +} + +void Matrix44::SetScale(float sx, float sy) +{ + SetIdentity(); + e[0] = sx; + e[5] = sy; +} + +void Matrix44::SetShear(float kx, float ky) +{ + SetIdentity(); + e[1] = ky; + e[4] = kx; +} + +void Matrix44::SetTransformation(float x, float y, float angle, float sx, float sy, float ox, float oy) +{ + memset(e, 0, sizeof(float) * 16); // zero out matrix + float c = cos(angle), s = sin(angle); + // matrix multiplication carried out on paper: + // |1 x| |c -s | |sx | |1 -ox| + // | 1 y| |s c | | sy | | 1 -oy| + // | 1 | | 1 | | 1 | | 1 | + // | 1| | 1| | 1| | 1 | + // move rotate scale origin + e[10] = e[15] = 1.0f; + e[0] = c * sx; // = a + e[1] = s * sx; // = b + e[4] = -s * sy; // = c + e[5] = c * sy; // = d + e[12] = x - ox * e[0] - oy * e[4]; + e[13] = y - ox * e[1] - oy * e[5]; +} + +void Matrix44::Translate(float x, float y) +{ + Matrix44 t; + t.SetTranslation(x, y); + this->operator *=(t); +} + +void Matrix44::Rotate(float rad) +{ + Matrix44 t; + t.SetRotation(rad); + this->operator *=(t); +} + +void Matrix44::Scale(float sx, float sy) +{ + Matrix44 t; + t.SetScale(sx, sy); + this->operator *=(t); +} + +void Matrix44::Shear(float kx, float ky) +{ + Matrix44 t; + t.SetShear(kx, ky); + this->operator *=(t); +} + +void Matrix44::Transform(float x, float y, float angle, float sx, float sy, float ox, float oy) +{ + Matrix44 t; + t.SetTransformation(x, y, angle, sx, sy, ox, oy); + this->operator *=(t); +} + +void Matrix44::Ortho(float left, float right, float bottom, float top, float near, float far) +{ + Matrix44 t; + t.SetOrtho(left, right, bottom, top, near, far); + this->operator *=(t); +} + +// | x | +// | y | +// | 0 | +// | 1 | +// | e0 e4 e8 e12 | +// | e1 e5 e9 e13 | +// | e2 e6 e10 e14 | +// | e3 e7 e11 e15 | + +//void Matrix44::transform(Graphics::Vertex* dst, const Graphics::Vertex* src, int size) const +//{ +// for (int i = 0; i<size; ++i) +// { +// // Store in temp variables in case src = dst +// float x = (e[0] * src[i].xy.x()) + (e[4] * src[i].xy.y()) + (0) + (e[12]); +// float y = (e[1] * src[i].xy.x()) + (e[5] * src[i].xy.y()) + (0) + (e[13]); + +// dst[i].xy.Set(x, y); +// } +//} + +void Matrix44::Frustum(float l, float r, float t, float b, float near, float far) +{ + + +} + +void Matrix44::Perspective(float fov, float aspect, float near, float far) +{ + +} + diff --git a/source/LoG/math/matrix44.h b/source/LoG/math/matrix44.h new file mode 100644 index 0000000..3639df9 --- /dev/null +++ b/source/LoG/math/matrix44.h @@ -0,0 +1,94 @@ +#ifndef __LOG_MAT44_H__ +#define __LOG_MAT44_H__ + + +// +// 4x4矩阵,不需要转置,直接运用在Opengl中,由于opengl的glUniformMatrix按列填入矩阵,进行 +// 的是和列向量的右乘,为了不需要转置,直接使用按列定义的矩阵。保证矩阵的内存排列和输入opengl +// 的统一 +// +class Matrix44 +{ +public: + + static const Matrix44 Identity; + + Matrix44(); + + Matrix44(const Matrix44& m); + + ~Matrix44(); + + void operator = (const Matrix44& m); + + void SetOrtho(float _left, float _right, float _bottom, float _top, float _near, float _far); + + Matrix44 operator * (const Matrix44 & m) const; + + void operator *= (const Matrix44 & m); + + const float* GetElements() const; + + void SetIdentity(); + + void SetTranslation(float x, float y); + + void SetRotation(float r); + + void SetScale(float sx, float sy); + + void SetShear(float kx, float ky); + + void SetTransformation(float x, float y, float angle, float sx, float sy, float ox, float oy); + + void Translate(float x, float y); + + // + // 饶xyz轴旋转 + // + void Rotate(float r, float x, float y, float z); + + void Scale(float sx, float sy); + + void Transform(float x, float y, float angle, float sx, float sy, float ox, float oy); + + // + // Multiplies this Matrix44 with a shear transformation. + // @param kx Shear along the x-axis. + // @param ky Shear along the y-axis. + // + void Shear(float kx, float ky); + + void Ortho(float left, float right, float bottom, float top, float near, float far); + + //// + //// Transforms an array of vertices by this Matrix44. The sources and + //// destination arrays may be the same. + //// + //// @param dst Storage for the transformed vertices. + //// @param src The source vertices. + //// @param size The number of vertices. + //// + //void transform(Graphics::Vertex* dst, const Graphics::Vertex * src, int size) const; + + // + // + // + void Frustum(float l, float r, float t, float b, float near, float far); + + void Perspective(float fov, float aspect, float near, float far); + +private: + + // + // | e0 e4 e8 e12 | + // | e1 e5 e9 e13 | + // | e2 e6 e10 e14 | + // | e3 e7 e11 e15 | + // + float e[16]; + +}; + + +#endif
\ No newline at end of file diff --git a/source/LoG/modding/modding.h b/source/LoG/modding/modding.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/source/LoG/modding/modding.h diff --git a/source/LoG/network/socket.h b/source/LoG/network/socket.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/source/LoG/network/socket.h diff --git a/source/LoG/physics/collision.h b/source/LoG/physics/collision.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/source/LoG/physics/collision.h diff --git a/source/LoG/scripting/api/api_list.h b/source/LoG/scripting/api/api_list.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/source/LoG/scripting/api/api_list.h diff --git a/source/LoG/threading/thread.h b/source/LoG/threading/thread.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/source/LoG/threading/thread.h diff --git a/source/LoG/utils/exception.h b/source/LoG/utils/exception.h new file mode 100644 index 0000000..16a6eda --- /dev/null +++ b/source/LoG/utils/exception.h @@ -0,0 +1,17 @@ +#ifndef __FFH_EXCEPTION_H__ +#define __FFH_EXCEPTION_H__ + +#include <exception> + +class Exception : public std::exception +{ +public: + + Exception(); + ~Exception(); + + const char* what(); + +}; + +#endif
\ No newline at end of file |