David Rose 14 years ago
parent
commit
fdf4cf15d4
2 changed files with 12 additions and 2 deletions
  1. 11 2
      pandatool/src/pfmprogs/pfmBba.cxx
  2. 1 0
      pandatool/src/pfmprogs/pfmBba.h

+ 11 - 2
pandatool/src/pfmprogs/pfmBba.cxx

@@ -33,10 +33,17 @@ PfmBba() {
      "Treats (0,0,0) in the pfm file as a special don't-touch value.",
      &PfmBba::dispatch_none, &_got_zero_special);
 
+  add_option
+    ("r", "index", 0,
+     "Selects a reorder index.",
+     &PfmBba::dispatch_int, NULL, &_reorder_index);
+
   add_option
     ("o", "filename", 50,
      "Specify the filename to which the resulting bba file will be written.",
      &PfmBba::dispatch_filename, &_got_output_filename, &_output_filename);
+
+  _reorder_index = 0;
 }
 
 
@@ -90,13 +97,15 @@ process_pfm(const Filename &input_filename, PfmFile &file) {
     }
     
     // This is the order expected by our existing bba system.
-    static const int ri = 0;
-    static const int reorder_points[][8] = {
+    static const int num_reorder_points = 4;
+    static const int reorder_points[num_reorder_points][8] = {
       { 0, 1, 2, 3, 4, 5, 6, 7 },  // unfiltered
       { 7, 5, 1, 3, 6, 4, 0, 2 },  // front, floor
       { 4, 6, 2, 0, 5, 7, 3, 1 },  // left
       { 7, 5, 1, 3, 2, 0, 4, 6 },  // right
     };
+    int ri = max(_reorder_index, 0);
+    ri = min(ri, num_reorder_points - 1);
     
     for (int i = 0; i < bounds->get_num_points(); ++i) {
       LPoint3 p = bounds->get_point(reorder_points[ri][i]);

+ 1 - 0
pandatool/src/pfmprogs/pfmBba.h

@@ -45,6 +45,7 @@ private:
   bool _got_zero_special;
   bool _got_output_filename;
   Filename _output_filename;
+  int _reorder_index;
 };
 
 #endif