00001 00010 #ifndef VIEWPOINTNAV_H 00011 #define VIEWPOINTNAV_H 00012 00013 #include "WorldTranslate.H" 00014 00015 // Gluebase includes 00016 #define OUTSIDE_GLUE_CORE 00017 #include <fsa/fsa.H> 00018 #include <mlib/points.H> 00019 #include <dev/room6d.H> 00020 #include <dev/buttons.H> 00021 #include <config/config.H> 00022 #include <std/list.H> 00023 00024 class ViewpointNav : public Interactor<ViewpointNav> 00025 { 00026 public: 00027 ViewpointNav() : Interactor<ViewpointNav>("ViewpointNav") { 00028 00029 int numviews = CONFIGval("NUM_STORED_VIEWPOINTS",0); 00030 for (int i=0;i<numviews;i++) { 00031 _views += CONFIGval(str_ptr("STORED_VIEWPOINT_") + i, Wtransf()); 00032 } 00033 00034 _cviewbtn = new EVENTbtn(CONFIGval("CYCLE_VIEW_BTN"),true); 00035 _entry += Arc(this, Gd(_cviewbtn), &ViewpointNav::cycle_view); 00036 EVENTmgr::add_handler(new FSA(&_entry)); 00037 } 00038 virtual ~ViewpointNav() {} 00039 00040 void addView(Wtransf m) { _views += m; } 00041 00042 int numViews() { return _views.num(); } 00043 void setView(int i) { 00044 if (!_views.num()) { 00045 cerr << "Error: no stored viewpoints." << endl; 00046 return; 00047 } 00048 00049 _curview = i; 00050 if (_curview >= _views.num()) 00051 _curview = 0; 00052 WorldTranslate::instance()->setROOM_TO_WORLD(_views[_curview]); 00053 cout << "Setting viewpoint #" << _curview << endl; 00054 } 00055 00056 protected: 00057 00058 void cycle_view(cEVENTbtnptr &evt, STATE *&) { 00059 setView(_curview + 1); 00060 } 00061 00062 EVENTbtnptr _cviewbtn; 00063 00064 int _curview; 00065 ARRAY<Wtransf> _views; 00066 00067 }; 00068 00069 #endif