The floor and ceiling in not visible in output in using panda3d

Converting 2d floorplan to 3D model, using GitHub - art-programmer/FloorplanTransformation: Raster-to-Vector: Revisiting Floorplan Transformation. In rendering folder, while after running viewer.py we get the 3d model. But the floor and ceiling is not visible the function for floor and ceiling in floorplan.py is and output is also attached
out

indent preformatted text by 4 spaces
```def generateFloor(self, data):
    floorGroup = EggGroup('floor')
    data.addChild(floorGroup)
    
    vp = EggVertexPool('floor_vertex')
    floorGroup.addChild(vp)


    exteriorWalls = []
    for wall in self.walls:
      if (wall[4] == 6 or wall[5] == 6):
        exteriorWalls.append(copy.deepcopy(wall))
        pass
      continue    


    exteriorOpenings = []
    for wall in exteriorWalls:
      lineDim = calcLineDim((wall[:2], wall[2:4]))
      for doorIndex, door in enumerate(self.doors):
        if calcLineDim((door[:2], door[2:4])) != lineDim:
          continue
        if door[lineDim] >= wall[lineDim] and door[2 + lineDim] <= wall[2 + lineDim] and abs(door[1 - lineDim] - wall[1 - lineDim]) <= self.wallWidth:
          exteriorOpenings.append(doorIndex)
          pass
        continue
      continue

    minDistance = 10000
    mainDoorIndex = -1
    for icon in self.icons:
      if icon[4] == 'entrance':
        for doorIndex in exteriorOpenings:
          door = self.doors[doorIndex]
          distance = pow(pow((door[0] + door[2]) / 2 - (icon[0] + icon[2]) / 2, 2) + pow((door[1] + door[3]) / 2 - (icon[1] + icon[3]) / 2, 2), 0.5)
          if distance < minDistance:
            minDistance = distance
            mainDoorIndex = doorIndex
            pass
          continue
        break
      continue

    self.startCameraPos = [0.5, -0.5, self.wallHeight * 0.5]
    self.startTarget = [0.5, 0.5, self.wallHeight * 0.5]
    if mainDoorIndex >= 0:
      mainDoor = self.doors[mainDoorIndex]
      lineDim = calcLineDim((mainDoor[:2], mainDoor[2:4]))
      fixedValue = (mainDoor[1 - lineDim] + mainDoor[3 - lineDim]) / 2
      imageSize = [self.width / self.maxDim, self.height / self.maxDim]
      side = int(fixedValue < imageSize[1 - lineDim] * 0.5) * 2 - 1
      self.startCameraPos[lineDim] = (mainDoor[lineDim] + mainDoor[2 + lineDim]) / 2
      self.startTarget[lineDim] = (mainDoor[lineDim] + mainDoor[2 + lineDim]) / 2
      self.startCameraPos[1 - lineDim] = fixedValue - 0.5 * side
      self.startTarget[1 - lineDim] = fixedValue + 0.5 * side
      
      self.startCameraPos[0] = 1 - self.startCameraPos[0]
      self.startTarget[0] = 1 - self.startTarget[0]
      pass
    
    newDoors = []
    self.windows = []
    for doorIndex, door in enumerate(self.doors):
      if doorIndex == mainDoorIndex or doorIndex not in exteriorOpenings:
        newDoors.append(door)
      else:
        self.windows.append(door)
        pass
      continue
    self.doors = newDoors


    exteriorWallLoops = []
    visitedMask = {}
    gap = 5.0 / self.maxDim
    for wallIndex, wall in enumerate(exteriorWalls):
      if wallIndex in visitedMask:
        continue
      visitedMask[wallIndex] = True
      exteriorWallLoop = []
      exteriorWallLoop.append(wall)
      for loopWall in exteriorWallLoop:
        for neighborWallIndex, neighborWall in enumerate(exteriorWalls):
          if neighborWallIndex in visitedMask:
            continue
          #if calcDistance(neighborWall[:2], loopWall[:2]) < gap or calcDistance(neighborWall[2:4], loopWall[:2]) < gap or calcDistance(neighborWall[:2], loopWall[2:4]) < gap or calcDistance(neighborWall[2:4], loopWall[2:4]) < gap:
          if calcDistance(neighborWall[:2], loopWall[2:4]) < gap:
            exteriorWallLoop.append(neighborWall)
            visitedMask[neighborWallIndex] = True
            break
          elif calcDistance(neighborWall[2:4], loopWall[2:4]) < gap:
            neighborWall[0], neighborWall[2] = neighborWall[2], neighborWall[0]
            neighborWall[1], neighborWall[3] = neighborWall[3], neighborWall[1]
            exteriorWallLoop.append(neighborWall)
            visitedMask[neighborWallIndex] = True
            break
          continue
        continue
      exteriorWallLoops.append(exteriorWallLoop)
      continue


    for exteriorWallLoop in exteriorWallLoops:
      poly = EggPolygon()
      floorGroup.addChild(poly)
      
      poly.setTexture(self.floorMat.getEggTexture())
      poly.setMaterial(self.floorMat.getEggMaterial())
      
      
      for wallIndex, wall in enumerate(exteriorWallLoop):
        if wallIndex == 0:
          v = EggVertex()
          v.setPos(Point3D(1 - wall[0], wall[1], 0))
          v.setUv(Point2D(wall[0] * self.maxDim / self.width, 1 - wall[1] * self.maxDim / self.height))
          poly.addVertex(vp.addVertex(v))
        else:
          v = EggVertex()
          v.setPos(Point3D(1 - (wall[0] + exteriorWallLoop[wallIndex - 1][2]) / 2, (wall[1] + exteriorWallLoop[wallIndex - 1][3]) / 2, 0))
          v.setUv(Point2D((wall[0] + exteriorWallLoop[wallIndex - 1][2]) / 2 * self.maxDim / self.width, 1 - (wall[1] + exteriorWallLoop[wallIndex - 1][3]) / 2 * self.maxDim / self.height))
          poly.addVertex(vp.addVertex(v))
          pass
        if wallIndex == len(exteriorWallLoop) - 1:
          v = EggVertex()
          v.setPos(Point3D(1 - wall[2], wall[3], 0))
          v.setUv(Point2D(wall[2] * self.maxDim / self.width, 1 - wall[3] * self.maxDim / self.height))
          poly.addVertex(vp.addVertex(v))
          pass
        continue
      continue


    ceilingGroup = EggGroup('ceiling')
    data.addChild(ceilingGroup)
    
    vp = EggVertexPool('ceiling_vertex')
    ceilingGroup.addChild(vp)

    for exteriorWallLoop in exteriorWallLoops:
      poly = EggPolygon()
      ceilingGroup.addChild(poly)
      
      poly.setTexture(self.ceilingMat.getEggTexture())
      poly.setMaterial(self.ceilingMat.getEggMaterial())

      for wallIndex, wall in enumerate(exteriorWallLoop):
        if wallIndex == 0:
          v = EggVertex()
          v.setPos(Point3D(1 - wall[0], wall[1], self.wallHeight))
          v.setUv(Point2D(wall[0], 1 - wall[1]))
          poly.addVertex(vp.addVertex(v))
        else:
          v = EggVertex()
          v.setPos(Point3D(1 - (wall[0] + exteriorWallLoop[wallIndex - 1][2]) / 2, (wall[1] + exteriorWallLoop[wallIndex - 1][3]) / 2, self.wallHeight))
          v.setUv(Point2D((wall[0] + exteriorWallLoop[wallIndex - 1][2]) / 2, 1 - (wall[1] + exteriorWallLoop[wallIndex - 1][3]) / 2))
          poly.addVertex(vp.addVertex(v))
          pass
        if wallIndex == len(exteriorWallLoop) - 1:
          v = EggVertex()
          v.setPos(Point3D(1 - wall[2], wall[3], self.wallHeight))
          v.setUv(Point2D(wall[2], 1 - wall[3]))
          poly.addVertex(vp.addVertex(v))
          pass
        continue
      continue

    return



Actually I'm not well aware with the code, so couldn't change anything carelessly, anyone who understood the code, please suggest what change should be done,

Panda3D ouput model, floor not visible

Just to check: if you change the background colour to something other than black, do you see that colour in place of the floor, or does the floor-area remain black?

Otherwise, for one or both of floor and ceiling, could it simply be that your winding order is such that the polygons are ending up facing “away” from the camera, and thus are being removed by back-face culling?

A quick way to diagnose what might be causing it would be to (1) view the model in wireframe mode to see if the geometry is even there, and (2) to call .setTwoSided(True) after loading the model into a node, to see if the winding order is reversed as @Thaumaturge suggests.

1 Like

For some Floorplan, at some places in the output the floor is visible, actually every function in the floorplan.py file is working fine except generateFloor() method where floor and ceiling part is there, example where floor at some places is visible


here you can see the second block the floor is visbile

Actually one thing I forgot to mention in the floorplan.py file in generateFloor() method at line 152 it was written walla[4]==10 or wall[5]==10 and for the single floorplan.txt file which they gave to us, for that the output was coming with perfect floor and ceiling but that code doesn’t worked for any other floorplan.txt file, so after observing I found that the maximum value in the wall[4] or wall[5] is set i.e in their case it was 10 but for every floorplan.txt file that maximum value is different, because of that I was getting AssertionError at that time, therfore i modifed the code little bit as
max_wall_col=0
for x in self.walls:
if (x[4]>max_wall_col):
max_wall_col=x[4]
if (x[5]>max_wall_col):
max_wall_col=x[5]

exteriorWalls = []
for wall in self.walls:
  if wall[4] == max_wall_col or wall[5] == max_wall_col:
    exteriorWalls.append(copy.deepcopy(wall))
    pass
  continue   

now, I got rid of that Assertionerro and 3d model is visible pefectly with walls and each icons the only thing is after modification the floor and ceiling is not visible

First, have you tried rdb’s suggestions, above? Those are likely to be fairly good indicators, I think.

Otherwise, in a single run of the program, are the same pieces of floor always visible, or does their visibility change as you move the view?

Could you pleasse help me where I should place setRenderModeWireframe() in viewer.py file and also it doesn’t matter where I move the view that visible portion is same everwhere?

Why not ask the developers of this library a question? Asking here is like asking Bill Gates a question about a problematic program found on the web.

1 Like

Okay, that gives us some information to work with.

I’m not familiar with your code, but I would guess that the thing to do would be to call it on the NodePath or NodePaths that hold the floor and/or ceiling. If not there, then on the NodePath that holds the building overall. And if not there, then perhaps on “render”.