def __init__(self): ''' ''' ShowBase.__init__(self) loadPrcFileData("", "notify-level-x11display fatal") # This variable gets set to true when a collision-event gets fired and to false every ode-frame self.ode_collisiontest = False base.setFrameRateMeter(True) # Show the Framerate self.world = OdeWorld() self.deltaTimeAccumulator = 0.0 # this variable is necessary to track the time for the physics self.stepSize = 1.0 / 300.0 # This stepSize makes the simulation run at 300 frames per second # Initialize Collisions (ODE) self.space = OdeSimpleSpace() # Initialize the surface-table, it defines how objects interact with each other self.world.initSurfaceTable(1) self.world.setSurfaceEntry(0, 0, 150, 0.0, 9.1, 0.9, 0.00001, 0.0, 0.002) self.space.setAutoCollideWorld(self.world) self.contactgroup = OdeJointGroup() self.space.setAutoCollideJointGroup(self.contactgroup) self.startGame()
def __init__(self): ShowBase.__init__(self) loadPrcFileData('', 'bullet-enable-contact-events true') world = BulletWorld() self.world = world world.setGravity(Vec3(0, 0, -9.81)) base.cam.setPos(0,-50,1) # Cameras base.camNode.setActive(0) self.cam1 = base.makeCamera(base.win, displayRegion=(0,.5,0.5,1)) self.cam2 = base.makeCamera(base.win, displayRegion=(.5,1,0.5,1)) self.cam1.setPos(-10,-50,1) self.cam2.setPos(10,-50,1) # base.camList[0].setPos(0,-100, 1) # Plane shape = BulletPlaneShape(Vec3(0, 0, 1), 1) node = BulletRigidBodyNode('Ground') node.addShape(shape) np = render.attachNewNode(node) np.setPos(0, 0, 0) self.world.attachRigidBody(node) scene = loader.loadModel('Ground2/Ground2') scene.reparentTo(render) self.newGame() taskMgr.add(self.update, 'update')
def __init__(self): self.visualize = False if self.visualize == False: from pandac.PandaModules import loadPrcFileData loadPrcFileData("", "window-type none") import direct.directbase.DirectStart self.ep = 0 self.ep_rew = 0 self.t = 0 self.prevDis = 0 self.action_space = Box(-1, 1, shape=(3, )) self.observation_space = Box(-50, 50, shape=(9, )) self.target = 8 * np.random.rand(3) self.construct() self.percentages = [] self.percentMean = [] self.percentStd = [] taskMgr.add(self.stepTask, 'update') taskMgr.add(self.lightTask, 'lights') self.rotorForce = np.array([0, 0, 9.81], dtype=np.float)
def main() : loadPrcFileData("", "window-type none") import direct.directbase.DirectStart # this sticks a ton into __builtins__ size = (800, 600) window, drawing_area = launch_gtk_window(size) launch_panda_window(drawing_area, size) base.disableMouse() taskMgr.add(gtk_iteration, "gtk") run()
def main(): loadPrcFileData("", "window-type none") import direct.directbase.DirectStart # this sticks a ton into __builtins__ size = (800, 600) window, drawing_area = launch_gtk_window(size) launch_panda_window(drawing_area, size) base.disableMouse() taskMgr.add(gtk_iteration, "gtk") run()
def __init__(self, visualize): if visualize == False: from pandac.PandaModules import loadPrcFileData loadPrcFileData("", "window-type none") import direct.directbase.DirectStart self.initialPos = 10 * (np.random.rand(3) - 0.5) + 4 * (np.random.rand(3) - 0.5) self.construct()
def __init__(self): ShowBase.__init__(self) if (self.debug): loadPrcFileData('', 'want-pstats 1') self.notify.warning('Debug Mode enabled.') base.startDirect() if (self.fps): base.setFrameRateMeter(True) base.camera.setPos(0, -15, 3) base.disableMouse() GameWorld()
def __init__(self): ShowBase.__init__(self) if(self.debug): loadPrcFileData('', 'want-pstats 1') self.notify.warning('Debug Mode enabled.') base.startDirect() if(self.fps): base.setFrameRateMeter(True) base.camera.setPos(0, -15, 3) base.disableMouse() GameWorld()
def __init__(self): ShowBase.__init__(self) utilities.setApp(self) loadPrcFileData('', 'bullet-enable-contact-events true') self.world = World(10) self.taskMgr.add(self.update, "update") self.accept("a", self.world.player.moveLeft, [True]) self.accept("a-up", self.world.player.moveLeft, [False]) self.accept("d", self.world.player.moveRight, [True]) self.accept("d-up", self.world.player.moveRight, [False]) self.accept("space", self.world.player.jump, [True]) self.accept("space-up", self.world.player.jump, [False]) self.accept("c", self.world.player.crouch, [True]) self.accept("c-up", self.world.player.crouch, [False]) self.accept("mouse1", self.world.player.activate, []) self.accept("escape", sys.exit, []) self.accept('bullet-contact-added', self.onContactAdded) self.accept('bullet-contact-destroyed', self.onContactDestroyed) self.accept("h", self.showDBG, [True]) self.accept("h-up", self.showDBG, [False]) self.prevTime = 0 self.mousePos = Point2() base.disableMouse() self.rl = base.camLens.makeCopy() # bullet testing debugNode = BulletDebugNode('Debug') debugNode.showWireframe(True) debugNode.showConstraints(True) debugNode.showBoundingBoxes(False) debugNode.showNormals(False) self.debugNP = render.attachNewNode(debugNode) self.debugNP.show() self.world.bw.setDebugNode(self.debugNP.node())
def __init__(self): ''' ''' # loadPrcFileData("", "want-pstats 1\n pstats-host 127.0.0.1\n pstats-tasks 1\n task-timer-verbose 1") # loadPrcFileData("", "pstatshost 192.168.220.121") ShowBase.__init__(self) loadPrcFileData( "", "default-directnotify-level debug\n notify-level-x11display fatal") # PStatClient.connect() #activate to start performance measuring with pstats base.setFrameRateMeter(True) # Show the Framerate # base.toggleWireframe() self.startGame()
def setupWindow(self, windowType, x, y, width, height, parent): """ Applies the indicated window parameters to the prc settings, for future windows; or applies them directly to the main window if the window has already been opened. This is called by the browser. """ if self.started and base.win: # If we've already got a window, this must be a # resize/reposition request. wp = WindowProperties() if x or y or windowType == 'embedded': wp.setOrigin(x, y) if width or height: wp.setSize(width, height) if windowType == 'embedded': wp.setParentWindow(parent) wp.setFullscreen(False) base.win.requestProperties(wp) self.windowProperties = wp return # If we haven't got a window already, start 'er up. Apply the # requested setting to the prc file, and to the default # WindowProperties structure. self.__clearWindowProperties() if windowType == 'hidden': data = 'window-type none\n' else: data = 'window-type onscreen\n' wp = WindowProperties.getDefault() wp.clearParentWindow() wp.clearOrigin() wp.clearSize() wp.setFullscreen(False) if windowType == 'fullscreen': wp.setFullscreen(True) if windowType == 'embedded': wp.setParentWindow(parent) if x or y or windowType == 'embedded': wp.setOrigin(x, y) if width or height: wp.setSize(width, height) self.windowProperties = wp self.windowPrc = loadPrcFileData("setupWindow", data) WindowProperties.setDefault(wp) self.gotWindow = True # Send this call to the main thread; don't call it directly. messenger.send('AppRunner_startIfReady', taskChain = 'default')
def loadMultifilePrcFiles(self, mf, root): """ Loads any prc files in the root of the indicated Multifile, which is presumed to have been mounted already under root. """ # We have to load these prc files explicitly, since the # ConfigPageManager can't directly look inside the vfs. Use # the Multifile interface to find the prc files, rather than # vfs.scanDirectory(), so we only pick up the files in this # particular multifile. for f in mf.getSubfileNames(): fn = Filename(f) if fn.getDirname() == '' and fn.getExtension() == 'prc': pathname = '%s/%s' % (root, f) data = file.open(Filename(pathname), 'r').read() loadPrcFileData(pathname, data)
def loadMultifilePrcFiles(self, mf, root): """ Loads any prc files in the root of the indicated Multifile, which is presumed to have been mounted already under root. """ # We have to load these prc files explicitly, since the # ConfigPageManager can't directly look inside the vfs. Use # the Multifile interface to find the prc files, rather than # vfs.scanDirectory(), so we only pick up the files in this # particular multifile. cpMgr = ConfigPageManager.getGlobalPtr() for f in mf.getSubfileNames(): fn = Filename(f) if fn.getDirname() == '' and fn.getExtension() == 'prc': pathname = '%s/%s' % (root, f) alreadyLoaded = False for cpi in range(cpMgr.getNumImplicitPages()): if cpMgr.getImplicitPage(cpi).getName() == pathname: # No need to load this file twice. alreadyLoaded = True break if not alreadyLoaded: data = file.open(Filename(pathname), 'r').read() cp = loadPrcFileData(pathname, data) # Set it to sort value 20, behind the implicit pages. cp.setSort(20)
def setupWindow(self, windowType, x, y, width, height, parent): """ Applies the indicated window parameters to the prc settings, for future windows; or applies them directly to the main window if the window has already been opened. This is called by the browser. """ if self.started and base.win: # If we've already got a window, this must be a # resize/reposition request. wp = WindowProperties() if x or y or windowType == 'embedded': wp.setOrigin(x, y) if width or height: wp.setSize(width, height) if windowType == 'embedded': wp.setParentWindow(parent) wp.setFullscreen(False) base.win.requestProperties(wp) self.windowProperties = wp return # If we haven't got a window already, start 'er up. Apply the # requested setting to the prc file, and to the default # WindowProperties structure. self.__clearWindowProperties() if windowType == 'hidden': data = 'window-type none\n' else: data = 'window-type onscreen\n' wp = WindowProperties.getDefault() wp.clearParentWindow() wp.clearOrigin() wp.clearSize() wp.setFullscreen(False) if windowType == 'fullscreen': wp.setFullscreen(True) if windowType == 'embedded': wp.setParentWindow(parent) if x or y or windowType == 'embedded': wp.setOrigin(x, y) if width or height: wp.setSize(width, height) self.windowProperties = wp self.windowPrc = loadPrcFileData("setupWindow", data) WindowProperties.setDefault(wp) self.gotWindow = True # Send this call to the main thread; don't call it directly. messenger.send('AppRunner_startIfReady', taskChain='default')
def __init__(self): '''TODO: An option should be added to graphics submenu that allows the user to adjust resolution''' # loadPrcFileData('', 'fullscreen 1') loadPrcFileData('', 'win-size 640 440') ShowBase.__init__(self) self.menu = Menu() ''' ATTENTION: to see all the tasks running uncomment the line below ''' # taskMgr.popupControls() # GUI stuff # self.title = OnscreenText(text="Bazibaz", style=1, fg=(1,1,1,1), pos=(0.9,0.9), scale = .1) # self.text = self.genLabelText("Orbits Alpha Ver.0.1", 0) # self.text = self.genLabelText( # "Zoom in and out using a mouse", 1) # self.text = self.genLabelText("Move mouse side to side", 2) # self.text = self.genLabelText("Rotate view by pressing on the right mouse key", 3) #Exit the program when escape is pressed self.accept("escape", sys.exit)
def __init__(self): from pandac.PandaModules import loadPrcFileData loadPrcFileData("", "want-directtools #t") loadPrcFileData("", "want-tk #t") self.camHandler = None self.environ = None self.isMoving = False self.trav = CollisionTraverser() self.cHandler = CollisionHandlerQueue() self.picked = None self.selected = None self.setupEnvironment() self.setupCamera() self.setupActors() self.setupLighting() self.gui = mouseSelectTool() self.gui.selectable = [self.box, self.box2]
def __init__(self): from pandac.PandaModules import loadPrcFileData loadPrcFileData("", "want-directtools #t") loadPrcFileData("", "want-tk #t") self.camHandler = None self.environ = None self.isMoving = False self.trav = CollisionTraverser() self.cHandler = CollisionHandlerQueue() self.picked = None self.selected = None self.setupEnvironment() self.setupCamera() self.setupActors() self.setupLighting() self.gui = mouseSelectTool() self.gui.selectable = [self.box,self.box2]
def __init__(self): ShowBase.__init__(self) loadPrcFileData('', 'bullet-enable-contact-events true') world = BulletWorld() self.world = world world.setGravity(Vec3(0, 0, -9.81)) base.cam.setPos(0, -50, 1) # Plane shape = BulletPlaneShape(Vec3(0, 0, 1), 1) node = BulletRigidBodyNode('Ground') node.addShape(shape) np = render.attachNewNode(node) np.setPos(0, 0, 0) self.world.attachRigidBody(node) scene = loader.loadModel('Ground2/Ground2') scene.reparentTo(render) self.newGame() taskMgr.add(self.update, 'update')
def __init__(self, pipe, name): """Arguments: pipe -- Multiprocessing pipe for communication. See messagecenter module for more info. name -- Name of this instance. """ #self.gameobjects = [] self.messageclient = MessageClient(pipe) self.name = name self.windows = {} # set a few default settings loadPrcFileData("", "window-type none") loadPrcFileData("", "audio-library-name null") # initiate Panda3D self.base = ShowBase() # start processing incoming requests self.messageclient.addListener(self.UImessageProcessor, req_type=UI) # The request processing task should never stop as long as the # subprocess exists. This is a wrapper that ensures that and saves # us from confusion about "hey, why has this message processing # stopped?!" def messageProcessor(task): self.messageclient.process() return task.cont self.base.addTask(messageProcessor, "message processor") # As soon as the user clicks the window, it should get focus, like any other widget. self.base.accept("mouse1", self.focus) # TODO: Wrap this around a try..except block and notify the main # process on errors. self.base.run()
def __init__(self, vis, agentNumber): self.visualize = vis self.agentNumber = agentNumber self.factor = 40 self.ep_rew = 0 self.t = 0 self.agents = [Agent(self.factor, self.visualize) for i in range(self.agentNumber)] if self.visualize == False : from pandac.PandaModules import loadPrcFileData loadPrcFileData("", "window-type none") import direct.directbase.DirectStart self.construct() self.constructAgents() self.constructTargets() taskMgr.add(self.stepTask, 'update')
def __init__(self): ShowBase.__init__(self) loadPrcFileData('', 'bullet-enable-contact-events true') loadPrcFileData("", "win-size 300 100") loadPrcFileData("", "show-buffers t") winProp = WindowProperties() winProp.setSize(300,100) base.win.requestProperties(winProp) world = BulletWorld() self.world = world # Cameras base.camNode.setActive(0) self.cam1 = base.makeCamera(base.win, displayRegion=(0,.5,0,1)) self.cam2 = base.makeCamera(base.win, displayRegion=(.5,1,0,1)) self.cam1.setPos(-10,-50,1) self.cam2.setPos(10,-50,1) # Plane ground shape = BulletPlaneShape(Vec3(0, 0, 1), 1) node = BulletRigidBodyNode('Ground') node.addShape(shape) np = render.attachNewNode(node) np.setPos(0, 0, 0) self.world.attachRigidBody(node) scene = loader.loadModel('Ground2/Ground2') scene.reparentTo(render) plight = PointLight('plight') plnp = render.attachNewNode(plight) plnp.setPos(100,0,1000) render.setLight(plnp) plight2 = PointLight('plight2') plnp2 = render.attachNewNode(plight2) plnp2.setPos(-100,0,1000) render.setLight(plnp2) # Repeat every new game self.newGame() self.skip = True plt.ion() plt.figure(figsize=(2,3)) # Repeat tasks every frame taskMgr.add(self.update, 'update') self.texDepth = Texture() base.win.addRenderTexture(self.texDepth, GraphicsOutput.RTMCopyRam, GraphicsOutput.RTPDepthStencil)
#!/usr/bin/python # System imports import sys # Panda Engine imports from pandac.PandaModules import loadPrcFileData loadPrcFileData("", """ window-title Rollin fullscreen 0 win-size 1024 768 cursor-hidden 0 sync-video 1 show-frame-rate-meter 1 """ ) from panda3d.rocket import * from direct.showbase.ShowBase import ShowBase # Game imports from cfg import Config from event import Event from game import Game #----------------------------------------------------------------------# ## Rollin ## class Main(ShowBase):
by fabius astelix @2010-02-16 Level: ADVANCED More than just a snippet this is a whole game level were you'll see many of the features seen so far put together for a real-world game. This snippet singularity is indeed to be a mix of 2d and 3d objects but for us don't change very much cos we're gong to apply the same tecniques seen so far applied. Note that the purpose of this snippet is not to have a perfect game but just for learning. NOTE If you won't find here some line of code explained, probably you missed it in the previous steps - if you don't find there as well though, or still isn't clear for you, browse at http://www.panda3d.org/phpbb2/viewtopic.php?t=7918 and post your issue to the thread. """ from direct.showbase.DirectObject import DirectObject from pandac.PandaModules import Vec3 from pandac.PandaModules import ActorNode, CollisionHandlerEvent, CollisionHandlerGravity, CollisionHandlerPusher, CollisionNode, CollisionSphere, CollisionTraverser, BitMask32, CollisionRay, NodePath from direct.interval.IntervalGlobal import * from pandac.PandaModules import loadPrcFileData loadPrcFileData("", """sync-video 0 """) import direct.directbase.DirectStart #** snippet support routines - not concerning the tutorial part import snipstuff #========================================================================= # Scenographic stuff #========================================================================= base.cam.setPos(40, -70, 35) splash = snipstuff.splashCard() snipstuff.info.append("2.5D collisions") snipstuff.info.append("how to collide 2D and 3D objects") snipstuff.info.append( "Try to reach the top of the windmill\n\nwasd=move the avatar around\nSPACE=avatar jump"
from panda3d.core import * from pandac.PandaModules import loadPrcFileData loadPrcFileData("", "framebuffer-multisample 1") loadPrcFileData("", "prefer-parasite-buffer #f") loadPrcFileData("", """fullscreen 1""" ) import direct.directbase.DirectStart from direct.showbase.Audio3DManager import Audio3DManager from direct.showbase.DirectObject import DirectObject from panda3d.physx import PhysxManager from panda3d.physx import PhysxEnums from panda3d.physx import PhysxSceneDesc from panda3d.physx import PhysxBodyDesc from panda3d.physx import PhysxActorDesc from panda3d.physx import PhysxBoxShapeDesc from panda3d.physx import PhysxPlaneShapeDesc from panda3d.physx import PhysxPointOnLineJointDesc from panda3d.physx import PhysxTriangleMeshDesc from panda3d.physx import PhysxTriangleMesh from panda3d.physx import PhysxTriangleMeshShape from panda3d.physx import PhysxTriangleMeshShapeDesc from panda3d.physx import PhysxKitchen from skydome import SkyDome from Car import Car from keycontrol import KeyControl from cameracontrol import CameraControl from speedometer import Speedometer from stearingcontrol import SteeringControl
from direct.showbase.DirectObject import DirectObject from pandac.PandaModules import loadPrcFileData WANTPSTATS = False WANTDEBUGGINGTOOLS = False # the amount of information written to the out.log logfile loadPrcFileData("", "notify-level error") loadPrcFileData("", "default-directnotify-level error") # the fps counter in the right upper corner loadPrcFileData("", "show-frame-rate-meter #t") # do we want some extra debugging tools? if WANTDEBUGGINGTOOLS or WANTPSTATS: # enable pstats for performance monitoring loadPrcFileData("", "want-pstats #t") if WANTDEBUGGINGTOOLS: # some debugging tools for panda3d loadPrcFileData("", "want-directtools #t") loadPrcFileData("", "want-tk #t") # Some more debugging goodies after we set up the ShowBase (APP/Main) def setupDebugHelp(APP): def toggleOobe(): """Switch between free camera (steering with the mouse) and the camera controled by the game""" APP.oobe() def explorer(): """activates the Panda3D halp tool to explore the render Nodepath""" APP.render.explore()
"""A generic Panda3D class that handles all windowing, lifecycle management, and input management, then passes the relevant triggers to a game state class. Chances are in the future that this will also provide the game state switcher. """ from direct.showbase.ShowBase import ShowBase from direct.task import Task from panda3d import core from game.battle import BattleArena from pandac.PandaModules import loadPrcFileData # Window config loadPrcFileData("", "window-title Launchpad AI War") ORDER_DURATION = 1.0 class MainApp(ShowBase): def __init__(self): ShowBase.__init__(self) # Old-style classes. Ew. self.battle = BattleArena() self.taskMgr.doMethodLater(ORDER_DURATION, self.update_orders, "orders") self.taskMgr.add(self.update, "update") base.setFrameRateMeter(True) self.build_lighting() music = self.loader.loadSfx("sound/like-cats-and-dogs.wav") music.setLoop(True) music.play()
import os, multiprocessing from pandac.PandaModules import loadPrcFile, loadPrcFileData from pandac.PandaModules import Filename loadPrcFile(Filename.expandFrom("$MAIN_DIR/etc/config.prc")) coresNum = multiprocessing.cpu_count() #int( os.environ["NUMBER_OF_PROCESSORS"] ) if coresNum > 1: threadsNum = str(pow(coresNum,3) ) loadPrcFileData('', 'loader-num-threads ' + threadsNum ) from direct.showbase.ShowBase import ShowBase from pandark.core import Core class Main(ShowBase): def __init__(self): ShowBase.__init__(self) self.core = Core() self.core.demand("Menu", "MainMenu") self.accept('a', self.load) self.accept('escape', self.exit) self.run() def load(self): #scene name
#!/usr/bin/env python from pandac.PandaModules import loadPrcFileData loadPrcFileData("", "prefer-parasite-buffer #f") #loadPrcFileData("", "show-frame-rate-meter #t") from direct.directbase import DirectStart # Import whatever classes are necessary from pandac.PandaModules import Texture, Vec3, Point3 from direct.interval.IntervalGlobal import Sequence from sys import exit # Import the Shadow Manager from shadowManager import ShadowManager class World(object): def __init__(self): # Make a way out of here! base.accept("escape", exit) # Initiate the shadows self.sMgr = ShadowManager(render) self.sMgr.setAmbient(0.2) # Most of these five are the default self.sMgr.setHardness(20) # values so it was kinda unnecessary to self.sMgr.setFov(40) # set them explicitly but I wanted to self.sMgr.setNearFar(10, 100) # show how to set them anyway. # Create the 'table'
from src.pandaInteractiveConsole import pandaInteractiveConsole, GUI, CONSOLE from src.plants import createSmallPlants, createMediumPlants, createLargePlants, createHugePlants from src.heightfield2 import heightfieldClass, MAPSIZE from src.roamingPanda import roamingPandaClass from src.environment import environmentClass from src.interface import interfaceClass from pandac.PandaModules import loadPrcFileData, Vec3, Vec4 ''' Finn: LoadPrcFileData allows settings which are normally set in a panda config file to be set for this program specifically at runtime ''' #Finn: sync-video makes the framerate limited to the screen refresh rate loadPrcFileData("", "sync-video 1" ) #Finn: show-frame-rate-meter shows the framerate in the top right #(this one isn't documented so worth noting) loadPrcFileData("", "show-frame-rate-meter 1") # -- set Fullscreen -- #loadPrcFileData("", "fullscreen 1") # -- set window title -- loadPrcFileData("", "window-title Procedural Forest") import direct.directbase.DirectStart from src.interactiveConsole.interactiveConsole import pandaConsole, INPUT_CONSOLE, INPUT_GUI, OUTPUT_PYTHON, OUTPUT_IRC from src.camera import cameraMovement, cameraPicking, cameraRotation, objectIdPickling, cameraAddons, cameraCollision, cameraPicking
from direct.stdpy.file import * from panda3d.bullet import BulletDebugNode, BulletRigidBodyNode, BulletSphereShape from panda3d.core import LPoint3d, NodePath, Vec3 import graphicsComponents import physics import shipComponents import universals import glob import re import yaml from pandac.PandaModules import loadPrcFileData loadPrcFileData("", "notify-level-ITF-ShipSystem debug") from direct.directnotify.DirectNotify import DirectNotify log = DirectNotify().newCategory("ITF-ShipSystem") #Conversion factor from SI to units used in game CONVERT = 1000.0 shipClasses = {} class ShipSystem(sandbox.EntitySystem): def init(self): self.accept("setPlayerStations", self.setPlayerStation) self.accept("setShipID", self.setShipID) self.accept('shipClassList', self.checkClasses)
def config(): loadPrcFileData("", "window-title stableorbit") print "Enter 'f' 'Enter' for fullscreen or just 'Enter' for windowed" fullVar = "f"#raw_input() if(fullVar=="f"): loadPrcFileData("", "fullscreen 1") print "Enter '1' for 1200x600" print " '2' for 1440x900" print " '3' for 1600x1050" print "or 'Enter' for default 800x600" screenVar = raw_input() if screenVar == "1": loadPrcFileData("", "win-size 1200 600") if screenVar == "2": loadPrcFileData("", "win-size 1440 900") if screenVar == "3": loadPrcFileData("", "win-size 1600 1050") else: loadPrcFileData("", "win-size 1200 600")
from pandac.PandaModules import loadPrcFileData loadPrcFileData('', 'frame-rate-meter-scale 0.035') loadPrcFileData('', 'frame-rate-meter-side-margin 0.1') loadPrcFileData('', 'show-frame-rate-meter 1') loadPrcFileData('', 'window-title ' + "Planet Prototype") loadPrcFileData('', "sync-video 0") loadPrcFileData('', 'basic-shaders-only #f') #loadPrcFileData('', 'dump-generated-shaders #t') #loadPrcFileData('', 'pstats-tasks 1') #loadPrcFileData('', 'want-pstats 1') #loadPrcFileData('', 'threading-model Cull/Draw') import direct.directbase.DirectStart #base.setBackgroundColor(0.0, 0.0, 0.0) import surface_mesh from panda3d.core import NodePath empty = NodePath('empty') #planet = surface_mesh.make_planet(debug=True) planet = surface_mesh.make_planet() planet.reparent_to(render) #planet.set_scale(6360) #planet.reparent_to(empty) #planet.set_texture('textures/earth_#.png') planet.set_textures('textures/earth_#.png', night_path='textures/earth_night_#.png', gloss_path='textures/earth_spec_#.png') planet.set_ambient(1, 1, 1, 1) planet.set_diffuse(1, 1, 1, 1) planet.set_specular(1, 1, 1, 1)
# # Default classes used to handle input and camera behaviour # Useful for fast prototyping # from myCamera import * from myInputHandler import InputHandler from myDebug import DebugPrint import sys, __builtin__ # # Show FPS and use utf8 encoding # from pandac.PandaModules import loadPrcFileData loadPrcFileData("", """ text-encoding utf8 show-frame-rate-meter 1 """) class World(ShowBase): def __init__(self): ShowBase.__init__(self) #starting all base methods __builtin__.myApp = self __builtin__.d = DebugPrint() __builtin__.myCamera = MyCamera() __builtin__.myInputHandler = InputHandler() #default config when just opened myCamera.mm.showMouse()
# by FenrirWolf (David Grace) 7/2009 # Free for use by all under the Panda license # Purpose: Demonstrates how to use Panda physics with a collisions to generate spheres which bounce on a ground # plane. from pandac.PandaModules import loadPrcFileData loadPrcFileData( '', ''' show-frame-rate-meter #t //want-tk #t //want-directtools #t''') from pandac.PandaModules import * # lazy git import direct.directbase.DirectStart from random import random # Set up the collision traverser. If we bind it to base.cTrav, then Panda will handle # management of this traverser (for example, by calling traverse() automatically for us once per frame) base.cTrav = CollisionTraverser() # Turn on particles. (Required to use Panda physics) base.enableParticles() # Turn on the traverser debugger if you want to see the collisions #base.cTrav.showCollisions (base.render) # Having trouble figuring out what's going on with messages? Turn this on. #messenger.toggleVerbose()
import direct.directbase.DirectStart from panda3d.core import Vec3 from panda3d.core import BitMask32 from panda3d.bullet import BulletWorld from panda3d.bullet import BulletPlaneShape from panda3d.bullet import BulletRigidBodyNode from panda3d.bullet import BulletBoxShape from panda3d.bullet import BulletCharacterControllerNode from panda3d.bullet import BulletCapsuleShape from panda3d.bullet import ZUp from pandac.PandaModules import loadPrcFileData loadPrcFileData('', 'bullet-enable-contact-events true') # World world = BulletWorld() world.setGravity(Vec3(0, 0, -9.81)) height = 1.75 radius = 0.4 # player shape3 = BulletBoxShape(Vec3(0.5,0.5,0.5)) playerNode = BulletRigidBodyNode('Player') playerNode.addShape(shape3) playerNode.setMass(1.0) playerNP = render.attachNewNode(playerNode) playerNP.setPos(0, 0, 14) playerNP.node().notifyCollisions(True) # playerNP.setH(45)
from pandac.PandaModules import NodePath from pandac.PandaModules import Point3 from libpandadna import DNAStorage from libpandadna import DNAVisGroup from libpandadna import DNASuitPoint from pandac.PandaModules import loadPrcFileData loadPrcFileData('', 'window-type none') import direct.directbase.DirectStart import unittest class TestStorage(unittest.TestCase): def test_storage_visgroups(self): store = DNAStorage() vg = DNAVisGroup("my_vg") vg.addVisible("visible1") vg.addVisible("visible2") vg.addVisible("visible3") store.storeDNAVisGroup(vg) self.assertEqual(store.getNumDNAVisGroups(), 1) self.assertEqual(store.getNumDNAVisGroupsAI(), 1) self.assertEqual(store.getDNAVisGroupAI(0), vg) self.assertEqual(store.getDNAVisGroupName(0), vg.getName()) num_visibles = store.getNumVisiblesInDNAVisGroup(0) self.assertEqual(num_visibles, 3)
from pandac.PandaModules import loadPrcFileData loadPrcFileData('', 'frame-rate-meter-scale 0.035') loadPrcFileData('', 'frame-rate-meter-side-margin 0.1') loadPrcFileData('', 'show-frame-rate-meter 1') loadPrcFileData('', 'window-title ' + "Vortex") loadPrcFileData('', "sync-video 0") loadPrcFileData('', 'task-timer-verbose 1') loadPrcFileData('', 'pstats-tasks 1') loadPrcFileData('', 'want-pstats 1') loadPrcFileData('', 'framebuffer-stencil 1') #loadPrcFileData('', 'show-buffers 1') #loadPrcFileData('', 'notify-level-glgsg debug') import sandbox import shapeGenerator from panda3d.core import AmbientLight, ColorWriteAttrib, NodePath, Shader, StencilAttrib, Vec4 # Set up stenciling system stencilReader = StencilAttrib.make(1,StencilAttrib.SCFEqual,StencilAttrib.SOKeep, StencilAttrib.SOKeep,StencilAttrib.SOKeep,1,1,0) constantOneStencil = StencilAttrib.make(1,StencilAttrib.SCFAlways,StencilAttrib.SOZero, StencilAttrib.SOReplace,StencilAttrib.SOReplace,1,0,1) #mesh = shapeGenerator.Tube(0.18, 0.18, 5.0, 32) # To be render on texture #inside_vortex = shapeGenerator.ShellCylinder(-0.18, 5.0, 32) inside_vortex = shapeGenerator.Circle(0.18, 32) inside_vortex.node().setAttrib(constantOneStencil)
#self.billboardNodePath.setScale(.025) InfoText.__init__(self, self.billboardNodePath) def setText(self, text): InfoText.setText(self, text) # move the center of rotation to the lower left corner # this is not entirely correct, the x-coordinate is a bit too small frameSize = self.textNode.getFrameActual() pos = Vec3(frameSize.getX(),0,-frameSize.getZ()) # * NodePath.getScale(self, self.parent) self.textNodePath.setPos(self, pos) ''' from pandac.PandaModules import loadPrcFileData loadPrcFileData( '', 'frame-rate-meter-scale 0.035' ) loadPrcFileData( '', 'frame-rate-meter-side-margin 0.1' ) loadPrcFileData( '', 'show-frame-rate-meter 1' ) loadPrcFileData( '', 'window-title Atmosphere Demo' ) loadPrcFileData('', "sync-video 0") from pandac.PandaModules import * from direct.directbase import DirectStart from direct.task import Task from panda3d.core import Shader, PointLight import math #base.setBackgroundColor(0.0, 0.0, 0.0) parent = base.camera # render # s = 0.8
def preSetWindowIcon(filename): # Must be called before ShowBase(). loadPrcFileData("", "icon-filename " + filename)
def loadFromSettings(self): mode = self.settings.getBool('game', 'fullscreen-mode') music = self.settings.getBool('game', 'music', True) sfx = self.settings.getBool('game', 'sfx', True) toonChatSounds = self.settings.getBool('game', 'toon-chat-sounds', True) musicVol = self.settings.getInt('game', 'music-vol', 100) / 100.0 sfxVol = self.settings.getInt('game', 'sfx-vol', 100) / 100.0 res = self.settings.getList('game', 'resolution', default=[800, 600], expectedLength=2) embed = self.settings.getBool('game', 'embed', False) antialias = self.settings.getInt('game', 'antialiasing', 0) if antialias: loadPrcFileData('toonBase Settings Framebuffer MSAA', 'framebuffer-multisample 1') loadPrcFileData('toonBase Settings MSAA Level', 'multisamples %i' % antialias) else: self.settings.updateSetting('game', 'antialiasing', antialias) loadPrcFileData('toonBase Settings Framebuffer MSAA', 'framebuffer-multisample 0') self.notify.debug('before prc settings embedded mode=%s' % str(embed)) self.notify.debug('before prc settings full screen mode=%s' % str(mode)) loadPrcFileData('toonBase Settings Window Res', 'win-size %s %s' % (res[0], res[1])) self.notify.debug('settings resolution = %s' % str(res)) loadPrcFileData('toonBase Settings Window FullScreen', 'fullscreen %s' % mode) self.notify.debug('settings full screen mode=%s' % str(mode)) loadPrcFileData('toonBase Settings Music Active', 'audio-music-active %s' % music) loadPrcFileData('toonBase Settings Sound Active', 'audio-sfx-active %s' % sfx) loadPrcFileData('toonBase Settings Music Volume', 'audio-master-music-volume %s' % musicVol) loadPrcFileData('toonBase Settings Sfx Volume', 'audio-master-sfx-volume %s' % sfxVol) loadPrcFileData('toonBase Settings Toon Chat Sounds', 'toon-chat-sounds %s' % toonChatSounds) self.settingsFullScreen = mode self.settingsWidth = res[0] self.settingsHeight = res[1] self.settingsEmbedded = embed self.antialias = antialias self.notify.debug('settings embedded mode=%s' % str(self.settingsEmbedded)) self.notify.info('settingsFullScreen = %s, embedded = %s width=%d height=%d' % (self.settingsFullScreen, self.settingsEmbedded, self.settingsWidth, self.settingsHeight)) return
from pandac.PandaModules import loadPrcFileData loadPrcFileData( "", """sync-video 0 fullscreen 1 win-size 1920 1080 yield-timeslice 0 client-sleep 0 multi-sleep 0 basic-shaders-only #t audio-library-name null""") from direct.directbase import DirectStart from system.map import * from direct.gui.DirectGui import DirectFrame from direct.gui.OnscreenText import OnscreenText import sys, gc from console.panda3d_console import panda3dIOClass render.setShaderAuto() #base.toggleWireframe() base.setFrameRateMeter(True) base.buttonThrowers[0].node().setModifierButtons(ModifierButtons()) """ Just for the sake of the demo -- quickly set showing ccd process visualization """ defaultShowCCD = False """ Good practice for the time of development
from pandac.PandaModules import loadPrcFileData loadPrcFileData("", """ window-title GrimFang OWP - Dungeon Crawler cursor-hidden #f #win-size 1024 600 #fullscreen #t model-path $MAIN_DIR/assets/ # DEBUGGING #want-directtools #t #want-tk #t show-frame-rate-meter 1 """ ) import sys from direct.showbase.ShowBase import ShowBase from gui.MainMenu import MainMenu from gui.HostMenu import HostMenu import socket from panda3d.core import WindowProperties class Main(ShowBase): """Main class of the application initialise the engine (ShowBase)""" def __init__(self): """initialise the engine""" ShowBase.__init__(self) #self.setBackgroundColor(0,0,0)
# -*- coding: utf-8-*- # APPNAME = 'Astrini' APPX, APPY = 1024, 768 # Show FPS and use utf8 encoding # noaudio... # from pandac.PandaModules import loadPrcFileData loadPrcFileData( "", """ text-encoding utf8 show-frame-rate-meter 1 audio-library-name null sync-video 1 task-timer-verbose #t fake-view-frustum-cull 1 """) # PANDA DEBUGTOOLS #~ loadPrcFileData("", "want-directtools #t") #~ loadPrcFileData("", "want-tk #t") #use slow realistic ephemeris for positionning planetoids USEEPHEM = False EPHEMSIMPLESET = -18.7399468035 #correction to align equinox in simple model MOONEPHEMSET = -44 #correction to align moon phases MOONROTSET = -55 EARTHROTSET = -160
self.accept("escape", sys.exit) # Escape quits self.accept("space", self.newGame, []) # Escape quits self.startupSeparateOne() #self.startupPerformMany() #self.startupDetective() self.newGame() self.gameTask = taskMgr.add(self.gameLoop, "gameLoop") def gameLoop(self, task): global globalClock dt = globalClock.getDt() for obj in self.steeringObjects: obj.update(dt) return Task.cont def newGame(self): for obj in self.steeringObjects: speed = getRandom(20, 50) obj.kinematic.position = Point2(getRandom(-WINDOW_SZ / 2.0, 0), getRandom(-WINDOW_SZ / 2.0, 0)) orientation = randomRadians() obj.kinematic.orientation = orientation obj.kinematic.velocity = directionalVector(orientation, speed) loadPrcFileData("", "win-size %d %d" % (WINDOW_SZ, WINDOW_SZ)) demo = MovementDemo() demo.run()
from pandac.PandaModules import loadPrcFileData loadPrcFileData('', 'frame-rate-meter-scale 0.035') loadPrcFileData('', 'frame-rate-meter-side-margin 0.1') loadPrcFileData('', 'show-frame-rate-meter 1') loadPrcFileData('', 'window-title Atmosphere Demo') loadPrcFileData('', "sync-video 0") from direct.directbase.DirectStart import * from direct.task import Task from panda3d.core import Shader, PointLight import math from shapeGenerator import * base.setBackgroundColor(0.0, 0.0, 0.0) light = render.attachNewNode(PointLight("sunPointLight")) light.setPos(1000, 0, 0) render.setLight(light) sun = loader.loadModel("models/solar_sky_sphere") sun.reparentTo(render) sun.setPos(1050, 0, 0) sun.setScale(5) #earth = loader.loadModel("models/planet_sphere") earth = Sphere(1, 128) earth.reparentTo(render) # This is a sphere with the normals flipped #atmo = loader.loadModel("models/solar_sky_sphere") atmo = Sphere(-1, 128)
from pandac.PandaModules import loadPrcFileData loadPrcFileData("", "sync-video t") #from pandac.PandaModules import loadPrcFileData #loadPrcFileData('', 'load-display tinydisplay') import sys import time import direct.directbase.DirectStart from direct.actor.Actor import Actor from direct.showbase.DirectObject import DirectObject from direct.showbase.InputStateGlobal import inputState from panda3d.core import AmbientLight from panda3d.core import DirectionalLight from panda3d.core import Vec3 from panda3d.core import Vec4 from panda3d.core import Point3 from panda3d.core import TransformState from panda3d.core import BitMask32 from panda3d.core import Filename from panda3d.core import PNMImage from panda3d.bullet import BulletWorld from panda3d.bullet import BulletPlaneShape from panda3d.bullet import BulletBoxShape from panda3d.bullet import BulletRigidBodyNode from panda3d.bullet import BulletDebugNode
from pandac.PandaModules import loadPrcFileData loadPrcFileData('','show-frame-rate-meter 1') import sys import direct.directbase.DirectStart from direct.showbase.DirectObject import DirectObject from direct.gui.DirectGui import * from panda3d.core import * from messages import * from engine import * from UDPconnection_thread import * from time import ctime MAX_ATTEMPTS = 50 # info = infopanel('infotext') class World(DirectObject): """World Class contains the main objects and handles network communication""" def __init__(self): self.log = logging.getLogger('World') self.log.debug("World started at %s", ctime()) self.mesmgr = messageManager(msghandler=self.sendmsg) self.accept("enter", self.mesmgr.showtextfield) self.accept("escape", self.quit) self.info = infopanel("infotext") self.info.setinfo('debug information here') # taskMgr.add(self.info.showtime, "ShowTime") taskMgr.add(self.showinfo, "ShowInfo") self.netclient = None self.netinit('127.0.0.1', 9099) # self.netinit('adhara.usm.uni-muenchen.de', 8888)
from pandac.PandaModules import loadPrcFileData loadPrcFileData('', 'bullet-filter-algorithm groups-mask') #loadPrcFileData('', 'load-display tinydisplay') import sys import direct.directbase.DirectStart from direct.showbase.DirectObject import DirectObject from direct.showbase.InputStateGlobal import inputState from panda3d.core import AmbientLight from panda3d.core import DirectionalLight from panda3d.core import Vec3 from panda3d.core import Vec4 from panda3d.core import Point3 from panda3d.core import TransformState from panda3d.core import BitMask32 from panda3d.bullet import BulletWorld from panda3d.bullet import BulletPlaneShape from panda3d.bullet import BulletBoxShape from panda3d.bullet import BulletRigidBodyNode from panda3d.bullet import BulletDebugNode class Game(DirectObject): def __init__(self): base.setBackgroundColor(0.1, 0.1, 0.8, 1) base.setFrameRateMeter(True) base.cam.setPos(0, -20, 4)
def loadFromSettings(self): return Settings.readSettings() mode = not Settings.getWindowedMode() music = Settings.getMusic() sfx = Settings.getSfx() toonChatSounds = Settings.getToonChatSounds() musicVol = Settings.getMusicVolume() sfxVol = Settings.getSfxVolume() resList = [ (640, 480), (800, 600), (1024, 768), (1280, 1024), (1600, 1200)] res = resList[Settings.getResolution()] embed = Settings.getEmbeddedMode() self.notify.debug('before prc settings embedded mode=%s' % str(embed)) self.notify.debug('before prc settings full screen mode=%s' % str(mode)) if mode == None: mode = 1 if res == None: res = (800, 600) if not Settings.doSavedSettingsExist(): self.notify.info('loadFromSettings: No settings; isDefaultEmbedded=%s' % self.isDefaultEmbedded()) embed = self.isDefaultEmbedded() if embed and not self.isEmbeddedPossible(): self.notify.warning('Embedded mode is not possible.') embed = False if not mode and not self.isWindowedPossible(): self.notify.warning('Windowed mode is not possible.') mode = True loadPrcFileData('toonBase Settings Window Res', 'win-size %s %s' % (res[0], res[1])) self.notify.debug('settings resolution = %s' % str(res)) loadPrcFileData('toonBase Settings Window FullScreen', 'fullscreen %s' % mode) self.notify.debug('settings full screen mode=%s' % str(mode)) loadPrcFileData('toonBase Settings Music Active', 'audio-music-active %s' % music) loadPrcFileData('toonBase Settings Sound Active', 'audio-sfx-active %s' % sfx) loadPrcFileData('toonBase Settings Music Volume', 'audio-master-music-volume %s' % musicVol) loadPrcFileData('toonBase Settings Sfx Volume', 'audio-master-sfx-volume %s' % sfxVol) loadPrcFileData('toonBase Settings Toon Chat Sounds', 'toon-chat-sounds %s' % toonChatSounds) self.settingsFullScreen = mode self.settingsWidth = res[0] self.settingsHeight = res[1] self.settingsEmbedded = embed self.notify.debug('settings embedded mode=%s' % str(self.settingsEmbedded)) self.notify.info('settingsFullScreen = %s, embedded = %s width=%d height=%d' % (self.settingsFullScreen, self.settingsEmbedded, self.settingsWidth, self.settingsHeight))
from pandac.PandaModules import loadPrcFileData loadPrcFileData('', 'bullet-filter-algorithm groups-mask') #loadPrcFileData('', 'load-display tinydisplay') import sys import direct.directbase.DirectStart from direct.showbase.DirectObject import DirectObject from direct.showbase.InputStateGlobal import inputState from panda3d.core import AmbientLight from panda3d.core import DirectionalLight from panda3d.core import Vec3 from panda3d.core import Vec4 from panda3d.core import Point3 from panda3d.core import TransformState from panda3d.core import BitMask32 from panda3d.bullet import BulletWorld from panda3d.bullet import BulletPlaneShape from panda3d.bullet import BulletBoxShape from panda3d.bullet import BulletRigidBodyNode from panda3d.bullet import BulletDebugNode class Game(DirectObject): def __init__(self): base.setBackgroundColor(0.1, 0.1, 0.8, 1) base.setFrameRateMeter(True)
-t Don't run threaded network -p [server:][port] game server and/or port number to contact -l output.log optional log filename If no options are specified, the default is to run a solo client-server.""" import getopt import os import sys from pandac.PandaModules import loadPrcFileData loadPrcFileData("", "notify-level-ITF debug") #loadPrcFileData("", "extended-exceptions 1") import universals from universals import log from panda3d.core import LPoint3d def usage(code, msg=''): print >> sys.stderr, usageText % {'prog': os.path.split(sys.argv[0])[1]} print >> sys.stderr, msg sys.exit(code) try: opts, args = getopt.getopt(sys.argv[1:], 'sacr:tp:l:h') except getopt.error, msg: usage(1, msg)
from pandac.PandaModules import loadPrcFileData loadPrcFileData("", """ sync-video 1 frame-rate-meter-update-interval 0.5 show-frame-rate-meter 1 """ ) from direct.showbase.ShowBase import ShowBase from direct.task import Task from pandac.PandaModules import * from db import DataBase from server import Server from game import Game from spell import Spell from spellmanager import SpellManager game_tick=1.0/60.0 num_users=5 class ServerInst(): def __init__(self): # Initialise Window self.showbase=ShowBase() # Disable Mouse Control for camera self.showbase.disableMouse()
from LoadingScreen import LoadingScreen from VehicleAttributes import VehicleAttributes from rrTrack import Track # afrom Chat import Chat # """ Custom Imports """ # import your modules from common.Constants import Constants from net.ConnectionManager import ConnectionManager from rrDashboard import * from threading import Thread from time import sleep import re from pandac.PandaModules import loadPrcFileData loadPrcFileData('', 'bullet-enable-contact-events true') SPEED = 0.5 def getDimensions(nPath): pt1, pt2 = nPath.getTightBounds() xDim = pt2.getX() - pt1.getX() yDim = pt2.getY() - pt1.getY() zDim = pt2.getZ() - pt1.getZ() return [xDim, yDim, zDim] path = ['f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', # 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', # 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b',
__author__ = 'dthakurta' # by FenrirWolf (David Grace) 7/2009 # Free for use by all under the Panda license # Purpose: Demonstrates how to use Panda physics with a collisions to generate spheres which bounce on a ground # plane. from pandac.PandaModules import loadPrcFileData loadPrcFileData('', ''' show-frame-rate-meter #t //want-tk #t //want-directtools #t''') from pandac.PandaModules import * # lazy git import direct.directbase.DirectStart from random import random # Set up the collision traverser. If we bind it to base.cTrav, then Panda will handle # management of this traverser (for example, by calling traverse() automatically for us once per frame) base.cTrav = CollisionTraverser() # Turn on particles. (Required to use Panda physics) base.enableParticles() # Turn on the traverser debugger if you want to see the collisions #base.cTrav.showCollisions (base.render) # Having trouble figuring out what's going on with messages? Turn this on. #messenger.toggleVerbose()