llcape.h

Go to the documentation of this file.
00001 
00032 #ifndef LLCAPE_H
00033 #define LLCAPE_H
00034 
00035 #include "llviewerobject.h"
00036 
00037 class LLVolumeImplFlexible;
00038 
00039 //-----------------------------------------------------------------------------------
00040 // Default setting for the attributes of a cloth object...
00041 //-----------------------------------------------------------------------------------
00042 const F32               CLOTH_MIN_LENGTH                                = 0.2f;
00043 const F32               CLOTH_DEFAULT_LENGTH                    = 1.5f;
00044 const F32               CLOTH_MAX_LENGTH                                = 2.0f;
00045 
00046 const F32               CLOTH_MIN_TENSION                               = 0.0f;
00047 const F32               CLOTH_DEFAULT_TENSION                   = 1.0f;
00048 const F32               CLOTH_MAX_TENSION                               = 10.0f;
00049 
00050 const F32               CLOTH_MIN_GRAVITY                               = FLEXIBLE_OBJECT_MIN_GRAVITY;
00051 const F32               CLOTH_DEFAULT_GRAVITY                   = 0.3f;
00052 const F32               CLOTH_MAX_GRAVITY                               = FLEXIBLE_OBJECT_MAX_GRAVITY;
00053 
00054 const F32               CLOTH_MIN_PITCH                                 = -1.0f;
00055 const F32               CLOTH_DEFAULT_PITCH                             = 0.1f;
00056 const F32               CLOTH_MAX_PITCH                                 = 1.0f;
00057 
00058 const F32               CLOTH_MIN_AIR_FRICTION                  = FLEXIBLE_OBJECT_MIN_AIR_FRICTION;
00059 const F32               CLOTH_DEFAULT_AIR_FRICTION              = 6.0f;
00060 const F32               CLOTH_MAX_AIR_FRICTION                  = FLEXIBLE_OBJECT_MAX_AIR_FRICTION;
00061 
00062 const F32               CLOTH_MIN_WIND_SENSITIVITY                      = FLEXIBLE_OBJECT_MIN_WIND_SENSITIVITY;
00063 const F32               CLOTH_DEFAULT_WIND_SENSITIVITY          = 0.0f;
00064 const F32               CLOTH_MAX_WIND_SENSITIVITY                      = FLEXIBLE_OBJECT_MAX_WIND_SENSITIVITY;
00065 
00066 const F32               CLOTH_MIN_CIRCLE_WRAP_AMOUNT    = 0.0f;
00067 const F32               CLOTH_DEFAULT_CIRCLE_WRAP_AMOUNT= 0.5f;
00068 const F32               CLOTH_MAX_CIRCLE_WRAP_AMOUNT    = 1.0f;
00069 
00070 const F32               CLOTH_MIN_WIDTH                                 = 0.01f;
00071 const F32               CLOTH_DEFAULT_WIDTH                             = 0.4f;
00072 const F32               CLOTH_MAX_WIDTH                                 = 1.0f;
00073 
00074 const int               CLOTH_MIN_STRANDS                               = 2;
00075 const int               CLOTH_DEFAULT_NUM_STRANDS               = 4;
00076 const int               CLOTH_MAX_STRANDS                               = 8;
00077 
00078 const int               CLOTH_MIN_SEGMENTS                              = 1;
00079 const int               CLOTH_DEFAULT_NUM_SEGMENTS              = 4;
00080 const int               CLOTH_MAX_SEGMENTS                              = 8;
00081 
00082 const int               CLOTH_MIN_TEXTURE_INDEX                 = 1;
00083 const int               CLOTH_DEFAULT_TEXTURE_INDEX             = 1;
00084 const int               CLOTH_MAX_TEXTURE_INDEX                 = 7;
00085 
00086 const F32               CLOTH_MIN_AVATAR_COLLISION_SPHERE_RADIUS        = 0.0f;
00087 const F32               CLOTH_DEFAULT_AVATAR_COLLISION_SPHERE_RADIUS= 0.1f;
00088 const F32               CLOTH_MAX_AVATAR_COLLISION_SPHERE_RADIUS        = 3.0f;
00089 
00090 const F32               CLOTH_MIN_AVATAR_COLLISION_SPHERE_RIGHT_OFFSET          = -2.0f;
00091 const F32               CLOTH_DEFAULT_AVATAR_COLLISION_SPHERE_RIGHT_OFFSET      = 0.0f;
00092 const F32               CLOTH_MAX_AVATAR_COLLISION_SPHERE_RIGHT_OFFSET          = 2.0f;
00093 
00094 const F32               CLOTH_MIN_AVATAR_COLLISION_SPHERE_UP_OFFSET             = -2.0f;
00095 const F32               CLOTH_DEFAULT_AVATAR_COLLISION_SPHERE_UP_OFFSET = 0.0f;
00096 const F32               CLOTH_MAX_AVATAR_COLLISION_SPHERE_UP_OFFSET             = 2.0f;
00097 
00098 const F32               CLOTH_MIN_AVATAR_COLLISION_SPHERE_FORWARD_OFFSET                = -2.0f;
00099 const F32               CLOTH_DEFAULT_AVATAR_COLLISION_SPHERE_FORWARD_OFFSET    = 0.0f;
00100 const F32               CLOTH_MAX_AVATAR_COLLISION_SPHERE_FORWARD_OFFSET                = 2.0f;
00101 
00102 const LLString  CLOTH_DEFAULT_TEXTURE_FILENAME                          = "not_specified";
00103 const bool              CLOTH_DEFAULT_VISUALIZE_STRANDS                         = false;
00104 const bool              CLOTH_DEFAULT_VISUALIZE_COLLISION_SPHERE        = false;
00105 
00106 const bool              CLOTH_DEFAULT_USING_AVATAR_COLLISION_SPHERE                             = false;
00107 const LLVector3 CLOTH_DEFAULT_AVATAR_COLLISION_SPHERE_POSITION_OFFSET   = LLVector3::zero;
00108 
00109 
00110 //-------------------------------------------------
00111 // This structure is also used in the part of the 
00112 // code that creates new cloth objects.
00113 //-------------------------------------------------
00114 struct LLClothAttributes
00115 {
00116         int                             mTextureIndex;
00117         LLString                mTextureFileName;
00118         bool                    mVisualizeStrands;
00119         bool                    mVisualizeAvCollisionSphere;
00120         int                             mNumStrands;
00121         int                             mNumSegments;
00122         F32                             mWidth;
00123         F32                             mPitch;
00124         F32                             mLength;
00125         F32                             mTension;
00126         F32                             mGravity;
00127         F32                             mAirFriction;   
00128         F32                             mWindSensitivity;       
00129         F32                             mCircleWrapAmount;
00130         bool                    mUsingAvatarCollisionSphere;
00131         F32                             mAvatarCollisionSphereRightOffset;
00132         F32                             mAvatarCollisionSphereUpOffset;
00133         F32                             mAvatarCollisionSphereForwardOffset;
00134         F32                             mAvatarCollisionSphereRadius;
00135 
00136 
00137 
00138         //------ the constructor for the structure ------------
00139         LLClothAttributes()
00140         {
00141                 mTextureFileName                = CLOTH_DEFAULT_TEXTURE_FILENAME;
00142                 mVisualizeStrands               = CLOTH_DEFAULT_VISUALIZE_STRANDS;
00143                 mNumStrands                             = CLOTH_DEFAULT_NUM_STRANDS;
00144                 mNumSegments                    = CLOTH_DEFAULT_NUM_SEGMENTS;
00145                 mWidth                                  = CLOTH_DEFAULT_WIDTH;
00146                 mLength                                 = CLOTH_DEFAULT_LENGTH;
00147                 mPitch                                  = CLOTH_DEFAULT_PITCH;
00148                 mTension                                = CLOTH_DEFAULT_TENSION;
00149                 mGravity                                = CLOTH_DEFAULT_GRAVITY;
00150                 mAirFriction                    = CLOTH_DEFAULT_AIR_FRICTION;
00151                 mWindSensitivity                = CLOTH_DEFAULT_WIND_SENSITIVITY;
00152                 mCircleWrapAmount               = CLOTH_DEFAULT_CIRCLE_WRAP_AMOUNT;
00153                 mTextureIndex                   = CLOTH_DEFAULT_TEXTURE_INDEX;
00154         }
00155 };// end of attributes structure
00156 
00157 
00158 
00159 //---------------------------------------------------------
00160 // The LLVOCloth class 
00161 //---------------------------------------------------------
00162 class LLVOCloth : public LLViewerObject
00163 {
00164         public:
00165                 LLVOCloth(const LLUUID &id, const LLPCode type, LLViewerRegion *regionp);
00166                 void    update();
00167                 void    render();
00168                 void    markAsDead();
00169 
00170                 //----------------------------------------------
00171                 // set stuff
00172                 //----------------------------------------------
00173                 void                            setAttributes( LLClothAttributes );
00174                 void                            setNumStrands( int num ); 
00175                 void                            setNumSegments( int num ); 
00176                 void                            setLength( F32 length ); 
00177                 void                            setTension( F32 t ); 
00178                 void                            setGravity( F32 g ); 
00179                 void                            setCircleWrapAmount( F32 n ); 
00180                 void                            setAirFriction( F32 a ); 
00181                 void                            setWindSensitivity( F32 w ); 
00182                 void                            setPitch( F32 p ); 
00183                 void                            setWidth( F32 n ); 
00184                 void                            setVisualizingStrands( bool v ); 
00185                 void                            setVisualizingAvCollisionSphere( bool v ); 
00186                 void                            setAvatarCollisionSphereRadius( F32 r ); 
00187                 void                            setAvatarCollisionSphereRight( F32 r ); 
00188                 void                            setAvatarCollisionSphereUp( F32 u ); 
00189                 void                            setAvatarCollisionSphereForward( F32 f); 
00190 
00191                 //----------------------------------------------
00192                 // get stuff
00193                 //----------------------------------------------
00194                 bool                            getVisualizingStrands() const; 
00195                 bool                            getVisualizingAvCollisionSphere() const; 
00196                 int                                     getNumStrands();
00197                 int                                     getNumSegments();
00198                 F32                                     getLength();
00199                 F32                                     getWidth();
00200                 F32                                     getCircleWrapAmount();
00201                 F32                                     getPitch();
00202                 F32                                     getTension();
00203                 F32                                     getGravity();
00204                 F32                                     getAirFriction();
00205                 F32                                     getWindSensitivity();
00206                 F32                                     getAvatarCollisionSphereRadius(); 
00207                 F32                                     getAvatarCollisionSphereRight(); 
00208                 F32                                     getAvatarCollisionSphereUp(); 
00209                 F32                                     getAvatarCollisionSphereForward(); 
00210 
00211         private:
00212                 //--------------------------------------
00213                 // private members
00214                 //--------------------------------------
00215                 LLClothAttributes       mAttributes;                                    // these determine the characteristics of the cloth
00216                 LLVector3                       mAvatarCollisionSpherePosition; // derived from the avatar
00217                 // Backlink only; don't make this an LLPointer.
00218                 LLViewerObject*                 mDummyVO [ CLOTH_MAX_STRANDS ];
00219                 LLVolumeImplFlexible*   mStrand [ CLOTH_MAX_STRANDS ];  // the array of strands that make up the cloth
00220 
00221 
00222                 //--------------------------------------
00223                 // private methods
00224                 //--------------------------------------
00225                 void updateVirtualServer();
00226                 void generateStrands();
00227 
00228 };// end of class definition
00229 
00230 
00231 #endif // LL_CLOTH_H

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