I am trying to create procedural geometry mesh with nested design, that is:
At the top of nested structure is object I call BigTileCluster, which contains several TileCluster, each of which contains several BasicTiles
In what follows I am proving code that should illustrate how those objects are creates, however the code is incomplete, I tried to provide only the necessary pieces.
The BasicTile is created in following manner:
class BasicTile(NodePath): def __init__( self, q, r, center, terrain_color ): super().__init__("BasicTile") self._default_color = terrain_color self.q = q self.r = r self.center = center self._highlight_color = self.set_highlight_color(color_offset) def create_tile( self, ): vdata, tris = self.triangulate_mesh(self.get_default_color()) geom = Geom(vdata) geom.add_primitive(tris) geom_grid=Geom(vdata_grid) geom_grid.add_primitive(tris_grid) node = GeomNode("tile") node.add_geom(geom) node.add_geom(geom_grid) self.attachNewNode(node) #here are other class methods
While TileCluster are created as follows:
class Cluster(NodePath): def __init__( self, q, r ): super().__init__("Cluster") self.q = q self.r = r self.cells = self.create_sub_cells_array() def create_sub_cells_array(self): tiles =np.empty( shape=(7), dtype=NodePath ) for i in range(7): #here is some code that returns tile_position, q0, r0, terrain_color.... tiles[i] = \ BasicTile(q0, r0, tile_position, terrain_color = terrain_color ) tiles[i].create_tile() tiles[i].reparent_to(self) return tiles #here are other class methods
BigTileCluster cluster is almost same except in its cells array are TileClusters instead of BasicTiles.
At the end, BigTileCluster is reparented to render.
Now, the issue I am encountering is that while I can navigate this structure by leveraging ‘tiles’ attribute, i.e., BigTileCluster.tiles.tiles, I am not able to navigate by using NodePath methods.
returns object which doesnt have q, r and center attributes, and I cant figure out how to access them.
My guess is that the issue lies with how I use inheritance. I think I dont quite understand all the nuances with NodePaths, PandaNodes and handles.
I would be glad if someone could help me understand how to properly implement such tree like structure of tiles in Panda3d.
Is it possible to access combined mesh of TileClusters? I am trying to get outer edge/boundary of TileCluster and BigTileCluster, however I am quite at loss how can this be achieved efficiently. I am bit reluctant to define it by hand…