Collision with terrain generate by HeightFieldTesselator

hi all,

I would like use the tesselator to manage LOD of the ground of my scene … but i have problem using detection collision on it… the way describe in the roaming ralph code, using ray, seems to be a good solution, but I’am not able to add the tesselated mesh to the proper bitmask…

        self.terrain = terrainGenerator( ) ) 


the answer :

AttributeError: 'generator' object has no attribute 'setCollideMask'

I know that I’am a newbie in OO en panda 3D… so did I do some fundamental mistake … or is there some sort of limitations that forbid this kind of collision …

what should I do to keep the character on the ground ?


The fundamental mistake is that what terrainGenerator( ) returns in NOT a NodePath Instance, but a Python generator object.

You have to assign the collide mask to the NodePath returned by tesselator.generate(). The improved demo pro-rsoft has provided does this around line 61-62.


ho … thanks a lot, I understand the mistake :wink: (and succed to solve it :stuck_out_tongue: )

but now I need to have all the vertex normals of the mesh to apply vertex shader on it … unfortunatey it seems that the tesselator does not compute their …

I would like to use de recomputeVertexNormal() method, but it seems to work on eggnode only …

how can I convert the node give by the tesselator into eggnode ? if it’s not possible i have to write some algorythm to compute vertex normal … how can I acces to the vertex levels of the node ?

The heightfield tesselator does create normals, and out-of-the box lighting (which depends on vertex normals) works fine. So perhaps there is something wrong with your shaders?

If it is about lighting then perhaps you should consider this: the terrain tesselator creates a mesh that is a fine approximation of the terrain close to a focal point, and a coarse approximation (less detail) far away. This means that the normals too are fine close to the focal point, and coarse far away. For better visual lighting results could use a static normal map (texture!). The normal vector is encoded as (r,g,b) components.


By the way. The most recommended way to have your player grounded on the Tesselator’s terrain is to use tesselator.getElevation(x,y). This returns the Z of the terrain at that position.

thanks pro-rsoft :wink: you’re surely right …

The reason that I use de ray collision solution to keep the character grounded is because we are curently testing different way to manage earthground …

one of these way is using the tesselator… and we and to benchmark it without completly modifyng our code ^^