/*---------------------------------------------------------------------------- * fly.c * * This file contains the routines to animate the arm by doing a simple * flypast by incrementally altering the viewpoint. A double buffered * Intuition screen is used. *---------------------------------------------------------------------------- */ #include #include #include #include "defs.h" #include "ds.h" extern struct RasInfo *ri ; extern struct BitMap b, b2 ; extern struct RastPort rp, rp2 ; extern struct Screen *screen ; extern ROTATION_INFO rot_info ; int flypast_trans [NUM_FLYPAST_VPOINTS] [4][4] ; /* array of pre-calculated */ /* view transformations */ open_db_screen_for_flypast () { int *save_trans = rot_info.curr_view_trans ; int i ; /*-------------------------------------------------------------------------- * This routine draws a frame, updates the viewing transformation, then * switches screen memory to the the bitplanes just drawn into * (via its rastport). The swapped out screen memory is then drawn into for * the next frame, and the process repeats until the required number of frames * are drawn. * The flight path is more or less a 90 degree circular sweep in XY, with * a linear increment in Z. *--------------------------------------------------------------------------- */ screen->RastPort.BitMap = &b2 ; /* put 2nd set of bitplanes */ ri->BitMap = &b2 ; /* on the screen */ MakeScreen (screen) ; RethinkDisplay () ; for (i = 0; i < NUM_FLYPAST_VPOINTS - 1; i = i + 2) { /* get next view transformation */ rot_info.curr_view_trans = (int *)flypast_trans [i] ; transform_links () ; /* new eye coordinates for view */ set_screen_coords () ; draw_image (&rp) ; /* draw into 1st set of bit planes */ screen->RastPort.BitMap = &b ; /* swap screen memory to 1st screen */ ri->BitMap = &b ; MakeScreen (screen) ; RethinkDisplay () ; /* get next view transformation */ rot_info.curr_view_trans = (int *)flypast_trans [i+1] ; transform_links () ; /* new eye coordinates for view */ set_screen_coords () ; draw_image (&rp2) ; /* draw into 2nd set of bit planes */ screen->RastPort.BitMap = &b2 ; /* swap screen memory to 1st screen */ ri->BitMap = &b2 ; MakeScreen (screen) ; RethinkDisplay () ; } SetRast (&rp, COLOR0) ; for (i = 0; i < 150000; ++i) /* let user have a look at last frame */ ; screen->RastPort.BitMap = &b ; ri->BitMap = &b ; MakeScreen (screen) ; RethinkDisplay () ; SetRast (&rp2, COLOR0) ; rot_info.curr_view_trans = save_trans ; } init_flypast_trans () { float flypast_viewpoint [3] ; static float fly_coords [] = { 10.0, 50.0, 90.0, 140.0, 190.0, 230.0, 280.0, 320.0, 360.0, 400.0, 430.0, 450.0, 470.0, 480.0, 490.0, 500.0 } ; float z = 200.0 ; int i, j = 0, k = 15 ; /*--------------------------------------------------------------------------- * Initialize (once at program start) the viewing transformations for the * flypast, in order to speed up animation. * The flight path is more or less a 90 degree circular sweep in XY, with * a linear increment in Z. *--------------------------------------------------------------------------- */ for (i = 0; i < NUM_FLYPAST_VPOINTS; ++i) { flypast_viewpoint [X] = fly_coords [j++] ; flypast_viewpoint [Y] = fly_coords [k--] ; flypast_viewpoint [Z] = z ; z = z + 20.0 ; viewing_transformation (flypast_viewpoint, flypast_trans [i]) ; } }