00001 /*************************************************************************** 00002 * Copyright (C) 2004 - 2006 by Raphael Langerhorst * 00003 * raphael-langerhorst@gmx.at * 00004 * * 00005 * Permission is hereby granted, free of charge, to any person obtaining * 00006 * a copy of this software and associated documentation files (the * 00007 * "Software"), to deal in the Software without restriction, including * 00008 * without limitation the rights to use, copy, modify, merge, publish, * 00009 * distribute, sublicense, and/or sell copies of the Software, and to * 00010 * permit persons to whom the Software is furnished to do so, subject to * 00011 * the following conditions: * 00012 * * 00013 * The above copyright notice and this permission notice shall be * 00014 * included in all copies or substantial portions of the Software. * 00015 * * 00016 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * 00017 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * 00018 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.* 00019 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR * 00020 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * 00021 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * 00022 * OTHER DEALINGS IN THE SOFTWARE. * 00023 ***************************************************************************/ 00024 00025 #ifndef GCECAMERAH 00026 #define GCECAMERAH 00027 00028 #include <GForm.h> 00029 #include <GVector3.h> 00030 00031 #include <QObject> 00032 #include <QThread> 00033 #include <QEvent> 00034 #include <QDateTime> 00035 00036 #include "GOpenGLFrame.h" 00037 00038 namespace GBE 00039 { 00040 class GMoveAgent; 00041 } 00042 00043 namespace GCE 00044 { 00045 00066 class GCamera : public QObject 00067 { 00068 Q_OBJECT 00069 00070 protected: 00071 00075 QTime KeyUpdateTime; 00076 00081 GOpenGLFrame* Frame; 00082 00087 GCS::GForm Form; 00088 00092 QMutex FormMutex; 00093 00102 double ViewDistancePercent; 00103 00107 double SpeedFactor; 00108 00112 double speedx; 00113 00117 double speedy; 00118 00122 bool shutdown; 00123 00124 00125 // KEY STATES 00126 bool left_key_down; 00127 bool right_key_down; 00128 bool up_key_down; 00129 bool down_key_down; 00130 bool space_key_down; 00131 00132 public: 00136 GCamera(GOpenGLFrame* frame = NULL, QObject* parent = 0); 00137 00141 ~GCamera(); 00142 00143 protected: 00144 00148 virtual bool eventFilter(QObject* watched, QEvent* e); 00149 00150 public slots: 00151 00155 virtual void update(); 00156 00162 virtual void setFrame(GOpenGLFrame* frame); 00163 00168 virtual void connectMoveAgent(GBE::GMoveAgent* agent); 00169 00173 virtual void formUpdated(const GCS::GForm& form); 00174 00178 virtual void startCamera(); 00179 00184 virtual void stopCamera(); 00185 00190 virtual void setViewDistance(int new_distance_percent); 00191 00196 virtual void setSpeedFactor(double speed_factor); 00197 00198 signals: 00199 00204 void action(const QString& actionname, QStringList params); 00205 00206 // /** 00207 // * Emitted when the camera, usually on behalf of the user, 00208 // * wants to change the speed. Since a camera is connected 00209 // * to a form, this signal should probably be connected to 00210 // * a GBE::GMoveAgent::addTranslationSpeedImpulse() 00211 // */ 00212 // void translationSpeedImpulse(const GCS::GVector3& v); 00213 // 00214 // /** 00215 // * Emitted when the camera, usually on behalf of the user, 00216 // * wants to change the speed. Since a camera is connected 00217 // * to a form, this signal should probably be connected to 00218 // * a GBE::GMoveAgent::addRotationSpeedImpulse() 00219 // */ 00220 // void rotationSpeedImpulse(const GCS::GVector3& v); 00221 // 00222 // /** 00223 // * Emitted when all movement of the camera element should stop. 00224 // */ 00225 // void stopMovement(); 00226 00227 }; 00228 00229 }; 00230 00231 #endif
1.4.7