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

panda/src/pgraph/geomTransformer.h

Go to the documentation of this file.
00001 // Filename: geomTransformer.h
00002 // Created by:  drose (14Mar02)
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 GEOMTRANSFORMER_H
00020 #define GEOMTRANSFORMER_H
00021 
00022 #include "pandabase.h"
00023 
00024 #include "geom.h"
00025 #include "luse.h"
00026 
00027 class GeomNode;
00028 
00029 ///////////////////////////////////////////////////////////////////
00030 //       Class : GeomTransformer
00031 // Description : An object specifically designed to transform the
00032 //               vertices of a Geom without disturbing indexing or
00033 //               affecting any other Geoms that may share the same
00034 //               vertex arrays, and without needlessly wasting memory
00035 //               when different Geoms sharing the same vertex arrays
00036 //               are transformed by the same amount.
00037 //
00038 //               If you create a single GeomTransformer and use it to
00039 //               transform a number of different Geoms by various
00040 //               transformations, then those Geoms which happen to
00041 //               share the same arrays and are transformed by the same
00042 //               amounts will still share the same arrays as each
00043 //               other (but different from the original arrays).
00044 ////////////////////////////////////////////////////////////////////
00045 class EXPCL_PANDA GeomTransformer {
00046 public:
00047   GeomTransformer();
00048   ~GeomTransformer();
00049 
00050   bool transform_vertices(Geom *geom, const LMatrix4f &mat);
00051   bool transform_vertices(GeomNode *node, const LMatrix4f &mat);
00052 
00053   bool transform_texcoords(Geom *geom, const LMatrix4f &mat);
00054   bool transform_texcoords(GeomNode *node, const LMatrix4f &mat);
00055 
00056   bool set_color(Geom *geom, const Colorf &color);
00057   bool set_color(GeomNode *node, const Colorf &color);
00058 
00059   bool transform_colors(Geom *geom, const LVecBase4f &scale);
00060   bool transform_colors(GeomNode *node, const LVecBase4f &scale);
00061 
00062   bool apply_state(GeomNode *node, const RenderState *state);
00063 
00064 private:
00065   class SourceVertices {
00066   public:
00067     INLINE bool operator < (const SourceVertices &other) const;
00068 
00069     LMatrix4f _mat;
00070     PTA_Vertexf _coords;
00071   };
00072   typedef pmap<SourceVertices, PTA_Vertexf> Vertices;
00073   Vertices _vertices;
00074 
00075   class SourceNormals {
00076   public:
00077     INLINE bool operator < (const SourceNormals &other) const;
00078 
00079     LMatrix4f _mat;
00080     PTA_Normalf _norms;
00081   };
00082   typedef pmap<SourceNormals, PTA_Normalf> Normals;
00083   Normals _normals;
00084 
00085   class SourceTexCoords {
00086   public:
00087     INLINE bool operator < (const SourceTexCoords &other) const;
00088 
00089     LMatrix4f _mat;
00090     PTA_TexCoordf _texcoords;
00091   };
00092   typedef pmap<SourceTexCoords, PTA_TexCoordf> TexCoords;
00093   TexCoords _texcoords;
00094 
00095   // We have two concepts of colors: the "fixed" colors, which are
00096   // slapped in complete replacement of the original colors (e.g. via
00097   // a ColorAttrib), and the "transformed" colors, which are modified
00098   // from the original colors (e.g. via a ColorScaleAttrib).
00099   typedef pmap<Colorf, PTA_Colorf> FColors;
00100   FColors _fcolors;
00101 
00102   class SourceColors {
00103   public:
00104     INLINE bool operator < (const SourceColors &other) const;
00105 
00106     LVecBase4f _scale;
00107     PTA_Colorf _colors;
00108   };
00109   typedef pmap<SourceColors, PTA_Colorf> TColors;
00110   TColors _tcolors;
00111 };
00112 
00113 #include "geomTransformer.I"
00114 
00115 #endif
00116 

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