Browse Source

*** empty log message ***

David Rose 25 years ago
parent
commit
eaf54bd45a
2 changed files with 28 additions and 13 deletions
  1. 2 2
      pandatool/src/flt/fltPackedColor.cxx
  2. 26 11
      pandatool/src/fltegg/fltToEggConverter.cxx

+ 2 - 2
pandatool/src/flt/fltPackedColor.cxx

@@ -27,8 +27,8 @@ extract_record(FltRecordReader &reader) {
   DatagramIterator &iterator = reader.get_iterator();
 
   _a = iterator.get_uint8();
-  _g = iterator.get_uint8();
   _b = iterator.get_uint8();
+  _g = iterator.get_uint8();
   _r = iterator.get_uint8();
 
   return true;
@@ -44,8 +44,8 @@ build_record(FltRecordWriter &writer) const {
   Datagram &datagram = writer.update_datagram();
 
   datagram.add_uint8(_a);
-  datagram.add_uint8(_g);
   datagram.add_uint8(_b);
+  datagram.add_uint8(_g);
   datagram.add_uint8(_r);
 
   return true;

+ 26 - 11
pandatool/src/fltegg/fltToEggConverter.cxx

@@ -336,10 +336,6 @@ setup_geometry(const FltGeometry *flt_geom, FltToEggLevelState &state,
   // Now examine the vertices.
   EggVertices::const_iterator vi;
 
-  if (flt_geom->has_color()) {
-    egg_prim->set_color(flt_geom->get_color());
-  }
-
   bool use_vertex_color = true;
   bool keep_normals = true;
   switch (flt_geom->_light_mode) {
@@ -377,18 +373,37 @@ setup_geometry(const FltGeometry *flt_geom, FltToEggLevelState &state,
     }
   }
 
+  // Get the alpha value based on the object's "transparency".
+  double a = 1.0 - (flt_geom->_transparency / 65536.0);
+  Colorf face_color;
+  
+  if (flt_geom->has_color()) {
+    // And make sure to set the transparency correctly.
+    face_color = flt_geom->get_color();
+    face_color[3] = a;
+    egg_prim->set_color(face_color);
+  }
+
   if (use_vertex_color) {
     // If we're to use vertex color instead of the face color, remove
     // the face color to eliminate any ambiguity.
-    if (flt_geom->has_color()) {
-      // Also, if some of our vertices don't have a color, set them to
-      // use the face color.
-      for (vi = vertices.begin(); vi != vertices.end(); ++vi) {
-	if (!(*vi)->has_color()) {
-	  (*vi)->set_color(flt_geom->get_color());
+    egg_prim->clear_color();
+
+    // Also, make sure the transparency is set correctly across all
+    // vertices.
+    for (vi = vertices.begin(); vi != vertices.end(); ++vi) {
+      EggVertex *vertex = (*vi);
+      if (vertex->has_color()) {
+	Colorf vertex_color = vertex->get_color();
+	vertex_color[3] = a;
+	vertex->set_color(vertex_color);
+      } else {
+	if (flt_geom->has_color()) {
+	  // If a vertex doesn't have a color but the face does, set
+	  // the vertex to use the face color.
+	  vertex->set_color(face_color);
 	}
       }
-      egg_prim->clear_color();
     }
 
   } else {