/************************************************************************* function :SetMatrix3 description :ÓÒϽÇΪÆðʼµãµÄ˳ʱÕëÂÝÐýÅÅÁÐ(µÝ¹éÐÍ) **************************************************************************/ void SetMatrix3(DWORD **rotaMatrix, DWORD **oriMatrix, int x, int y, DWORD index, int m, int n, int M, int N) { int i, j; if (n<=0 || m<=0) return; if ((n==1) && (m==1)) { rotaMatrix[x][y] = oriMatrix[index/N][index%N]; return; } else if((m==1)&&(n!=1)) { for (i = x; i > (N-x-2); i--) // µ×²¿ { rotaMatrix[y][i] = oriMatrix[index/N][index%N]; index++; } return ; } else if((m!=1)&&(n==1)) { for (j = y; j > (M-y-2); j--) // ×ó±ß { rotaMatrix[j][x] = oriMatrix[index/N][index%N]; index++; } return ; } for (i = x; i > (N-x-1); i--) // µ×²¿ { rotaMatrix[y][i] = oriMatrix[index/N][index%N]; index++; } for (j = y; j > (M-y-1); j--) // ×ó±ß { rotaMatrix[j][x-n+1] = oriMatrix[index/N][index%N]; index++; } for (i = x-n+1; i < x ; i++) // Éϲ¿ { rotaMatrix[y-m+1][i] = oriMatrix[index/N][index%N]; index++; } for (j = y-m+1; j < y; j++) // ÓÒ±ß { rotaMatrix[j][x] = oriMatrix[index/N][index%N]; index++; } // printf("\n"); // disMatrix(matrix, M, N); SetMatrix3(rotaMatrix, oriMatrix, x-1, y-1, index, m-2, n-2, M, N); /* µÝ¹é */ }
/************************************************************************* function :RotaMatrix param :matrix, M, N, opr return :none description :½«matrix¾ØÕóµÄÄÚÈÝ°´Ö¸¶¨µÄ·½Ê½ÂÝÐýÅÅÁÐ **************************************************************************/ void RotaMatrix(DWORD **matrix, int M, int N, int opr) { DWORD **rotaMatrix; rotaMatrix = (DWORD **)malloc(M * sizeof(DWORD *)); //Ϊ¾ØÕó·ÖÅä¿Õ¼ä for (int i = 0; i<M; i++) rotaMatrix[i] = (DWORD *)malloc(N * sizeof(DWORD)); switch (opr) { case 1: SetMatrix1(rotaMatrix, matrix, 0, 0, 0, M, N, M, N); break; case 2: SetMatrix2(rotaMatrix, matrix, N-1, 0, 0, M, N, M, N); break; case 3: SetMatrix3(rotaMatrix, matrix, N-1, M-1, 0, M, N, M, N); break; case 4: SetMatrix4(rotaMatrix, matrix, 0, M-1, 0, M, N, M, N); break; default: break; } //equ equMatrix(matrix, rotaMatrix, M, N); //release buffer for (int i = 0; i<M; i++) free(rotaMatrix[i]); free(rotaMatrix); }
void ShaderConstant::SetMatrix3( const Matrix3& matrix ) { MEDUSA_ASSERT(mDataType==GraphicsUniformDataType::FloatMat3,"ErrorDataType"); SetMatrix3(1,matrix.Items()); }
void ShaderUniform::SetMatrix3(const Matrix3& matrix) { MEDUSA_ASSERT(mDataType == GraphicsUniformDataType::FloatMat3, "ErrorDataType"); SetMatrix3(MemoryFloatData::FromStatic(matrix.Items(),9*sizeof(float))); }