I’ve done basically the same thing here :
[how to make these kind shodow?)
It’s grid based, so what I do is instance/copy the terrain chunks around the avatar from the pool to the scenegraph.
This is the relevant piece in updateDropShadow() :
if self.CH.getAirborneHeight()<.1:
minx = max( 0, int((w.terrainMinX+pos[0]-self.radius)/GRIDX) )
miny = max( 0, int((w.terrainMinY+pos[1]-self.radius)/GRIDY) )
maxx = min( int((w.terrainMinX+pos[0]+self.radius)/GRIDX), w.XSIZE-1 )
maxy = min( int((w.terrainMinY+pos[1]+self.radius)/GRIDY), w.YSIZE-1 )
idx = ( (minx,maxx), (miny,maxy) )
if self.DSidx!=idx:
self.DSidx=idx
self.dropShadowGeom.removeChildren()
ds = self.dropShadowGeom.attachNewNode('')
for yi in range(miny,maxy+1):
for xi in range(minx,maxx+1):
gnp = w.glist[xi][yi]
if gnp:
gnp.instanceTo(ds,0)
ds.flattenStrong()
Enter debug mode and see how the white terrain chunks around the avatar are attached and removed from scenegraph.