00001 // Filename: loaderFileTypeStf.cxx 00002 // Created by: drose (06Oct10) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #include "loaderFileTypeStf.h" 00016 #include "speedTreeNode.h" 00017 00018 TypeHandle LoaderFileTypeStf::_type_handle; 00019 00020 //////////////////////////////////////////////////////////////////// 00021 // Function: LoaderFileTypeStf::Constructor 00022 // Access: Public 00023 // Description: 00024 //////////////////////////////////////////////////////////////////// 00025 LoaderFileTypeStf:: 00026 LoaderFileTypeStf() { 00027 } 00028 00029 //////////////////////////////////////////////////////////////////// 00030 // Function: LoaderFileTypeStf::get_name 00031 // Access: Public, Virtual 00032 // Description: 00033 //////////////////////////////////////////////////////////////////// 00034 string LoaderFileTypeStf:: 00035 get_name() const { 00036 return "SpeedTree compiled tree"; 00037 } 00038 00039 //////////////////////////////////////////////////////////////////// 00040 // Function: LoaderFileTypeStf::get_extension 00041 // Access: Public, Virtual 00042 // Description: 00043 //////////////////////////////////////////////////////////////////// 00044 string LoaderFileTypeStf:: 00045 get_extension() const { 00046 return "stf"; 00047 } 00048 00049 //////////////////////////////////////////////////////////////////// 00050 // Function: LoaderFileTypeStf::supports_compressed 00051 // Access: Published, Virtual 00052 // Description: Returns true if this file type can transparently load 00053 // compressed files (with a .pz extension), false 00054 // otherwise. 00055 //////////////////////////////////////////////////////////////////// 00056 bool LoaderFileTypeStf:: 00057 supports_compressed() const { 00058 return true; 00059 } 00060 00061 //////////////////////////////////////////////////////////////////// 00062 // Function: LoaderFileTypeStf::load_file 00063 // Access: Public, Virtual 00064 // Description: 00065 //////////////////////////////////////////////////////////////////// 00066 PT(PandaNode) LoaderFileTypeStf:: 00067 load_file(const Filename &path, const LoaderOptions &options, 00068 BamCacheRecord *record) const { 00069 if (!path.is_regular_file()) { 00070 // Quietly fail if the file doesn't exist. The Loader expects 00071 // this. 00072 return NULL; 00073 } 00074 00075 PT(SpeedTreeNode) st = new SpeedTreeNode(path.get_basename()); 00076 st->add_from_stf(path, options); 00077 00078 return st.p(); 00079 }