home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / demos / audio / drive / Driver.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  3.6 KB  |  138 lines

  1. /*
  2.  * Copyright 1992-1993, 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. //////////////////////////////////////////////////////////////////////
  18. // Driver.h - definition of the driver class
  19. //
  20. // The driver initiates events and views output from the
  21. // simulator.
  22. //
  23. // This class is what changes if the interface to the
  24. // outside world changes (i.e. mouse-based workstation simulation
  25. // becomes full-fledged car device. Yeah, right. Dream on, pal.)
  26. //////////////////////////////////////////////////////////////////////
  27.  
  28. #ifndef DRIVER_H
  29. #define DRIVER_H
  30.  
  31. #include "Defines.h"
  32. #include "Window.h"
  33. #include "Display.h"
  34.  
  35. class Car;
  36. class Cockpit;
  37. class Road;
  38. class sample;
  39. class Timer;
  40.  
  41. // Top of the cockpit in a window of height 1.0
  42. const float COCKPIT_TOP = (6.5/20.0);
  43.  
  44. class Driver {
  45.  
  46. public:
  47.  
  48.     Driver(Car *);
  49.     ~Driver();
  50.  
  51.     void update(Boolean ok_to_sleep);
  52.     Boolean done() const { return _done; };
  53.  
  54.     float get_fps() const { return _fps; };
  55.     float get_max_fps() const { return _max_fps; };
  56.     long last_frame_time() const { return _last_frame_time; };
  57.  
  58.     const Cockpit * get_cockpit() const { return _cockpit; };
  59.  
  60.     void crash() { _crashed = TRUE; _crash_handled = FALSE; };
  61.  
  62.     Timer * get_timer() const { return _timer; };
  63.  
  64.     Boolean helping() const { return _helping; };
  65.  
  66.     SbVec2s getViewWindowSize() const 
  67.         { return SbVec2s((short)_view_win.sizex, (short)_view_win.sizey); }
  68.  
  69. protected:
  70.  
  71.     void open();
  72.     void draw();
  73.     void draw_view();
  74.     void timed_draw(Boolean include_in_average);
  75.     void draw_flags();
  76.     void draw_cars(Boolean draw_self);
  77.     void event(long, short);
  78.     void set_view();
  79.     void init_devices();
  80.     void reset_all();
  81.     void reshape_subwindow(long wid);
  82.     void reset_helicopter();
  83.     void handle_crash();
  84.     void draw_crash();
  85.  
  86.     // window relative, -1.0 to 1.0
  87.     float _mouse_x;
  88.  
  89.     // car that this driver is in
  90.     Car * _car;
  91.  
  92.     // cockpit that this driver is looking at
  93.     // only car's with local drivers need a cockpit
  94.     // robots don't, networked cars don't
  95.     Cockpit * _cockpit;
  96.  
  97.     // information about the windows
  98.     Window _parent_win, _cockpit_win, _view_win;
  99.  
  100.     // Do the viewports need to be redrawn ?
  101.     // a redraw_cockpit implies a redraw_view
  102.     Boolean _redraw_cockpit, _redraw_view;
  103.  
  104.     float _fps, _max_fps; // frames per second
  105.     long _last_frame_time; // in microseconds
  106.  
  107.     Boolean _done; // are we outta here?
  108.  
  109.     Display _display; // How we see the world
  110.     
  111.     // circular list of car positions used to orient helicopter
  112.     SbMatrix * _helio_orientation;
  113.     SbVec3f * _helio_position;
  114.     SbVec3f _helio_offset;
  115.     int _helio_use_index;
  116.     int _helio_fill_index;
  117.     int _helio_lag; // number of frames behind car
  118.  
  119.     Boolean _cranking; // is the ignition being held
  120.  
  121.     // keyboard repeat params saved away
  122.     short _old_keywarp[2]; // threshold and repeat rate
  123.  
  124.     // lap timing
  125.     Timer * _timer;
  126.     Boolean _first_timing;
  127.  
  128.     // stuff for the crash
  129.     Boolean _crashed, _crash_handled;
  130.     Boolean _broken_winshield;
  131.     sample * _crash_noise;
  132.  
  133.     Boolean _helping; // TRUE if displaying help screen
  134. };
  135.  
  136. #endif
  137.     
  138.