I have a chunked world with a variable number of static models per chunk. When I click save or compile in my world editor I want to combine all the statics of a chunk into one bam file.
The problem comes in when I try to load the combined bam file into an LODNode, at which point some of the models just disappear as if they are not even part of the bam file.
I know that I can actually create an Actor() with an LODNode, add the models to the different LOD switches and then save the Actor as a bam file. Then I load the bam file into an Actor like this:
After loading it like this I get the same result as above where some of the models in the bam file just disappear.
If I load it like this:
The bam works perfect, but how can I set the LOD Ins and Outs when I load it like this? Not even sure I can set them when loading into an Actor as above.
I’m not sure what you mean when you say “some of the models just disappear”. It rather sounds like the LODNode is doing what it’s supposed to do, which is making certain nodes invisible or visible depending on the distance to the camera (and the LODNode setup).
But to answer your question, the way to set up the switch distances on the LOD is to get a handle to the LODNode itself and call addSwitch() or setSwitch() on it for each child.
Yes, disappear is not the right word. I meant, they are just not there or missing, as if they were never even loaded. Can’t be sure what is wrong, but I’m definitely sure its not because of a bad LOD switch that they appear to be missing. The switch I used is Out=0 In=500 for the whole combined model. Why would only one model show up?
Anyway, I’ll try getting a handle to the LODNode and test the setSwitch() function.
Ok, this is my code. Here I have my combinedModel and combinedLODModel, both have a few models reparented to them.
actor.addLOD("0", inDist=250, outDist=0)
actor.addLOD("1", inDist=500, outDist=250)
Then I load the bam as follows and try to get it’s LODNode:
I get the following error:
Traceback (most recent call last):
File "main.py", line 33, in <module>
File "C:\Panda3D-1.7.1\direct\actor\Actor.py", line 624, in getLODNode
AttributeError: 'NoneType' object has no attribute 'node'
Oh, you probably don’t want to be using Actor.setLODNode(). That’s not designed to be written to a bam file and reloaded.
Instead, just create an LODNode outside of the Actor, and parent the Actor to it. When you reload the Actor from a bam file, do it again.
I did not realize that an LODNode does not need an Actor(). Works now, thanks.