Panda3D
loaderFileTypeStf.cxx
1 // Filename: loaderFileTypeStf.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 "loaderFileTypeStf.h"
16 #include "speedTreeNode.h"
17 
18 TypeHandle LoaderFileTypeStf::_type_handle;
19 
20 ////////////////////////////////////////////////////////////////////
21 // Function: LoaderFileTypeStf::Constructor
22 // Access: Public
23 // Description:
24 ////////////////////////////////////////////////////////////////////
25 LoaderFileTypeStf::
26 LoaderFileTypeStf() {
27 }
28 
29 ////////////////////////////////////////////////////////////////////
30 // Function: LoaderFileTypeStf::get_name
31 // Access: Public, Virtual
32 // Description:
33 ////////////////////////////////////////////////////////////////////
34 string LoaderFileTypeStf::
35 get_name() const {
36  return "SpeedTree compiled tree";
37 }
38 
39 ////////////////////////////////////////////////////////////////////
40 // Function: LoaderFileTypeStf::get_extension
41 // Access: Public, Virtual
42 // Description:
43 ////////////////////////////////////////////////////////////////////
44 string LoaderFileTypeStf::
45 get_extension() const {
46  return "stf";
47 }
48 
49 ////////////////////////////////////////////////////////////////////
50 // Function: LoaderFileTypeStf::supports_compressed
51 // Access: Published, Virtual
52 // Description: Returns true if this file type can transparently load
53 // compressed files (with a .pz extension), false
54 // otherwise.
55 ////////////////////////////////////////////////////////////////////
58  return true;
59 }
60 
61 ////////////////////////////////////////////////////////////////////
62 // Function: LoaderFileTypeStf::load_file
63 // Access: Public, Virtual
64 // Description:
65 ////////////////////////////////////////////////////////////////////
66 PT(PandaNode) LoaderFileTypeStf::
67 load_file(const Filename &path, const LoaderOptions &options,
68  BamCacheRecord *record) const {
69  if (!path.is_regular_file()) {
70  // Quietly fail if the file doesn't exist. The Loader expects
71  // this.
72  return NULL;
73  }
74 
75  PT(SpeedTreeNode) st = new SpeedTreeNode(path.get_basename());
76  st->add_from_stf(path, options);
77 
78  return st.p();
79 }
string get_basename() const
Returns the basename part of the filename.
Definition: filename.I:436
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
bool is_regular_file() const
Returns true if the filename exists and is the name of a regular file (i.e.
Definition: filename.cxx:1389
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...
virtual bool supports_compressed() const
Returns true if this file type can transparently load compressed files (with a .pz extension)...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85