VR-Forces 5.0.3 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtSceneObject.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2021 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvCore/vrvCore.h>
13 #include <vrvCore/DtUniqueID.h>
14 #include <matrix/vlVector.h>
15 #include <matrix/vlTaitBryan.h>
16 
17 #include <vrvUtil/signalslib.h>
18 
19 #include <boost/unordered_map.hpp>
20 
21 namespace makVrv
22 {
23  class DtDe;
24  class DtModel;
25  class DtQuat;
26  class DtSceneObjectUpdater;
27 
43  {
44 
45  public:
46 
48  {
50  DtTaitBryan orientation;
51  };
52 
53  typedef std::vector<ObjectTransform> TransformList;
54 
55  // A record which stores a model and it's visibility.
56  struct ModelRecord
57  {
60  };
61 
62  // Utility functor object for using std::find_if with the ModelList.
64  {
65  FindModelFunctor(DtModel* aKey = 0) : myKey(aKey) {}
66  FindModelFunctor(const FindModelFunctor& fm) : myKey(fm.myKey) {}
67 
68  bool operator() (const DtSceneObject::ModelRecord& rec) const
69  {
70  return myKey == rec.model;
71  }
72 
74  };
75 
76  typedef std::vector<ModelRecord> ModelList;
77 
78  enum ModelSet
79  {
80  ModelSet_Unspecified = -1,
81  ModelSet_3D = 0,
82  ModelSet_3DColorized = 1,
83  ModelSet_2DIcons = 5
84  };
85 
87  DtSceneObject( DtDe& de, DtUniqueID id );
88 
90  virtual ~DtSceneObject();
91 
94  void addModel(DtModel* model, int visualizerType );
95 
97  void removeModel(DtModel* model );
98 
100  void removeModels();
101 
104  void setPosition( int vtx, const DtVector& position );
105 
107  void addPosition( int vtx, const DtVector& position );
108 
110  void getPosition( int vtx, DtVector& position ) const;
111 
115  void setOffset( const DtVector& offset );
116 
118  void getOffset( DtVector& offset ) const;
119 
121  void setOrientation( int vtx, const DtTaitBryan& orientation );
122 
124  void setPositionAndOrientation(int vtx, const DtVector& position, const DtTaitBryan& orientation);
125 
127  // topographic coordinate system (x north, y east, z down)
128  void setTopographicOrientation( int vtx,
129  const DtTaitBryan& topoOrientation );
130 
132  void getOrientation( int vtx, DtTaitBryan& orientation ) const;
133 
135  // topographic coordinate system (x north, y east, z down)
136  void getTopographicOrientation( int vtx, DtTaitBryan& orientation ) const;
137 
141  DtTaitBryan getTopographicOrientation(const DtVector& geocLocation, const DtTaitBryan& geocOrientation) const;
142 
144  void getOrientation( int vtx, DtQuat& orientation ) const;
145 
148  virtual void transformToSceneObjectCoord(const DtVector& dbCoord, DtVector& soCoord);
149 
152  virtual void transformToDatabaseCoord(const DtVector& soCoord, DtVector& dbCoord);
153 
155  void setColor(float r, float g, float b, float a);
156 
162  void setModelSet( int modelSet );
163 
165  int modelSet() const;
166 
169  void setIsProp( bool isProp );
170 
172  bool isProp() const;
173 
175  void setIsSupportObject( bool b );
176 
178  bool isSupportObject();
179 
181  void setSolid( bool b );
182 
184  bool isSolid() const;
185 
187  DtElementID elementID() const;
188 
191  void setElementID( DtElementID elementID );
192 
194  DtUniqueID uniqueId() const;
195 
197  const ModelList& models() const;
198 
200  ModelList& models();
201 
203  const TransformList& transforms() const;
204 
206  virtual void removePosition(int);
207 
210  void setBoundingBoxSize(double minX, double maxX,
211  double minY, double maxY, double minZ, double maxZ);
212 
214  const DtVector& boundingBoxExtents() const;
215 
217  void getBoundingBoxExtents(double& x, double& y, double& z) const;
218 
220  const DtVector& boundingBoxCenter() const;
221 
223  void getBoundingBoxCenter(double& x, double& y, double& z) const;
224 
226  double boundingRadius() const;
227 
231  void setVisible( bool visible );
232 
237  bool isVisible() const;
238 
239  //{@
244  virtual void setBeingObserved(bool observed);
245  virtual bool beingObserved() const;
247 
249  void setUpdater(DtSceneObjectUpdater* updater);
250 
252  DtSceneObjectUpdater* findUpdater();
253  const DtSceneObjectUpdater* findUpdater() const;
254 
256  virtual float getAndResetMinModelDistance();
257 
260 
262  boost::signalslib::signal<void (DtModel*)> signal_modelAdded;
263 
265  boost::signalslib::signal<void (DtModel*)> signal_modelRemoved;
266 
268  boost::signalslib::signal< void (const DtUniqueID&) > signal_sceneObjectToBeDeleted;
269 
271  boost::signalslib::signal<void (DtSceneObject*)> signal_boundingVolumeChanged;
272 
274 
275  protected:
276 
278  void initializeModel( DtModel* modelInstanceOwner );
279 
281  void modelChanged( DtModel* model );
282 
285  // are not. I highly doubt that this works at all, so please ignore.
286  bool modelVisibilityRequested( DtModel* model, bool visible);
287 
289  void resetModelTransforms();
290 
293  void updateBoundingBoxViaContents();
294 
296  void calculateBoundingRadius();
297 
299  virtual void addModelConnections( DtModel* model );
300 
302  virtual void removeModelConnections( DtModel* model );
303 
304 
305  protected:
306 
312 
314  bool myIsProp;
325 
327  {
328  boost::signalslib::connection modelDestroyedConnection;
329  boost::signalslib::connection modelChangedConnection;
330  boost::signalslib::connection modelVisibilityConnection;
331  };
332  typedef std::pair<DtModel*, ModelConnections> ModelConnectionsPair;
333  typedef boost::unordered_map<DtModel*, ModelConnections> ModelConnectionsMap;
335  };
336 }
DtVector position
Definition: DtSceneObject.h:49
Definition: DtSceneObject.h:47
boost::unordered_map< DtModel *, ModelConnections > ModelConnectionsMap
Definition: DtSceneObject.h:333
boost::signalslib::signal< void(DtModel *)> signal_modelAdded
Signaled after a model has been added.
Definition: DtSceneObject.h:262
ModelList myModels
Definition: DtSceneObject.h:317
DtVector myBoundingBoxExtents
Definition: DtSceneObject.h:321
int myModelSet
Definition: DtSceneObject.h:313
double myBoundingRadius
Definition: DtSceneObject.h:322
Scene Object Updater.
Definition: DtSceneObjectUpdater.h:36
boost::signalslib::connection modelDestroyedConnection
Definition: DtSceneObject.h:328
Definition: DtSceneObject.h:56
boost::signalslib::signal< void(DtSceneObject *)> signal_boundingVolumeChanged
Emitted after the bounding volume of the object changes.
Definition: DtSceneObject.h:271
ModelSet
Definition: DtSceneObject.h:78
boost::signalslib::connection modelChangedConnection
Definition: DtSceneObject.h:329
bool myIsDrawnSolid
Definition: DtSceneObject.h:316
bool origVisibility
Definition: DtSceneObject.h:59
DtVector myBoundingBoxCenter
Definition: DtSceneObject.h:320
bool myVisibleFlag
Definition: DtSceneObject.h:318
#define DT_DLL_VRVCORE
Definition: vrvCore.h:20
bool myIsProp
Definition: DtSceneObject.h:314
FindModelFunctor(const FindModelFunctor &fm)
Definition: DtSceneObject.h:66
bool myBeingObserved
Definition: DtSceneObject.h:324
DtModel * model
Definition: DtSceneObject.h:58
DtUniqueID myUniqueId
Definition: DtSceneObject.h:308
boost::signalslib::connection modelVisibilityConnection
Definition: DtSceneObject.h:330
DtVector myOffset
Definition: DtSceneObject.h:323
Definition: DtSceneObject.h:63
DtSceneObjectUpdater * myUpdater
Definition: DtSceneObject.h:311
DtElementID myElementID
Definition: DtSceneObject.h:310
FindModelFunctor(DtModel *aKey=0)
Definition: DtSceneObject.h:65
std::pair< DtModel *, ModelConnections > ModelConnectionsPair
Definition: DtSceneObject.h:332
bool myGroundClampTo
Definition: DtSceneObject.h:315
TransformList myTransforms
Definition: DtSceneObject.h:309
bool myCalculateBoundingBoxFlag
Definition: DtSceneObject.h:319
boost::signalslib::signal< void(const DtUniqueID &) > signal_sceneObjectToBeDeleted
Emitted before the scene object is destroyed.
Definition: DtSceneObject.h:268
A DtSceneObject represents an object that can be positioned in the scene by (possibly) attaching it t...
Definition: DtSceneObject.h:42
A model which owns a single model instance. A DtModel is a managing container for a single DtModelIns...
Definition: DtModel.h:55
Contains makVrv::DtUniqueID type.
ModelConnectionsMap myModelConnections
Definition: DtSceneObject.h:334
std::vector< ObjectTransform > TransformList
Definition: DtSceneObject.h:53
The DtDe is the core component of any VR-Vantage application. It owns a DtRenderer, DtDeCommunicator, as well as a DtDisplay and other things.
Definition: DtDe.h:70
boost::signalslib::signal< void(DtModel *)> signal_modelRemoved
Signaled after the model has been removed.
Definition: DtSceneObject.h:265
Definition: DtSceneObject.h:326
DtDe & myDe
Definition: DtSceneObject.h:307
A utility Quaternion class.
Definition: DtQuat.h:19
DtTaitBryan orientation
Definition: DtSceneObject.h:50
std::vector< ModelRecord > ModelList
Definition: DtSceneObject.h:76
DtModel * myKey
Definition: DtSceneObject.h:73
voidpf uLong offset
Definition: ioapi.h:42
Contains DLL export macros.

Document ID: Generated on Thu Jun 1 17:58:13 EDT 2023 from SVN revision 255404
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)