3d Libgdx Rotation
I think this question is not a duplicate, or if it is, I couldn't understand how to make this work. (sorry for my great drawing capabilities...) I have a ball, radius 0.5 (so, per
Solution 1:
Like @Springrbua said you could take the cross product to get the axis to rotate around. For example (untested code):
publicvoidupdate(float delta) {
velocity.add(tmpV.set(acceleration).scl(delta));
position.add(tmpV.set(velocity).scl(delta));
final float speed = velocity.len();
final float angle = speed*delta*MathUtils.radiansToDegrees;
Vector3 axis = tmpV.set(velocity).scl(-1f/speed).crs(Vector3.Y);
tmpQ.set(axis, angle);
rotation.mulLeft(tmpQ);
transform.set(position, rotation);
}
Here's the full source of a working example: https://gist.github.com/xoppa/3b841fb52f46e8cdec24
Post a Comment for "3d Libgdx Rotation"