Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/gobj/imageBuffer.cxx

Go to the documentation of this file.
00001 // Filename: imageBuffer.cxx
00002 // Created by:  mike (09Jan97)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #include "pandabase.h"
00020 
00021 #include "imageBuffer.h"
00022 #include "config_gobj.h"
00023 #include "config_util.h"
00024 
00025 #include "datagram.h"
00026 #include "datagramIterator.h"
00027 #include "bamReader.h"
00028 
00029 TypeHandle ImageBuffer::_type_handle;
00030 
00031 ////////////////////////////////////////////////////////////////////
00032 //     Function: ImageBuffer::Constructor
00033 //       Access: Public
00034 //  Description: 
00035 ////////////////////////////////////////////////////////////////////
00036 ImageBuffer::
00037 ImageBuffer() {
00038   _primary_file_num_channels = 0;
00039   _alpha_file_channel = 0;
00040 }
00041 
00042 ////////////////////////////////////////////////////////////////////
00043 //     Function: ImageBuffer::Destructor
00044 //       Access: Public, Virtual
00045 //  Description: 
00046 ////////////////////////////////////////////////////////////////////
00047 ImageBuffer::
00048 ~ImageBuffer() {
00049 }
00050 
00051 ////////////////////////////////////////////////////////////////////
00052 //     Function: ImageBuffer::write_datagram
00053 //       Access: Public
00054 //  Description: Function to write the important information in
00055 //               the particular object to a Datagram
00056 ////////////////////////////////////////////////////////////////////
00057 void ImageBuffer::
00058 write_datagram(BamWriter *, Datagram &me)
00059 {
00060   Filename filename = get_filename();
00061   Filename alpha_filename = get_alpha_filename();
00062 
00063   switch (bam_texture_mode) {
00064   case BTM_unchanged:
00065     break;
00066 
00067   case BTM_fullpath:
00068     filename = get_fullpath();
00069     alpha_filename = get_alpha_fullpath();
00070     break;
00071 
00072   case BTM_relative:
00073     filename = get_fullpath();
00074     alpha_filename = get_alpha_fullpath();
00075     filename.find_on_searchpath(get_texture_path()) ||
00076       filename.find_on_searchpath(get_model_path());
00077     if (gobj_cat.is_debug()) {
00078       gobj_cat.debug()
00079         << "Texture file " << get_filename() << " found as " << filename << "\n";
00080     }
00081     alpha_filename.find_on_searchpath(get_texture_path()) ||
00082       alpha_filename.find_on_searchpath(get_model_path());
00083     if (gobj_cat.is_debug()) {
00084       gobj_cat.debug()
00085         << "Alpha image " << get_alpha_filename() << " found as " << alpha_filename << "\n";
00086     }
00087     break;
00088 
00089   case BTM_basename:
00090     filename = filename.get_basename();
00091     alpha_filename = alpha_filename.get_basename();
00092     break;
00093 
00094   default:
00095     gobj_cat.error()
00096       << "Unsupported bam-texture-mode: " << (int)bam_texture_mode << "\n";
00097   }
00098 
00099   me.add_string(get_name());
00100   me.add_string(filename);
00101   me.add_string(alpha_filename);
00102   me.add_uint8(_primary_file_num_channels);
00103   me.add_uint8(_alpha_file_channel);
00104 }
00105 
00106 ////////////////////////////////////////////////////////////////////
00107 //     Function: ImageBuffer::fillin
00108 //       Access: Protected
00109 //  Description: Function that reads out of the datagram (or asks
00110 //               manager to read) all of the data that is needed to
00111 //               re-create this object and stores it in the appropiate
00112 //               place
00113 ////////////////////////////////////////////////////////////////////
00114 void ImageBuffer::
00115 fillin(DatagramIterator &scan, BamReader *manager) {
00116   set_name(scan.get_string());
00117   set_filename(scan.get_string());
00118   set_alpha_filename(scan.get_string());
00119 
00120   if (manager->get_file_minor_ver() < 3) {
00121     _primary_file_num_channels = 0;
00122     _alpha_file_channel = 0;
00123   } else {
00124     _primary_file_num_channels = scan.get_uint8();
00125     _alpha_file_channel = scan.get_uint8();
00126   }
00127 }

Generated on Fri May 2 00:39:31 2003 for Panda by doxygen1.3