Torque3D Documentation / _generateds / guiRiverEditorCtrl.h

guiRiverEditorCtrl.h

Engine/source/environment/editors/guiRiverEditorCtrl.h

More...

Classes:

Public Defines

define
InvalidMousePoint() (-100,-100)

Detailed Description

Public Defines

InvalidMousePoint() (-100,-100)
  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 _GUIRIVEREDITORCTRL_H_
 25#define _GUIRIVEREDITORCTRL_H_
 26
 27#ifndef _EDITTSCTRL_H_
 28#include "gui/worldEditor/editTSCtrl.h"
 29#endif
 30#ifndef _UNDO_H_
 31#include "util/undo.h"
 32#endif
 33#ifndef _RIVER_H_
 34#include "environment/river.h"
 35#endif
 36#ifndef _GIZMO_H_
 37#include "gui/worldEditor/gizmo.h"
 38#endif
 39
 40struct ObjectRenderInst;
 41class SceneManager;
 42class SceneRenderState;
 43class BaseMatInstance;
 44
 45
 46class GuiRiverEditorCtrl : public EditTSCtrl
 47{
 48   typedef EditTSCtrl Parent;
 49
 50   public:
 51   
 52      friend class GuiRiverEditorUndoAction;
 53
 54      //static StringTableEntry smNormalMode;
 55      //static StringTableEntry smAddNodeMode;
 56      
 57      String mSelectRiverMode;
 58      String mAddRiverMode;
 59      String mAddNodeMode;
 60      String mInsertPointMode;
 61      String mRemovePointMode;
 62      String mMovePointMode;
 63      String mScalePointMode;
 64      String mRotatePointMode;
 65
 66      GuiRiverEditorCtrl();
 67      ~GuiRiverEditorCtrl();
 68
 69      DECLARE_CONOBJECT(GuiRiverEditorCtrl);
 70
 71      // SimObject
 72      bool onAdd();
 73      static void initPersistFields();
 74
 75      // GuiControl
 76      virtual void onSleep();
 77      virtual void onRender(Point2I offset, const RectI &updateRect);
 78
 79      // EditTSCtrl      
 80      bool onKeyDown(const GuiEvent& event);
 81      void get3DCursor( GuiCursor *&cursor, bool &visible, const Gui3DMouseEvent &event_ );
 82      void on3DMouseDown(const Gui3DMouseEvent & event);
 83      void on3DMouseUp(const Gui3DMouseEvent & event);
 84      void on3DMouseMove(const Gui3DMouseEvent & event);
 85      void on3DMouseDragged(const Gui3DMouseEvent & event);
 86      void on3DMouseEnter(const Gui3DMouseEvent & event);
 87      void on3DMouseLeave(const Gui3DMouseEvent & event);
 88      void on3DRightMouseDown(const Gui3DMouseEvent & event);
 89      void on3DRightMouseUp(const Gui3DMouseEvent & event);
 90      void updateGuiInfo();      
 91      void renderScene(const RectI & updateRect);
 92
 93      // GuiRiverEditorCtrl      
 94      bool getStaticPos( const Gui3DMouseEvent & event, Point3F &tpos );
 95      void deleteSelectedNode();
 96      void deleteSelectedRiver( bool undoAble = true );
 97      
 98      void setMode( String mode, bool sourceShortcut  );
 99      String getMode() { return mMode; }
100
101      //void setGizmoMode( Gizmo::Mode mode ) { mGizmo->setMode( mode ); }
102
103      void setSelectedRiver( River *river );
104      River* getSelectedRiver() { return mSelRiver; };
105      void setSelectedNode( S32 node );
106
107      F32 getNodeWidth();
108      void setNodeWidth( F32 width );
109
110      F32 getNodeDepth();
111      void setNodeDepth( F32 depth );
112
113      Point3F getNodePosition();
114      void setNodePosition(const Point3F& pos);
115
116      VectorF getNodeNormal();
117      void setNodeNormal( const VectorF &normal );
118
119   protected:
120
121      void _renderSelectedRiver( ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance *matInst );
122      void _prepRenderImage( SceneManager* sceneGraph, const SceneRenderState* sceneState );
123      void _drawRiverSpline( River *river, const ColorI &color );
124      void _drawRiverControlNodes( River *river, const ColorI &color );
125      void _process3DMouseDown( const Gui3DMouseEvent& event );
126
127      void submitUndo( const UTF8 *name = "Action" );
128
129      GFXStateBlockRef mZDisableSB;
130      GFXStateBlockRef mZEnableSB;
131
132      bool mSavedDrag;
133      bool mIsDirty;
134
135      SimSet *mRiverSet;
136      S32 mSelNode;
137      S32 mHoverNode;
138      U32 mAddNodeIdx;
139      SimObjectPtr<River> mSelRiver;      
140      SimObjectPtr<River> mHoverRiver;
141
142      String mMode;
143
144      F32 mDefaultWidth;
145      F32 mDefaultDepth;
146      VectorF mDefaultNormal;
147      S32 mInsertIdx;
148
149      F32 mStartHeight;
150      F32 mStartWidth;
151      S32 mStartX;
152      Point3F mStartWorld;
153
154      Point2I mNodeHalfSize;
155
156      //Gizmo mGizmo;
157
158      Gui3DMouseEvent mLastMouseEvent;
159
160      F32 mNodeSphereRadius;
161      ColorI mNodeSphereFillColor;
162      ColorI mNodeSphereLineColor;
163
164      ColorI mHoverSplineColor;
165      ColorI mSelectedSplineColor;
166      ColorI mHoverNodeColor;
167
168      #define InvalidMousePoint Point2I(-100,-100)
169      Point2I mStartDragMousePoint;
170
171      Point3F mStartDragNodePos;
172
173      //GuiCursor *mMoveNodeCursor;
174      //GuiCursor *mAddNodeCursor;
175      //GuiCursor *mInsertNodeCursor;
176      //GuiCursor *mResizeNodeCursor;
177};
178
179class GuiRiverEditorUndoAction : public UndoAction
180{
181   public:
182
183      GuiRiverEditorUndoAction( const UTF8* actionName ) : UndoAction( actionName )
184      {
185         mRiverEditor = NULL;
186         mObjId = 0;
187         mMetersPerSegment = 1.0f;
188         mSegmentsPerBatch = 10;
189      }
190
191      GuiRiverEditorCtrl *mRiverEditor;         
192
193      Vector<RiverNode> mNodes;
194
195      SimObjectId mObjId;
196      F32 mMetersPerSegment;
197      U32 mSegmentsPerBatch;
198
199      virtual void undo();
200      virtual void redo() { undo(); }
201};
202
203#endif
204
205
206
207