Panda3D
loaderFileTypeStf.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 loaderFileTypeStf.cxx
10  * @author drose
11  * @date 2010-10-06
12  */
13 
14 #include "loaderFileTypeStf.h"
15 #include "speedTreeNode.h"
16 
17 TypeHandle LoaderFileTypeStf::_type_handle;
18 
19 /**
20  *
21  */
22 LoaderFileTypeStf::
23 LoaderFileTypeStf() {
24 }
25 
26 /**
27  *
28  */
29 std::string LoaderFileTypeStf::
30 get_name() const {
31  return "SpeedTree compiled tree";
32 }
33 
34 /**
35  *
36  */
37 std::string LoaderFileTypeStf::
38 get_extension() const {
39  return "stf";
40 }
41 
42 /**
43  * Returns true if this file type can transparently load compressed files
44  * (with a .pz or .gz extension), false otherwise.
45  */
48  return true;
49 }
50 
51 /**
52  *
53  */
54 PT(PandaNode) LoaderFileTypeStf::
55 load_file(const Filename &path, const LoaderOptions &options,
56  BamCacheRecord *record) const {
57  if (!path.is_regular_file()) {
58  // Quietly fail if the file doesn't exist. The Loader expects this.
59  return nullptr;
60  }
61 
62  PT(SpeedTreeNode) st = new SpeedTreeNode(path.get_basename());
63  st->add_from_stf(path, options);
64 
65  return st;
66 }
A basic node of the scene graph or data graph.
Definition: pandaNode.h:64
Specifies parameters that may be passed to the loader.
Definition: loaderOptions.h:23
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
An instance of this class is written to the front of a Bam or Txo file to make the file a cached inst...
Interfaces with the SpeedTree library to render SpeedTree objects, especially trees,...
Definition: speedTreeNode.h:50
bool is_regular_file() const
Returns true if the filename exists and is the name of a regular file (i.e.
Definition: filename.cxx:1297
bool add_from_stf(const Filename &stf_filename, const LoaderOptions &options=LoaderOptions())
Opens and reads the named STF (SpeedTree Forest) file, and adds the SRT files named within as instanc...
std::string get_basename() const
Returns the basename part of the filename.
Definition: filename.I:367
virtual bool supports_compressed() const
Returns true if this file type can transparently load compressed files (with a .pz or ....
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.