Hauptseite | Liste aller Namensbereiche | Klassenhierarchie | Alphabetische Liste | Datenstrukturen | Auflistung der Dateien | Datenstruktur-Elemente | Datei-Elemente

Camera.h

gehe zur Dokumentation dieser Datei
00001 /*
00002 Autor: $Author: kunkel $ State: $State: Exp $
00003 Datum: $Date: 2005/05/30 12:35:25 $
00004 Version: $Revision: 1.1 $
00005 */
00006 
00012 #ifndef CAMERA_H
00013 #define CAMERA_H
00014 
00015 #include "config.h"
00016 #include "Vector.h"
00017 #include "Object.h"
00018 
00023 class Camera {
00024 public:
00028     static const int CAMERA_SAVES = 10;
00029 private:
00033     class cameraPos {
00034     public:
00038         Vector place;
00039 
00043         Vector upper;
00044 
00048         Vector projectionCenter;
00049     };
00050 
00054     Vector place;
00055 
00059     Vector upper;
00060 
00064     Vector projectionCenter;
00065 
00069     cameraPos positionList[CAMERA_SAVES];
00070 
00074     double aperture;
00075 
00079     int screenwidth, screenheight;
00080 
00081 
00082 public:
00083     Camera();
00084 
00085     void saveAktuallCameraPosition(int to);
00086 
00087     void loadAktuallCameraPosition(int from);
00088 
00092     typedef enum {NONE, ROTATEXY,ROTATEZ,FORWARD,MOVE,ROTATEKEEPPOSXY,ZOOM} Action;
00093 
00097     Action action;
00098 
00102     int getScreenWidth() {
00103         return screenwidth;
00104     }
00105 
00109     int getScreenHeight() {
00110         return screenheight;
00111     }
00112 
00118     void setScreen(int width,int height) {
00119         screenwidth = width;
00120         screenheight = height;
00121     }
00122 
00123 
00124     /* Breite und Hoehe der Projektionsflaeche       */
00125 
00138     void rotateKeepViewPoint(int ix, int iy, int iz);
00139     void rotateKeepPosition(int ix, int iy);
00140 
00141     void saveCamera(ostream & FILE);
00142     void loadCamera(istream & FILE);
00143     void reloadAutomaticAdaption();
00144 
00150     inline void loadCameraMatrix() {
00151         /* Eine perspektivische Projektion einstellen. (Die soeben geladene
00152         Einheitsmatrix wird mit einer aus den folgenden Angaben berechneten
00153         Projektionsmatrix multipliziert.) Das erste Argument ist
00154         der Oeffnungswinkel der Kamera in Grad; danach steht das Verhaeltnis
00155         von Projektionsflaechenbreite zu -hoehe, anschliessend werden die
00156         Abstaende zwischen Kamera und vorderer Beschneidungsflaeche sowie
00157         zwischen Kamera und hinterer Beschneidungsflaeche angegeben. Alles,
00158         was sich zwischen diesen beiden, senkrecht zur Blickrichtung stehenden
00159         Flaechen befindet, wird in die Darstellung der Szene mit einbezogen. */
00160         gluLookAt(place.x, place.y, place.z,
00161                   projectionCenter.x, projectionCenter.y, projectionCenter.z,
00162                   upper.x, upper.y, upper.z);
00163     }
00164 
00165     inline void loadCameraPerspective() {
00166         gluPerspective(aperture, screenwidth / (double) screenheight, 0.2, 1e12);
00167     }
00168 
00169     void setAllToViewObject(Object *);
00170 
00171     void home();
00172     void moveForward(double multiplier);
00173     void move(double unten, double right); // 2 Dimensional gesehene Bewegung
00174     void zoom(double multiplier) ;
00175     void zoomTo(Vector & pos_, double distance_);
00176     void changeLinearScaleFactor(double multiplier);
00177 
00182     inline void setProjectionCenter(const Vector & pos_) {
00183         projectionCenter = pos_;
00184     }
00185 
00189     inline Vector getProjectionCenter() {
00190         return projectionCenter;
00191     }
00192 
00196     inline Vector getViewDirectionOrthogonal() {
00197         Vector viewDirection=projectionCenter - place;
00198         viewDirection.normalise();
00199         return  viewDirection.crossProduct(upper);
00200     }
00201 
00206     inline void setPosition(const Vector & pos_) {
00207         place = pos_;
00208     }
00209 
00214     inline void setUpper(const Vector & pos_) {
00215         upper = pos_;
00216         upper.normalise();
00217     }
00218 
00222     inline Vector getUpper() {
00223         return upper;
00224     }
00225 
00229     inline Vector getPosition() {
00230         return place;
00231     }
00232 
00236     double getProjectionDistance() {
00237         return (projectionCenter-place).length();
00238     }
00239 };
00240 
00241 extern Camera ourCamera;
00242 
00243 #endif

Erzeugt am Mon May 30 14:31:15 2005 für Sunsystembuildingandsimulation von doxygen 1.3.6