Up Movements

Started by san14, March 17, 2007, 08:43:00 AM

Previous topic - Next topic

san14

Hi
    I am trying to move UP and Down In JPCTDemo.java type example. I am using Page UP and Page down key. But as soon as I press the page UP key it moves out of environment in infinity. I have writen code as


private final static float COLLISION_SPHERE_RADIUS = 6f;
private final static float PLAYER_HEIGHT = 25f;
private SimpleVector playerTop = new SimpleVector();
private final static SimpleVector UP_MOVEMENT =new SimpleVector(COLLISION_SPHERE_RADIUS,PLAYER_HEIGHT/1f,COLLISION_SPHERE_RADIUS);


playerTop = theWorld.getCamera().getZAxis();
For Page UP
if (up) {
        changed = true;
        camera.moveCamera(new SimpleVector(1, 0, 0), UP_MOVEMENT.z);
        SimpleVector temp = new SimpleVector(playerTop);
        temp.scalarMul( -1f);
        theWorld.checkCameraCollisionEllipsoid(temp, UP_MOVEMENT, 1, 8  );
       
       camera.rotateX(ts);
     
    }


Am i doing the right thing ? can some one suggest me
The Movement should stop as soon as it tuches the sealing of the room. and should move right up and down.

With Regards
San
San14

EgonOlsen

Looks overcomplicated...try something like:


if (up) {
        theWorld.checkCameraCollisionEllipsoid(new SimpleVector(0,-1,0), UP_MOVEMENT, 1, 8);
}

san14

HI

   Thanks it worked But It gives jurk up words And comes back to same position

Quote from: EgonOlsen on March 17, 2007, 12:38:26 PM
Looks overcomplicated...try something like:


if (up) {
        theWorld.checkCameraCollisionEllipsoid(new SimpleVector(0,-1,0), UP_MOVEMENT, 1, 8);
}


I want to go up words till it tuch the roof..How can i controll this movements.?

With Regards
San
San14

EgonOlsen

I'm not sure what exactly you are talking about... ??? Maybe you are still applying some gravity to the camera?

san14

Hi EgonOlsen
     I am looking for a linear UP movement. I am able to move in Up in linear direction, But as soon as I release Page UP Key the camera take the initial possion.


if (up) {
       theWorld.checkCameraCollisionEllipsoid(new SimpleVector(0,1,0), UP_MOVEMENT, -1,8 );
           
        }


How can i get camera position to the place I have moved up through Page UP key.  I tried with camera.getPosition(); But could not make it.


With Regards
San
San14

EgonOlsen

How can i know? If the camera moves down after releasing the key, it's all in your code somewhere. That's why i mentioned gravity. If it's based on the fps example or the one that you gave me once, it does apply gravity (i.e. move down). Just remove that gravity related code and you should be fine.

san14

Thanks  EgonOlsen

   
      It worked. I am able to move UP and Down in linear direction...Thanks A Lot.

   
With Regards
San 
San14