Panda3D
 All Classes Functions Variables Enumerations
loaderFileTypeSrt.cxx
1 // Filename: loaderFileTypeSrt.cxx
2 // Created by: drose (06Oct10)
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 "loaderFileTypeSrt.h"
16 #include "speedTreeNode.h"
17 #include "stTree.h"
18 
19 TypeHandle LoaderFileTypeSrt::_type_handle;
20 
21 ////////////////////////////////////////////////////////////////////
22 // Function: LoaderFileTypeSrt::Constructor
23 // Access: Public
24 // Description:
25 ////////////////////////////////////////////////////////////////////
26 LoaderFileTypeSrt::
27 LoaderFileTypeSrt() {
28 }
29 
30 ////////////////////////////////////////////////////////////////////
31 // Function: LoaderFileTypeSrt::get_name
32 // Access: Public, Virtual
33 // Description:
34 ////////////////////////////////////////////////////////////////////
35 string LoaderFileTypeSrt::
36 get_name() const {
37  return "SpeedTree compiled tree";
38 }
39 
40 ////////////////////////////////////////////////////////////////////
41 // Function: LoaderFileTypeSrt::get_extension
42 // Access: Public, Virtual
43 // Description:
44 ////////////////////////////////////////////////////////////////////
45 string LoaderFileTypeSrt::
46 get_extension() const {
47  return "srt";
48 }
49 
50 ////////////////////////////////////////////////////////////////////
51 // Function: LoaderFileTypeSrt::supports_compressed
52 // Access: Published, Virtual
53 // Description: Returns true if this file type can transparently load
54 // compressed files (with a .pz extension), false
55 // otherwise.
56 ////////////////////////////////////////////////////////////////////
59  return false;
60 }
61 
62 ////////////////////////////////////////////////////////////////////
63 // Function: LoaderFileTypeSrt::load_file
64 // Access: Public, Virtual
65 // Description:
66 ////////////////////////////////////////////////////////////////////
68 load_file(const Filename &path, const LoaderOptions &,
69  BamCacheRecord *record) const {
70  if (!path.is_regular_file()) {
71  // Quietly fail if the file doesn't exist. The Loader expects
72  // this.
73  return NULL;
74  }
75 
76  PT(STTree) tree = new STTree(path);
77  if (!tree->is_valid()) {
78  return NULL;
79  }
80 
81  PT(SpeedTreeNode) st = new SpeedTreeNode(path.get_basename());
82  st->add_instance(tree, STTransform());
83 
84  return st.p();
85 }
A basic node of the scene graph or data graph.
Definition: pandaNode.h:72
Specifies parameters that may be passed to the loader.
Definition: loaderOptions.h:26
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:44
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, within the Panda3D scene graph.
Definition: speedTreeNode.h:54
Represents a transform that may be applied to a particular instance of a tree when added to the Speed...
Definition: stTransform.h:29
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
This defines the Loader interface to read SpeedTree SRT files, which describe a single tree...
Encapsulates a single tree model in the SpeedTree library, as loaded from an SRT file.
Definition: stTree.h:30
virtual bool supports_compressed() const
Returns true if this file type can transparently load compressed files (with a .pz extension)...