TerrainPage invisible if directly over it

I've got a TerrainPage set up at (0,0,0) and a camera set at (0, 400, 0). Nothing is visible. If I move the camera for (0,400, 1) the whole page is visible. This seems like a bug, and might already be a known bug, but I can't, for the life of me, think of how to search for it :wink:



JWar

Could you provide an example to look at?

I've tried to replicate it outside my own program for clarity's sake and noticed that something different is going on. I still think this isn't the correct behavious, but might be wrong:



import com.jme.app.SimpleGame;
import com.jme.input.KeyBindingManager;
import com.jme.math.Vector3f;
import com.jme.scene.CameraNode;
import com.jmex.terrain.TerrainPage;

public class BugDemo extends SimpleGame {

   /**
    * @param args
    */
   public static void main(String[] args) {
      BugDemo demo = new BugDemo();
      demo.setDialogBehaviour(SimpleGame.ALWAYS_SHOW_PROPS_DIALOG);
      demo.start();
   }

   @Override
   protected void simpleInitGame() {
      
      int size = 513;
      int[] indices = new int[size*size];
      for (int i = 0; i < indices.length; i++) {
         indices[i] = 1;
      }
      
      TerrainPage page = new TerrainPage("page", 128, size,
            new Vector3f(1, 0.05f, 1), indices, false);
      
      rootNode.attachChild(page);
      
      float Z_VALUE = 0;
      //float Z_VALUE = 1;
      //float Z_VALUE = -1;
      
      CameraNode camNode = new CameraNode("camNode", cam);
      camNode.setLocalTranslation(new Vector3f(0, 500, Z_VALUE
            ));
      
      camNode.lookAt( page.getLocalTranslation(), new Vector3f(0,1,0));
      
      cam.update();
      
      rootNode.attachChild(camNode);
      
      rootNode.updateGeometricState(0, true);
      
      
   }
}



uncomment the different Z_VALUE lines to see different effects. The strange behaviour is in Z_VALUE = 0. Compare the results to -1 and 1 to see what I mean.

things get hairy when trying to do lookAt in the same direction as the passed upvector…

right, there is a mathematical singularity going on here.  actually, in this case it is because the lookAt and the up are directly opposite.  Because they lie in the same plane, the cross products used to determine correct camera orientation will create seemingly "invalid", perhaps undefinable results.  We could detect this coplanar nature, but how could we know what to do about it?  If you are looking straight down, where should the top of your head point?  I would suggest this has to be handled by the application, not the library.

What do you think about detecting it and throwing an exception when this occurs?  This would make it a little easier for people to realize they are doing something wrong here.  Just a thought. :wink:

We'd have to check each vector of the camera if they are orthogonal. Each time the camera changes… pretty expensive.



Edit: Me speak English good.

It should be javadoc'd properly at least.  I think it's not really necessary to throw exceptions.  It is similar to gluLookAt ( http://www.mevis.de/opengl/gluLookAt.html ) which also has the same requirements.  Determining the vectors are parallel (sorry, coplanar was not quite right) seems expensive and unnecessary.

You're right…if it costs us much of anything it's really not worthwhile.