Camera Issues

Hey everyone.



I am having some problems with using a camera node. I have read a previous post from Cep about ‘the case of the disappearing skybox’ and I believe that my problem is somewhat related to that. My skybox doesn’t disappear though…its just so far away that it is being clipped by the far clipping plane. What is really odd is that the problem only occurs when the camera in a SimpleGame is attached to a CameraNode using a NodeHandler to control the view. If I move very close to the skyBox I am able to see it using the cameraNode setup. However, if I use the default cam and the FPSHandler set up by default in SimpleGame, I am able to view everything.



Here are some pictures that show the behavior:



No skybox is visible…





But if I move towards where the box is…









Here we see the clipping issue on the model:















Now let me describe the setup and my logic behind it.







I have created two nodes (SceneNode and nonCollisionNode) to attach everything in the system. When I perform collision detection checks, I only bother to check things on the SceneNode. Not only would collision detection on particle systems be expensive, but setting up the correct OBBTree structures on the particle systems and cameraNode is a problem. I am not even sure what I would really be bounding with a cameraNode. That being said, this is a good time to bring up the fact that on the nonCollisionNode (which the camera is now attached to), there is not really a bounding structure set up anywhere.



Anyway, the NodeHandler I spoke of above is attached to the playerNode. It works great because I get the simultaneous translation and rotation on the weapon and camera for the FPS look.



I suspect that the culprit is the lack of bounding volumes on the nonCollisionNode, but if I attach the playerNode (which contains the cameraNode) to the sceneNode, my collision detection code barfs because the cameraNode seems to lack bounding volumes, and I am not sure how to add bounding volumes to it.



How would guys tackle this problem? Do you think I have my sceneGraph set up correctly, or should I take a different approach?

As for the skybox I would attach it to the camera node. This allows the sky to move with the player (it’s supposed to always surround us and we can’t ever reach it anyways, right?). Take a look at the TestSkyBox, this actually creates a very small skybox (so clipping never takes place), but it never writes to the depth buffer, so it’s always behind everything. For the other clipping issues, you can increase the far plane of the camera (however, be careful with this as you may run into other artifacts as the difference between the near and far clipping plane increase) (i.e. running out of bits in the depth buffer).



BTW, the games is looking great.

Heya, it sounds like you simply need to extend the far clip plane of your frustum. The default is 1000 units from the camera. You can change that via:


cam.setFrustumFar(5000);  // play with the number to get something right for you...
cam.onFrustumChange(); // You might need cam.update();l



make sure you place this in simpleInitGame().

Let me know if that works for you.

beat me to it mojo… :slight_smile:

Thanks guys! Such a simple call. :smiley:


cam.setFrustumFar(3000);



Just curious, why would this call not set that far plane properly?

cam.setFrustumPerspective(45.0f, (float) display.getWidth()
            / (float) display.getHeight(), 1, 3000);



Is the far parameter in that call different than that in the first?

Also, I'll try attaching the SkyBox to the Camera. Thanks for the great idea and encouragement on the game. :)
Just curious, why would this call not set that far plane properly?

Code:
cam.setFrustumPerspective(45.0f, (float) display.getWidth()
/ (float) display.getHeight(), 1, 3000);


Is the far parameter in that call different than that in the first?


Hmmm, it should, might be a bug, I'll look into it...

Yeah, both should work the same really (as far as the far param goes… )



If you get the skybox working in the manner described by mojo (with the small skybox), much of your clipping issues should go away already though.



PS: The setFrustumFar method already calls onFrustumChange() so forget that part of what I wrote above. Hmm, come to think of it, if you are calling setFrustumPerspective in your own game, but don’t call update or onFrustumChange, your changes wouldn’t be taking affect… so that could be it.

the perspective method wasn’t calling onFrustumChange(), so now it is. This also appears to have fixed an issue with using perspective to set the frustum with the TerrainPage. In CVS now. Not sure if this will fix your issue, but give it a shot.

The update worked.





About attaching the SkyBox to the CameraNode…



Would I need to disable the automatic update of the SkyBox’s geometric state and instead just update it’s local translation in simpleUpdate? Otherwise, any rotation taking place on the player node will translate to the SkyBox and I will always be facing the same position.

yes, take a look at the TestSkyBox for a good way of handling this.