I just implemented an arcball cam in libgdx
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);
Everything works fine, but one thing is not good:
I have some decal that always rotated to the camera as a billboard:
p.decalPoint.setPosition(p.pos.x, p.pos.y, p.pos.z);
p.decalPoint.setRotation(camera.direction, camera.up);
Now this is broken. Why? How can I fix this?
I need an arcball camera like here:
The above code works well, but billboarding not working with the cam.
I ended up using two rotation matrix and a camfocusvector as an arcball
Quaternions are not suitable for this