Torque3D Documentation / _generateds / guiMeshRoadEditorCtrl.h

guiMeshRoadEditorCtrl.h

Engine/source/environment/editors/guiMeshRoadEditorCtrl.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 _GUIMESHROADEDITORCTRL_H_
 25#define _GUIMESHROADEDITORCTRL_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 _GIZMO_H_
 34#include "gui/worldEditor/gizmo.h"
 35#endif
 36#ifndef _MESHROAD_H_
 37#include "environment/meshRoad.h"
 38#endif
 39
 40class GameBase;
 41
 42class GuiMeshRoadEditorCtrl : public EditTSCtrl
 43{
 44   typedef EditTSCtrl Parent;
 45
 46   public:
 47   
 48      friend class GuiMeshRoadEditorUndoAction;
 49      
 50      String mSelectMeshRoadMode;
 51      String mAddMeshRoadMode;
 52      String mAddNodeMode;
 53      String mInsertPointMode;
 54      String mRemovePointMode;
 55      String mMovePointMode;
 56      String mScalePointMode;
 57      String mRotatePointMode;
 58
 59      GuiMeshRoadEditorCtrl();
 60      ~GuiMeshRoadEditorCtrl();
 61
 62      DECLARE_CONOBJECT(GuiMeshRoadEditorCtrl);
 63
 64      // SimObject
 65      bool onAdd();
 66      static void initPersistFields();
 67
 68      // GuiControl
 69      virtual void onSleep();
 70
 71      // EditTSCtrl      
 72      bool onKeyDown(const GuiEvent& event);
 73      void get3DCursor( GuiCursor *&cursor, bool &visible, const Gui3DMouseEvent &event_ );
 74      void on3DMouseDown(const Gui3DMouseEvent & event);
 75      void on3DMouseUp(const Gui3DMouseEvent & event);
 76      void on3DMouseMove(const Gui3DMouseEvent & event);
 77      void on3DMouseDragged(const Gui3DMouseEvent & event);
 78      void on3DMouseEnter(const Gui3DMouseEvent & event);
 79      void on3DMouseLeave(const Gui3DMouseEvent & event);
 80      void on3DRightMouseDown(const Gui3DMouseEvent & event);
 81      void on3DRightMouseUp(const Gui3DMouseEvent & event);
 82      void updateGuiInfo();      
 83      void renderScene(const RectI & updateRect);
 84
 85      // GuiRiverEditorCtrl      
 86      bool getStaticPos( const Gui3DMouseEvent & event, Point3F &tpos );
 87      void deleteSelectedNode();
 88      void deleteSelectedRoad( bool undoAble = true );
 89
 90      void setMode( String mode, bool sourceShortcut  );
 91      String getMode() { return mMode; }
 92
 93      void setSelectedRoad( MeshRoad *road );
 94      MeshRoad* getSelectedRoad() { return mSelRoad; };
 95      void setSelectedNode( S32 node );
 96
 97      F32 getNodeWidth();
 98      void setNodeWidth( F32 width );
 99
100      F32 getNodeDepth();
101      void setNodeDepth( F32 depth );
102      
103      Point3F getNodePosition();
104      void setNodePosition(const Point3F& pos);
105
106      VectorF getNodeNormal();
107      void setNodeNormal( const VectorF &normal );
108
109      void matchTerrainToRoad();
110
111   protected:
112      
113      enum { 
114         Top = 0, 
115         Bottom = 1, 
116         Side = 2,
117         SurfaceCount = 3
118      };
119
120      S32 _getNodeAtScreenPos( const MeshRoad *pRoad, const Point2I &posi );
121      void _drawSpline( MeshRoad *road, const ColorI &color );
122      void _drawControlNodes( MeshRoad *road, const ColorI &color );
123
124      void submitUndo( const UTF8 *name = "Action" );
125
126      GFXStateBlockRef mZDisableSB;
127      GFXStateBlockRef mZEnableSB;
128
129      bool mSavedDrag;
130      bool mIsDirty;
131
132      SimSet *mRoadSet;
133      S32 mSelNode;
134      S32 mHoverNode;
135      U32 mAddNodeIdx;
136      SimObjectPtr<MeshRoad> mSelRoad;      
137      SimObjectPtr<MeshRoad> mHoverRoad;
138
139      String mMode;
140
141      F32 mDefaultWidth;
142      F32 mDefaultDepth;
143      VectorF mDefaultNormal;
144
145      Point2I mNodeHalfSize;      
146
147      ColorI mHoverSplineColor;
148      ColorI mSelectedSplineColor;
149      ColorI mHoverNodeColor;
150
151      bool mHasCopied;
152   public:
153      
154      StringTableEntry mMaterialName[SurfaceCount];
155};
156
157class GuiMeshRoadEditorUndoAction : public UndoAction
158{
159   public:
160
161      GuiMeshRoadEditorUndoAction( const UTF8* actionName ) : UndoAction( actionName )
162      {
163      }
164
165      GuiMeshRoadEditorCtrl *mEditor;         
166
167      Vector<MeshRoadNode> mNodes;
168
169      SimObjectId mObjId;
170      F32 mMetersPerSegment;
171
172      virtual void undo();
173      virtual void redo() { undo(); }
174};
175
176#endif // _GUIMESHROADEDITORCTRL_H_
177
178
179
180