summaryrefslogtreecommitdiff
path: root/indra/llprimitive/llmaterial.h
blob: 81f41ddc511d46f93e368d83ee42c6ef8b4262f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/**
 * @file llmaterial.h
 * @brief Material definition
 *
 * $LicenseInfo:firstyear=2006&license=viewerlgpl$
 * Second Life Viewer Source Code
 * Copyright (C) 2010, Linden Research, Inc.
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation;
 * version 2.1 of the License only.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 * 
 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 * $/LicenseInfo$
 */

#ifndef LL_LLMATERIAL_H
#define LL_LLMATERIAL_H

#include "llmaterialid.h"
#include "llsd.h"
#include "v4coloru.h"
#include "llpointer.h"
#include "llrefcount.h"

class LLMaterial : public LLRefCount
{
public:

    typedef enum
    {
        DIFFUSE_ALPHA_MODE_NONE = 0,
        DIFFUSE_ALPHA_MODE_BLEND = 1,
        DIFFUSE_ALPHA_MODE_MASK = 2,
        DIFFUSE_ALPHA_MODE_EMISSIVE = 3,
        DIFFUSE_ALPHA_MODE_DEFAULT = 4,
    } eDiffuseAlphaMode;

    typedef enum
    {
        SHADER_COUNT = 16,
        ALPHA_SHADER_COUNT = 4
    } eShaderCount;

    static const U8         DEFAULT_SPECULAR_LIGHT_EXPONENT = ((U8)(0.2f * 255));
    static const LLColor4U  DEFAULT_SPECULAR_LIGHT_COLOR;
    static const U8         DEFAULT_ENV_INTENSITY = 0;

    LLMaterial();
    LLMaterial(const LLSD& material_data);

    LLSD asLLSD() const;
    void fromLLSD(const LLSD& material_data);

    const LLUUID&   getNormalID() const;
    void            setNormalID(const LLUUID& normal_id);

    void        getNormalOffset(F32& offset_x, F32& offset_y) const;
    F32         getNormalOffsetX() const;
    F32         getNormalOffsetY() const;

    void        setNormalOffset(F32 offset_x, F32 offset_y);
    void        setNormalOffsetX(F32 offset_x);
    void        setNormalOffsetY(F32 offset_y);

    void        getNormalRepeat(F32& repeat_x, F32& repeat_y) const;
    F32         getNormalRepeatX() const;
    F32         getNormalRepeatY() const;

    void        setNormalRepeat(F32 repeat_x, F32 repeat_y);
    void        setNormalRepeatX(F32 repeat_x);
    void        setNormalRepeatY(F32 repeat_y);

    F32         getNormalRotation() const;
    void        setNormalRotation(F32 rot);

    const LLUUID& getSpecularID() const;
    void        setSpecularID(const LLUUID& specular_id);
    void        getSpecularOffset(F32& offset_x, F32& offset_y) const;
    F32         getSpecularOffsetX() const;
    F32         getSpecularOffsetY() const;

    void        setSpecularOffset(F32 offset_x, F32 offset_y);
    void        setSpecularOffsetX(F32 offset_x);
    void        setSpecularOffsetY(F32 offset_y);

    void        getSpecularRepeat(F32& repeat_x, F32& repeat_y) const;
    F32         getSpecularRepeatX() const;
    F32         getSpecularRepeatY() const;

    void        setSpecularRepeat(F32 repeat_x, F32 repeat_y);
    void        setSpecularRepeatX(F32 repeat_x);
    void        setSpecularRepeatY(F32 repeat_y);

    F32         getSpecularRotation() const;
    void        setSpecularRotation(F32 rot);

    const LLColor4U getSpecularLightColor() const;
    void        setSpecularLightColor(const LLColor4U& color);
    U8          getSpecularLightExponent() const;
    void        setSpecularLightExponent(U8 exponent);
    U8          getEnvironmentIntensity() const;
    void        setEnvironmentIntensity(U8 intensity);
    U8          getDiffuseAlphaMode() const;
    void        setDiffuseAlphaMode(U8 alpha_mode);
    U8          getAlphaMaskCutoff() const;
    void        setAlphaMaskCutoff(U8 cutoff);

    bool        isNull() const;
    static const LLMaterial null;

    bool        operator == (const LLMaterial& rhs) const;
    bool        operator != (const LLMaterial& rhs) const;

    U32         getShaderMask(U32 alpha_mode, BOOL is_alpha);
    LLUUID      getHash() const;

protected:
    LLUUID      mNormalID;
    F32         mNormalOffsetX;
    F32         mNormalOffsetY;
    F32         mNormalRepeatX;
    F32         mNormalRepeatY;
    F32         mNormalRotation;

    LLUUID      mSpecularID;
    F32         mSpecularOffsetX;
    F32         mSpecularOffsetY;
    F32         mSpecularRepeatX;
    F32         mSpecularRepeatY;
    F32         mSpecularRotation;

    LLColor4U   mSpecularLightColor;
    U8          mSpecularLightExponent;
    U8          mEnvironmentIntensity;
    U8          mDiffuseAlphaMode;
    U8          mAlphaMaskCutoff;
};

typedef LLPointer<LLMaterial> LLMaterialPtr;

#endif // LL_LLMATERIAL_H