Ejemplo n.º 1
0
    def __init__(self, world, modname, mapname):
        """Load the objects from the map"""

        #store instance variables
        self.world = world

        #Load from the XML file holding the entities
        filename = Mod.MapPath(modname, mapname) + "objects.mb2"
        self.ents = EntLoader.LoadEntsFromFile(filename, world,
                                               self.world.isServer)

        self.staticMeshScene = StaticMeshScene(self.ents)
        self.dynamicEnts = [x for x in self.ents if not x.isStatic]
Ejemplo n.º 2
0
 def __init__(self, modname, mapname ):
     self._shaderProgram = None
     self.layers = TerrainLayer.loadLayers( modname, mapname )
     self._colormapName = Mod.MapPath(modname,mapname) + 'colormap.png'
Ejemplo n.º 3
0
 def __init__(self, modname, mapname ):
     """Initialize the project description"""
     filename = Mod.MapPath( modname, mapname ) + "project.xml"
     tree = ET.parse( filename )
     root = tree.getroot()
     self._parseLevel( root )
Ejemplo n.º 4
0
    def __init__ ( self, modname, mapname, is_server=False, graphics_enabled=True ):
        """Initialize the world from the given map"""
        self.modname = modname
        self.mapname = mapname
        self.playerEnt = None
        self.isServer = is_server
        self.graphicsEnabled = graphics_enabled
        self.idCounter = 0

        self.ninjasKilled   = 0
        self.piratesKilled  = 0
        self.treasuresTaken = 0
        self.deathBlotches = []

        path = Mod.MapPath( modname, mapname)
        hmap = path+"heightmap.bin"
        projectdesc = ProjectDesc ( modname, mapname )
        self.projectDesc = projectdesc
        self.seaLevel = float(projectdesc.SeaLevel)
        self.solver = Physics.Solver()
        self.solver.setMinimumFramerate(10)

        #create materials
        self.materialMap = Materials.DefaultMaterialMap(self.solver)

        #setup atmosphere
        self.atmosphere = Atmosphere.Atmosphere(projectdesc)
        self._extractShadowMap()
        self.terrainMaterial = TerrainMaterial.TerrainMaterial( modname, mapname )
        self.terrain = Terrain.TerrainPatch(  None, self, Heightmap.fromFile(hmap), self.terrainMaterial, projectdesc.Spacing )
        #if self.graphicsEnabled:
        #    self.terrain.initGraphics()
        self.ocean = Ocean.Ocean(float(projectdesc.SeaLevel),
                                 projectdesc.WaterTexture,
                                 self.terrain.getextent() )

        mx = self.terrain.getextent() / 2
        mz = self.terrain.getextent() / 2
        my = self.terrain.getWorldHeightValue( mx, mz ) + 2.0

        #Set the world size (Newton will disable anything that's not
        #within the world box
        extent = float(self.terrain.getextent())
        self.solver.setWorldSize( (-extent, -2000.0, -extent ), (extent, 2000.0, extent) )

        #Create scene. This should load all the entities as well
        self.scene   = SceneManager.SceneManager(self, modname, mapname)
        #set camera
        if not self.graphicsEnabled:
            self.playerEnt = None
            self.camera = None
        else:
            if self.playerEnt == None or Settings.RunPhysics == False:
                self.camera = Camera.Freecam()
                self.camera.position = vec3( mx, my, mz)
                self.camera.yaw = 0
                self.camera.pitch = 0
            else:
                self.camera = Camera.AttachableCamera( self.playerEnt )
            self.frustrum_camera = self.camera.asFreecam()
        print "World loaded"
Ejemplo n.º 5
0
 def fsPath( self ):
     return Mod.MapPath( self.modname, self.mapname)