Bläddra i källkod

*** empty log message ***

David Rose 25 år sedan
förälder
incheckning
a38bbff0b7
2 ändrade filer med 30 tillägg och 9 borttagningar
  1. 24 6
      pandatool/src/lwoegg/cLwoSurface.cxx
  2. 6 3
      pandatool/src/lwoegg/cLwoSurface.h

+ 24 - 6
pandatool/src/lwoegg/cLwoSurface.cxx

@@ -69,6 +69,10 @@ CLwoSurface(LwoToEggConverter *converter, const LwoSurface *surface) :
 	_flags |= F_transparency;
 	_flags |= F_transparency;
 	_transparency = param->_value;
 	_transparency = param->_value;
 
 
+      } else if (type == IffId("GLOS")) {
+	_flags |= F_gloss;
+	_gloss = param->_value;
+
       } else if (type == IffId("TRNL")) {
       } else if (type == IffId("TRNL")) {
 	_flags |= F_translucency;
 	_flags |= F_translucency;
 	_translucency = param->_value;
 	_translucency = param->_value;
@@ -126,6 +130,8 @@ CLwoSurface(LwoToEggConverter *converter, const LwoSurface *surface) :
   if ((_flags & F_transparency) != 0) {
   if ((_flags & F_transparency) != 0) {
     _color[3] = 1.0 - _transparency;
     _color[3] = 1.0 - _transparency;
   }
   }
+
+  _diffuse_color = _color;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -165,7 +171,7 @@ apply_properties(EggPrimitive *egg_prim, vector_PT_EggVertex &egg_vertices,
   bool has_texture = check_texture();
   bool has_texture = check_texture();
   bool has_material = check_material();
   bool has_material = check_material();
 
 
-  egg_prim->set_color(_color);
+  egg_prim->set_color(_diffuse_color);
 
 
   if (has_material) {
   if (has_material) {
     egg_prim->set_material(_egg_material);
     egg_prim->set_material(_egg_material);
@@ -293,12 +299,19 @@ check_material() {
   _egg_material = new EggMaterial(get_name());
   _egg_material = new EggMaterial(get_name());
 
 
   if ((_flags & F_diffuse) != 0) {
   if ((_flags & F_diffuse) != 0) {
-    Colorf diffuse(_color[0] * _diffuse,
-		   _color[1] * _diffuse,
-		   _color[2] * _diffuse,
-		   _color[3]);
-    _egg_material->set_diff(diffuse);
+    _diffuse_color.set(_color[0] * _diffuse,
+		       _color[1] * _diffuse,
+		       _color[2] * _diffuse,
+		       _color[3]);
+    // We want to avoid setting the diffuse color on the material.
+    // We're already setting the color explicitly on the object, so
+    // there's no need to also set a diffuse color on the material,
+    // and doing so prevents nice features like set_color() and
+    // set_color_scale() from working in Panda.
+
+    //_egg_material->set_diff(_diffuse_color);
   }
   }
+
   if ((_flags & F_luminosity) != 0) {
   if ((_flags & F_luminosity) != 0) {
     Colorf luminosity(_color[0] * _luminosity,
     Colorf luminosity(_color[0] * _luminosity,
 		      _color[1] * _luminosity,
 		      _color[1] * _luminosity,
@@ -306,6 +319,7 @@ check_material() {
 		      1.0);
 		      1.0);
     _egg_material->set_emit(luminosity);
     _egg_material->set_emit(luminosity);
   }
   }
+
   if ((_flags & F_specular) != 0) {
   if ((_flags & F_specular) != 0) {
     Colorf specular(_color[0] * _specular,
     Colorf specular(_color[0] * _specular,
 		    _color[1] * _specular,
 		    _color[1] * _specular,
@@ -314,6 +328,10 @@ check_material() {
     _egg_material->set_spec(specular);
     _egg_material->set_spec(specular);
   }
   }
 
 
+  if ((_flags & F_gloss) != 0) {
+    _egg_material->set_shininess(_gloss * 128.0);
+  }
+
   return true;
   return true;
 }
 }
   
   

+ 6 - 3
pandatool/src/lwoegg/cLwoSurface.h

@@ -52,9 +52,10 @@ public:
     F_specular     = 0x0008,
     F_specular     = 0x0008,
     F_reflection   = 0x0010,
     F_reflection   = 0x0010,
     F_transparency = 0x0020,
     F_transparency = 0x0020,
-    F_translucency = 0x0040,
-    F_smooth_angle = 0x0080,
-    F_backface     = 0x0100,
+    F_gloss        = 0x0040,
+    F_translucency = 0x0080,
+    F_smooth_angle = 0x0100,
+    F_backface     = 0x0200,
   };
   };
   
   
   int _flags;
   int _flags;
@@ -64,11 +65,13 @@ public:
   float _specular;
   float _specular;
   float _reflection;
   float _reflection;
   float _transparency;
   float _transparency;
+  float _gloss;
   float _translucency;
   float _translucency;
   float _smooth_angle;
   float _smooth_angle;
   bool _backface;
   bool _backface;
 
 
   Colorf _color;
   Colorf _color;
+  Colorf _diffuse_color;
 
 
   LwoToEggConverter *_converter;
   LwoToEggConverter *_converter;
   CPT(LwoSurface) _surface;
   CPT(LwoSurface) _surface;