Camera Movement causes ripple effect

When I move my camera a ripple effect goes from the top to the bottom of the screen every few seconds or so.  My camera is attached to a camera node and I move the camera node.  My camera node is a member of a BasicGameState.  I move my camera node by calling its move methods from a controller based on the mouse position.  Below are my controller and camera state.



Controller


package Controller;

import State.CameraState;

import com.jme.input.lwjgl.LWJGLMouseInput;
import com.jme.scene.Controller;
import com.jme.system.DisplaySystem;

public class MainCameraController extends Controller
{
   private CameraState   camState;
   private LWJGLMouseInput mouseInput;

   public MainCameraController( CameraState cameraState)
   {
      camState = cameraState;
      mouseInput = (LWJGLMouseInput)LWJGLMouseInput.get();
   }

   public void update( float time )
   {
      if (mouseInput.getXAbsolute() >= DisplaySystem.getDisplaySystem().getWidth() - 20)
      {
         camState.moveRight( time );
      }
      
      if (mouseInput.getXAbsolute() <= 20)
      {
         camState.moveLeft( time );
      }
      
      if (mouseInput.getYAbsolute() >= DisplaySystem.getDisplaySystem().getHeight() - 20)
      {
         camState.moveDown( time );
      }
      
      if (mouseInput.getYAbsolute() <= 20)
      {
         camState.moveUp( time );
      }
   }
}



Camera Game State

package State;

import com.jme.math.Vector3f;
import com.jme.renderer.Camera;
import com.jme.scene.CameraNode;
import com.jme.system.DisplaySystem;
import com.jmex.game.state.BasicGameState;

public class CameraState extends BasicGameState
{
   private CameraNode   camNode;
   private final int MOVESPEED = 20;

   /************************ Constructors ***************************/
   
   public CameraState()
   {
      super( "camera" );
      initCamera();
      setLoc( 50, 100, 50 );
      lookAt( new Vector3f(50,0,50), Vector3f.UNIT_Y );
      
      rootNode.updateRenderState();
   }
   
   /************************ Getters ***************************/
   
   public CameraNode getCamNode()
   {
      return camNode;
   }
   
   public Camera getCamera()
   {
      return camNode.getCamera();
   }
   
   public Vector3f getLoc()
   {
      return camNode.getLocalTranslation();
   }
   
   /************************ Setters ***************************/
   
   public void setLoc( float x, float y, float z )
   {
      camNode.setLocalTranslation( new Vector3f(x, y, z) );
      camNode.updateWorldData(0);
   }
   
   public void setLoc( Vector3f loc )
   {
      camNode.setLocalTranslation( loc );
      camNode.updateWorldData(0);
   }

   /************************ Mutators ***************************/
   
   public void moveLeft(float time)
   {
      float amount = time*MOVESPEED;
      setLoc( getLoc().add( new Vector3f(1,0,0).mult( amount ) ) );
   }
   
   public void moveRight(float time)
   {
      float amount = time*MOVESPEED;
      setLoc( getLoc().add( new Vector3f(1,0,0).mult( -amount ) ) );
   }
   
   public void moveUp(float time)
   {
      float amount = time*MOVESPEED;
      setLoc( getLoc().add( new Vector3f(0,0,1).mult( -amount ) ) );
   }
   
   public void moveDown(float time)
   {
      float amount = time*MOVESPEED;
      setLoc( getLoc().add( new Vector3f(0,0,1).mult( amount ) ) );
   }

   public void lookAt( Vector3f pos, Vector3f worldUpVector )
   {
      camNode.lookAt( pos, worldUpVector );
      camNode.updateWorldData(0);
   }
   
   /************************ helpers ***************************/

   private void initCamera()
   {
      Camera camera = DisplaySystem.getDisplaySystem().getRenderer().getCamera();
      camera.setFrustumFar( 2000f );
      camNode = new CameraNode( "cam", camera );

      getRootNode().attachChild( camNode );
   }
}

That's called vertical desynchronization.  It's not really a bug, it happens in all 3d engines…



…unless you enable vsync, which drops your frame rate a lot, but fixes the choppy screen.  You can set whether or not to enable vsync at the options window when you start each jme program.

I do enable vertical sync but I still get the effect.  My monitor resolution is 1400,900.  I have tried fullscreen and windowed mode and the effect shows up in both.  Here are my game settings:


public App()
   {
      game = new StandardGame( "A Simple Test" );
      game.getSettings().setWidth( 800 );
      game.getSettings().setHeight( 600 );
      game.getSettings().setVerticalSync( true );
      game.start();
      
      battleState = new BattleState("BattleState");
      GameStateManager.getInstance().attachChild( battleState );
      battleState.setActive( true );

      battleState.getRootNode().updateRenderState();
   }

I guess i know what your exact problem is, its in  setting the camera frustum prespective ; the main method with its parameters is :



setFrustumPerspective(float fovY, float aspect, float near, float far) // dont insert this in updating loop, just in the initsystem.





note: fovy usually is 45.0f , for aspect float,you just float cast the display.width ()/display.length(),and float near usually is 0.02f and the float far is variable, just try to play with last 2 parameters.



-> all of that should remove ripple and wavy effect when you walk, hope that helps.(you can check many scripts that contains that , mostly all).

The effect is still there after changing my camera frustrum persepctive.  My cameraNode init method is now this:


private void initCamera()
{
   Camera camera = DisplaySystem.getDisplaySystem().getRenderer().getCamera();
   camera.setFrustumPerspective( 45.0f, DisplaySystem.getDisplaySystem().getWidth()/
         (float)DisplaySystem.getDisplaySystem().getHeight(), 0.02f, 500f );
   camNode = new CameraNode( "cam", camera );

   getRootNode().attachChild( camNode );
}

Have you tried updating your graphics drivers? What graphics card/chip do you have?

My graphics card is a 8600m gt.  I have upgrade the drivers. and the effect is still there.