editTSCtrl.h

Engine/source/gui/worldEditor/editTSCtrl.h

More...

Classes:

Detailed Description

  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2012 GarageGames, LLC
  4//
  5// Permission is hereby granted, free of charge, to any person obtaining a copy
  6// of this software and associated documentation files (the "Software"), to
  7// deal in the Software without restriction, including without limitation the
  8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9// sell copies of the Software, and to permit persons to whom the Software is
 10// furnished to do so, subject to the following conditions:
 11//
 12// The above copyright notice and this permission notice shall be included in
 13// all copies or substantial portions of the Software.
 14//
 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21// IN THE SOFTWARE.
 22//-----------------------------------------------------------------------------
 23
 24#ifndef _EDITTSCTRL_H_
 25#define _EDITTSCTRL_H_
 26
 27#ifndef _GUITSCONTROL_H_
 28#include "gui/3d/guiTSControl.h"
 29#endif
 30#ifndef _GIZMO_H_
 31#include "gizmo.h"
 32#endif
 33
 34class TerrainBlock;
 35class MissionArea;
 36class Gizmo;
 37class EditManager;
 38struct ObjectRenderInst;
 39class SceneRenderState;
 40class BaseMatInstance;
 41
 42
 43class EditTSCtrl : public GuiTSCtrl
 44{
 45      typedef GuiTSCtrl Parent;
 46
 47   protected:
 48
 49      void make3DMouseEvent(Gui3DMouseEvent & gui3Devent, const GuiEvent &event);
 50
 51      // GuiControl
 52      virtual void getCursor(GuiCursor *&cursor, bool &showCursor, const GuiEvent &lastGuiEvent);
 53      virtual void onMouseUp(const GuiEvent & event);
 54      virtual void onMouseDown(const GuiEvent & event);
 55      virtual void onMouseMove(const GuiEvent & event);
 56      virtual void onMouseDragged(const GuiEvent & event);
 57      virtual void onMouseEnter(const GuiEvent & event);
 58      virtual void onMouseLeave(const GuiEvent & event);
 59      virtual void onRightMouseDown(const GuiEvent & event);
 60      virtual void onRightMouseUp(const GuiEvent & event);
 61      virtual void onRightMouseDragged(const GuiEvent & event);
 62      virtual void onMiddleMouseDown(const GuiEvent & event);
 63      virtual void onMiddleMouseUp(const GuiEvent & event);
 64      virtual void onMiddleMouseDragged(const GuiEvent & event);
 65      virtual bool onInputEvent(const InputEventInfo & event);
 66      virtual bool onMouseWheelUp(const GuiEvent &event);
 67      virtual bool onMouseWheelDown(const GuiEvent &event);
 68
 69
 70      virtual void updateGuiInfo() {};
 71      virtual void renderScene(const RectI &){};
 72      void renderMissionArea();
 73      virtual void renderCameraAxis();
 74      virtual void renderGrid();
 75
 76      // GuiTSCtrl
 77      void renderWorld(const RectI & updateRect);
 78
 79      void _renderScene(ObjectRenderInst*, SceneRenderState *state, BaseMatInstance*);
 80
 81      /// Zoom in/out in ortho views by "steps".
 82      void orthoZoom( F32 steps );
 83
 84   protected:
 85      enum DisplayType
 86      {
 87         DisplayTypeTop,
 88         DisplayTypeBottom,
 89         DisplayTypeFront,
 90         DisplayTypeBack,
 91         DisplayTypeLeft,
 92         DisplayTypeRight,
 93         DisplayTypePerspective,
 94         DisplayTypeIsometric,
 95      };
 96
 97      S32      mDisplayType;
 98      F32      mOrthoFOV;
 99      Point3F  mOrthoCamTrans;
100      EulerF   mIsoCamRot;
101      Point3F  mIsoCamRotCenter;
102      F32      mIsoCamAngle;
103      Point3F  mRawCamPos;
104      Point2I  mLastMousePos;
105      bool     mLastMouseClamping;
106
107      bool     mAllowBorderMove;
108      S32      mMouseMoveBorder;
109      F32      mMouseMoveSpeed;
110      U32      mLastBorderMoveTime;
111
112      Gui3DMouseEvent   mLastEvent;
113      bool              mLeftMouseDown;
114      bool              mRightMouseDown;
115      bool              mMiddleMouseDown;
116      bool              mMiddleMouseTriggered;
117      bool              mMouseLeft;
118
119      SimObjectPtr<Gizmo> mGizmo;
120      GizmoProfile *mGizmoProfile;
121
122   public:
123
124      EditTSCtrl();
125      ~EditTSCtrl();
126
127      // SimObject
128      bool onAdd();
129      void onRemove();
130
131      //
132      bool        mRenderMissionArea;
133      ColorI      mMissionAreaFillColor;
134      ColorI      mMissionAreaFrameColor;
135      F32         mMissionAreaHeightAdjust;
136
137      //
138      ColorI            mConsoleFrameColor;
139      ColorI            mConsoleFillColor;
140      S32               mConsoleSphereLevel;
141      S32               mConsoleCircleSegments;
142      S32               mConsoleLineWidth;
143
144      static void initPersistFields();
145      static void consoleInit();
146
147      //
148      bool              mConsoleRendering;
149      bool              mRightMousePassThru;
150      bool              mMiddleMousePassThru;
151
152      // all editors will share a camera
153      static Point3F    smCamPos;
154      static MatrixF    smCamMatrix;
155      static bool       smCamOrtho;
156      static F32        smCamNearPlane;
157      static F32        smCamFOV;
158      static F32        smVisibleDistanceScale;
159
160      static U32        smSceneBoundsMask;
161      static Point3F    smMinSceneBounds;
162
163      bool              mRenderGridPlane;
164      ColorI            mGridPlaneColor;
165      F32               mGridPlaneSize;
166      F32               mGridPlaneSizePixelBias;
167      S32               mGridPlaneMinorTicks;
168      ColorI            mGridPlaneMinorTickColor;
169      ColorI            mGridPlaneOriginColor;
170
171      GFXStateBlockRef  mBlendSB;
172
173      // GuiTSCtrl
174      virtual bool getCameraTransform(MatrixF* cameraMatrix);
175      virtual void computeSceneBounds(Box3F& bounds);
176      bool processCameraQuery(CameraQuery * query);
177
178      // guiControl
179      virtual void onRender(Point2I offset, const RectI &updateRect);
180      virtual void on3DMouseUp(const Gui3DMouseEvent &){};
181      virtual void on3DMouseDown(const Gui3DMouseEvent &){};
182      virtual void on3DMouseMove(const Gui3DMouseEvent &){};
183      virtual void on3DMouseDragged(const Gui3DMouseEvent &){};
184      virtual void on3DMouseEnter(const Gui3DMouseEvent &){};
185      virtual void on3DMouseLeave(const Gui3DMouseEvent &){};
186      virtual void on3DRightMouseDown(const Gui3DMouseEvent &){};
187      virtual void on3DRightMouseUp(const Gui3DMouseEvent &){};
188      virtual void on3DRightMouseDragged(const Gui3DMouseEvent &){};
189      virtual void on3DMouseWheelUp(const Gui3DMouseEvent &){};
190      virtual void on3DMouseWheelDown(const Gui3DMouseEvent &){};
191      virtual void get3DCursor(GuiCursor *&cursor, bool &visible, const Gui3DMouseEvent &);
192
193      virtual bool isMiddleMouseDown() {return mMiddleMouseDown;}
194
195      virtual bool resize(const Point2I& newPosition, const Point2I& newExtent);
196
197      S32 getDisplayType() const {return mDisplayType;}
198      virtual void setDisplayType(S32 type);
199      
200      /// Return true if the current view is an ortho projection along one of the world axes.
201      bool isOrthoDisplayType() const { return ( mDisplayType != DisplayTypePerspective && mDisplayType != DisplayTypeIsometric ); }
202      
203      F32 getOrthoFOV() const { return mOrthoFOV; }
204      void setOrthoFOV( F32 fov ) { mOrthoFOV = fov; }
205
206      virtual TerrainBlock* getActiveTerrain();
207
208      virtual void calcOrthoCamOffset(F32 mousex, F32 mousey, U8 modifier=0);
209
210      Gizmo* getGizmo() { return mGizmo; }
211
212      /// Set flags or other Gizmo state appropriate for the current situation.
213      /// For example derived classes may override this to disable certain
214      /// axes of modes of manipulation.
215      virtual void updateGizmo();
216
217      DECLARE_CONOBJECT(EditTSCtrl);
218      DECLARE_CATEGORY( "Gui Editor" );
219};
220
221#endif // _EDITTSCTRL_H_
222