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