123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220 |
- //-----------------------------------------------------------------------------
- // Copyright (c) 2012 GarageGames, LLC
- //
- // Permission is hereby granted, free of charge, to any person obtaining a copy
- // of this software and associated documentation files (the "Software"), to
- // deal in the Software without restriction, including without limitation the
- // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- // sell copies of the Software, and to permit persons to whom the Software is
- // furnished to do so, subject to the following conditions:
- //
- // The above copyright notice and this permission notice shall be included in
- // all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- // IN THE SOFTWARE.
- //-----------------------------------------------------------------------------
- #ifndef _EDITTSCTRL_H_
- #define _EDITTSCTRL_H_
- #ifndef _GUITSCONTROL_H_
- #include "gui/3d/guiTSControl.h"
- #endif
- #ifndef _GIZMO_H_
- #include "gizmo.h"
- #endif
- class TerrainBlock;
- class MissionArea;
- class Gizmo;
- class EditManager;
- struct ObjectRenderInst;
- class SceneRenderState;
- class BaseMatInstance;
- class EditTSCtrl : public GuiTSCtrl
- {
- typedef GuiTSCtrl Parent;
- protected:
- void make3DMouseEvent(Gui3DMouseEvent & gui3Devent, const GuiEvent &event);
- // GuiControl
- virtual void getCursor(GuiCursor *&cursor, bool &showCursor, const GuiEvent &lastGuiEvent);
- virtual void onMouseUp(const GuiEvent & event);
- virtual void onMouseDown(const GuiEvent & event);
- virtual void onMouseMove(const GuiEvent & event);
- virtual void onMouseDragged(const GuiEvent & event);
- virtual void onMouseEnter(const GuiEvent & event);
- virtual void onMouseLeave(const GuiEvent & event);
- virtual void onRightMouseDown(const GuiEvent & event);
- virtual void onRightMouseUp(const GuiEvent & event);
- virtual void onRightMouseDragged(const GuiEvent & event);
- virtual void onMiddleMouseDown(const GuiEvent & event);
- virtual void onMiddleMouseUp(const GuiEvent & event);
- virtual void onMiddleMouseDragged(const GuiEvent & event);
- virtual bool onInputEvent(const InputEventInfo & event);
- virtual bool onMouseWheelUp(const GuiEvent &event);
- virtual bool onMouseWheelDown(const GuiEvent &event);
- virtual void updateGuiInfo() {};
- virtual void renderScene(const RectI &){};
- void renderMissionArea();
- virtual void renderCameraAxis();
- virtual void renderGrid();
- // GuiTSCtrl
- void renderWorld(const RectI & updateRect);
- void _renderScene(ObjectRenderInst*, SceneRenderState *state, BaseMatInstance*);
- /// Zoom in/out in ortho views by "steps".
- void orthoZoom( F32 steps );
- protected:
- enum DisplayType
- {
- DisplayTypeTop,
- DisplayTypeBottom,
- DisplayTypeFront,
- DisplayTypeBack,
- DisplayTypeLeft,
- DisplayTypeRight,
- DisplayTypePerspective,
- DisplayTypeIsometric,
- };
- S32 mDisplayType;
- F32 mOrthoFOV;
- Point3F mOrthoCamTrans;
- EulerF mIsoCamRot;
- Point3F mIsoCamRotCenter;
- F32 mIsoCamAngle;
- Point3F mRawCamPos;
- Point2I mLastMousePos;
- bool mLastMouseClamping;
- bool mAllowBorderMove;
- S32 mMouseMoveBorder;
- F32 mMouseMoveSpeed;
- U32 mLastBorderMoveTime;
- Gui3DMouseEvent mLastEvent;
- bool mLeftMouseDown;
- bool mRightMouseDown;
- bool mMiddleMouseDown;
- bool mMiddleMouseTriggered;
- bool mMouseLeft;
- SimObjectPtr<Gizmo> mGizmo;
- GizmoProfile *mGizmoProfile;
- public:
- EditTSCtrl();
- ~EditTSCtrl();
- // SimObject
- bool onAdd();
- void onRemove();
- //
- bool mRenderMissionArea;
- ColorI mMissionAreaFillColor;
- ColorI mMissionAreaFrameColor;
- F32 mMissionAreaHeightAdjust;
- //
- ColorI mConsoleFrameColor;
- ColorI mConsoleFillColor;
- S32 mConsoleSphereLevel;
- S32 mConsoleCircleSegments;
- S32 mConsoleLineWidth;
- static void initPersistFields();
- static void consoleInit();
- //
- bool mConsoleRendering;
- bool mRightMousePassThru;
- bool mMiddleMousePassThru;
- // all editors will share a camera
- static Point3F smCamPos;
- static MatrixF smCamMatrix;
- static bool smCamOrtho;
- static F32 smCamNearPlane;
- static F32 smCamFOV;
- static F32 smVisibleDistanceScale;
- static U32 smSceneBoundsMask;
- static Point3F smMinSceneBounds;
- bool mRenderGridPlane;
- ColorI mGridPlaneColor;
- F32 mGridPlaneSize;
- F32 mGridPlaneSizePixelBias;
- S32 mGridPlaneMinorTicks;
- ColorI mGridPlaneMinorTickColor;
- ColorI mGridPlaneOriginColor;
- GFXStateBlockRef mBlendSB;
- // GuiTSCtrl
- virtual bool getCameraTransform(MatrixF* cameraMatrix);
- virtual void computeSceneBounds(Box3F& bounds);
- bool processCameraQuery(CameraQuery * query);
- // guiControl
- virtual void onRender(Point2I offset, const RectI &updateRect);
- virtual void on3DMouseUp(const Gui3DMouseEvent &){};
- virtual void on3DMouseDown(const Gui3DMouseEvent &){};
- virtual void on3DMouseMove(const Gui3DMouseEvent &){};
- virtual void on3DMouseDragged(const Gui3DMouseEvent &){};
- virtual void on3DMouseEnter(const Gui3DMouseEvent &){};
- virtual void on3DMouseLeave(const Gui3DMouseEvent &){};
- virtual void on3DRightMouseDown(const Gui3DMouseEvent &){};
- virtual void on3DRightMouseUp(const Gui3DMouseEvent &){};
- virtual void on3DRightMouseDragged(const Gui3DMouseEvent &){};
- virtual void on3DMouseWheelUp(const Gui3DMouseEvent &){};
- virtual void on3DMouseWheelDown(const Gui3DMouseEvent &){};
- virtual void get3DCursor(GuiCursor *&cursor, bool &visible, const Gui3DMouseEvent &);
- virtual bool isMiddleMouseDown() {return mMiddleMouseDown;}
- virtual bool resize(const Point2I& newPosition, const Point2I& newExtent);
- S32 getDisplayType() const {return mDisplayType;}
- virtual void setDisplayType(S32 type);
-
- /// Return true if the current view is an ortho projection along one of the world axes.
- bool isOrthoDisplayType() const { return ( mDisplayType != DisplayTypePerspective && mDisplayType != DisplayTypeIsometric ); }
-
- F32 getOrthoFOV() const { return mOrthoFOV; }
- void setOrthoFOV( F32 fov ) { mOrthoFOV = fov; }
- virtual TerrainBlock* getActiveTerrain();
- virtual void calcOrthoCamOffset(F32 mousex, F32 mousey, U8 modifier=0);
- Gizmo* getGizmo() { return mGizmo; }
- /// Set flags or other Gizmo state appropriate for the current situation.
- /// For example derived classes may override this to disable certain
- /// axes of modes of manipulation.
- virtual void updateGizmo();
- DECLARE_CONOBJECT(EditTSCtrl);
- DECLARE_CATEGORY( "Gui Editor" );
- };
- #endif // _EDITTSCTRL_H_
|