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

pandatool/src/egg-palettize/texturePlacement.h

Go to the documentation of this file.
00001 // Filename: texturePlacement.h
00002 // Created by:  drose (28Nov00)
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 #ifndef TEXTUREPLACEMENT_H
00020 #define TEXTUREPLACEMENT_H
00021 
00022 #include "pandatoolbase.h"
00023 
00024 #include "omitReason.h"
00025 #include "texturePosition.h"
00026 
00027 #include "typedWritable.h"
00028 #include "luse.h"
00029 
00030 #include "pset.h"
00031 
00032 class TextureImage;
00033 class DestTextureImage;
00034 class PaletteGroup;
00035 class PaletteImage;
00036 class PalettePage;
00037 class TextureProperties;
00038 class TextureReference;
00039 class PNMImage;
00040 
00041 ////////////////////////////////////////////////////////////////////
00042 //       Class : TexturePlacement
00043 // Description : This corresponds to a particular assignment of a
00044 //               TextureImage with a PaletteGroup, and specifically
00045 //               describes which PaletteImage (if any), and where on
00046 //               the PaletteImage, the TextureImage has been assigned
00047 //               to.
00048 ////////////////////////////////////////////////////////////////////
00049 class TexturePlacement : public TypedWritable {
00050 private:
00051   TexturePlacement();
00052 
00053 public:
00054   TexturePlacement(TextureImage *texture, PaletteGroup *group);
00055   ~TexturePlacement();
00056 
00057   const string &get_name() const;
00058   TextureImage *get_texture() const;
00059   const TextureProperties &get_properties() const;
00060   PaletteGroup *get_group() const;
00061 
00062   void add_egg(TextureReference *reference);
00063   void remove_egg(TextureReference *reference);
00064   void mark_eggs_stale();
00065 
00066   void set_dest(DestTextureImage *dest);
00067   DestTextureImage *get_dest() const;
00068 
00069   bool determine_size();
00070   bool is_size_known() const;
00071   OmitReason get_omit_reason() const;
00072   int get_x_size() const;
00073   int get_y_size() const;
00074   double get_uv_area() const;
00075 
00076   bool is_placed() const;
00077   PaletteImage *get_image() const;
00078   PalettePage *get_page() const;
00079   int get_placed_x() const;
00080   int get_placed_y() const;
00081   int get_placed_x_size() const;
00082   int get_placed_y_size() const;
00083   double get_placed_uv_area() const;
00084 
00085   void place_at(PaletteImage *image, int x, int y);
00086   void force_replace();
00087   void omit_solitary();
00088   void not_solitary();
00089   bool intersects(int x, int y, int x_size, int y_size);
00090 
00091   void compute_tex_matrix(LMatrix3d &transform);
00092 
00093   void write_placed(ostream &out, int indent_level = 0);
00094 
00095   bool is_filled() const;
00096   void mark_unfilled();
00097   void fill_image(PNMImage &image);
00098   void flag_error_image(PNMImage &image);
00099 
00100 private:
00101   void compute_size_from_uvs(const TexCoordd &min_uv, const TexCoordd &max_uv);
00102 
00103   TextureImage *_texture;
00104   PaletteGroup *_group;
00105   PaletteImage *_image;
00106   DestTextureImage *_dest;
00107 
00108   bool _has_uvs;
00109   bool _size_known;
00110   TexturePosition _position;
00111 
00112   bool _is_filled;
00113   TexturePosition _placed;
00114   OmitReason _omit_reason;
00115 
00116   typedef pset<TextureReference *> References;
00117   References _references;
00118 
00119   // The TypedWritable interface follows.
00120 public:
00121   static void register_with_read_factory();
00122   virtual void write_datagram(BamWriter *writer, Datagram &datagram);
00123   virtual int complete_pointers(TypedWritable **p_list,
00124                                 BamReader *manager);
00125 
00126 protected:
00127   static TypedWritable *make_TexturePlacement(const FactoryParams &params);
00128   void fillin(DatagramIterator &scan, BamReader *manager);
00129 
00130 private:
00131   // This value is only filled in while reading from the bam file;
00132   // don't use it otherwise.
00133   int _num_references;
00134 
00135 public:
00136   static TypeHandle get_class_type() {
00137     return _type_handle;
00138   }
00139   static void init_type() {
00140     TypedWritable::init_type();
00141     register_type(_type_handle, "TexturePlacement",
00142                   TypedWritable::get_class_type());
00143   }
00144   virtual TypeHandle get_type() const {
00145     return get_class_type();
00146   }
00147 
00148 private:
00149   static TypeHandle _type_handle;
00150 };
00151 
00152 
00153 // This is an STL object to sort an array of TexturePlacement pointers
00154 // in order from biggest to smallest.
00155 class SortPlacementBySize {
00156 public:
00157   bool operator ()(TexturePlacement *a, TexturePlacement *b) const;
00158 };
00159 
00160 #endif
00161 

Generated on Fri May 2 03:18:14 2003 for Panda-Tool by doxygen1.3