Easiest way to flip y-axis?

I'm looking for an easy way to flip the y-axis, so increasing values go down and decreasing values go up.  Is there anywhere I can flip an argument to a negative or something and have everything magically work?

where do you need that "flip"? i suppose in some cases you could multiply the y component by -1 or  in other cases you could rotate your spatial by 180 degrees on x or z

I want it everywhere.  See I'm porting my engine from Java's AWT to use JMonkey.  The whole engine is built assuming bigger y values mean down.  I think I want to do something like change the world coordinate system in JMonkey.

I tried flipping the "up" direction on the camera but then increasing x values go left and decreasing x values go right :slight_smile:

You need to set your camera's matrix to:



left: 1,0,0

up: 0,-1,0

dir: 0, 0, -1



You'll probably have to reset the camera to the input system (but I can't remember off hand).

Doesn't seem to be working.  Up and down are working correctly, but left goes right and right goes left.



I'm wondering if this could be a bug, because when I do this:



Vector3f left = new Vector3f( 1.0f, 0.0f, 0.0f );



I get the same exact results as when I do this:



Vector3f left = new Vector3f( -1.0f, 0.0f, 0.0f );



I know very little about 3d engines though, so I could be wrong.



Here's my modified code from BaseSimpleGame:


        /** Set up how our camera sees. */
        cameraPerspective();
        Vector3f loc = new Vector3f( 0.0f, 0.0f, 25.0f );
        Vector3f left = new Vector3f( 1.0f, 0.0f, 0.0f );
        Vector3f up = new Vector3f( 0.0f, -1.0f, 0.0f );
        Vector3f dir = new Vector3f( 0.0f, 0f, -1.0f );
        /** Move our camera to a correct place and orientation. */
        cam.setFrame( loc, left, up, dir );
        /** Signal that we've changed our camera's location/frustum. */
        cam.update();
        /** Assign the camera to this renderer. */
        display.getRenderer().setCamera( cam );


       
Here's how I move the camera:

   public void moveCamKeys() {      
      Camera cam = Game.getRenderer().getCamera();
      Vector3f pos = cam.getLocation();
      KeyInput keys = KeyInput.get();
            
      if( keys.isKeyDown( KeyInput.KEY_LEFT ) )
         pos.x -= speed;
      if( keys.isKeyDown( KeyInput.KEY_RIGHT) )
         pos.x += speed;
      if( keys.isKeyDown( KeyInput.KEY_UP ) )
         pos.y -= speed;
      if( Keyboard.isDown( KeyInput.KEY_DOWN ) )
         pos.y += speed;
      

      if( keys.isKeyDown( KeyInput.KEY_W ) )
         pos.z += speed;
      if( keys.isKeyDown( KeyInput.KEY_S ) )
         pos.z -= speed;
         
                cam.update();
   }



Pretty simple, really.  I don't see what's going wrong.

Oh yeah, and I also commented this part out:


        /** Create a basic input controller. */
        /*FirstPersonHandler firstPersonHandler = new FirstPersonHandler( cam, 50,
                1 );
        input = firstPersonHandler;/**/

Hi jebso,

have you solved the "flip" problem of orizontal axes?

I've the same problem, but in vertical axes…