summaryrefslogtreecommitdiff
path: root/source/modules/asura-core/graphics/matrix_stack.h
diff options
context:
space:
mode:
Diffstat (limited to 'source/modules/asura-core/graphics/matrix_stack.h')
-rw-r--r--source/modules/asura-core/graphics/matrix_stack.h82
1 files changed, 82 insertions, 0 deletions
diff --git a/source/modules/asura-core/graphics/matrix_stack.h b/source/modules/asura-core/graphics/matrix_stack.h
new file mode 100644
index 0000000..1923b30
--- /dev/null
+++ b/source/modules/asura-core/graphics/matrix_stack.h
@@ -0,0 +1,82 @@
+#ifndef __ASURA_MATRIX_STACK_H__
+#define __ASURA_MATRIX_STACK_H__
+
+#include <asura-utils/type.h>
+#include <asura-utils/math/matrix44.h>
+
+namespace AsuraEngine
+{
+ namespace Graphics
+ {
+
+ ///
+ /// ջľȡ
+ ///
+#define ASURA_MAX_MATRIX_STACK_DEPTH 32 // 2KB
+
+ ///
+ /// ջ״ָ̬֮ǰ״̬ջеһstack[i]ֵstack[0]*..*stack[i-1]
+ /// ֵһϵtransform
+ ///
+ /// TODO: template<uint _capacity> MatrixStack
+ ///
+ class MatrixStack
+ {
+ public:
+
+ MatrixStack();
+ ~MatrixStack();
+
+ ///
+ /// ջԪصIJֻͨºʵ
+ ///
+ void LoadIdentity();
+ bool Push();
+ bool Pop();
+
+ AEMath::Matrix44& GetTop();
+ void GetTop(asura_out AEMath::Matrix44& mat44);
+
+ void LoadMatrix(const AEMath::Matrix44& mat44);
+ void MultMatrix(const AEMath::Matrix44& mat44);
+
+ ///
+ /// 任
+ ///
+ void Rotate(float angle, float x, float y, float z);
+ void Translate(float x, float y, float z);
+ void Scale(float x, float y, float z);
+
+ ///
+ /// ͶӰ任
+ ///
+ void Ortho(float left, float right, float bottom, float top, float near, float far);
+ //void Perspective(float fov, float aspect, float near, float far);
+ //void Frustum(float left, float right, float top, float bottom, float near, float far);
+ //void LookAt(float x, float y, float z, float cx, float cy, float cz, float ux, float uy, float uz);
+
+ ///
+ /// ջΧ0~ASURA_MAX_MATRIX_STACK_DEPTH-1
+ ///
+ uint GetTopIndex();
+
+ ///
+ /// ջASURA_MAX_MATRIX_STACK_DEPTH
+ ///
+ uint GetCapacity();
+
+ private:
+
+ AEMath::Matrix44 mStack[ASURA_MAX_MATRIX_STACK_DEPTH];
+
+ ///
+ /// ջ0~ASURA_MAX_MATRIX_STACK_DEPTH-1
+ ///
+ uint8 top;
+
+ };
+
+ }
+}
+
+#endif \ No newline at end of file