From 31c4d599a077acb3c51aca5c891b70c4065997b3 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Thu, 8 May 2008 13:49:19 +0000 Subject: * Applying patch #1156 - More implementation work on llGetPrimitiveParams (Thanks middlelink!) --- .../Common/BuiltIn_Commands_BaseClass.cs | 4 +- .../ScriptEngine/Common/LSL_BuiltIn_Commands.cs | 177 ++++++++++++++++++++- .../Common/LSL_BuiltIn_Commands_Interface.cs | 3 +- 3 files changed, 179 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Common/BuiltIn_Commands_BaseClass.cs b/OpenSim/Region/ScriptEngine/Common/BuiltIn_Commands_BaseClass.cs index 49ddd3f..eccc6d9 100644 --- a/OpenSim/Region/ScriptEngine/Common/BuiltIn_Commands_BaseClass.cs +++ b/OpenSim/Region/ScriptEngine/Common/BuiltIn_Commands_BaseClass.cs @@ -1605,9 +1605,9 @@ namespace OpenSim.Region.ScriptEngine.Common return m_LSL_Functions.llGetGeometricCenter(); } - public void llGetPrimitiveParams() + public LSL_Types.list llGetPrimitiveParams(LSL_Types.list rules) { - m_LSL_Functions.llGetPrimitiveParams(); + return m_LSL_Functions.llGetPrimitiveParams(rules); } // diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs index 805a575..e3bec9d 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs @@ -4830,10 +4830,183 @@ namespace OpenSim.Region.ScriptEngine.Common return new LSL_Types.Vector3(m_host.GetGeometricCenter().X, m_host.GetGeometricCenter().Y, m_host.GetGeometricCenter().Z); } - public void llGetPrimitiveParams() + public LSL_Types.list llGetPrimitiveParams(LSL_Types.list rules) { m_host.AddScriptLPS(1); - NotImplemented("llGetPrimitiveParams"); + + LSL_Types.list res = new LSL_Types.list(); + int idx=0; + while(idx < rules.Length) + { + int code=Convert.ToInt32(rules.Data[idx++]); + int remain=rules.Length-idx; + + switch(code) + { + case 2: // PRIM_MATERIAL + res.Add(new LSL_Types.LSLInteger(m_host.Material)); + break; + + case 3: // PRIM_PHYSICS + if ((m_host.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.Physics) != 0) + res.Add(new LSL_Types.LSLInteger(1)); + else + res.Add(new LSL_Types.LSLInteger(0)); + break; + + case 4: // PRIM_TEMP_ON_REZ + if ((m_host.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.TemporaryOnRez) != 0) + res.Add(new LSL_Types.LSLInteger(1)); + else + res.Add(new LSL_Types.LSLInteger(0)); + break; + + case 5: // PRIM_PHANTOM + if ((m_host.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.Phantom) != 0) + res.Add(new LSL_Types.LSLInteger(1)); + else + res.Add(new LSL_Types.LSLInteger(0)); + break; + + case 6: // PRIM_POSITION + res.Add(new LSL_Types.Vector3(m_host.AbsolutePosition.X, + m_host.AbsolutePosition.Y, + m_host.AbsolutePosition.Z)); + break; + + case 7: // PRIM_SIZE + res.Add(new LSL_Types.Vector3(m_host.Scale.X, + m_host.Scale.Y, + m_host.Scale.Z)); + break; + + case 8: // PRIM_ROTATION + res.Add(new LSL_Types.Quaternion(m_host.RotationOffset.X, + m_host.RotationOffset.Y, + m_host.RotationOffset.Z, + m_host.RotationOffset.W)); + break; + + case 9: // PRIM_TYPE + // TODO-------------- + res.Add(new LSL_Types.LSLInteger(0)); + break; + + case 17: // PRIM_TEXTURE + if (remain < 1) + return res; + + int face=Convert.ToInt32(rules.Data[idx++]); + if (face == -1) + face = 0; + + LLObject.TextureEntry tex = m_host.Shape.Textures; + LLObject.TextureEntryFace texface = tex.GetFace((uint)face); + + res.Add(new LSL_Types.LSLString(texface.TextureID.ToString())); + res.Add(new LSL_Types.Vector3(texface.RepeatU, + texface.RepeatV, + 0)); + res.Add(new LSL_Types.Vector3(texface.OffsetU, + texface.OffsetV, + 0)); + res.Add(new LSL_Types.LSLFloat(texface.Rotation)); + break; + + case 18: // PRIM_COLOR + if (remain < 1) + return res; + + face=Convert.ToInt32(rules.Data[idx++]); + + tex = m_host.Shape.Textures; + LLColor texcolor; + if (face == -1) // TMP: Until we can determine number of sides, ALL_SIDES (-1) will return default color + texcolor = tex.DefaultTexture.RGBA; + else + texcolor = tex.GetFace((uint)face).RGBA; + res.Add(new LSL_Types.Vector3((255 - (texcolor.R * 255)) / 255, + (255 - (texcolor.G * 255)) / 255, + (255 - (texcolor.B * 255)) / 255)); + res.Add(new LSL_Types.LSLFloat((texcolor.A * 255) / 255)); + break; + + case 19: // PRIM_BUMP_SHINY + // TODO-------------- + if (remain < 1) + return res; + + face=Convert.ToInt32(rules.Data[idx++]); + + res.Add(new LSL_Types.LSLInteger(0)); + res.Add(new LSL_Types.LSLInteger(0)); + break; + + case 20: // PRIM_FULLBRIGHT + // TODO-------------- + if (remain < 1) + return res; + + face=Convert.ToInt32(rules.Data[idx++]); + + res.Add(new LSL_Types.LSLInteger(0)); + break; + + case 21: // PRIM_FLEXIBLE + PrimitiveBaseShape shape = m_host.Shape; + + if (shape.FlexiEntry) + res.Add(new LSL_Types.LSLInteger(1)); // active + else + res.Add(new LSL_Types.LSLInteger(0)); + res.Add(new LSL_Types.LSLInteger(shape.FlexiSoftness));// softness + res.Add(new LSL_Types.LSLFloat(shape.FlexiGravity)); // gravity + res.Add(new LSL_Types.LSLFloat(shape.FlexiDrag)); // friction + res.Add(new LSL_Types.LSLFloat(shape.FlexiWind)); // wind + res.Add(new LSL_Types.LSLFloat(shape.FlexiTension)); // tension + res.Add(new LSL_Types.Vector3(shape.FlexiForceX, // force + shape.FlexiForceY, + shape.FlexiForceZ)); + break; + + case 22: // PRIM_TEXGEN + // TODO-------------- + // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR) + if (remain < 1) + return res; + + face=Convert.ToInt32(rules.Data[idx++]); + + res.Add(new LSL_Types.LSLInteger(0)); + break; + + case 23: // PRIM_POINT_LIGHT: + shape = m_host.Shape; + + if (shape.LightEntry) + res.Add(new LSL_Types.LSLInteger(1)); // active + else + res.Add(new LSL_Types.LSLInteger(0)); + res.Add(new LSL_Types.Vector3(shape.LightColorR, // color + shape.LightColorG, + shape.LightColorB)); + res.Add(new LSL_Types.LSLFloat(shape.LightIntensity)); // intensity + res.Add(new LSL_Types.LSLFloat(shape.LightRadius)); // radius + res.Add(new LSL_Types.LSLFloat(shape.LightFalloff)); // falloff + break; + + case 24: // PRIM_GLOW + // TODO-------------- + if (remain < 1) + return res; + + face=Convert.ToInt32(rules.Data[idx++]); + + res.Add(new LSL_Types.LSLFloat(0)); + break; + } + } + return res; } // diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs index 115e4e8..f970878 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs @@ -544,7 +544,8 @@ namespace OpenSim.Region.ScriptEngine.Common LSL_Types.list llGetBoundingBox(string obj); //wiki: vector llGetGeometricCenter() LSL_Types.Vector3 llGetGeometricCenter(); - void llGetPrimitiveParams(); + //wiki: list llGetPrimitiveParams(list rules) + LSL_Types.list llGetPrimitiveParams(LSL_Types.list rules); //wiki: string llIntegerToBase64(integer number) string llIntegerToBase64(int number); //wiki integer llBase64ToInteger(string str) -- cgit v1.1