Torque3D Documentation / _generateds / guiRoadEditorCtrl.h

guiRoadEditorCtrl.h

Engine/source/environment/editors/guiRoadEditorCtrl.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 _GUIROADEDITORCTRL_H_
 25#define _GUIROADEDITORCTRL_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 _DECALROAD_H_
 34#include "environment/decalRoad.h"
 35#endif
 36
 37class GameBase;
 38class DecalRoad;
 39
 40
 41class GuiRoadEditorCtrl : public EditTSCtrl
 42{
 43   typedef EditTSCtrl Parent;
 44
 45   public:
 46   
 47      friend class GuiRoadEditorUndoAction;
 48      
 49      String mSelectRoadMode;
 50      String mAddRoadMode;
 51      String mAddNodeMode;
 52      String mInsertPointMode;
 53      String mRemovePointMode;
 54      String mMovePointMode;
 55      String mScalePointMode;
 56
 57      GuiRoadEditorCtrl();
 58      ~GuiRoadEditorCtrl();
 59
 60      DECLARE_CONOBJECT(GuiRoadEditorCtrl);
 61
 62      // SimObject
 63      bool onAdd();
 64      static void initPersistFields();
 65
 66      // GuiControl
 67      virtual void onSleep();
 68      virtual void onRender(Point2I offset, const RectI &updateRect);
 69
 70      // EditTSCtrl      
 71      bool onKeyDown(const GuiEvent& event);
 72      void get3DCursor( GuiCursor *&cursor, bool &visible, const Gui3DMouseEvent &event_ );
 73      void on3DMouseDown(const Gui3DMouseEvent & event);
 74      void on3DMouseUp(const Gui3DMouseEvent & event);
 75      void on3DMouseMove(const Gui3DMouseEvent & event);
 76      void on3DMouseDragged(const Gui3DMouseEvent & event);
 77      void on3DMouseEnter(const Gui3DMouseEvent & event);
 78      void on3DMouseLeave(const Gui3DMouseEvent & event);
 79      void on3DRightMouseDown(const Gui3DMouseEvent & event);
 80      void on3DRightMouseUp(const Gui3DMouseEvent & event);
 81      void updateGuiInfo();      
 82      void renderScene(const RectI & updateRect);
 83      void renderGui(Point2I offset, const RectI &updateRect);
 84
 85      bool getTerrainPos( const Gui3DMouseEvent & event, Point3F &tpos );
 86      void deleteSelectedNode();
 87      void deleteSelectedRoad( bool undoAble = true );
 88      
 89      void setMode( String mode, bool sourceShortcut );
 90      String getMode() { return mMode; }
 91
 92      void setSelectedRoad( DecalRoad *road );
 93      DecalRoad* getSelectedRoad() { return mSelRoad; };
 94      void setSelectedNode( S32 node );
 95      S32 getSelectedNode() { return mSelNode; };
 96
 97      F32 getNodeWidth();
 98      void setNodeWidth( F32 width );
 99
100      Point3F getNodePosition();
101      void setNodePosition(const Point3F& pos);
102
103      void setTextureFile( StringTableEntry file );
104   
105   public:
106
107      StringTableEntry mMaterialAssetId;
108      AssetPtr<MaterialAsset> mMaterialAsset;
109   protected:
110
111      void _drawRoadSpline( DecalRoad *road, const ColorI &color );
112      void _drawRoadControlNodes( DecalRoad *road, const ColorI &color );
113
114      void submitUndo( const UTF8 *name );
115
116      bool mSavedDrag;
117      bool mIsDirty;
118
119      SimSet *mRoadSet;
120      S32 mSelNode;
121      S32 mHoverNode;
122      U32 mAddNodeIdx;
123      SimObjectPtr<DecalRoad> mSelRoad;      
124      SimObjectPtr<DecalRoad> mHoverRoad;
125
126      ColorI mHoverSplineColor;
127      ColorI mSelectedSplineColor;
128      ColorI mHoverNodeColor;
129
130      String mMode;
131
132      F32 mDefaultWidth;
133      S32 mInsertIdx;
134
135      F32 mStartWidth;
136      S32 mStartX;
137      Point3F mStartWorld;
138
139      Point2I mNodeHalfSize;
140
141      // StateBlock for rendering road splines.
142      GFXStateBlockRef mZDisableSB;
143};
144
145class GuiRoadEditorUndoAction : public UndoAction
146{
147   public:
148
149      GuiRoadEditorUndoAction( const UTF8* actionName ) : UndoAction( actionName )
150      {
151         mRoadEditor = NULL;
152         mObjId = 0;
153         mBreakAngle = 3.0f;
154         mSegmentsPerBatch = 0;
155         mTextureLength = 0.0f;
156      }
157
158      GuiRoadEditorCtrl *mRoadEditor;
159
160      Vector<RoadNode> mNodes;
161
162      SimObjectId mObjId;
163      StringTableEntry mMaterialAssetId;
164      F32 mBreakAngle;
165      U32 mSegmentsPerBatch;
166      F32 mTextureLength;
167
168      virtual void undo();
169      virtual void redo() { undo(); }
170};
171
172#endif
173
174
175
176