00001
00002
00003
00004
00005
00006 #ifndef __ARCBALL_CAMERA_H__
00007 #define __ARCBALL_CAMERA_H__
00008
00009 #include "cglib/vector3.h"
00010 #include "cglib/point3.h"
00011 #include "cglib/matrix4x4.h"
00012
00013 class ArcballCamera
00014 {
00015 public:
00016
00017 ArcballCamera();
00018
00019 typedef enum { NONE, LEFT, MIDDLE, RIGHT } Button;
00020
00021
00022
00023
00024
00025 void SetDimensions(int w, int h);
00026 void SetViewport(int x, int y, int w, int h);
00027 void SetPerspective(float fovy);
00028
00029
00030 void MouseClick(Button button, int x, int y);
00031 void MouseDrag(int x, int y);
00032 void MouseRelease(int x, int y);
00033
00034
00035
00036 void ApplyViewport() const;
00037 void ApplyPerspective() const;
00038 void ApplyModelview();
00039
00040
00041 void SetCenter(const Point3 & center);
00042 void SetRotation(const Matrix4x4 & rotation);
00043 void SetDistance(const float distance);
00044
00045
00046 Point3 GetCenter() const { return mCurrentCenter; }
00047 Matrix4x4 GetRotation() const { return mCurrentRot; }
00048 float GetDistance() const { return mCurrentDistance; }
00049
00050
00051 int mDimensions[2];
00052 int mStartClick[2];
00053 Button mButtonState;
00054
00055
00056 Matrix4x4 mStartRot;
00057 Matrix4x4 mCurrentRot;
00058
00059
00060 float mPerspective[2];
00061 int mViewport[4];
00062 Point3 mStartCenter;
00063 Point3 mCurrentCenter;
00064
00065
00066 float mStartDistance;
00067 float mCurrentDistance;
00068
00069 void ArcBallRotation(int x, int y);
00070 void PlaneTranslation(int x, int y);
00071 void DistanceZoom(int x, int y);
00072 };
00073
00074 #endif