Author Topic: World.setClippingPlanes has no effect for me  (Read 1596 times)

Offline Roland

  • byte
  • *
  • Posts: 7
    • View Profile
World.setClippingPlanes has no effect for me
« on: March 21, 2012, 10:20:49 am »
when i'm not to close to an object, i still start to see through it because it is cutting the closest parts, so i tested change the world to this: theWorld.setClippingPlanes(0.01f, 1000f);
But still I see no difference. is there any other way I should do, for it to render even when the object is quite close to the camera?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: World.setClippingPlanes has no effect for me
« Reply #1 on: March 21, 2012, 10:35:37 am »
To make the near plane have an effect, you have to set Config.glIgnoreNearPlane=false; This is to keep compatibility with the software renderer, which behaves different for the near plane. However, i've never seen a case where 1 isn't sufficient. Maybe you should avoid coming that close in the first place...

Offline Roland

  • byte
  • *
  • Posts: 7
    • View Profile
Re: World.setClippingPlanes has no effect for me
« Reply #2 on: March 21, 2012, 03:25:39 pm »
didn't help att all, tested first

theWorld.setClippingPlanes(0.1f, 1000f);
      Config.glIgnoreNearPlane = false;

and then

theWorld.setClippingPlanes(0.01f, 1000f);
      Config.glIgnoreNearPlane = false;

made no different, tested putting Config.glIgnoreNearPlane = false; a little bit here and there, but no different.

I need to come closer then a meter, ever seen a fps where the closest the person is, is 1 meter away from the wall?
In the template for the fps jpct provided, the person was like 30 meters high, that is why you didn't see. but my game need to be more close to reality since i'm using larger worlds, and want to use the precision of meters

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: World.setClippingPlanes has no effect for me
« Reply #3 on: March 21, 2012, 09:00:43 pm »
jPCT doesn't allow for a near clipping plane lower than 1. And you don't want that anyway, because the resulting frustum will cause a look like this: (0.1, 1000):



Using one unit in world space as one meter in the real world isn't very much anyway. You'll most likely run into accuracy problems with collision detection when doing this. The person in the fps example isn't 30 meters high...it might by 30 units high. But as long as you scale everything by the same amount, the visual outcome of using 1 unit/meter or 10 units/meter or 1000 units/meter will be exactly the same (except for the mentioned problems with accurcy for very small or very large scales).
I suggest to scale everything by 10, so that in your scene, 10 units are the equivalent of 1 meter. That's the scale that i'm using most the time, too. It's a good compromise and the near plane at 1 means a clipping 10cm before the viewer. That should be fine.

Offline Roland

  • byte
  • *
  • Posts: 7
    • View Profile
Re: World.setClippingPlanes has no effect for me
« Reply #4 on: March 22, 2012, 10:21:42 am »
If there isn't any other way I must do like that, but the problem with is that then I haveto add another thing to the game, which is moving the world as I walk.
If I have 1 unit as 1 meter, then I can have a world that is 32 kilometers with 1 millimeter precision, however, if I use a much higher value for everything, the scaled precision will not be as accurate, and then I have to make a solution for that, which I wished to avoid if possible.
Hoever, I think it must be a way to not have to change the size of everything, but to change the clipping instead.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: World.setClippingPlanes has no effect for me
« Reply #5 on: March 22, 2012, 12:54:07 pm »
If there isn't any other way I must do like that, but the problem with is that then I haveto add another thing to the game, which is moving the world as I walk.
If I have 1 unit as 1 meter, then I can have a world that is 32 kilometers with 1 millimeter precision, however, if I use a much higher value for everything, the scaled precision will not be as accurate, and then I have to make a solution for that, which I wished to avoid if possible.
Hoever, I think it must be a way to not have to change the size of everything, but to change the clipping instead.
The near value is set directly into the glFrustum-function. It defines the clipping plane, but it also defines the view frustum which leads to the results that you are seeing in the screen shot. You can of course specify additional clipping planes, but they can't be located behind the near plane itself.