java - LibGDX - perspective camera smooth translation & direction -


i trying implement smooth 3d camera in game. so, have few reserved positions , directions , want change view of camera applying them camera. doing below:

//reserved positions , directions  //view #1 vector3 pos1 = new vector3(0, 5, -10); vector3 dir1 = new vector3(0, 0, 10);  //view #2 vector3 pos2 = new vector3(5, 2, 5); vector3 dir2 = new vector3(-2, 2, 7);  //applying view #2 camera.position.set(pos2); camera.lookat(dir2); 

it works, need smoothly. i've seen similar question 2d camera, doesn't appropriate me, because orthographic camera doesn't need direction , z-axis.

update:

i tried use method described 2d camera. so, positioning works needed, can't same direction. behaviour of direction wrong. rotates camera on z-axis. seems me have update up vector too.

float lerp = 0.01f; vector3 position = camera.position; position.x += (pos2.x - position.x) * lerp; position.y += (pos2.y - position.y) * lerp; position.z += (pos2.z - position.z) * lerp;  vector3 direction = camera.direction; direction.x += (dir2.x - direction.x) * lerp; direction.y += (dir2.y - direction.y) * lerp; direction.z += (dir2.z - direction.z) * lerp;  //code libgdx's camera //lookat function /* tmpvec.set(x, y, z).sub(position).nor();     if (!tmpvec.iszero()) {         float dot = tmpvec.dot(up); // , direction must orthonormal vectors         if (math.abs(dot - 1) < 0.000000001f) {             // collinear             up.set(direction).scl(-1);         } else if (math.abs(dot + 1) < 0.000000001f) {             // collinear opposite             up.set(direction);         }         direction.set(tmpvec);         normalizeup();     } */ 

what correct way set direction?

i use univesal tween engine, library interpolating pretty anything.

you'd have write vector3accessor class (which simple), you'd have sorts of controls , options smooth movement. has rich api , used lot sort of thing.

i'd recommend put little time investigating option -it'll give better result, , once know you'll find sorts of other cool uses in app.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -