Panda3D

eggRenderState.h

00001 // Filename: eggRenderState.h
00002 // Created by:  drose (12Mar05)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef EGGRENDERSTATE_H
00016 #define EGGRENDERSTATE_H
00017 
00018 #include "pandabase.h"
00019 
00020 #include "eggUserData.h"
00021 #include "eggLoader.h"
00022 #include "renderState.h"
00023 #include "renderAttrib.h"
00024 #include "internalName.h"
00025 #include "geomPrimitive.h"
00026 #include "luse.h"
00027 #include "pointerTo.h"
00028 #include "pvector.h"
00029 #include "pmap.h"
00030 
00031 class EggPrimitive;
00032 class EggTexture;
00033 class EggMaterial;
00034 
00035 ////////////////////////////////////////////////////////////////////
00036 //       Class : EggRenderState
00037 // Description : This class is used within this package only to record
00038 //               the render state that should be assigned to each
00039 //               primitive.  It is assigned to EggPrimitive objects
00040 //               via the EggBinner.
00041 ////////////////////////////////////////////////////////////////////
00042 class EggRenderState : public EggUserData {
00043 public:
00044   INLINE EggRenderState(EggLoader &loader);
00045   INLINE void add_attrib(const RenderAttrib *attrib);
00046 
00047   void fill_state(EggPrimitive *egg_prim);
00048 
00049   int compare_to(const EggRenderState &other) const;
00050 
00051 private:
00052   CPT(RenderAttrib) get_material_attrib(const EggMaterial *egg_mat,
00053                                         bool bface);
00054   static TexGenAttrib::Mode get_tex_gen(const EggTexture *egg_tex);
00055 
00056   CPT(RenderAttrib)
00057   apply_tex_mat(CPT(RenderAttrib) tex_mat_attrib, 
00058                 TextureStage *stage, const EggTexture *egg_tex);
00059 
00060 public:
00061   CPT(RenderState) _state;
00062   bool _hidden;
00063   bool _flat_shaded;
00064   Geom::PrimitiveType _primitive_type;
00065 
00066   typedef EggLoader::BakeInUVs BakeInUVs;
00067   typedef EggLoader::TextureDef TextureDef;
00068   typedef EggLoader::Materials Materials;
00069 
00070   BakeInUVs _bake_in_uvs;
00071 
00072 private:
00073   EggLoader &_loader;
00074 
00075   typedef pvector<const TextureDef *> TexMatTextures;
00076   typedef pmap<LMatrix4d, TexMatTextures> TexMatTransforms;
00077   typedef pmap<CPT(InternalName), TexMatTransforms> TexMats;
00078 };
00079 
00080 #include "eggRenderState.I"
00081 
00082 #endif
00083 
 All Classes Functions Variables Enumerations