Re: [AD] small docs addition

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


> Reading the docs, I understand that 'aspect' is simply here to tell the
> camera matrix the ratio of the output image. Hence for a 320x240 viewport,
> you pass aspect = 4/3.

Here's a patch that fixes the code for get_camera_matrix() as well as the
two examples that use the function, of course at the expense of a backward
compatibility breakage.

--- cvsroot/allegro/src/math3d.c Sat Dec  1 20:16:36 2001
+++ allegro/src/math3d.c Sun Mar  3 12:37:58 2002
@@ -597,7 +597,7 @@

    /* construct a scaling matrix to deal with aspect ratio and FOV */
    width = floattan(64.0 - fov/2);
-   get_scaling_matrix_f(&scale, width, -aspect*width*4/3, -1.0);
+   get_scaling_matrix_f(&scale, width, -aspect*width, -1.0);

    /* combine the camera and scaling matrices */
    matrix_mul_f(&camera, &scale, m);
--- cvsroot/allegro/docs/src/allegro._tx Sun Mar  3 00:03:04 2002
+++ allegro/docs/src/allegro._tx Sun Mar  3 14:48:10 2002
@@ -6452,7 +6452,8 @@
    format. For typical projections, a field of view in the region 32-48
will
    work well. Finally, the aspect ratio is used to scale the Y dimensions
of
    the image relative to the X axis, so you can use it to adjust the
-   proportions of the output image (set it to 1 for no scaling).
+   proportions of the output image (set it to 1 for no scaling). Note that
+   versions prior to 4.1.0 wrongly multiplied this aspect ratio by 4/3.

 @\void @get_camera_matrix_f(MATRIX_f *m, float x, y, z, xfront, yfront,
zfront,
 @@                         float xup, yup, zup, fov, aspect);
--- cvsroot/allegro/examples/excamera.c Sat Dec  1 20:16:32 2001
+++ allegro/examples/excamera.c Sun Mar  3 14:33:02 2002
@@ -29,7 +29,7 @@
 int viewport_w = 320;
 int viewport_h = 240;
 int fov = 48;
-float aspect = 1;
+float aspect = 1.33f;
 float xpos = 0;
 float ypos = -2;
 float zpos = -4;
@@ -205,6 +205,8 @@
 /* deal with user input */
 void process_input(void)
 {
+   double frac, iptr;
+
    poll_keyboard();

    if (key[KEY_W]) {
@@ -241,13 +243,21 @@
    }

    if (key[KEY_A]) {
+      frac = modf(aspect*10.0, &iptr);
+
       if (key_shifts & KB_SHIFT_FLAG) {
-  aspect += 0.05;
+  if ((frac>0.59) && (frac<0.61))
+     aspect += 0.04f;
+  else
+     aspect += 0.03f;
   if (aspect > 2)
      aspect = 2;
       }
       else {
-  aspect -= 0.05;
+  if ((frac>0.99) || (frac<0.01))
+     aspect -= 0.04f;
+  else
+     aspect -= 0.03f;
   if (aspect < .1)
      aspect = .1;
       }
--- cvsroot/allegro/examples/exquat.c Mon Dec  3 18:26:34 2001
+++ allegro/examples/exquat.c Sun Mar  3 14:36:44 2002
@@ -307,7 +307,7 @@
    e_to.z = (float)(rand() % 256);

    /* the camera is backed away from the origin and turned to face it */
-   get_camera_matrix_f(&camera, 5, 0, 0, -1, 0, 0, 0, 0, 1, 46, 1);
+   get_camera_matrix_f(&camera, 5, 0, 0, -1, 0, 0, 0, 0, 1, 46, 1.33f);

    /* this is a 'for'ever loop */
    for (;;) {


--
Eric Botcazou
ebotcazou@xxxxxxxxxx



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/