我刚刚实施了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