LWJGL - Matrix4f无法正确旋转

时间:2013-08-20 19:01:45

标签: java opengl matrix rotation lwjgl

我使用opengl中的matrix4f类来围绕中心旋转我的对象..

我就是这样做的:

pos.m30 = -(getWidth()/2f); 
pos.m31 = +(getHeight()/2f);
pos.m20 = -(getWidth()/2f); 
pos.m21 = -(getHeight()/2f);
pos.m00 = +(getWidth()/2f); 
pos.m01 = -(getHeight()/2f);
pos.m10 = +(getWidth()/2f); 
pos.m11 = +(getHeight()/2f);

rotate(pos); //TODO                                           

//Position                                                      
pos.m30 += phyxBody.getPosition().x;                            
pos.m31 += phyxBody.getPosition().y;                            
pos.m20 += phyxBody.getPosition().x;                            
pos.m21 += phyxBody.getPosition().y;                            
pos.m00 += phyxBody.getPosition().x;                            
pos.m01 += phyxBody.getPosition().y;                            
pos.m10 += phyxBody.getPosition().x;                            
pos.m11 += phyxBody.getPosition().y;    

旋转方法:角度为弧度..

    pos.rotate(phyxBody.getAngle(),new Vector3f(0f,1f,0));

然而,这并没有正确地旋转身体..它围绕左上角而不是围绕中心旋转..

0 个答案:

没有答案