aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llprimitive/lltextureentry.h
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llprimitive/lltextureentry.h')
-rw-r--r--linden/indra/llprimitive/lltextureentry.h145
1 files changed, 145 insertions, 0 deletions
diff --git a/linden/indra/llprimitive/lltextureentry.h b/linden/indra/llprimitive/lltextureentry.h
new file mode 100644
index 0000000..b06f9a1
--- /dev/null
+++ b/linden/indra/llprimitive/lltextureentry.h
@@ -0,0 +1,145 @@
1/**
2 * @file lltextureentry.h
3 * @brief LLTextureEntry base class
4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 *
7 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement
10 * ("Other License"), formally executed by you and Linden Lab. Terms of
11 * the GPL can be found in doc/GPL-license.txt in this distribution, or
12 * online at http://secondlife.com/developers/opensource/gplv2
13 *
14 * There are special exceptions to the terms and conditions of the GPL as
15 * it is applied to this Source Code. View the full text of the exception
16 * in the file doc/FLOSS-exception.txt in this software distribution, or
17 * online at http://secondlife.com/developers/opensource/flossexception
18 *
19 * By copying, modifying or distributing this software, you acknowledge
20 * that you have read and understood your obligations described above,
21 * and agree to abide by those obligations.
22 *
23 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
25 * COMPLETENESS OR PERFORMANCE.
26 */
27
28#ifndef LL_LLTEXTUREENTRY_H
29#define LL_LLTEXTUREENTRY_H
30
31#include "lluuid.h"
32#include "v4color.h"
33#include "llsd.h"
34
35const S32 TEM_CHANGE_COLOR = 0x1;
36const S32 TEM_CHANGE_TEXTURE = 0x2;
37const S32 TEM_INVALID = 0x4;
38
39const S32 TEM_BUMPMAP_COUNT = 32;
40
41// The Bump Shiny Fullbright values are bits in an eight bit field:
42// +----------+
43// | SSFBBBBB | S = Shiny, F = Fullbright, B = Bumpmap
44// | 76543210 |
45// +----------+
46const S32 TEM_BUMP_MASK = 0x1f; // 5 bits
47const S32 TEM_FULLBRIGHT_MASK = 0x01; // 1 bit
48const S32 TEM_SHINY_MASK = 0x03; // 2 bits
49const S32 TEM_BUMP_SHINY_MASK = (0xc0 | 0x1f);
50const S32 TEM_FULLBRIGHT_SHIFT = 5;
51const S32 TEM_SHINY_SHIFT = 6;
52
53// The Media Tex Gen values are bits in a bit field:
54// +----------+
55// | .....TTM | M = Media Flags (web page), T = LLTextureEntry::eTexGen, . = unused
56// | 76543210 |
57// +----------+
58const S32 TEM_MEDIA_MASK = 0x01;
59const S32 TEM_TEX_GEN_MASK = 0x06;
60const S32 TEM_TEX_GEN_SHIFT = 1;
61
62
63class LLTextureEntry
64{
65public:
66
67 typedef enum e_texgen
68 {
69 TEX_GEN_DEFAULT = 0x00,
70 TEX_GEN_PLANAR = 0x02,
71 TEX_GEN_SPHERICAL = 0x04,
72 TEX_GEN_CYLINDRICAL = 0x06
73 } eTexGen;
74
75 LLTextureEntry();
76 LLTextureEntry(const LLUUID& tex_id);
77 LLTextureEntry(const LLTextureEntry &rhs);
78
79 LLTextureEntry &operator=(const LLTextureEntry &rhs);
80 ~LLTextureEntry();
81
82 bool operator==(const LLTextureEntry &rhs) const;
83 bool operator!=(const LLTextureEntry &rhs) const;
84
85 LLSD asLLSD() const;
86 operator LLSD() const { return asLLSD(); }
87 bool fromLLSD(LLSD& sd);
88
89 void init(const LLUUID& tex_id, F32 scale_s, F32 scale_t, F32 offset_s, F32 offset_t, F32 rotation, U8 bump);
90
91 // These return a TEM_ flag from above to indicate if something changed.
92 S32 setID (const LLUUID &tex_id);
93 S32 setColor(const LLColor4 &color);
94 S32 setColor(const LLColor3 &color);
95 S32 setAlpha(const F32 alpha);
96 S32 setScale(F32 s, F32 t);
97 S32 setOffset(F32 s, F32 t);
98 S32 setRotation(F32 theta);
99
100 S32 setBumpmap(U8 bump);
101 S32 setFullbright(U8 bump);
102 S32 setShiny(U8 bump);
103 S32 setBumpShiny(U8 bump);
104 S32 setBumpShinyFullbright(U8 bump);
105
106 S32 setMediaFlags(U8 media_flags);
107 S32 setTexGen(U8 texGen);
108 S32 setMediaTexGen(U8 media);
109
110 const LLUUID &getID() const { return mID; }
111 const LLColor4 &getColor() const { return mColor; }
112 void getScale(F32 *s, F32 *t) const { *s = mScaleS; *t = mScaleT; }
113 void getOffset(F32 *s, F32 *t) const { *s = mOffsetS; *t = mOffsetT; }
114 F32 getRotation() const { return mRotation; }
115 void getRotation(F32 *theta) const { *theta = mRotation; }
116
117 U8 getBumpmap() const { return mBump & TEM_BUMP_MASK; }
118 U8 getFullbright() const { return (mBump>>TEM_FULLBRIGHT_SHIFT) & TEM_FULLBRIGHT_MASK; }
119 U8 getShiny() const { return (mBump>>TEM_SHINY_SHIFT) & TEM_SHINY_MASK; }
120 U8 getBumpShiny() const { return mBump & TEM_BUMP_SHINY_MASK; }
121 U8 getBumpShinyFullbright() const { return mBump; }
122
123 U8 getMediaFlags() const { return mMediaFlags & TEM_MEDIA_MASK; }
124 U8 getTexGen() const { return mMediaFlags & TEM_TEX_GEN_MASK; }
125 U8 getMediaTexGen() const { return mMediaFlags; }
126
127 // Media flags
128 enum { MF_NONE = 0x0, MF_WEB_PAGE = 0x1 };
129
130public:
131 F32 mScaleS; // S, T offset
132 F32 mScaleT; // S, T offset
133 F32 mOffsetS; // S, T offset
134 F32 mOffsetT; // S, T offset
135 F32 mRotation; // anti-clockwise rotation in rad about the bottom left corner
136
137 static const LLTextureEntry null;
138protected:
139 LLUUID mID; // Texture GUID
140 LLColor4 mColor;
141 U8 mBump; // Bump map, shiny, and fullbright
142 U8 mMediaFlags; // replace with web page, movie, etc.
143};
144
145#endif