Browse Source

a couple more pgraph attribs

David Rose 24 years ago
parent
commit
29bf5a2ae3

+ 32 - 104
panda/src/egg2pg/qpeggLoader.cxx

@@ -23,12 +23,17 @@
 #include "renderState.h"
 #include "renderState.h"
 #include "transformState.h"
 #include "transformState.h"
 #include "textureAttrib.h"
 #include "textureAttrib.h"
+#include "textureApplyAttrib.h"
 #include "texturePool.h"
 #include "texturePool.h"
 #include "billboardAttrib.h"
 #include "billboardAttrib.h"
 #include "cullFaceAttrib.h"
 #include "cullFaceAttrib.h"
 #include "cullBinAttrib.h"
 #include "cullBinAttrib.h"
 #include "transparencyAttrib.h"
 #include "transparencyAttrib.h"
 #include "decalAttrib.h"
 #include "decalAttrib.h"
+#include "depthTestAttrib.h"
+#include "depthWriteAttrib.h"
+#include "materialAttrib.h"
+#include "materialPool.h"
 #include "qpgeomNode.h"
 #include "qpgeomNode.h"
 #include "string_utils.h"
 #include "string_utils.h"
 #include "eggPrimitive.h"
 #include "eggPrimitive.h"
@@ -125,7 +130,6 @@ build_graph() {
   make_node(&_data, _root);
   make_node(&_data, _root);
   _builder.qpbuild();
   _builder.qpbuild();
 
 
-  //  reset_directs();
   reparent_decals();
   reparent_decals();
 
 
   //  apply_deferred_arcs(_root);
   //  apply_deferred_arcs(_root);
@@ -196,54 +200,6 @@ reparent_decals() {
   }
   }
 }
 }
 
 
-/*
-////////////////////////////////////////////////////////////////////
-//     Function: qpEggLoader::reset_directs
-//       Access: Public
-//  Description: This applies to all of the nodes marked with the
-//               "render" flag, i.e. direct rendering of a subgraph,
-//               in depth-first order, as opposed to state-sorting
-//               within the subgraph.  For each such node, it moves
-//               all the transitions from the first GeomNode under
-//               that node up to the node itself, just so we'll be
-//               able to state-sort at least the tops of the
-//               subgraphs.
-////////////////////////////////////////////////////////////////////
-void qpEggLoader::
-reset_directs() {
-  Directs::const_iterator di;
-  for (di = _directs.begin(); di != _directs.end(); ++di) {
-    RenderRelation *arc = (*di);
-    nassertv(arc != (RenderRelation *)NULL);
-    PandaNode *node = DCAST(PandaNode, arc->get_child());
-    nassertv(node != (PandaNode *)NULL);
-
-    // First, search for the first GeomNode.
-    GeomNode *geom = NULL;
-    NodeRelation *child_arc = NULL;
-
-    int num_children =
-      node->get_num_children(RenderRelation::get_class_type());
-    for (int i = 0; i < num_children && geom == (GeomNode *)NULL; i++) {
-      child_arc = node->get_child(RenderRelation::get_class_type(), i);
-      nassertv(child_arc != (NodeRelation *)NULL);
-      Node *child = child_arc->get_child();
-      nassertv(child != (Node *)NULL);
-
-      if (child->is_of_type(GeomNode::get_class_type())) {
-        DCAST_INTO_V(geom, child);
-      }
-    }
-
-    if (geom != (GeomNode *)NULL) {
-      // Now copy all of the GeomNode's transitions up to its parent.
-      nassertv(child_arc != (NodeRelation *)NULL);
-      arc->copy_transitions_from(child_arc);
-    }
-  }
-}
-*/
-
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: qpEggLoader::make_nonindexed_primitive
 //     Function: qpEggLoader::make_nonindexed_primitive
@@ -512,16 +468,11 @@ load_texture(TextureDef &def, const EggTexture *egg_tex) {
     }
     }
   }
   }
 
 
-  /*
-  PT(TextureApplyTransition) apply =
-    new TextureApplyTransition(TextureApplyProperty::M_modulate);
-  */
-
   apply_texture_attributes(tex, egg_tex);
   apply_texture_attributes(tex, egg_tex);
-  //  apply_texture_apply_attributes(apply, egg_tex);
+  CPT(RenderAttrib) apply = get_texture_apply_attributes(egg_tex);
 
 
   def._texture = TextureAttrib::make(tex);
   def._texture = TextureAttrib::make(tex);
-  //  def._apply = *(_texture_applies.insert(apply).first);
+  def._apply = apply;
 
 
   return true;
   return true;
 }
 }
@@ -819,26 +770,25 @@ apply_texture_attributes(Texture *tex, const EggTexture *egg_tex) {
   }
   }
 }
 }
 
 
-/*
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: qpEggLoader::apply_texture_apply_attributes
 //     Function: qpEggLoader::apply_texture_apply_attributes
 //       Access: Private
 //       Access: Private
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-void qpEggLoader::
-apply_texture_apply_attributes(TextureApplyTransition *apply,
-                               const EggTexture *egg_tex) {
+CPT(RenderAttrib) qpEggLoader::
+get_texture_apply_attributes(const EggTexture *egg_tex) {
+  CPT(RenderAttrib) result = TextureApplyAttrib::make(TextureApplyAttrib::M_modulate);
   if (egg_always_decal_textures) {
   if (egg_always_decal_textures) {
-    apply->set_mode(TextureApplyProperty::M_decal);
+    result = TextureApplyAttrib::make(TextureApplyAttrib::M_decal);
 
 
   } else {
   } else {
     switch (egg_tex->get_env_type()) {
     switch (egg_tex->get_env_type()) {
     case EggTexture::ET_modulate:
     case EggTexture::ET_modulate:
-      apply->set_mode(TextureApplyProperty::M_modulate);
+      result = TextureApplyAttrib::make(TextureApplyAttrib::M_modulate);
       break;
       break;
 
 
     case EggTexture::ET_decal:
     case EggTexture::ET_decal:
-      apply->set_mode(TextureApplyProperty::M_decal);
+      result = TextureApplyAttrib::make(TextureApplyAttrib::M_decal);
       break;
       break;
 
 
     case EggTexture::ET_unspecified:
     case EggTexture::ET_unspecified:
@@ -850,19 +800,19 @@ apply_texture_apply_attributes(TextureApplyTransition *apply,
         << (int)egg_tex->get_env_type() << "\n";
         << (int)egg_tex->get_env_type() << "\n";
     }
     }
   }
   }
+
+  return result;
 }
 }
-*/
 
 
-/*
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: qpEggLoader::get_material_transition
+//     Function: qpEggLoader::get_material_attrib
 //       Access: Private
 //       Access: Private
-//  Description: Returns a transition suitable for enabling the
+//  Description: Returns a RenderAttrib suitable for enabling the
 //               material indicated by the given EggMaterial, and with
 //               material indicated by the given EggMaterial, and with
 //               the indicated backface flag.
 //               the indicated backface flag.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-MaterialTransition *qpEggLoader::
-get_material_transition(const EggMaterial *egg_mat, bool bface) {
+CPT(RenderAttrib) qpEggLoader::
+get_material_attrib(const EggMaterial *egg_mat, bool bface) {
   Materials &materials = bface ? _materials_bface : _materials;
   Materials &materials = bface ? _materials_bface : _materials;
 
 
   // First, check whether we've seen this material before.
   // First, check whether we've seen this material before.
@@ -902,13 +852,12 @@ get_material_transition(const EggMaterial *egg_mat, bool bface) {
   // Now get a global Material pointer, shared with other models.
   // Now get a global Material pointer, shared with other models.
   const Material *shared_mat = MaterialPool::get_material(mat);
   const Material *shared_mat = MaterialPool::get_material(mat);
 
 
-  // And create a MaterialTransition for this Material.
-  PT(MaterialTransition) mt = new MaterialTransition(shared_mat);
+  // And create a MaterialAttrib for this Material.
+  CPT(RenderAttrib) mt = MaterialAttrib::make(shared_mat);
   materials.insert(Materials::value_type(egg_mat, mt));
   materials.insert(Materials::value_type(egg_mat, mt));
 
 
   return mt;
   return mt;
 }
 }
-*/
 
 
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -989,7 +938,7 @@ setup_bucket(BuilderBucket &bucket, PandaNode *parent,
     const TextureDef &def = _textures[egg_tex];
     const TextureDef &def = _textures[egg_tex];
     if (def._texture != (const RenderAttrib *)NULL) {
     if (def._texture != (const RenderAttrib *)NULL) {
       bucket.add_attrib(def._texture);
       bucket.add_attrib(def._texture);
-      //      bucket.add_attrib(def._apply);
+      bucket.add_attrib(def._apply);
 
 
       // If neither the primitive nor the texture specified an alpha
       // If neither the primitive nor the texture specified an alpha
       // mode, assume it should be alpha'ed if the texture has an
       // mode, assume it should be alpha'ed if the texture has an
@@ -1006,13 +955,12 @@ setup_bucket(BuilderBucket &bucket, PandaNode *parent,
     }
     }
   }
   }
 
 
-  /*
   if (egg_prim->has_material()) {
   if (egg_prim->has_material()) {
-    MaterialTransition *mt = get_material_transition(egg_prim->get_material(),
-                                                     egg_prim->get_bface_flag());
+    CPT(RenderAttrib) mt =
+      get_material_attrib(egg_prim->get_material(),
+                          egg_prim->get_bface_flag());
     bucket.add_attrib(mt);
     bucket.add_attrib(mt);
   }
   }
-  */
 
 
 
 
   // Also check the color of the primitive to see if we should assume
   // Also check the color of the primitive to see if we should assume
@@ -1047,7 +995,7 @@ setup_bucket(BuilderBucket &bucket, PandaNode *parent,
 
 
   case EggRenderMode::AM_blend_no_occlude:
   case EggRenderMode::AM_blend_no_occlude:
     bucket.add_attrib(TransparencyAttrib::make(TransparencyAttrib::M_alpha));
     bucket.add_attrib(TransparencyAttrib::make(TransparencyAttrib::M_alpha));
-    //    bucket.add_attrib(new DepthWriteTransition(DepthWriteTransition::off()));
+    bucket.add_attrib(DepthWriteAttrib::make(DepthWriteAttrib::M_off));
     break;
     break;
 
 
   case EggRenderMode::AM_ms:
   case EggRenderMode::AM_ms:
@@ -1063,35 +1011,31 @@ setup_bucket(BuilderBucket &bucket, PandaNode *parent,
     break;
     break;
   }
   }
 
 
-  /*
   switch (dwm) {
   switch (dwm) {
   case EggRenderMode::DWM_on:
   case EggRenderMode::DWM_on:
-    bucket.add_attrib(new DepthWriteTransition);
+    bucket.add_attrib(DepthWriteAttrib::make(DepthWriteAttrib::M_on));
     break;
     break;
 
 
   case EggRenderMode::DWM_off:
   case EggRenderMode::DWM_off:
-    bucket.add_attrib(new DepthWriteTransition(DepthWriteTransition::off()));
+    bucket.add_attrib(DepthWriteAttrib::make(DepthWriteAttrib::M_off));
     break;
     break;
 
 
   default:
   default:
     break;
     break;
   }
   }
-  */
 
 
-  /*
   switch (dtm) {
   switch (dtm) {
   case EggRenderMode::DTM_on:
   case EggRenderMode::DTM_on:
-    bucket.add_attrib(new DepthTestTransition(DepthTestProperty::M_less));
+    bucket.add_attrib(DepthTestAttrib::make(DepthTestAttrib::M_less));
     break;
     break;
 
 
   case EggRenderMode::DTM_off:
   case EggRenderMode::DTM_off:
-    bucket.add_attrib(new DepthTestTransition(DepthTestProperty::M_none));
+    bucket.add_attrib(DepthTestAttrib::make(DepthTestAttrib::M_none));
     break;
     break;
 
 
   default:
   default:
     break;
     break;
   }
   }
-  */
 
 
   if (has_bin) {
   if (has_bin) {
     bucket.add_attrib(CullBinAttrib::make(bin, draw_order));
     bucket.add_attrib(CullBinAttrib::make(bin, draw_order));
@@ -1477,7 +1421,7 @@ make_node(EggGroup *egg_group, PandaNode *parent) {
 //     Function: qpEggLoader::create_group_arc
 //     Function: qpEggLoader::create_group_arc
 //       Access: Private
 //       Access: Private
 //  Description: Creates the arc parenting a new group to the scene
 //  Description: Creates the arc parenting a new group to the scene
-//               graph, and applies any relevant transitions to the
+//               graph, and applies any relevant attribs to the
 //               arc according to the EggGroup node that inspired the
 //               arc according to the EggGroup node that inspired the
 //               group.
 //               group.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -1523,22 +1467,6 @@ create_group_arc(EggGroup *egg_group, PandaNode *parent, PandaNode *node) {
     _decals.insert(node);
     _decals.insert(node);
   }
   }
 
 
-  /*
-  if (egg_group->get_direct_flag()) {
-    // If the group has the "direct" flag set, it means that
-    // everything at this node and below should be rendered in direct
-    // mode, i.e. in depth-first tree order, without state-sorting.
-
-    arc->set_transition(new DirectRenderTransition);
-
-    // We'll also want to set up the transitions on this arc to
-    // reflect the geometry at the top of the tree below this node, so
-    // we get good state-sorting behavior.  We'll have to do this
-    // later.
-    _directs.insert(arc);
-  }
-  */
-
   /*
   /*
   // If the group specified some property that should propagate down
   // If the group specified some property that should propagate down
   // to the leaves, we have to remember this arc and apply the
   // to the leaves, we have to remember this arc and apply the
@@ -2002,7 +1930,7 @@ void qpEggLoader::
 apply_deferred_arcs(Node *root) {
 apply_deferred_arcs(Node *root) {
   DeferredArcTraverser trav(_deferred_arcs);
   DeferredArcTraverser trav(_deferred_arcs);
 
 
-  df_traverse(root, trav, NullTransitionWrapper(), DeferredArcProperty(),
+  df_traverse(root, trav, NullAttribWrapper(), DeferredArcProperty(),
               PandaNode::get_class_type());
               PandaNode::get_class_type());
 }
 }
 */
 */

+ 5 - 14
panda/src/egg2pg/qpeggLoader.h

@@ -64,7 +64,6 @@ public:
 
 
   void build_graph();
   void build_graph();
   void reparent_decals();
   void reparent_decals();
-  void reset_directs();
 
 
   void make_nonindexed_primitive(EggPrimitive *egg_prim, PandaNode *parent,
   void make_nonindexed_primitive(EggPrimitive *egg_prim, PandaNode *parent,
                                  const LMatrix4d *transform = NULL);
                                  const LMatrix4d *transform = NULL);
@@ -77,19 +76,16 @@ private:
   class TextureDef {
   class TextureDef {
   public:
   public:
     CPT(RenderAttrib) _texture;
     CPT(RenderAttrib) _texture;
-    //    PT(TextureApplyTransition) _apply;
+    CPT(RenderAttrib) _apply;
   };
   };
 
 
   void load_textures();
   void load_textures();
   bool load_texture(TextureDef &def, const EggTexture *egg_tex);
   bool load_texture(TextureDef &def, const EggTexture *egg_tex);
   void apply_texture_attributes(Texture *tex, const EggTexture *egg_tex);
   void apply_texture_attributes(Texture *tex, const EggTexture *egg_tex);
-  void apply_texture_apply_attributes(TextureApplyTransition *apply,
-                                      const EggTexture *egg_tex);
+  CPT(RenderAttrib) get_texture_apply_attributes(const EggTexture *egg_tex);
 
 
-  /*
-  MaterialTransition *get_material_transition(const EggMaterial *egg_mat,
-                                              bool bface);
-  */
+  CPT(RenderAttrib) get_material_attrib(const EggMaterial *egg_mat,
+                                        bool bface);
 
 
   void setup_bucket(BuilderBucket &bucket, PandaNode *parent,
   void setup_bucket(BuilderBucket &bucket, PandaNode *parent,
                     EggPrimitive *egg_prim);
                     EggPrimitive *egg_prim);
@@ -133,19 +129,14 @@ private:
   typedef pmap<PT_EggTexture, TextureDef> Textures;
   typedef pmap<PT_EggTexture, TextureDef> Textures;
   Textures _textures;
   Textures _textures;
 
 
-  /*
-  typedef pmap<CPT_EggMaterial, PT(MaterialTransition) > Materials;
+  typedef pmap<CPT_EggMaterial, CPT(RenderAttrib) > Materials;
   Materials _materials;
   Materials _materials;
   Materials _materials_bface;
   Materials _materials_bface;
-  */
 
 
   typedef pset<PandaNode *> Decals;
   typedef pset<PandaNode *> Decals;
   Decals _decals;
   Decals _decals;
 
 
   /*
   /*
-  typedef pset<PandaNode *> Directs;
-  Directs _directs;
-
   DeferredArcs _deferred_arcs;
   DeferredArcs _deferred_arcs;
   */
   */
 
 

+ 32 - 0
panda/src/glgsg/glGraphicsStateGuardian.cxx

@@ -3455,6 +3455,18 @@ issue_texture(const TextureAttrib *attrib) {
   report_errors();
   report_errors();
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: GLGraphicsStateGuardian::issue_texture_apply
+//       Access: Public, Virtual
+//  Description:
+////////////////////////////////////////////////////////////////////
+void GLGraphicsStateGuardian::
+issue_texture_apply(const TextureApplyAttrib *attrib) {
+  GLint glmode = get_texture_apply_mode_type(attrib->get_mode());
+  glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, glmode);
+  report_errors();
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GLGraphicsStateGuardian::issue_cull_face
 //     Function: GLGraphicsStateGuardian::issue_cull_face
 //       Access: Public, Virtual
 //       Access: Public, Virtual
@@ -4386,6 +4398,26 @@ get_texture_apply_mode_type( TextureApplyProperty::Mode am ) const
   return GL_MODULATE;
   return GL_MODULATE;
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: GLGraphicsStateGuardian::get_texture_apply_mode_type
+//       Access: Protected
+//  Description: Maps from the texture environment's mode types
+//       to the corresponding OpenGL ids
+////////////////////////////////////////////////////////////////////
+GLint GLGraphicsStateGuardian::
+get_texture_apply_mode_type(TextureApplyAttrib::Mode am) const {
+  switch (am) {
+  case TextureApplyAttrib::M_modulate: return GL_MODULATE;
+  case TextureApplyAttrib::M_decal: return GL_DECAL;
+  case TextureApplyAttrib::M_blend: return GL_BLEND;
+  case TextureApplyAttrib::M_replace: return GL_REPLACE;
+  case TextureApplyAttrib::M_add: return GL_ADD;
+  }
+  glgsg_cat.error()
+    << "Invalid TextureApplyAttrib::Mode value" << endl;
+  return GL_MODULATE;
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GLGraphicsStateGuardian::get_depth_func_type
 //     Function: GLGraphicsStateGuardian::get_depth_func_type
 //       Access: Protected
 //       Access: Protected

+ 3 - 1
panda/src/glgsg/glGraphicsStateGuardian.h

@@ -34,8 +34,8 @@
 #include "stencilProperty.h"
 #include "stencilProperty.h"
 #include "fog.h"
 #include "fog.h"
 #include "pt_Light.h"
 #include "pt_Light.h"
-
 #include "depthTestAttrib.h"
 #include "depthTestAttrib.h"
+#include "textureApplyAttrib.h"
 #include "pointerToArray.h"
 #include "pointerToArray.h"
 
 
 #ifdef WIN32_VC
 #ifdef WIN32_VC
@@ -160,6 +160,7 @@ public:
 
 
   virtual void issue_transform(const TransformState *transform);
   virtual void issue_transform(const TransformState *transform);
   virtual void issue_texture(const TextureAttrib *attrib);
   virtual void issue_texture(const TextureAttrib *attrib);
+  virtual void issue_texture_apply(const TextureApplyAttrib *attrib);
   virtual void issue_cull_face(const CullFaceAttrib *attrib);
   virtual void issue_cull_face(const CullFaceAttrib *attrib);
   virtual void issue_transparency(const TransparencyAttrib *attrib);
   virtual void issue_transparency(const TransparencyAttrib *attrib);
   virtual void issue_color_write(const ColorWriteAttrib *attrib);
   virtual void issue_color_write(const ColorWriteAttrib *attrib);
@@ -264,6 +265,7 @@ protected:
   GLenum get_external_image_format(PixelBuffer::Format format);
   GLenum get_external_image_format(PixelBuffer::Format format);
   GLenum get_internal_image_format(PixelBuffer::Format format);
   GLenum get_internal_image_format(PixelBuffer::Format format);
   GLint get_texture_apply_mode_type( TextureApplyProperty::Mode am ) const;
   GLint get_texture_apply_mode_type( TextureApplyProperty::Mode am ) const;
+  GLint get_texture_apply_mode_type(TextureApplyAttrib::Mode am) const;
   GLenum get_depth_func_type(DepthTestProperty::Mode m) const;
   GLenum get_depth_func_type(DepthTestProperty::Mode m) const;
   GLenum get_depth_func_type(DepthTestAttrib::Mode m) const;
   GLenum get_depth_func_type(DepthTestAttrib::Mode m) const;
   GLenum get_stencil_func_type(StencilProperty::Mode m) const;
   GLenum get_stencil_func_type(StencilProperty::Mode m) const;

+ 6 - 0
panda/src/pgraph/Sources.pp

@@ -28,11 +28,13 @@
     drawCullHandler.h drawCullHandler.I \
     drawCullHandler.h drawCullHandler.I \
     qpgeomNode.h qpgeomNode.I \
     qpgeomNode.h qpgeomNode.I \
     qplensNode.h qplensNode.I \
     qplensNode.h qplensNode.I \
+    materialAttrib.h materialAttrib.I \
     nodeChain.h nodeChain.I \
     nodeChain.h nodeChain.I \
     nodeChainComponent.h nodeChainComponent.I \
     nodeChainComponent.h nodeChainComponent.I \
     pandaNode.h pandaNode.I \
     pandaNode.h pandaNode.I \
     renderAttrib.h renderAttrib.I \
     renderAttrib.h renderAttrib.I \
     renderState.h renderState.I \
     renderState.h renderState.I \
+    textureApplyAttrib.h textureApplyAttrib.I \
     textureAttrib.h textureAttrib.I \
     textureAttrib.h textureAttrib.I \
     transformState.h transformState.I \
     transformState.h transformState.I \
     transparencyAttrib.h transparencyAttrib.I
     transparencyAttrib.h transparencyAttrib.I
@@ -61,11 +63,13 @@
     drawCullHandler.cxx \
     drawCullHandler.cxx \
     qpgeomNode.cxx \
     qpgeomNode.cxx \
     qplensNode.cxx \
     qplensNode.cxx \
+    materialAttrib.cxx \
     nodeChain.cxx \
     nodeChain.cxx \
     nodeChainComponent.cxx \
     nodeChainComponent.cxx \
     pandaNode.cxx \
     pandaNode.cxx \
     renderAttrib.cxx \
     renderAttrib.cxx \
     renderState.cxx \
     renderState.cxx \
+    textureApplyAttrib.cxx \
     textureAttrib.cxx \
     textureAttrib.cxx \
     transformState.cxx \
     transformState.cxx \
     transparencyAttrib.cxx
     transparencyAttrib.cxx
@@ -99,11 +103,13 @@
     drawCullHandler.h drawCullHandler.I \
     drawCullHandler.h drawCullHandler.I \
     qpgeomNode.h qpgeomNode.I \
     qpgeomNode.h qpgeomNode.I \
     qplensNode.h qplensNode.I \
     qplensNode.h qplensNode.I \
+    materialAttrib.h materialAttrib.I \
     nodeChain.h nodeChain.I \
     nodeChain.h nodeChain.I \
     nodeChainComponent.h nodeChainComponent.I \
     nodeChainComponent.h nodeChainComponent.I \
     pandaNode.h pandaNode.I \
     pandaNode.h pandaNode.I \
     renderAttrib.h renderAttrib.I \
     renderAttrib.h renderAttrib.I \
     renderState.h renderState.I \
     renderState.h renderState.I \
+    textureApplyAttrib.h textureApplyAttrib.I \
     textureAttrib.h textureAttrib.I \
     textureAttrib.h textureAttrib.I \
     transformState.h transformState.I \
     transformState.h transformState.I \
     transparencyAttrib.h transparencyAttrib.I
     transparencyAttrib.h transparencyAttrib.I

+ 6 - 3
panda/src/pgraph/config_pgraph.cxx

@@ -33,13 +33,14 @@
 #include "depthWriteAttrib.h"
 #include "depthWriteAttrib.h"
 #include "qpgeomNode.h"
 #include "qpgeomNode.h"
 #include "qplensNode.h"
 #include "qplensNode.h"
+#include "materialAttrib.h"
 #include "nodeChain.h"
 #include "nodeChain.h"
 #include "nodeChainComponent.h"
 #include "nodeChainComponent.h"
 #include "pandaNode.h"
 #include "pandaNode.h"
 #include "renderAttrib.h"
 #include "renderAttrib.h"
 #include "renderState.h"
 #include "renderState.h"
+#include "textureApplyAttrib.h"
 #include "textureAttrib.h"
 #include "textureAttrib.h"
-#include "colorAttrib.h"
 #include "transformState.h"
 #include "transformState.h"
 #include "transparencyAttrib.h"
 #include "transparencyAttrib.h"
 
 
@@ -89,13 +90,14 @@ init_libpgraph() {
   DepthWriteAttrib::init_type();
   DepthWriteAttrib::init_type();
   qpGeomNode::init_type();
   qpGeomNode::init_type();
   qpLensNode::init_type();
   qpLensNode::init_type();
+  MaterialAttrib::init_type();
   NodeChain::init_type();
   NodeChain::init_type();
   NodeChainComponent::init_type();
   NodeChainComponent::init_type();
   PandaNode::init_type();
   PandaNode::init_type();
   RenderAttrib::init_type();
   RenderAttrib::init_type();
   RenderState::init_type();
   RenderState::init_type();
+  TextureApplyAttrib::init_type();
   TextureAttrib::init_type();
   TextureAttrib::init_type();
-  ColorAttrib::init_type();
   TransformState::init_type();
   TransformState::init_type();
   TransparencyAttrib::init_type();
   TransparencyAttrib::init_type();
 
 
@@ -108,10 +110,11 @@ init_libpgraph() {
   DepthTestAttrib::register_with_read_factory();
   DepthTestAttrib::register_with_read_factory();
   DepthWriteAttrib::register_with_read_factory();
   DepthWriteAttrib::register_with_read_factory();
   qpGeomNode::register_with_read_factory();
   qpGeomNode::register_with_read_factory();
+  MaterialAttrib::register_with_read_factory();
   PandaNode::register_with_read_factory();
   PandaNode::register_with_read_factory();
   RenderState::register_with_read_factory();
   RenderState::register_with_read_factory();
+  TextureApplyAttrib::register_with_read_factory();
   TextureAttrib::register_with_read_factory();
   TextureAttrib::register_with_read_factory();
-  ColorAttrib::register_with_read_factory();
   TransformState::register_with_read_factory();
   TransformState::register_with_read_factory();
   TransparencyAttrib::register_with_read_factory();
   TransparencyAttrib::register_with_read_factory();
 }
 }

+ 52 - 0
panda/src/pgraph/materialAttrib.I

@@ -0,0 +1,52 @@
+// Filename: materialAttrib.I
+// Created by:  drose (04Mar02)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
+//
+// All use of this software is subject to the terms of the Panda 3d
+// Software license.  You should have received a copy of this license
+// along with this source code; you will also find a current copy of
+// the license at http://www.panda3d.org/license.txt .
+//
+// To contact the maintainers of this program write to
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+
+////////////////////////////////////////////////////////////////////
+//     Function: MaterialAttrib::Constructor
+//       Access: Private
+//  Description: Use MaterialAttrib::make() to construct a new
+//               MaterialAttrib object.
+////////////////////////////////////////////////////////////////////
+INLINE MaterialAttrib::
+MaterialAttrib() {
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: MaterialAttrib::is_off
+//       Access: Published
+//  Description: Returns true if the MaterialAttrib is an 'off'
+//               MaterialAttrib, indicating that it should disable
+//               texturing.
+////////////////////////////////////////////////////////////////////
+INLINE bool MaterialAttrib::
+is_off() const {
+  return _material == (const Material *)NULL;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: MaterialAttrib::get_material
+//       Access: Published
+//  Description: If the MaterialAttrib is not an 'off' MaterialAttrib,
+//               returns the material that is associated.  Otherwise,
+//               return NULL.
+////////////////////////////////////////////////////////////////////
+INLINE const Material *MaterialAttrib::
+get_material() const {
+  return _material;
+}

+ 196 - 0
panda/src/pgraph/materialAttrib.cxx

@@ -0,0 +1,196 @@
+// Filename: materialAttrib.cxx
+// Created by:  drose (04Mar02)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
+//
+// All use of this software is subject to the terms of the Panda 3d
+// Software license.  You should have received a copy of this license
+// along with this source code; you will also find a current copy of
+// the license at http://www.panda3d.org/license.txt .
+//
+// To contact the maintainers of this program write to
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+#include "materialAttrib.h"
+#include "graphicsStateGuardianBase.h"
+#include "bamReader.h"
+#include "bamWriter.h"
+#include "datagram.h"
+#include "datagramIterator.h"
+
+TypeHandle MaterialAttrib::_type_handle;
+
+////////////////////////////////////////////////////////////////////
+//     Function: MaterialAttrib::make
+//       Access: Published, Static
+//  Description: Constructs a new MaterialAttrib object suitable for
+//               rendering the indicated material onto geometry.
+////////////////////////////////////////////////////////////////////
+CPT(RenderAttrib) MaterialAttrib::
+make(const Material *material) {
+  MaterialAttrib *attrib = new MaterialAttrib;
+  attrib->_material = material;
+  return return_new(attrib);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: MaterialAttrib::make_off
+//       Access: Published, Static
+//  Description: Constructs a new MaterialAttrib object suitable for
+//               rendering unmateriald geometry.
+////////////////////////////////////////////////////////////////////
+CPT(RenderAttrib) MaterialAttrib::
+make_off() {
+  MaterialAttrib *attrib = new MaterialAttrib;
+  return return_new(attrib);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: MaterialAttrib::issue
+//       Access: Public, Virtual
+//  Description: Calls the appropriate method on the indicated GSG
+//               to issue the graphics commands appropriate to the
+//               given attribute.  This is normally called
+//               (indirectly) only from
+//               GraphicsStateGuardian::set_state() or modify_state().
+////////////////////////////////////////////////////////////////////
+void MaterialAttrib::
+issue(GraphicsStateGuardianBase *gsg) const {
+  gsg->issue_material(this);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: MaterialAttrib::output
+//       Access: Public, Virtual
+//  Description: 
+////////////////////////////////////////////////////////////////////
+void MaterialAttrib::
+output(ostream &out) const {
+  out << get_type() << ":";
+  if (is_off()) {
+    out << "(off)";
+  } else {
+    out << *_material;
+  }
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: MaterialAttrib::compare_to_impl
+//       Access: Protected, Virtual
+//  Description: Intended to be overridden by derived MaterialAttrib
+//               types to return a unique number indicating whether
+//               this MaterialAttrib is equivalent to the other one.
+//
+//               This should return 0 if the two MaterialAttrib objects
+//               are equivalent, a number less than zero if this one
+//               should be sorted before the other one, and a number
+//               greater than zero otherwise.
+//
+//               This will only be called with two MaterialAttrib
+//               objects whose get_type() functions return the same.
+////////////////////////////////////////////////////////////////////
+int MaterialAttrib::
+compare_to_impl(const RenderAttrib *other) const {
+  const MaterialAttrib *ta;
+  DCAST_INTO_R(ta, other, 0);
+  return (int)(_material - ta->_material);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: MaterialAttrib::make_default_impl
+//       Access: Protected, Virtual
+//  Description: Intended to be overridden by derived MaterialAttrib
+//               types to specify what the default property for a
+//               MaterialAttrib of this type should be.
+//
+//               This should return a newly-allocated MaterialAttrib of
+//               the same type that corresponds to whatever the
+//               standard default for this kind of MaterialAttrib is.
+////////////////////////////////////////////////////////////////////
+RenderAttrib *MaterialAttrib::
+make_default_impl() const {
+  return new MaterialAttrib;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: MaterialAttrib::register_with_read_factory
+//       Access: Public, Static
+//  Description: Tells the BamReader how to create objects of type
+//               MaterialAttrib.
+////////////////////////////////////////////////////////////////////
+void MaterialAttrib::
+register_with_read_factory() {
+  BamReader::get_factory()->register_factory(get_class_type(), make_from_bam);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: MaterialAttrib::write_datagram
+//       Access: Public, Virtual
+//  Description: Writes the contents of this object to the datagram
+//               for shipping out to a Bam file.
+////////////////////////////////////////////////////////////////////
+void MaterialAttrib::
+write_datagram(BamWriter *manager, Datagram &dg) {
+  RenderAttrib::write_datagram(manager, dg);
+
+  manager->write_pointer(dg, _material);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: MaterialAttrib::complete_pointers
+//       Access: Public, Virtual
+//  Description: Receives an array of pointers, one for each time
+//               manager->read_pointer() was called in fillin().
+//               Returns the number of pointers processed.
+////////////////////////////////////////////////////////////////////
+int MaterialAttrib::
+complete_pointers(TypedWritable **p_list, BamReader *manager) {
+  int pi = RenderAttrib::complete_pointers(p_list, manager);
+
+  TypedWritable *material = p_list[pi++];
+  if (material != (TypedWritable *)NULL) {
+    _material = DCAST(Material, material);
+  }
+
+  return pi;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: MaterialAttrib::make_from_bam
+//       Access: Protected, Static
+//  Description: This function is called by the BamReader's factory
+//               when a new object of type MaterialAttrib is encountered
+//               in the Bam file.  It should create the MaterialAttrib
+//               and extract its information from the file.
+////////////////////////////////////////////////////////////////////
+TypedWritable *MaterialAttrib::
+make_from_bam(const FactoryParams &params) {
+  MaterialAttrib *attrib = new MaterialAttrib;
+  DatagramIterator scan;
+  BamReader *manager;
+
+  parse_params(params, scan, manager);
+  attrib->fillin(scan, manager);
+
+  return attrib;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: MaterialAttrib::fillin
+//       Access: Protected
+//  Description: This internal function is called by make_from_bam to
+//               read in all of the relevant data from the BamFile for
+//               the new MaterialAttrib.
+////////////////////////////////////////////////////////////////////
+void MaterialAttrib::
+fillin(DatagramIterator &scan, BamReader *manager) {
+  RenderAttrib::fillin(scan, manager);
+
+  // Read the _material pointer.
+  manager->read_pointer(scan, this);
+}

+ 86 - 0
panda/src/pgraph/materialAttrib.h

@@ -0,0 +1,86 @@
+// Filename: materialAttrib.h
+// Created by:  drose (04Mar02)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
+//
+// All use of this software is subject to the terms of the Panda 3d
+// Software license.  You should have received a copy of this license
+// along with this source code; you will also find a current copy of
+// the license at http://www.panda3d.org/license.txt .
+//
+// To contact the maintainers of this program write to
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+#ifndef MATERIALATTRIB_H
+#define MATERIALATTRIB_H
+
+#include "pandabase.h"
+
+#include "renderAttrib.h"
+#include "material.h"
+
+////////////////////////////////////////////////////////////////////
+//       Class : MaterialAttrib
+// Description : Indicates which, if any, material should be applied
+//               to geometry.  The material is used primarily to
+//               control lighting effects, and isn't necessarily (or
+//               useful) in the absence of lighting.
+////////////////////////////////////////////////////////////////////
+class EXPCL_PANDA MaterialAttrib : public RenderAttrib {
+private:
+  INLINE MaterialAttrib();
+
+PUBLISHED:
+  static CPT(RenderAttrib) make(const Material *tex);
+  static CPT(RenderAttrib) make_off();
+
+  INLINE bool is_off() const;
+  INLINE const Material *get_material() const;
+
+public:
+  virtual void issue(GraphicsStateGuardianBase *gsg) const;
+  virtual void output(ostream &out) const;
+
+protected:
+  virtual int compare_to_impl(const RenderAttrib *other) const;
+  virtual RenderAttrib *make_default_impl() const;
+
+private:
+  CPT(Material) _material;
+
+public:
+  static void register_with_read_factory();
+  virtual void write_datagram(BamWriter *manager, Datagram &dg);
+  virtual int complete_pointers(TypedWritable **plist, BamReader *manager);
+
+protected:
+  static TypedWritable *make_from_bam(const FactoryParams &params);
+  void fillin(DatagramIterator &scan, BamReader *manager);
+  
+public:
+  static TypeHandle get_class_type() {
+    return _type_handle;
+  }
+  static void init_type() {
+    RenderAttrib::init_type();
+    register_type(_type_handle, "MaterialAttrib",
+                  RenderAttrib::get_class_type());
+  }
+  virtual TypeHandle get_type() const {
+    return get_class_type();
+  }
+  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
+
+private:
+  static TypeHandle _type_handle;
+};
+
+#include "materialAttrib.I"
+
+#endif
+

+ 2 - 0
panda/src/pgraph/pgraph_composite1.cxx

@@ -13,3 +13,5 @@
 #include "cullHandler.cxx"
 #include "cullHandler.cxx"
 #include "cullResult.cxx"
 #include "cullResult.cxx"
 #include "qpcullTraverser.cxx"
 #include "qpcullTraverser.cxx"
+#include "cullableObject.cxx"
+

+ 2 - 1
panda/src/pgraph/pgraph_composite2.cxx

@@ -1,16 +1,17 @@
-#include "cullableObject.cxx"
 #include "decalAttrib.cxx"
 #include "decalAttrib.cxx"
 #include "depthTestAttrib.cxx"
 #include "depthTestAttrib.cxx"
 #include "depthWriteAttrib.cxx"
 #include "depthWriteAttrib.cxx"
 #include "drawCullHandler.cxx"
 #include "drawCullHandler.cxx"
 #include "qpgeomNode.cxx"
 #include "qpgeomNode.cxx"
 #include "qplensNode.cxx"
 #include "qplensNode.cxx"
+#include "materialAttrib.cxx"
 #include "nodeChain.cxx"
 #include "nodeChain.cxx"
 #include "nodeChainComponent.cxx"
 #include "nodeChainComponent.cxx"
 #include "pandaNode.cxx"
 #include "pandaNode.cxx"
 #include "renderAttrib.cxx"
 #include "renderAttrib.cxx"
 #include "renderState.cxx"
 #include "renderState.cxx"
 #include "test_pgraph.cxx"
 #include "test_pgraph.cxx"
+#include "textureApplyAttrib.cxx"
 #include "textureAttrib.cxx"
 #include "textureAttrib.cxx"
 #include "transformState.cxx"
 #include "transformState.cxx"
 #include "transparencyAttrib.cxx"
 #include "transparencyAttrib.cxx"

+ 40 - 0
panda/src/pgraph/textureApplyAttrib.I

@@ -0,0 +1,40 @@
+// Filename: textureApplyAttrib.I
+// Created by:  drose (04Mar02)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
+//
+// All use of this software is subject to the terms of the Panda 3d
+// Software license.  You should have received a copy of this license
+// along with this source code; you will also find a current copy of
+// the license at http://www.panda3d.org/license.txt .
+//
+// To contact the maintainers of this program write to
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+
+////////////////////////////////////////////////////////////////////
+//     Function: TextureApplyAttrib::Constructor
+//       Access: Private
+//  Description: Use TextureApplyAttrib::make() to construct a new
+//               TextureApplyAttrib object.
+////////////////////////////////////////////////////////////////////
+INLINE TextureApplyAttrib::
+TextureApplyAttrib(TextureApplyAttrib::Mode mode) :
+  _mode(mode)
+{
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: TextureApplyAttrib::get_mode
+//       Access: Published
+//  Description: Returns the culling mode.
+////////////////////////////////////////////////////////////////////
+INLINE TextureApplyAttrib::Mode TextureApplyAttrib::
+get_mode() const {
+  return _mode;
+}

+ 183 - 0
panda/src/pgraph/textureApplyAttrib.cxx

@@ -0,0 +1,183 @@
+// Filename: textureApplyAttrib.cxx
+// Created by:  drose (04Mar02)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
+//
+// All use of this software is subject to the terms of the Panda 3d
+// Software license.  You should have received a copy of this license
+// along with this source code; you will also find a current copy of
+// the license at http://www.panda3d.org/license.txt .
+//
+// To contact the maintainers of this program write to
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+#include "textureApplyAttrib.h"
+#include "graphicsStateGuardianBase.h"
+#include "dcast.h"
+#include "bamReader.h"
+#include "bamWriter.h"
+#include "datagram.h"
+#include "datagramIterator.h"
+
+TypeHandle TextureApplyAttrib::_type_handle;
+
+////////////////////////////////////////////////////////////////////
+//     Function: TextureApplyAttrib::make
+//       Access: Published, Static
+//  Description: Constructs a new TextureApplyAttrib object that specifies
+//               how to cull geometry.  By Panda convention, vertices
+//               are ordered counterclockwise when seen from the
+//               front, so the M_cull_clockwise will cull backfacing
+//               polygons.
+////////////////////////////////////////////////////////////////////
+CPT(RenderAttrib) TextureApplyAttrib::
+make(TextureApplyAttrib::Mode mode) {
+  TextureApplyAttrib *attrib = new TextureApplyAttrib(mode);
+  return return_new(attrib);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: TextureApplyAttrib::issue
+//       Access: Public, Virtual
+//  Description: Calls the appropriate method on the indicated GSG
+//               to issue the graphics commands appropriate to the
+//               given attribute.  This is normally called
+//               (indirectly) only from
+//               GraphicsStateGuardian::set_state() or modify_state().
+////////////////////////////////////////////////////////////////////
+void TextureApplyAttrib::
+issue(GraphicsStateGuardianBase *gsg) const {
+  gsg->issue_texture_apply(this);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: TextureApplyAttrib::output
+//       Access: Public, Virtual
+//  Description: 
+////////////////////////////////////////////////////////////////////
+void TextureApplyAttrib::
+output(ostream &out) const {
+  out << get_type() << ":";
+  switch (get_mode()) {
+  case M_modulate:
+    out << "modulate";
+    break;
+
+  case M_decal:
+    out << "decal";
+    break;
+
+  case M_blend:
+    out << "blend";
+    break;
+
+  case M_replace:
+    out << "replace";
+    break;
+
+  case M_add:
+    out << "add";
+    break;
+  }
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: TextureApplyAttrib::compare_to_impl
+//       Access: Protected, Virtual
+//  Description: Intended to be overridden by derived TextureApplyAttrib
+//               types to return a unique number indicating whether
+//               this TextureApplyAttrib is equivalent to the other one.
+//
+//               This should return 0 if the two TextureApplyAttrib objects
+//               are equivalent, a number less than zero if this one
+//               should be sorted before the other one, and a number
+//               greater than zero otherwise.
+//
+//               This will only be called with two TextureApplyAttrib
+//               objects whose get_type() functions return the same.
+////////////////////////////////////////////////////////////////////
+int TextureApplyAttrib::
+compare_to_impl(const RenderAttrib *other) const {
+  const TextureApplyAttrib *ta;
+  DCAST_INTO_R(ta, other, 0);
+  return (int)_mode - (int)ta->_mode;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: TextureApplyAttrib::make_default_impl
+//       Access: Protected, Virtual
+//  Description: Intended to be overridden by derived TextureApplyAttrib
+//               types to specify what the default property for a
+//               TextureApplyAttrib of this type should be.
+//
+//               This should return a newly-allocated TextureApplyAttrib of
+//               the same type that corresponds to whatever the
+//               standard default for this kind of TextureApplyAttrib is.
+////////////////////////////////////////////////////////////////////
+RenderAttrib *TextureApplyAttrib::
+make_default_impl() const {
+  return new TextureApplyAttrib;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: TextureApplyAttrib::register_with_read_factory
+//       Access: Public, Static
+//  Description: Tells the BamReader how to create objects of type
+//               TextureApplyAttrib.
+////////////////////////////////////////////////////////////////////
+void TextureApplyAttrib::
+register_with_read_factory() {
+  BamReader::get_factory()->register_factory(get_class_type(), make_from_bam);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: TextureApplyAttrib::write_datagram
+//       Access: Public, Virtual
+//  Description: Writes the contents of this object to the datagram
+//               for shipping out to a Bam file.
+////////////////////////////////////////////////////////////////////
+void TextureApplyAttrib::
+write_datagram(BamWriter *manager, Datagram &dg) {
+  RenderAttrib::write_datagram(manager, dg);
+
+  dg.add_int8(_mode);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: TextureApplyAttrib::make_from_bam
+//       Access: Protected, Static
+//  Description: This function is called by the BamReader's factory
+//               when a new object of type TextureApplyAttrib is encountered
+//               in the Bam file.  It should create the TextureApplyAttrib
+//               and extract its information from the file.
+////////////////////////////////////////////////////////////////////
+TypedWritable *TextureApplyAttrib::
+make_from_bam(const FactoryParams &params) {
+  TextureApplyAttrib *attrib = new TextureApplyAttrib;
+  DatagramIterator scan;
+  BamReader *manager;
+
+  parse_params(params, scan, manager);
+  attrib->fillin(scan, manager);
+
+  return attrib;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: TextureApplyAttrib::fillin
+//       Access: Protected
+//  Description: This internal function is called by make_from_bam to
+//               read in all of the relevant data from the BamFile for
+//               the new TextureApplyAttrib.
+////////////////////////////////////////////////////////////////////
+void TextureApplyAttrib::
+fillin(DatagramIterator &scan, BamReader *manager) {
+  RenderAttrib::fillin(scan, manager);
+
+  _mode = (Mode)scan.get_int8();
+}

+ 89 - 0
panda/src/pgraph/textureApplyAttrib.h

@@ -0,0 +1,89 @@
+// Filename: textureApplyAttrib.h
+// Created by:  drose (04Mar02)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
+//
+// All use of this software is subject to the terms of the Panda 3d
+// Software license.  You should have received a copy of this license
+// along with this source code; you will also find a current copy of
+// the license at http://www.panda3d.org/license.txt .
+//
+// To contact the maintainers of this program write to
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+#ifndef TEXTUREAPPLYATTRIB_H
+#define TEXTUREAPPLYATTRIB_H
+
+#include "pandabase.h"
+
+#include "renderAttrib.h"
+
+////////////////////////////////////////////////////////////////////
+//       Class : TextureApplyAttrib
+// Description : Specifies how textures are applied; specifically, how
+//               texture color modifies geometry color.
+////////////////////////////////////////////////////////////////////
+class EXPCL_PANDA TextureApplyAttrib : public RenderAttrib {
+PUBLISHED:
+  enum Mode {
+    M_modulate,
+    M_decal,
+    M_blend,
+    M_replace,
+    M_add
+  };
+
+private:
+  INLINE TextureApplyAttrib(Mode mode = M_modulate);
+
+PUBLISHED:
+  static CPT(RenderAttrib) make(Mode mode);
+
+  INLINE Mode get_mode() const;
+
+public:
+  virtual void issue(GraphicsStateGuardianBase *gsg) const;
+  virtual void output(ostream &out) const;
+
+protected:
+  virtual int compare_to_impl(const RenderAttrib *other) const;
+  virtual RenderAttrib *make_default_impl() const;
+
+private:
+  Mode _mode;
+
+public:
+  static void register_with_read_factory();
+  virtual void write_datagram(BamWriter *manager, Datagram &dg);
+
+protected:
+  static TypedWritable *make_from_bam(const FactoryParams &params);
+  void fillin(DatagramIterator &scan, BamReader *manager);
+  
+public:
+  static TypeHandle get_class_type() {
+    return _type_handle;
+  }
+  static void init_type() {
+    RenderAttrib::init_type();
+    register_type(_type_handle, "TextureApplyAttrib",
+                  RenderAttrib::get_class_type());
+  }
+  virtual TypeHandle get_type() const {
+    return get_class_type();
+  }
+  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
+
+private:
+  static TypeHandle _type_handle;
+};
+
+#include "textureApplyAttrib.I"
+
+#endif
+