Panda3D
modelLoadRequest.cxx
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file modelLoadRequest.cxx
10  * @author drose
11  * @date 2006-08-29
12  */
13 
14 #include "modelLoadRequest.h"
15 #include "loader.h"
16 #include "config_pgraph.h"
17 
18 TypeHandle ModelLoadRequest::_type_handle;
19 
20 /**
21  * Create a new ModelLoadRequest, and add it to the loader via load_async(),
22  * to begin an asynchronous load.
23  */
25 ModelLoadRequest(const std::string &name,
26  const Filename &filename, const LoaderOptions &options,
27  Loader *loader) :
28  AsyncTask(name),
29  _filename(filename),
30  _options(options),
31  _loader(loader)
32 {
33 }
34 
35 /**
36  * Performs the task: that is, loads the one model.
37  */
38 AsyncTask::DoneStatus ModelLoadRequest::
39 do_task() {
40  double delay = async_load_delay;
41  if (delay != 0.0) {
42  Thread::sleep(delay);
43  }
44 
45  PT(PandaNode) model = _loader->load_sync(_filename, _options);
46  set_result(model);
47 
48  // Don't continue the task; we're done.
49  return DS_done;
50 }
A basic node of the scene graph or data graph.
Definition: pandaNode.h:64
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
ModelLoadRequest(const std::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:23
A convenient class for loading models from disk, in bam or egg format (or any of a number of other fo...
Definition: loader.h:42
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:39
void set_result(std::nullptr_t)
Sets this future's result.
Definition: asyncFuture.I:92
static void sleep(double seconds)
Suspends the current thread for at least the indicated amount of time.
Definition: thread.I:192
This class represents a concrete task performed by an AsyncManager.
Definition: asyncTask.h:32
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.