How to set clipping planes ?

Hi all,

I’m trying to make a stellar system editor in Panda3D. The distances involved would mean to use great values of the far clipping distance. However, I couldn’t find for now the way to change the clipping planes distances. I see them in the tools window, but I just can’t get to them by code…

Thanks in advance for any hint !

This is described on the “Lenses and field of view” page of the manual. The short answer is, base.camLens.setFar(value) to set the far distance to a given value.

There are practical limits to how far out you can set it, based largely on the limits of single-precision floating-point arithmetic.

David

Hi David,

Thanks for the hint !

I already read that page but when I tried to test, I surely did something bad, because it didn’t seem to work.

As there was another page on Rendering Attributes that explicitely told of clip planes, but didn’t tell how to set them, I assumed that I hadn’t found the right place.

I’ll re-run my tests and try to pinpoint what I did wrong… So thanks again !

As for the limits being these of float single-precision, I got the same issue in TV3D, so I’ll first assume Panda3D will do just the same and the same solutions will apply. Except if I find better solutions in the Panda3D forums, of course ^-^

Hi all, hi David,

I tested on my small orbital camera example, and I got a weird behavior…

I can set Far Plane as I want, no problem.

The issue seems to be in the way clipping actually occurs. With far plane under 1e5, it works as expected, clipping polys under the specified distance. But as soon as I set far plane greater than 1e5, it seems to clip just farther than 1e5. It would seem that 1e5 is a kind of higher limit.

Maybe it’s just my mobile’s graphics card that is weird. I’ll try on my home system and keep you updated…

Anyhow, if someone did have any hint about the issue, I would appreciate much ^-^

EDIT : just tested on my home system, just the same behavior. Below 1e5 all is fine, above, clipping still occurs around 1e5.

Hmm, this might be a minor bug in Panda3D’s lens code. I’ll investigate.

David

Hi drwr,

Thanks for your interest ! Since then, I completed a first test at having Earth and Moon with orbit drawn and that kind of things.

Next step is to build generic classes around this code and the XSD template I built to store stellar system data.

So do you have found something ? This is just in case I could upload a new build of Panda and use actual units throughout the app instead of using a render ratio for everything rendering-related ^-^

Thanks in advance for any hint ^-^

So far, it looks like a simple limitation of single-precision floating-point arithmetic. The projection matrix has to include the value 1 + 1e-N, where your far plane is 1eN. For suffiently large values of N (around 5), 1 + 1e-N == 1 in single-precision arithmetic. So the matrix breaks down beyond that.

So, there may not be anything Panda can do about it–it appears to be a limitation of the single-precision graphics hardware.

David

Actually, on further inspection, I was mistaken. There was a genuine bug in there. I have committed a fix, so if pick up and build the cvs version of Panda, you should be able to push the far plane further out without issues.

David

Hi drwr,

Thanks for your answers, particularly the second one ^-^ I knew there was something strange, as I already played with far planes as large as 1e10 on other engines, namely Ogre, Unity and TV3D.

So thanks for the fix. Now I must devise how I can build Panda from CSV. But that’s another issue entirely ^-^

If you don’t want to build Panda3D from CVS, you can also wait for the next daily build;:
panda3d.org/buildbot/

Hi rdb,

OK, thanks, nice idea to have a dialy build ! I’ll get the next one !

Hi rdb,

Sorry for not having posted back, I got on other tasks on the project and the gamedev tasks got low priority. Now I’m back at it.

But I tested it once you told me, with build “Panda3D-2010.06.10-43”, and it works very well. Thanks for the fix !

In the meantime, I’ve reinstalled my laptop so I’ll reinstall Panda on it and keep on happy work ^-^