LOD and Collision Data

Hi everyone. I’ve notice a strange (not really strange) beheaver that I don’t like about the fadelod. It seems that the collision data for level0 is also still caclulated for use when level0 goes to level1. Is there anyway to have the fadelod level0 collision turn off/hidden when switching between nodes? Maybe a way to change its collision bit?

When you are using collide-with-geometry, then the default is to perform collision tests with the lowest level of geometry under an LODNode only, even when a higher level is visible. The idea is that a collision test should always be performed against a low-detail model.

If you want to collide with a specific level of detail, you will have to model that level of detail explicitly and not use an LODNode. For instance, you could switch it out with a task instead.

David

Thanks drwr, but how does it knows whitch is the lowest level? I guess (and from what I test) the lowest is what ever first you add to the LODNode?

If so, maybe could we get that change to base on the LOD switching instead? I seem to run into issues if level0 or level1 gets added before the other. For example, if level1 gets loaded before level0, it does the right collision, but level0 doesn’t show up at all. And via vers, if level0 loads up before level1, both show up right, but collision is only apply to level0 witch is wrong level that I need to give the collision to.

      #LOD_groupname_#_distant1_distant2
      if NodePathName[0] == "LOD":
        print NodePathName
        if not self.LodNode.has_key(NodePathName[1]):
          self.LodNode[NodePathName[1]] = NodePath(FadeLODNode(NodePathName[1]))
          self.LodNode[NodePathName[1]].reparentTo(render)
          center = self.GetCenterPos(nodePath)
          self.LodNode[NodePathName[1]].setPos(center[0], center[1], center[2])
        if NodePathName[2] == "0":
          self.LodNode[NodePathName[1]].node().addSwitch(750, float(NodePathName[3]))
        else:
          self.LodNode[NodePathName[1]].node().addSwitch(float(NodePathName[3]),float(NodePathName[4]))

        nodePath.wrtReparentTo(self.LodNode[NodePathName[1]])
        if NodePathName[2] == "1":#May Change to Low-Mid-High(collision)
          self.BuildCollision(self.LodNode[NodePathName[1]])
        NumberOfgeomNode -= 1


  def BuildCollision(self, Node):
    self.collisiondummyNod[Node] = octreefy(Node)
    self.collisiondummyNod[Node].setCollideMask(BitMask32.bit(0)|BitMask32.bit(1))
    self.collisiondummyNod[Node].reparentTo(Node)

The order that you add them means nothing (other than the matching up of addSwitch() calls and children). The “lowest” level is the one with the closest switch distance.

If you’re not seeing a model when you change the order, are you sure you’re matching up your addSwitch() calls with the order in which you’re adding models?

david

I’m sure. It all depends on the order I pass to lodnode when adding the switches… They would work if I could some how change the order around, but that would seems ugly to do to me.

code output from the print command:

#Doesn't works.
['LOD', 'ManTin', '1', '400', '0']
['LOD', 'ManTin', '0', '400']
#Doesn't works.
['LOD', 'Maze', '1', '50', '0']
['LOD', 'Maze', '0', '50']
#Doesn't works.
['LOD', 'A1Church', '1', '250', '0']
['LOD', 'A1Church', '0', '250']
#Only one that works showing both right, but collision will be set to level0 instead of level1.
['LOD', 'Test', '0', '200']
['LOD', 'Test', '1', '200', '0']

I don’t know, that code looks kind of complicated. Are you sure you’re setting up the switches the way you think you are? Try printing the LODNode after you have done it to prove that the switch distances are sensible for each model.

David

I can explane anything you like to know about the code if it’s to complicated. I’m perty sure; the output looks right. Is this what you mean?

Level0 is what seen when the user is x distant from the model, but less than 750 because the user can only see that far anyways. Then for level1, it has both a high and low just under the level0 low.

        if NodePathName[2] == "0":
          self.LodNode[NodePathName[1]].node().addSwitch(750, float(NodePathName[3]))
          print float(NodePathName[3])
        else:
          self.LodNode[NodePathName[1]].node().addSwitch(float(NodePathName[3]),float(NodePathName[4]))
          print float(NodePathName[3])
          print float(NodePathName[4])


#output
['LOD', 'ManTin', '1', '400', '0']
400.0
0.0
['LOD', 'ManTin', '0', '400']
400.0
['LOD', 'Maze', '1', '50', '0']
50.0
0.0
['LOD', 'Maze', '0', '50']
50.0
['LOD', 'A1Church', '1', '250', '0']
250.0
0.0
['LOD', 'A1Church', '0', '250']
250.0
['LOD', 'Test', '0', '200']
200.0
['LOD', 'Test', '1', '200', '0']
200.0
0.0

No, I want to know the final results of that code. The logic is too complicated for me to follow it through by reading the code, so just show me what it does:

print self.LodNode[NodePathName[1]].node()
print self.LodNode[NodePathName[1]].getChildren()

David

Oh sorry there=) Mis understood.

Heres thos results:

['LOD', 'ManTin', '1', '400', '0']
FadeLODNode ManTin center(0 0 0) (400/0) fade time: 0.5 T:(pos 115.2 570.24 40.32)

render/ManTin/LOD_ManTin_1_400_0
render/ManTin/octree-root

['LOD', 'ManTin', '0', '400']
FadeLODNode ManTin center(0 0 0) (400/0) (750/400) fade time: 0.5 T:(pos 115.2 570.24 40.32)

render/ManTin/LOD_ManTin_1_400_0
render/ManTin/octree-root
render/ManTin/LOD_ManTin_0_400

['LOD', 'Maze', '1', '50', '0']
FadeLODNode Maze center(0 0 0) (50/0) fade time: 0.5 T:(pos 111.36 535.68 -34.56)

render/Maze/LOD_Maze_1_50_0
render/Maze/octree-root

['LOD', 'Maze', '0', '50']
FadeLODNode Maze center(0 0 0) (50/0) (750/50) fade time: 0.5 T:(pos 111.36 535.68 -34.56)

render/Maze/LOD_Maze_1_50_0
render/Maze/octree-root
render/Maze/LOD_Maze_0_50

['LOD', 'A1Church', '1', '250', '0']
FadeLODNode A1Church center(0 0 0) (250/0) fade time: 0.5 T:(pos -504.96 -318.72 48)

render/A1Church/LOD_A1Church_1_250_0
render/A1Church/octree-root

['LOD', 'A1Church', '0', '250']
FadeLODNode A1Church center(0 0 0) (250/0) (750/250) fade time: 0.5 T:(pos -504.96 -318.72 48)

render/A1Church/LOD_A1Church_1_250_0
render/A1Church/octree-root
render/A1Church/LOD_A1Church_0_250

['LOD', 'Test', '0', '200']
FadeLODNode Test center(0 0 0) (750/200) fade time: 0.5 T:(pos 69.12 -426.72 10.56)

render/Test/LOD_Test_0_200

['LOD', 'Test', '1', '200', '0']
FadeLODNode Test center(0 0 0) (750/200) (200/0) fade time: 0.5 T:(pos 69.12 -426.72 10.56)

render/Test/LOD_Test_0_200
render/Test/LOD_Test_1_200_0

So it looks like you have a child called “octree_root” that’s creeping in there from somewhere, that doesn’t appear to be one of your LOD versions. That will certainly cause problems.

David

Yup, that’s for the collision =) Hmmm, so I tried switching it out for a more manual control… but it looks so ugly in code and is slow.

I think we should have a better control over how the LOD works myself. Seems limited to just detail of “looks” instead of the total saving value.

That, or I’m just not in the logic mood atm.

Thanks again drwr. Hope you have a good day/weekend=)