我使用 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));
然而,这并没有正确旋转身体..它围绕左上角而不是围绕中心旋转..