VR-Forces 4.0.4 Class Documentation
include/vrvCore/DtAttachableUpdater.h
Go to the documentation of this file.
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 <vrvCore/DtUpdater.h>
00015 
00016 #include <matrix/vlVector.h>
00017 #include <matrix/vlTaitBryan.h>
00018 
00019 #include <vector>
00020 #include <list>
00021 
00022 namespace makVrv
00023 {
00024 
00025    class DtDe;
00026 
00030    class DT_DLL_VRVCORE DtAttachableUpdater : public DtUpdater
00031    {
00032    public:
00033 
00035       enum AttachedPointType
00036       {
00037          AttachedPointTypeVertex,
00038          AttachedPointTypeObject,
00039          AttachedPointTypeProportional,
00040          AttachedPointTypeDeprecatedObject,
00041          AttachedPointTypeInvalidObject
00042       };
00043 
00044       enum AttachedPointMode
00045       {
00046          AttachedPointModePositionAndOrientation,
00047          AttachedPointModePositionOnly,
00048          AttachedPointModeOrientationOnly
00049       };
00050 
00052       class AttachedPoint
00053       {
00054       public:
00055 
00056          AttachedPoint( AttachedPointType type, int targetVertexIndex,
00057                const DtVector& positionOffset )
00058             : myAttachedPointType( type )
00059             , myTargetVertexIndex( targetVertexIndex )
00060             , myPositionOffset( positionOffset )
00061           , myAttachedPointMode(AttachedPointModePositionAndOrientation)
00062          {
00063          }
00064 
00065          virtual ~AttachedPoint() {}
00066 
00067          AttachedPointType type() const
00068          {
00069             return myAttachedPointType;
00070          }
00071 
00072          int targetVertexIndex()
00073          {
00074             return myTargetVertexIndex;
00075          }
00076 
00077          void setPositionOffset(const DtVector& o)
00078          {
00079             myPositionOffset = o;
00080          }
00081 
00082          const DtVector& positionOffset() const
00083          {
00084             return myPositionOffset;
00085          }
00086 
00087          void setAttachedPointMode( AttachedPointMode mode )
00088          {
00089             myAttachedPointMode = mode;
00090          }
00091 
00092          AttachedPointMode attachedPointMode() const
00093          {
00094             return myAttachedPointMode;
00095          }
00096 
00097         protected:
00098 
00099          AttachedPointType myAttachedPointType;
00100          int myTargetVertexIndex;
00101          DtVector myPositionOffset;
00102          AttachedPointMode myAttachedPointMode;
00103 
00104       };
00105 
00107       class ObjectAttachedPoint : public AttachedPoint
00108       {
00109       public:
00110 
00111          ObjectAttachedPoint( DtSceneObject* sceneObject, DtUpdater* updater,
00112                int targetVertexIndex, const DtVector& positionOffset )
00113             : AttachedPoint( AttachedPointTypeObject, targetVertexIndex, positionOffset )
00114             , mySceneObject( sceneObject )
00115             , myUpdater( updater )
00116          {
00117          }
00118 
00119          virtual ~ObjectAttachedPoint() {}
00120 
00121          inline void setSceneObject( DtSceneObject* sceneObject )
00122          {
00123             mySceneObject = sceneObject;
00124          }
00125 
00126          inline DtSceneObject* sceneObject() const
00127          {
00128             return mySceneObject;
00129          }
00130 
00131          inline void setUpdater( DtUpdater* updater )
00132          {
00133             myUpdater = updater;
00134          }
00135 
00136          inline DtUpdater* updater() const 
00137          {
00138             return myUpdater;
00139          }
00140 
00141       protected:
00142 
00143          DtSceneObject* mySceneObject;
00144          DtUpdater* myUpdater;
00145       };
00146 
00149       class VertexAttachedPoint : public AttachedPoint
00150       {
00151       public:
00152 
00153          VertexAttachedPoint( const DtVector& position, int targetVertexIndex,
00154                const DtVector& positionOffset )
00155             : AttachedPoint( AttachedPointTypeVertex, targetVertexIndex, positionOffset )
00156             , myVertex( position )
00157          {
00158          }
00159          virtual ~VertexAttachedPoint() {}
00160 
00161          DtVector vertex() const
00162          {
00163             return myVertex;
00164          }
00165 
00166       protected:
00167 
00168          DtVector myVertex;
00169       };
00170 
00173       class LinearAttachedPoint : public ObjectAttachedPoint
00174       {
00175       public:
00176 
00177          LinearAttachedPoint( DtSceneObject* sceneObject, DtUpdater* updater,
00178                int vtx1, int vtx2, double proportion, int targetVertexIndex,
00179                const DtVector& positionOffset )
00180             : ObjectAttachedPoint( sceneObject, updater, targetVertexIndex, positionOffset )
00181             , myFirstVtx( vtx1 )
00182             , mySecondVtx( vtx2 )
00183             , myProportion( proportion )
00184          {
00185             myAttachedPointType = AttachedPointTypeProportional;
00186          }
00187 
00188          inline int firstVtx()
00189          {
00190             return myFirstVtx;
00191          }
00192 
00193          inline int secondVtx()
00194          {
00195             return mySecondVtx;
00196          }
00197 
00198          inline double proportion()
00199          {
00200             return myProportion;
00201          }
00202 
00203       protected:
00204 
00205          int myFirstVtx;
00206          int mySecondVtx;
00207          double myProportion;
00208 
00209       };
00210 
00211    public:
00212 
00214       DtAttachableUpdater( DtDe& de, DtUniqueID id, bool doNotAddToMgr = false );
00215 
00217       virtual ~DtAttachableUpdater();
00218 
00222       virtual void addAttachedPoint( const DtVector& position, int targetVertexIndex );
00223 
00227       virtual void addAttachedPoint( DtUniqueID uniqueID, int targetVertexIndex );
00228 
00232       virtual void addAttachedPoint( DtUniqueID uniqueID, int vtx1, int vtx2,
00233          double proportion, int targetVertexIndex );
00234 
00239       virtual const AttachedPoint& attachedPoint( int targetVertexIndex ) const;
00240 
00243       virtual void setPositionOffset( const DtVector& offset );
00244 
00248       virtual void setPositionOffset( const DtVector& offset, int vtx );
00249 
00252       virtual void setOrientationOffset(const DtTaitBryan& offset);
00253 
00255       virtual void setAttachedPointMode( unsigned int mode, int vtx );
00256 
00258       virtual void update( double simTime );
00259 
00262       virtual void doAttachment();
00263 
00264    protected:
00265 
00266       virtual void slot_attachedSceneObjectToBeDeleted( const DtUniqueID& );
00267       virtual void slot_attachedUpdaterToBeDeleted( const DtUniqueID& id );
00268 
00269       // get values of attached point at simTime
00270       virtual bool pointLocationAndOrientation( AttachedPoint* point, 
00271          double simTime, DtVector& location, DtTaitBryan& orientation );
00272 
00274       virtual void removeAttachedPoint(int vtx, DtVector* positionOffset = 0);
00275 
00276    protected:
00277 
00278       typedef std::vector<AttachedPoint*> AttachedPointsVector;
00279       AttachedPointsVector myAttachedPoints;
00280 
00281       DtVector myPositionOffset;
00282       DtTaitBryan myOrientationOffset;
00283 
00284    };
00285 
00286 }

Document ID: Generated on Fri Jun 29 16:33:32 EDT 2012 from SVN revision 116588
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)