loaderFileTypeStf.cxx 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. #include "loaderFileTypeStf.h"
  15. #include "speedTreeNode.h"
  16. TypeHandle LoaderFileTypeStf::_type_handle;
  17. ////////////////////////////////////////////////////////////////////
  18. // Function: LoaderFileTypeStf::Constructor
  19. // Access: Public
  20. // Description:
  21. ////////////////////////////////////////////////////////////////////
  22. LoaderFileTypeStf::
  23. LoaderFileTypeStf() {
  24. }
  25. ////////////////////////////////////////////////////////////////////
  26. // Function: LoaderFileTypeStf::get_name
  27. // Access: Public, Virtual
  28. // Description:
  29. ////////////////////////////////////////////////////////////////////
  30. string LoaderFileTypeStf::
  31. get_name() const {
  32. return "SpeedTree compiled tree";
  33. }
  34. ////////////////////////////////////////////////////////////////////
  35. // Function: LoaderFileTypeStf::get_extension
  36. // Access: Public, Virtual
  37. // Description:
  38. ////////////////////////////////////////////////////////////////////
  39. string LoaderFileTypeStf::
  40. get_extension() const {
  41. return "stf";
  42. }
  43. ////////////////////////////////////////////////////////////////////
  44. // Function: LoaderFileTypeStf::supports_compressed
  45. // Access: Published, Virtual
  46. // Description: Returns true if this file type can transparently load
  47. // compressed files (with a .pz extension), false
  48. // otherwise.
  49. ////////////////////////////////////////////////////////////////////
  50. bool LoaderFileTypeStf::
  51. supports_compressed() const {
  52. return true;
  53. }
  54. ////////////////////////////////////////////////////////////////////
  55. // Function: LoaderFileTypeStf::load_file
  56. // Access: Public, Virtual
  57. // Description:
  58. ////////////////////////////////////////////////////////////////////
  59. PT(PandaNode) LoaderFileTypeStf::
  60. load_file(const Filename &path, const LoaderOptions &options,
  61. BamCacheRecord *record) const {
  62. if (!path.is_regular_file()) {
  63. // Quietly fail if the file doesn't exist. The Loader expects
  64. // this.
  65. return NULL;
  66. }
  67. PT(SpeedTreeNode) st = new SpeedTreeNode(path.get_basename());
  68. st->add_from_stf(path, options);
  69. return st.p();
  70. }