def __init__(self): loadPrcFile("server-config.prc") ShowBase.__init__(self) self.__rotations = {} # Panda pollutes the global namespace. Some of the extra globals can be referred to in nicer ways # (for example self.render instead of render). The globalClock object, though, is only a global! We # create a reference to it here, in a way that won't upset PyFlakes. self.globalClock = __builtins__["globalClock"] # Set up physics: the ground plane and the capsule which represents the player. self.world = BulletWorld() # The ground first: shape = BulletPlaneShape(Vec3(0, 0, 1), 0) node = BulletRigidBodyNode("Ground") node.addShape(shape) np = self.render.attachNewNode(node) np.setPos(0, 0, 0) self.world.attachRigidBody(node) # Create a task to update the scene regularly. self.taskMgr.add(self.update, "UpdateTask")
def __init__(self, configFile): loadPrcFile(configFile) self.ignoreTypes = { '': ConfigVariableBool('ignore-client', True).getValue(), 'AI': ConfigVariableBool('ignore-AI', False).getValue(), 'UD': ConfigVariableBool('ignore-UD', False).getValue(), 'OV': ConfigVariableBool('ignore-OV', True).getValue() } self.wantOverwrite = ConfigVariableBool('overwrite-files', False).getValue() self.generateNonImportDclasses = ConfigVariableBool('generate-non-import-dclasses', False).getValue() self.wantInit = ConfigVariableBool('generate-init', False).getValue() self.dcfile = DCFile() self.dcfile.readAll() self.classesTuples = [] self.dclass2module = {} self.className2Fields = {} self.className2ImportSymbol = {} self.dclass2subclass = {} self.ignoredClasses = [] if not self.dcfile.allObjectsValid(): print 'There was an error reading the dcfile!' return self.readImports() if self.generateNonImportDclasses: self.readDclasses() if not os.path.isdir('output'): os.makedirs('./output') os.chdir('output') else: os.chdir('output') self.readClasses() self.readFields() print 'Done.'
import sys from math import pi, sin, cos from direct.showbase.ShowBase import ShowBase from direct.task import Task from direct.actor.Actor import Actor from direct.interval.IntervalGlobal import Sequence from panda3d.core import Point3 from direct.gui.OnscreenText import OnscreenText # Let's configure our Panda Project a little bit from pandac.PandaModules import loadPrcFile loadPrcFile("./conf/client.prc") class MyApp(ShowBase): def __init__(self): ShowBase.__init__(self) # Disable the camera trackball controls. self.disableMouse() # Setup Camera Control self.x, self.y, self.z = 0, -80, 5 self.walk_speed = 1 self.strafe_speed = 0.25 self.angle = 0 # Setup Menu toggles self.info_toggle = False
import asyncore from direct.showbase.ShowBase import ShowBase from direct.actor.Actor import Actor from panda3d.bullet import BulletCapsuleShape, BulletCharacterControllerNode, BulletPlaneShape, BulletRigidBodyNode, \ BulletWorld, ZUp from panda3d.core import AmbientLight, DirectionalLight, Point3, VBase4, Vec3, deg2Rad from pandac.PandaModules import loadPrcFile from ..scene import Scene loadPrcFile("client-config.prc") class Thing(object): __things = {} @classmethod def add(self, tag, node, node_path): thing = Thing() Thing.__things[tag] = thing thing.tag = tag thing.node = node thing.node_path = node_path def remove(self): del Thing.__things[self.tag] @classmethod def get_thing(self, tag): return self.__things[tag]
############################################################################### # # This file is part of Orbital Industry. # # Orbital Industry is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Orbital Industry is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # more details. # # You should have received a copy of the GNU General Public License along with # Orbital Industry. If not, see <http://www.gnu.org/licenses/>. # ############################################################################### from pandac.PandaModules import loadPrcFile loadPrcFile("conf/Config.prc") import direct.directbase.DirectStart from orbital.core import GameManager gameManager = GameManager() gameManager.demand('Menu') run()
from options import options # If we only need to print version, do this first and leave everything else # untouched. if options.print_version: try: f = Filename(EE.expandString("$MAIN_DIR/VERSION")).toOsSpecific() print open(f).read() except IOError: print "Version unknown. Can't find the VERSION file." sys.exit() from pandac.PandaModules import loadPrcFile from pandac.PandaModules import Filename # Config file should be loaded as soon as possible. loadPrcFile(Filename.expandFrom("$MAIN_DIR/etc/azure.prc")) from direct.showbase.ShowBase import ShowBase from core import Core class Azure(ShowBase): def __init__(self): """Program entry point.""" # TODO(Nemesis#13): rewrite ShowBase to not use globals. # This basically sets up our rendering node-tree, some builtins and # the master loop (which iterates each frame). ShowBase.__init__(self) # Turn off Panda3D's standard camera handling.
# Load the config from pandac.PandaModules import loadPrcFile loadPrcFile("appconfig.prc") # Import our application class from libs.Game import Game from libs.Input import Input # Instantiate and run the game game = Game() game.registerPlugin('input', Input()) game.run()
import sys # Load the config from pandac.PandaModules import loadPrcFile loadPrcFile("appconfig.prc") appName = sys.argv[1] app = __import__('examples.' + appName)
# --------------------------------------------------------------------------- # Cosmica - All rights reserved by NeuroJump Trademark 2018 # directapp.py # Written by Chris Lewis # --------------------------------------------------------------------------- # This is the main application, including client side panda code # --------------------------------------------------------------------------- import os from anw.func import globals from pandac.PandaModules import loadPrcFile, Filename, loadPrcFileData, WindowProperties from threading import Event loadPrcFile("data/config.prc") windowtitle = 'Cosmica (version %s%s)' % (globals.currentVersion,globals.currentVersionTag) loadPrcFileData('', 'window-title %s' % windowtitle) from direct.interval.IntervalGlobal import Func from direct.showbase.DirectObject import DirectObject from pandac.PandaModules import Point2, Point3, Vec3, Vec4, BitMask32 from pandac.PandaModules import Shader, ColorBlendAttrib from pandac.PandaModules import PandaNode, NodePath, Mat4 from direct.interval.SoundInterval import SoundInterval from app import Application class DirectApplication(Application, DirectObject): """A Direct Application includes the Panda Engine Code""" def __init__(self, sound=1, server='', galaxy='', empire='', password='', shipBattle=None, glow=1): self.shutdownFlag = Event() props = WindowProperties() props.setTitle('%s (Game = %s)' % (windowtitle, galaxy)) base.win.requestProperties(props) Application.__init__(self, server=server, galaxy=galaxy, empire=empire, password=password, shipBattle=shipBattle, glow=glow)
# An example of using pymetasurf to create objects in Panda3d # Written by Cas Rusnov <*****@*****.**> import pymetasurf import pymetasurf.shapes as shapes from pandac.PandaModules import loadPrcFile configfiles = ["./Config.prc",] for prc in configfiles: loadPrcFile(prc) import sys from direct.showbase.ShowBase import ShowBase from direct.showbase import DirectObject from direct.task import Task from direct.actor.Actor import Actor from direct.interval.IntervalGlobal import Sequence from panda3d.core import Point3, PointLight, VBase4, AmbientLight, Spotlight, Vec4, DirectionalLight, Material from panda3d.core import Geom, GeomVertexFormat, GeomVertexData, GeomVertexWriter, GeomNode, GeomTriangles from math import pi, sin, cos, tan, sqrt, exp, radians class spherical_coordinate(object): def __init__(self, rho=1, theta=0, phi=0): self.rho = rho self.theta = theta self.phi = phi @property def x(self): return self.rho * sin(radians(self.theta)) * cos(radians(self.phi))
import direct.directbase.DirectStart from direct.showbase.DirectObject import DirectObject #from direct.showbase.ShowBase import ShowBase #from direct.task import Task from direct.gui.DirectGui import * from pandac.PandaModules import * import sys from pandac.PandaModules import loadPrcFile loadPrcFile('./conf/client.prc') # Initialization esc_toggle = False class FPS(object,DirectObject): def __init__(self): self.initCollision() self.loadLevel() self.initPlayer() self.initHealth() #set this between 0.0 and 1.0 self.setHealth(.75) #exactly what you think this is BOOOOYYYYYYY def initHealth(self): #CardMaker will render a 2d card; we'll need a foreground and background card (fg and bd respectively) cmfg = CardMaker('fg') #tbh not sure what setFrame is doing here (stolen code)
GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, see <http://www.gnu.org/licenses/>. """ import sys import os try: from pandac.PandaModules import loadPrcFile from pandac.PandaModules import Filename except ImportError: print "It seems you haven't got Panda3D installed properly." sys.exit(1) # Config file should be loaded as soon as possible. loadPrcFile(Filename.fromOsSpecific(os.path.abspath(os.path.join(sys.path[0], "etc/azure.prc")))) from direct.showbase.ShowBase import ShowBase from direct.task import Task from pandac.PandaModules import * from core import Core class Azure(object): """Main class called by the top level main function (see below).""" def __init__(self): # This basically sets up our rendering node-tree, some builtins and # the master loop (which iterates each frame). ShowBase() # Turn off Panda3D's standard camera handling.
# TODO: Suppress Panda3d console output # TODO: Genericize card rendering # TODO: Handle not enough images import glob, math, os, random, sys from direct.showbase.ShowBase import ShowBase from direct.showbase.DirectObject import DirectObject from direct.task import Task from direct.interval.IntervalGlobal import * from panda3d.core import * # Load our custom, app-specific config file from pandac.PandaModules import loadPrcFile loadPrcFile("./etc/Config.prc") # TODO: Rewrite controls code class Controls(DirectObject): def __init__(self): self.mouseChangeX = 0 self.windowSizeX = base.win.getXSize() self.windowSizeY = base.win.getYSize() self.centerX = self.windowSizeX / 2 self.centerY = self.windowSizeY / 2 self.H = base.camera.getH() self.P = base.camera.getP() self.pos = base.camera.getPos() self.sensitivity = .5 self.speed = .2 self.walking = False
# # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # Entry point - sets up the plugin system by giving it the config file to load and then releases panda to do its thing... # Important: this must be first from pandac.PandaModules import loadPrcFile, loadPrcFileData loadPrcFile("config/settings.prc") loadPrcFileData("window-disable", "window-type none") import direct.directbase.DirectStart import direct.stdpy.file as pfile from direct.task import Task from bin.manager import * import sys #messenger.toggleVerbose() # Detect if we are in a multifile and, if so, jump through hoops that shouldn't exist... if base.appRunner!=None: print 'In multifile, root = '+base.appRunner.multifileRoot baseDir = base.appRunner.multifileRoot+'/'
from direct.gui.OnscreenText import OnscreenText from direct.gui.OnscreenImage import OnscreenImage from direct.task import Task from direct.interval.IntervalGlobal import * from direct.particles.Particles import Particles from direct.particles.ParticleEffect import ParticleEffect from pandac.PandaModules import * from pandac.PandaModules import loadPrcFile from pandac.PandaModules import TransparencyAttrib import direct.directbase.DirectStart import random import math import sys loadPrcFile("cfg.prc") #---------------------------------------------------------------------------------------- #------------------------------------------------------------------------------------------------------ #Class enviroment for construct enviroment #------------------------------------------------------------------------------------------------------ class Environment(DirectObject.DirectObject): #------------------------------------------------------------------------------------------------------ #Class constructor #------------------------------------------------------------------------------------------------------ def __init__(self): print "Loading (Level)" # add light dlight = DirectionalLight('my dlight')
import direct.directbase.DirectStart from pandac.PandaModules import loadPrcFile loadPrcFile('dependencies/config/general.prc') loadPrcFile('dependencies/config/release/dev.prc') from panda3d.core import TransparencyAttrib from direct.gui.DirectGui import * from panda3d.core import * from direct.gui.OnscreenText import OnscreenText from pandac.PandaModules import Vec3 from direct.task import Task import urllib2 import socket import sys import hashlib import os background=OnscreenImage(image = 'resources/phase_3/maps/background.jpg', pos = (0, 0, 0),parent=render2d) background.setTransparency(TransparencyAttrib.MAlpha) logo=OnscreenImage(image = 'resources/phase_3/maps/toontown-logo.png', pos = (0, 0, 0),parent=render2d) logo.setTransparency(TransparencyAttrib.MAlpha) logo.setScale(0.5) buttonup=OnscreenImage(image = 'resources/launcher/Button_Up.png', pos = (0, 0, 0)) buttonup.setTransparency(TransparencyAttrib.MAlpha) buttonup.setScale(0.0) buttondown=OnscreenImage(image = 'resources/launcher/Button_Down.png', pos = (0, 0, 0)) buttondown.setTransparency(TransparencyAttrib.MAlpha) buttondown.setScale(0.0)
#!/usr/bin/python import __builtin__ import sys #load default config import default default.load_panda_default() from pandac.PandaModules import loadPrcFile loadPrcFile(sys.path[0]+'/config.prc') from panda3d.core import ConfigVariableBool,ConfigVariableString,PStatClient from direct.fsm import FSM from direct.showbase.MessengerGlobal import messenger from direct.task.TaskManagerGlobal import taskMgr from screen.screen import Screen from screen.gaming.gentity import GEntity from server.serverproxy import ServerProxy from server import network if ConfigVariableBool('stats').getValue(): from tools import pstat class GameClient(FSM.FSM): def __init__(self): FSM.FSM.__init__(self, 'GameClient.fsm') self.defaultTransitions = { 'Game_setup':['Main_menu', 'Gaming'], 'Gaming':['Stats', 'Pause', 'Quit'], 'Init':['Intro'], 'Intro':['Main_menu'], 'Main_menu':['Options', 'Game_setup', 'Quit', 'Load_game'],
# you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # Entry point - sets up the plugin system by giving it the config file to load and then releases panda to do its thing... # Important: this must be first from pandac.PandaModules import loadPrcFile, loadPrcFileData loadPrcFile("config/settings.prc") loadPrcFileData("window-disable", "window-type none") import direct.directbase.DirectStart import direct.stdpy.file as pfile from direct.task import Task from bin.manager import * import sys #messenger.toggleVerbose() # Detect if we are in a multifile and, if so, jump through hoops that shouldn't exist... if base.appRunner != None: print 'In multifile, root = ' + base.appRunner.multifileRoot baseDir = base.appRunner.multifileRoot + '/'
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
if options.print_version: try: print open(EE.expandString("$MAIN_DIR/VERSION")).read() except IOError: print "Version unknown. Can't find the VERSION file." sys.exit() try: from pandac.PandaModules import loadPrcFile from pandac.PandaModules import Filename except ImportError: print "It seems you haven't got Panda3D installed properly." sys.exit(1) # Config file should be loaded as soon as possible. # TODO(Nemesis#13): this must get smarter loadPrcFile(EE.expandString("$MAIN_DIR/etc/azure.prc")) from direct.showbase.ShowBase import ShowBase from core import Core class Azure(ShowBase): """Main class called by the top level main function (see below).""" def __init__(self): # This basically sets up our rendering node-tree, some builtins and # the master loop (which iterates each frame). ShowBase.__init__(self) # Turn off Panda3D's standard camera handling. self.disableMouse() self.setBackgroundColor(0,0,0,1)