VR-Forces 4.0.4 Class Documentation
include/vrvCore/DtGroundClampingUpdater.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 #include <vrvCore/DtUpdater.h>
00012 #include <matrix/vlVector.h>
00013 #include <matrix/vlTaitBryan.h>
00014 
00015 namespace makVrv 
00016 {
00017    class DtIntersectionCache;
00018 
00023    class DT_DLL_VRVCORE DtGroundClampingUpdater : public DtUpdater
00024    { 
00025    public:
00026 
00028       enum GroundClampingMode
00029       {
00030          ClampNone         = 0,
00031          ClampOrientation  = 1,
00032          ClampPosition     = 2,
00033          ClampUpright      = 4,
00034          ClampOrientationAndPosition = ClampOrientation | ClampPosition,
00035          ClampOrientationAndUpright = ClampOrientation | ClampUpright,
00036          ClampPositionAndUpright = ClampPosition | ClampUpright,
00037          ClampAll = ClampOrientation | ClampPosition | ClampUpright
00038       };
00039 
00040    public:
00041 
00043       DtGroundClampingUpdater(DtDe& de, DtUniqueID id, bool doNotAddToMgr = false );
00044 
00046       virtual ~DtGroundClampingUpdater();
00047 
00049       virtual void update( double simTime );
00050 
00052       virtual void setPosition(const DtVector& position);
00053 
00055       virtual void setOrientation(const DtTaitBryan& ori);
00056 
00059       virtual void setPosition(int index, const DtVector&);
00060 
00063       virtual void setOrientation(int index, const DtTaitBryan&);
00064 
00066       virtual void removeSpatial(int);
00067 
00069       virtual void resetToUnclamped();
00070 
00073       virtual void setEnabled(bool enabled);
00074 
00076       virtual void setMode(GroundClampingMode mode);
00077 
00079       bool isClamping() const;
00080 
00082       inline bool isClampingUp() const
00083       {
00084          return myMode & ClampUpright;
00085       }
00086 
00088       inline bool isClampingOrientation() const
00089       {
00090          return myMode & ClampOrientation;
00091       }
00092 
00094       inline bool isClampingPosition() const
00095       {
00096          return myMode & ClampPosition;
00097       }
00098 
00106       virtual void setCullCylinderRadiusScale(float scale);
00107 
00109       virtual void setClampAlways(bool enabled);
00110 
00112       virtual void setCheckForCulling(bool);
00113 
00116       virtual bool doGroundClamp();
00117 
00120       virtual void setClampTimeThreshold(double);
00121 
00122    protected:
00123 
00125       static void computePerpendicularRotation( const DtVector& pos, 
00126          const DtVector& hitNormal, const DtTaitBryan& orientation, 
00127          DtTaitBryan& output );  
00128 
00132       bool computeGroundClampingHit(const DtVector& up,const DtVector& unclampedPosition, DtVector& hitLocation, DtVector& hitNormal);
00133 
00135       void computeIntersectionOrigin(const DtVector& up, const DtVector& unclampedPosition, DtVector& origin) const;
00136 
00138       bool needClampThisTick() const;
00139 
00142       bool targetIsMoving( const DtVector& newPos, const DtVector& lastPos ) const;
00143 
00146       bool targetIsTurning( const DtTaitBryan& newOri, const DtTaitBryan& lastOri ) const;      
00147 
00149       bool checkCulling(const DtVector& up) const;
00150 
00151       // handy helper func to determine the delta between circle angles, 
00153       static double angleDifference( double prev, double curr );
00154 
00155    protected:
00156 
00157       static const double theClampTimeThreshold;
00158       static const double theMaxCacheInterval;
00159       static const double theClampDistThreshold;
00160       static const double theClampOrientThreshold;
00161       static const double theIsectLength;    
00162 
00163       typedef std::vector<DtVector> Positions;
00164       typedef std::vector<DtTaitBryan> Orientations;
00165 
00166       Positions myLastUnclampedPositions;
00167       Orientations myLastUnclampedOrientations;
00168 
00169       Positions myUnclampedPositions;
00170       Orientations myUnclampedOrientations;
00171 
00172       double myLastCacheUpdateTime;
00173       double myLastClampTime;
00174 
00177       float myCullCylinderScale;
00178 
00180       GroundClampingMode myMode;
00181 
00183       DtIntersectionCache* myIntersectionCache;
00184 
00186       bool myEnabledFlag;
00187 
00189       bool myClampAlwaysFlag;
00190 
00192       bool myClampCulledLastFrame;      
00193 
00195       bool myCheckForCull;
00196 
00197       double myClampTimeThreshold;
00198       bool myBecameEnabledThisTick;
00199    }; 
00200 } 

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)