Panda3D
 All Classes Functions Variables Enumerations
modelLoadRequest.cxx
1 // Filename: modelLoadRequest.cxx
2 // Created by: drose (29Aug06)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "modelLoadRequest.h"
16 #include "loader.h"
17 #include "config_pgraph.h"
18 
19 TypeHandle ModelLoadRequest::_type_handle;
20 
21 ////////////////////////////////////////////////////////////////////
22 // Function: ModelLoadRequest::Constructor
23 // Access: Published
24 // Description: Create a new ModelLoadRequest, and add it to the loader
25 // via load_async(), to begin an asynchronous load.
26 ////////////////////////////////////////////////////////////////////
28 ModelLoadRequest(const string &name,
29  const Filename &filename, const LoaderOptions &options,
30  Loader *loader) :
31  AsyncTask(name),
32  _filename(filename),
33  _options(options),
34  _loader(loader),
35  _is_ready(false)
36 {
37 }
38 
39 ////////////////////////////////////////////////////////////////////
40 // Function: ModelLoadRequest::do_task
41 // Access: Protected, Virtual
42 // Description: Performs the task: that is, loads the one model.
43 ////////////////////////////////////////////////////////////////////
44 AsyncTask::DoneStatus ModelLoadRequest::
45 do_task() {
46  double delay = async_load_delay;
47  if (delay != 0.0) {
48  Thread::sleep(delay);
49  }
50 
51  _model = _loader->load_sync(_filename, _options);
52  _is_ready = true;
53 
54  // Don't continue the task; we're done.
55  return DS_done;
56 }
ModelLoadRequest(const string &name, const Filename &filename, const LoaderOptions &options, Loader *loader)
Create a new ModelLoadRequest, and add it to the loader via load_async(), to begin an asynchronous lo...
Specifies parameters that may be passed to the loader.
Definition: loaderOptions.h:26
A convenient class for loading models from disk, in bam or egg format (or any of a number of other fo...
Definition: loader.h:47
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:44
static void sleep(double seconds)
Suspends the current thread for at least the indicated amount of time.
Definition: thread.I:236
This class represents a concrete task performed by an AsyncManager.
Definition: asyncTask.h:43
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85