00001 /* 00002 RenderStack Support library for OpenGL 3+ 00003 Copyright (C) 2010 Timo Suoranta 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Lesser General Public 00007 License as published by the Free Software Foundation; either 00008 version 2.1 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Lesser General Public License for more details. 00014 00015 You should have received a copy of the GNU Lesser General Public 00016 License along with this library; if not, write to the Free Software 00017 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00018 */ 00019 00027 #ifndef CONTROL_HPP 00028 #define CONTROL_HPP 00029 00030 #include "renderstack/rs.h" 00031 #include "renderstack/quaternion.hpp" 00032 00033 namespace renderstack { 00034 00035 class frame; 00036 00038 class control 00039 { 00040 protected: 00041 static const int bit_more = 1; 00042 static const int bit_less = 2; 00043 static const int bit_stop = 4; 00044 static const int bit_active = 8; 00045 static const int bit_inhibit = 16; 00046 static const int bit_dampen_linear = 32; 00047 static const int bit_dampen_multiply = 64; 00048 static const int bit_dampen_master = 128; 00049 static const int bitmask_clear = bit_more | bit_less | bit_stop | bit_active | bit_inhibit; 00050 00051 public: 00052 control(); 00053 00054 void clear (); 00055 void update (); 00056 void adjust (float delta); 00057 void dampen (); 00058 void more (bool apply); 00059 void less (bool apply); 00060 void stop (bool apply); 00061 void inhibit(bool apply); 00062 00063 void set_max_delta (float max_delta){ m_max_delta = max_delta; } 00064 void set_damp (float damp){ m_damp = damp; } 00065 00066 float current_delta() const { return m_current_delta; } 00067 float current_value() const { return m_current_value; } 00068 00069 private: 00070 int m_options; 00071 float m_damp; 00072 float m_max_delta; 00073 float m_max_value; 00074 float m_min_value; 00075 float m_current_delta; 00076 float m_current_value; 00077 }; 00078 00080 class frame_controls 00081 { 00082 public: 00083 frame_controls(frame &slave_frame); 00084 00085 private: 00086 frame_controls(frame_controls const &other); 00087 frame_controls &operator=(frame_controls const &); 00088 00089 public: 00090 control &rotate_x() { return m_rotate_x; } 00091 control &rotate_y() { return m_rotate_y; } 00092 control &rotate_z() { return m_rotate_z; } 00093 control &translate_x() { return m_translate_x; } 00094 control &translate_y() { return m_translate_y; } 00095 control &translate_z() { return m_translate_z; } 00096 00097 void fixed_update(); 00098 void once_per_frame_update(); 00099 00100 private: 00101 frame &m_frame; 00102 control m_rotate_x; 00103 control m_rotate_y; 00104 control m_rotate_z; 00105 control m_translate_x; 00106 control m_translate_y; 00107 control m_translate_z; 00108 quaternion m_rotation; 00109 vec3 m_position_in_world; 00110 }; 00111 00112 } 00113 00114 #endif 00115