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

panda/src/builder/builderPrim.h

Go to the documentation of this file.
00001 // Filename: builderPrim.h
00002 // Created by:  drose (09Sep97)
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 BUILDERPRIM_H
00020 #define BUILDERPRIM_H
00021 
00022 ///////////////////////////////////////////////////////////////////
00023 //
00024 // BuilderPrim, BuilderPrimI
00025 //
00026 // The basic class for passing primitives (polygons, etc.) to the
00027 // builder.  See the comments at the beginning of builder.h and
00028 // builderVertex.h.
00029 //
00030 // A BuilderPrim has a few attributes of its own--color and
00031 // normal--which are defined in builderAttrib.h (which it inherits
00032 // from).  It also has a collection of vertices, represented as
00033 // BuilderVertex objects, each of which can have its own attributes as
00034 // well.  Any additional attributes, such as texture, lighting, etc.,
00035 // are considered to be external to the primitive, and are defined in
00036 // the BuilderBucket object.
00037 //
00038 // BuilderPrimI is exactly like BuilderPrim, except that it represents
00039 // an indexed primitive.  A BuilderPrimI keeps its collection of
00040 // vertices as BuilderVertexI's, which store their values as index
00041 // numbers into an array rather than as actual coordinate values. The
00042 // arrays themselves are stored in the BuilderBucket.
00043 //
00044 // In fact, BuilderPrim and BuilderPrimI are both instantiations of
00045 // the same template object, BuilderPrimTempl, with different vertex
00046 // types (BuilderVertex and BuilderVertexI, respectively).
00047 //
00048 // It is this templating that drives most of the code in this package.
00049 // A lot of stuff in the builder tool, and everything in the mesher
00050 // tool, is templated on the BuilderPrim type, so the same code is
00051 // used to support both indexed and nonindexed primitives.
00052 //
00053 //
00054 // In addition to storing the primitives--individual polygons,
00055 // generally--as passed in by user code, BuilderPrim objects can store
00056 // the compound primitives that might have been generated by the
00057 // mesher, like triangle strips.  In this case, in addition to an
00058 // array of vertices, it has an array of component attributes, which
00059 // store the attributes specific to each individual component
00060 // (e.g. the normal of each triangle in a triangle strip).
00061 //
00062 ///////////////////////////////////////////////////////////////////
00063 
00064 
00065 
00066 #include <pandabase.h>
00067 
00068 #include "builderPrimTempl.h"
00069 #include "builderBucket.h"
00070 #include "builderTypes.h"
00071 
00072 #include <pta_ushort.h>
00073 #include <geom.h>
00074 
00075 EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, BuilderPrimTempl<BuilderVertex>);
00076 EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, BuilderPrimTempl<BuilderVertexI>);
00077 
00078 /////////////////////////////////////////////////////////////////////
00079 //       Class : BuilderPrim
00080 // Description : The basic class for passing nonindexed primitives
00081 //               to the builder.  See the comments at the the head of
00082 //               this file, and in builder.h.
00083 //
00084 //               Look in builderPrimTempl.h and builderAttribTempl.h
00085 //               for most of the interface to BuilderPrim.
00086 ////////////////////////////////////////////////////////////////////
00087 class EXPCL_PANDAEGG BuilderPrim : public BuilderPrimTempl<BuilderVertex> {
00088 public:
00089   INLINE BuilderPrim();
00090   INLINE BuilderPrim(const BuilderPrim &copy);
00091   INLINE BuilderPrim &operator = (const BuilderPrim &copy);
00092 
00093   BuilderPrim &nonindexed_copy(const BuilderPrimTempl<BuilderVertexI> &copy,
00094                                const BuilderBucket &bucket);
00095 
00096   void flatten_vertex_properties();
00097 
00098   static void fill_geom(Geom *geom, const PTA_BuilderV &v_array,
00099                         GeomBindType n_attr, const PTA_BuilderN &n_array,
00100                         GeomBindType t_attr, const PTA_BuilderTC &t_array,
00101                         GeomBindType c_attr, const PTA_BuilderC &c_array,
00102                         const BuilderBucket &bucket,
00103                         int num_prims, int num_components, int num_verts);
00104 };
00105 
00106 
00107 ///////////////////////////////////////////////////////////////////
00108 //       Class : BuilderPrimI
00109 // Description : The basic class for passing indexed primitives
00110 //               to the builder.
00111 //
00112 //               Look in builderPrimTempl.h and builderAttribTempl.h
00113 //               for most of the interface to BuilderPrimI.
00114 ////////////////////////////////////////////////////////////////////
00115 class EXPCL_PANDAEGG BuilderPrimI : public BuilderPrimTempl<BuilderVertexI> {
00116 public:
00117   INLINE BuilderPrimI();
00118   INLINE BuilderPrimI(const BuilderPrimI &copy);
00119   INLINE BuilderPrimI &operator = (const BuilderPrimI &copy);
00120 
00121   void flatten_vertex_properties();
00122 
00123   static void fill_geom(Geom *geom, const PTA_ushort &v_array,
00124                         GeomBindType n_attr, PTA_ushort n_array,
00125                         GeomBindType t_attr, PTA_ushort t_array,
00126                         GeomBindType c_attr, PTA_ushort c_array,
00127                         const BuilderBucket &bucket,
00128                         int num_prims, int num_components, int num_verts);
00129 };
00130 
00131 #include "builderPrim.I"
00132 
00133 
00134 // Tell GCC that we'll take care of the instantiation explicitly here.
00135 #ifdef __GNUC__
00136 #pragma interface
00137 #endif
00138 
00139 #endif

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