# Loader

from direct.showbase.Loader import Loader

Load models, textures, sounds, and code.

## Inheritance:

Loader: DirectObject
DirectObject:

## Methods of Loader:

__asyncFlattenDone
__gotAsyncObject
__init__
asyncFlattenStrong
cancelRequest
destroy
isRequestPending
load3DTexture
loadCubeMap
loadFont
loadModel
loadModelCopy
loadModelNode
loadModelOnce
loadMusic
loadSfx
loadShader
loadSound
loadTexture
unloadModel
unloadSfx
unloadShader
unloadTexture

## Methods of DirectObject:

__init__
accept
acceptOnce
classTree
getAllAccepting
ignore
ignoreAll
isAccepting
isIgnoring

__asyncFlattenDone def __asyncFlattenDone(self, models, gotList, callback, origModelList, extraArgs) The asynchronous flatten operation has completed; quietly drop in the new models.

__gotAsyncObject def __gotAsyncObject(self, request) A model or sound file or some such thing has just been loaded asynchronously by the sub-thread. Add it to the list of loaded objects, and call the appropriate callback when it's time.

__init__ def __init__(self, base) Undocumented function.

asyncFlattenStrong def asyncFlattenStrong(self, model, inPlace=True, callback=None, extraArgs=[]) Performs a model.flattenStrong() operation in a sub-thread (if threading is compiled into Panda). The model may be a single NodePath, or it may be a list of NodePaths. Each model is duplicated and flattened in the sub-thread. If inPlace is True, then when the flatten operation completes, the newly flattened copies are automatically dropped into the scene graph, in place the original models. If a callback is specified, then it is called after the operation is finished, receiving the flattened model (or a list of flattened models).

cancelRequest def cancelRequest(self, cb) Cancels an aysynchronous loading or flatten request issued earlier. The callback associated with the request will not be called after cancelRequest() has been performed.

destroy def destroy(self) Undocumented function.

isRequestPending def isRequestPending(self, cb) Returns true if an asynchronous loading or flatten request issued earlier is still pending, or false if it has completed or been cancelled.

load3DTexture def load3DTexture(self, texturePattern, readMipmaps=False) texturePattern is a string that contains a sequence of one or more '#' characters, which will be filled in with the sequence number. Returns a 3-D Texture object, suitable for rendering volumetric textures, if successful, or None if not.

loadCubeMap def loadCubeMap(self, texturePattern, readMipmaps=False) texturePattern is a string that contains a sequence of one or more '#' characters, which will be filled in with the sequence number. Returns a six-face cube map Texture object if successful, or None if not.

loadFont def loadFont(self, modelPath, spaceAdvance=None, pointSize=None, pixelsPerUnit=None, scaleFactor=None, textureMargin=None, polyMargin=None, minFilter=None, magFilter=None, anisotropicDegree=None, lineHeight=None) modelPath is a string. This loads a special model as a TextFont object, for rendering text with a TextNode. A font file must be either a special egg file (or bam file) generated with egg-mkfont, or a standard font file (like a TTF file) that is supported by FreeType.

loadModel def loadModel(self, modelPath, loaderOptions=None, noCache=None, allowInstance=False, callback=None, extraArgs=[]) Attempts to load a model or models from one or more relative pathnames. If the input modelPath is a string (a single model pathname), the return value will be a NodePath to the model loaded if the load was successful, or None otherwise. If the input modelPath is a list of pathnames, the return value will be a list of NodePaths and/or Nones. loaderOptions may optionally be passed in to control details about the way the model is searched and loaded. See the LoaderOptions class for more. The default is to look in the ModelPool (RAM) cache first, and return a copy from that if the model can be found there. If the bam cache is enabled (via the model-cache-dir config variable), then that will be consulted next, and if both caches fail, the file will be loaded from disk. If noCache is True, then neither cache will be consulted or updated. If callback is not None, then the model load will be performed asynchronously. In this case, loadModel() will initiate a background load and return immediately. The return value will be an object that may later be passed to loader.cancelRequest() to cancel the asynchronous request. At some later point, when the requested model(s) have finished loading, the callback function will be invoked with the n loaded models passed as its parameter list. It is possible that the callback will be invoked immediately, even before loadModel() returns. True asynchronous model loading requires Panda to have been compiled with threading support enabled (you can test Thread.isThreadingSupported()). In the absence of threading support, the asynchronous interface still exists and still behaves exactly as described, except that loadModel() might not return immediately.

loadModelCopy def loadModelCopy(self, modelPath, loaderOptions=None) loadModelCopy(self, string) Attempt to load a model from modelPool, if not present then attempt to load it from disk. Return a nodepath to a copy of the model if successful or None otherwise

loadModelNode def loadModelNode(self, modelPath) modelPath is a string. This is like loadModelOnce in that it loads a model from the modelPool, but it does not then instance it to hidden and it returns a Node instead of a NodePath. This is particularly useful for special models like fonts that you don't care about where they're parented to, and you don't want a NodePath anyway--it prevents accumulation of instances of the font model under hidden. However, if you're loading a font, see loadFont(), below.

loadModelOnce def loadModelOnce(self, modelPath) modelPath is a string. Attempt to load a model from modelPool, if not present then attempt to load it from disk. Return a nodepath to the model if successful or None otherwise

loadMusic def loadMusic(self, *args, **kw) Loads one or more sound files, specifically designated as a "music" file (that is, uses the musicManager to load the sound). There is no distinction between sound effect files and music files other than the particular AudioManager used to load the sound file, but this distinction allows the sound effects and/or the music files to be adjusted as a group, independently of the other group.

loadSfx def loadSfx(self, *args, **kw) Loads one or more sound files, specifically designated as a "sound effect" file (that is, uses the sfxManager to load the sound). There is no distinction between sound effect files and music files other than the particular AudioManager used to load the sound file, but this distinction allows the sound effects and/or the music files to be adjusted as a group, independently of the other group.

loadShader def loadShader(self, shaderPath) Undocumented function.

loadSound def loadSound(self, manager, soundPath, positional=False, callback=None, extraArgs=[]) Loads one or more sound files, specifying the particular AudioManager that should be used to load them. The soundPath may be either a single filename, or a list of filenames. If a callback is specified, the loading happens in the background, just as in loadModel(); otherwise, the loading happens before loadSound() returns.

loadTexture def loadTexture(self, texturePath, alphaPath=None, readMipmaps=False) texturePath is a string. Attempt to load a texture from the given file path using TexturePool class. Returns None if not found

unloadModel def unloadModel(self, model) model is the return value of loadModel(). For backward compatibility, it may also be the filename that was passed to loadModel(), though this requires a disk search.

unloadSfx def unloadSfx(self, sfx) Undocumented function.

unloadShader def unloadShader(self, shaderPath) Undocumented function.

unloadTexture def unloadTexture(self, texture) Removes the previously-loaded texture from the cache, so that when the last reference to it is gone, it will be released. This also means that the next time the same texture is loaded, it will be re-read from disk (and duplicated in texture memory if there are still outstanding references to it). The texture parameter may be the return value of any previous call to loadTexture(), load3DTexture(), or loadCubeMap().

__init__ def __init__(self) Undocumented function.

accept def accept(self, event, method, extraArgs=[]) Undocumented function.

acceptOnce def acceptOnce(self, event, method, extraArgs=[]) Undocumented function.

classTree def classTree(self) Undocumented function.

getAllAccepting def getAllAccepting(self) Undocumented function.

ignore def ignore(self, event) Undocumented function.

ignoreAll def ignoreAll(self) Undocumented function.

isAccepting def isAccepting(self, event) Undocumented function.

isIgnoring def isIgnoring(self, event) Undocumented function.