def readFavIcon(self): vfs = VirtualFileSystem.getGlobalPtr() filename = Filename('favicon.ico') searchPath = DSearchPath() searchPath.appendDirectory(Filename('.')) searchPath.appendDirectory(Filename('etc')) searchPath.appendDirectory(Filename.fromOsSpecific(os.path.expandvars('$DIRECT/src/http'))) searchPath.appendDirectory(Filename.fromOsSpecific(os.path.expandvars('direct/src/http'))) searchPath.appendDirectory(Filename.fromOsSpecific(os.path.expandvars('direct/http'))) found = vfs.resolveFilename(filename,searchPath) if not found: raise "Couldn't find direct/http/favicon.ico" return vfs.readFile(filename, 1)
from panda3d.pandac import PointLight, AmbientLight from panda3d.pandac import LightRampAttrib, AuxBitplaneAttrib from panda3d.pandac import CardMaker from panda3d.pandac import Shader, Texture from panda3d.pandac import Point3, Vec4, Vec3 from panda3d.direct.task.Task import Task from panda3d.direct.actor.Actor import Actor from panda3d.direct.gui.OnscreenText import OnscreenText from panda3d.direct.showbase.DirectObject import DirectObject from panda3d.direct.showbase.BufferViewer import BufferViewer from panda3d.direct.filter.CommonFilters import CommonFilters import sys, os # Figure out what directory this program is in. MYDIR = os.path.abspath(sys.path[0]) MYDIR = Filename.fromOsSpecific(MYDIR).getFullpath() font = loader.loadFont("cmss12") # Function to put instructions on the screen. def addInstructions(pos, msg): return OnscreenText(text=msg, style=1, fg=(1, 1, 1, 1), font=font, pos=(-1.3, pos), align=TextNode.ALeft, scale=.05)
def __init__(self, path): self.dir_path = Filename.fromOsSpecific(path)
def getdata(self, path): path = Filename(self.dir_path, Filename.fromOsSpecific(path)) f = open(path, 'rb') return f.read()
from panda3d.pandac import PointLight, AmbientLight from panda3d.pandac import LightRampAttrib, AuxBitplaneAttrib from panda3d.pandac import CardMaker from panda3d.pandac import Shader, Texture from panda3d.pandac import Point3,Vec4,Vec3 from panda3d.direct.task.Task import Task from panda3d.direct.actor.Actor import Actor from panda3d.direct.gui.OnscreenText import OnscreenText from panda3d.direct.showbase.DirectObject import DirectObject from panda3d.direct.showbase.BufferViewer import BufferViewer from panda3d.direct.filter.CommonFilters import CommonFilters import sys,os # Figure out what directory this program is in. MYDIR=os.path.abspath(sys.path[0]) MYDIR=Filename.fromOsSpecific(MYDIR).getFullpath() font = loader.loadFont("cmss12") # Function to put instructions on the screen. def addInstructions(pos, msg): return OnscreenText(text=msg, style=1, fg=(1,1,1,1), font = font, pos=(-1.3, pos), align=TextNode.ALeft, scale = .05) # Function to put title on the screen. def addTitle(text): return OnscreenText(text=text, style=1, fg=(1,1,1,1), font = font, pos=(1.3,-0.95), align=TextNode.ARight, scale = .07) class ToonMaker(DirectObject): def __init__(self):
def loadShader(self, name): fn = os.path.join(PANDA_SHADER_PATH, name) fn = Filename.fromOsSpecific(fn) fn.makeTrueCase() return Shader.load(fn)
def runPackedApp(args): if not args: raise ArgumentError, "No Panda app specified. Use:\npython RunAppMF.py app.mf" vfs = VirtualFileSystem.getGlobalPtr() fname = Filename.fromOsSpecific(args[0]) if not vfs.exists(fname): raise ArgumentError, "No such file: %s" % (args[0]) mf = Multifile() if not mf.openRead(fname): raise ArgumentError, "Not a Panda Multifile: %s" % (args[0]) # Clear *all* the mount points, including "/", so that we no # longer access the disk directly. vfs.unmountAll() # Mount the Multifile under /mf, by convention, and make that our # "current directory". vfs.mount(mf, MultifileRoot, vfs.MFReadOnly) vfs.chdir(MultifileRoot) # Make sure the directories on our standard Python path are mounted # read-only, so we can still load Python. for dirname in sys.path: vfs.mount(dirname, dirname, vfs.MFReadOnly) # Also mount some standard directories read-write (temporary and # app-data directories). tdir = Filename.temporary('', '') for dirname in set([ tdir.getDirname(), Filename.getTempDirectory().cStr(), Filename.getUserAppdataDirectory().cStr(), Filename.getCommonAppdataDirectory().cStr() ]): vfs.mount(dirname, dirname, 0) # Now set up Python to import this stuff. VFSImporter.register() sys.path = [ MultifileRoot ] + sys.path # Put our root directory on the model-path and prc-path, too. getModelPath().prependDirectory(MultifileRoot) # Load the implicit App.prc file. loadPrcFileData(AppPrcFilename, AppPrc) # Load any prc files in the root. We have to load them # explicitly, since the ConfigPageManager can't directly look # inside the vfs. for f in vfs.scanDirectory(MultifileRoot): if f.getFilename().getExtension() == 'prc': data = f.readFile(True) loadPrcFileData(f.getFilename().cStr(), data) # Replace the builtin open and file symbols so user code will get # our versions by default, which can open and read files out of # the multifile. __builtin__.file = file.file __builtin__.open = file.open os.listdir = file.listdir os.walk = file.walk import main if hasattr(main, 'main') and callable(main.main): main.main()