Mouse Mapper

Started by san14, May 22, 2007, 07:15:22 AM

Previous topic - Next topic

EgonOlsen

Init the MouseMapper, call mouse.hide() on it. Do both things ONE time, not multiple times in the loop.
Call move() in the loop. Should work.

san14

Hi EgonOlsen
     
        Is it what I need to do As
       private void initMouseMapper(){
                            mouse.hide();
     
              }
              private void gameLoop() throws Exception {
                            move();
             }
       
       



         Is some thing else to be done in initMouseMapper(). As i tried with this and could not do.


With Regards
San14


San14

EgonOlsen

Looks fine so far. Maybe you application does something else with the camera that makes the call to move() useless. Look at move() and adept what it does to your case. I don't know what you are doing exactly, so this example is for manipulating the camera as if no other code would do it. If it does, you have to adjust that behaviour.

san14

#18
HI EgonOlsen

     The mouse code is working fine. I have tried to put forward movement as
                 
            float speedForMouse=3;

             if (mouse.buttonDown(0)) {
                      SimpleVector s=camera.getDirection();
                theWorld.checkCameraCollisionEllipsoid(s, UP_MOVEMENT, 2, 2);              
              }

             
            And is Working fine
           How do I do same for Right Click of Mouse


With Regards
san14
San14

EgonOlsen

mouse.buttonDown(1) ?

san14

Thanks EgonOlsen
     
        It worked.  :D

With Regards
San14
San14

san14

HI
    I am able to move in environment using mouse. I want to move in front and back , even if i am seeing at roof..etc.

   Means Player should not leave the floor while seeing roof and walking ahead.
   This is the code for normal movement. Can some one help me out with it.


if (mouse.buttonDown(0)) {              
         SimpleVector s=camera.getDirection(); 
         theWorld.checkCameraCollisionEllipsoid(s, UP_MOVEMENT, 2, 2);
     }

if (mouse.buttonDown(1)) {              
           SimpleVector s=camera.getDirection();
         theWorld.checkCameraCollisionEllipsoid(s, UP_MOVEMENT, -2, 2);
    }



With Regards
San14
San14

EgonOlsen

The fps-example as well as the advanced example are doing this. The basic idea is, to keep track of the rotations in the X-Z-plane (i.e. around the y-axis) in the seperate matrix instead of only turning the camera. You have to modify the rotations for x-mouse-movement (dx<0; dx>0) in a way that you add a <your-tracking-matrix>.rotateY(angle);. Then you can use this matrix instead of the camera's so that SimpleVector s=camera.getDirection(); becomes something like SimpleVector s=<your-tracking-matrix>.getZAxis();
As said: Both examples contain similar code. In fact, this thread contains similar code (taken from the advanced example) in the earlier posts.

san14

#23
Hi EgonOlsen

      I looked for movements in Advance example but could not make out. But I am able to achive the movements using this code. But the problem is that When I take turn the user. The user forgets the direction and moves in other direction.


  if (mouse.buttonDown(0)) { 
             SimpleVector s=camera.getDirection();
           SimpleVector ss=new Matrix().getZAxis();
                   theWorld.checkCameraCollisionEllipsoid(ss, UP_MOVEMENT, 2, 2);

       
     }
    if (mouse.buttonDown(1)) {              
           SimpleVector s=camera.getDirection();
           SimpleVector ss=new Matrix().getZAxis();
                   theWorld.checkCameraCollisionEllipsoid(ss, UP_MOVEMENT, -2, 2);
     }



Can suggest how to go about this


With Regards
San14
San14

EgonOlsen

That code makes no sense. It's a very complicated of saying: Just move along the z-axis. Instead of instantiating the Matrix for ss everytime, do it once and apply the rotations of the user to it, i.e. you are now doing a cam.rotateAxis(com.getYAxis(), ang) or something similar. You simply add (not replace) a <your_matrix>.rotateY(ang); and use that <your_matrix> to derive your ss from it.

san14

Hi EgonOlsen
   
       Please can you tell me, which portion or file implements this kind of mouse movement in Advance Example.


With Regards
San14
San14

EgonOlsen

Sure. That's feud.testgame.model.LocalPlayerObject