diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 0535dcbeec..6741e5ef4a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2895,6 +2895,55 @@ namespace OpenSim.Region.Framework.Scenes } } + /// + /// Set the color & alpha of prim faces + /// + /// + /// + /// + public void SetFaceColorAlpha(int face, Vector3 color, double alpha) + { + // The only way to get a deep copy/ If we don't do this, we can + // never detect color changes further down. + Byte[] buf = Shape.Textures.GetBytes(); + Primitive.TextureEntry tex = new Primitive.TextureEntry(buf, 0, buf.Length); + Color4 texcolor; + if (face >= 0 && face < GetNumberOfSides()) + { + texcolor = tex.CreateFace((uint)face).RGBA; + texcolor.R = Util.Clip((float)color.X, 0.0f, 1.0f); + texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f); + texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f); + texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f); + tex.FaceTextures[face].RGBA = texcolor; + UpdateTextureEntry(tex.GetBytes()); + return; + } + else if (face == ALL_SIDES) + { + for (uint i = 0; i < GetNumberOfSides(); i++) + { + if (tex.FaceTextures[i] != null) + { + texcolor = tex.FaceTextures[i].RGBA; + texcolor.R = Util.Clip((float)color.X, 0.0f, 1.0f); + texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f); + texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f); + texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f); + tex.FaceTextures[i].RGBA = texcolor; + } + texcolor = tex.DefaultTexture.RGBA; + texcolor.R = Util.Clip((float)color.X, 0.0f, 1.0f); + texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f); + texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f); + texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f); + tex.DefaultTexture.RGBA = texcolor; + } + UpdateTextureEntry(tex.GetBytes()); + return; + } + } + /// /// Get the number of sides that this part has. /// diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 4645e7a799..dbbfbd38c0 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -7484,8 +7484,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api LSL_Vector color=rules.GetVector3Item(idx++); double alpha=(double)rules.GetLSLFloatItem(idx++); - part.SetFaceColor(color, face); - SetAlpha(part, alpha, face); + part.SetFaceColorAlpha(face, new Vector3((float)color.x, (float)color.y, (float)color.z), alpha); break;