Camera.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893
  1. //---------------------------------------------------------------------------
  2. //
  3. // Camera.h -- File contains the camera class definitions
  4. //
  5. //---------------------------------------------------------------------------//
  6. // Copyright (C) Microsoft Corporation. All rights reserved. //
  7. //===========================================================================//
  8. #ifndef CAMERA_H
  9. #define CAMERA_H
  10. //---------------------------------------------------------------------------
  11. // Include Files
  12. #ifndef DCAMERA_H
  13. #include "dcamera.h"
  14. #endif
  15. #ifndef TERRAIN_H
  16. #include "terrain.h"
  17. #endif
  18. #ifndef MATHFUNC_H
  19. #include "mathfunc.h"
  20. #endif
  21. #ifndef TGL_H
  22. #include "tgl.h"
  23. #endif
  24. #ifndef INIFILE_H
  25. #include "inifile.h"
  26. #endif
  27. #include <stuff\stuff.hpp>
  28. inline signed short int float2short(float _in)
  29. {
  30. #if 1
  31. return short(floor(_in));
  32. #else
  33. _in-=0.5f;
  34. _in+=12582912.0f;
  35. return(*(signed short int*)&_in);
  36. #endif
  37. }
  38. extern float zero;
  39. extern float one;
  40. extern float point1;
  41. //---------------------------------------------------------------------------
  42. // Also defined in Stuff but not getting into here somehow.
  43. enum Axes {
  44. X_Axis,
  45. Y_Axis,
  46. Z_Axis,
  47. W_Axis
  48. };
  49. #define MAX_LODS 3
  50. #define MAX_VIEWS 4
  51. #define F2_VIEW 0
  52. #define F3_VIEW 1
  53. #define F4_VIEW 2
  54. #define F5_VIEW 3
  55. //---------------------------------------------------------------------------
  56. class Camera
  57. {
  58. //Data Members
  59. //-------------
  60. protected:
  61. float projectionAngle; //Angle of orthogonal projection
  62. Stuff::Vector3D screenResolution; //Resolution of screen in pixels
  63. Stuff::Vector3D screenCenter; //Center coordinate of screen
  64. Stuff::Vector3D lookVector; //Direction camera is looking.
  65. Stuff::Vector3D physicalPos; //Actual Physical Position of camera in world.
  66. CameraClass cameraClass; //Type of camera.w
  67. // data for Camera Movement
  68. Stuff::Vector3D position; //Position of camera in 3Space.
  69. float cameraRotation; //Current Direction camera is looking.
  70. float worldCameraRotation; //Current Direction camera is facing in World Frame of reference.
  71. float zoomLevelLODScale[MAX_LODS]; //Data to help calc which LOD at which zoom.
  72. Stuff::LinearMatrix4D cameraOrigin; //Translation and rotation of Camera
  73. Stuff::LinearMatrix4D worldToCameraMatrix; //Inverse of the above.
  74. Stuff::YawPitchRange cameraDirection; //Direction camera is looking.
  75. Stuff::Vector2DOf<float> cameraShift; //Position camera is looking At.
  76. Stuff::Matrix4D cameraToClip; //Camera Clip Matrix--Used for projection and zoom.
  77. Stuff::Matrix4D worldToClip; //Matrix used to bring a point from world space to camera/clip space
  78. Stuff::Matrix4D clipToWorld; //Matrix used to bring a point from camera/clip space to world space
  79. float startZInverse; //Used to help interpolate the Screen Coords in InverseProjectZ
  80. float startWInverse;
  81. float zPerPixel;
  82. float wPerPixel;
  83. TG_LightPtr *worldLights; //Lighting for the entire world.
  84. long numLights; //Number of lights in the above list. Always MAX_LIGHTS!
  85. TG_LightPtr *activeLights; //This is the light list to process every frame.
  86. long numActiveLights; //Number of lights active. Actually Correct.
  87. TG_LightPtr *terrainLights; //This is the light list to process every frame for TERRAIN ONLY
  88. long numTerrainLights; //Number of lights active for terrain. Actually Correct.
  89. //Camera Scripting stuff
  90. Stuff::Vector3D goalPosition;
  91. Stuff::Vector3D lookPosition;
  92. float goalPosTime;
  93. Stuff::Vector3D goalRotation;
  94. float goalRotTime;
  95. float goalFOV;
  96. float goalFOVTime;
  97. Stuff::Vector3D velocity;
  98. Stuff::Vector3D goalVelocity;
  99. float goalVelTime;
  100. long lookTargetObject;
  101. float letterBoxPos;
  102. float letterBoxTime;
  103. BYTE letterBoxAlpha;
  104. bool startEnding;
  105. bool inFadeMode;
  106. DWORD fadeColor;
  107. DWORD fadeAlpha;
  108. DWORD fadeStart;
  109. float timeLeftToFade;
  110. float startFadeTime;
  111. public:
  112. bool active; //Is camera active (ie. drawing itself)
  113. bool ready; //Is camera ready to be activated?
  114. bool usePerspective; //Switch camera from Parallel to perspective view
  115. Stuff::Vector3D lightDirection; //Direction of Spot Light
  116. float lightYaw; //Direction of Light in Azimuth, elevation
  117. float lightPitch;
  118. float lightFinalYaw;
  119. float lightFinalPitch;
  120. float lightTimeToFinal;
  121. float newScaleFactor; //Smooth Zooming
  122. float camera_fov; //Smooth Perspective zooming.
  123. float cosHalfFOV; //Cosine of half the FOV for view cone.
  124. float viewMulX, viewMulY, //GOS Viewport data variables
  125. viewAddX, viewAddY;
  126. unsigned char lightRed; //Red component of World Light
  127. unsigned char lightGreen; //Green component of World Light
  128. unsigned char lightBlue; //Blue component of World Light
  129. unsigned char ambientRed; //Red component of World Light
  130. unsigned char ambientGreen; //Green component of World Light
  131. unsigned char ambientBlue; //Blue component of World Light
  132. bool terrainShadowColorEnabled;
  133. unsigned char terrainShadowRed; //Red component of World Light
  134. unsigned char terrainShadowGreen; //Green component of World Light
  135. unsigned char terrainShadowBlue; //Blue component of World Light
  136. //Day/Night transition data.
  137. float dayLightPitch;
  138. unsigned char dayLightRed; //Red component of World Light
  139. unsigned char dayLightGreen; //Green component of World Light
  140. unsigned char dayLightBlue; //Blue component of World Light
  141. unsigned char dayAmbientRed; //Red component of World Light
  142. unsigned char dayAmbientGreen; //Green component of World Light
  143. unsigned char dayAmbientBlue; //Blue component of World Light
  144. unsigned char sunsetLightRed; //Red component of World Light
  145. unsigned char sunsetLightGreen; //Green component of World Light
  146. unsigned char sunsetLightBlue; //Blue component of World Light
  147. unsigned char nightLightRed; //Red component of World Light
  148. unsigned char nightLightGreen; //Green component of World Light
  149. unsigned char nightLightBlue; //Blue component of World Light
  150. unsigned char nightAmbientRed; //Red component of World Light
  151. unsigned char nightAmbientGreen; //Green component of World Light
  152. unsigned char nightAmbientBlue; //Blue component of World Light
  153. bool terrainLightNight; //What state are the terrain lights in?
  154. bool terrainLightCalc; //Should we activate all terrain lights this frame and burn their lights in?
  155. bool isNight; //Flag indicating if we are in NightMode
  156. //Based solely on light angle.
  157. float nightFactor; //How "night" is it? 1.0f being full night, 0.0f being full day!
  158. float day2NightTransitionTime;//Time in Seconds that light goes from day to night.
  159. float dayLightTime; //Current dayToNight Transition time.
  160. bool forceShadowRecalc; //Has the sun/moon moved enough for shadows to have changed?
  161. unsigned char seenRed; //Red component of World Light
  162. unsigned char seenGreen; //Green component of World Light
  163. unsigned char seenBlue; //Blue component of World Light
  164. unsigned char baseRed; //Red component of World Light
  165. unsigned char baseGreen; //Green component of World Light
  166. unsigned char baseBlue; //Blue component of World Light
  167. float cameraShiftZ;
  168. float goalPositionZ;
  169. float fogStart; //Altitude at which fog starts
  170. float fogFull; //Altitude at which fog is Full;
  171. DWORD dayFogColor; //Color of FOG.
  172. float fogTransparency; //How much of the sky color will show through
  173. DWORD fogColor; //Color of FOG.
  174. float cameraAltitude;
  175. float cameraAltitudeDesired; //What would I like the camera to be at! Maybe smaller due to low angle!
  176. static float globalScaleFactor; //Global Rescale Factor.
  177. static float MaxClipDistance;
  178. static float MinHazeDistance;
  179. static float DistanceFactor;
  180. static float MinNearPlane;
  181. static float MaxNearPlane;
  182. static float MinFarPlane;
  183. static float MaxFarPlane;
  184. static float HazeFactor;
  185. static float verticalSphereClipConstant;
  186. static float horizontalSphereClipConstant;
  187. static float NearPlaneDistance;
  188. static float FarPlaneDistance;
  189. static float AltitudeMinimum;
  190. static float AltitudeMaximumLo;
  191. static float AltitudeMaximumHi;
  192. static float AltitudeTight;
  193. static float AltitudeDefault;
  194. static float MaxLetterBoxTime;
  195. static float MIN_PERSPECTIVE;
  196. static float MAX_PERSPECTIVE;
  197. static float MIN_ORTHO;
  198. static float MAX_ORTHO;
  199. static bool inMovieMode;
  200. static bool forceMovieEnd;
  201. static float MaxLetterBoxPos;
  202. static float cameraTilt[MAX_VIEWS];
  203. static float cameraZoom[MAX_VIEWS];
  204. static frameOfRef cameraFrame;
  205. //Member Functions
  206. //-----------------
  207. public:
  208. virtual void init (void)
  209. {
  210. projectionAngle = 30;
  211. screenResolution.x = 400.0;
  212. screenResolution.y = 400.0;
  213. position.Zero();
  214. ready = active = FALSE;
  215. cameraClass = INVALID_CAMERA;
  216. setCameraRotation(0.0,0.0);
  217. cameraShiftZ = goalPositionZ = 0.0f;
  218. lightDirection.Zero();
  219. newScaleFactor = 0.5;
  220. cameraShift.x = cameraShift.y = 0.0;
  221. worldLights = NULL;
  222. activeLights = NULL;
  223. terrainLights = NULL;
  224. fogStart = fogFull = 0.0;
  225. dayFogColor = 0xffffffff;
  226. fogTransparency = 1.0;
  227. fogColor = 0xffffffff;
  228. usePerspective = false;
  229. viewMulX = viewMulY = viewAddX = viewAddY = 0.0f;
  230. isNight = false;
  231. forceShadowRecalc = false;
  232. goalPosition.Zero();
  233. lookPosition.Zero();
  234. goalPosTime = 0.0;
  235. goalRotation.x = goalRotation.y = goalRotation.z = 0.0;
  236. goalRotTime = 0.0;
  237. goalFOV = 0.0;
  238. goalFOVTime = 0.0;
  239. velocity.Zero();
  240. goalVelocity.Zero();
  241. goalVelTime = 0.0;
  242. lookTargetObject = -1;
  243. terrainLightNight = false;
  244. terrainLightCalc = true;
  245. letterBoxPos = 0.0f;
  246. letterBoxTime = 0.0f;
  247. letterBoxAlpha = 0x0;
  248. startEnding = false;
  249. inFadeMode = false;
  250. fadeColor = 0x0;
  251. fadeAlpha = 0x0;
  252. timeLeftToFade = 0.0f;
  253. startFadeTime = 0.0f;
  254. cameraAltitude = 1200.0f;
  255. cameraAltitudeDesired = 1200.0f;
  256. nightFactor = 0.0f;
  257. }
  258. Camera (void)
  259. {
  260. init();
  261. }
  262. long init (FitIniFile *cameraFile);
  263. void destroy (void);
  264. ~Camera (void)
  265. {
  266. destroy();
  267. }
  268. float getProjectionAngle (void)
  269. {
  270. return(projectionAngle);
  271. }
  272. void setCameraRotation (float angle, float angleWorld);
  273. float getCameraRotation (void);
  274. //---------------------------------------------------------------------------
  275. bool projectZ (Stuff::Vector3D &point, Stuff::Vector4D &screen)
  276. {
  277. //--------------------------------------------------------------------
  278. // Now run the NEW project code
  279. Stuff::Vector4D xformCoords;
  280. Stuff::Point3D coords;
  281. coords.x = -point.x;
  282. coords.y = point.z;
  283. coords.z = point.y;
  284. xformCoords.Multiply(coords,worldToClip);
  285. if (usePerspective)
  286. {
  287. //---------------------------------------
  288. // Perspective Transform
  289. float rhw = 1.0f;
  290. if (xformCoords.w != 0.0f)
  291. rhw = 1.0f / xformCoords.w;
  292. screen.x = (xformCoords.x * rhw) * viewMulX + viewAddX;
  293. screen.y = (xformCoords.y * rhw) * viewMulY + viewAddY;
  294. screen.z = (xformCoords.z * rhw);
  295. screen.w = fabs(rhw);
  296. }
  297. else
  298. {
  299. //---------------------------------------
  300. // Parallel Transform
  301. screen.x = (1.0f - xformCoords.x) * viewMulX + viewAddX;
  302. screen.y = (1.0f - xformCoords.y) * viewMulY + viewAddY;
  303. screen.z = xformCoords.z;
  304. screen.w = 0.000001f;
  305. }
  306. if ((screen.x < 0) || (screen.y < 0) || (screen.x > screenResolution.x) || (screen.y > screenResolution.y))
  307. return FALSE;
  308. return TRUE;
  309. }
  310. void inverseProjectZ (Stuff::Vector4D &screen, Stuff::Vector3D &point);
  311. void projectCamera (Stuff::Vector3D &point);
  312. unsigned long inverseProject (Stuff::Vector2DOf<long> &screenPos, Stuff::Vector3D &point);
  313. void getClosestVertex (Stuff::Vector2DOf<long> &screenPos, long &row, long &col);
  314. void setOrthogonal(void);
  315. virtual void setCameraOrigin (void);
  316. void calculateProjectionConstants (void);
  317. void calculateTopViewConstants (void);
  318. void changeResolution (Stuff::Vector3D newRes)
  319. {
  320. screenResolution = newRes;
  321. calculateProjectionConstants();
  322. }
  323. void prepareBackground (void);
  324. CameraClass getClass (void)
  325. {
  326. return cameraClass;
  327. }
  328. void setClass(CameraClass newClass) {cameraClass = newClass;}
  329. Stuff::Vector3D getPosition (void)
  330. {
  331. return position;
  332. }
  333. void updateDaylight (bool bInitialize = false);
  334. virtual long update (void);
  335. virtual void render (void);
  336. virtual long activate (void);
  337. virtual void reset (void)
  338. {
  339. }
  340. void deactivate (void);
  341. void setLightColor (long index, DWORD argb)
  342. {
  343. if ((index >= 0) && (index < numLights) && worldLights[index])
  344. worldLights[index]->SetaRGB(argb);
  345. }
  346. DWORD getLightColor (long index)
  347. {
  348. if ((index >= 0) && (index < numLights) && worldLights[index])
  349. return worldLights[index]->GetaRGB();
  350. return 0x00ffffff;
  351. }
  352. void setLightIntensity (long index, float intensity)
  353. {
  354. if ((index >= 0) && (index < numLights) && worldLights[index])
  355. worldLights[index]->intensity = intensity;
  356. }
  357. //Return the ACTIVE lights. NOT the total light list!!
  358. TG_LightPtr getWorldLight (long index)
  359. {
  360. if ((index >= 0) && (index < numActiveLights) && activeLights[index])
  361. return activeLights[index];
  362. return NULL;
  363. }
  364. TG_LightPtr *getWorldLights (void)
  365. {
  366. return activeLights;
  367. }
  368. long getNumLights (void)
  369. {
  370. return numActiveLights;
  371. }
  372. TG_LightPtr getTerrainLight (long index)
  373. {
  374. if ((index >= 0) && (index < numTerrainLights) && terrainLights[index])
  375. return terrainLights[index];
  376. return NULL;
  377. }
  378. TG_LightPtr *getTerrainLights (void)
  379. {
  380. return terrainLights;
  381. }
  382. long getNumTerrainLights (void)
  383. {
  384. return numTerrainLights;
  385. }
  386. long addWorldLight (TG_LightPtr light)
  387. {
  388. numLights = MAX_LIGHTS_IN_WORLD;
  389. bool lightAdded = false;
  390. for (long i=0;i<MAX_LIGHTS_IN_WORLD;i++)
  391. {
  392. if (!worldLights[i])
  393. {
  394. worldLights[i] = light;
  395. lightAdded = true;
  396. return i;
  397. }
  398. }
  399. return -1;
  400. }
  401. void removeWorldLight (DWORD lightNum, TG_LightPtr light)
  402. {
  403. if ((lightNum < MAX_LIGHTS_IN_WORLD) && (worldLights[lightNum] == light))
  404. {
  405. worldLights[lightNum] = NULL; //Up to class that created light to free it!!!!!!
  406. return;
  407. }
  408. //If we get here, the light we passed in either had an invalid index OR did not match the pointer
  409. // at the location we passed in. Scan all lights for a match and toss any and all that do match
  410. for (long i=0;i<MAX_LIGHTS_IN_WORLD;i++)
  411. {
  412. if (worldLights[i] == light)
  413. worldLights[i] = NULL;
  414. }
  415. }
  416. Stuff::Vector3D getScreenRes (void)
  417. {
  418. return screenResolution;
  419. }
  420. bool getIsNight (void)
  421. {
  422. return isNight;
  423. }
  424. float getNightFactor (void)
  425. {
  426. return nightFactor;
  427. }
  428. long getScreenResX (void)
  429. {
  430. return float2long(screenResolution.x);
  431. }
  432. long getScreenResY (void)
  433. {
  434. return float2long(screenResolution.y);
  435. }
  436. float fgetScreenResX (void)
  437. {
  438. return screenResolution.x;
  439. }
  440. float fgetScreenResY (void)
  441. {
  442. return screenResolution.y;
  443. }
  444. float getScaleFactor (void)
  445. {
  446. return newScaleFactor;
  447. }
  448. long getScaleLOD (void)
  449. {
  450. for (long i=0;i<MAX_LODS;i++)
  451. {
  452. if (newScaleFactor >= zoomLevelLODScale[i])
  453. return i;
  454. }
  455. return (MAX_LODS-1); //ALWAYS return worst case if necessary
  456. }
  457. //-----------------------------------------
  458. // Returns Vector in Direction of Camera.
  459. // For BackFacing Object Checks
  460. Stuff::Vector3D getLookVector (void)
  461. {
  462. return lookVector;
  463. }
  464. Stuff::Vector3D getCameraOrigin (void)
  465. {
  466. return physicalPos;
  467. }
  468. float getTiltFactor (void)
  469. {
  470. float result = 1.0;
  471. if (usePerspective)
  472. {
  473. result = 0.5f + ((projectionAngle - 28.0f) * 0.016666667f * 0.5); //1/60th
  474. }
  475. return result;
  476. }
  477. //----------------------------------------------
  478. // Camera Positioning Functions
  479. void setCameraView (long viewNum);
  480. void allNormal (void)
  481. {
  482. tiltNormal();
  483. ZoomNormal();
  484. rotateNormal();
  485. }
  486. void allDefault (void)
  487. {
  488. ZoomDefault();
  489. }
  490. void allMaxIn (void)
  491. {
  492. ZoomMax();
  493. }
  494. virtual void allTight (void)
  495. {
  496. ZoomTight();
  497. }
  498. void zoomValue (float value);
  499. void ZoomIn (float amount);
  500. void ZoomOut (float amount);
  501. void ZoomNormal (void);
  502. void ZoomDefault (void);
  503. void ZoomTight (void);
  504. void ZoomMax (void);
  505. void ZoomMin (void);
  506. void tiltValue (float value);
  507. void tiltUp (float amount);
  508. void tiltDown (float amount);
  509. void tiltNormal (void);
  510. void movePosLeft(float amount, Stuff::Vector3D &pos);
  511. void movePosRight(float amount, Stuff::Vector3D &pos);
  512. void movePosUp(float amount, Stuff::Vector3D &pos);
  513. void movePosDown(float amount, Stuff::Vector3D &pos);
  514. virtual void moveLeft(float amount);
  515. virtual void moveRight(float amount);
  516. virtual void moveUp(float amount);
  517. virtual void moveDown(float amount);
  518. void rotateLeft(float amount);
  519. void rotateRight(float amount);
  520. void rotateNormal (void);
  521. void rotateLightLeft(float amount);
  522. void rotateLightRight(float amount);
  523. void rotateLightUp(float amount);
  524. void rotateLightDown(float amount);
  525. unsigned char getLightRed (float intensity);
  526. unsigned char getLightGreen (float intensity);
  527. unsigned char getLightBlue (float intensity);
  528. void setPosition(Stuff::Vector3D newPosition, bool swoopy = true);
  529. bool save( FitIniFile* fileName );
  530. float getFarClipDistance();
  531. void setFarClipDistance(float farClipDistance);
  532. float getNearClipDistance();
  533. void setNearClipDistance(float nearClipDistance);
  534. float getMaximumCameraAltitude();
  535. void setMaximumCameraAltitude(float maxAltitude);
  536. //--------------------------------------------
  537. // Camera Scripting API
  538. void setMovieMode (void)
  539. {
  540. if (!inMovieMode)
  541. {
  542. inMovieMode = true;
  543. startEnding = false;
  544. forceMovieEnd = false;
  545. letterBoxPos = 0.0f; //Start letterboxing;
  546. letterBoxTime = 0.0f;
  547. }
  548. }
  549. void endMovieMode (void)
  550. {
  551. if (inMovieMode)
  552. startEnding = true; //Start the letterbox shrinking. When fully shrunk, inMovieMode goes false!
  553. }
  554. void fadeToColor (DWORD color, float timeToFade)
  555. {
  556. if (!inFadeMode && (timeToFade > Stuff::SMALL))
  557. {
  558. inFadeMode = true;
  559. fadeStart = fadeColor;
  560. fadeColor = color;
  561. timeLeftToFade = 0.0f;
  562. startFadeTime = timeToFade;
  563. }
  564. }
  565. void forceMovieToEnd (void) //ABL Script must handle this going true!!!!
  566. {
  567. forceMovieEnd = true;
  568. }
  569. void setFieldOfView (float fov)
  570. {
  571. camera_fov = fov;
  572. }
  573. float getFieldOfView (void)
  574. {
  575. return camera_fov;
  576. }
  577. void setFieldOfViewGoal (float fov, float time)
  578. {
  579. goalFOV = fov;
  580. goalFOVTime = time;
  581. }
  582. float getFieldOfViewGoal (void)
  583. {
  584. return goalFOV;
  585. }
  586. void setGoalPosition (Stuff::Vector3D goalPos)
  587. {
  588. goalPosition = goalPos;
  589. }
  590. void setLookPosition (Stuff::Vector3D goalPos)
  591. {
  592. lookPosition = goalPos;
  593. }
  594. Stuff::Vector3D getGoalPosition (void)
  595. {
  596. return goalPosition;
  597. }
  598. Stuff::Vector3D getLookPosition (void)
  599. {
  600. return lookPosition;
  601. }
  602. void setGoalPosTime (float time)
  603. {
  604. goalPosTime = time;
  605. }
  606. Stuff::Vector3D getRotation (void)
  607. {
  608. Stuff::Vector3D rot(0.0,0.0,0.0);
  609. rot.x = projectionAngle;
  610. rot.y = cameraRotation;
  611. return rot;
  612. }
  613. void setRotation (Stuff::Vector3D rot)
  614. {
  615. projectionAngle = rot.x;
  616. setCameraRotation(rot.y,rot.y);
  617. cameraAltitude = rot.z;
  618. if (cameraAltitude < AltitudeMinimum)
  619. cameraAltitude = AltitudeMinimum;
  620. float anglePercent = (projectionAngle - MIN_PERSPECTIVE) / (MAX_PERSPECTIVE - MIN_PERSPECTIVE);
  621. float testMax = Camera::AltitudeMaximumLo + ((Camera::AltitudeMaximumHi - Camera::AltitudeMaximumLo) * anglePercent);
  622. newScaleFactor = 1.0f - ((cameraAltitude - AltitudeMinimum) / testMax);
  623. }
  624. void setGoalRotation (Stuff::Vector3D goalRot)
  625. {
  626. goalRotation = goalRot;
  627. }
  628. Stuff::Vector3D getGoalRotation (void)
  629. {
  630. return goalRotation;
  631. }
  632. void setGoalRotTime (float time)
  633. {
  634. goalRotTime = time;
  635. }
  636. Stuff::Vector3D getVelocity (void)
  637. {
  638. return velocity;
  639. }
  640. void setVelocity (Stuff::Vector3D vel)
  641. {
  642. velocity = vel;
  643. }
  644. Stuff::Vector3D getGoalVelocity (void)
  645. {
  646. return goalVelocity;
  647. }
  648. void setGoalVelocity (Stuff::Vector3D goalVel)
  649. {
  650. goalVelocity = goalVel;
  651. }
  652. void setGoalVelTime (float time)
  653. {
  654. goalVelTime = time;
  655. }
  656. void updateGoalVelocity(void);
  657. void updateGoalPosition (Stuff::Vector3D &pos);
  658. void updateGoalRotation (void);
  659. void updateGoalFOV (void);
  660. void updateLetterboxAndFade (void);
  661. void setCameraTargetId (long targId)
  662. {
  663. lookTargetObject = targId;
  664. }
  665. long getCameraTargetId (void)
  666. {
  667. return lookTargetObject;
  668. }
  669. void setInverseProject (float sZ, float sW, float zPP, float wPP)
  670. {
  671. startZInverse = sZ;
  672. startWInverse = sW;
  673. zPerPixel = zPP;
  674. wPerPixel = wPP;
  675. }
  676. };
  677. //---------------------------------------------------------------------------
  678. extern CameraPtr eye;
  679. //---------------------------------------------------------------------------
  680. #endif
  681. //---------------------------------------------------------------------------
  682. //
  683. // Edit log
  684. //
  685. //---------------------------------------------------------------------------