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      void setCentroidPosition(bool useBoxCenter, const Point3F & pos);
113
114      void orient(const MatrixF &, const Point3F &);
115      void rotate(const EulerF &);
116      void rotate(const EulerF &, const Point3F &);
117      void setRotate(const EulerF &);
118
119      void scale(const VectorF &);
120      void scale(const VectorF &, const Point3F &);
121      void setScale(const VectorF &);
122      void setScale(const VectorF &, const Point3F &);
123
124      void addSize(const VectorF &);
125      void setSize(const VectorF &);
126
127      /// @}
128
129      /// Enable collision for all objects in the selection.
130      void enableCollision();
131      
132      /// Disable collision for all objects in the selection.
133      void disableCollision();
134      
135      //
136      void setAutoSelect(bool b) { mAutoSelect = b; }
137      void invalidateCentroid() { mCentroidValid = false; }
138      
139      // SimSet.
140      virtual void addObject( SimObject* );
141      virtual void removeObject( SimObject* );
142      virtual void setCanSave( bool value );
143      
144      static void initPersistFields();
145                  
146      DECLARE_CONOBJECT( WorldEditorSelection );
147      DECLARE_CATEGORY( "Editor World" );
148      DECLARE_DESCRIPTION( "A selection set for the World Editor." );
149};
150
151#endif // !_WORLDEDITORSELECTION_H_
152