![]() |
VR-Forces 4.0.4 Class Documentation
|
00001 /****************************************************************************** 00002 ** Copyright (c) 2012 MAK Technologies, Inc. 00003 ** All rights reserved. 00004 ******************************************************************************/ 00005 00009 00010 #pragma once 00011 00012 #include <vrvCore/vrvCore.h> 00013 #include <vrvCore/DtUniqueID.h> 00014 #include <matrix/vlVector.h> 00015 #include <matrix/vlTaitBryan.h> 00016 #include <boost/signals.hpp> 00017 #include <vector> 00018 #include <list> 00019 00020 namespace makVrv 00021 { 00022 class DtDe; 00023 class DtModel; 00024 class DtUpdater; 00025 class DtQuat; 00026 00032 class DT_DLL_VRVCORE DtSceneObject 00033 { 00034 00035 public: 00036 00037 struct ObjectTransform 00038 { 00039 DtVector position; 00040 DtTaitBryan orientation; 00041 }; 00042 00043 typedef std::vector<ObjectTransform> TransformList; 00044 00045 // A record which stores a model and it's visibility. 00046 struct ModelRecord 00047 { 00048 DtModel* model; 00049 bool origVisibility; 00050 }; 00051 00052 // Utility functor object for using std::find_if with the ModelList. 00053 struct FindModelFunctor 00054 { 00055 FindModelFunctor(DtModel* aKey = 0) : myKey(aKey) {} 00056 FindModelFunctor(const FindModelFunctor& fm) : myKey(fm.myKey) {} 00057 00058 bool operator() (const DtSceneObject::ModelRecord& rec) const 00059 { 00060 return myKey == rec.model; 00061 } 00062 00063 DtModel* myKey; 00064 }; 00065 00066 typedef std::vector<ModelRecord> ModelList; 00067 00069 DtSceneObject( DtDe& de, DtUniqueID id ); 00070 00072 ~DtSceneObject(); 00073 00076 void addModel(DtModel* model, int visualizerType ); 00077 00079 void removeModel(DtModel* model ); 00080 00082 void removeModels(); 00083 00086 void setPosition( int vtx, const DtVector& position ); 00087 00089 void addPosition( int vtx, const DtVector& position ); 00090 00092 void getPosition( int vtx, DtVector& position ) const; 00093 00097 void setOffset( const DtVector& offset ); 00098 00100 void getOffset( DtVector& offset ) const; 00101 00103 void setOrientation( int vtx, const DtTaitBryan& orientation ); 00104 00106 void getOrientation( int vtx, DtTaitBryan& orientation ) const; 00107 00109 void getOrientation( int vtx, DtQuat& orientation ) const; 00110 00112 void setColor(float r, float g, float b, float a); 00113 00116 void setModelSet( int modelSet ); 00117 00119 int modelSet() const; 00120 00123 void setIsProp( bool isProp ); 00124 00126 bool isProp() const; 00127 00128 void setSolid( bool b ); 00129 00131 DtElementID elementID() const; 00132 00134 void setElementID( DtElementID elementID ); 00135 00137 DtUniqueID uniqueId() const; 00138 00140 const ModelList& models() const; 00141 00143 ModelList& models(); 00144 00146 const TransformList& transforms() const; 00147 00149 virtual void removePosition(int); 00150 00153 void setBoundingBoxSize(double minX, double maxX, 00154 double minY, double maxY, double minZ, double maxZ); 00155 00157 const DtVector& boundingBoxExtents() const; 00158 00160 void getBoundingBoxExtents(double& x, double& y, double& z) const; 00161 00163 const DtVector& boundingBoxCenter() const; 00164 00166 void getBoundingBoxCenter(double& x, double& y, double& z) const; 00167 00169 double boundingRadius() const; 00170 00172 void setVisible( bool visible ); 00173 00175 void setVisibleViaSwitch( bool visible ); 00176 00178 bool isVisible() const; 00179 00181 void setUpdater(DtUpdater* updater); 00182 00184 DtUpdater* findUpdater(); 00185 00187 boost::signal<void (DtModel*)> signal_modelAdded; 00188 00190 boost::signal<void (DtModel*)> signal_modelRemoved; 00191 00193 boost::signal< void (const DtUniqueID&) > signal_sceneObjectToBeDeleted; 00194 00196 boost::signal<void (DtSceneObject*)> signal_boundingVolumeChanged; 00197 00198 protected: 00199 00201 void initializeModel( DtModel* modelInstanceOwner ); 00202 00204 void modelChanged( DtModel* model ); 00205 00208 // are not. I highly doubt that this works at all, so please ignore. 00209 bool modelVisibilityRequested( DtModel* model, bool visible); 00210 00212 void resetModelTransforms(); 00213 00216 void updateBoundingBoxViaContents(); 00217 00219 void calculateBoundingRadius(); 00220 00221 protected: 00222 00223 DtDe& myDe; 00224 DtUniqueID myUniqueId; 00225 TransformList myTransforms; 00226 DtElementID myElementID; 00227 DtUpdater* myUpdater; 00228 00229 int myModelSet; 00230 bool myIsProp; 00231 bool myGroundClampTo; 00232 ModelList myModels; 00233 bool myVisibleFlag; 00234 bool myCalculateBoundingBoxFlag; 00235 DtVector myBoundingBoxCenter; 00236 DtVector myBoundingBoxExtents; 00237 double myBoundingRadius; 00238 DtVector myOffset; 00239 }; 00240 } 00241 00242