panda3d.core.Loader

from panda3d.core import Loader
class Loader

Bases: TypedReferenceCount, Namable

A convenient class for loading models from disk, in bam or egg format (or any of a number of other formats implemented by a LoaderFileType, such as ptloader).

This class supports synchronous as well as asynchronous loading. In asynchronous loading, the model is loaded in the background by a thread, and an event will be generated when the model is available. If threading is not available, the asynchronous loading interface may be used, but it loads synchronously.

Inheritance diagram

Inheritance diagram of Loader

class Results
__init__() → None
__init__(copy: Results) → None
assign(copy: Results) → Results
Return type

Results

clear() → None

Removes all the files from the list.

getFile(n: int) → Filename

Returns the nth file on the result list.

Return type

Filename

getFileType(n: int) → LoaderFileType

Returns the file type of the nth file on the result list.

Return type

LoaderFileType

getFileTypes() → list
getFiles() → list
getNumFiles() → int

Returns the number of files on the result list.

__init__(param0: Loader) → None
__init__(name: str) → None
static getClassType() → TypeHandle
Return type

TypeHandle

static getGlobalPtr() → Loader

Returns a pointer to the global Loader. This is the Loader that most code should use for loading models.

Return type

Loader

getTaskChain() → str

Returns the task chain that is used for asynchronous loads.

getTaskManager() → AsyncTaskManager

Returns the task manager that is used for asynchronous loads.

Return type

AsyncTaskManager

loadAsync(request: AsyncTask) → None

Begins an asynchronous load request. To use this call, first call makeAsyncRequest() to create a new ModelLoadRequest object with the filename you wish to load, and then add that object to the Loader with load_async. This function will return immediately, and the model will be loaded in the background.

To determine when the model has completely loaded, you may poll request->is_ready() from time to time, or set the done_event on the request object and listen for that event. When the model is ready, you may retrieve it via request->get_model().

loadBamStream(in: istream) → PandaNode

Attempts to read a bam file from the indicated stream and return the scene graph defined there.

Return type

PandaNode

loadSync(filename: Filename, options: LoaderOptions) → PandaNode

Loads the file immediately, waiting for it to complete.

If search is true, the file is searched for along the model path; otherwise, only the exact filename is loaded.

Return type

PandaNode

makeAsyncRequest(filename: Filename, options: LoaderOptions) → AsyncTask

Returns a new AsyncTask object suitable for adding to loadAsync() to start an asynchronous model load.

Return type

AsyncTask

makeAsyncSaveRequest(filename: Filename, options: LoaderOptions, node: PandaNode) → AsyncTask

Returns a new AsyncTask object suitable for adding to saveAsync() to start an asynchronous model save.

Return type

AsyncTask

output(out: ostream) → None
remove(task: AsyncTask) → bool

Removes a pending asynchronous load request. Returns true if successful, false otherwise.

Deprecated: use task.cancel() to cancel the request instead.

saveAsync(request: AsyncTask) → None

Begins an asynchronous save request. To use this call, first call makeAsyncSaveRequest() to create a new ModelSaveRequest object with the filename you wish to load, and then add that object to the Loader with save_async. This function will return immediately, and the model will be loaded in the background.

To determine when the model has completely loaded, you may poll request->is_ready() from time to time, or set the done_event on the request object and listen for that event. When the request is ready, you may retrieve the success or failure via request->get_success().

saveSync(filename: Filename, options: LoaderOptions, node: PandaNode) → bool

Saves the file immediately, waiting for it to complete.

setTaskChain(task_chain: str) → None

Specifies the task chain that is used for asynchronous loads. The default is the initial name of the Loader object.

setTaskManager(task_manager: AsyncTaskManager) → None

Specifies the task manager that is used for asynchronous loads. The default is the global task manager.

stopThreads() → None

Stop any threads used for asynchronous loads.