1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #ifndef TITANIC_VIEWPORT_H 24 #define TITANIC_VIEWPORT_H 25 26 #include "titanic/star_control/base_stars.h" 27 #include "titanic/star_control/fpose.h" 28 29 class SimpleFile; 30 31 namespace Titanic { 32 33 /** 34 * The color of the stars when drawn (CBaseStars::draw) 35 * For starview it should be white 36 * For skyview it should be pink 37 */ 38 enum StarColor { WHITE = 0, PINK = 2 }; 39 40 /** 41 * Implements the viewport functionality for viewing the star field in 42 * a given position and orientation. 43 * CCamera is a big user of this class 44 */ 45 class CViewport { 46 private: 47 double _spin; 48 double _centerYAngleDegrees; 49 double _centerZAngleDegrees; 50 int _width; 51 int _height; 52 FMatrix _orientation; 53 FPose _currentPose; 54 FPose _rawPose; 55 FPoint _center; 56 bool _poseUpToDate; 57 private: 58 void reset(); 59 public: 60 FVector _position; 61 double _frontClip; 62 double _backClip; 63 StarColor _starColor; // Used in CBaseStars::draw 64 double _valArray[2]; // has value 0.0 or 30.0 65 double _isZero; 66 double _pixel1OffSetX; // Used in CBaseStars::draw3 and CBaseStars::draw4 has value 0.0 or 28000.0 67 double _pixel2OffSetX; // Used in CBaseStars::draw3 and CBaseStars::draw4 has value 0.0 or -28000.0 68 FVector _centerVector; 69 public: 70 CViewport(); 71 CViewport(CViewport *src); 72 73 /** 74 * Copys the data from another instance 75 */ 76 void copyFrom(const CViewport *src); 77 78 /** 79 * Load the data for the class from file 80 */ 81 void load(SimpleFile *file, int param); 82 83 /** 84 * Save the data for the class to file 85 */ 86 void save(SimpleFile *file, int indent); 87 88 /** 89 * Sets the position 90 */ 91 void setPosition(const FVector &v); 92 93 /** 94 * Sets the position 95 */ 96 void setPosition(const FPose &pose); 97 98 /** 99 * Sets the orientation from a passed matrix 100 */ 101 void setOrientation(const FMatrix &m); 102 103 /** 104 * Sets the orientation from a passed vector 105 */ 106 void setOrientation(const FVector &v); 107 108 void randomizeOrientation(); 109 110 /** 111 * The view has changed between starview and skyview 112 * Change the enum that tracks the color of the stars 113 * Also change the X coordinate pixel offset used for star drawing 114 */ 115 void changeStarColorPixel(StarMode mode, double pixelOffSet); 116 void reposition(double factor); 117 118 /** 119 * Applys a rotation matrix to the current 120 * orientation 121 */ 122 void changeOrientation(const FMatrix &matrix); 123 124 FPose getPose(); 125 FPose getRawPose(); 126 FVector getRelativePosNoCentering(int index, const FVector &src); 127 FVector getRelativePosCentering(int index, const FVector &src); 128 FVector getRelativePosCenteringRaw(int index, const FVector &src); 129 130 /** 131 * All arguments are return values 132 * First is the x center coordinate relative to y 133 * Second is the x center coordinate relative to z 134 * Third is the first x center pixel offset 135 * Fourth is the second x center pixel offset 136 */ 137 void getRelativeXCenterPixels(double *v1, double *v2, double *v3, double *v4); 138 139 /** 140 * Returns the viewport's orientation 141 */ 142 const FMatrix &getOrientation() const; 143 144 /** 145 * Assigns a roll angle about the view direction 146 */ 147 void SetRoleAngle(double angle); 148 149 /** 150 * Assign a near clip plane distance 151 */ 152 void setFrontClip(double dist); 153 154 /** 155 * Assign a far clipping plane distance 156 */ 157 void setBackClip(double dist); 158 159 /** 160 * Sets the center vector y angle 161 * The actual center y value doesn't 162 * change untill reset is called 163 */ 164 void setCenterYAngle(double angleDegrees); 165 166 /** 167 * Sets the center vector z angle 168 * The actual center z value doesn't 169 * change untill reset is called 170 */ 171 void setCenterZAngle(double angleDegrees); 172 }; 173 174 } // End of namespace Titanic 175 176 #endif /* TITANIC_VIEWPORT_H */ 177