llviewerjointmesh.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_LLVIEWERJOINTMESH_H
00033 #define LL_LLVIEWERJOINTMESH_H
00034 
00035 #include "llviewerjoint.h"
00036 #include "llviewerimage.h"
00037 #include "llpolymesh.h"
00038 #include "v4color.h"
00039 #include "llapr.h"
00040 
00041 class LLDrawable;
00042 class LLFace;
00043 class LLCharacter;
00044 class LLTexLayerSet;
00045 
00046 typedef enum e_avatar_render_pass
00047 {
00048         AVATAR_RENDER_PASS_SINGLE,
00049         AVATAR_RENDER_PASS_CLOTHING_INNER,
00050         AVATAR_RENDER_PASS_CLOTHING_OUTER
00051 } EAvatarRenderPass;
00052 
00053 class LLSkinJoint
00054 {
00055 public:
00056         LLSkinJoint();
00057         ~LLSkinJoint();
00058         BOOL setupSkinJoint( LLViewerJoint *joint);
00059 
00060         LLViewerJoint   *mJoint;
00061         LLVector3               mRootToJointSkinOffset;
00062         LLVector3               mRootToParentJointSkinOffset;
00063 };
00064 
00065 //-----------------------------------------------------------------------------
00066 // class LLViewerJointMesh
00067 //-----------------------------------------------------------------------------
00068 class LLViewerJointMesh : public LLViewerJoint
00069 {
00070 protected:
00071         LLColor4                                        mColor;                 // color value
00072 //      LLColor4                                        mSpecular;              // specular color (always white for now)
00073         F32                                                     mShiny;                 // shiny value
00074         LLPointer<LLViewerImage>        mTexture;               // ptr to a global texture
00075         LLTexLayerSet*                          mLayerSet;              // ptr to a layer set owned by the avatar
00076         U32                                             mTestImageName;         // handle to a temporary texture for previewing uploads
00077         LLPolyMesh*                                     mMesh;                  // ptr to a global polymesh
00078         BOOL                                            mCullBackFaces; // true by default
00079         LLFace*                                         mFace;                  // ptr to a face w/ AGP copy of mesh
00080 
00081         U32                                                     mFaceIndexCount;
00082         BOOL                                            mIsTransparent;
00083 
00084         U32                                                     mNumSkinJoints;
00085         LLSkinJoint*                            mSkinJoints;
00086         S32                                                     mMeshID;
00087 
00088 public:
00089         static BOOL                                     sPipelineRender;
00090         //RN: this is here for testing purposes
00091         static U32                                      sClothingMaskImageName;
00092         static EAvatarRenderPass        sRenderPass;
00093         static LLColor4                         sClothingInnerColor;
00094 
00095 public:
00096         // Constructor
00097         LLViewerJointMesh();
00098 
00099         // Destructor
00100         virtual ~LLViewerJointMesh();
00101 
00102         // Gets the shape color
00103         void getColor( F32 *red, F32 *green, F32 *blue, F32 *alpha );
00104 
00105         // Sets the shape color
00106         void setColor( F32 red, F32 green, F32 blue, F32 alpha );
00107 
00108         // Sets the shininess
00109         void setSpecular( const LLColor4& color, F32 shiny ) { /*mSpecular = color;*/ mShiny = shiny; };
00110 
00111         // Sets the shape texture
00112         void setTexture( LLViewerImage *texture );
00113 
00114         void setTestTexture( U32 name ) { mTestImageName = name; }
00115 
00116         // Sets layer set responsible for a dynamic shape texture (takes precedence over normal texture)
00117         void setLayerSet( LLTexLayerSet* layer_set );
00118 
00119         // Gets the poly mesh
00120         LLPolyMesh *getMesh();
00121 
00122         // Sets the poly mesh
00123         void setMesh( LLPolyMesh *mesh );
00124 
00125         // Sets up joint matrix data for rendering
00126         void setupJoint(LLViewerJoint* current_joint);
00127 
00128         // Render time method to upload batches of joint matrices
00129         void uploadJointMatrices();
00130 
00131         // Sets ID for picking
00132         void setMeshID( S32 id ) {mMeshID = id;}
00133 
00134         // Gets ID for picking
00135         S32 getMeshID() { return mMeshID; }     
00136 
00137         // overloaded from base class
00138         /*virtual*/ void drawBone();
00139         /*virtual*/ BOOL isTransparent();
00140         /*virtual*/ U32 drawShape( F32 pixelArea, BOOL first_pass );
00141 
00142         /*virtual*/ void updateFaceSizes(U32 &num_vertices, U32& num_indices, F32 pixel_area);
00143         /*virtual*/ void updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_wind = FALSE);
00144         /*virtual*/ BOOL updateLOD(F32 pixel_area, BOOL activate);
00145         /*virtual*/ void updateGeometry();
00146         /*virtual*/ void dump();
00147 
00148         void setIsTransparent(BOOL is_transparent) { mIsTransparent = is_transparent; }
00149 
00150         /*virtual*/ BOOL isAnimatable() { return FALSE; }
00151         void writeCAL3D(apr_file_t* fp, S32 material_num, LLCharacter* characterp);
00152 
00153         // Avatar vertex skinning is a significant performance issue on computers
00154         // with avatar vertex programs turned off (for example, most Macs).  We
00155         // therefore have custom versions that use SIMD instructions.
00156         //
00157         // These functions require compiler options for SSE2, SSE, or neither, and
00158         // hence are contained in separate individual .cpp files.  JC
00159         static void updateGeometryOriginal(LLFace* face, LLPolyMesh* mesh);
00160         // generic vector code, used for Altivec
00161         static void updateGeometryVectorized(LLFace* face, LLPolyMesh* mesh);
00162         static void updateGeometrySSE(LLFace* face, LLPolyMesh* mesh);
00163         static void updateGeometrySSE2(LLFace* face, LLPolyMesh* mesh);
00164 
00165         // Use a fuction pointer to indicate which version we are running.
00166         static void (*sUpdateGeometryFunc)(LLFace* face, LLPolyMesh* mesh);
00167 
00168 private:
00169         // Allocate skin data
00170         BOOL allocateSkinData( U32 numSkinJoints );
00171 
00172         S32 getBoundJointsByIndex(S32 index, S32 &joint_a, S32& joint_b);
00173 
00174         // Free skin data
00175         void freeSkinData();
00176 };
00177 
00178 #endif // LL_LLVIEWERJOINTMESH_H

Generated on Thu Jul 1 06:09:28 2010 for Second Life Viewer by  doxygen 1.4.7