00001
00002
00003
00004
00005 #ifndef OglGui_Camera3DControlEx_h
00006 #define OglGui_Camera3DControlEx_h
00007
00008 #ifndef OglGui_Camera3DXYZ_h
00009 #include "OglGui/Camera3DXYZ.h"
00010 #endif
00011
00012 #ifndef OglGui_Camera3DMoveZ_h
00013 #include "OglGui/Camera3DMoveZ.h"
00014 #endif
00015
00016 #ifndef OglGui_Camera3DAnchorControl_h
00017 #include "OglGui/Camera3DAnchorControl.h"
00018 #endif
00019
00020 namespace OglGui {
00021
00022 class Camera3DControlEx : public Window
00023 {
00024 public:
00025 Camera3DControlEx(Window* parent, int x, int y, int w, int h,
00026 Window* target=0) :
00027 Window(parent, x, y, w, h)
00028 {
00029 Init(w, h, target);
00030 }
00031
00032 Window* TargetWnd() { return mTarget; }
00033 Camera3DXYZ* CameraXYZ() { return mCamXYZ; }
00034 Camera3DMoveZ* CameraMoveZ() { return mCamZ; }
00035 Camera3DAnchorControl* CameraAnchor() { return mCamAnchor; }
00036
00037 void MinMaxX(float minX, float maxX)
00038 {
00039 mMinX = minX;
00040 mMaxX = maxX;
00041 }
00042 void MinMaxY(float minY, float maxY)
00043 {
00044 mMinY = minY;
00045 mMaxY = maxY;
00046 }
00047 void MinMaxZ(float minZ, float maxZ)
00048 {
00049 mMinZ = minZ;
00050 mMaxZ = maxZ;
00051 }
00052
00053 void ClampCamera()
00054 {
00055 if (!mTarget)
00056 return;
00057 SCENE3D* cam = (SCENE3D*) mTarget->GetOGLWND()->sceneInfo;
00058 if (cam->camX < mMinX) cam->camX = mMinX;
00059 if (cam->camX > mMaxX) cam->camX = mMaxX;
00060 if (cam->camY < mMinY) cam->camY = mMinY;
00061 if (cam->camY > mMaxY) cam->camY = mMaxY;
00062 if (cam->camZ < mMinZ) cam->camZ = mMinZ;
00063 if (cam->camZ > mMaxZ) cam->camZ = mMaxZ;
00064 }
00065
00066 virtual void DisplayFunc()
00067 {
00068 Window::DisplayFunc();
00069 ClampCamera();
00070 }
00071
00072 static void PreferredSize(int& w, int& h)
00073 {
00074 Camera3DAnchorControl::PreferredSize(w,h);
00075 w += h + 28;
00076 }
00077
00078
00079 private:
00080 void Init(int w, int h, Window* target)
00081 {
00082 int prefW, prefH;
00083
00084 PreferredSize(prefW, prefH);
00085 SetDimensions(prefW, prefH);
00086 mTarget = target;
00087 SetBorderType(BEV_ETCHED);
00088 mCamXYZ = new Camera3DXYZ(this, 4, 4, prefH-8, prefH-8, target);
00089 mCamZ = new Camera3DMoveZ(this, prefH, 4, 20, prefH-8, target);
00090 new Camera3DAnchorControl(this, prefH+24, 4, prefW-prefH-28, prefH-8, target);
00091
00092 mCamXYZ->SetRoundness(6, 6, 6, 6);
00093 mCamXYZ->SetBorderFillShaded();
00094
00095 mCamZ->SetRoundness(6, 6, 6, 6);
00096 mCamZ->SetBorderFillShaded();
00097 MinMaxX(-10000,10000);
00098 MinMaxY(-10000,10000);
00099 MinMaxZ(-10000,10000);
00100 ScaleChildren(0,1);
00101 SetAllowChildScaling(false);
00102 SetDimensions(w, h);
00103 }
00104
00105 Window* mTarget;
00106 Camera3DXYZ* mCamXYZ;
00107 Camera3DMoveZ* mCamZ;
00108 Camera3DAnchorControl* mCamAnchor;
00109
00110 float mMinX, mMaxX;
00111 float mMinY, mMaxY;
00112 float mMinZ, mMaxZ;
00113 };
00114 }
00115
00116 #endif