New Camera - Black Screen

Hello! :slight_smile:



I have a little problem with the JME Camera.



That's what I have:


  • Standardgame with some GameStates
  • A ChaseCam on the Player



    The problem is, if I do:

    Camera cam = DisplaySystem.getDisplaySystem().getRenderer().createCamera(800,600);



    the screen turns black. The camera is not attached to the display system, it's just created! Has it anything to do  with the chase cam? Any suggestions?



    Greetings,

    mars

Umm, I think you need to set some things first, perpective/ortho; and then actually set the camera with


DisplaySystem.getDisplaySystem().getRenderer().setCamera( cam );



Check out how it's done in BaseGame (I believe its there)

I've already tried that. : /



      cam = DisplaySystem.getDisplaySystem().getRenderer().createCamera(ClientSettings.SCREEN_WIDTH, ClientSettings.SCREEN_HEIGHT);
      cam .setLocation(new Vector3f(1,10,1));
      cam .setFrustumPerspective(35.0f, (float)DisplaySystem.getDisplaySystem().getWidth() / (float)DisplaySystem.getDisplaySystem().getHeight(), 1.0f, 100.0f);
      cam .setParallelProjection(false);
      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, 0.0f, -1.0f);
      cam .setFrame(loc, left, up, dir);
      cam .update();
      DisplaySystem.getDisplaySystem().getRenderer().setCamera( cam );



I also tried to modify the parameters randomly, so I should at least see the skybox.

You need to set the frustum and frame before setting the location and lookAt



        Vector3f loc = new Vector3f( 0.0f, 0.0f, 0.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 );
        cam.update();
       
       
        Vector3f position = Utils.convertVector( jme_Driver.getDriver().getLogic().getTable( Globals.playerTable ).getPosition() );
        position.y = 25f;
        position.z -= ( Globals.tableLength/3f );
        cam.setLocation( position );
       
        // cam.setDirection( new Vector3f( 0, -0.1f, 0 ) );
        cam.lookAt( new Vector3f( 0, -1000, 5000 ), up );
       
        cam.update();



This is how I setup my cam

Funny - it works now. :slight_smile: thanks a lot

Just did setFrame first (with an update) and then the Location.

no problemo :slight_smile: