llvoavatarself.h
上传用户:king477883
上传日期:2021-03-01
资源大小:9553k
文件大小:14k
源码类别:

游戏引擎

开发平台:

C++ Builder

  1. /**
  2.  * @file llvoavatarself.h
  3.  * @brief Declaration of LLVOAvatar class which is a derivation fo
  4.  * LLViewerObject
  5.  *
  6.  * $LicenseInfo:firstyear=2001&license=viewergpl$
  7.  * 
  8.  * Copyright (c) 2001-2010, Linden Research, Inc.
  9.  * 
  10.  * Second Life Viewer Source Code
  11.  * The source code in this file ("Source Code") is provided by Linden Lab
  12.  * to you under the terms of the GNU General Public License, version 2.0
  13.  * ("GPL"), unless you have obtained a separate licensing agreement
  14.  * ("Other License"), formally executed by you and Linden Lab.  Terms of
  15.  * the GPL can be found in doc/GPL-license.txt in this distribution, or
  16.  * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  17.  * 
  18.  * There are special exceptions to the terms and conditions of the GPL as
  19.  * it is applied to this Source Code. View the full text of the exception
  20.  * in the file doc/FLOSS-exception.txt in this software distribution, or
  21.  * online at
  22.  * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  23.  * 
  24.  * By copying, modifying or distributing this software, you acknowledge
  25.  * that you have read and understood your obligations described above,
  26.  * and agree to abide by those obligations.
  27.  * 
  28.  * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  29.  * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  30.  * COMPLETENESS OR PERFORMANCE.
  31.  * $/LicenseInfo$
  32.  */
  33. #ifndef LL_LLVOAVATARSELF_H
  34. #define LL_LLVOAVATARSELF_H
  35. #include "llviewertexture.h"
  36. #include "llvoavatar.h"
  37. struct LocalTextureData;
  38. //------------------------------------------------------------------------
  39. // LLVOAvatarSelf
  40. //------------------------------------------------------------------------
  41. class LLVOAvatarSelf :
  42. public LLVOAvatar
  43. {
  44. /********************************************************************************
  45.  **                                                                            **
  46.  **                    INITIALIZATION
  47.  **/
  48. public:
  49. LLVOAvatarSelf(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp);
  50. virtual  ~LLVOAvatarSelf();
  51. virtual void markDead();
  52. virtual void  initInstance(); // Called after construction to initialize the class.
  53. protected:
  54. /*virtual*/ BOOL loadAvatar();
  55. BOOL loadAvatarSelf();
  56. BOOL buildSkeletonSelf(const LLVOAvatarSkeletonInfo *info);
  57. BOOL buildMenus();
  58. /*virtual*/ BOOL loadLayersets();
  59. /**                    Initialization
  60.  **                                                                            **
  61.  *******************************************************************************/
  62. /********************************************************************************
  63.  **                                                                            **
  64.  **                    INHERITED
  65.  **/
  66. //--------------------------------------------------------------------
  67. // LLViewerObject interface and related
  68. //--------------------------------------------------------------------
  69. public:
  70. /*virtual*/ void  updateRegion(LLViewerRegion *regionp);
  71. //--------------------------------------------------------------------
  72. // LLCharacter interface and related
  73. //--------------------------------------------------------------------
  74. public:
  75. /*virtual*/ void  stopMotionFromSource(const LLUUID& source_id);
  76. /*virtual*/ void  requestStopMotion(LLMotion* motion);
  77. /*virtual*/ LLJoint* getJoint(const std::string &name);
  78. /*virtual*/ BOOL setVisualParamWeight(LLVisualParam *which_param, F32 weight, BOOL upload_bake = FALSE );
  79. /*virtual*/ BOOL setVisualParamWeight(const char* param_name, F32 weight, BOOL upload_bake = FALSE );
  80. /*virtual*/ BOOL setVisualParamWeight(S32 index, F32 weight, BOOL upload_bake = FALSE );
  81. /*virtual*/ void updateVisualParams();
  82. /*virtual*/ void idleUpdateAppearanceAnimation();
  83. private:
  84. // helper function. Passed in param is assumed to be in avatar's parameter list.
  85. BOOL setParamWeight(LLViewerVisualParam *param, F32 weight, BOOL upload_bake = FALSE );
  86. /**                    Initialization
  87.  **                                                                            **
  88.  *******************************************************************************/
  89. /********************************************************************************
  90.  **                                                                            **
  91.  **                    STATE
  92.  **/
  93. public:
  94. /*virtual*/ bool  isSelf() const { return true; }
  95. //--------------------------------------------------------------------
  96. // Updates
  97. //--------------------------------------------------------------------
  98. public:
  99. /*virtual*/ BOOL  updateCharacter(LLAgent &agent);
  100. /*virtual*/ void  idleUpdateTractorBeam();
  101. //--------------------------------------------------------------------
  102. // Loading state
  103. //--------------------------------------------------------------------
  104. public:
  105. /*virtual*/ BOOL    updateIsFullyLoaded();
  106. private:
  107. BOOL                mIsBaked; // are the stored baked textures up to date?
  108. //--------------------------------------------------------------------
  109. // Region state
  110. //--------------------------------------------------------------------
  111. private:
  112. U64 mLastRegionHandle;
  113. LLFrameTimer mRegionCrossingTimer;
  114. S32 mRegionCrossingCount;
  115. /**                    State
  116.  **                                                                            **
  117.  *******************************************************************************/
  118. /********************************************************************************
  119.  **                                                                            **
  120.  **                    RENDERING
  121.  **/
  122. //--------------------------------------------------------------------
  123. // Render beam
  124. //--------------------------------------------------------------------
  125. protected:
  126. BOOL  needsRenderBeam();
  127. private:
  128. LLPointer<LLHUDEffectSpiral> mBeam;
  129. LLFrameTimer mBeamTimer;
  130. //--------------------------------------------------------------------
  131. // LLVOAvatar Constants
  132. //--------------------------------------------------------------------
  133. public:
  134. /*virtual*/ LLViewerTexture::EBoostLevel  getAvatarBoostLevel() const { return LLViewerTexture::BOOST_AVATAR_SELF; }
  135. /*virtual*/ LLViewerTexture::EBoostLevel  getAvatarBakedBoostLevel() const { return LLViewerTexture::BOOST_AVATAR_BAKED_SELF; }
  136. /*virtual*/ S32  getTexImageSize() const { return LLVOAvatar::getTexImageSize()*4; }
  137. /**                    Rendering
  138.  **                                                                            **
  139.  *******************************************************************************/
  140. /********************************************************************************
  141.  **                                                                            **
  142.  **                    TEXTURES
  143.  **/
  144. //--------------------------------------------------------------------
  145. // Loading status
  146. //--------------------------------------------------------------------
  147. public:
  148. /*virtual*/ bool hasPendingBakedUploads() const;
  149. S32 getLocalDiscardLevel(LLVOAvatarDefines::ETextureIndex type, U32 index) const;
  150. bool areTexturesCurrent() const;
  151. BOOL isLocalTextureDataAvailable(const LLTexLayerSet* layerset) const;
  152. BOOL isLocalTextureDataFinal(const LLTexLayerSet* layerset) const;
  153. // If you want to check all textures of a given type, pass gAgentWearables.getWearableCount() for index
  154. /*virtual*/ BOOL    isTextureDefined(LLVOAvatarDefines::ETextureIndex type, U32 index) const;
  155. //--------------------------------------------------------------------
  156. // Local Textures
  157. //--------------------------------------------------------------------
  158. public:
  159. BOOL getLocalTextureGL(LLVOAvatarDefines::ETextureIndex type, LLViewerTexture** image_gl_pp, U32 index) const;
  160. LLViewerFetchedTexture* getLocalTextureGL(LLVOAvatarDefines::ETextureIndex type, U32 index) const;
  161. const LLUUID& getLocalTextureID(LLVOAvatarDefines::ETextureIndex type, U32 index) const;
  162. void setLocalTextureTE(U8 te, LLViewerTexture* image, U32 index);
  163. const LLUUID& grabLocalTexture(LLVOAvatarDefines::ETextureIndex type, U32 index) const;
  164. BOOL canGrabLocalTexture(LLVOAvatarDefines::ETextureIndex type, U32 index) const;
  165. /*virtual*/ void setLocalTexture(LLVOAvatarDefines::ETextureIndex type, LLViewerTexture* tex, BOOL baked_version_exits, U32 index);
  166. protected:
  167. /*virtual*/ void setBakedReady(LLVOAvatarDefines::ETextureIndex type, BOOL baked_version_exists, U32 index);
  168. void localTextureLoaded(BOOL succcess, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata);
  169. void getLocalTextureByteCount(S32* gl_byte_count) const;
  170. /*virtual*/ void addLocalTextureStats(LLVOAvatarDefines::ETextureIndex i, LLViewerFetchedTexture* imagep, F32 texel_area_ratio, BOOL rendered, BOOL covered_by_baked, U32 index);
  171. LLLocalTextureObject* getLocalTextureObject(LLVOAvatarDefines::ETextureIndex i, U32 index) const;
  172. private:
  173. static void onLocalTextureLoaded(BOOL succcess, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata);
  174. /*virtual*/ void setImage(const U8 te, LLViewerTexture *imagep, const U32 index); 
  175. /*virtual*/ LLViewerTexture* getImage(const U8 te, const U32 index) const;
  176. //--------------------------------------------------------------------
  177. // Baked textures
  178. //--------------------------------------------------------------------
  179. public:
  180. LLVOAvatarDefines::ETextureIndex getBakedTE(const LLTexLayerSet* layerset ) const;
  181. void setNewBakedTexture(LLVOAvatarDefines::EBakedTextureIndex i, const LLUUID &uuid);
  182. void setNewBakedTexture(LLVOAvatarDefines::ETextureIndex i, const LLUUID& uuid);
  183. void setCachedBakedTexture(LLVOAvatarDefines::ETextureIndex i, const LLUUID& uuid);
  184. void forceBakeAllTextures(bool slam_for_debug = false);
  185. static void processRebakeAvatarTextures(LLMessageSystem* msg, void**);
  186. protected:
  187. /*virtual*/ void removeMissingBakedTextures();
  188. //--------------------------------------------------------------------
  189. // Layers
  190. //--------------------------------------------------------------------
  191. public:
  192. void  requestLayerSetUploads();
  193. void requestLayerSetUpdate(LLVOAvatarDefines::ETextureIndex i);
  194. LLTexLayerSet* getLayerSet(LLVOAvatarDefines::ETextureIndex index) const;
  195. //--------------------------------------------------------------------
  196. // Composites
  197. //--------------------------------------------------------------------
  198. public:
  199. /* virtual */ void invalidateComposite(LLTexLayerSet* layerset, BOOL upload_result);
  200. /* virtual */ void invalidateAll();
  201. /* virtual */ void setCompositeUpdatesEnabled(BOOL b); // only works for self
  202. void setupComposites();
  203. void updateComposites();
  204. //--------------------------------------------------------------------
  205. // Scratch textures (used for compositing)
  206. //--------------------------------------------------------------------
  207. public:
  208. BOOL bindScratchTexture(LLGLenum format);
  209. static void deleteScratchTextures();
  210. protected:
  211. LLGLuint getScratchTexName(LLGLenum format, S32& components, U32* texture_bytes);
  212. private:
  213. static S32  sScratchTexBytes;
  214. static LLMap< LLGLenum, LLGLuint*> sScratchTexNames;
  215. static LLMap< LLGLenum, F32*> sScratchTexLastBindTime;
  216. /**                    Textures
  217.  **                                                                            **
  218.  *******************************************************************************/
  219. /********************************************************************************
  220.  **                                                                            **
  221.  **                    MESHES
  222.  **/
  223. protected:
  224. /*virtual*/ void   restoreMeshData();
  225. /**                    Meshes
  226.  **                                                                            **
  227.  *******************************************************************************/
  228. /********************************************************************************
  229.  **                                                                            **
  230.  **                    WEARABLES
  231.  **/
  232. public:
  233. /*virtual*/ BOOL isWearingWearableType(EWearableType type) const;
  234. void wearableUpdated(EWearableType type, BOOL upload_result);
  235. protected:
  236. U32 getNumWearables(LLVOAvatarDefines::ETextureIndex i) const;
  237. //--------------------------------------------------------------------
  238. // Attachments
  239. //--------------------------------------------------------------------
  240. public:
  241. void  updateAttachmentVisibility(U32 camera_mode);
  242. BOOL  isWearingAttachment(const LLUUID& inv_item_id) const;
  243. LLViewerObject*  getWornAttachment(const LLUUID& inv_item_id);
  244. const std::string   getAttachedPointName(const LLUUID& inv_item_id) const;
  245. /*virtual*/ const LLViewerJointAttachment *attachObject(LLViewerObject *viewer_object);
  246. /*virtual*/ BOOL  detachObject(LLViewerObject *viewer_object);
  247. //--------------------------------------------------------------------
  248. // HUDs
  249. //--------------------------------------------------------------------
  250. private:
  251. LLViewerJoint*  mScreenp; // special purpose joint for HUD attachments
  252. /**                    Attachments
  253.  **                                                                            **
  254.  *******************************************************************************/
  255. /********************************************************************************
  256.  **                                                                            **
  257.  **                    APPEARANCE
  258.  **/
  259. public:
  260. static void onCustomizeStart();
  261. static void onCustomizeEnd();
  262. //--------------------------------------------------------------------
  263. // Visibility
  264. //--------------------------------------------------------------------
  265. public:
  266. bool sendAppearanceMessage(LLMessageSystem *mesgsys) const;
  267. /**                    Appearance
  268.  **                                                                            **
  269.  *******************************************************************************/
  270. /********************************************************************************
  271.  **                                                                            **
  272.  **                    DIAGNOSTICS
  273.  **/
  274. public:
  275. static void dumpTotalLocalTextureByteCount();
  276. void dumpLocalTextures() const;
  277. static void dumpScratchTextureByteCount();
  278. /**                    Diagnostics
  279.  **                                                                            **
  280.  *******************************************************************************/
  281. };
  282. #endif // LL_VO_AVATARSELF_H