Panda3D
Classes | Public Member Functions | Static Public Member Functions | List of all members
Loader Class Reference

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). More...

Inheritance diagram for Loader:
TypedReferenceCount Namable TypedObject ReferenceCount

Classes

class  Results
 

Public Member Functions

 __init__ (const Loader)
 
 __init__ (str name)
 
str getTaskChain ()
 Returns the task chain that is used for asynchronous loads. More...
 
AsyncTaskManager getTaskManager ()
 Returns the task manager that is used for asynchronous loads. More...
 
 loadAsync (AsyncTask request)
 Begins an asynchronous load request. More...
 
PandaNode loadBamStream (Istream in)
 Attempts to read a bam file from the indicated stream and return the scene graph defined there. More...
 
PandaNode loadSync (const Filename filename, const LoaderOptions options)
 Loads the file immediately, waiting for it to complete. More...
 
AsyncTask makeAsyncRequest (const Filename filename, const LoaderOptions options)
 Returns a new AsyncTask object suitable for adding to load_async() to start an asynchronous model load. More...
 
AsyncTask makeAsyncSaveRequest (const Filename filename, const LoaderOptions options, PandaNode node)
 Returns a new AsyncTask object suitable for adding to save_async() to start an asynchronous model save. More...
 
 output (Ostream out)
 
bool remove (AsyncTask task)
 Removes a pending asynchronous load request. More...
 
 saveAsync (AsyncTask request)
 Begins an asynchronous save request. More...
 
bool saveSync (const Filename filename, const LoaderOptions options, PandaNode node)
 Saves the file immediately, waiting for it to complete. More...
 
 setTaskChain (str task_chain)
 Specifies the task chain that is used for asynchronous loads. More...
 
 setTaskManager (AsyncTaskManager task_manager)
 Specifies the task manager that is used for asynchronous loads. More...
 
 stopThreads ()
 Stop any threads used for asynchronous loads. More...
 
- Public Member Functions inherited from TypedObject
TypeHandle getType ()
 
int getTypeIndex ()
 Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. More...
 
bool isExactType (TypeHandle handle)
 Returns true if the current object is the indicated type exactly. More...
 
bool isOfType (TypeHandle handle)
 Returns true if the current object is or derives from the indicated type. More...
 
- Public Member Functions inherited from ReferenceCount
int getRefCount ()
 Returns the current reference count. More...
 
 ref ()
 Explicitly increments the reference count. More...
 
bool testRefCountIntegrity ()
 Does some easy checks to make sure that the reference count isn't completely bogus. More...
 
bool testRefCountNonzero ()
 Does some easy checks to make sure that the reference count isn't zero, or completely bogus. More...
 
bool unref ()
 Explicitly decrements the reference count. More...
 
- Public Member Functions inherited from Namable
 __init__ (const Namable)
 
 __init__ (str initial_name)
 
 clearName ()
 Resets the Namable's name to empty. More...
 
str getName ()
 
bool hasName ()
 Returns true if the Namable has a nonempty name set, false if the name is empty. More...
 
 output (Ostream out)
 Outputs the Namable. More...
 
 setName (str name)
 

Static Public Member Functions

static TypeHandle getClassType ()
 
static Loader getGlobalPtr ()
 Returns a pointer to the global Loader. More...
 
- Static Public Member Functions inherited from TypedReferenceCount
static TypeHandle getClassType ()
 
- Static Public Member Functions inherited from TypedObject
static TypeHandle getClassType ()
 
- Static Public Member Functions inherited from ReferenceCount
static TypeHandle getClassType ()
 
- Static Public Member Functions inherited from Namable
static TypeHandle getClassType ()
 

Additional Inherited Members

- Public Attributes inherited from TypedObject
TypeHandle type
 Returns the TypeHandle representing this object's type. More...
 
- Public Attributes inherited from ReferenceCount
int ref_count
 The current reference count. More...
 
- Public Attributes inherited from Namable
const String name
 

Detailed Description

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.

Member Function Documentation

◆ __init__() [1/2]

__init__ ( const  Loader)

◆ __init__() [2/2]

__init__ ( str  name)

◆ getClassType()

static TypeHandle getClassType ( )
static

◆ getGlobalPtr()

static Loader getGlobalPtr ( )
static

Returns a pointer to the global Loader.

This is the Loader that most code should use for loading models.

◆ getTaskChain()

str getTaskChain ( )

Returns the task chain that is used for asynchronous loads.

◆ getTaskManager()

AsyncTaskManager getTaskManager ( )

Returns the task manager that is used for asynchronous loads.

◆ loadAsync()

loadAsync ( AsyncTask  request)

Begins an asynchronous load request.

To use this call, first call make_async_request() 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()

PandaNode loadBamStream ( Istream  in)

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

◆ loadSync()

PandaNode loadSync ( const Filename  filename,
const LoaderOptions  options 
)

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()

AsyncTask makeAsyncRequest ( const Filename  filename,
const LoaderOptions  options 
)

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

◆ makeAsyncSaveRequest()

AsyncTask makeAsyncSaveRequest ( const Filename  filename,
const LoaderOptions  options,
PandaNode  node 
)

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

◆ output()

output ( Ostream  out)

◆ remove()

bool remove ( AsyncTask  task)

Removes a pending asynchronous load request.

Returns true if successful, false otherwise.

◆ saveAsync()

saveAsync ( AsyncTask  request)

Begins an asynchronous save request.

To use this call, first call make_async_save_request() 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()

bool saveSync ( const Filename  filename,
const LoaderOptions  options,
PandaNode  node 
)

Saves the file immediately, waiting for it to complete.

◆ setTaskChain()

setTaskChain ( str  task_chain)

Specifies the task chain that is used for asynchronous loads.

The default is the initial name of the Loader object.

◆ setTaskManager()

setTaskManager ( AsyncTaskManager  task_manager)

Specifies the task manager that is used for asynchronous loads.

The default is the global task manager.

◆ stopThreads()

stopThreads ( )

Stop any threads used for asynchronous loads.