【发布时间】:2016-02-06 19:42:46
【问题描述】:
我在计算 lookAt 方法方面需要帮助 这是我的方法
public void lookAt(Vector3f position, Vector3f direction, Vector3f up) {
Vector3f f = new Vector3f();
Vector3f u = new Vector3f();
Vector3f s = new Vector3f();
Vector3f.sub(direction, position, f);
f.normalise(f);
up.normalise(u);
Vector3f.cross(f, u, s);
s.normalise(s);
Vector3f.cross(s, f, u);
this.setIdentity();
this.m00 = s.x;
this.m10 = s.y;
this.m20 = s.z;
this.m01 = u.x;
this.m11 = u.y;
this.m21 = u.z;
this.m02 = -f.x;
this.m12 = -f.y;
this.m22 = -f.z;
this.m30 = -Vector3f.dot(s, position);
this.m31 = -Vector3f.dot(u, position);
this.m32 = Vector3f.dot(f, position);
}
但是当我像这样camera.lookAt(position, new Vector3f(1, 0 ,0), new Vector3f(0, -1, 0)); 进行测试时,我的相机正在向下看,如果我这样做camera.lookAt(position, new Vector3f(10000, 0 ,0), new Vector3f(0, -1, 0)); 就结束了,相机正在向前看。你能帮忙吗?
附:对不起我的英语
【问题讨论】: