From c935b308e67d4468437fa201a3bf444d9715f377 Mon Sep 17 00:00:00 2001
From: Dalien Talbot
Date: Sun, 10 Feb 2008 22:23:11 +0000
Subject: The very beginnings of attachments (no detachments! :)
---
OpenSim/Framework/IClientAPI.cs | 7 +
OpenSim/Region/ClientStack/ClientView.cs | 20 ++-
OpenSim/Region/Environment/Scenes/InnerScene.cs | 147 +++++++++++++++++++++
.../Region/Environment/Scenes/Scene.Inventory.cs | 10 ++
OpenSim/Region/Environment/Scenes/Scene.cs | 2 +
.../Region/Examples/SimpleApp/MyNpcCharacter.cs | 2 +
.../DotNetEngine/Compiler/LSL/LSL2CSConverter.cs | 21 +--
7 files changed, 194 insertions(+), 15 deletions(-)
diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs
index bb4fd15..b9ad348 100644
--- a/OpenSim/Framework/IClientAPI.cs
+++ b/OpenSim/Framework/IClientAPI.cs
@@ -234,6 +234,11 @@ namespace OpenSim.Framework
uint EveryoneMask, uint GroupMask, uint NextOwnerMask, uint ItemFlags,
bool RezSelected, bool RemoveItem, LLUUID fromTaskID );
+ public delegate void RezSingleAttachmentFromInv(IClientAPI remoteClient, LLUUID itemID, uint AttachmentPt,
+ uint ItemFlags, uint NextOwnerMask);
+
+ public delegate void ObjectAttach(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, LLQuaternion rot);
+
public delegate void ModifyTerrain(
float height, float seconds, byte size, byte action, float north, float west, float south, float east,
IClientAPI remoteClient);
@@ -417,6 +422,8 @@ namespace OpenSim.Framework
event ModifyTerrain OnModifyTerrain;
event SetAppearance OnSetAppearance;
event AvatarNowWearing OnAvatarNowWearing;
+ event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv;
+ event ObjectAttach OnObjectAttach;
event StartAnim OnStartAnim;
event StopAnim OnStopAnim;
event LinkObjects OnLinkObjects;
diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs
index a35c83c..cb076b5 100644
--- a/OpenSim/Region/ClientStack/ClientView.cs
+++ b/OpenSim/Region/ClientStack/ClientView.cs
@@ -515,6 +515,8 @@ namespace OpenSim.Region.ClientStack
public event GenericCall2 OnRequestWearables;
public event SetAppearance OnSetAppearance;
public event AvatarNowWearing OnAvatarNowWearing;
+ public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv;
+ public event ObjectAttach OnObjectAttach;
public event GenericCall2 OnCompleteMovementToRegion;
public event UpdateAgent OnAgentUpdate;
public event AgentRequestSit OnAgentRequestSit;
@@ -1645,6 +1647,7 @@ namespace OpenSim.Region.ClientStack
public void AttachObject(uint localID, LLQuaternion rotation, byte attachPoint)
{
ObjectAttachPacket attach = (ObjectAttachPacket)PacketPool.Instance.GetPacket(PacketType.ObjectAttach);
+ System.Console.WriteLine("Attach object!");
// TODO: don't create new blocks if recycling an old packet
attach.AgentData.AgentID = AgentId;
attach.AgentData.SessionID = m_sessionId;
@@ -2009,7 +2012,7 @@ namespace OpenSim.Region.ClientStack
///
///
///
- protected ObjectUpdatePacket.ObjectDataBlock CreateDefaultAvatarPacket(byte[] textureEntry)
+ public ObjectUpdatePacket.ObjectDataBlock CreateDefaultAvatarPacket(byte[] textureEntry)
{
ObjectUpdatePacket.ObjectDataBlock objdata = new ObjectUpdatePacket.ObjectDataBlock();
// new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1, ref i);
@@ -2858,6 +2861,21 @@ namespace OpenSim.Region.ClientStack
OnAvatarNowWearing(this, wearingArgs);
}
break;
+ case PacketType.RezSingleAttachmentFromInv:
+ if (OnRezSingleAttachmentFromInv != null)
+ {
+ RezSingleAttachmentFromInvPacket rez = (RezSingleAttachmentFromInvPacket) Pack;
+ OnRezSingleAttachmentFromInv(this, rez.ObjectData.ItemID,
+ rez.ObjectData.AttachmentPt, rez.ObjectData.ItemFlags, rez.ObjectData.NextOwnerMask);
+ }
+ break;
+ case PacketType.ObjectAttach:
+ if (OnObjectAttach != null)
+ {
+ ObjectAttachPacket att = (ObjectAttachPacket) Pack;
+ OnObjectAttach(this, att.ObjectData[0].ObjectLocalID, att.AgentData.AttachmentPoint, att.ObjectData[0].Rotation);
+ }
+ break;
case PacketType.SetAlwaysRun:
SetAlwaysRunPacket run = (SetAlwaysRunPacket)Pack;
diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs
index 7421957..cb04939 100644
--- a/OpenSim/Region/Environment/Scenes/InnerScene.cs
+++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs
@@ -232,6 +232,153 @@ namespace OpenSim.Region.Environment.Scenes
}
}
+ public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, LLQuaternion rot)
+ {
+ System.Console.WriteLine("Attaching object " + objectLocalID + " to " + AttachmentPt);
+ SceneObjectPart p = GetSceneObjectPart(objectLocalID);
+ ScenePresence av = null;
+ if (TryGetAvatar(remoteClient.AgentId, out av)) {
+ ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
+ objupdate.RegionData.RegionHandle = m_regInfo.RegionHandle;
+ objupdate.RegionData.TimeDilation = 64096;
+ objupdate.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[2];
+ // avatar stuff - horrible group copypaste
+
+ objupdate.ObjectData[0] = new ObjectUpdatePacket.ObjectDataBlock();
+ objupdate.ObjectData[0].PSBlock = new byte[0];
+ objupdate.ObjectData[0].ExtraParams = new byte[1];
+ objupdate.ObjectData[0].MediaURL = new byte[0];
+ objupdate.ObjectData[0].NameValue = new byte[0];
+ objupdate.ObjectData[0].Text = new byte[0];
+ objupdate.ObjectData[0].TextColor = new byte[4];
+ objupdate.ObjectData[0].JointAxisOrAnchor = new LLVector3(0, 0, 0);
+ objupdate.ObjectData[0].JointPivot = new LLVector3(0, 0, 0);
+ objupdate.ObjectData[0].Material = 4;
+ objupdate.ObjectData[0].TextureAnim = new byte[0];
+ objupdate.ObjectData[0].Sound = LLUUID.Zero;
+
+ objupdate.ObjectData[0].State = 0;
+ objupdate.ObjectData[0].Data = new byte[0];
+
+ objupdate.ObjectData[0].ObjectData = new byte[76];
+ objupdate.ObjectData[0].ObjectData[15] = 128;
+ objupdate.ObjectData[0].ObjectData[16] = 63;
+ objupdate.ObjectData[0].ObjectData[56] = 128;
+ objupdate.ObjectData[0].ObjectData[61] = 102;
+ objupdate.ObjectData[0].ObjectData[62] = 40;
+ objupdate.ObjectData[0].ObjectData[63] = 61;
+ objupdate.ObjectData[0].ObjectData[64] = 189;
+
+
+ objupdate.ObjectData[0].UpdateFlags = 61 + (9 << 8) + (130 << 16) + (16 << 24);
+ objupdate.ObjectData[0].PathCurve = 16;
+ objupdate.ObjectData[0].ProfileCurve = 1;
+ objupdate.ObjectData[0].PathScaleX = 100;
+ objupdate.ObjectData[0].PathScaleY = 100;
+ objupdate.ObjectData[0].ParentID = 0;
+ objupdate.ObjectData[0].OwnerID = LLUUID.Zero;
+ objupdate.ObjectData[0].Scale = new LLVector3(1, 1, 1);
+ objupdate.ObjectData[0].PCode = 47;
+ objupdate.ObjectData[0].TextureEntry = ScenePresence.DefaultTexture;
+
+ objupdate.ObjectData[0].ID = av.LocalId;
+ objupdate.ObjectData[0].FullID = remoteClient.AgentId;
+ objupdate.ObjectData[0].ParentID = 0;
+ objupdate.ObjectData[0].NameValue =
+ Helpers.StringToField("FirstName STRING RW SV " + av.Firstname + "\nLastName STRING RW SV " + av.Lastname);
+ LLVector3 pos2 = av.AbsolutePosition;
+ // new LLVector3((float) Pos.X, (float) Pos.Y, (float) Pos.Z);
+ byte[] pb = pos2.GetBytes();
+ Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length);
+
+
+ // primitive part
+ objupdate.ObjectData[1] = new ObjectUpdatePacket.ObjectDataBlock();
+ // SetDefaultPrimPacketValues
+ objupdate.ObjectData[1].PSBlock = new byte[0];
+ objupdate.ObjectData[1].ExtraParams = new byte[1];
+ objupdate.ObjectData[1].MediaURL = new byte[0];
+ objupdate.ObjectData[1].NameValue = new byte[0];
+ objupdate.ObjectData[1].Text = new byte[0];
+ objupdate.ObjectData[1].TextColor = new byte[4];
+ objupdate.ObjectData[1].JointAxisOrAnchor = new LLVector3(0, 0, 0);
+ objupdate.ObjectData[1].JointPivot = new LLVector3(0, 0, 0);
+ objupdate.ObjectData[1].Material = 3;
+ objupdate.ObjectData[1].TextureAnim = new byte[0];
+ objupdate.ObjectData[1].Sound = LLUUID.Zero;
+ objupdate.ObjectData[1].State = 0;
+ objupdate.ObjectData[1].Data = new byte[0];
+
+ objupdate.ObjectData[1].ObjectData = new byte[60];
+ objupdate.ObjectData[1].ObjectData[46] = 128;
+ objupdate.ObjectData[1].ObjectData[47] = 63;
+
+ // SetPrimPacketShapeData
+ PrimitiveBaseShape primData = p.Shape;
+
+ objupdate.ObjectData[1].TextureEntry = primData.TextureEntry;
+ objupdate.ObjectData[1].PCode = primData.PCode;
+ objupdate.ObjectData[1].State = (byte)(((byte)AttachmentPt) << 4) ;
+ objupdate.ObjectData[1].PathBegin = primData.PathBegin;
+ objupdate.ObjectData[1].PathEnd = primData.PathEnd;
+ objupdate.ObjectData[1].PathScaleX = primData.PathScaleX;
+ objupdate.ObjectData[1].PathScaleY = primData.PathScaleY;
+ objupdate.ObjectData[1].PathShearX = primData.PathShearX;
+ objupdate.ObjectData[1].PathShearY = primData.PathShearY;
+ objupdate.ObjectData[1].PathSkew = primData.PathSkew;
+ objupdate.ObjectData[1].ProfileBegin = primData.ProfileBegin;
+ objupdate.ObjectData[1].ProfileEnd = primData.ProfileEnd;
+ objupdate.ObjectData[1].Scale = primData.Scale;
+ objupdate.ObjectData[1].PathCurve = primData.PathCurve;
+ objupdate.ObjectData[1].ProfileCurve = primData.ProfileCurve;
+ objupdate.ObjectData[1].ProfileHollow = primData.ProfileHollow;
+ objupdate.ObjectData[1].PathRadiusOffset = primData.PathRadiusOffset;
+ objupdate.ObjectData[1].PathRevolutions = primData.PathRevolutions;
+ objupdate.ObjectData[1].PathTaperX = primData.PathTaperX;
+ objupdate.ObjectData[1].PathTaperY = primData.PathTaperY;
+ objupdate.ObjectData[1].PathTwist = primData.PathTwist;
+ objupdate.ObjectData[1].PathTwistBegin = primData.PathTwistBegin;
+ objupdate.ObjectData[1].ExtraParams = primData.ExtraParams;
+
+
+ objupdate.ObjectData[1].UpdateFlags = 276957500; // flags; // ??
+ objupdate.ObjectData[1].ID = p.LocalID;
+ objupdate.ObjectData[1].FullID = p.UUID;
+ objupdate.ObjectData[1].OwnerID = p.OwnerID;
+ objupdate.ObjectData[1].Text = Helpers.StringToField(p.Text);
+ objupdate.ObjectData[1].TextColor[0] = 255;
+ objupdate.ObjectData[1].TextColor[1] = 255;
+ objupdate.ObjectData[1].TextColor[2] = 255;
+ objupdate.ObjectData[1].TextColor[3] = 128;
+ objupdate.ObjectData[1].ParentID = objupdate.ObjectData[0].ID;
+ //objupdate.ObjectData[1].PSBlock = particleSystem;
+ //objupdate.ObjectData[1].ClickAction = clickAction;
+ objupdate.ObjectData[1].Radius = 20;
+ objupdate.ObjectData[1].NameValue =
+ Helpers.StringToField("AttachItemID STRING RW SV " + p.UUID);
+ LLVector3 pos = new LLVector3((float) 0.0, (float) 0.0, (float) 0.0);
+
+ pb = pos.GetBytes();
+ Array.Copy(pb, 0, objupdate.ObjectData[1].ObjectData, 0, pb.Length);
+
+ byte[] brot = rot.GetBytes();
+ Array.Copy(brot, 0, objupdate.ObjectData[1].ObjectData, 36, brot.Length);
+
+
+
+ remoteClient.OutPacket(objupdate, ThrottleOutPacketType.Task);
+
+
+
+
+ }
+ else
+ {
+ m_log.Info("[SCENE]: Avatar " + remoteClient.AgentId + " not found");
+ }
+ }
+
+
public ScenePresence CreateAndAddScenePresence(IClientAPI client, bool child, AvatarAppearance appearance)
{
ScenePresence newAvatar = null;
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
index cc9d294..fee1e66 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
@@ -33,6 +33,10 @@ using libsecondlife.Packets;
using OpenSim.Framework;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Console;
+using System.IO;
+using System.Text;
+using System.Xml;
+
namespace OpenSim.Region.Environment.Scenes
{
@@ -766,6 +770,12 @@ namespace OpenSim.Region.Environment.Scenes
}
}
}
+ public void RezSingleAttachment(IClientAPI remoteClient, LLUUID itemID, uint AttachmentPt,
+ uint ItemFlags, uint NextOwnerMask)
+ {
+ System.Console.WriteLine("RezSingleAttachment: unimplemented yet");
+ }
+
private void AddRezObject(string xmlData, LLVector3 pos)
{
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index dfbeed1..015ba12 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -1299,6 +1299,8 @@ namespace OpenSim.Region.Environment.Scenes
client.OnGrabUpdate += m_innerScene.MoveObject;
client.OnDeRezObject += DeRezObject;
client.OnRezObject += RezObject;
+ client.OnRezSingleAttachmentFromInv += RezSingleAttachment;
+ client.OnObjectAttach += m_innerScene.AttachObject;
client.OnNameFromUUIDRequest += CommsManager.HandleUUIDNameRequest;
client.OnObjectDescription += m_innerScene.PrimDescription;
client.OnObjectName += m_innerScene.PrimName;
diff --git a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs
index b15db31..2599e61 100644
--- a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs
+++ b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs
@@ -58,6 +58,8 @@ namespace SimpleApp
public event ModifyTerrain OnModifyTerrain;
public event SetAppearance OnSetAppearance;
public event AvatarNowWearing OnAvatarNowWearing;
+ public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv;
+ public event ObjectAttach OnObjectAttach;
public event StartAnim OnStartAnim;
public event StopAnim OnStopAnim;
public event LinkObjects OnLinkObjects;
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs
index 07a31d0..613aa32 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs
@@ -176,9 +176,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
{
// 0 => 1: Get last
Match m =
- //Regex.Match(cache, @"(?![a-zA-Z_]+)\s*([a-zA-Z_]+)[^a-zA-Z_\(\)]*{",
- Regex.Match(cache, @"(?![a-zA-Z_]+)\s*(state\s+)?(?[a-zA-Z_]+)[^a-zA-Z_\(\)]*{",
-
+ Regex.Match(cache, @"(?![a-zA-Z_]+)\s*([a-zA-Z_]+)[^a-zA-Z_\(\)]*{",
RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
in_state = false;
@@ -186,14 +184,13 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
{
// Go back to level 0, this is not a state
in_state = true;
- current_statename = m.Groups["statename"].Captures[0].Value;
+ current_statename = m.Groups[1].Captures[0].Value;
//Console.WriteLine("Current statename: " + current_statename);
cache =
- //@"(?(?![a-zA-Z_]+)\s*)" + @"([a-zA-Z_]+)(?[^a-zA-Z_\(\)]*){",
Regex.Replace(cache,
- @"(?(?![a-zA-Z_]+)\s*)" + @"(state\s+)?([a-zA-Z_]+)(?[^a-zA-Z_\(\)]*){",
+ @"(?(?![a-zA-Z_]+)\s*)" + @"([a-zA-Z_]+)(?[^a-zA-Z_\(\)]*){",
"${s1}${s2}",
- RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline | RegexOptions.IgnoreCase);
+ RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
}
ret += cache;
cache = String.Empty;
@@ -214,7 +211,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
Regex.Replace(cache,
@"^(\s*)((?!(if|switch|for|while)[^a-zA-Z0-9_])[a-zA-Z0-9_]*\s*\([^\)]*\)[^;]*\{)",
@"$1public " + current_statename + "_event_$2",
- RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline | RegexOptions.IgnoreCase);
+ RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
}
ret += cache;
@@ -260,10 +257,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
// Replace and
Script =
- Regex.Replace(Script, @"<([^,>;]*,[^,>;]*,[^,>;]*,[^,>;]*)>", @"new LSL_Types.Quaternion($1)",
+ Regex.Replace(Script, @"<([^,>;]*,[^,>;\)]*,[^,>;\)]*,[^,>;\)]*)>", @"new LSL_Types.Quaternion($1)",
RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
Script =
- Regex.Replace(Script, @"<([^,>;)]*,[^,>;]*,[^,>;]*)>", @"new LSL_Types.Vector3($1)",
+ Regex.Replace(Script, @"<([^,>;]*,[^,>;\)]*,[^,>;\)]*)>", @"new LSL_Types.Vector3($1)",
RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
// Replace List []'s
@@ -280,10 +277,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
Regex.Replace(Script, @"\((float|int)\)\s*([a-zA-Z0-9_.]+(\s*\([^\)]*\))?)", @"$1.Parse($2)",
RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
- // Replace "state STATENAME" with "state("statename")"
- Script =
- Regex.Replace(Script, @"(state)\s+([^;\n\r]+)([\r\n\s];)", "$1(\"$2\")$3",
- RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline | RegexOptions.IgnoreCase);
// REPLACE BACK QUOTES
foreach (string key in quotes.Keys)
--
cgit v1.1