How to use LOD

I am struggling through the documentation to figure out how to use LODNodes to no avail so far. I have searched through the forums looking for a good example of doing this but all I have found is bits and pieces of the big picture. I could spend a great deal of time and document all of the things I have tried but I am under the gun to get something out fairly quickly. Can someone help me get started here? This has got to be a trivial coding problem for P3D. I’ll take the results and create a full example for the docs when it’s done. Here is what I want to do:

I create 4 torus models as follows:

ID  Facets  TexSize  Filename               LOD-Range
1   32x256   1024    Torus_32_256.bam.pz   0-100
2   16x128   512     Torus_16_128.bam.pz   100-200
3     8x64    56     Torus_08_064.bam.pz   200-300
4     4x32    64     Torus_04_032.bam.pz   300-inf

I want to create a single NodePath that handles all four of these models and switches them in and out according to the specified LOD range.


lod = NodePath(LODNode('lod'))
lod.node().addSwitch(100, 0)
lod.node().addSwitch(200, 100)
lod.node().addSwitch(300, 200)
lod.node().addSwitch(999999, 300)

You might prefer the look of a FadeLODNode instead of an ordinary LODNode.


Awesome, perfect, fantastic, beautiful. Thanks again for your help David. I posted the example code here :