概念
向量
M3DVector3f
矩阵
M3DMatrix44f
opengl 默认:列矩阵
{
Ax, Bx, Cx, Dx
Ay, By, Cy, Dy
Az, Bz, Cz, Dz
0, 0, 0, 1
}
矩阵相乘规则
矩阵A * 矩阵B
当 A的列 等于 B的行
生成 A的行数、B的列数的矩阵
叉乘
m3dCrossProduct3
点乘
m3dDotProduct3
矩阵相关的变换
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| inline void m3dTranslationMatrix44(M3DMatrix44f m, float x, float y, float z)
void m3dRotationMatrix44(M3DMatrix44f m, float angle, float x, float y, float z)
inline void m3dScaleMatrix44(M3DMatrix44f m, float xScale, float yScale, float zScale)
void m3dMatrixMultiply44(M3DMatrix44f product, const M3DMatrix44f a, const M3DMatrix44f b)
GLGeometryTransform transformPipeline GLMatrixStack modelViewMatrix; GLMatrixStack projectionMatrix; GLFrame cameraFrame; GLFrame objectFrame; GLFrustum viewFrustum;
transformPipeline.SetMatrixStacks(modelViewMatrix, projectionMatrix);
viewFrustum.SetPerspective(35.0f, float(w) / float(h), 1.0f, 500.0f);
projectionMatrix.LoadMatrix(viewFrustum.GetProjectionMatrix())
modelViewMatrix.LoadIdentity();
objectFrame.RotateWorld(m3dDegToRad(-5.0f), 1.0f, 0.0f, 0.0f); objectFrame.MoveForward(15.0f); ...
modelViewMatrix.PushMatrix(objectFrame)
modelViewMatrix.PopMatrix()
transformPipeline.GetModelViewProjectionMatrix()
|