我剛剛實施了libgdxLibgdx軌跡球相機和廣告牌
private void rotate(float pitch, float yaw, float roll) {
tempQuat.setEulerAngles(pitch, yaw, roll);
rotationQuat.mulLeft(tempQuat);
}
的軌跡球凸輪...
float aspect = camera.viewportWidth/camera.viewportHeight;
camera.projection.setToProjection(Math.abs(camera.near), Math.abs(camera.far), camera.fieldOfView, aspect);
camera.view.setToLookAt(camera.position, tempVector.set(camera.position).add(camera.direction), camera.up);
rotate(MyGestureListener.mXAngle, MyGestureListener.mYAngle, 0);
camera.view.rotate(rotationQuat);
camera.combined.set(camera.projection);
Matrix4.mul(camera.combined.val, camera.view.val);
camera.invProjectionView.set(camera.combined);
Matrix4.inv(camera.invProjectionView.val);
camera.frustum.update(camera.invProjectionView);
一切工作正常,但有一點不好:
我有作爲廣告牌總是旋轉到相機的一些貼花紙:
p.decalPoint.setPosition(p.pos.x, p.pos.y, p.pos.z);
p.decalPoint.setRotation(camera.direction, camera.up);
現在這個壞了。爲什麼?我怎樣才能解決這個問題?
我需要一個軌跡球相機喜歡這裏:
上面的代碼工作得很好,但廣告牌效果不與凸輪工作。
私人四元getRotatedQuaternion(浮動間距,浮子偏航,浮動輥){ tempQuat.setEulerAngles(間距,偏航,滾動); rotateQuat.mulLeft(tempQuat); return rotationQuat; } camera.lookAt(Axis.ORIGO); camera.rotate(getRotatedQuaternion(gestureListener.mXAngle,gestureListener.mYAngle,0)); camera.update();它不能按預期工作:( – lacas
也許然後首先解釋你的期望,雖然這段代碼看起來非常不同,所以如果你有不同的問題,那麼最好問一個新的問題。 – Xoppa
這將是一個弧球相機。如何更新方向和向量? – lacas