Panda3D
modelSaveRequest.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 modelSaveRequest.cxx
10  * @author drose
11  * @date 2012-12-19
12  */
13 
14 #include "modelSaveRequest.h"
15 #include "loader.h"
16 #include "config_pgraph.h"
17 
18 TypeHandle ModelSaveRequest::_type_handle;
19 
20 /**
21  * Create a new ModelSaveRequest, and add it to the loader via save_async(),
22  * to begin an asynchronous save.
23  */
25 ModelSaveRequest(const std::string &name,
26  const Filename &filename, const LoaderOptions &options,
27  PandaNode *node, Loader *loader) :
28  AsyncTask(name),
29  _filename(filename),
30  _options(options),
31  _node(node),
32  _loader(loader),
33  _success(false)
34 {
35 }
36 
37 /**
38  * Performs the task: that is, saves the one model.
39  */
40 AsyncTask::DoneStatus ModelSaveRequest::
41 do_task() {
42  double delay = async_load_delay;
43  if (delay != 0.0) {
44  Thread::sleep(delay);
45  }
46 
47  _success = _loader->save_sync(_filename, _options, _node);
48 
49  // Don't continue the task; we're done.
50  return DS_done;
51 }
A basic node of the scene graph or data graph.
Definition: pandaNode.h:64
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Specifies parameters that may be passed to the loader.
Definition: loaderOptions.h:23
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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
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
ModelSaveRequest(const std::string &name, const Filename &filename, const LoaderOptions &options, PandaNode *node, Loader *loader)
Create a new ModelSaveRequest, and add it to the loader via save_async(), to begin an asynchronous sa...