hacky stuff

This commit is contained in:
David Rose 2012-02-16 00:18:31 +00:00
parent 1fc2e4b35d
commit 0b0a286101

View File

@ -33,17 +33,10 @@ PfmBba() {
"Treats (0,0,0) in the pfm file as a special don't-touch value.", "Treats (0,0,0) in the pfm file as a special don't-touch value.",
&PfmBba::dispatch_none, &_got_zero_special); &PfmBba::dispatch_none, &_got_zero_special);
add_option
("r", "index", 0,
"Selects a reorder index.",
&PfmBba::dispatch_int, NULL, &_reorder_index);
add_option add_option
("o", "filename", 50, ("o", "filename", 50,
"Specify the filename to which the resulting bba file will be written.", "Specify the filename to which the resulting bba file will be written.",
&PfmBba::dispatch_filename, &_got_output_filename, &_output_filename); &PfmBba::dispatch_filename, &_got_output_filename, &_output_filename);
_reorder_index = 0;
} }
@ -95,20 +88,23 @@ process_pfm(const Filename &input_filename, PfmFile &file) {
<< "Unable to open " << bba_filename << "\n"; << "Unable to open " << bba_filename << "\n";
return false; return false;
} }
LPoint3 points[8];
for (int i = 0; i < 8; ++i) {
points[i] = bounds->get_point(i);
}
LPlanef plane(points[0], points[1], points[2]);
LVector3 normal = plane.get_normal();
static const PN_stdfloat scale = 20.0f;
normal *= scale;
points[0] += normal;
points[1] += normal;
points[2] += normal;
points[3] += normal;
// This is the order expected by our existing bba system. for (int i = 0; i < 8; ++i) {
static const int num_reorder_points = 4; const LPoint3 &p = points[i];
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]);
out << p[0] << "," << p[1] << "," << p[2] << "\n"; out << p[0] << "," << p[1] << "," << p[2] << "\n";
} }
} }