Torque3D Documentation / _generateds / forestBrushTool.h

forestBrushTool.h

Engine/source/forest/editor/forestBrushTool.h

More...

Classes:

Public Typedefs

Public Functions

Detailed Description

Public Typedefs

typedef ForestBrushTool::BrushMode ForestBrushMode 

Public Functions

DefineEnumType(ForestBrushMode )

  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 _FOREST_EDITOR_BRUSH_H_
 25#define _FOREST_EDITOR_BRUSH_H_
 26
 27#ifndef _FOREST_EDITOR_TOOL_H_
 28#include "forest/editor/forestTool.h"
 29#endif
 30#ifndef _FORESTITEM_H_
 31#include "forest/forestItem.h"
 32#endif
 33#ifndef _FOREST_EDITOR_BRUSHELEMENT_H_
 34#include "forest/editor/forestBrushElement.h"
 35#endif
 36#ifndef _COLOR_H_
 37#include "core/color.h"
 38#endif
 39
 40
 41
 42class Forest;
 43class ForestUndoAction;
 44
 45class ForestBrushTool : public ForestTool
 46{
 47   typedef ForestTool Parent;
 48
 49   friend class ForestBrushToolEvent;
 50
 51public:
 52
 53   enum BrushMode
 54   {
 55      Paint = 0,
 56      Erase,
 57      EraseSelected
 58   };
 59
 60   ForestBrushTool();
 61   virtual ~ForestBrushTool();
 62
 63   // SimObject
 64   DECLARE_CONOBJECT( ForestBrushTool );
 65   static void initPersistFields();
 66   virtual bool onAdd();
 67   virtual void onRemove();
 68
 69   // ForestTool
 70   virtual void on3DMouseDown( const Gui3DMouseEvent &evt );
 71   virtual void on3DMouseUp( const Gui3DMouseEvent &evt );
 72   virtual void on3DMouseMove( const Gui3DMouseEvent &evt );
 73   virtual void on3DMouseDragged( const Gui3DMouseEvent &evt );
 74   virtual bool onMouseWheel(const GuiEvent &evt );   
 75   virtual void onRender3D();
 76   virtual void onRender2D();
 77   virtual void onActivated( const Gui3DMouseEvent &lastEvent );
 78   virtual void onDeactivated();
 79   virtual bool updateGuiInfo();
 80
 81   // ForestBrushTool
 82   void setSize( F32 val );
 83   void setPressure( F32 val );
 84   void setHardness( F32 val );
 85   void collectElements() { _collectElements(); }
 86   bool getGroundAt( const Point3F &worldPt, F32 *zValueOut, VectorF *normalOut );
 87
 88protected:      
 89
 90   void _onStroke();
 91   virtual void _action( const Point3F &point );
 92   virtual void _paint( const Point3F &point );
 93   virtual void _erase( const Point3F &point );
 94      
 95   bool _updateBrushPoint( const Gui3DMouseEvent &event_ );   
 96   virtual void _collectElements();
 97
 98   static bool protectedSetSize( void *object, const char *index, const char *data );
 99   static bool protectedSetPressure( void *object, const char *index, const char *data );
100   static bool protectedSetHardness( void *object, const char *index, const char *data );
101
102protected:
103
104   MRandom mRandom;
105
106   /// We treat this as a radius.
107   F32 mSize;
108   F32 mPressure;
109   F32 mHardness;
110
111   U32 mMode;
112
113   ColorI mColor;
114
115   Vector<ForestBrushElement*> mElements;
116   Vector<ForestItemData*> mDatablocks;
117
118   ///
119   bool mBrushDown;
120
121   ///
122   bool mDrawBrush;
123
124   ///
125   U32 mStrokeEvent;
126
127   ///
128   Point3F mLastBrushPoint;
129   Point3F mLastBrushNormal;
130
131   /// The creation action we're actively filling.
132   ForestUndoAction *mCurrAction;  
133};
134
135typedef ForestBrushTool::BrushMode ForestBrushMode;
136DefineEnumType( ForestBrushMode );
137
138
139class ForestBrushToolEvent : public SimEvent
140{
141public:
142
143   void process( SimObject *object )
144   {
145      ((ForestBrushTool*)object)->_onStroke();
146   }
147};
148
149
150#endif // _FOREST_EDITOR_BRUSH_H_
151
152
153
154