00001 /* 00002 File: Camera.h 00003 00004 Function: Defines a camera. When sent to a Renderer, this defines 00005 the current view (and perspective) transformations. 00006 A camera can be embedded in a scene: see SceneObjects.cc 00007 00008 Author(s): Andrew Willmott 00009 00010 Copyright: (c) 1995-2000, Andrew Willmott 00011 */ 00012 00013 #ifndef __Camera__ 00014 #define __Camera__ 00015 00016 #include "gcl/Geometry.h" 00017 #include "cl/String.h" 00018 #include <iostream.h> 00019 00020 class Camera 00021 // Maps view into viewport [-1,1] x [-1,1] 00022 { 00023 public: 00024 Camera(); 00025 00026 // Set standard camera parameters. (shared by all.) 00027 Void SetClipping(GCLReal nearPlane, GCLReal farPlane); 00028 Void SetFOV(GCLReal fieldOfView); 00029 Void SetAspect(GCLReal aspect); 00030 Void SetScale(GCLReal scale); 00031 00032 // useful routines for directly setting the view 00033 Void SetView(const Point &eyePoint, const Quaternion &orientation); 00034 Void SetViewDir(const Point &pos, const Vector &dir); 00035 Void SetLookAt(const Point &pos, const Point &at); 00036 Void SetModelCentric(const Coord &rot, const Vector &trans); 00037 Void SetViewUp(Vector up); 00038 00039 // set up a particular model from params (low-level) 00040 Void SetupViewDir(); 00041 Void SetupLookAt(); 00042 Void SetupModelCentric(); 00043 00044 // set params for a particular model from the generic model. 00045 Void GetViewDirParams(); 00046 Void GetLookAtParams(); 00047 Void GetModelCentricParams(); 00048 00049 // avar handling stuff 00050 virtual Void PrintAvars(Bool animFormat = false); 00051 virtual Bool CheckAvar(StrConst avarName, GCLReal avarVal); 00052 virtual Void SetupFromParams(); 00053 00054 virtual Transform ProjMatrix() const; 00055 // Return the projection matrix from Camera space to 00056 // Display Space ([-1,1] ^ 2) 00057 virtual Transform ModelMatrix() const; 00058 // Return the transformation from World space to Camera 00059 // space 00060 00061 00062 Int model; 00063 00064 // generic camera model. all models convert to this. 00065 Point position; 00066 Quaternion orient; 00067 GCLReal scale; 00068 GCLReal clipNear, clipFar; 00069 GCLReal fov; 00070 GCLReal aspect; 00071 Int lhand; 00072 00073 // the standard view-up/direction camera model params 00074 Point up; 00075 Vector viewDir; 00076 Point lookAt; 00077 00078 // model-centric model params 00079 Point modelCentre; 00080 Point trans; 00081 Coord rot; 00082 }; 00083 00097 Void FindWorldRay( 00098 const Coord &c, 00099 const Transform &inverseW2S, 00100 Point &from, 00101 Vector &dir 00102 ); 00103 00104 00105 #endif