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.
- get_file_type(n: int) LoaderFileType
Returns the file type of the nth file on the result list.
- __init__(name: str)
- static get_class_type() TypeHandle
- static get_global_ptr() Loader
Returns a pointer to the global Loader. This is the Loader that most code should use for loading models.
- get_task_manager() AsyncTaskManager
Returns the task manager that is used for asynchronous loads.
- load_async(request: AsyncTask)
Begins an asynchronous load request. To use this call, first call
make_async_request()
to create a newModelLoadRequest
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().
- load_bam_stream(in: istream) PandaNode
Attempts to read a bam file from the indicated stream and return the scene graph defined there.
- load_sync(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.
- make_async_request(filename: Filename, options: LoaderOptions) AsyncTask
Returns a new
AsyncTask
object suitable for adding toload_async()
to start an asynchronous model load.
- make_async_save_request(filename: Filename, options: LoaderOptions, node: PandaNode) AsyncTask
Returns a new
AsyncTask
object suitable for adding tosave_async()
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.
- save_async(request: AsyncTask)
Begins an asynchronous save request. To use this call, first call
make_async_save_request()
to create a newModelSaveRequest
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().
- save_sync(filename: Filename, options: LoaderOptions, node: PandaNode) bool
Saves the file immediately, waiting for it to complete.
- set_task_chain(task_chain: str)
Specifies the task chain that is used for asynchronous loads. The default is the initial name of the Loader object.
- set_task_manager(task_manager: AsyncTaskManager)
Specifies the task manager that is used for asynchronous loads. The default is the global task manager.
- stop_threads()
Stop any threads used for asynchronous loads.