Camera frustrum issues

my camera frustrum seems to be too small, stuff gets culled while it is still on screen, but me being the noob that i am, I can't seem to fix the settings so that this stops happening



      cam = display.getRenderer().createCamera(display.getWidth(),display.getHeight());
      cam.setFrustumPerspective(45.0f, width/height, 1, 10000);
      cam.setParallelProjection(false);
      cam.setFrame(new Vector3f(200,400,40), new Vector3f(1,0,0), new Vector3f(0,1,0), new Vector3f(0,0,-1) );
      cam.setLocation(new Vector3f(700,600,800));
      cam.setDirection(new Vector3f(0,-1,-1));
      cam.update();
      display.getRenderer().setCamera(cam);



this is how i have it setup right now, I am creating an rpg and i want that 45 degree view down onto the world. Do you see anything that stands out that should be altered? Or where i should look?

hmm, does normalizing the camera direction help at all?



ie:


cam.setDirection(new Vector3f(0,-1,-1).normalizeLocal());

your response was almost too fast…



but anyway, sorry, normalizing doesn't seem to do the trick.

:frowning:



Also with statistics, i have an empty update loop and only rendering taking place in the render loop but im getting sky rocketing values for meshes, triangles and vertex's, am i supposed to be doing something more than just .getStatistics(); ?



Thanks for the help

renderer.clearStatistics()



Also, I've often found that if objects cull out of the scene too early/late, it's because something doesn't have a model bound set properly.  Try using Debugger to draw your bounds and see if when a bounds for something else leaves the screen, other objects suddenly cull too.

well thanks for clear statistics! that works awesome now



Now, for the main issue at hand…



I used debugger and it looks like the bounds are in check, im going to back to blaiming this on my frustrum



Wait here is a very stupid basic question about opengl, and scengraphs, If a parent node is culled, are all of the children culled? Yes, right?

yes, that is done on the jME side…



what's the width and height variables set to? they should be the same ratio as display.getWidth() and display.getHeight() (which you usually send in to that method instead)



and, setting the direction like that without changing the up and left vector accordingly can screw up the camera frustum. so, either use the camera.lookAt method instead or update the up/left vectors when changing your direction…look in the lookAt method for code…



you need something like this:


      cam.getDirection().set( newDirection );
      cam.getLeft().set( Vector3f.UNIT_Y ).crossLocal( cam.getDirection() ).normalizeLocal();
      cam.getUp().set( cam.getDirection() ).crossLocal( cam.getLeft() ).normalizeLocal();
      cam.update();

mmm, nice catch

wow… much better now Mr.Coder and Renanse, thanks for everything!!