From 8ee81f98ea093d6bae70ba493a9d11a4ce576622 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Thu, 9 Apr 2009 14:51:18 +0000 Subject: * Implements IObject.Materials[].* * This lets you do things like IObject.Materials[0].Texture = new UUID("0000-..."); --- .../Scripting/Minimodule/Graphics.cs | 2 +- .../Scripting/Minimodule/SOPObject.cs | 2 +- .../Scripting/Minimodule/SOPObjectMaterial.cs | 91 ++++++++++++++++++++++ 3 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectMaterial.cs diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs index 4de249f..44bae5c 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs @@ -25,7 +25,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule AssetBase asset = new AssetBase(); asset.FullID = UUID.Random(); asset.Data = OpenJPEG.EncodeFromImage(data, lossless); - asset.Name = "MRMDynamicImage" + Util.RandomClass.Next(1, 10000); + asset.Name = "MRMDynamicImage"; asset.Type = 0; asset.Description = "MRM Image"; asset.Local = false; diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index 75ec33a..d6c3f7f 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs @@ -167,7 +167,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule for (int i = 0; i < rets.Length;i++ ) { - //rets[i] = new ObjectFace + rets[i] = new SOPObjectMaterial(i, sop); } return rets; diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectMaterial.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectMaterial.cs new file mode 100644 index 0000000..94de09e --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectMaterial.cs @@ -0,0 +1,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(); } + } + } +} -- cgit v1.1