Pixel-size of a NodePath

I want to replace a nodepath with an image of it without changing its size on screen. I can use billboards but propably using sprites (GeomPoints) is much faster.
Nodepath-sizes are specified in world-units and sprite-sizes in pixels.
How can that be converted?

According to the manual if you do setRenderModePerspective(True) on the node with the GeomPoints then each point should become a 11 sprite in world units. You can setRenderModeThickness(n) to make it nn. I guess it has to be square. I’m going to do some experimenting to see what I can get.

That doesn’t seem to be related to the OP’s question. Unless I misunderstand, the question was to determine how large a model is onscreen?

There’s not a straightforward answer, but in general you will have to project the model into render2d space and then measure the size in render2d space. There are functions in Panda to project an individual point from render to render2d (see base.camLens.project; try searching the forums for this). One approach to project an entire model is to pick several points from the model arbitrarily, project them to render2d, and then see how far apart the points are onscreen.

The whole art of determining a suitable LOD representation for an arbitrary model is quite complex and there are textbooks written on the subject.


Yeah I guess I don’t understand the question. I thought he’s talking about doing a render-to-texture of a 3D object in which case you choose dimensions of the buffer. If the texture buffer is 256*256 and the point thickness is 1, then 256 texels = 1 unit, but of course this is scaled/filtered with distance from the camera.

Heh, yeah okay I’m confused.
Edit: actually I should say texels not pixels, shouldn’t I