camera basics

Started by raft, February 25, 2005, 04:27:02 PM

Previous topic - Next topic

raft

hi,

i am moving camera in a simple world (an xz plane at origin) with

SimpleVector normalizedDirection = direction.normalize();
world.checkCameraCollisionEllipsoid(normalizedDirection, COLLISION_ELLIPSOID, moveSpeed, RECURSE_DEPTH);

when i move camera down (+y) i expected it go down to COLLISION_ELLIPSOID.y but this is not the case. independent of ellipsoid.y it moves to ellipsoid.z + a small amount depending on move speed.

couldnt get why ?

r a f t
RECURSE_DEPTH : 5
moveSpeed : 2 - 10

EgonOlsen

What is "direction"? A SimpleVector like (0,1,0)? The behaviour that it moves according to moveSpeed is correct. The ellipsoid just defines the bounds of the object/camera, not the translation that it makes when moving. That's what moveSpeed is for.
Regarding your directional problem, i assume that you are applying a rotation to the level, so that object space and world space don't match anymore (for example: You do a rotateZ(a) on an object and the same on the camera (explicit of implicit (lookAt() or similar may cause this). This looks exactly the same as if you hadn't rotated anything at all, but when moving in world space (which the camera does), the outcome will be different).  If this is the case, you either have to apply this rotation to your direction vector too, or rotate the level object permanently by using the rotateMesh()-approach.

Edit: As a rule of thumb: Make sure that object space and world space match (except for translations..they don't matter in this case) for your world/level/main object. That makes life a lot easier.

raft

still unclear :(

in our case direction is (0, -1, 0)  (upwards) and move speed is negative resulting in moving downwards.

this was the code piece creating and rotating the plane to make it an xz plane (to which you can approach up to ellipsoid.z)
       
map = Primitives.getPlane(6, 100);
map.rotateX((float)(Math.PI / 2f));


as you suggested i added a rotate mesh:
       
map = Primitives.getPlane(6, 100);
map.rotateX((float)(Math.PI / 2f));
map.rotateMesh();


very strange, it resulted in a xy plane facing -z (can be seen best when camera direction is 0, 0, -1) and can be approached upto to ellipsoid.z (collision radius is correct in this case)  it behaved like i made a rotateY(pi) :?: :?:

what s up ?
r a f t
damn ! i was almost good at linear algebra

raft

here it is. one must reset rotation matrix after rotating mesh, without it the result is as rotating it twice  8)

       
map = Primitives.getPlane(6, 100);
map.rotateX((float)(Math.PI / 2f));
map.rotateMesh();
map.setRotationMatrix(new Matrix());


all is well now, both appereance and collision radius. men, it is really a great library !

r a f tdamn it ! i almost gone mad

EgonOlsen

Quote from: "raft"here it is. one must reset rotation matrix after rotating mesh, without it the result is as rotating it twice  8)
Yes, i should have mentioned this... :wink: