這本書相信大家都有吧,沒有的話網上也很好下到電子書和代碼
第四章上的例子:112頁
代碼為第四章:ModelViewProjection
部分代碼如下:
M3DMatrix44f mTranslate, mRotate, mModelview, mModelViewProjection;
// Create a translation matrix to move the torus back and into sight
m3dTranslationMatrix44(mTranslate, 0.0f, 0.0f, -2.5f);
// Create a rotation matrix based on the current value of yRot
//m3dDegToRad(yRot)為旋轉弧度
m3dRotationMatrix44(mRotate, m3dDegToRad(yRot), 0.0f, 1.0f, 0.0f);
// Add the rotation to the translation, store the result in mModelView
//這里明明是先平移后旋轉
m3dMatrixMultiply44(, mTranslate, mRotate);
// Add the modelview matrix to the projection matrix,
// the final matrix is the ModelViewProjection matrix.
//可這里為啥是先投影,后模型視圖變化,不是應該先模型視圖變化,后投影嗎?????????????????
m3dMatrixMultiply44(mModelViewProjection,viewFrustum.GetProjectionMatrix(),mModelview);
運行了一下程式,都正常,圖形先移動,后旋轉,之后正確的投影到螢屏上, m3dMatrixMultiply44函式僅僅是簡單地后一矩陣乘以前一矩陣,沒有任何判斷。
困擾好幾天了,各位高手幫忙看一下
uj5u.com熱心網友回復:
http://www.cnblogs.com/graphics/archive/2012/08/02/2616017.html看看這個文章,主要意思是opengl 的矩陣使用列向量,當向量vec 與矩陣 mat 相乘時,
directx: result = vec * mat;
opengl: result = mat * vec;
連乘時,靠近頂點的變換先實作
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/74254.html
標籤:其它游戲引擎
