Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

Camera3DMoveZ.h

Go to the documentation of this file.
00001 /*
00002 12345678901234567890123456789012345678901234567890123456789012345678901234567890
00003 */
00004 // RvB: Should be renamed in Camera3DFwBw
00005 
00006 #ifndef OglGui_Camera3DMoveZ_h
00007 #define OglGui_Camera3DMoveZ_h
00008 
00009 #ifndef OglGui_Window_h
00010 #include "OglGui/Window.h"
00011 #endif
00012 
00013 namespace OglGui
00014 {
00015 class Camera3DMoveZ : public Window
00016 {
00017 public:
00018     Camera3DMoveZ(Window* parent, int x, int y, int w, int h, Window* target=0):
00019         Window(parent, x, y, w, h)
00020     {
00021         Init(w, h, target);
00022     }
00023 
00024     virtual void DisplayFunc()
00025     {
00026         Window::DisplayFunc();
00027 
00028         DrawLine(0, H()/2, W(), H()/2);
00029 
00030         if (!(mTarget && mPropagateMouse))
00031             return;
00032 
00033         SCENE3D* cam   = (SCENE3D *) mTarget->GetOGLWND()->sceneInfo;
00034         float step = (mMouseY-H()/2);
00035 
00036         step *= 2 * mStepFactor * (abs(step) < 15 ? 1.f : abs(step)/15.f);
00037 
00038         cam->camX += step * cam->tX;
00039         cam->camY += step * cam->tY;
00040         cam->camZ += step * cam->tZ;
00041         if (!mTextFeedBack)
00042             return;
00043         oglSys.PosColPrintf(mOglWnd, 0, mMouseY, oglRED, "Z%s",
00044                             step > 0 ? "+" : step < 0 ? "-" : "");
00045     }
00046 
00047     virtual void MouseFunc(int msg, int btn, int state, int x, int y)
00048     {
00049         mMouseY = y;
00050 
00051         if (msg==oglMouseDown && mTarget)
00052         {
00053             mPropagateMouse = true;
00054             oglSys.SetAlwaysDraw(mOglWnd, 1);
00055         }
00056         if (!state || !mTarget)
00057         {
00058             mPropagateMouse = false;
00059             oglSys.SetAlwaysDraw(mOglWnd, 0);
00060         }
00061     }
00062 
00063     virtual void KeyboardFunc(int c, int state)
00064     {
00065         if (mTarget)
00066             mTarget->KeyboardFunc(c, state);
00067         Window::KeyboardFunc(c, state);
00068     }
00069 
00070 
00071 private:
00072     void Init(int w, int h, Window* target)
00073     {
00074         mTarget = target;
00075 
00076         SetBorderType(BEV_LINE);
00077 
00078         mTextFeedBack = true;
00079         mPropagateMouse = false;
00080         mStepFactor = 0.001f;
00081     }
00082 
00083     Window* mTarget;
00084 
00085     bool    mTextFeedBack;
00086     bool    mPropagateMouse;
00087     int     mMouseY;
00088 
00089     float   mStepFactor;
00090 };
00091 } // nasmespace OglGui
00092 
00093 #endif

Generated on Fri Mar 19 09:31:33 2010 for ImpalaSrc by  doxygen 1.5.1