VR-Forces 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) 2022 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 
15 #include <matrix/vlVector.h>
16 #include <matrix/vlTaitBryan.h>
17 
18 #include <vrvUtil/signalslib.h>
19 
20 #include <boost/unordered_map.hpp>
21 
22 namespace makVrv
23 {
24  class DtDe;
25  class DtModel;
26  class DtQuat;
27  class DtSceneObjectUpdater;
28  enum class DtModelSetId;
29 
45  {
46 
47  public:
48 
50  {
51  DtVector position;
52  DtTaitBryan orientation;
53  bool dirty;
54  };
55 
56  typedef std::vector<ObjectTransform> TransformList;
57 
58  // A record which stores a model and it's visibility.
59  struct ModelRecord
60  {
63  };
64 
65  // Utility functor object for using std::find_if with the ModelList.
67  {
68  FindModelFunctor(DtModel* aKey = 0) : myKey(aKey) {}
69  FindModelFunctor(const FindModelFunctor& fm) : myKey(fm.myKey) {}
70 
71  bool operator() (const DtSceneObject::ModelRecord& rec) const
72  {
73  return myKey == rec.model;
74  }
75 
77  };
78 
79  typedef std::vector<ModelRecord> ModelList;
80 
82  DtSceneObject( DtDe& de, DtUniqueID id );
83 
85  virtual ~DtSceneObject();
86 
89  void addModel(DtModel* model, int visualizerType );
90 
92  void removeModel(DtModel* model );
93 
95  void removeModels();
96 
99  void setPosition( int vtx, const DtVector& position );
100 
102  void addPosition( int vtx, const DtVector& position );
103 
105  void getPosition( int vtx, DtVector& position ) const;
106 
110  void setOffset( const DtVector& offset );
111 
113  void getOffset( DtVector& offset ) const;
114 
116  void setOrientation( int vtx, const DtTaitBryan& orientation );
117 
119  void setPositionAndOrientation(int vtx, const DtVector& position, const DtTaitBryan& orientation);
120 
122  // topographic coordinate system (x north, y east, z down)
123  void setTopographicOrientation( int vtx,
124  const DtTaitBryan& topoOrientation );
125 
127  void getOrientation( int vtx, DtTaitBryan& orientation ) const;
128 
130  // topographic coordinate system (x north, y east, z down)
131  void getTopographicOrientation( int vtx, DtTaitBryan& orientation ) const;
132 
136  DtTaitBryan getTopographicOrientation(const DtVector& geocLocation, const DtTaitBryan& geocOrientation) const;
137 
139  void getOrientation( int vtx, DtQuat& orientation ) const;
140 
143  virtual void transformToSceneObjectCoord(const DtVector& dbCoord, DtVector& soCoord) const;
144 
147  virtual void transformToDatabaseCoord(const DtVector& soCoord, DtVector& dbCoord) const;
148 
150  void setColor(float r, float g, float b, float a);
151 
157  void setModelSet( DtModelSetId modelSet );
158 
160  DtModelSetId modelSet() const;
161 
164  void setIsProp( bool isProp );
165 
167  bool isProp() const;
168 
170  void setIsSupportObject( bool b );
171 
173  bool isSupportObject();
174 
176  void setSolid( bool b );
177 
179  bool isSolid() const;
180 
182  DtElementID elementID() const;
183 
186  void setElementID( DtElementID elementID );
187 
189  DtUniqueID uniqueId() const;
190 
192  const ModelList& models() const;
193 
195  ModelList& models();
196 
198  const TransformList& transforms() const;
199 
201  virtual void removePosition(int);
202 
205  void setBoundingBoxSize(double minX, double maxX,
206  double minY, double maxY, double minZ, double maxZ);
207 
209  const DtVector& boundingBoxExtents() const;
210 
212  void getBoundingBoxExtents(double& x, double& y, double& z) const;
213 
215  const DtVector& boundingBoxCenter() const;
216 
218  void getBoundingBoxCenter(double& x, double& y, double& z) const;
219 
221  double boundingRadius() const;
222 
226  void setVisible( bool visible );
227 
232  bool isVisible() const;
233 
234  //{@
239  virtual void setBeingObserved(bool observed);
240  virtual bool beingObserved() const;
242 
244  void setUpdater(DtSceneObjectUpdater* updater);
245 
247  DtSceneObjectUpdater* findUpdater();
248  const DtSceneObjectUpdater* findUpdater() const;
249 
251  virtual float getAndResetMinModelDistance();
252 
255 
257  boost::signalslib::signal<void (DtModel*)> signal_modelAdded;
258 
260  boost::signalslib::signal<void (DtModel*)> signal_modelRemoved;
261 
263  boost::signalslib::signal< void (const DtUniqueID&) > signal_sceneObjectToBeDeleted;
264 
266  boost::signalslib::signal<void (DtSceneObject*)> signal_boundingVolumeChanged;
267 
269  public:
270 
271  // convert a point from model coordinates (y-front, x-right, z-up) to scene object (x-front, y-right, zdown) coordinates
272  static void modelCoordToSceneObjectCoord(const DtVector& modelCoord, DtVector& soCoord);
273 
274  protected:
275 
277  void initializeModel( DtModel* modelInstanceOwner );
278 
280  void modelChanged( DtModel* model );
281 
284  // are not. I highly doubt that this works at all, so please ignore.
285  bool modelVisibilityRequested( DtModel* model, bool visible);
286 
288  void resetModelTransforms();
289 
292  void updateBoundingBoxViaContents();
293 
295  void calculateBoundingRadius();
296 
298  virtual void addModelConnections( DtModel* model );
299 
301  virtual void removeModelConnections( DtModel* model );
302 
303 
304  protected:
305 
311 
313  bool myIsProp;
322  DtVector myOffset;
324 
328  {
329  boost::signalslib::connection modelDestroyedConnection;
330  boost::signalslib::connection modelChangedConnection;
331  boost::signalslib::connection modelVisibilityConnection;
332  };
333  typedef std::pair<DtModel*, ModelConnections> ModelConnectionsPair;
334  typedef boost::unordered_map<DtModel*, ModelConnections> ModelConnectionsMap;
336  };
337 }
DtVector position
Definition: DtSceneObject.h:51
Definition: DtSceneObject.h:49
boost::unordered_map< DtModel *, ModelConnections > ModelConnectionsMap
Definition: DtSceneObject.h:334
boost::signalslib::signal< void(DtModel *)> signal_modelAdded
Signaled after a model has been added.
Definition: DtSceneObject.h:257
ModelList myModels
Definition: DtSceneObject.h:316
DtVector myBoundingBoxExtents
Definition: DtSceneObject.h:320
DtModelSetId myModelSet
Definition: DtSceneObject.h:312
double myBoundingRadius
Definition: DtSceneObject.h:321
Scene Object Updater.
Definition: DtSceneObjectUpdater.h:40
boost::signalslib::connection modelDestroyedConnection
Definition: DtSceneObject.h:329
Definition: DtSceneObject.h:59
boost::signalslib::signal< void(DtSceneObject *)> signal_boundingVolumeChanged
Emitted after the bounding volume of the object changes.
Definition: DtSceneObject.h:266
DtUniqueID DtElementID
The ElementID is a specific type of unique ID used to represent VR-Vantage uniquely defined elements...
Definition: DtUniqueID.h:23
bool myResetModelsTransforms
Definition: DtSceneObject.h:325
boost::signalslib::connection modelChangedConnection
Definition: DtSceneObject.h:330
bool myIsDrawnSolid
Definition: DtSceneObject.h:315
bool origVisibility
Definition: DtSceneObject.h:62
DtVector myBoundingBoxCenter
Definition: DtSceneObject.h:319
bool myVisibleFlag
Definition: DtSceneObject.h:317
#define DT_DLL_VRVCORE
Definition: vrvCore.h:20
bool myIsProp
Definition: DtSceneObject.h:313
FindModelFunctor(const FindModelFunctor &fm)
Definition: DtSceneObject.h:69
bool myBeingObserved
Definition: DtSceneObject.h:323
DtModel * model
Definition: DtSceneObject.h:61
bool myUpdateModelsSpatial
Definition: DtSceneObject.h:326
DtUniqueID myUniqueId
Definition: DtSceneObject.h:307
boost::signalslib::connection modelVisibilityConnection
Definition: DtSceneObject.h:331
DtVector myOffset
Definition: DtSceneObject.h:322
bool dirty
Definition: DtSceneObject.h:53
Definition: DtSceneObject.h:66
DtSceneObjectUpdater * myUpdater
Definition: DtSceneObject.h:310
DtElementID myElementID
Definition: DtSceneObject.h:309
unsigned long long DtUniqueID
Definition: DtUniqueID.h:19
FindModelFunctor(DtModel *aKey=0)
Definition: DtSceneObject.h:68
std::pair< DtModel *, ModelConnections > ModelConnectionsPair
Definition: DtSceneObject.h:333
bool myGroundClampTo
Definition: DtSceneObject.h:314
TransformList myTransforms
Definition: DtSceneObject.h:308
bool myCalculateBoundingBoxFlag
Definition: DtSceneObject.h:318
boost::signalslib::signal< void(const DtUniqueID &) > signal_sceneObjectToBeDeleted
Emitted before the scene object is destroyed.
Definition: DtSceneObject.h:263
A DtSceneObject represents an object that can be positioned in the scene by (possibly) attaching it t...
Definition: DtSceneObject.h:44
A model which owns a single model instance. A DtModel is a managing container for a single DtModelIns...
Definition: DtModel.h:56
Contains makVrv::DtUniqueID type.
ModelConnectionsMap myModelConnections
Definition: DtSceneObject.h:335
std::vector< ObjectTransform > TransformList
Definition: DtSceneObject.h:56
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:76
boost::signalslib::signal< void(DtModel *)> signal_modelRemoved
Signaled after the model has been removed.
Definition: DtSceneObject.h:260
Definition: DtSceneObject.h:327
DtDe & myDe
Definition: DtSceneObject.h:306
A utility Quaternion class.
Definition: DtQuat.h:19
DtTaitBryan orientation
Definition: DtSceneObject.h:52
std::vector< ModelRecord > ModelList
Definition: DtSceneObject.h:79
DtModel * myKey
Definition: DtSceneObject.h:76
DtModelSetId
Definition: DtModelSetEnums.h:19
voidpf uLong offset
Definition: ioapi.h:42
Contains DLL export macros.

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)