How to set the camera near clipping distance?


i have the problem, that objects coming too close to the camera are cut off too early.

I want to be able to go much closer (like all the way) before it clips / cuts them off.

What is the correct parameter to play with?

1 Like

This is what you want :slight_smile:


Edit: if you’re using SimpleApplication, the camera variable is called cam.

I tried that. But it caused that i can’t see anything anymore!

But now i figured it out! You cannot set it to 0. Then you don’t see anything anymore.

LOL, i tried setting it to 0.001f. It created a very funny effect, like a warp-effect.

Everything distorted into the distance.

I tried several other values, the closer it gets to 1 the less distortion. I suppose 1 is the default.

But it doesn’t solve my problem. Maybe the other frustrum parameters need to be adjusted at the same time?!

BTW, the function was called [java]cam.setFrustumNear(1f);[/java]

But even with 0.5f it would cut off objects before i reach them.

I guess this is the wrong parameter.

I’m posting from a phone, so my memory may be a bit off on exact names… if you look in the sources for the Application class (superclass for SimpleApplication) you’ll see the camera setup through a setPerspectiveProjection method where you can give it near and far planes as well as view angle and aspect ratio… I would try setting it up with that

BINGO! You got it!

And this is the code to solve the problem:

[java]cam.setFrustumPerspective(45f, (float) cam.getWidth() / cam.getHeight(), 0.01f, 1000f);[/java]

I simply replaced the 1f with 0.01f, that’s all.



Cool! Glad to help :slight_smile: