本文整理汇总了Python中panda3d.core.VirtualFileSystem.getGlobalPtr方法的典型用法代码示例。如果您正苦于以下问题:Python VirtualFileSystem.getGlobalPtr方法的具体用法?Python VirtualFileSystem.getGlobalPtr怎么用?Python VirtualFileSystem.getGlobalPtr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类panda3d.core.VirtualFileSystem
的用法示例。
在下文中一共展示了VirtualFileSystem.getGlobalPtr方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: reloadTextures
# 需要导入模块: from panda3d.core import VirtualFileSystem [as 别名]
# 或者: from panda3d.core.VirtualFileSystem import getGlobalPtr [as 别名]
def reloadTextures(textureName=""):
"""
Artfart command to reload all of the textures.
TODO: A panel that says "Reloading textures... Please wait!"
...though it's not important since it's a staff command and
only staff will see it.
Stolen from ToontownStart.py
Remount all phase files. This maybe might work? Idk. Lets see
if Panda craps itself.
Place raw files in /resources/non-mf/phase_*/ and they will be
mounted without needing to multify!
"""
# Lock ...
vfs = VirtualFileSystem.getGlobalPtr()
for file in glob.glob("resources/non-mf/phase_*/"):
# Slightly hacky. We remove the trailing slash so we have a tail,
# and select the tail value from the returned tuple. Finally we
# prepend a slash for the mount point.
mount_point = "/" + str(os.path.split(file[:-1])[1])
vfs.mount(Filename(file), Filename(mount_point), 0)
# ... and load.
if textureName:
pool = TexturePool.findAllTextures("*" + textureName + "*")
else:
pool = TexturePool.findAllTextures()
for texture in pool:
texture.reload()
if textureName:
return "Reloaded all textures matching '%s'" % textureName
return "Reloaded all of the textures!"
示例2: dummyAppRunner
# 需要导入模块: from panda3d.core import VirtualFileSystem [as 别名]
# 或者: from panda3d.core.VirtualFileSystem import getGlobalPtr [as 别名]
def dummyAppRunner(tokens = [], argv = None):
""" This function creates a dummy global AppRunner object, which
is useful for testing running in a packaged environment without
actually bothering to package up the application. Call this at
the start of your application to enable it.
It places the current working directory under /mf, as if it were
mounted from a packed multifile. It doesn't convert egg files to
bam files, of course; and there are other minor differences from
running in an actual packaged environment. But it can be a useful
first-look sanity check. """
if AppRunnerGlobal.appRunner:
print("Already have AppRunner, not creating a new one.")
return AppRunnerGlobal.appRunner
appRunner = AppRunner()
appRunner.dummy = True
AppRunnerGlobal.appRunner = appRunner
platform = PandaSystem.getPlatform()
version = PandaSystem.getPackageVersionString()
hostUrl = PandaSystem.getPackageHostUrl()
if platform.startswith('win'):
rootDir = Filename(Filename.getUserAppdataDirectory(), 'Panda3D')
elif platform.startswith('osx'):
rootDir = Filename(Filename.getHomeDirectory(), 'Library/Caches/Panda3D')
else:
rootDir = Filename(Filename.getHomeDirectory(), '.panda3d')
appRunner.rootDir = rootDir
appRunner.logDirectory = Filename(rootDir, 'log')
# Of course we will have the panda3d application loaded.
appRunner.addPackageInfo('panda3d', platform, version, hostUrl)
appRunner.tokens = tokens
appRunner.tokenDict = dict(tokens)
if argv is None:
argv = sys.argv
appRunner.argv = argv
appRunner.altHost = appRunner.tokenDict.get('alt_host', None)
appRunner.p3dInfo = None
appRunner.p3dPackage = None
# Mount the current directory under the multifileRoot, as if it
# were coming from a multifile.
cwd = ExecutionEnvironment.getCwd()
vfs = VirtualFileSystem.getGlobalPtr()
vfs.mount(cwd, appRunner.multifileRoot, vfs.MFReadOnly)
appRunner.initPackedAppEnvironment()
return appRunner
示例3: __init__
# 需要导入模块: from panda3d.core import VirtualFileSystem [as 别名]
# 或者: from panda3d.core.VirtualFileSystem import getGlobalPtr [as 别名]
def __init__(self, filepath):
self.filepath = filepath
self.vfs = VirtualFileSystem.getGlobalPtr()
if __debug__:
self.mountPoint = "../resources"
else:
self.mountPoint = "/"
self.sortOrder = []
示例4: loadText
# 需要导入模块: from panda3d.core import VirtualFileSystem [as 别名]
# 或者: from panda3d.core.VirtualFileSystem import getGlobalPtr [as 别名]
def loadText(self):
# Load database
vfs = VirtualFileSystem.getGlobalPtr()
#print "Virtual fs" ,vfs.lsAll('/mf')
path = vfs.findFile('TXT_UI_Common.yaml', '.')
if not path:
path = vfs.findFile('TXT_UI_Common.yaml', '/mf')
stream = vfs.readFile(path.getFilename(), True)
textDictionary = yaml.load(stream)
for key in textDictionary:
self.database[key] = textDictionary[key]
示例5: __init__
# 需要导入模块: from panda3d.core import VirtualFileSystem [as 别名]
# 或者: from panda3d.core.VirtualFileSystem import getGlobalPtr [as 别名]
def __init__(self, filepath='contentpacks/', sortFilename='sort.yaml'):
self.filepath = filepath
self.sortFilename = os.path.join(self.filepath, sortFilename)
if __debug__:
self.mountPoint = '../resources'
else:
self.mountPoint = '/'
self.vfs = VirtualFileSystem.getGlobalPtr()
self.sort = []
self.ambience = {}
示例6: ReadResponse
# 需要导入模块: from panda3d.core import VirtualFileSystem [as 别名]
# 或者: from panda3d.core.VirtualFileSystem import getGlobalPtr [as 别名]
def ReadResponse(self, dataOut, bytesToRead, bytesReadOut, callback):
if self.contents is None:
self.contents = VirtualFileSystem.getGlobalPtr().readFile(self.filePath, False)
if self.offset < len(self.contents):
dataOut[0] = self.contents[self.offset:self.offset + bytesToRead]
bytesReadOut[0] = bytesToRead
self.offset += bytesToRead
return True
# We are done
self.clientHandler._ReleaseStrongReference(self)
return False
示例7: GetResponseHeaders
# 需要导入模块: from panda3d.core import VirtualFileSystem [as 别名]
# 或者: from panda3d.core.VirtualFileSystem import getGlobalPtr [as 别名]
def GetResponseHeaders(self, response, responseLengthOut, redirectUrlOut):
"""
:type response: cefpython.PyResponse
"""
response.SetMimeType(getMimeType(self.url))
file = VirtualFileSystem.getGlobalPtr().getFile(self.filePath)
if file is None:
response.SetStatus(404)
response.SetStatusText("File not found")
return
responseLengthOut[0] = file.getFileSize()
示例8: findAllModelFilesInVFS
# 需要导入模块: from panda3d.core import VirtualFileSystem [as 别名]
# 或者: from panda3d.core.VirtualFileSystem import getGlobalPtr [as 别名]
def findAllModelFilesInVFS(phase_array):
models = []
vfs = VirtualFileSystem.getGlobalPtr()
for phase in phase_array:
fileList = vfs.scanDirectory(Filename(phase))
for fileName in fileList:
if fileName.get_filename().get_fullpath().endswith('.bam') or fileName.get_filename().get_fullpath().endswith('.egg') or fileName.get_filename().get_fullpath().endswith('.pz'):
if fileName.get_filename().get_fullpath() not in models:
models.append(fileName.get_filename().get_fullpath())
else:
fileList2 = vfs.scanDirectory(Filename(fileName.get_filename().get_fullpath()))
for fileName2 in fileList2:
if fileName2.get_filename().get_fullpath().endswith('.bam') or fileName2.get_filename().get_fullpath().endswith('.egg') or fileName2.get_filename().get_fullpath().endswith('.pz'):
if fileName2.get_filename().get_fullpath() not in models:
models.append(fileName2.get_filename().get_fullpath())
return models
示例9: initPackedAppEnvironment
# 需要导入模块: from panda3d.core import VirtualFileSystem [as 别名]
# 或者: from panda3d.core.VirtualFileSystem import getGlobalPtr [as 别名]
def initPackedAppEnvironment(self):
""" This function sets up the Python environment suitably for
running a packed app. It should only run once in any given
session (and it includes logic to ensure this). """
if self.packedAppEnvironmentInitialized:
return
self.packedAppEnvironmentInitialized = True
vfs = VirtualFileSystem.getGlobalPtr()
# Now set up Python to import this stuff.
VFSImporter.register()
sys.path.append(self.multifileRoot)
# Make sure that $MAIN_DIR is set to the p3d root before we
# start executing the code in this file.
ExecutionEnvironment.setEnvironmentVariable("MAIN_DIR", Filename(self.multifileRoot).toOsSpecific())
# Put our root directory on the model-path, too.
getModelPath().appendDirectory(self.multifileRoot)
if not self.trueFileIO:
# 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.
builtins.open = file.open
if sys.version_info < (3, 0):
builtins.file = file.open
builtins.execfile = file.execfile
os.listdir = file.listdir
os.walk = file.walk
os.path.join = file.join
os.path.isfile = file.isfile
os.path.isdir = file.isdir
os.path.exists = file.exists
os.path.lexists = file.lexists
os.path.getmtime = file.getmtime
os.path.getsize = file.getsize
sys.modules["glob"] = glob
self.checkDiskUsage()
示例10: fromFile
# 需要导入模块: from panda3d.core import VirtualFileSystem [as 别名]
# 或者: from panda3d.core.VirtualFileSystem import getGlobalPtr [as 别名]
def fromFile(self, packageDir, filename, pathname = None, st = None):
""" Reads the file information from the indicated file. If st
is supplied, it is the result of os.stat on the filename. """
vfs = VirtualFileSystem.getGlobalPtr()
filename = Filename(filename)
if pathname is None:
pathname = Filename(packageDir, filename)
self.filename = str(filename)
self.basename = filename.getBasename()
if st is None:
st = os.stat(pathname.toOsSpecific())
self.size = st.st_size
self.timestamp = int(st.st_mtime)
self.readHash(pathname)
示例11: mount
# 需要导入模块: from panda3d.core import VirtualFileSystem [as 别名]
# 或者: from panda3d.core.VirtualFileSystem import getGlobalPtr [as 别名]
def mount(self):
""" Inits the VFS Mounts """
self.debug("Setting up virtual filesystem.")
vfs = VirtualFileSystem.getGlobalPtr()
# Mount data and models
vfs.mountLoop(join(self.basePath, 'Data'), 'Data', 0)
vfs.mountLoop(join(self.basePath, 'Models'), 'Models', 0)
vfs.mountLoop(join(self.basePath, 'Config'), 'Config', 0)
# Ensure the pipeline write path exists, and if not, create it
if not isdir(self.writePath):
self.debug("Creating temp path, as it does not exist yet")
try:
os.makedirs(self.writePath, 0777)
except Exception, msg:
self.error("Failed to create temp path:",msg)
import sys
sys.exit(0)
示例12: mount
# 需要导入模块: from panda3d.core import VirtualFileSystem [as 别名]
# 或者: from panda3d.core.VirtualFileSystem import getGlobalPtr [as 别名]
def mount(self):
""" Inits the VFS Mounts """
self.debug("Setting up virtual filesystem.")
vfs = VirtualFileSystem.getGlobalPtr()
# Mount shaders
vfs.mountLoop(
join(self.basePath, 'Shader'), 'Shader', 0)
# Mount data
vfs.mountLoop(join(self.basePath, 'Data'), 'Data', 0)
# TODO: Mount core
if not isdir(self.writePath):
self.debug("Creating temp path, as it does not exist yet")
try:
makedirs(self.writePath)
except Exception, msg:
self.error("Failed to create temp path:",msg)
import sys
sys.exit(0)
示例13: inspect
# 需要导入模块: from panda3d.core import VirtualFileSystem [as 别名]
# 或者: from panda3d.core.VirtualFileSystem import getGlobalPtr [as 别名]
__builtins__['jobMgr'] = simbase.jobMgr
__builtins__['eventMgr'] = simbase.eventMgr
__builtins__['messenger'] = simbase.messenger
__builtins__['bboard'] = simbase.bboard
__builtins__['config'] = simbase.config
__builtins__['directNotify'] = directNotify
from direct.showbase import Loader
simbase.loader = Loader.Loader(simbase)
__builtins__['loader'] = simbase.loader
directNotify.setDconfigLevels()
def inspect(anObject):
from direct.tkpanels import Inspector
Inspector.inspect(anObject)
__builtins__['inspect'] = inspect
if not __debug__ and __dev__:
notify = directNotify.newCategory('ShowBaseGlobal')
notify.error("You must set 'want-dev' to false in non-debug mode.")
taskMgr.finalInit()
# The VirtualFileSystem, which has already initialized, doesn't see the mount
# directives in the config(s) yet. We have to force it to load those manually:
from panda3d.core import VirtualFileSystem, ConfigVariableList, Filename
vfs = VirtualFileSystem.getGlobalPtr()
mounts = ConfigVariableList('vfs-mount')
for mount in mounts:
mountfile, mountpoint = (mount.split(' ', 2) + [None, None, None])[:2]
vfs.mount(Filename(mountfile), Filename(mountpoint), 0)
示例14: installPackage
# 需要导入模块: from panda3d.core import VirtualFileSystem [as 别名]
# 或者: from panda3d.core.VirtualFileSystem import getGlobalPtr [as 别名]
def installPackage(self, appRunner):
""" Mounts the package and sets up system paths so it becomes
available for use. Returns true on success, false on failure. """
assert self.hasPackage
if self.installed:
# Already installed.
return True
assert self not in appRunner.installedPackages
mfPathname = Filename(self.getPackageDir(), self.uncompressedArchive.filename)
mf = Multifile()
if not mf.openRead(mfPathname):
self.notify.warning("Couldn't open %s" % (mfPathname))
return False
# We mount it under its actual location on disk.
root = self.getPackageDir()
vfs = VirtualFileSystem.getGlobalPtr()
vfs.mount(mf, root, vfs.MFReadOnly)
# Add this to the Python search path, if it's not already
# there. We have to take a bit of care to check if it's
# already there, since there can be some ambiguity in
# os-specific path strings.
osRoot = self.getPackageDir().toOsSpecific()
foundOnPath = False
for p in sys.path:
if osRoot == p:
# Already here, exactly.
foundOnPath = True
break
elif osRoot == Filename.fromOsSpecific(p).toOsSpecific():
# Already here, with some futzing.
foundOnPath = True
break
if not foundOnPath:
# Not already here; add it.
sys.path.append(osRoot)
# Put it on the model-path, too. We do this indiscriminantly,
# because the Panda3D runtime won't be adding things to the
# model-path, so it shouldn't be already there.
getModelPath().appendDirectory(self.getPackageDir())
# Set the environment variable to reference the package root.
envvar = '%s_ROOT' % (self.packageName.upper())
ExecutionEnvironment.setEnvironmentVariable(envvar, osRoot)
# Add the package root to the system paths.
if sys.platform.startswith('win'):
path = os.environ.get('PATH', '')
os.environ['PATH'] = "%s;%s" % (osRoot, path)
else:
path = os.environ.get('PATH', '')
os.environ['PATH'] = "%s:%s" % (osRoot, path)
path = os.environ.get('LD_LIBRARY_PATH', '')
os.environ['LD_LIBRARY_PATH'] = "%s:%s" % (osRoot, path)
if sys.platform == "darwin":
path = os.environ.get('DYLD_LIBRARY_PATH', '')
os.environ['DYLD_LIBRARY_PATH'] = "%s:%s" % (osRoot, path)
# Now that the environment variable is set, read all of the
# prc files in the package.
appRunner.loadMultifilePrcFiles(mf, self.getPackageDir())
# Also, find any toplevel Python packages, and add these as
# shared packages. This will allow different packages
# installed in different directories to share Python files as
# if they were all in the same directory.
for filename in mf.getSubfileNames():
if filename.endswith('/__init__.pyc') or \
filename.endswith('/__init__.pyo') or \
filename.endswith('/__init__.py'):
components = filename.split('/')[:-1]
moduleName = '.'.join(components)
VFSImporter.sharedPackages[moduleName] = True
# Fix up any shared directories so we can load packages from
# disparate locations.
VFSImporter.reloadSharedPackages()
self.installed = True
appRunner.installedPackages.append(self)
self.markUsed()
return True
示例15: setP3DFilename
# 需要导入模块: from panda3d.core import VirtualFileSystem [as 别名]
# 或者: from panda3d.core.VirtualFileSystem import getGlobalPtr [as 别名]
def setP3DFilename(self, p3dFilename, tokens, argv, instanceId,
interactiveConsole, p3dOffset = 0, p3dUrl = None):
""" Called by the browser to specify the p3d file that
contains the application itself, along with the web tokens
and/or command-line arguments. Once this method has been
called, the application is effectively started. """
# One day we will have support for multiple instances within a
# Python session. Against that day, we save the instance ID
# for this instance.
self.instanceId = instanceId
self.tokens = tokens
self.argv = argv
# We build up a token dictionary with care, so that if a given
# token appears twice in the token list, we record only the
# first value, not the second or later. This is consistent
# with the internal behavior of the core API.
self.tokenDict = {}
for token, keyword in tokens:
self.tokenDict.setdefault(token, keyword)
# Also store the arguments on sys, for applications that
# aren't instance-ready.
sys.argv = argv
# That means we now know the altHost in effect.
self.altHost = self.tokenDict.get('alt_host', None)
# Tell the browser that Python is up and running, and ready to
# respond to queries.
self.notifyRequest('onpythonload')
# Now go load the applet.
fname = Filename.fromOsSpecific(p3dFilename)
vfs = VirtualFileSystem.getGlobalPtr()
if not vfs.exists(fname):
raise ArgumentError, "No such file: %s" % (p3dFilename)
fname.makeAbsolute()
fname.setBinary()
mf = Multifile()
if p3dOffset == 0:
if not mf.openRead(fname):
raise ArgumentError, "Not a Panda3D application: %s" % (p3dFilename)
else:
if not mf.openRead(fname, p3dOffset):
raise ArgumentError, "Not a Panda3D application: %s at offset: %s" % (p3dFilename, p3dOffset)
# Now load the p3dInfo file.
self.p3dInfo = None
self.p3dPackage = None
self.p3dConfig = None
self.allowPythonDev = False
i = mf.findSubfile('p3d_info.xml')
if i >= 0 and hasattr(core, 'readXmlStream'):
stream = mf.openReadSubfile(i)
self.p3dInfo = core.readXmlStream(stream)
mf.closeReadSubfile(stream)
if self.p3dInfo:
self.p3dPackage = self.p3dInfo.FirstChildElement('package')
if self.p3dPackage:
self.p3dConfig = self.p3dPackage.FirstChildElement('config')
xhost = self.p3dPackage.FirstChildElement('host')
while xhost:
self.__readHostXml(xhost)
xhost = xhost.NextSiblingElement('host')
if self.p3dConfig:
allowPythonDev = self.p3dConfig.Attribute('allow_python_dev')
if allowPythonDev:
self.allowPythonDev = int(allowPythonDev)
guiApp = self.p3dConfig.Attribute('gui_app')
if guiApp:
self.guiApp = int(guiApp)
trueFileIO = self.p3dConfig.Attribute('true_file_io')
if trueFileIO:
self.trueFileIO = int(trueFileIO)
# The interactiveConsole flag can only be set true if the
# application has allow_python_dev set.
if not self.allowPythonDev and interactiveConsole:
raise StandardError, "Impossible, interactive_console set without allow_python_dev."
self.interactiveConsole = interactiveConsole
if self.allowPythonDev:
# Set the fps text to remind the user that
# allow_python_dev is enabled.
ConfigVariableString('frame-rate-meter-text-pattern').setValue('allow_python_dev %0.1f fps')
if self.guiApp:
init_app_for_gui()
self.initPackedAppEnvironment()
#.........这里部分代码省略.........