Author Topic: Up Movements  (Read 3056 times)

Offline san14

  • int
  • **
  • Posts: 60
    • View Profile
Up Movements
« on: March 17, 2007, 08:43:00 am »
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
« Last Edit: March 17, 2007, 08:47:08 am by san14 »
San14

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: Up Movements
« Reply #1 on: March 17, 2007, 12:38:26 pm »
Looks overcomplicated...try something like:

Code: [Select]
if (up) {
        theWorld.checkCameraCollisionEllipsoid(new SimpleVector(0,-1,0), UP_MOVEMENT, 1, 8);
}

Offline san14

  • int
  • **
  • Posts: 60
    • View Profile
Re: Up Movements
« Reply #2 on: March 17, 2007, 01:26:55 pm »
HI

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

Looks overcomplicated...try something like:

Code: [Select]
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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: Up Movements
« Reply #3 on: March 17, 2007, 02:27:40 pm »
I'm not sure what exactly you are talking about... ??? Maybe you are still applying some gravity to the camera?

Offline san14

  • int
  • **
  • Posts: 60
    • View Profile
Re: Up Movements
« Reply #4 on: March 19, 2007, 01:36:29 pm »
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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: Up Movements
« Reply #5 on: March 19, 2007, 05:32:16 pm »
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.

Offline san14

  • int
  • **
  • Posts: 60
    • View Profile
Re: Up Movements
« Reply #6 on: March 20, 2007, 08:29:41 am »
Thanks  EgonOlsen

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

   
With Regards
San 
San14