2 #include "TileObject.h" 3 #include "PortalFrustum.h" 4 #include "CameraFrustum.h" 34 enum CharacterAndCameraKeys
53 #define WM_MOUSEWHEEL 0x020A 56 #define KEY_WAS_DOWN_MASK 0x80 57 #define KEY_IS_DOWN_MASK 0x01 59 #define MOUSE_LEFT_BUTTON 0x01 60 #define MOUSE_MIDDLE_BUTTON 0x02 61 #define MOUSE_RIGHT_BUTTON 0x04 62 #define MOUSE_WHEEL 0x08 75 static BYTE m_scancode_key_map[MAX_KEYS];
89 ATTRIBUTE_METHOD1(
CBaseCamera, GetNearPlane_s,
float*) {*p1 = cls->GetNearPlane();
return S_OK;}
90 ATTRIBUTE_METHOD1(
CBaseCamera, SetNearPlane_s,
float) {cls->SetNearPlane(p1);
return S_OK;}
92 ATTRIBUTE_METHOD1(
CBaseCamera, GetFarPlane_s,
float*) {*p1 = cls->GetFarPlane();
return S_OK;}
93 ATTRIBUTE_METHOD1(
CBaseCamera, SetFarPlane_s,
float) {cls->SetFarPlane(p1);
return S_OK;}
95 ATTRIBUTE_METHOD1(
CBaseCamera, GetFieldOfView_s,
float*) {*p1 = cls->GetFieldOfView();
return S_OK;}
96 ATTRIBUTE_METHOD1(
CBaseCamera, SetFieldOfView_s,
float) {cls->SetFieldOfView(p1);
return S_OK;}
98 ATTRIBUTE_METHOD1(
CBaseCamera, GetAspectRatio_s,
float*) {*p1 = cls->GetAspectRatio();
return S_OK;}
99 ATTRIBUTE_METHOD1(
CBaseCamera, SetAspectRatio_s,
float) {cls->SetAspectRatio(p1);
return S_OK;}
101 ATTRIBUTE_METHOD1(
CBaseCamera, IsPerspectiveView_s,
bool*) {*p1 = cls->IsPerspectiveView();
return S_OK;}
102 ATTRIBUTE_METHOD1(
CBaseCamera, SetIsPerspectiveView_s,
bool) {cls->SetIsPerspectiveView(p1);
return S_OK;}
104 ATTRIBUTE_METHOD1(
CBaseCamera, GetOrthoWidth_s,
float*) {*p1 = cls->GetOrthoWidth();
return S_OK;}
105 ATTRIBUTE_METHOD1(
CBaseCamera, SetOrthoWidth_s,
float) {cls->SetOrthoWidth(p1);
return S_OK;}
107 ATTRIBUTE_METHOD1(
CBaseCamera, GetOrthoHeight_s,
float*) {*p1 = cls->GetOrthoHeight();
return S_OK;}
108 ATTRIBUTE_METHOD1(
CBaseCamera, SetOrthoHeight_s,
float) {cls->SetOrthoHeight(p1);
return S_OK;}
110 ATTRIBUTE_METHOD1(
CBaseCamera, GetMoveScaler_s,
float*) {*p1 = cls->GetMoveScaler();
return S_OK;}
111 ATTRIBUTE_METHOD1(
CBaseCamera, SetMoveScaler_s,
float) {cls->SetMoveScaler(p1);
return S_OK;}
113 ATTRIBUTE_METHOD1(
CBaseCamera, GetRotationScaler_s,
float*) {*p1 = cls->GetRotationScaler();
return S_OK;}
114 ATTRIBUTE_METHOD1(
CBaseCamera, SetRotationScaler_s,
float) {cls->SetRotationScaler(p1);
return S_OK;}
117 ATTRIBUTE_METHOD1(
CBaseCamera, IsShiftMoveSwitched_s,
bool*) {*p1 = cls->IsShiftMoveSwitched();
return S_OK;}
118 ATTRIBUTE_METHOD1(
CBaseCamera, SetShiftMoveSwitched_s,
bool) {cls->SetShiftMoveSwitched(p1);
return S_OK;}
120 ATTRIBUTE_METHOD1(
CBaseCamera, IsInvertPitch_s,
bool*) {*p1 = cls->IsInvertPitch();
return S_OK;}
121 ATTRIBUTE_METHOD1(
CBaseCamera, SetInvertPitch_s,
bool) {cls->SetInvertPitch(p1);
return S_OK;}
123 ATTRIBUTE_METHOD1(
CBaseCamera, GetNumberOfFramesToSmoothMouseData_s,
int*) {*p1 = cls->GetNumberOfFramesToSmoothMouseData();
return S_OK;}
124 ATTRIBUTE_METHOD1(
CBaseCamera, SetNumberOfFramesToSmoothMouseData_s,
int) {cls->SetNumberOfFramesToSmoothMouseData(p1);
return S_OK;}
126 ATTRIBUTE_METHOD1(
CBaseCamera, GetEyePosition_s,
DVector3*) {*p1 = cls->GetEyePosition();
return S_OK;}
127 ATTRIBUTE_METHOD1(
CBaseCamera, GetLookAtPosition_s,
DVector3*) {*p1 =cls->GetLookAtPosition();
return S_OK;}
130 ATTRIBUTE_METHOD1(
CBaseCamera, GetMovementDrag_s,
bool*) {*p1 = cls->GetMovementDrag();
return S_OK;}
131 ATTRIBUTE_METHOD1(
CBaseCamera, SetMovementDrag_s,
bool) {cls->SetMovementDrag(p1);
return S_OK;}
133 ATTRIBUTE_METHOD1(
CBaseCamera, GetTotalDragTime_s,
float*) {*p1 = cls->GetTotalDragTime();
return S_OK;}
134 ATTRIBUTE_METHOD1(
CBaseCamera, SetTotalDragTime_s,
float) {cls->SetTotalDragTime(p1);
return S_OK;}
136 ATTRIBUTE_METHOD(
CBaseCamera, FrameMove_s) {cls->FrameMove(0.f);
return S_OK;}
142 virtual LRESULT HandleMessages( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
143 virtual void FrameMove( FLOAT fElapsedTime );
171 virtual void Reset();
172 virtual void SetViewParams(
const DVector3& vEyePt,
const DVector3& vLookatPt);
173 void SetProjParams(FLOAT fFOV, FLOAT fAspect, FLOAT fNearPlane, FLOAT fFarPlane);
175 virtual void SetFollowTarget(
CBaseObject* pObj) {};
176 virtual CBaseObject* GetFollowTarget(){
return NULL; };
188 VOID SetInvertPitch(
bool bInvertPitch );
189 bool IsInvertPitch(){
return m_bInvertPitch;}
190 VOID SetDrag(
bool bMovementDrag, FLOAT fTotalDragTimeToZero = 0.25f ) { m_bMovementDrag = bMovementDrag; m_fTotalDragTimeToZero = fTotalDragTimeToZero; }
191 VOID SetEnableYAxisMovement(
bool bEnableYAxisMovement ) { m_bEnableYAxisMovement = bEnableYAxisMovement; }
192 VOID SetEnablePositionMovement(
bool bEnablePositionMovement ) { m_bEnablePositionMovement = bEnablePositionMovement; }
193 VOID SetClipToBoundary(
bool bClipToBoundary,
Vector3* pvMinBoundary,
Vector3* pvMaxBoundary ) { m_bClipToBoundary = bClipToBoundary;
if( pvMinBoundary ) m_vMinBoundary = *pvMinBoundary;
if( pvMaxBoundary ) m_vMaxBoundary = *pvMaxBoundary; }
194 VOID SetScalers( FLOAT fRotationScaler = 0.01f, FLOAT fMoveScaler = 5.0f ) { m_fRotationScaler = fRotationScaler; m_fMoveScaler = fMoveScaler; }
196 VOID SetRotationScaler( FLOAT fRotationScaler = 0.01f);
197 float GetRotationScaler();
198 VOID SetMoveScaler( FLOAT fMoveScaler = 5.0f);
199 float GetMoveScaler();
201 VOID SetNumberOfFramesToSmoothMouseData(
int nFrames ) {
if( nFrames > 0 ) m_fFramesToSmoothMouseData = (float)nFrames; }
202 int GetNumberOfFramesToSmoothMouseData( ) {
return (
int)m_fFramesToSmoothMouseData; }
203 VOID SetResetCursorAfterMove(
bool bResetCursorAfterMove ) { m_bResetCursorAfterMove = bResetCursorAfterMove; }
210 inline Matrix4* GetViewMatrix() {
return &m_mView; }
211 inline Matrix4* GetProjMatrix() {
return &m_mProj; }
212 inline bool IsBeingDragged() {
return (m_bMouseLButtonDown || m_bMouseMButtonDown || m_bMouseRButtonDown); }
213 inline bool IsMouseLButtonDown() {
return m_bMouseLButtonDown; }
214 inline bool IsMouseMButtonDown() {
return m_bMouseMButtonDown; }
215 inline bool IsMouseRButtonDown() {
return m_bMouseRButtonDown; }
220 inline DVector3 GetEyePosition(){
return m_vEye;};
221 inline DVector3 GetLookAtPosition(){
return m_vLookAt;};
222 inline float GetFieldOfView(){
return m_fFOV;};
223 inline float GetAspectRatio(){
return m_fAspect;};
224 inline float GetNearPlane(){
return m_fNearPlane;};
225 inline float GetFarPlane(){
return m_fFarPlane;};
226 inline float GetOrthoHeight(){
return m_fOrthoHeight;};
227 inline float GetOrthoWidth(){
return m_fOrthoWidth;};
251 inline Vector3 GetWorldRight() {
return Vector3( m_mCameraWorld._11, m_mCameraWorld._12, m_mCameraWorld._13 ); }
252 inline Vector3 GetWorldUp() {
return Vector3( m_mCameraWorld._21, m_mCameraWorld._22, m_mCameraWorld._23 ); }
253 inline Vector3 GetWorldAhead() {
return Vector3( m_mCameraWorld._31, m_mCameraWorld._32, m_mCameraWorld._33 ); }
254 inline Vector3 GetEyePt() {
return Vector3( m_mCameraWorld._41, m_mCameraWorld._42, m_mCameraWorld._43 ); }
256 virtual Vector3 GetRenderEyePosition();
258 static void SetKeyMap(CharacterAndCameraKeys key, BYTE scancode);
260 static BYTE GetKeyMap(CharacterAndCameraKeys key);
265 virtual CharacterAndCameraKeys MapKey( UINT nKey );
266 BOOL IsKeyDown( BYTE key ) {
return( (key & KEY_IS_DOWN_MASK) == KEY_IS_DOWN_MASK ); }
267 BOOL WasKeyDown( BYTE key ) {
return( (key & KEY_WAS_DOWN_MASK) == KEY_WAS_DOWN_MASK ); }
271 void UpdateMouseDelta(
float fElapsedTime );
276 void UpdateMouseDelta(
int nDX,
int nDY);
277 void UpdateVelocity(
float fElapsedTime );
285 bool GetMovementDrag();
292 float GetTotalDragTime();
321 BYTE m_aKeys[MAX_KEYS];
322 POINT m_ptLastMousePosition;
323 bool m_bMouseLButtonDown;
324 bool m_bMouseMButtonDown;
325 bool m_bMouseRButtonDown;
326 int m_nCurrentButtonMask;
327 int m_nMouseWheelDelta;
329 float m_fFramesToSmoothMouseData;
335 float m_fCameraYawAngle;
336 float m_fCameraPitchAngle;
339 bool m_bMovementDrag;
342 FLOAT m_fTotalDragTimeToZero;
350 float m_fOrthoHeight;
351 bool m_bIsPerspectiveView;
353 float m_fRotationScaler;
357 bool m_bEnablePositionMovement;
358 bool m_bEnableYAxisMovement;
360 bool m_bClipToBoundary;
364 bool m_bResetCursorAfterMove;
382 virtual void FrameMove(
float fElapsedTime );
bool IsPerspectiveView()
get whether we use perspective view or orthogonal view
Definition: BaseCamera.h:230
void SetOrthoWidth(float fWidth)
change orthographic width of view volumn.
Definition: BaseCamera.cpp:193
void SetAspectRatio(float fAspect)
change the aspect ratio.
Definition: BaseCamera.cpp:199
CCameraFrustum * GetShadowFrustum()
get the shadow view frustum info shadow view frustum is smaller than m_frustum_object; its far plane ...
Definition: BaseCamera.h:162
3-dimensional vector with double precision.
Definition: ParaDVector3.h:17
an attribute class is a collection of attribute fields.
Definition: AttributeClass.h:10
First person view of the Target object.
Definition: BaseCamera.h:15
void SetTotalDragTime(float fTime)
Time it takes for velocity to go from full to 0.
Definition: BaseCamera.cpp:625
Definition: BaseCamera.h:376
bool CanSeeObject(IViewClippingObject *pObj)
test again view frustum
Definition: BaseCamera.cpp:803
virtual int GetAttributeClassID()
attribute class ID should be identical, unless one knows how overriding rules work.
Definition: BaseCamera.h:81
Definition: combase.h:159
Pure interface for CBaseObject (3D scene object) It defines basic shapes and collision detection...
Definition: IViewClippingObject.h:29
different physics engine has different winding order.
Definition: EventBinding.h:32
void SetFarPlane(float fDist)
change the far plane.
Definition: BaseCamera.cpp:223
Definition: PEtypes.h:116
DVector3 m_vEyeReferencePoint
: the eye position is always added by the m_vEyeReferencePoint when changed it is initialized to be (...
Definition: BaseCamera.h:316
CameraMode
Definition: BaseCamera.h:12
CCameraFrustum m_frustum_shadow
shadow view frustum, this is smaller than m_frustum_object; its far plane is set at a fixed size...
Definition: BaseCamera.h:301
Standard 3-dimensional vector.
Definition: ParaVector3.h:16
void SetFieldOfView(float fFieldofview)
change the field of view .
Definition: BaseCamera.cpp:208
CPortalFrustum m_frustum_portal
portal frustum with many planes formed by the portal vertices and the camera eye position.
Definition: BaseCamera.h:304
Definition: BaseCamera.h:70
void UpdateProjParams()
update the projection matrix using the current field of view and near and far plane values...
Definition: BaseCamera.cpp:177
void GetMouseRay(Vector3 &vPickRayOrig, Vector3 &vPickRayDir, POINT ptCursor, UINT nWidth, UINT nHeight, const Matrix4 *pMatWorld)
Desc: Get the mouse pay for object picking [in] fCursor: mouse position [in] nWidth, nHeight: Device Screen size [in] world transform matrix.
Definition: BaseCamera.cpp:703
Standard 2-dimensional vector.
Definition: ParaVector2.h:16
void SetMovementDrag(bool bEnable)
If true, then camera movement will slow to a stop otherwise movement is instant.
Definition: BaseCamera.cpp:615
void UpdateFrustum()
update the culling planes according to view and projection matrix on top of the global stack ...
Definition: BaseCamera.cpp:738
virtual void Reset()
Reset the camera's position back to the default.
Definition: BaseCamera.cpp:513
virtual int InstallFields(CAttributeClass *pClass, bool bOverride)
this class should be implemented if one wants to add new attribute.
Definition: BaseCamera.cpp:584
Specialized frustum shaped culling volume that has culling planes created from portals This isn't rea...
Definition: PortalFrustum.h:61
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: ParaMatrix4.h:23
Camera as a first person.
Definition: BaseCamera.h:26
Defines a plane in 3D space.
Definition: ParaPlane.h:23
void SetIsPerspectiveView(bool bIsPerspectiveView)
set whether we use perspective view or orthogonal view
Definition: BaseCamera.cpp:171
CCameraFrustum m_frustum_object
object view frustum, this is smaller than m_frustum; its far plane is set at fog end ...
Definition: BaseCamera.h:298
CCameraFrustum m_frustum
camera view frustum
Definition: BaseCamera.h:295
virtual const char * GetAttributeClassDescription()
a static string, describing the attribute class object
Definition: BaseCamera.h:85
virtual const char * GetAttributeClassName()
a static string, describing the attribute class object's name
Definition: BaseCamera.h:83
Third person view, allow rotation, character centered.
Definition: BaseCamera.h:17
CCameraFrustum * GetFrustum()
get the camera view frustum info
Definition: BaseCamera.h:149
bool IsShiftMoveSwitched()
whether the AD and QE key are switched for character movement.
Definition: BaseCamera.cpp:670
this value is used for the end of Camera follow modes.
Definition: BaseCamera.h:19
Plane & GetFogPlane()
test to see if any of the vertices are inside the fog plane
Definition: BaseCamera.h:168
Plane m_fog_plane
this is the fog end plane, it is plane with normal of the eye vector and distance of the fog range be...
Definition: BaseCamera.h:309
CCameraFrustum * GetObjectFrustum()
get the object view frustum info object view frustum is smaller than m_frustum; its far plane is set ...
Definition: BaseCamera.h:157
Tile Object have position and bounding rect and can usually be attached to quad-tree terrain tile...
Definition: TileObject.h:10
void SetNearPlane(float fDist)
change the near plane.
Definition: BaseCamera.cpp:217
Defines the base class of all scene elements:CBaseObject for Parallel World Engine.
Definition: BaseObject.h:230
: Third person view, disable rotation, character restricted to a rectangular, if character is reaches...
Definition: BaseCamera.h:22
void SetShiftMoveSwitched(bool bSwitched=false)
whether the AD and QE key are switched for character movement.
Definition: BaseCamera.cpp:675
void ConstrainToBoundary(DVector3 *pV)
Clamps pV to lie inside m_vMinBoundary & m_vMaxBoundary.
Definition: BaseCamera.cpp:459
void SetOrthoHeight(float fHeight)
change orthographic height of view volumn.
Definition: BaseCamera.cpp:187
CPortalFrustum * GetPortalFrustum()
get the camera view frustum info
Definition: BaseCamera.h:152
void CopyCameraParamsFrom(CBaseCamera *pFromCamera)
copy only basic parameters like projection and camera transforms, etc.
Definition: BaseCamera.cpp:100
the camera view culling frustum
Definition: CameraFrustum.h:10