Torque3D Documentation / _generateds / worldEditorSelection.h

worldEditorSelection.h

Engine/source/gui/worldEditor/worldEditorSelection.h

More...

Classes:

class

A selection set in the World Editor.

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 _WORLDEDITORSELECTION_H_
 25#define _WORLDEDITORSELECTION_H_
 26
 27#ifndef _SIMPERSISTSET_H_
 28   #include "console/simPersistSet.h"
 29#endif
 30#ifndef _MPOINT3_H_
 31   #include "math/mPoint3.h"
 32#endif
 33#ifndef _MMATRIX_H_
 34   #include "math/mMatrix.h"
 35#endif
 36#ifndef _TVECTOR_H_
 37   #include "core/util/tVector.h"
 38#endif
 39
 40
 41class SceneObject;
 42
 43
 44/// A selection set in the World Editor.
 45///
 46/// Selections are by default transient objects, but can be made persistent and
 47/// saved to disk.
 48///
 49class WorldEditorSelection : public SimPersistSet
 50{
 51   public:
 52   
 53      typedef SimPersistSet Parent;
 54
 55   private:
 56      
 57      /// The averaged positions of all objects in the selection.
 58      Point3F mCentroid;
 59      
 60      /// The center point of the bounding box around the selection.
 61      Point3F mBoxCentroid;
 62      
 63      /// The bounding box around the selection.
 64      Box3F mBoxBounds;
 65      
 66      ///
 67      MatrixF mTransform;
 68      
 69      /// If false, the selection has been modified and bounding box values
 70      /// and center points need to be recomputed.
 71      bool mCentroidValid;
 72      
 73      /// If true, the selection contains one or more objects that have
 74      /// global bounds enabled.
 75      bool mContainsGlobalBounds;
 76      
 77      bool mAutoSelect;
 78      Point3F mPrevCentroid;
 79
 80      void updateCentroid();
 81
 82   public:
 83
 84      WorldEditorSelection();
 85      ~WorldEditorSelection();
 86
 87      /// Return true if "object" is contained in the selection.
 88      bool objInSet( SimObject* object );
 89
 90      void storeCurrentCentroid() { mPrevCentroid = getCentroid(); }
 91      bool hasCentroidChanged() { return (mPrevCentroid != getCentroid()); }
 92
 93      bool containsGlobalBounds();
 94      
 95      /// @name Transforms
 96      ///
 97      /// Note that these methods do not update transforms of client objects.
 98      /// Use WorldEditor::updateClientTransforms to do that.
 99      ///
100      /// @{
101
102      /// 
103      const Point3F& getCentroid();
104      const Point3F& getBoxCentroid();
105      const Box3F& getBoxBounds();
106      Point3F getBoxBottomCenter();
107      const MatrixF& getTransform();
108      
109      //
110      void offset(const Point3F& delta, F32 gridSnap = 0.f );
111      void setPosition(const Point3F & pos);
112      F32 _snapFloat(const F32 &val, const F32 &snap) const;
113      void setCentroidPosition(bool useBoxCenter, const Point3F & pos);
114
115      void orient(const MatrixF &, const Point3F &);
116      void rotate(const EulerF &);
117      void rotate(const EulerF &, const Point3F &);
118      void setRotate(const EulerF &);
119
120      void scale(const VectorF &);
121      void scale(const VectorF &, const Point3F &);
122      void setScale(const VectorF &);
123      void setScale(const VectorF &, const Point3F &);
124
125      void addSize(const VectorF &);
126      void setSize(const VectorF &);
127
128      /// @}
129
130      /// Enable collision for all objects in the selection.
131      void enableCollision();
132      
133      /// Disable collision for all objects in the selection.
134      void disableCollision();
135      
136      //
137      void setAutoSelect(bool b) { mAutoSelect = b; }
138      void invalidateCentroid() { mCentroidValid = false; }
139      
140      // SimSet.
141      virtual void addObject( SimObject* );
142      virtual void removeObject( SimObject* );
143      virtual void setCanSave( bool value );
144      
145      static void initPersistFields();
146                  
147      DECLARE_CONOBJECT( WorldEditorSelection );
148      DECLARE_CATEGORY( "Editor World" );
149      DECLARE_DESCRIPTION( "A selection set for the World Editor." );
150};
151
152#endif // !_WORLDEDITORSELECTION_H_
153