Loader
from panda3d.core import Loader
- class Loader
Bases:
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
- class Results
Bases:
- __init__()
- __init__(copy: Results)
- clear()
Removes all the files from the list.
- getFileType(n: int) LoaderFileType
Returns the file type of the nth file on the result list.
- __init__(name: str)
- static getClassType() TypeHandle
- static getGlobalPtr() Loader
Returns a pointer to the global Loader. This is the Loader that most code should use for loading models.
- getTaskManager() AsyncTaskManager
Returns the task manager that is used for asynchronous loads.
- loadAsync(request: AsyncTask)
Begins an asynchronous load request. To use this call, first call
makeAsyncRequest()
to create a newModelLoadRequest
object with the filename you wish to load, and then add that object to the Loader withloadAsync()
. 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.
- 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.
- makeAsyncRequest(filename: Filename, options: LoaderOptions) AsyncTask
Returns a new
AsyncTask
object suitable for adding toloadAsync()
to start an asynchronous model load.
- makeAsyncSaveRequest(filename: Filename, options: LoaderOptions, node: PandaNode) AsyncTask
Returns a new
AsyncTask
object suitable for adding tosaveAsync()
to start an asynchronous model save.
- 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)
Begins an asynchronous save request. To use this call, first call
makeAsyncSaveRequest()
to create a newModelSaveRequest
object with the filename you wish to load, and then add that object to the Loader withsaveAsync()
. 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)
Specifies the task chain that is used for asynchronous loads. The default is the initial name of the Loader object.
- setTaskManager(task_manager: AsyncTaskManager)
Specifies the task manager that is used for asynchronous loads. The default is the global task manager.
- stopThreads()
Stop any threads used for asynchronous loads.