From: <de...@us...> - 2004-04-03 22:31:23
|
Update of /cvsroot/csp/APPLICATIONS/CSPSim/Include/Views In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24179 Added Files: View.h CameraKinematics.h CameraCommand.h CameraAgent.h Log Message: see CHANGES.current --- NEW FILE: View.h --- // Combat Simulator Project - FlightSim Demo // Copyright (C) 2004 The Combat Simulator Project // http://csp.sourceforge.net // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** * @file View.h * **/ #ifndef __VIEW_H__ #define __VIEW_H__ #include <map> #include <SimData/Quat.h> #include <SimData/Ref.h> #include <SimData/Vector3.h> class CameraAgent; class CameraKinematics; class SimObject; class DynamicObject; class View { size_t m_ViewMode; protected: bool m_InternalView; simdata::Ref<DynamicObject> m_ActiveObject; CameraKinematics* m_CameraKinematics; void updateBody(simdata::Vector3& ep,simdata::Vector3& lp,simdata::Vector3& up); void updateWorld(simdata::Vector3& ep,simdata::Vector3& lp,simdata::Vector3& up); virtual void constrain(){} public: View(size_t vm); virtual void activate(){} virtual void update(simdata::Vector3& ep,simdata::Vector3& lp,simdata::Vector3& up, double dt) = 0; void accept(const simdata::Ref<DynamicObject> object) {m_ActiveObject = object;} void accept(CameraKinematics* ck) {m_CameraKinematics = ck;} virtual void recalculate(simdata::Vector3& ep,simdata::Vector3& lp,simdata::Vector3& up, double dt){ update(ep,lp,up,dt); } void cull(); virtual ~View(){} }; class InternalView: public View { public: InternalView(size_t vm):View(vm){m_InternalView = true;} virtual void constrain(); virtual void update(simdata::Vector3& ep,simdata::Vector3& lp,simdata::Vector3& up, double dt); virtual void activate(); virtual ~InternalView(){} }; class InternalViewHist: public InternalView { public: InternalViewHist(size_t vm):InternalView(vm){} virtual void update(simdata::Vector3& ep,simdata::Vector3& lp,simdata::Vector3& up, double dt); virtual ~InternalViewHist(){} }; class ExternalViewBody: public View { public: ExternalViewBody(size_t vm):View(vm){} virtual void activate(); virtual void update(simdata::Vector3& ep,simdata::Vector3& lp,simdata::Vector3& up, double dt); virtual ~ExternalViewBody(){} }; class ExternalViewWorld: public View { public: ExternalViewWorld(size_t vm):View(vm){} virtual void activate(); virtual void update(simdata::Vector3& ep,simdata::Vector3& lp,simdata::Vector3& up,double dt); virtual ~ExternalViewWorld(){} }; class FlybyView: public View { simdata::Vector3 m_FixedCameraPosition; void newFixedCamPos(SimObject* target); public: FlybyView(size_t vm):View(vm){} virtual void activate(); virtual void update(simdata::Vector3& ep,simdata::Vector3& lp,simdata::Vector3& up,double dt); virtual void recalculate(simdata::Vector3& ep,simdata::Vector3& lp,simdata::Vector3& up,double dt); virtual ~FlybyView(){} }; class SatelliteView: public View { public: SatelliteView(size_t vm):View(vm){} virtual void activate(); virtual void update(simdata::Vector3& ep,simdata::Vector3& lp,simdata::Vector3& up,double dt); virtual ~SatelliteView(){} }; class PadlockView: public View { // padlock testing simdata::Ref<DynamicObject> m_Padlock; float m_NeckPhi,m_NeckTheta,m_psi; bool m_NeckLimit; simdata::Quat m_Attitude; void constrain(simdata::Vector3& ep,simdata::Vector3& lp,simdata::Vector3& up,double dt); public: PadlockView(size_t vm); virtual void activate(); virtual void update(simdata::Vector3& ep,simdata::Vector3& lp,simdata::Vector3& up,double dt); virtual ~PadlockView(){} }; typedef std::map<size_t,View*> ViewList; class ViewFactory { View* createView_1() const; View* createView_2() const; View* createView_3() const; View* createView_4() const; View* createView_7() const; View* createView_8() const; View* createView_9() const; public: void attachAllView(CameraAgent* ca) const; }; #endif //__VIEW_H__ --- NEW FILE: CameraKinematics.h --- // Combat Simulator Project - FlightSim Demo // Copyright (C) 2004 The Combat Simulator Project // http://csp.sourceforge.net // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** * @file CameraKinematics.h * **/ #ifndef __CAMERAKINEMATICS_H__ #define __CAMERAKINEMATICS_H__ #include <deque> class CameraCommand; class CameraKinematics { typedef std::deque<CameraCommand*> CameraCommandList; CameraCommandList m_CameraCommandList; // XXX: serialize const float m_BaseRate, m_DisplacementCoefficient; const float m_MinimumDistanceOffset, m_AbsoluteMaximumDistance; double m_AngleRotX, m_AngleRotZ; float m_PanRateX, m_PanRateZ, m_ZoomRate; double m_DistanceToObject, m_MinimumDistance; void rotateAboutZ(double dt) {m_AngleRotZ += m_PanRateZ * dt;} void rotateAboutX(double dt) {m_AngleRotX += m_PanRateX * dt;} void scale(double dt); float smooth(double value, float min_value,float max_value) const; public: CameraKinematics(); virtual ~CameraKinematics(){} void clampX(double& value,float min_value,float max_value, bool smooth_on = true); void clampZ(double& value,float min_value,float max_value, bool smooth_on = true); void reset(); void resetDistance(); void update(double dt); void panLeft(); void panRight(); void panLeftRightStop(); void panUp(); void panDown(); void panUpDownStop(); void zoomIn(); void zoomOut(); void zoomStop(); void displacement(int x, int y, int dx, int dy); void setAngleX(double angle_x) {m_AngleRotX = angle_x;} double& getAngleX() {return m_AngleRotX;} void setAngleZ(double angle_z) {m_AngleRotZ = angle_z;} double& getAngleZ() {return m_AngleRotZ;} void setDistance(float d) {m_DistanceToObject = d;} double getDistance() const {return m_DistanceToObject;} void accept(CameraCommand* cm); }; #endif //__CAMERAKINEMATICS_H__ --- NEW FILE: CameraCommand.h --- // Combat Simulator Project - FlightSim Demo // Copyright (C) 2004 The Combat Simulator Project // http://csp.sourceforge.net // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** * @file CameraCommand.h * **/ #ifndef __CAMERACOMMAND_H__ #define __CAMERACOMMAND_H__ #include "Views/CameraKinematics.h" class Command { public: virtual void execute() = 0; virtual ~Command(){} }; class CameraCommand: public Command { protected: CameraKinematics* m_CameraKinematics; public: CameraCommand(): m_CameraKinematics(0){} void setCameraKinematics(CameraKinematics* cm) { m_CameraKinematics = cm; } virtual ~CameraCommand(){} }; class CameraReset: public CameraCommand { public: virtual void execute() { m_CameraKinematics->reset(); } virtual ~CameraReset(){} }; class PanLeft: public CameraCommand { public: virtual void execute() { m_CameraKinematics->panLeft(); } virtual ~PanLeft(){} }; class PanRight: public CameraCommand { public: virtual void execute() { m_CameraKinematics->panRight(); } virtual ~PanRight(){} }; class PanLeftRightStop: public CameraCommand { public: virtual void execute() { m_CameraKinematics->panLeftRightStop(); } virtual ~PanLeftRightStop(){} }; class PanUp: public CameraCommand { public: virtual void execute() { m_CameraKinematics->panUp(); } virtual ~PanUp(){} }; class PanDown: public CameraCommand { public: virtual void execute() { m_CameraKinematics->panDown(); } virtual ~PanDown(){} }; class PanUpDownStop: public CameraCommand { public: virtual void execute() { m_CameraKinematics->panUpDownStop(); } virtual ~PanUpDownStop(){} }; class ZoomIn: public CameraCommand { public: virtual void execute() { m_CameraKinematics->zoomIn(); } virtual ~ZoomIn(){} }; class ZoomOut: public CameraCommand { public: virtual void execute() { m_CameraKinematics->zoomOut(); } virtual ~ZoomOut(){} }; class ZoomStop: public CameraCommand { public: virtual void execute() { m_CameraKinematics->zoomStop(); } virtual ~ZoomStop(){} }; class MouseCommand: public CameraCommand { int m_x,m_y,m_dx,m_dy; void reset() { m_x = 0; m_y = 0; m_dx = 0; m_dy = 0; } public: MouseCommand() { reset(); } void set(int x,int y, int dx, int dy) { m_x = x; m_y = y; m_dx = dx; m_dy = dy; } virtual void execute() { m_CameraKinematics->displacement(m_x,m_y,m_dx,m_dy); reset(); } virtual ~MouseCommand(){} }; #endif //__CAMERACOMMAND_H__ --- NEW FILE: CameraAgent.h --- // Combat Simulator Project - FlightSim Demo // Copyright (C) 2004 The Combat Simulator Project // http://csp.sourceforge.net // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** * @file CameraAgent.h * **/ #ifndef __CAMERAAGENT_H__ #define __CAMERAAGENT_H__ #include <SimData/Ref.h> #include <SimData/Vector3.h> #include "Views/CameraKinematics.h" #include "Views/View.h" class CameraCommand; class DynamicObject; class CameraAgent { simdata::Vector3 m_EyePoint,m_LookPoint,m_UpVector; CameraKinematics m_CameraKinematics; size_t m_ViewMode; ViewList m_ViewList; void validate(double dt); void deleteViews(); void notifyCameraKinematicsToViews(); public: CameraAgent(const ViewFactory& vf); ~CameraAgent(); void attach(size_t mode,View* vm); void set(size_t vm, CameraCommand* ck = 0); void notifyObjectToViews(const simdata::Ref<DynamicObject> object); void updateCamera(double dt); const simdata::Vector3& getEyePoint() const {return m_EyePoint;} const simdata::Vector3& getLookPoint() const {return m_LookPoint;} const simdata::Vector3& getUpVector() const {return m_UpVector;} }; #endif //__CAMERAAGENT_H__ |