loaderFileTypeSrt.cxx 2.6 KB

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