Node position precision.

Hello,
Again I’ve run myself into trouble. In my project I use X,Y,Z position system with (0,0,0) point in center of Earth. Body on surface has got position with big floating point numbers, for example:[3688910.3940231404, 2305085.3991088001, 4664676.7814143915]. But panda node getX(),getY(),getZ() functions returned: 3688910.5 2305085.5 4664677.0

Does anyone know how to make panda to use more decimal places with big numbers?

I know it does use them with smaller numbers. I could transform all positions to make them smaller and use this transformation(move by some vector to make positions lesser then 10000) on all visible objects, but I don’t like this option.

Lech “Pikkot” Glowiak

Panda uses single-precision floats for its internal representation, because your graphics card does, too. An IEEE 754 single-precision floating-point number reserves 23 bits for the mantissa, which means you get about 6 digits of meaningful data in your number. You can put the decimal point anywhere in those six digits you like. So you can store (very precisely) the number 0.00000123456, or (less precisely) 1.23456, or (not at all precisely) 12,345,600,000; in general, the larger the number, the fewer bits of precision you will have to the right of the decimal point.

This is just the nature of floating-point number representation on computers.

So, yeah, I suggest storing your points with relative centers that are closer to the geometry in question, so you don’t need to use such large numbers. You can use Panda’s relative scene graph for this. For instance, model your houses such that (0, 0, 0) is in the middle of the house, and then attach each house to a node that transforms it to the appropriate place on the street, and then attach the street to a node that transforms it to the appropriate place in the neighborhood, and so on. Use as few or as as many levels of transforms as you need.

David

Thanks for quick reply!

If I got object with position like : 1000000.324,2000000.23423,2000000.543
I should make node with position 1000000,2000000,2000000 and then attach to it object with position 0.324, 0.23423,0.543? It sounds like that for me, but I’m not sure. How to make a node without actor or model?

You can create new nodes at any place on the scene graph, e.g. on render.

NewNodePath=render.attachNewNode('NewNodeName')

Thanks!