refactoring out SetFaceColor
parent
ede3b9ab07
commit
481c00f50a
|
@ -2850,63 +2850,17 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
pa.VehicleRotationParam(param, rotation);
|
pa.VehicleRotationParam(param, rotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Set the color of prim faces
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="color"></param>
|
|
||||||
/// <param name="face"></param>
|
|
||||||
public void SetFaceColor(Vector3 color, int face)
|
|
||||||
{
|
|
||||||
Vector3 clippedColor = Util.Clip(color, 0.0f, 1.0f);
|
|
||||||
|
|
||||||
// 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 = clippedColor.X;
|
|
||||||
texcolor.G = clippedColor.Y;
|
|
||||||
texcolor.B = clippedColor.Z;
|
|
||||||
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 = clippedColor.X;
|
|
||||||
texcolor.G = clippedColor.Y;
|
|
||||||
texcolor.B = clippedColor.Z;
|
|
||||||
tex.FaceTextures[i].RGBA = texcolor;
|
|
||||||
}
|
|
||||||
texcolor = tex.DefaultTexture.RGBA;
|
|
||||||
texcolor.R = clippedColor.X;
|
|
||||||
texcolor.G = clippedColor.Y;
|
|
||||||
texcolor.B = clippedColor.Z;
|
|
||||||
tex.DefaultTexture.RGBA = texcolor;
|
|
||||||
}
|
|
||||||
UpdateTextureEntry(tex.GetBytes());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set the color & alpha of prim faces
|
/// Set the color & alpha of prim faces
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="face"></param>
|
/// <param name="face"></param>
|
||||||
/// <param name="color"></param>
|
/// <param name="color"></param>
|
||||||
/// <param name="alpha"></param>
|
/// <param name="alpha"></param>
|
||||||
public void SetFaceColorAlpha(int face, Vector3 color, double alpha)
|
public void SetFaceColorAlpha(int face, Vector3 color, double ?alpha)
|
||||||
{
|
{
|
||||||
Vector3 clippedColor = Util.Clip(color, 0.0f, 1.0f);
|
Vector3 clippedColor = Util.Clip(color, 0.0f, 1.0f);
|
||||||
float clippedAlpha = Util.Clip((float)alpha, 0.0f, 1.0f);
|
float clippedAlpha = alpha.HasValue ?
|
||||||
|
Util.Clip((float)alpha.Value, 0.0f, 1.0f) : 0;
|
||||||
|
|
||||||
// The only way to get a deep copy/ If we don't do this, we can
|
// The only way to get a deep copy/ If we don't do this, we can
|
||||||
// never detect color changes further down.
|
// never detect color changes further down.
|
||||||
|
@ -2919,7 +2873,10 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
texcolor.R = clippedColor.X;
|
texcolor.R = clippedColor.X;
|
||||||
texcolor.G = clippedColor.Y;
|
texcolor.G = clippedColor.Y;
|
||||||
texcolor.B = clippedColor.Z;
|
texcolor.B = clippedColor.Z;
|
||||||
texcolor.A = clippedAlpha;
|
if (alpha.HasValue)
|
||||||
|
{
|
||||||
|
texcolor.A = clippedAlpha;
|
||||||
|
}
|
||||||
tex.FaceTextures[face].RGBA = texcolor;
|
tex.FaceTextures[face].RGBA = texcolor;
|
||||||
UpdateTextureEntry(tex.GetBytes());
|
UpdateTextureEntry(tex.GetBytes());
|
||||||
return;
|
return;
|
||||||
|
@ -2934,14 +2891,20 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
texcolor.R = clippedColor.X;
|
texcolor.R = clippedColor.X;
|
||||||
texcolor.G = clippedColor.Y;
|
texcolor.G = clippedColor.Y;
|
||||||
texcolor.B = clippedColor.Z;
|
texcolor.B = clippedColor.Z;
|
||||||
texcolor.A = clippedAlpha;
|
if (alpha.HasValue)
|
||||||
|
{
|
||||||
|
texcolor.A = clippedAlpha;
|
||||||
|
}
|
||||||
tex.FaceTextures[i].RGBA = texcolor;
|
tex.FaceTextures[i].RGBA = texcolor;
|
||||||
}
|
}
|
||||||
texcolor = tex.DefaultTexture.RGBA;
|
texcolor = tex.DefaultTexture.RGBA;
|
||||||
texcolor.R = clippedColor.X;
|
texcolor.R = clippedColor.X;
|
||||||
texcolor.G = clippedColor.Y;
|
texcolor.G = clippedColor.Y;
|
||||||
texcolor.B = clippedColor.Z;
|
texcolor.B = clippedColor.Z;
|
||||||
texcolor.A = clippedAlpha;
|
if (alpha.HasValue)
|
||||||
|
{
|
||||||
|
texcolor.A = clippedAlpha;
|
||||||
|
}
|
||||||
tex.DefaultTexture.RGBA = texcolor;
|
tex.DefaultTexture.RGBA = texcolor;
|
||||||
}
|
}
|
||||||
UpdateTextureEntry(tex.GetBytes());
|
UpdateTextureEntry(tex.GetBytes());
|
||||||
|
|
|
@ -1377,7 +1377,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
if (face == ScriptBaseClass.ALL_SIDES)
|
if (face == ScriptBaseClass.ALL_SIDES)
|
||||||
face = SceneObjectPart.ALL_SIDES;
|
face = SceneObjectPart.ALL_SIDES;
|
||||||
|
|
||||||
m_host.SetFaceColor(color, face);
|
m_host.SetFaceColorAlpha(face, color, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetTexGen(SceneObjectPart part, int face,int style)
|
public void SetTexGen(SceneObjectPart part, int face,int style)
|
||||||
|
@ -3572,7 +3572,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
List<SceneObjectPart> parts = GetLinkParts(linknumber);
|
List<SceneObjectPart> parts = GetLinkParts(linknumber);
|
||||||
|
|
||||||
foreach (SceneObjectPart part in parts)
|
foreach (SceneObjectPart part in parts)
|
||||||
part.SetFaceColor(color, face);
|
part.SetFaceColorAlpha(face, color, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void llCreateLink(string target, int parent)
|
public void llCreateLink(string target, int parent)
|
||||||
|
|
Loading…
Reference in New Issue