55 lines
1.4 KiB
Python
55 lines
1.4 KiB
Python
|
|
||
|
from direct.showbase.ShowBase import ShowBase
|
||
|
from panda3d.core import WindowProperties, GeomVertexArrayFormat, GeomVertexFormat, Geom, GeomVertexData, GeomVertexWriter, GeomTriangles, GeomNode
|
||
|
from panda3d.core import VirtualFileSystem
|
||
|
from panda3d.core import Vec3
|
||
|
|
||
|
from map.file import parse_map_file
|
||
|
|
||
|
|
||
|
class DungeonCell:
|
||
|
def __init__(self):
|
||
|
self.mesh = None
|
||
|
self.bounds = [None, None]
|
||
|
self.connections = []
|
||
|
|
||
|
def getBounds(self):
|
||
|
bmin, bmax = self.mesh.getTightBounds()
|
||
|
self.bounds = [bmin, bmax]
|
||
|
|
||
|
class CellArrange1(DungeonCell):
|
||
|
def __init__(self):
|
||
|
DungeonCell.__init__(self)
|
||
|
self.mesh = loader.loadModel("/models/arrangements/arrange1.glb")
|
||
|
|
||
|
self.connections = [
|
||
|
Vec3(0, 5, 0),
|
||
|
Vec3(0, -5, 0),
|
||
|
Vec3(5, 0, 0),
|
||
|
Vec3(-5, 0, 0)
|
||
|
]
|
||
|
self.getBounds()
|
||
|
|
||
|
class Game(ShowBase):
|
||
|
def __init__(self):
|
||
|
ShowBase.__init__(self)
|
||
|
|
||
|
vfs = VirtualFileSystem.getGlobalPtr()
|
||
|
vfs.mount('assets', '/', 0)
|
||
|
|
||
|
tex_bricks = loader.loadTexture('/textures/generic_bricks.png')
|
||
|
tex_floor = loader.loadTexture('/textures/generic_tiles.png')
|
||
|
|
||
|
|
||
|
self.room = CellArrange1()
|
||
|
self.room.mesh.reparentTo(render)
|
||
|
self.room.mesh.find('**/A1.Walls').setTexture(tex_bricks, 1)
|
||
|
self.room.mesh.find('**/A1.Floor').setTexture(tex_floor, 1)
|
||
|
print(self.room.bounds)
|
||
|
|
||
|
winprops = WindowProperties()
|
||
|
winprops.setSize(1600, 900)
|
||
|
self.win.requestProperties(winprops)
|
||
|
|
||
|
game = Game()
|
||
|
game.run()
|