imageBuffer.cxx 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // Filename: imageBuffer.cxx
  2. // Created by: mike (09Jan97)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
  8. //
  9. // All use of this software is subject to the terms of the Panda 3d
  10. // Software license. You should have received a copy of this license
  11. // along with this source code; you will also find a current copy of
  12. // the license at http://www.panda3d.org/license.txt .
  13. //
  14. // To contact the maintainers of this program write to
  15. // [email protected] .
  16. //
  17. ////////////////////////////////////////////////////////////////////
  18. ////////////////////////////////////////////////////////////////////
  19. // Includes
  20. ////////////////////////////////////////////////////////////////////
  21. #include <pandabase.h>
  22. #include "imageBuffer.h"
  23. #include "config_gobj.h"
  24. #include "config_util.h"
  25. #include <datagram.h>
  26. #include <datagramIterator.h>
  27. #include <bamReader.h>
  28. ////////////////////////////////////////////////////////////////////
  29. // Static variables
  30. ////////////////////////////////////////////////////////////////////
  31. TypeHandle ImageBuffer::_type_handle;
  32. ////////////////////////////////////////////////////////////////////
  33. // Function: ImageBuffer::write_datagram
  34. // Access: Public
  35. // Description: Function to write the important information in
  36. // the particular object to a Datagram
  37. ////////////////////////////////////////////////////////////////////
  38. void ImageBuffer::
  39. write_datagram(BamWriter *, Datagram &me)
  40. {
  41. Filename filename = get_name();
  42. Filename alpha_filename = get_alpha_name();
  43. switch (bam_texture_mode) {
  44. case BTM_fullpath:
  45. break;
  46. case BTM_relative:
  47. filename.find_on_searchpath(get_texture_path());
  48. filename.find_on_searchpath(get_model_path());
  49. if (gobj_cat.is_debug()) {
  50. gobj_cat.debug()
  51. << "Texture file " << get_name() << " found as " << filename << "\n";
  52. }
  53. alpha_filename.find_on_searchpath(get_texture_path());
  54. alpha_filename.find_on_searchpath(get_model_path());
  55. if (gobj_cat.is_debug()) {
  56. gobj_cat.debug()
  57. << "Alpha image " << get_alpha_name() << " found as " << alpha_filename << "\n";
  58. }
  59. break;
  60. case BTM_basename:
  61. filename = filename.get_basename();
  62. alpha_filename = alpha_filename.get_basename();
  63. break;
  64. default:
  65. gobj_cat.error()
  66. << "Unsupported bam-texture-mode: " << (int)bam_texture_mode << "\n";
  67. }
  68. me.add_string(filename);
  69. me.add_string(alpha_filename);
  70. }
  71. ////////////////////////////////////////////////////////////////////
  72. // Function: ImageBuffer::fillin
  73. // Access: Protected
  74. // Description: Function that reads out of the datagram (or asks
  75. // manager to read) all of the data that is needed to
  76. // re-create this object and stores it in the appropiate
  77. // place
  78. ////////////////////////////////////////////////////////////////////
  79. void ImageBuffer::
  80. fillin(DatagramIterator &scan, BamReader *manager) {
  81. set_name(scan.get_string());
  82. set_alpha_name(scan.get_string());
  83. }