【发布时间】:2015-02-01 22:10:16
【问题描述】:
当我使用我创建的函数在opengl es中旋转模型矩阵时,模型矩阵在旋转时使模型变小,我不明白为什么。
这里是旋转函数的代码(仅绕z轴旋转)。
public void rotateZ(float angle){
float cos = (float) (Math.cos(Math.toRadians(angle)));
float sin = (float) (Math.sin(Math.toRadians(angle)));
Matrix4x4 ret = IdentityM();
ret.setValue(cos, 0, 0);
ret.setValue(-sin, 0, 1);
ret.setValue(sin, 1, 0);
ret.setValue(cos, 1, 1);
Multiply(ret);
}
这里是乘法函数的代码:
public void Multiply(Matrix4x4 m){
float[][] m1 = m.toFloatMat();
for(int i = 0; i < 4; i++){
for(int j = 0; j < 4; j++){
float value = 0f;
for(int t = 0; t < 4; t++){
value += matrix[i][t] * m1[t][j];
}
matrix[i][j] = value;
}
}
}
还有setValue函数:
public void setValue(float v, int i, int j){
matrix[i][j] = v;
}
对象只是越来越小,我不明白为什么>
【问题讨论】:
标签: java math opengl-es rotation