Needs some advices with bullet world

Hi, everyone! I’m new to Panda3D, I was trying to solve this myself, there are many similar topics on this in the forums, but after spending 5 hours with no result, I decided to create this thread.

I need to do simple task. I have level with static geometry, and camera moving around this level. I need to ‘map’ the level, i.e. sent raycast in all directions from the camera, and get collision distances from camera to the surface, though mapping level this way.

I thought that most effcicient way to do this is to use Bullet World physics, though I’ll have so sent lots of rays in all directions, I think there is no ‘SphereOverlap’ or something like that in Panda3D.

So I created test scene inside 3Ds Max, and exported it, keeping this inside egg file:

<Collide> Floor_Big_004 { Polyset keep descend }

Then coded this:

from direct.showbase.ShowBase import ShowBase
from FirstPersonCamera import FirstPersonCamera
from panda3d.core import *
#loadPrcFileData("", "want-directtools #t")
#loadPrcFileData("", "want-tk #t")
from panda3d.bullet import BulletWorld
class Application(ShowBase):
    
    def __init__(self):
        
        ShowBase.__init__(self)
        self.setupCD()
        base.setBackgroundColor(1, 1, 1)
        base.disableMouse()
        
        
        self.floor = loader.loadModel("Floor_Big_02.egg")
        self.floor.reparentTo(render)
        self.floor.setPos(0, 0, 0)
        self.floor.setScale(0.1, 0.1, 0.1) 
        
        self.geomnodes = self.floor.findAllMatches('**/+GeomNode')
        self.gn = self.geomnodes.getPath(0).node   
        self.geom = self.gn.getGeom(0)  
        self.mesh = BulletTriangleMesh()   
        self.mesh.addGeom(self.geom)   
        self.shape = BulletTriangleMeshShape(self.mesh, dynamic=False)
        
        self.cam.setPos(10, -10, 5)
        self.mouseLook = FirstPersonCamera(self, self.cam, self.render)

    def setupCD(self):
        taskMgr.add(self.update, 'update')  
        self.world = BulletWorld()
        self.world.setGravity(Vec3(0, 0, -9.81))
        
    def update(self, task):
      dt = globalClock.getDt()
      self.world.doPhysics(dt)
      
      pFrom = self.cam.getPos() 
      pTo = pFrom + Vec3(1, 0, 0) * 99999
        
      result = self.world.rayTestAll(pFrom, pTo)

      if result.hasHits():
       print result.hasHits()

      return task.cont

“GeomNode” is not found no matter what. From what I learned, Panda3D should have created it automatically; On second thought, when I look at the egg file, it has not GeomNode tags either

<Group> character {
  <Dart> { 1 }
  <Group> Floor_Big_004 {
    <Collide> Floor_Big_004 { Polyset keep descend }
    <VertexPool> Floor_Big_004.verts {
      <Vertex> 0 {
        139.996 -400.004 2.28882e-005
        <UV> {
          0.000207861 0.499871
          <Tangent> { 1 8.92681e-007 0 }
          <Binormal> { -8.92681e-007 1 2.72486e-007 }
        }
        <Normal> { 0 -2.72486e-007 1 }
      }
      <Vertex> 1 {
    ....
        139.996 -540 -1.52588e-005
        <UV> {

Any advice, what might be wrong? And is my approach for mapping is, in general, efficient?

If I remove that ‘self.floor.findAllMatches(’**/+GeomNode’)’ part which always fails, raycast will simply return ‘false’ all the time.

It would be far more efficient to render depth maps to a texture, specifically a depth cube map (using cameras with 90 degree fovs in all 6 directions), and calculate the distances by reading the depth values of the texture pixels.

Thank you, I was thinking too, that colliders are not needed in this case. May you point to any example/reference shader which does something with depth cube maps, so that I could use it as a reference?

After investigating everything, I found out the default cubemap function can not produce depth maps, so I can not use it. While, if using renderingSceneInto, I need to create display regions, which overlaps;

I wanted to stick to this solution:

But I could not find a way to render depth pass inside camera view.

Basically, which is the most performant way? As I do not want to display those depth passes at all. Just render them to some buffer and work with that data.

Instead of makeTextureBuffer, use the lower level base.graphicsEngine.makeOutput(base.pipe, name, sort, fbprops, WindowProperties.size(width, height), GraphicsPipe.BF_refuse_window, win.getGsg(), win). For fbprops, pass in a FramebufferProperties object that has set_depth_bits set to the desired bits. On the return value, call addRenderTexture(texture, RTM_bind_or_copy, RTP_depth) to set up your render-to-texture to a depth map.

Got this, thank you.