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
00051 const F32 FLEXIBLE_OBJECT_TIMESLICE = 0.003f;
00052 const U32 FLEXIBLE_OBJECT_MAX_LOD = 10;
00053
00054
00055
00056
00057
00058 struct LLFlexibleObjectSection
00059 {
00060
00061 LLVector2 mScale;
00062 LLQuaternion mAxisRotation;
00063
00064 LLVector3 mPosition;
00065 LLVector3 mVelocity;
00066 LLVector3 mDirection;
00067 LLQuaternion mRotation;
00068
00069 LLVector3 mdPosition;
00070
00071
00072 };
00073
00074
00075
00076
00077 class LLVolumeImplFlexible : public LLVolumeInterface
00078 {
00079 public:
00080 LLVolumeImplFlexible(LLViewerObject* volume, LLFlexibleObjectData* attributes);
00081
00082
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();
00100 void doFlexibleRebuild();
00101 void preRebuild();
00102
00103
00104 void setParentPositionAndRotationDirectly( LLVector3 p, LLQuaternion r );
00105 void setUsingCollisionSphere( bool u );
00106 void setCollisionSphere( LLVector3 position, F32 radius );
00107 void setRenderingCollisionSphere( bool r);
00108
00109 LLVector3 getEndPosition();
00110 LLQuaternion getEndRotation();
00111 LLVector3 getNodePosition( int nodeIndex );
00112 LLVector3 getAnchorPosition() const;
00113
00114 private:
00115
00116
00117
00118
00119 LLViewerObject* mVO;
00120 LLTimer mTimer;
00121 LLVector3 mAnchorPosition;
00122 LLVector3 mParentPosition;
00123 LLQuaternion mParentRotation;
00124 LLQuaternion mLastFrameRotation;
00125 LLQuaternion mLastSegmentRotation;
00126 BOOL mInitialized;
00127 BOOL mUpdated;
00128 LLFlexibleObjectData* mAttributes;
00129 LLFlexibleObjectSection mSection [ (1<<FLEXIBLE_OBJECT_MAX_SECTIONS)+1 ];
00130 S32 mInitializedRes;
00131 S32 mSimulateRes;
00132 S32 mRenderRes;
00133 U32 mFrameNum;
00134 LLVector3 mCollisionSpherePosition;
00135 F32 mCollisionSphereRadius;
00136 U32 mID;
00137
00138
00139
00140
00141 void setAttributesOfAllSections (LLVector3* inScale = NULL);
00142
00143 void remapSections(LLFlexibleObjectSection *source, S32 source_sections,
00144 LLFlexibleObjectSection *dest, S32 dest_sections);
00145
00146 public:
00147
00148 static F32 sUpdateFactor;
00149
00150 };
00151
00152
00153 #endif // LL_LLFLEXIBLEOBJECT_H