llflexibleobject.h

Go to the documentation of this file.
00001 
00042 #ifndef LL_LLFLEXIBLEOBJECT_H
00043 #define LL_LLFLEXIBLEOBJECT_H
00044 
00045 #include "llmemory.h"
00046 #include "llprimitive.h"
00047 #include "llvovolume.h"
00048 #include "llwind.h"
00049 
00050 // 10 ms for the whole thing!
00051 const F32       FLEXIBLE_OBJECT_TIMESLICE               = 0.003f;
00052 const U32       FLEXIBLE_OBJECT_MAX_LOD                 = 10;
00053 
00054 // See llprimitive.h for LLFlexibleObjectData and DEFAULT/MIN/MAX values 
00055 
00056 //-------------------------------------------------------------------
00057 
00058 struct LLFlexibleObjectSection
00059 {
00060         // Input parameters
00061         LLVector2               mScale;
00062         LLQuaternion    mAxisRotation;
00063         // Simulated state
00064         LLVector3               mPosition;
00065         LLVector3               mVelocity;
00066         LLVector3               mDirection;
00067         LLQuaternion    mRotation;
00068         // Derivatives (Not all currently used, will come back with LLVolume changes to automagically generate normals)
00069         LLVector3               mdPosition;
00070         //LLMatrix4             mRotScale;
00071         //LLMatrix4             mdRotScale;
00072 };
00073 
00074 //---------------------------------------------------------
00075 // The LLVolumeImplFlexible class 
00076 //---------------------------------------------------------
00077 class LLVolumeImplFlexible : public LLVolumeInterface
00078 {
00079         public:
00080                 LLVolumeImplFlexible(LLViewerObject* volume, LLFlexibleObjectData* attributes);
00081 
00082                 // Implements LLVolumeInterface
00083                 U32 getID() const { return mID; }
00084                 LLVector3 getFramePosition() const;
00085                 LLQuaternion getFrameRotation() const;
00086                 LLVolumeInterfaceType getInterfaceType() const          { return INTERFACE_FLEXIBLE; }
00087                 BOOL doIdleUpdate(LLAgent &agent, LLWorld &world, const F64 &time);
00088                 BOOL doUpdateGeometry(LLDrawable *drawable);
00089                 LLVector3 getPivotPosition() const;
00090                 void onSetVolume(const LLVolumeParams &volume_params, const S32 detail);
00091                 void onSetScale(const LLVector3 &scale, BOOL damped);
00092                 void onParameterChanged(U16 param_type, LLNetworkData *data, BOOL in_use, bool local_origin);
00093                 void onShift(const LLVector3 &shift_vector);
00094                 bool isVolumeUnique() const { return true; }
00095                 bool isVolumeGlobal() const { return true; }
00096                 bool isActive() const { return true; }
00097                 const LLMatrix4& getWorldMatrix(LLXformMatrix* xform) const;
00098                 void updateRelativeXform();
00099                 void doFlexibleUpdate(); // Called to update the simulation
00100                 void doFlexibleRebuild(); // Called to rebuild the geometry
00101                 
00102                 //void                          setAttributes( LLFlexibleObjectData );
00103                 void                            setParentPositionAndRotationDirectly( LLVector3 p, LLQuaternion r );
00104                 void                            setUsingCollisionSphere( bool u );
00105                 void                            setCollisionSphere( LLVector3 position, F32 radius );
00106                 void                            setRenderingCollisionSphere( bool r);
00107 
00108                 LLVector3                       getEndPosition();
00109                 LLQuaternion            getEndRotation();
00110                 LLVector3                       getNodePosition( int nodeIndex );
00111                 LLVector3                       getAnchorPosition() const;
00112 
00113         private:
00114                 //--------------------------------------
00115                 // private members
00116                 //--------------------------------------
00117             // Backlink only; don't make this an LLPointer.
00118                 LLViewerObject*                         mVO;
00119                 LLTimer                                         mTimer;
00120                 LLVector3                                       mAnchorPosition;
00121                 LLVector3                                       mParentPosition;
00122                 LLQuaternion                            mParentRotation;
00123                 LLQuaternion                            mLastFrameRotation;
00124                 LLQuaternion                            mLastSegmentRotation;
00125                 BOOL                                            mInitialized;
00126                 BOOL                                            mUpdated;
00127                 LLFlexibleObjectData*           mAttributes;
00128                 LLFlexibleObjectSection         mSection        [ (1<<FLEXIBLE_OBJECT_MAX_SECTIONS)+1 ];
00129                 S32                                                     mInitializedRes;
00130                 S32                                                     mSimulateRes;
00131                 S32                                                     mRenderRes;
00132                 U32                                                     mFrameNum;
00133                 LLVector3                                       mCollisionSpherePosition;
00134                 F32                                                     mCollisionSphereRadius;
00135                 U32                                                     mID;
00136 
00137                 //--------------------------------------
00138                 // private methods
00139                 //--------------------------------------
00140                 void setAttributesOfAllSections ();
00141 
00142                 void remapSections(LLFlexibleObjectSection *source, S32 source_sections,
00143                                                                                  LLFlexibleObjectSection *dest, S32 dest_sections);
00144                 
00145 public:
00146                 // Global setting for update rate
00147                 static F32                                      sUpdateFactor;
00148 
00149 };// end of class definition
00150 
00151 
00152 #endif // LL_LLFLEXIBLEOBJECT_H

Generated on Thu Jul 1 06:08:30 2010 for Second Life Viewer by  doxygen 1.4.7