aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectMaterial.cs
blob: 94de09e0acdf424e8227d94c56a718e81a2c882a (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
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Text;
using OpenMetaverse;
using OpenSim.Region.Framework.Scenes;

namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
{
    class SOPObjectMaterial : IObjectMaterial
    {
        private readonly int m_face;
        private readonly SceneObjectPart m_parent;

        public SOPObjectMaterial(int m_face, SceneObjectPart m_parent)
        {
            this.m_face = m_face;
            this.m_parent = m_parent;
        }

        public Color Color
        {
            get
            {
                Color4 res = GetTexface().RGBA;
                return Color.FromArgb((int) (res.A*255), (int) (res.R*255), (int) (res.G*255), (int) (res.B*255));
            }
            set
            {
                Primitive.TextureEntry tex = m_parent.Shape.Textures;
                Primitive.TextureEntryFace texface = tex.CreateFace((uint)m_face);
                texface.RGBA = new Color4(value.R,value.G,value.B,value.A);
                tex.FaceTextures[m_face] = texface;
                m_parent.UpdateTexture(tex);
            }
        }

        public UUID Texture
        {
            get
            {
                Primitive.TextureEntryFace texface = GetTexface();
                return texface.TextureID;
            }
            set
            {
                Primitive.TextureEntry tex = m_parent.Shape.Textures;
                Primitive.TextureEntryFace texface = tex.CreateFace((uint)m_face);
                texface.TextureID = value;
                tex.FaceTextures[m_face] = texface;
                m_parent.UpdateTexture(tex);
            }
        }

        private Primitive.TextureEntryFace GetTexface()
        {
            Primitive.TextureEntry tex = m_parent.Shape.Textures;
            return tex.GetFace((uint)m_face);
        }

        public TextureMapping Mapping
        {
            get { throw new System.NotImplementedException(); }
            set { throw new System.NotImplementedException(); }
        }

        public bool Bright
        {
            get { return GetTexface().Fullbright; }
            set { throw new System.NotImplementedException(); }
        }

        public double Bloom
        {
            get { return GetTexface().Glow; }
            set { throw new System.NotImplementedException(); }
        }

        public bool Shiny
        {
            get { return GetTexface().Shiny != Shininess.None; }
            set { throw new System.NotImplementedException(); }
        }

        public bool BumpMap
        {
            get { throw new System.NotImplementedException(); }
            set { throw new System.NotImplementedException(); }
        }
    }
}