Răsfoiți Sursa

*** empty log message ***

David Rose 25 ani în urmă
părinte
comite
22d7921db2

+ 12 - 1
pandaapp/src/stitchbase/stitchCommand.cxx

@@ -92,6 +92,10 @@ operator << (ostream &out, StitchCommand::Command c) {
     return out << "film_size";
     break;
 
+  case StitchCommand::C_film_offset:
+    return out << "film_offset";
+    break;
+
   case StitchCommand::C_grid:
     return out << "grid";
     break;
@@ -588,8 +592,15 @@ create_image() {
     }
   }
 
+  LVecBase2d film_offset_mm(0.0, 0.0);
+  cmd = find_command(C_film_offset);
+  if (cmd != NULL) {
+    film_offset_mm = cmd->get_point2d();
+  }
+
   StitchImage *image = 
-    new StitchImage(get_name(), filename, lens, size_pixels, resolution);
+    new StitchImage(get_name(), filename, lens, size_pixels, film_offset_mm,
+		    resolution);
   image->setup_grid(50, 50);
 
   // Also look for points and other stuff.

+ 1 - 0
pandaapp/src/stitchbase/stitchCommand.h

@@ -41,6 +41,7 @@ public:
     C_show_points,
     C_image_size,
     C_film_size,
+    C_film_offset,
     C_grid,
     C_untextured_color,
     C_hpr,

+ 10 - 5
pandaapp/src/stitchbase/stitchImage.cxx

@@ -13,10 +13,12 @@
 StitchImage::
 StitchImage(const string &name, const string &filename,
 	    StitchLens *lens, const LVecBase2d &size_pixels,
-	    const LVecBase2d &pixels_per_mm) :
+	    const LVecBase2d &pixels_per_mm,
+	    const LVecBase2d &film_offset_mm) :
   _lens(lens),
   _size_pixels(size_pixels),
   _pixels_per_mm(pixels_per_mm),
+  _film_offset_mm(film_offset_mm),
   _rotate(LMatrix3d::ident_mat()),
   _inv_rotate(LMatrix3d::ident_mat()),
   _filename(filename),
@@ -36,8 +38,9 @@ StitchImage(const string &name, const string &filename,
   // _size_pixels[1] - 1) at the lower-right.
 
   // Millimeters are used when interfacing with the lens.  They start
-  // at (0, 0) at the center, and range from -size_mm at the
-  // lower-left, to size_mm at the upper-right.
+  // at -film_offset_mm at the center, and range from
+  // -film_offset_mm-size_mm at the lower-left, to
+  // -film_offset_mm+size_mm at the upper-right.
 
   LVector2d pixels_per_uv(_size_pixels[0] - 1.0, _size_pixels[1] - 1.0);
 
@@ -64,11 +67,13 @@ StitchImage(const string &name, const string &filename,
 
   _uv_to_mm = 
     LMatrix3d::translate_mat(LVector2d(-0.5, -0.5)) *
-    LMatrix3d::scale_mat(mm_per_uv);
+    LMatrix3d::scale_mat(mm_per_uv) *
+    LMatrix3d::translate_mat(-_film_offset_mm);
 
   _mm_to_uv =
+    LMatrix3d::translate_mat(_film_offset_mm) *
     LMatrix3d::scale_mat(1.0 / mm_per_uv[0], 1.0 / mm_per_uv[1]) *
-    LMatrix3d::translate_mat(LVector2d(0.5, 0.5));
+    LMatrix3d::translate_mat(LVector2d(0.5, 0.5) + _film_offset_mm);
 
   _pixels_to_mm = _pixels_to_uv * _uv_to_mm;
   _mm_to_pixels = _mm_to_uv * _uv_to_pixels;

+ 3 - 1
pandaapp/src/stitchbase/stitchImage.h

@@ -28,7 +28,8 @@ public:
   StitchImage(const string &name, const string &filename,
 	      StitchLens *lens, 
 	      const LVecBase2d &size_pixels,
-	      const LVecBase2d &pixels_per_mm);
+	      const LVecBase2d &pixels_per_mm,
+	      const LVecBase2d &film_offset_mm);
 
   bool has_name() const;
   string get_name() const;
@@ -99,6 +100,7 @@ public:
   StitchLens *_lens;
   LVecBase2d _size_pixels, _size_mm;
   LVecBase2d _pixels_per_mm;
+  LVecBase2d _film_offset_mm;
   LMatrix3d _mm_to_uv, _uv_to_mm;
   LMatrix3d _pixels_to_mm, _mm_to_pixels;
   LMatrix3d _pixels_to_uv, _uv_to_pixels;

+ 31 - 28
pandaapp/src/stitchbase/stitchLexer.lxx

@@ -11,6 +11,7 @@
 #include "stitchParser.h"
 
 #include <indent.h>
+#include <string_utils.h>
 
 #include <assert.h>
 #include <math.h>
@@ -296,61 +297,63 @@ NUMERIC         ([+-]?(([0-9]+[.]?)|([0-9]*[.][0-9]+))([eE][+-]?[0-9]+)?)
   string str = yytext;
   stitchyylval.str = str;
 
-  if (str == "define") {
+  if (cmp_nocase_uh(str, "define") == 0) {
     return KW_DEFINE;
-  } else if (str == "lens") {
+  } else if (cmp_nocase_uh(str, "lens") == 0) {
     return KW_LENS;
-  } else if (str == "input_image") {
+  } else if (cmp_nocase_uh(str, "input_image") == 0) {
     return KW_INPUT_IMAGE;
-  } else if (str == "output_image") {
+  } else if (cmp_nocase_uh(str, "output_image") == 0) {
     return KW_OUTPUT_IMAGE;
-  } else if (str == "perspective") {
+  } else if (cmp_nocase_uh(str, "perspective") == 0) {
     return KW_PERSPECTIVE;
-  } else if (str == "fisheye") {
+  } else if (cmp_nocase_uh(str, "fisheye") == 0) {
     return KW_FISHEYE;
-  } else if (str == "cylindrical") {
+  } else if (cmp_nocase_uh(str, "cylindrical") == 0) {
     return KW_CYLINDRICAL;
-  } else if (str == "psphere") {
+  } else if (cmp_nocase_uh(str, "psphere") == 0) {
     return KW_PSPHERE;
-  } else if (str == "focal_length") {
+  } else if (cmp_nocase_uh(str, "focal_length") == 0) {
     return KW_FOCAL_LENGTH;
-  } else if (str == "fov") {
+  } else if (cmp_nocase_uh(str, "fov") == 0) {
     return KW_FOV;
-  } else if (str == "singularity_tolerance") {
+  } else if (cmp_nocase_uh(str, "singularity_tolerance") == 0) {
     return KW_SINGULARITY_TOLERANCE;
-  } else if (str == "resolution") {
+  } else if (cmp_nocase_uh(str, "resolution") == 0) {
     return KW_RESOLUTION;
-  } else if (str == "filename") {
+  } else if (cmp_nocase_uh(str, "filename") == 0) {
     return KW_FILENAME;
-  } else if (str == "point") {
+  } else if (cmp_nocase_uh(str, "point") == 0) {
     return KW_POINT;
-  } else if (str == "show_points") {
+  } else if (cmp_nocase_uh(str, "show_points") == 0) {
     return KW_SHOW_POINTS;
-  } else if (str == "image_size") {
+  } else if (cmp_nocase_uh(str, "image_size") == 0) {
     return KW_IMAGE_SIZE;
-  } else if (str == "film_size") {
+  } else if (cmp_nocase_uh(str, "film_size") == 0) {
     return KW_FILM_SIZE;
-  } else if (str == "grid") {
+  } else if (cmp_nocase_uh(str, "film_offset") == 0) {
+    return KW_FILM_OFFSET;
+  } else if (cmp_nocase_uh(str, "grid") == 0) {
     return KW_GRID;
-  } else if (str == "untextured_color") {
+  } else if (cmp_nocase_uh(str, "untextured_color") == 0) {
     return KW_UNTEXTURED_COLOR;
-  } else if (str == "hpr") {
+  } else if (cmp_nocase_uh(str, "hpr") == 0) {
     return KW_HPR;
-  } else if (str == "layers") {
+  } else if (cmp_nocase_uh(str, "layers") == 0) {
     return KW_LAYERS;
-  } else if (str == "stitch") {
+  } else if (cmp_nocase_uh(str, "stitch") == 0) {
     return KW_STITCH;
-  } else if (str == "points") {
+  } else if (cmp_nocase_uh(str, "points") == 0) {
     return KW_POINTS;
-  } else if (str == "using") {
+  } else if (cmp_nocase_uh(str, "using") == 0) {
     return KW_USING;
-  } else if (str == "in") {
+  } else if (cmp_nocase_uh(str, "in") == 0) {
     return KW_IN;
-  } else if (str == "mm") {
+  } else if (cmp_nocase_uh(str, "mm") == 0) {
     return KW_MM;
-  } else if (str == "cm") {
+  } else if (cmp_nocase_uh(str, "cm") == 0) {
     return KW_CM;
-  } else if (str == "p") {
+  } else if (cmp_nocase_uh(str, "p") == 0) {
     return KW_P;
   }
 

+ 12 - 11
pandaapp/src/stitchbase/stitchParser.h

@@ -18,17 +18,18 @@
 #define	KW_SHOW_POINTS	274
 #define	KW_IMAGE_SIZE	275
 #define	KW_FILM_SIZE	276
-#define	KW_GRID	277
-#define	KW_UNTEXTURED_COLOR	278
-#define	KW_HPR	279
-#define	KW_LAYERS	280
-#define	KW_STITCH	281
-#define	KW_POINTS	282
-#define	KW_USING	283
-#define	KW_IN	284
-#define	KW_MM	285
-#define	KW_CM	286
-#define	KW_P	287
+#define	KW_FILM_OFFSET	277
+#define	KW_GRID	278
+#define	KW_UNTEXTURED_COLOR	279
+#define	KW_HPR	280
+#define	KW_LAYERS	281
+#define	KW_STITCH	282
+#define	KW_POINTS	283
+#define	KW_USING	284
+#define	KW_IN	285
+#define	KW_MM	286
+#define	KW_CM	287
+#define	KW_P	288
 
 
 extern YYSTYPE stitchyylval;

+ 6 - 0
pandaapp/src/stitchbase/stitchParser.yxx

@@ -50,6 +50,7 @@ stitch_init_parser(istream &in, const string &filename,
 %token KW_SHOW_POINTS
 %token KW_IMAGE_SIZE
 %token KW_FILM_SIZE
+%token KW_FILM_OFFSET
 %token KW_GRID
 %token KW_UNTEXTURED_COLOR
 %token KW_HPR
@@ -218,6 +219,11 @@ simple_command:
 {
   $$ = new StitchCommand(parent, StitchCommand::C_film_size);
   $$->set_length_pair((const LPoint2d &)$2);
+}
+	| KW_FILM_OFFSET length_pair
+{
+  $$ = new StitchCommand(parent, StitchCommand::C_film_offset);
+  $$->set_length_pair((const LPoint2d &)$2);
 }
 	| KW_GRID vec2
 {