lltextureentry.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_LLTEXTUREENTRY_H
00033 #define LL_LLTEXTUREENTRY_H
00034 
00035 #include "lluuid.h"
00036 #include "v4color.h"
00037 #include "llsd.h"
00038 
00039 const S32 TEM_CHANGE_COLOR = 0x1;
00040 const S32 TEM_CHANGE_TEXTURE = 0x2;
00041 const S32 TEM_INVALID = 0x4;
00042 
00043 const S32 TEM_BUMPMAP_COUNT = 32;
00044 
00045 // The Bump Shiny Fullbright values are bits in an eight bit field:
00046 // +----------+
00047 // | SSFBBBBB | S = Shiny, F = Fullbright, B = Bumpmap
00048 // | 76543210 |
00049 // +----------+
00050 const S32 TEM_BUMP_MASK                 = 0x1f; // 5 bits
00051 const S32 TEM_FULLBRIGHT_MASK   = 0x01; // 1 bit
00052 const S32 TEM_SHINY_MASK                = 0x03; // 2 bits
00053 const S32 TEM_BUMP_SHINY_MASK   = (0xc0 | 0x1f);
00054 const S32 TEM_FULLBRIGHT_SHIFT  = 5;
00055 const S32 TEM_SHINY_SHIFT               = 6;
00056 
00057 // The Media Tex Gen values are bits in a bit field:
00058 // +----------+
00059 // | .....TTM | M = Media Flags (web page), T = LLTextureEntry::eTexGen, . = unused
00060 // | 76543210 |
00061 // +----------+
00062 const S32 TEM_MEDIA_MASK                = 0x01;
00063 const S32 TEM_TEX_GEN_MASK              = 0x06;
00064 const S32 TEM_TEX_GEN_SHIFT             = 1;
00065 
00066 
00067 class LLTextureEntry
00068 {
00069 public: 
00070 
00071         typedef enum e_texgen
00072         {
00073                 TEX_GEN_DEFAULT                 = 0x00,
00074                 TEX_GEN_PLANAR                  = 0x02,
00075                 TEX_GEN_SPHERICAL               = 0x04,
00076                 TEX_GEN_CYLINDRICAL             = 0x06
00077         } eTexGen;
00078 
00079         LLTextureEntry();
00080         LLTextureEntry(const LLUUID& tex_id);
00081         LLTextureEntry(const LLTextureEntry &rhs);
00082 
00083         LLTextureEntry &operator=(const LLTextureEntry &rhs);
00084     ~LLTextureEntry();
00085 
00086         bool operator==(const LLTextureEntry &rhs) const;
00087         bool operator!=(const LLTextureEntry &rhs) const;
00088 
00089         LLSD asLLSD() const;
00090         operator LLSD() const { return asLLSD(); }
00091         bool fromLLSD(LLSD& sd);
00092 
00093         void init(const LLUUID& tex_id, F32 scale_s, F32 scale_t, F32 offset_s, F32 offset_t, F32 rotation, U8 bump);
00094 
00095         // These return a TEM_ flag from above to indicate if something changed.
00096         S32  setID (const LLUUID &tex_id);
00097         S32  setColor(const LLColor4 &color);
00098         S32  setColor(const LLColor3 &color);
00099         S32  setAlpha(const F32 alpha);
00100         S32  setScale(F32 s, F32 t);
00101         S32  setOffset(F32 s, F32 t);
00102         S32  setRotation(F32 theta);
00103 
00104         S32  setBumpmap(U8 bump);
00105         S32  setFullbright(U8 bump);
00106         S32  setShiny(U8 bump);
00107         S32  setBumpShiny(U8 bump);
00108         S32  setBumpShinyFullbright(U8 bump);
00109 
00110         S32  setMediaFlags(U8 media_flags);
00111         S32      setTexGen(U8 texGen);
00112         S32  setMediaTexGen(U8 media);
00113     S32  setGlow(F32 glow);
00114         
00115         const LLUUID &getID() const { return mID; }
00116         const LLColor4 &getColor() const { return mColor; }
00117         void getScale(F32 *s, F32 *t) const { *s = mScaleS; *t = mScaleT; }
00118         void getOffset(F32 *s, F32 *t) const { *s = mOffsetS; *t = mOffsetT; }
00119         F32  getRotation() const { return mRotation; }
00120         void getRotation(F32 *theta) const { *theta = mRotation; }
00121 
00122         U8       getBumpmap() const { return mBump & TEM_BUMP_MASK; }
00123         U8       getFullbright() const { return (mBump>>TEM_FULLBRIGHT_SHIFT) & TEM_FULLBRIGHT_MASK; }
00124         U8       getShiny() const { return (mBump>>TEM_SHINY_SHIFT) & TEM_SHINY_MASK; }
00125         U8       getBumpShiny() const { return mBump & TEM_BUMP_SHINY_MASK; }
00126         U8       getBumpShinyFullbright() const { return mBump; }
00127 
00128         U8       getMediaFlags() const { return mMediaFlags & TEM_MEDIA_MASK; }
00129         U8       getTexGen() const      { return mMediaFlags & TEM_TEX_GEN_MASK; }
00130         U8       getMediaTexGen() const { return mMediaFlags; }
00131     F32  getGlow() const { return mGlow; }
00132         
00133         // Media flags
00134         enum { MF_NONE = 0x0, MF_WEB_PAGE = 0x1 };
00135 
00136 public:
00137         F32                 mScaleS;                // S, T offset
00138         F32                 mScaleT;                // S, T offset
00139         F32                 mOffsetS;               // S, T offset
00140         F32                 mOffsetT;               // S, T offset
00141         F32                 mRotation;              // anti-clockwise rotation in rad about the bottom left corner
00142 
00143         static const LLTextureEntry null;
00144 protected:
00145         LLUUID                          mID;                                    // Texture GUID
00146         LLColor4                        mColor;
00147         U8                                      mBump;                                  // Bump map, shiny, and fullbright
00148         U8                                      mMediaFlags;                    // replace with web page, movie, etc.
00149         F32                 mGlow;
00150 
00151         // NOTE: when adding new data to this class, in addition to adding it to the serializers asLLSD/fromLLSD and the
00152         // message packers (e.g. LLPrimitive::packTEMessage) you must also implement its copy in LLPrimitive::copyTEs()
00153 
00154         
00155 };
00156 
00157 #endif

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