Panda3D
loaderFileTypeSrt.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 loaderFileTypeSrt.cxx
10  * @author drose
11  * @date 2010-10-06
12  */
13 
14 #include "loaderFileTypeSrt.h"
15 #include "speedTreeNode.h"
16 #include "stTree.h"
17 
18 TypeHandle LoaderFileTypeSrt::_type_handle;
19 
20 /**
21  *
22  */
23 LoaderFileTypeSrt::
24 LoaderFileTypeSrt() {
25 }
26 
27 /**
28  *
29  */
30 std::string LoaderFileTypeSrt::
31 get_name() const {
32  return "SpeedTree compiled tree";
33 }
34 
35 /**
36  *
37  */
38 std::string LoaderFileTypeSrt::
39 get_extension() const {
40  return "srt";
41 }
42 
43 /**
44  * Returns true if this file type can transparently load compressed files
45  * (with a .pz or .gz extension), false otherwise.
46  */
49  return false;
50 }
51 
52 /**
53  *
54  */
55 PT(PandaNode) LoaderFileTypeSrt::
56 load_file(const Filename &path, const LoaderOptions &,
57  BamCacheRecord *record) const {
58  if (!path.is_regular_file()) {
59  // Quietly fail if the file doesn't exist. The Loader expects this.
60  return nullptr;
61  }
62 
63  PT(STTree) tree = new STTree(path);
64  if (!tree->is_valid()) {
65  return nullptr;
66  }
67 
68  PT(SpeedTreeNode) st = new SpeedTreeNode(path.get_basename());
69  st->add_instance(tree, STTransform());
70 
71  return st;
72 }
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual bool supports_compressed() const
Returns true if this file type can transparently load compressed files (with a .pz or ....
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...
void add_instance(const STTree *tree, const STTransform &transform)
Adds a new instance of the indicated tree at the indicated transform.
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
std::string get_basename() const
Returns the basename part of the filename.
Definition: filename.I:367
Represents a transform that may be applied to a particular instance of a tree when added to the Speed...
Definition: stTransform.h:26
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
Encapsulates a single tree model in the SpeedTree library, as loaded from an SRT file.
Definition: stTree.h:28