2007-07-30 20:11:40 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Text;
|
|
|
|
using Axiom.Math;
|
|
|
|
using libsecondlife;
|
|
|
|
using libsecondlife.Packets;
|
|
|
|
using OpenSim.Framework.Interfaces;
|
|
|
|
using OpenSim.Framework.Types;
|
|
|
|
using OpenSim.Physics.Manager;
|
|
|
|
|
|
|
|
namespace OpenSim.Region.Environment.Scenes
|
|
|
|
{
|
|
|
|
// public delegate void PrimCountTaintedDelegate();
|
|
|
|
|
2007-08-09 17:54:22 +00:00
|
|
|
public class SceneObjectGroup : EntityBase
|
2007-07-30 20:11:40 +00:00
|
|
|
{
|
|
|
|
private Encoding enc = Encoding.ASCII;
|
|
|
|
|
2007-08-09 17:54:22 +00:00
|
|
|
protected SceneObjectPart m_rootPart;
|
|
|
|
protected Dictionary<LLUUID, SceneObjectPart> m_parts = new Dictionary<LLUUID, SceneObjectPart>();
|
2007-07-30 20:11:40 +00:00
|
|
|
|
2007-08-03 11:44:30 +00:00
|
|
|
protected ulong m_regionHandle;
|
|
|
|
|
2007-07-30 20:11:40 +00:00
|
|
|
public event PrimCountTaintedDelegate OnPrimCountTainted;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
/// </summary>
|
2007-08-01 16:50:20 +00:00
|
|
|
public int PrimCount
|
2007-07-30 20:11:40 +00:00
|
|
|
{
|
2007-08-03 20:09:55 +00:00
|
|
|
get { return 1; }
|
2007-07-30 20:11:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
/// </summary>
|
|
|
|
public LLVector3 GroupCentrePoint
|
|
|
|
{
|
2007-08-03 20:09:55 +00:00
|
|
|
get { return new LLVector3(0, 0, 0); }
|
2007-07-30 20:11:40 +00:00
|
|
|
}
|
|
|
|
|
2007-08-09 17:54:22 +00:00
|
|
|
public Dictionary<LLUUID, SceneObjectPart> Children
|
|
|
|
{
|
|
|
|
get { return this.m_parts; }
|
|
|
|
set { m_parts = value; }
|
|
|
|
}
|
|
|
|
|
2007-08-07 18:31:20 +00:00
|
|
|
public override LLVector3 Pos
|
|
|
|
{
|
|
|
|
get { return m_rootPart.GroupPosition; }
|
|
|
|
set
|
|
|
|
{
|
|
|
|
lock (this.m_parts)
|
|
|
|
{
|
2007-08-09 17:54:22 +00:00
|
|
|
foreach (SceneObjectPart part in this.m_parts.Values)
|
2007-08-07 18:31:20 +00:00
|
|
|
{
|
|
|
|
part.GroupPosition = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public override uint LocalId
|
|
|
|
{
|
|
|
|
get { return m_rootPart.LocalID; }
|
|
|
|
set { m_rootPart.LocalID = value; }
|
|
|
|
}
|
|
|
|
|
|
|
|
public override LLUUID UUID
|
|
|
|
{
|
|
|
|
get { return m_rootPart.UUID; }
|
|
|
|
set { m_rootPart.UUID = value; }
|
|
|
|
}
|
|
|
|
|
2007-08-09 17:54:22 +00:00
|
|
|
public LLUUID OwnerID
|
|
|
|
{
|
|
|
|
get { return m_rootPart.OwnerID; }
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Added because the Parcel code seems to use it
|
|
|
|
/// but not sure a object should have this
|
|
|
|
/// as what does it tell us? that some avatar has selected it
|
|
|
|
/// think really there should be a list (or whatever) in each scenepresence
|
|
|
|
/// saying what prim(s) that user has selected at any time.
|
|
|
|
/// </summary>
|
|
|
|
protected bool m_isSelected = false;
|
|
|
|
public bool IsSelected
|
|
|
|
{
|
|
|
|
get{ return m_isSelected;}
|
|
|
|
set { m_isSelected = value; }
|
|
|
|
}
|
|
|
|
|
2007-08-03 14:47:38 +00:00
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
/// </summary>
|
2007-08-09 17:54:22 +00:00
|
|
|
public SceneObjectGroup()
|
2007-08-03 14:47:38 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2007-08-03 16:17:05 +00:00
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
/// </summary>
|
2007-08-09 17:54:22 +00:00
|
|
|
public SceneObjectGroup(byte[] data)
|
2007-08-03 16:17:05 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2007-07-30 20:11:40 +00:00
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
/// </summary>
|
2007-08-09 17:54:22 +00:00
|
|
|
public SceneObjectGroup(Scene scene, ulong regionHandle, LLUUID ownerID, uint localID, LLVector3 pos, PrimitiveBaseShape shape)
|
2007-07-30 20:11:40 +00:00
|
|
|
{
|
2007-08-03 11:44:30 +00:00
|
|
|
m_regionHandle = regionHandle;
|
2007-08-06 13:40:45 +00:00
|
|
|
m_scene = scene;
|
2007-07-30 20:11:40 +00:00
|
|
|
|
2007-08-03 11:44:30 +00:00
|
|
|
this.Pos = pos;
|
2007-08-03 12:00:24 +00:00
|
|
|
LLVector3 rootOffset = new LLVector3(0, 0, 0);
|
2007-08-09 17:54:22 +00:00
|
|
|
SceneObjectPart newPart = new SceneObjectPart(m_regionHandle, this, ownerID, localID, shape, pos, rootOffset);
|
2007-08-03 12:00:24 +00:00
|
|
|
this.m_parts.Add(newPart.UUID, newPart);
|
|
|
|
this.SetPartAsRoot(newPart);
|
2007-08-09 18:45:40 +00:00
|
|
|
|
2007-07-30 20:11:40 +00:00
|
|
|
}
|
|
|
|
|
2007-08-03 16:17:05 +00:00
|
|
|
|
2007-08-03 15:04:23 +00:00
|
|
|
#region Copying
|
2007-07-30 20:11:40 +00:00
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
/// </summary>
|
2007-08-03 14:47:38 +00:00
|
|
|
/// <returns></returns>
|
2007-08-09 17:54:22 +00:00
|
|
|
public new SceneObjectGroup Copy()
|
2007-08-03 14:47:38 +00:00
|
|
|
{
|
2007-08-09 17:54:22 +00:00
|
|
|
SceneObjectGroup dupe = (SceneObjectGroup)this.MemberwiseClone();
|
2007-08-03 14:47:38 +00:00
|
|
|
dupe.Pos = new LLVector3(Pos.X, Pos.Y, Pos.Z);
|
2007-08-03 15:04:23 +00:00
|
|
|
dupe.m_scene = m_scene;
|
|
|
|
dupe.m_regionHandle = this.m_regionHandle;
|
2007-08-03 14:47:38 +00:00
|
|
|
|
2007-08-03 15:04:23 +00:00
|
|
|
dupe.CopyRootPart(this.m_rootPart);
|
2007-08-03 20:09:55 +00:00
|
|
|
|
2007-08-09 17:54:22 +00:00
|
|
|
foreach (SceneObjectPart part in this.m_parts.Values)
|
2007-08-03 14:47:38 +00:00
|
|
|
{
|
|
|
|
if (part.UUID != this.m_rootPart.UUID)
|
|
|
|
{
|
|
|
|
dupe.CopyPart(part);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return dupe;
|
|
|
|
}
|
|
|
|
|
2007-08-04 18:15:48 +00:00
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="part"></param>
|
2007-08-09 17:54:22 +00:00
|
|
|
public void CopyRootPart(SceneObjectPart part)
|
2007-08-03 14:47:38 +00:00
|
|
|
{
|
2007-08-09 17:54:22 +00:00
|
|
|
SceneObjectPart newPart = part.Copy(m_scene.PrimIDAllocate());
|
2007-08-03 15:04:23 +00:00
|
|
|
this.m_parts.Add(newPart.UUID, newPart);
|
|
|
|
this.SetPartAsRoot(newPart);
|
2007-08-03 14:47:38 +00:00
|
|
|
}
|
|
|
|
|
2007-08-04 18:15:48 +00:00
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="part"></param>
|
2007-08-09 17:54:22 +00:00
|
|
|
public void CopyPart(SceneObjectPart part)
|
2007-08-03 14:47:38 +00:00
|
|
|
{
|
2007-08-09 17:54:22 +00:00
|
|
|
SceneObjectPart newPart = part.Copy(m_scene.PrimIDAllocate());
|
2007-08-03 15:04:23 +00:00
|
|
|
this.m_parts.Add(newPart.UUID, newPart);
|
2007-08-03 16:17:05 +00:00
|
|
|
this.SetPartAsNonRoot(newPart);
|
2007-08-03 14:47:38 +00:00
|
|
|
}
|
2007-08-03 15:04:23 +00:00
|
|
|
#endregion
|
2007-08-03 14:47:38 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
/// </summary>
|
|
|
|
public override void Update()
|
|
|
|
{
|
2007-08-09 17:54:22 +00:00
|
|
|
foreach (SceneObjectPart part in this.m_parts.Values)
|
2007-08-03 14:47:38 +00:00
|
|
|
{
|
|
|
|
part.SendScheduledUpdates();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
/// </summary>
|
|
|
|
public void ScheduleGroupForFullUpdate()
|
|
|
|
{
|
2007-08-09 17:54:22 +00:00
|
|
|
foreach (SceneObjectPart part in this.m_parts.Values)
|
2007-08-03 14:47:38 +00:00
|
|
|
{
|
|
|
|
part.ScheduleFullUpdate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
/// </summary>
|
|
|
|
public void ScheduleGroupForTerseUpdate()
|
|
|
|
{
|
2007-08-09 17:54:22 +00:00
|
|
|
foreach (SceneObjectPart part in this.m_parts.Values)
|
2007-08-03 14:47:38 +00:00
|
|
|
{
|
|
|
|
part.ScheduleTerseUpdate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
/// </summary>
|
2007-08-03 15:04:23 +00:00
|
|
|
public void SendGroupFullUpdate()
|
2007-07-30 20:11:40 +00:00
|
|
|
{
|
2007-08-09 17:54:22 +00:00
|
|
|
foreach (SceneObjectPart part in this.m_parts.Values)
|
2007-08-03 12:00:24 +00:00
|
|
|
{
|
|
|
|
part.SendFullUpdateToAllClients();
|
|
|
|
}
|
2007-07-30 20:11:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
/// </summary>
|
2007-08-03 14:47:38 +00:00
|
|
|
public void SendGroupTerseUpdate()
|
2007-07-30 20:11:40 +00:00
|
|
|
{
|
2007-08-09 17:54:22 +00:00
|
|
|
foreach (SceneObjectPart part in this.m_parts.Values)
|
2007-08-03 12:00:24 +00:00
|
|
|
{
|
2007-08-03 18:45:42 +00:00
|
|
|
part.SendTerseUpdateToAllClients();
|
2007-08-03 12:00:24 +00:00
|
|
|
}
|
2007-07-30 20:11:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="objectGroup"></param>
|
2007-08-09 17:54:22 +00:00
|
|
|
public void LinkToGroup(SceneObjectGroup objectGroup)
|
2007-07-30 20:11:40 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="primID"></param>
|
|
|
|
/// <returns></returns>
|
2007-08-09 17:54:22 +00:00
|
|
|
private SceneObjectPart GetChildPrim(LLUUID primID)
|
2007-07-30 20:11:40 +00:00
|
|
|
{
|
2007-08-09 17:54:22 +00:00
|
|
|
SceneObjectPart childPart = null;
|
2007-07-30 20:11:40 +00:00
|
|
|
if (this.m_parts.ContainsKey(primID))
|
|
|
|
{
|
|
|
|
childPart = this.m_parts[primID];
|
|
|
|
}
|
|
|
|
return childPart;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="localID"></param>
|
|
|
|
/// <returns></returns>
|
2007-08-09 17:54:22 +00:00
|
|
|
private SceneObjectPart GetChildPrim(uint localID)
|
2007-07-30 20:11:40 +00:00
|
|
|
{
|
2007-08-09 17:54:22 +00:00
|
|
|
foreach (SceneObjectPart part in this.m_parts.Values)
|
2007-07-30 20:11:40 +00:00
|
|
|
{
|
2007-08-01 16:50:20 +00:00
|
|
|
if (part.LocalID == localID)
|
2007-07-30 20:11:40 +00:00
|
|
|
{
|
|
|
|
return part;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2007-08-02 16:40:50 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Does this group contain the child prim
|
|
|
|
/// should be able to remove these methods once we have a entity index in scene
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="primID"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
public bool HasChildPrim(LLUUID primID)
|
|
|
|
{
|
2007-08-09 17:54:22 +00:00
|
|
|
SceneObjectPart childPart = null;
|
2007-08-02 16:40:50 +00:00
|
|
|
if (this.m_parts.ContainsKey(primID))
|
|
|
|
{
|
|
|
|
childPart = this.m_parts[primID];
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Does this group contain the child prim
|
|
|
|
/// should be able to remove these methods once we have a entity index in scene
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="localID"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
public bool HasChildPrim(uint localID)
|
|
|
|
{
|
2007-08-09 17:54:22 +00:00
|
|
|
foreach (SceneObjectPart part in this.m_parts.Values)
|
2007-08-02 16:40:50 +00:00
|
|
|
{
|
|
|
|
if (part.LocalID == localID)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-08-03 11:44:30 +00:00
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
/// </summary>
|
2007-07-30 20:11:40 +00:00
|
|
|
public void TriggerTainted()
|
|
|
|
{
|
|
|
|
if (OnPrimCountTainted != null)
|
|
|
|
{
|
|
|
|
this.OnPrimCountTainted();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="offset"></param>
|
|
|
|
/// <param name="pos"></param>
|
|
|
|
/// <param name="remoteClient"></param>
|
|
|
|
public void GrapMovement(LLVector3 offset, LLVector3 pos, IClientAPI remoteClient)
|
|
|
|
{
|
|
|
|
this.Pos = pos;
|
2007-08-03 18:45:42 +00:00
|
|
|
this.m_rootPart.SendTerseUpdateToAllClients();
|
2007-07-30 20:11:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="client"></param>
|
|
|
|
public void GetProperites(IClientAPI client)
|
|
|
|
{
|
|
|
|
ObjectPropertiesPacket proper = new ObjectPropertiesPacket();
|
|
|
|
proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1];
|
|
|
|
proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock();
|
|
|
|
proper.ObjectData[0].ItemID = LLUUID.Zero;
|
|
|
|
proper.ObjectData[0].CreationDate = (ulong)this.m_rootPart.CreationDate;
|
|
|
|
proper.ObjectData[0].CreatorID = this.m_rootPart.CreatorID;
|
|
|
|
proper.ObjectData[0].FolderID = LLUUID.Zero;
|
|
|
|
proper.ObjectData[0].FromTaskID = LLUUID.Zero;
|
|
|
|
proper.ObjectData[0].GroupID = LLUUID.Zero;
|
|
|
|
proper.ObjectData[0].InventorySerial = 0;
|
|
|
|
proper.ObjectData[0].LastOwnerID = this.m_rootPart.LastOwnerID;
|
2007-08-09 17:54:22 +00:00
|
|
|
proper.ObjectData[0].ObjectID = this.UUID;
|
2007-07-30 20:11:40 +00:00
|
|
|
proper.ObjectData[0].OwnerID = this.m_rootPart.OwnerID;
|
|
|
|
proper.ObjectData[0].TouchName = enc.GetBytes(this.m_rootPart.TouchName + "\0");
|
|
|
|
proper.ObjectData[0].TextureID = new byte[0];
|
|
|
|
proper.ObjectData[0].SitName = enc.GetBytes(this.m_rootPart.SitName + "\0");
|
2007-08-07 17:22:15 +00:00
|
|
|
proper.ObjectData[0].Name = enc.GetBytes(this.m_rootPart.PartName + "\0");
|
2007-07-30 20:11:40 +00:00
|
|
|
proper.ObjectData[0].Description = enc.GetBytes(this.m_rootPart.Description + "\0");
|
|
|
|
proper.ObjectData[0].OwnerMask = this.m_rootPart.OwnerMask;
|
|
|
|
proper.ObjectData[0].NextOwnerMask = this.m_rootPart.NextOwnerMask;
|
|
|
|
proper.ObjectData[0].GroupMask = this.m_rootPart.GroupMask;
|
|
|
|
proper.ObjectData[0].EveryoneMask = this.m_rootPart.EveryoneMask;
|
|
|
|
proper.ObjectData[0].BaseMask = this.m_rootPart.BaseMask;
|
|
|
|
|
|
|
|
client.OutPacket(proper);
|
|
|
|
}
|
|
|
|
|
2007-08-09 17:54:22 +00:00
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="name"></param>
|
|
|
|
public void SetPartName(string name, uint localID)
|
|
|
|
{
|
|
|
|
SceneObjectPart part = this.GetChildPrim(localID);
|
|
|
|
if (part != null)
|
|
|
|
{
|
|
|
|
part.PartName = name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void SetPartDescription(string des, uint localID)
|
|
|
|
{
|
|
|
|
SceneObjectPart part = this.GetChildPrim(localID);
|
|
|
|
if (part != null)
|
|
|
|
{
|
|
|
|
part.Description = des;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-08-03 11:44:30 +00:00
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="remoteClient"></param>
|
|
|
|
/// <param name="localID"></param>
|
2007-08-09 17:54:22 +00:00
|
|
|
public void GetPartInventory(IClientAPI remoteClient, uint localID)
|
2007-08-03 11:44:30 +00:00
|
|
|
{
|
2007-08-09 17:54:22 +00:00
|
|
|
SceneObjectPart part = this.GetChildPrim(localID);
|
2007-08-03 11:44:30 +00:00
|
|
|
if (part != null)
|
|
|
|
{
|
|
|
|
part.GetInventory(remoteClient, localID);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="localID"></param>
|
|
|
|
/// <param name="type"></param>
|
|
|
|
/// <param name="inUse"></param>
|
|
|
|
/// <param name="data"></param>
|
|
|
|
public void UpdateExtraParam(uint localID, ushort type, bool inUse, byte[] data)
|
|
|
|
{
|
2007-08-09 17:54:22 +00:00
|
|
|
SceneObjectPart part = this.GetChildPrim(localID);
|
2007-08-03 11:44:30 +00:00
|
|
|
if (part != null)
|
|
|
|
{
|
|
|
|
part.UpdateExtraParam(type, inUse, data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="localID"></param>
|
|
|
|
/// <param name="textureEntry"></param>
|
|
|
|
public void UpdateTextureEntry(uint localID, byte[] textureEntry)
|
|
|
|
{
|
2007-08-09 17:54:22 +00:00
|
|
|
SceneObjectPart part = this.GetChildPrim(localID);
|
2007-08-03 11:44:30 +00:00
|
|
|
if (part != null)
|
|
|
|
{
|
|
|
|
part.UpdateTextureEntry(textureEntry);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-30 20:11:40 +00:00
|
|
|
#region Shape
|
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="shapeBlock"></param>
|
|
|
|
public void UpdateShape(ObjectShapePacket.ObjectDataBlock shapeBlock, uint localID)
|
|
|
|
{
|
2007-08-09 17:54:22 +00:00
|
|
|
SceneObjectPart part = this.GetChildPrim(localID);
|
2007-07-30 20:11:40 +00:00
|
|
|
if (part != null)
|
|
|
|
{
|
|
|
|
part.UpdateShape(shapeBlock);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
2007-08-09 17:54:22 +00:00
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="scale"></param>
|
|
|
|
/// <param name="localID"></param>
|
|
|
|
public void Resize(LLVector3 scale, uint localID)
|
|
|
|
{
|
|
|
|
SceneObjectPart part = this.GetChildPrim(localID);
|
|
|
|
if (part != null)
|
|
|
|
{
|
|
|
|
part.Resize(scale);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-30 20:11:40 +00:00
|
|
|
#region Position
|
2007-08-03 11:44:30 +00:00
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="pos"></param>
|
2007-07-30 20:11:40 +00:00
|
|
|
public void UpdateGroupPosition(LLVector3 pos)
|
|
|
|
{
|
2007-08-07 18:31:20 +00:00
|
|
|
this.Pos = pos;
|
2007-07-30 20:11:40 +00:00
|
|
|
}
|
|
|
|
|
2007-08-03 11:44:30 +00:00
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="pos"></param>
|
|
|
|
/// <param name="localID"></param>
|
2007-07-30 20:11:40 +00:00
|
|
|
public void UpdateSinglePosition(LLVector3 pos, uint localID)
|
|
|
|
{
|
2007-08-09 17:54:22 +00:00
|
|
|
SceneObjectPart part = this.GetChildPrim(localID);
|
2007-07-30 20:11:40 +00:00
|
|
|
if (part != null)
|
|
|
|
{
|
2007-08-01 16:50:20 +00:00
|
|
|
if (part.UUID == this.m_rootPart.UUID)
|
2007-07-30 20:11:40 +00:00
|
|
|
{
|
|
|
|
this.UpdateRootPosition(pos);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
part.UpdateOffSet(pos);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-08-03 11:44:30 +00:00
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="pos"></param>
|
2007-07-30 20:11:40 +00:00
|
|
|
private void UpdateRootPosition(LLVector3 pos)
|
|
|
|
{
|
|
|
|
LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z);
|
|
|
|
LLVector3 oldPos = new LLVector3(this.Pos.X + this.m_rootPart.OffsetPosition.X, this.Pos.Y + this.m_rootPart.OffsetPosition.Y, this.Pos.Z + this.m_rootPart.OffsetPosition.Z);
|
|
|
|
LLVector3 diff = oldPos - newPos;
|
|
|
|
Axiom.Math.Vector3 axDiff = new Vector3(diff.X, diff.Y, diff.Z);
|
|
|
|
Axiom.Math.Quaternion partRotation = new Quaternion(this.m_rootPart.RotationOffset.W, this.m_rootPart.RotationOffset.X, this.m_rootPart.RotationOffset.Y, this.m_rootPart.RotationOffset.Z);
|
|
|
|
axDiff = partRotation.Inverse() * axDiff;
|
|
|
|
diff.X = axDiff.x;
|
|
|
|
diff.Y = axDiff.y;
|
|
|
|
diff.Z = axDiff.z;
|
|
|
|
|
2007-08-09 17:54:22 +00:00
|
|
|
foreach (SceneObjectPart obPart in this.m_parts.Values)
|
2007-07-30 20:11:40 +00:00
|
|
|
{
|
2007-08-01 16:50:20 +00:00
|
|
|
if (obPart.UUID != this.m_rootPart.UUID)
|
2007-07-30 20:11:40 +00:00
|
|
|
{
|
|
|
|
obPart.OffsetPosition = obPart.OffsetPosition + diff;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.Pos = newPos;
|
|
|
|
pos.X = newPos.X;
|
|
|
|
pos.Y = newPos.Y;
|
|
|
|
pos.Z = newPos.Z;
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region Roation
|
2007-08-03 11:44:30 +00:00
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="rot"></param>
|
2007-07-30 20:11:40 +00:00
|
|
|
public void UpdateGroupRotation(LLQuaternion rot)
|
|
|
|
{
|
|
|
|
this.m_rootPart.UpdateRotation(rot);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="pos"></param>
|
|
|
|
/// <param name="rot"></param>
|
|
|
|
public void UpdateGroupRotation(LLVector3 pos, LLQuaternion rot)
|
|
|
|
{
|
|
|
|
this.m_rootPart.UpdateRotation(rot);
|
2007-08-07 18:31:20 +00:00
|
|
|
this.Pos = pos;
|
2007-07-30 20:11:40 +00:00
|
|
|
}
|
|
|
|
|
2007-08-03 11:44:30 +00:00
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="rot"></param>
|
|
|
|
/// <param name="localID"></param>
|
2007-07-30 20:11:40 +00:00
|
|
|
public void UpdateSingleRotation(LLQuaternion rot, uint localID)
|
|
|
|
{
|
2007-08-09 17:54:22 +00:00
|
|
|
SceneObjectPart part = this.GetChildPrim(localID);
|
2007-07-30 20:11:40 +00:00
|
|
|
if (part != null)
|
|
|
|
{
|
2007-08-01 16:50:20 +00:00
|
|
|
if (part.UUID == this.m_rootPart.UUID)
|
2007-07-30 20:11:40 +00:00
|
|
|
{
|
|
|
|
this.UpdateRootRotation(rot);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
part.UpdateRotation(rot);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-08-03 11:44:30 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="rot"></param>
|
2007-07-30 20:11:40 +00:00
|
|
|
private void UpdateRootRotation(LLQuaternion rot)
|
|
|
|
{
|
|
|
|
this.m_rootPart.UpdateRotation(rot);
|
|
|
|
Axiom.Math.Quaternion axRot = new Quaternion(rot.W, rot.X, rot.Y, rot.Z);
|
|
|
|
Axiom.Math.Quaternion oldParentRot = new Quaternion(this.m_rootPart.RotationOffset.W, this.m_rootPart.RotationOffset.X, this.m_rootPart.RotationOffset.Y, this.m_rootPart.RotationOffset.Z);
|
|
|
|
|
2007-08-09 17:54:22 +00:00
|
|
|
foreach (SceneObjectPart prim in this.m_parts.Values)
|
2007-07-30 20:11:40 +00:00
|
|
|
{
|
2007-08-01 16:50:20 +00:00
|
|
|
if (prim.UUID != this.m_rootPart.UUID)
|
2007-07-30 20:11:40 +00:00
|
|
|
{
|
|
|
|
Vector3 axPos = new Vector3(prim.OffsetPosition.X, prim.OffsetPosition.Y, prim.OffsetPosition.Z);
|
|
|
|
axPos = oldParentRot * axPos;
|
|
|
|
axPos = axRot.Inverse() * axPos;
|
|
|
|
prim.OffsetPosition = new LLVector3(axPos.x, axPos.y, axPos.z);
|
|
|
|
Axiom.Math.Quaternion primsRot = new Quaternion(prim.RotationOffset.W, prim.RotationOffset.X, prim.RotationOffset.Y, prim.RotationOffset.Z);
|
|
|
|
Axiom.Math.Quaternion newRot = oldParentRot * primsRot;
|
|
|
|
newRot = axRot.Inverse() * newRot;
|
|
|
|
prim.RotationOffset = new LLQuaternion(newRot.w, newRot.x, newRot.y, newRot.z);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-08-03 11:44:30 +00:00
|
|
|
|
2007-07-30 20:11:40 +00:00
|
|
|
#endregion
|
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="part"></param>
|
2007-08-09 17:54:22 +00:00
|
|
|
private void SetPartAsRoot(SceneObjectPart part)
|
2007-07-30 20:11:40 +00:00
|
|
|
{
|
|
|
|
this.m_rootPart = part;
|
2007-08-07 18:31:20 +00:00
|
|
|
//this.m_uuid= part.UUID;
|
|
|
|
// this.m_localId = part.LocalID;
|
2007-07-30 20:11:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="part"></param>
|
2007-08-09 17:54:22 +00:00
|
|
|
private void SetPartAsNonRoot(SceneObjectPart part)
|
2007-07-30 20:11:40 +00:00
|
|
|
{
|
2007-08-03 16:17:05 +00:00
|
|
|
part.ParentID = this.m_rootPart.LocalID;
|
2007-07-30 20:11:40 +00:00
|
|
|
}
|
2007-08-03 12:00:24 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
/// </summary>
|
|
|
|
/// <returns></returns>
|
|
|
|
public List<ScenePresence> RequestSceneAvatars()
|
|
|
|
{
|
2007-08-03 20:09:55 +00:00
|
|
|
return m_scene.RequestAvatarList();
|
2007-08-03 12:00:24 +00:00
|
|
|
}
|
2007-08-07 17:25:21 +00:00
|
|
|
|
2007-08-07 18:31:20 +00:00
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="remoteClient"></param>
|
|
|
|
/// <param name="part"></param>
|
2007-08-09 17:54:22 +00:00
|
|
|
internal void SendPartFullUpdate(IClientAPI remoteClient, SceneObjectPart part)
|
2007-08-07 17:25:21 +00:00
|
|
|
{
|
|
|
|
if( m_rootPart == part )
|
|
|
|
{
|
|
|
|
part.SendFullUpdateToClient( remoteClient, Pos );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
part.SendFullUpdateToClient( remoteClient );
|
|
|
|
}
|
|
|
|
}
|
2007-08-07 18:31:20 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="remoteClient"></param>
|
|
|
|
/// <param name="part"></param>
|
2007-08-09 17:54:22 +00:00
|
|
|
internal void SendPartTerseUpdate(IClientAPI remoteClient, SceneObjectPart part)
|
2007-08-07 18:31:20 +00:00
|
|
|
{
|
|
|
|
if (m_rootPart == part)
|
|
|
|
{
|
|
|
|
part.SendTerseUpdateToClient(remoteClient, Pos);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
part.SendTerseUpdateToClient(remoteClient);
|
|
|
|
}
|
|
|
|
}
|
2007-07-30 20:11:40 +00:00
|
|
|
}
|
|
|
|
}
|