Started change to having SceneObject and then that having child Primitives which in turn have a Shape object (currently PrimitiveBaseShape). The plan is only for the SceneObject to interface with the physics engines. As a physics Entity should be able to have mulitple shapes connected to it.

Sugilite
MW 2007-07-01 17:26:33 +00:00
parent 7cafe7f6d9
commit 9800c05c1b
25 changed files with 1246 additions and 740 deletions

View File

@ -29,6 +29,17 @@ Global
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectDependencies) = postSolution
({FD2D303D-0000-0000-0000-000000000000}).2 = ({36B72A9B-0000-0000-0000-000000000000})
({17F7F694-0000-0000-0000-000000000000}).1 = ({36B72A9B-0000-0000-0000-000000000000})
({17F7F6BE-0000-0000-0000-000000000000}).2 = ({36B72A9B-0000-0000-0000-000000000000})
({6ECC56A9-0000-0000-0000-000000000000}).1 = ({36B72A9B-0000-0000-0000-000000000000})
({586E2916-0000-0000-0000-000000000000}).4 = ({36B72A9B-0000-0000-0000-000000000000})
({60FCC3A6-0000-0000-0000-000000000000}).4 = ({36B72A9B-0000-0000-0000-000000000000})
({60FCC3A6-0000-0000-0000-000000000000}).7 = ({4B7BFD1C-0000-0000-0000-000000000000})
({2FC96F92-0000-0000-0000-000000000000}).4 = ({36B72A9B-0000-0000-0000-000000000000})
({2FC96F92-0000-0000-0000-000000000000}).7 = ({586E2916-0000-0000-0000-000000000000})
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{36B72A9B-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{36B72A9B-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU

View File

@ -1,5 +1,5 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
# Visual C# Express 2005
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim", "OpenSim\Region\Application\OpenSim.csproj", "{438A9556-0000-0000-0000-000000000000}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim.Framework", "OpenSim\Framework\General\OpenSim.Framework.csproj", "{8ACA2445-0000-0000-0000-000000000000}"

View File

@ -54,13 +54,16 @@ namespace OpenSim.Framework.Communications
#region Packet Handlers
public void HandleUUIDNameRequest(LLUUID uuid, IClientAPI remote_client)
{
System.Text.Encoding enc = System.Text.Encoding.ASCII;
UserProfileData profileData = this.UserServer.GetUserProfile(uuid);
if (profileData != null)
{
UUIDNameReplyPacket packet = new UUIDNameReplyPacket();
packet.UUIDNameBlock = new UUIDNameReplyPacket.UUIDNameBlockBlock[1];
packet.UUIDNameBlock[0] = new UUIDNameReplyPacket.UUIDNameBlockBlock();
packet.UUIDNameBlock[0].ID = profileData.UUID;
packet.UUIDNameBlock[0].FirstName = libsecondlife.Helpers.StringToField(profileData.username);
packet.UUIDNameBlock[0].LastName = libsecondlife.Helpers.StringToField(profileData.surname);
packet.UUIDNameBlock[0].FirstName = enc.GetBytes(profileData.username + "\0");
packet.UUIDNameBlock[0].LastName = enc.GetBytes(profileData.surname +"\0");
remote_client.OutPacket((Packet)packet);
}

View File

@ -160,6 +160,8 @@ namespace OpenSim.Framework.Interfaces
void AttachObject(uint localID, LLQuaternion rotation, byte attachPoint);
void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimData primData, LLVector3 pos, LLQuaternion rotation, LLUUID textureID , uint flags);
void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimData primData, LLVector3 pos, LLUUID textureID, uint flags);
void SendPrimitiveToClient2(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, LLQuaternion rotation, LLUUID textureID, uint flags, LLUUID objectID, LLUUID ownerID);
void SendPrimitiveToClient2(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, LLUUID textureID, uint flags, LLUUID objectID, LLUUID ownerID);
void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLQuaternion rotation);
}
}

View File

@ -184,6 +184,9 @@
<Compile Include="Types\PrimData.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Types\PrimitiveBaseShape.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Types\RegionHandle.cs">
<SubType>Code</SubType>
</Compile>

View File

@ -43,6 +43,7 @@
<include name="Types/NetworkServersInfo.cs" />
<include name="Types/ParcelData.cs" />
<include name="Types/PrimData.cs" />
<include name="Types/PrimitiveBaseShape.cs" />
<include name="Types/RegionHandle.cs" />
<include name="Types/RegionInfo.cs" />
<include name="Types/UUID.cs" />

View File

@ -0,0 +1,106 @@
using System;
using System.Collections.Generic;
using System.Text;
using libsecondlife;
using libsecondlife.Packets;
using OpenSim.Framework.Interfaces;
namespace OpenSim.Framework.Types
{
public enum ShapeType
{
Box,
Sphere,
Ring,
Tube,
Torus,
Prism,
Scuplted,
Cylinder
}
public class PrimitiveBaseShape
{
private ShapeType type;
public byte PCode;
public ushort PathBegin;
public ushort PathEnd;
public byte PathScaleX;
public byte PathScaleY;
public byte PathShearX;
public byte PathShearY;
public sbyte PathSkew;
public ushort ProfileBegin;
public ushort ProfileEnd;
public LLVector3 Scale;
public byte PathCurve;
public byte ProfileCurve;
public uint ParentID = 0;
public ushort ProfileHollow;
public sbyte PathRadiusOffset;
public byte PathRevolutions;
public sbyte PathTaperX;
public sbyte PathTaperY;
public sbyte PathTwist;
public sbyte PathTwistBegin;
public byte[] TextureEntry; // a LL textureEntry in byte[] format
public ShapeType PrimType
{
get
{
return this.type;
}
}
public LLVector3 PrimScale
{
get
{
return this.Scale;
}
}
public PrimitiveBaseShape()
{
}
//void returns need to change of course
public void GetMesh()
{
}
public static PrimitiveBaseShape DefaultCube()
{
PrimitiveBaseShape primShape = new PrimitiveBaseShape();
primShape.Scale = new LLVector3(0.5f, 0.5f, 0.5f);
primShape.PCode = 9;
primShape.ParentID = 0;
primShape.PathBegin = 0;
primShape.PathEnd = 0;
primShape.PathScaleX = 0;
primShape.PathScaleY = 0;
primShape.PathShearX = 0;
primShape.PathShearY = 0;
primShape.PathSkew = 0;
primShape.ProfileBegin = 0;
primShape.ProfileEnd = 0;
primShape.PathCurve = 16;
primShape.ProfileCurve = 1;
primShape.ProfileHollow = 0;
primShape.PathRadiusOffset = 0;
primShape.PathRevolutions = 0;
primShape.PathTaperX = 0;
primShape.PathTaperY = 0;
primShape.PathTwist = 0;
primShape.PathTwistBegin = 0;
return primShape;
}
}
}

View File

@ -167,18 +167,6 @@ namespace OpenSim.Framework.Servers
return response;
}
protected virtual string ParseLLSDXML(string requestBody)
{
// dummy function for now - IMPLEMENT ME!
//Console.WriteLine("LLSD request "+requestBody);
string resp = "";
if (firstcaps)
{
resp = "<llsd><map><key>MapLayer</key><string>http://127.0.0.1:9000/CAPS/</string></map></llsd>";
firstcaps = false;
}
return resp;
}
protected virtual string ParseXMLRPC(string requestBody)
{

View File

@ -1,4 +1,4 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectType>Local</ProjectType>
<ProductVersion>8.0.50727</ProductVersion>
@ -6,8 +6,7 @@
<ProjectGuid>{4B7BFD1C-0000-0000-0000-000000000000}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ApplicationIcon>
</ApplicationIcon>
<ApplicationIcon></ApplicationIcon>
<AssemblyKeyContainerName>
</AssemblyKeyContainerName>
<AssemblyName>OpenSim.Grid.Framework.Manager</AssemblyName>
@ -16,11 +15,9 @@
<DefaultTargetSchema>IE50</DefaultTargetSchema>
<DelaySign>false</DelaySign>
<OutputType>Library</OutputType>
<AppDesignerFolder>
</AppDesignerFolder>
<AppDesignerFolder></AppDesignerFolder>
<RootNamespace>OpenSim.Grid.Framework.Manager</RootNamespace>
<StartupObject>
</StartupObject>
<StartupObject></StartupObject>
<FileUpgradeFlags>
</FileUpgradeFlags>
</PropertyGroup>
@ -31,8 +28,7 @@
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<DocumentationFile>
</DocumentationFile>
<DocumentationFile></DocumentationFile>
<DebugSymbols>True</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>False</Optimize>
@ -41,8 +37,7 @@
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWarn>
</NoWarn>
<NoWarn></NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
@ -51,8 +46,7 @@
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE</DefineConstants>
<DocumentationFile>
</DocumentationFile>
<DocumentationFile></DocumentationFile>
<DebugSymbols>False</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>True</Optimize>
@ -61,27 +55,26 @@
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWarn>
</NoWarn>
<NoWarn></NoWarn>
</PropertyGroup>
<ItemGroup>
<Reference Include="libsecondlife.dll">
<Reference Include="libsecondlife.dll" >
<HintPath>..\..\..\bin\libsecondlife.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="OpenSim.Framework">
<Reference Include="OpenSim.Framework" >
<HintPath>OpenSim.Framework.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="OpenSim.Framework.Servers">
<HintPath>..\..\..\bin\OpenSim.Framework.Servers.dll</HintPath>
<Reference Include="OpenSim.Framework.Servers" >
<HintPath>OpenSim.Framework.Servers.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System">
<Reference Include="System" >
<HintPath>System.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="XMLRPC.dll">
<Reference Include="XMLRPC.dll" >
<HintPath>..\..\..\bin\XMLRPC.dll</HintPath>
<Private>False</Private>
</Reference>

View File

@ -626,6 +626,39 @@ namespace OpenSim.Region.ClientStack
OutPacket(outPacket);
}
public void SendPrimitiveToClient2(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, LLQuaternion rotation, LLUUID textureID, uint flags, LLUUID objectID, LLUUID ownerID)
{
ObjectUpdatePacket outPacket = new ObjectUpdatePacket();
outPacket.RegionData.RegionHandle = regionHandle;
outPacket.RegionData.TimeDilation = timeDilation;
outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
outPacket.ObjectData[0] = this.CreatePrimUpdateBlock(primShape, textureID, flags);
outPacket.ObjectData[0].ID = localID;
outPacket.ObjectData[0].FullID = objectID;
outPacket.ObjectData[0].OwnerID = ownerID;
byte[] pb = pos.GetBytes();
Array.Copy(pb, 0, outPacket.ObjectData[0].ObjectData, 0, pb.Length);
byte[] rot = rotation.GetBytes();
Array.Copy(rot, 0, outPacket.ObjectData[0].ObjectData, 48, rot.Length);
OutPacket(outPacket);
}
public void SendPrimitiveToClient2(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, LLUUID textureID, uint flags, LLUUID objectID, LLUUID ownerID)
{
ObjectUpdatePacket outPacket = new ObjectUpdatePacket();
outPacket.RegionData.RegionHandle = regionHandle;
outPacket.RegionData.TimeDilation = timeDilation;
outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
outPacket.ObjectData[0] = this.CreatePrimUpdateBlock(primShape, textureID, flags);
outPacket.ObjectData[0].ID = localID;
outPacket.ObjectData[0].FullID = objectID;
outPacket.ObjectData[0].OwnerID = ownerID;
byte[] pb = pos.GetBytes();
Array.Copy(pb, 0, outPacket.ObjectData[0].ObjectData, 0, pb.Length);
OutPacket(outPacket);
}
/// <summary>
///
/// </summary>
@ -815,6 +848,22 @@ namespace OpenSim.Region.ClientStack
return objupdate;
}
/// <summary>
/// Create the ObjectDataBlock for a ObjectUpdatePacket (for a Primitive)
/// </summary>
/// <param name="primData"></param>
/// <returns></returns>
protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(PrimitiveBaseShape primShape, LLUUID textureID, uint flags)
{
ObjectUpdatePacket.ObjectDataBlock objupdate = new ObjectUpdatePacket.ObjectDataBlock();
this.SetDefaultPrimPacketValues(objupdate);
objupdate.UpdateFlags = flags;
this.SetPrimPacketShapeData(objupdate, primShape, textureID);
return objupdate;
}
/// <summary>
/// Copy the data from a PrimData object to a ObjectUpdatePacket
/// </summary>
@ -848,6 +897,33 @@ namespace OpenSim.Region.ClientStack
objectData.PathTwistBegin = primData.PathTwistBegin;
}
protected void SetPrimPacketShapeData(ObjectUpdatePacket.ObjectDataBlock objectData, PrimitiveBaseShape primData, LLUUID textureID)
{
LLObject.TextureEntry ntex = new LLObject.TextureEntry(textureID);
objectData.TextureEntry = ntex.ToBytes();
objectData.PCode = primData.PCode;
objectData.PathBegin = primData.PathBegin;
objectData.PathEnd = primData.PathEnd;
objectData.PathScaleX = primData.PathScaleX;
objectData.PathScaleY = primData.PathScaleY;
objectData.PathShearX = primData.PathShearX;
objectData.PathShearY = primData.PathShearY;
objectData.PathSkew = primData.PathSkew;
objectData.ProfileBegin = primData.ProfileBegin;
objectData.ProfileEnd = primData.ProfileEnd;
objectData.Scale = primData.Scale;
objectData.PathCurve = primData.PathCurve;
objectData.ProfileCurve = primData.ProfileCurve;
objectData.ParentID = primData.ParentID;
objectData.ProfileHollow = primData.ProfileHollow;
objectData.PathRadiusOffset = primData.PathRadiusOffset;
objectData.PathRevolutions = primData.PathRevolutions;
objectData.PathTaperX = primData.PathTaperX;
objectData.PathTaperY = primData.PathTaperY;
objectData.PathTwist = primData.PathTwist;
objectData.PathTwistBegin = primData.PathTwistBegin;
}
/// <summary>
/// Set some default values in a ObjectUpdatePacket
/// </summary>

View File

@ -211,7 +211,6 @@ namespace OpenSim.Region.ClientStack
}
break;
case PacketType.ObjectAdd:
// m_world.AddNewPrim((ObjectAddPacket)Pack, this);
if (OnAddPrim != null)
{
OnAddPrim(Pack, this);

View File

@ -45,7 +45,7 @@ namespace OpenSim.Region.Communications.Local
public CommunicationsLocal(NetworkServersInfo serversInfo)
: base(serversInfo)
{
UserServices = new LocalUserServices(this,this.ServersInfo.DefaultHomeLocX,this.ServersInfo.DefaultHomeLocY);
UserServices = new LocalUserServices(this, serversInfo);
UserServices.AddPlugin("OpenSim.Framework.Data.DB4o.dll");
UserServer = UserServices;
GridServer = SandBoxServices;

View File

@ -18,13 +18,15 @@ namespace OpenSim.Region.Communications.Local
{
private CommunicationsLocal m_Parent;
private NetworkServersInfo serversInfo;
private uint defaultHomeX ;
private uint defaultHomeY;
public LocalUserServices(CommunicationsLocal parent, uint defHomeX, uint defHomeY)
public LocalUserServices(CommunicationsLocal parent, NetworkServersInfo serversData)
{
m_Parent = parent;
defaultHomeX = defHomeX;
defaultHomeY = defHomeY;
this.serversInfo = serversData;
defaultHomeX = this.serversInfo.DefaultHomeLocX;
defaultHomeY = this.serversInfo.DefaultHomeLocY;
}
public UserProfileData GetUserProfile(string firstName, string lastName)
@ -81,7 +83,6 @@ namespace OpenSim.Region.Communications.Local
ulong currentRegion = theUser.currentAgent.currentHandle;
RegionInfo reg = m_Parent.GridServer.RequestNeighbourInfo(currentRegion);
if (reg != null)
{
response.Home = "{'region_handle':[r" + (reg.RegionLocX * 256).ToString() + ",r" + (reg.RegionLocY * 256).ToString() + "], " +
@ -92,7 +93,9 @@ namespace OpenSim.Region.Communications.Local
response.SimPort = (Int32)reg.ExternalEndPoint.Port;
response.RegionX = reg.RegionLocX ;
response.RegionY = reg.RegionLocY ;
response.SeedCapability = "http://" + reg.ExternalHostName + ":" + reg.ExternalEndPoint.Port.ToString() + "/CAPS/" + capsPath + "0000/";
//following port needs changing as we don't want a http listener for every region (or do we?)
response.SeedCapability = "http://" + reg.ExternalHostName + ":" + this.serversInfo.HttpListenerPort.ToString() + "/CAPS/" + capsPath + "0000/";
theUser.currentAgent.currentRegion = reg.SimUUID;
theUser.currentAgent.currentHandle = reg.RegionHandle;

View File

@ -156,12 +156,18 @@
<Compile Include="Scenes\Entity.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Scenes\EntityBase.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Scenes\IScenePresenceBody.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Scenes\Primitive.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Scenes\PrimitiveOld.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Scenes\Scene.cs">
<SubType>Code</SubType>
</Compile>

View File

@ -15,8 +15,10 @@
<include name="ParcelManager.cs" />
<include name="RegionManager.cs" />
<include name="Scenes/Entity.cs" />
<include name="Scenes/EntityBase.cs" />
<include name="Scenes/IScenePresenceBody.cs" />
<include name="Scenes/Primitive.cs" />
<include name="Scenes/PrimitiveOld.cs" />
<include name="Scenes/Scene.cs" />
<include name="Scenes/Scene.PacketHandlers.cs" />
<include name="Scenes/SceneBase.cs" />

View File

@ -34,29 +34,14 @@ using libsecondlife;
namespace OpenSim.Region.Environment.Scenes
{
public abstract class Entity
public abstract class Entity :EntityBase //will be phased out
{
public libsecondlife.LLUUID uuid;
public Quaternion rotation;
protected List<Entity> children;
protected PhysicsActor _physActor;
protected Scene m_world;
protected string m_name;
/// <summary>
///
/// </summary>
public virtual string Name
{
get { return m_name; }
}
protected LLVector3 m_pos;
/// <summary>
///
/// </summary>
public virtual LLVector3 Pos
public override LLVector3 Pos
{
get
{
@ -91,12 +76,11 @@ namespace OpenSim.Region.Environment.Scenes
}
}
public LLVector3 velocity;
/// <summary>
///
/// </summary>
public virtual LLVector3 Velocity
public override LLVector3 Velocity
{
get
{
@ -130,64 +114,5 @@ namespace OpenSim.Region.Environment.Scenes
velocity = value;
}
}
protected uint m_localId;
public uint LocalId
{
get { return m_localId; }
}
/// <summary>
/// Creates a new Entity (should not occur on it's own)
/// </summary>
public Entity()
{
uuid = new libsecondlife.LLUUID();
m_pos = new LLVector3();
velocity = new LLVector3();
rotation = new Quaternion();
m_name = "(basic entity)";
children = new List<Entity>();
}
/// <summary>
///
/// </summary>
public virtual void updateMovement()
{
foreach (Entity child in children)
{
child.updateMovement();
}
}
/// <summary>
/// Performs any updates that need to be done at each frame. This function is overridable from it's children.
/// </summary>
public virtual void update() {
// Do any per-frame updates needed that are applicable to every type of entity
foreach (Entity child in children)
{
child.update();
}
}
/// <summary>
/// Called at a set interval to inform entities that they should back themsleves up to the DB
/// </summary>
public virtual void BackUp()
{
}
/// <summary>
/// Infoms the entity that the land (heightmap) has changed
/// </summary>
public virtual void LandRenegerated()
{
}
}
}

View File

@ -0,0 +1,133 @@
using System;
using System.Collections.Generic;
using System.Text;
using Axiom.MathLib;
using libsecondlife;
namespace OpenSim.Region.Environment.Scenes
{
public abstract class EntityBase
{
public libsecondlife.LLUUID uuid;
protected List<EntityBase> children;
protected Scene m_world;
protected string m_name;
/// <summary>
///
/// </summary>
public virtual string Name
{
get { return m_name; }
}
protected LLVector3 m_pos;
/// <summary>
///
/// </summary>
public virtual LLVector3 Pos
{
get
{
return m_pos;
}
set
{
m_pos = value;
}
}
public LLVector3 velocity;
/// <summary>
///
/// </summary>
public virtual LLVector3 Velocity
{
get
{
return velocity;
}
set
{
velocity = value;
}
}
public Quaternion _rotation;
public virtual Quaternion rotation
{
get
{
return _rotation;
}
set
{
_rotation = value;
}
}
protected uint m_localId;
public uint LocalId
{
get { return m_localId; }
}
/// <summary>
/// Creates a new Entity (should not occur on it's own)
/// </summary>
public EntityBase()
{
uuid = new libsecondlife.LLUUID();
m_pos = new LLVector3();
velocity = new LLVector3();
rotation = new Quaternion();
m_name = "(basic entity)";
children = new List<EntityBase>();
}
/// <summary>
///
/// </summary>
public virtual void updateMovement()
{
foreach (EntityBase child in children)
{
child.updateMovement();
}
}
/// <summary>
/// Performs any updates that need to be done at each frame. This function is overridable from it's children.
/// </summary>
public virtual void update()
{
// Do any per-frame updates needed that are applicable to every type of entity
foreach (EntityBase child in children)
{
child.update();
}
}
/// <summary>
/// Called at a set interval to inform entities that they should back themsleves up to the DB
/// </summary>
public virtual void BackUp()
{
}
/// <summary>
/// Infoms the entity that the land (heightmap) has changed
/// </summary>
public virtual void LandRenegerated()
{
}
}
}

View File

@ -1,31 +1,3 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Text;
@ -38,171 +10,62 @@ using OpenSim.Framework.Inventory;
namespace OpenSim.Region.Environment.Scenes
{
public class Primitive : Entity
public class Primitive : EntityBase
{
internal PrimData primData;
private LLVector3 positionLastFrame = new LLVector3(0, 0, 0);
// private Dictionary<uint, IClientAPI> m_clientThreads;
private ulong m_regionHandle;
private const uint FULL_MASK_PERMISSIONS = 2147483647;
private bool physicsEnabled = false;
private LLVector3 positionLastFrame = new LLVector3(0, 0, 0);
private ulong m_regionHandle;
private byte updateFlag = 0;
private uint flags = 32 + 65536 + 131072 + 256 + 4 + 8 + 2048 + 524288 + 268435456 + 128;
private Dictionary<LLUUID, InventoryItem> inventoryItems;
#region Properties
public LLUUID OwnerID;
public Int32 CreationDate;
public uint OwnerMask = FULL_MASK_PERMISSIONS;
public uint NextOwnerMask = FULL_MASK_PERMISSIONS;
public uint GroupMask = FULL_MASK_PERMISSIONS;
public uint EveryoneMask = FULL_MASK_PERMISSIONS;
public uint BaseMask = FULL_MASK_PERMISSIONS;
public LLVector3 Scale
{
set
{
this.primData.Scale = value;
//this.dirtyFlag = true;
}
get
{
return this.primData.Scale;
}
}
private PrimitiveBaseShape m_Shape;
public PhysicsActor PhysActor
{
set
{
this._physActor = value;
}
}
private SceneObject m_RootParent;
private bool isRootPrim;
private EntityBase m_Parent;
public override LLVector3 Pos
{
get
{
return base.Pos;
if (isRootPrim)
{
return this.m_pos + m_Parent.Pos;
}
else
{
return this.m_pos;
}
}
set
{
base.Pos = value;
this.m_pos = value - m_Parent.Pos; //should we being subtracting the parent position
}
}
#endregion
/// <summary>
///
/// </summary>
/// <param name="clientThreads"></param>
/// <param name="regionHandle"></param>
/// <param name="world"></param>
public Primitive( ulong regionHandle, Scene world)
}
public Primitive(ulong regionHandle, Scene world, ObjectAddPacket addPacket, LLUUID ownerID, uint localID, bool isRoot, EntityBase parent , SceneObject rootObject)
{
// m_clientThreads = clientThreads;
m_regionHandle = regionHandle;
m_world = world;
inventoryItems = new Dictionary<LLUUID, InventoryItem>();
}
/// <summary>
///
/// </summary>
/// <param name="regionHandle"></param>
/// <param name="world"></param>
/// <param name="addPacket"></param>
/// <param name="ownerID"></param>
/// <param name="localID"></param>
public Primitive(ulong regionHandle, Scene world, ObjectAddPacket addPacket, LLUUID ownerID, uint localID)
{
// m_clientThreads = clientThreads;
m_regionHandle = regionHandle;
m_world = world;
inventoryItems = new Dictionary<LLUUID, InventoryItem>();
this.m_Parent = parent;
this.isRootPrim = isRoot;
this.m_RootParent = rootObject;
this.CreateFromPacket(addPacket, ownerID, localID);
}
/// <summary>
///
/// </summary>
/// <param name="clientThreads"></param>
/// <param name="regionHandle"></param>
/// <param name="world"></param>
/// <param name="owner"></param>
/// <param name="fullID"></param>
/// <param name="localID"></param>
public Primitive( ulong regionHandle, Scene world, LLUUID owner, LLUUID fullID, uint localID)
{
// m_clientThreads = clientThreads;
m_regionHandle = regionHandle;
m_world = world;
inventoryItems = new Dictionary<LLUUID, InventoryItem>();
this.primData = new PrimData();
this.primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
this.primData.OwnerID = owner;
this.primData.FullID = this.uuid = fullID;
this.primData.LocalID = m_localId = localID;
}
/// <summary>
/// Constructor to create a default cube
/// </summary>
/// <param name="clientThreads"></param>
/// <param name="regionHandle"></param>
/// <param name="world"></param>
/// <param name="owner"></param>
/// <param name="localID"></param>
/// <param name="position"></param>
public Primitive( ulong regionHandle, Scene world, LLUUID owner, uint localID, LLVector3 position)
{
//m_clientThreads = clientThreads;
m_regionHandle = regionHandle;
m_world = world;
inventoryItems = new Dictionary<LLUUID, InventoryItem>();
this.primData = PrimData.DefaultCube();
this.primData.OwnerID = owner;
this.primData.LocalID = m_localId = localID;
this.Pos = this.primData.Position = position;
this.updateFlag = 1;
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public byte[] GetByteArray()
{
byte[] result = null;
List<byte[]> dataArrays = new List<byte[]>();
dataArrays.Add(primData.ToBytes());
foreach (Entity child in children)
{
if (child is OpenSim.Region.Environment.Scenes.Primitive)
{
dataArrays.Add(((OpenSim.Region.Environment.Scenes.Primitive)child).GetByteArray());
}
}
byte[] primstart = Helpers.StringToField("<Prim>");
byte[] primend = Helpers.StringToField("</Prim>");
int totalLength = primstart.Length + primend.Length;
for (int i = 0; i < dataArrays.Count; i++)
{
totalLength += dataArrays[i].Length;
}
result = new byte[totalLength];
int arraypos = 0;
Array.Copy(primstart, 0, result, 0, primstart.Length);
arraypos += primstart.Length;
for (int i = 0; i < dataArrays.Count; i++)
{
Array.Copy(dataArrays[i], 0, result, arraypos, dataArrays[i].Length);
arraypos += dataArrays[i].Length;
}
Array.Copy(primend, 0, result, arraypos, primend.Length);
return result;
}
#region Overridden Methods
/// <summary>
///
/// </summary>
@ -218,166 +81,73 @@ namespace OpenSim.Region.Environment.Scenes
this.SendTerseUpdateToALLClients();
this.updateFlag = 0;
}
base.update();
}
/// <summary>
///
/// </summary>
public override void BackUp()
/// <param name="addPacket"></param>
/// <param name="ownerID"></param>
/// <param name="localID"></param>
public void CreateFromPacket(ObjectAddPacket addPacket, LLUUID ownerID, uint localID)
{
this.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
this.OwnerID = ownerID;
this.Pos = addPacket.ObjectData.RayEnd;
this.uuid = LLUUID.Random();
this.m_localId = (uint)(localID);
PrimitiveBaseShape pShape = new PrimitiveBaseShape();
this.m_Shape = pShape;
pShape.PCode = addPacket.ObjectData.PCode;
pShape.PathBegin = addPacket.ObjectData.PathBegin;
pShape.PathEnd = addPacket.ObjectData.PathEnd;
pShape.PathScaleX = addPacket.ObjectData.PathScaleX;
pShape.PathScaleY = addPacket.ObjectData.PathScaleY;
pShape.PathShearX = addPacket.ObjectData.PathShearX;
pShape.PathShearY = addPacket.ObjectData.PathShearY;
pShape.PathSkew = addPacket.ObjectData.PathSkew;
pShape.ProfileBegin = addPacket.ObjectData.ProfileBegin;
pShape.ProfileEnd = addPacket.ObjectData.ProfileEnd;
pShape.Scale = addPacket.ObjectData.Scale;
pShape.PathCurve = addPacket.ObjectData.PathCurve;
pShape.ProfileCurve = addPacket.ObjectData.ProfileCurve;
pShape.ParentID = 0;
pShape.ProfileHollow = addPacket.ObjectData.ProfileHollow;
pShape.PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset;
pShape.PathRevolutions = addPacket.ObjectData.PathRevolutions;
pShape.PathTaperX = addPacket.ObjectData.PathTaperX;
pShape.PathTaperY = addPacket.ObjectData.PathTaperY;
pShape.PathTwist = addPacket.ObjectData.PathTwist;
pShape.PathTwistBegin = addPacket.ObjectData.PathTwistBegin;
this.updateFlag = 1;
}
public void AddToChildren(SceneObject linkObject)
{
}
#endregion
#region Packet handlers
/// <summary>
///
/// </summary>
/// <param name="pos"></param>
public void UpdatePosition(LLVector3 pos)
{
this.Pos = new LLVector3(pos.X, pos.Y, pos.Z);
LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z);
if (this.isRootPrim)
{
this.m_Parent.Pos = newPos;
}
this.Pos = newPos;
this.updateFlag = 2;
}
/// <summary>
///
/// </summary>
/// <param name="addPacket"></param>
public void UpdateShape(ObjectShapePacket.ObjectDataBlock updatePacket)
{
this.primData.PathBegin = updatePacket.PathBegin;
this.primData.PathEnd = updatePacket.PathEnd;
this.primData.PathScaleX = updatePacket.PathScaleX;
this.primData.PathScaleY = updatePacket.PathScaleY;
this.primData.PathShearX = updatePacket.PathShearX;
this.primData.PathShearY = updatePacket.PathShearY;
this.primData.PathSkew = updatePacket.PathSkew;
this.primData.ProfileBegin = updatePacket.ProfileBegin;
this.primData.ProfileEnd = updatePacket.ProfileEnd;
this.primData.PathCurve = updatePacket.PathCurve;
this.primData.ProfileCurve = updatePacket.ProfileCurve;
this.primData.ProfileHollow = updatePacket.ProfileHollow;
this.primData.PathRadiusOffset = updatePacket.PathRadiusOffset;
this.primData.PathRevolutions = updatePacket.PathRevolutions;
this.primData.PathTaperX = updatePacket.PathTaperX;
this.primData.PathTaperY = updatePacket.PathTaperY;
this.primData.PathTwist = updatePacket.PathTwist;
this.primData.PathTwistBegin = updatePacket.PathTwistBegin;
}
/// <summary>
///
/// </summary>
/// <param name="tex"></param>
public void UpdateTexture(byte[] tex)
{
this.primData.TextureEntry = tex;
}
/// <summary>
///
/// </summary>
/// <param name="pack"></param>
public void UpdateObjectFlags(ObjectFlagUpdatePacket pack)
{
}
/// <summary>
///
/// </summary>
/// <param name="prim"></param>
public void AssignToParent(Primitive prim)
{
}
#endregion
# region Inventory Methods
/// <summary>
///
/// </summary>
/// <param name="item"></param>
/// <returns></returns>
public bool AddToInventory(InventoryItem item)
{
return false;
}
/// <summary>
///
/// </summary>
/// <param name="itemID"></param>
/// <returns></returns>
public InventoryItem RemoveFromInventory(LLUUID itemID)
{
return null;
}
/// <summary>
///
/// </summary>
/// <param name="simClient"></param>
/// <param name="packet"></param>
public void RequestInventoryInfo(IClientAPI simClient, RequestTaskInventoryPacket packet)
{
}
/// <summary>
///
/// </summary>
/// <param name="simClient"></param>
/// <param name="xferID"></param>
public void RequestXferInventory(IClientAPI simClient, ulong xferID)
{
//will only currently work if the total size of the inventory data array is under about 1000 bytes
SendXferPacketPacket send = new SendXferPacketPacket();
send.XferID.ID = xferID;
send.XferID.Packet = 1 + 2147483648;
send.DataPacket.Data = this.ConvertInventoryToBytes();
simClient.OutPacket(send);
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public byte[] ConvertInventoryToBytes()
{
System.Text.Encoding enc = System.Text.Encoding.ASCII;
byte[] result = new byte[0];
List<byte[]> inventoryData = new List<byte[]>();
int totallength = 0;
foreach (InventoryItem invItem in inventoryItems.Values)
{
byte[] data = enc.GetBytes(invItem.ExportString());
inventoryData.Add(data);
totallength += data.Length;
}
//TODO: copy arrays into the single result array
return result;
}
/// <summary>
///
/// </summary>
/// <param name="data"></param>
public void CreateInventoryFromBytes(byte[] data)
{
}
#endregion
#region Update viewers Methods
#region Client Update Methods
/// <summary>
///
@ -402,17 +172,9 @@ namespace OpenSim.Region.Environment.Scenes
public void SendFullUpdateToClient(IClientAPI remoteClient)
{
LLVector3 lPos;
if (this._physActor != null && this.physicsEnabled)
{
PhysicsVector pPos = this._physActor.Position;
lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z);
}
else
{
lPos = this.Pos;
}
remoteClient.SendPrimitiveToClient(this.m_regionHandle, 64096, this.LocalId, this.primData, lPos, new LLUUID("00000000-0000-0000-9999-000000000005"), this.flags);
remoteClient.SendPrimitiveToClient2(this.m_regionHandle, 64096, this.LocalId, this.m_Shape, lPos, new LLUUID("00000000-0000-0000-9999-000000000005"), this.flags, this.uuid, this.OwnerID);
}
/// <summary>
@ -427,6 +189,22 @@ namespace OpenSim.Region.Environment.Scenes
}
}
/// <summary>
///
/// </summary>
/// <param name="remoteClient"></param>
public void SendTerseUpdateForAllChildren(IClientAPI remoteClient)
{
this.SendTerseUpdateToClient(remoteClient);
for (int i = 0; i < this.children.Count; i++)
{
if (this.children[i] is Primitive)
{
((Primitive)this.children[i]).SendTerseUpdateForAllChildren(remoteClient);
}
}
}
/// <summary>
///
/// </summary>
@ -435,17 +213,10 @@ namespace OpenSim.Region.Environment.Scenes
{
LLVector3 lPos;
Axiom.MathLib.Quaternion lRot;
if (this._physActor != null && this.physicsEnabled) //is this needed ? doesn't the property fields do this for us?
{
PhysicsVector pPos = this._physActor.Position;
lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z);
lRot = this._physActor.Orientation;
}
else
{
lPos = this.Pos;
lRot = this.rotation;
}
LLQuaternion mRot = new LLQuaternion(lRot.x, lRot.y, lRot.z, lRot.w);
RemoteClient.SendPrimTerseUpdate(this.m_regionHandle, 64096, this.LocalId, lPos, mRot);
}
@ -463,120 +234,5 @@ namespace OpenSim.Region.Environment.Scenes
}
#endregion
#region Create Methods
/// <summary>
///
/// </summary>
/// <param name="addPacket"></param>
/// <param name="ownerID"></param>
/// <param name="localID"></param>
public void CreateFromPacket(ObjectAddPacket addPacket, LLUUID ownerID, uint localID)
{
PrimData PData = new PrimData();
this.primData = PData;
this.primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
PData.OwnerID = ownerID;
PData.PCode = addPacket.ObjectData.PCode;
PData.PathBegin = addPacket.ObjectData.PathBegin;
PData.PathEnd = addPacket.ObjectData.PathEnd;
PData.PathScaleX = addPacket.ObjectData.PathScaleX;
PData.PathScaleY = addPacket.ObjectData.PathScaleY;
PData.PathShearX = addPacket.ObjectData.PathShearX;
PData.PathShearY = addPacket.ObjectData.PathShearY;
PData.PathSkew = addPacket.ObjectData.PathSkew;
PData.ProfileBegin = addPacket.ObjectData.ProfileBegin;
PData.ProfileEnd = addPacket.ObjectData.ProfileEnd;
PData.Scale = addPacket.ObjectData.Scale;
PData.PathCurve = addPacket.ObjectData.PathCurve;
PData.ProfileCurve = addPacket.ObjectData.ProfileCurve;
PData.ParentID = 0;
PData.ProfileHollow = addPacket.ObjectData.ProfileHollow;
PData.PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset;
PData.PathRevolutions = addPacket.ObjectData.PathRevolutions;
PData.PathTaperX = addPacket.ObjectData.PathTaperX;
PData.PathTaperY = addPacket.ObjectData.PathTaperY;
PData.PathTwist = addPacket.ObjectData.PathTwist;
PData.PathTwistBegin = addPacket.ObjectData.PathTwistBegin;
LLVector3 pos1 = addPacket.ObjectData.RayEnd;
this.primData.FullID = this.uuid = LLUUID.Random();
this.primData.LocalID = m_localId = (uint)(localID);
this.primData.Position = this.Pos = pos1;
this.updateFlag = 1;
}
/// <summary>
///
/// </summary>
/// <param name="data"></param>
public void CreateFromBytes(byte[] data)
{
}
/// <summary>
///
/// </summary>
/// <param name="primData"></param>
public void CreateFromPrimData(PrimData primData)
{
this.CreateFromPrimData(primData, primData.Position, primData.LocalID, false);
}
/// <summary>
///
/// </summary>
/// <param name="primData"></param>
/// <param name="posi"></param>
/// <param name="localID"></param>
/// <param name="newprim"></param>
public void CreateFromPrimData(PrimData primData, LLVector3 posi, uint localID, bool newprim)
{
}
public void GrapMovement(LLVector3 offset, LLVector3 pos, IClientAPI remoteClient)
{
// Console.WriteLine("moving prim to new location " + pos.X + " , " + pos.Y + " , " + pos.Z);
this.Pos = pos;
this.SendTerseUpdateToALLClients();
}
public void GetProperites(IClientAPI client)
{
//needs changing
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)primData.CreationDate;
proper.ObjectData[0].CreatorID = primData.OwnerID;
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 = LLUUID.Zero;
proper.ObjectData[0].ObjectID = this.uuid;
proper.ObjectData[0].OwnerID = primData.OwnerID;
proper.ObjectData[0].TouchName = new byte[0];
proper.ObjectData[0].TextureID = new byte[0];
proper.ObjectData[0].SitName = new byte[0];
proper.ObjectData[0].Name = new byte[0];
proper.ObjectData[0].Description = new byte[0];
proper.ObjectData[0].OwnerMask = primData.OwnerMask;
proper.ObjectData[0].NextOwnerMask = primData.NextOwnerMask;
proper.ObjectData[0].GroupMask = primData.GroupMask;
proper.ObjectData[0].EveryoneMask = primData.EveryoneMask;
proper.ObjectData[0].BaseMask = primData.BaseMask;
client.OutPacket(proper);
}
#endregion
}
}

View File

@ -0,0 +1,582 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Text;
using libsecondlife;
using libsecondlife.Packets;
using OpenSim.Framework.Interfaces;
using OpenSim.Physics.Manager;
using OpenSim.Framework.Types;
using OpenSim.Framework.Inventory;
namespace OpenSim.Region.Environment.Scenes
{
public class PrimitiveOld : Entity
{
internal PrimData primData;
private LLVector3 positionLastFrame = new LLVector3(0, 0, 0);
// private Dictionary<uint, IClientAPI> m_clientThreads;
private ulong m_regionHandle;
private const uint FULL_MASK_PERMISSIONS = 2147483647;
private bool physicsEnabled = false;
private byte updateFlag = 0;
private uint flags = 32 + 65536 + 131072 + 256 + 4 + 8 + 2048 + 524288 + 268435456 + 128;
private Dictionary<LLUUID, InventoryItem> inventoryItems;
#region Properties
public LLVector3 Scale
{
set
{
this.primData.Scale = value;
//this.dirtyFlag = true;
}
get
{
return this.primData.Scale;
}
}
public PhysicsActor PhysActor
{
set
{
this._physActor = value;
}
}
public override LLVector3 Pos
{
get
{
return base.Pos;
}
set
{
base.Pos = value;
}
}
#endregion
/// <summary>
///
/// </summary>
/// <param name="clientThreads"></param>
/// <param name="regionHandle"></param>
/// <param name="world"></param>
public PrimitiveOld( ulong regionHandle, Scene world)
{
// m_clientThreads = clientThreads;
m_regionHandle = regionHandle;
m_world = world;
inventoryItems = new Dictionary<LLUUID, InventoryItem>();
}
/// <summary>
///
/// </summary>
/// <param name="regionHandle"></param>
/// <param name="world"></param>
/// <param name="addPacket"></param>
/// <param name="ownerID"></param>
/// <param name="localID"></param>
public PrimitiveOld(ulong regionHandle, Scene world, ObjectAddPacket addPacket, LLUUID ownerID, uint localID)
{
// m_clientThreads = clientThreads;
m_regionHandle = regionHandle;
m_world = world;
inventoryItems = new Dictionary<LLUUID, InventoryItem>();
this.CreateFromPacket(addPacket, ownerID, localID);
}
/// <summary>
///
/// </summary>
/// <param name="clientThreads"></param>
/// <param name="regionHandle"></param>
/// <param name="world"></param>
/// <param name="owner"></param>
/// <param name="fullID"></param>
/// <param name="localID"></param>
public PrimitiveOld( ulong regionHandle, Scene world, LLUUID owner, LLUUID fullID, uint localID)
{
// m_clientThreads = clientThreads;
m_regionHandle = regionHandle;
m_world = world;
inventoryItems = new Dictionary<LLUUID, InventoryItem>();
this.primData = new PrimData();
this.primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
this.primData.OwnerID = owner;
this.primData.FullID = this.uuid = fullID;
this.primData.LocalID = m_localId = localID;
}
/// <summary>
/// Constructor to create a default cube
/// </summary>
/// <param name="clientThreads"></param>
/// <param name="regionHandle"></param>
/// <param name="world"></param>
/// <param name="owner"></param>
/// <param name="localID"></param>
/// <param name="position"></param>
public PrimitiveOld( ulong regionHandle, Scene world, LLUUID owner, uint localID, LLVector3 position)
{
//m_clientThreads = clientThreads;
m_regionHandle = regionHandle;
m_world = world;
inventoryItems = new Dictionary<LLUUID, InventoryItem>();
this.primData = PrimData.DefaultCube();
this.primData.OwnerID = owner;
this.primData.LocalID = m_localId = localID;
this.Pos = this.primData.Position = position;
this.updateFlag = 1;
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public byte[] GetByteArray()
{
byte[] result = null;
List<byte[]> dataArrays = new List<byte[]>();
dataArrays.Add(primData.ToBytes());
foreach (Entity child in children)
{
if (child is OpenSim.Region.Environment.Scenes.PrimitiveOld)
{
dataArrays.Add(((OpenSim.Region.Environment.Scenes.PrimitiveOld)child).GetByteArray());
}
}
byte[] primstart = Helpers.StringToField("<Prim>");
byte[] primend = Helpers.StringToField("</Prim>");
int totalLength = primstart.Length + primend.Length;
for (int i = 0; i < dataArrays.Count; i++)
{
totalLength += dataArrays[i].Length;
}
result = new byte[totalLength];
int arraypos = 0;
Array.Copy(primstart, 0, result, 0, primstart.Length);
arraypos += primstart.Length;
for (int i = 0; i < dataArrays.Count; i++)
{
Array.Copy(dataArrays[i], 0, result, arraypos, dataArrays[i].Length);
arraypos += dataArrays[i].Length;
}
Array.Copy(primend, 0, result, arraypos, primend.Length);
return result;
}
#region Overridden Methods
/// <summary>
///
/// </summary>
public override void update()
{
if (this.updateFlag == 1) // is a new prim just been created/reloaded
{
this.SendFullUpdateToAllClients();
this.updateFlag = 0;
}
if (this.updateFlag == 2) //some change has been made so update the clients
{
this.SendTerseUpdateToALLClients();
this.updateFlag = 0;
}
}
/// <summary>
///
/// </summary>
public override void BackUp()
{
}
#endregion
#region Packet handlers
/// <summary>
///
/// </summary>
/// <param name="pos"></param>
public void UpdatePosition(LLVector3 pos)
{
this.Pos = new LLVector3(pos.X, pos.Y, pos.Z);
this.updateFlag = 2;
}
/// <summary>
///
/// </summary>
/// <param name="addPacket"></param>
public void UpdateShape(ObjectShapePacket.ObjectDataBlock updatePacket)
{
this.primData.PathBegin = updatePacket.PathBegin;
this.primData.PathEnd = updatePacket.PathEnd;
this.primData.PathScaleX = updatePacket.PathScaleX;
this.primData.PathScaleY = updatePacket.PathScaleY;
this.primData.PathShearX = updatePacket.PathShearX;
this.primData.PathShearY = updatePacket.PathShearY;
this.primData.PathSkew = updatePacket.PathSkew;
this.primData.ProfileBegin = updatePacket.ProfileBegin;
this.primData.ProfileEnd = updatePacket.ProfileEnd;
this.primData.PathCurve = updatePacket.PathCurve;
this.primData.ProfileCurve = updatePacket.ProfileCurve;
this.primData.ProfileHollow = updatePacket.ProfileHollow;
this.primData.PathRadiusOffset = updatePacket.PathRadiusOffset;
this.primData.PathRevolutions = updatePacket.PathRevolutions;
this.primData.PathTaperX = updatePacket.PathTaperX;
this.primData.PathTaperY = updatePacket.PathTaperY;
this.primData.PathTwist = updatePacket.PathTwist;
this.primData.PathTwistBegin = updatePacket.PathTwistBegin;
}
/// <summary>
///
/// </summary>
/// <param name="tex"></param>
public void UpdateTexture(byte[] tex)
{
this.primData.TextureEntry = tex;
}
/// <summary>
///
/// </summary>
/// <param name="pack"></param>
public void UpdateObjectFlags(ObjectFlagUpdatePacket pack)
{
}
/// <summary>
///
/// </summary>
/// <param name="prim"></param>
public void AssignToParent(PrimitiveOld prim)
{
}
#endregion
# region Inventory Methods
/// <summary>
///
/// </summary>
/// <param name="item"></param>
/// <returns></returns>
public bool AddToInventory(InventoryItem item)
{
return false;
}
/// <summary>
///
/// </summary>
/// <param name="itemID"></param>
/// <returns></returns>
public InventoryItem RemoveFromInventory(LLUUID itemID)
{
return null;
}
/// <summary>
///
/// </summary>
/// <param name="simClient"></param>
/// <param name="packet"></param>
public void RequestInventoryInfo(IClientAPI simClient, RequestTaskInventoryPacket packet)
{
}
/// <summary>
///
/// </summary>
/// <param name="simClient"></param>
/// <param name="xferID"></param>
public void RequestXferInventory(IClientAPI simClient, ulong xferID)
{
//will only currently work if the total size of the inventory data array is under about 1000 bytes
SendXferPacketPacket send = new SendXferPacketPacket();
send.XferID.ID = xferID;
send.XferID.Packet = 1 + 2147483648;
send.DataPacket.Data = this.ConvertInventoryToBytes();
simClient.OutPacket(send);
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public byte[] ConvertInventoryToBytes()
{
System.Text.Encoding enc = System.Text.Encoding.ASCII;
byte[] result = new byte[0];
List<byte[]> inventoryData = new List<byte[]>();
int totallength = 0;
foreach (InventoryItem invItem in inventoryItems.Values)
{
byte[] data = enc.GetBytes(invItem.ExportString());
inventoryData.Add(data);
totallength += data.Length;
}
//TODO: copy arrays into the single result array
return result;
}
/// <summary>
///
/// </summary>
/// <param name="data"></param>
public void CreateInventoryFromBytes(byte[] data)
{
}
#endregion
#region Update viewers Methods
/// <summary>
///
/// </summary>
/// <param name="remoteClient"></param>
public void SendFullUpdateForAllChildren(IClientAPI remoteClient)
{
this.SendFullUpdateToClient(remoteClient);
for (int i = 0; i < this.children.Count; i++)
{
if (this.children[i] is PrimitiveOld)
{
((PrimitiveOld)this.children[i]).SendFullUpdateForAllChildren(remoteClient);
}
}
}
/// <summary>
///
/// </summary>
/// <param name="remoteClient"></param>
public void SendFullUpdateToClient(IClientAPI remoteClient)
{
LLVector3 lPos;
if (this._physActor != null && this.physicsEnabled)
{
PhysicsVector pPos = this._physActor.Position;
lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z);
}
else
{
lPos = this.Pos;
}
remoteClient.SendPrimitiveToClient(this.m_regionHandle, 64096, this.LocalId, this.primData, lPos, new LLUUID("00000000-0000-0000-9999-000000000005"), this.flags);
}
/// <summary>
///
/// </summary>
public void SendFullUpdateToAllClients()
{
List<ScenePresence> avatars = this.m_world.RequestAvatarList();
for (int i = 0; i < avatars.Count; i++)
{
this.SendFullUpdateToClient(avatars[i].ControllingClient);
}
}
/// <summary>
///
/// </summary>
/// <param name="RemoteClient"></param>
public void SendTerseUpdateToClient(IClientAPI RemoteClient)
{
LLVector3 lPos;
Axiom.MathLib.Quaternion lRot;
if (this._physActor != null && this.physicsEnabled) //is this needed ? doesn't the property fields do this for us?
{
PhysicsVector pPos = this._physActor.Position;
lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z);
lRot = this._physActor.Orientation;
}
else
{
lPos = this.Pos;
lRot = this.rotation;
}
LLQuaternion mRot = new LLQuaternion(lRot.x, lRot.y, lRot.z, lRot.w);
RemoteClient.SendPrimTerseUpdate(this.m_regionHandle, 64096, this.LocalId, lPos, mRot);
}
/// <summary>
///
/// </summary>
public void SendTerseUpdateToALLClients()
{
List<ScenePresence> avatars = this.m_world.RequestAvatarList();
for (int i = 0; i < avatars.Count; i++)
{
this.SendTerseUpdateToClient(avatars[i].ControllingClient);
}
}
#endregion
#region Create Methods
/// <summary>
///
/// </summary>
/// <param name="addPacket"></param>
/// <param name="ownerID"></param>
/// <param name="localID"></param>
public void CreateFromPacket(ObjectAddPacket addPacket, LLUUID ownerID, uint localID)
{
PrimData PData = new PrimData();
this.primData = PData;
this.primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
PData.OwnerID = ownerID;
PData.PCode = addPacket.ObjectData.PCode;
PData.PathBegin = addPacket.ObjectData.PathBegin;
PData.PathEnd = addPacket.ObjectData.PathEnd;
PData.PathScaleX = addPacket.ObjectData.PathScaleX;
PData.PathScaleY = addPacket.ObjectData.PathScaleY;
PData.PathShearX = addPacket.ObjectData.PathShearX;
PData.PathShearY = addPacket.ObjectData.PathShearY;
PData.PathSkew = addPacket.ObjectData.PathSkew;
PData.ProfileBegin = addPacket.ObjectData.ProfileBegin;
PData.ProfileEnd = addPacket.ObjectData.ProfileEnd;
PData.Scale = addPacket.ObjectData.Scale;
PData.PathCurve = addPacket.ObjectData.PathCurve;
PData.ProfileCurve = addPacket.ObjectData.ProfileCurve;
PData.ParentID = 0;
PData.ProfileHollow = addPacket.ObjectData.ProfileHollow;
PData.PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset;
PData.PathRevolutions = addPacket.ObjectData.PathRevolutions;
PData.PathTaperX = addPacket.ObjectData.PathTaperX;
PData.PathTaperY = addPacket.ObjectData.PathTaperY;
PData.PathTwist = addPacket.ObjectData.PathTwist;
PData.PathTwistBegin = addPacket.ObjectData.PathTwistBegin;
LLVector3 pos1 = addPacket.ObjectData.RayEnd;
this.primData.FullID = this.uuid = LLUUID.Random();
this.primData.LocalID = m_localId = (uint)(localID);
this.primData.Position = this.Pos = pos1;
this.updateFlag = 1;
}
/// <summary>
///
/// </summary>
/// <param name="data"></param>
public void CreateFromBytes(byte[] data)
{
}
/// <summary>
///
/// </summary>
/// <param name="primData"></param>
public void CreateFromPrimData(PrimData primData)
{
this.CreateFromPrimData(primData, primData.Position, primData.LocalID, false);
}
/// <summary>
///
/// </summary>
/// <param name="primData"></param>
/// <param name="posi"></param>
/// <param name="localID"></param>
/// <param name="newprim"></param>
public void CreateFromPrimData(PrimData primData, LLVector3 posi, uint localID, bool newprim)
{
}
public void GrapMovement(LLVector3 offset, LLVector3 pos, IClientAPI remoteClient)
{
// Console.WriteLine("moving prim to new location " + pos.X + " , " + pos.Y + " , " + pos.Z);
this.Pos = pos;
this.SendTerseUpdateToALLClients();
}
public void GetProperites(IClientAPI client)
{
//needs changing
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)primData.CreationDate;
proper.ObjectData[0].CreatorID = primData.OwnerID;
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 = LLUUID.Zero;
proper.ObjectData[0].ObjectID = this.uuid;
proper.ObjectData[0].OwnerID = primData.OwnerID;
proper.ObjectData[0].TouchName = new byte[0];
proper.ObjectData[0].TextureID = new byte[0];
proper.ObjectData[0].SitName = new byte[0];
proper.ObjectData[0].Name = new byte[0];
proper.ObjectData[0].Description = new byte[0];
proper.ObjectData[0].OwnerMask = primData.OwnerMask;
proper.ObjectData[0].NextOwnerMask = primData.NextOwnerMask;
proper.ObjectData[0].GroupMask = primData.GroupMask;
proper.ObjectData[0].EveryoneMask = primData.EveryoneMask;
proper.ObjectData[0].BaseMask = primData.BaseMask;
client.OutPacket(proper);
}
#endregion
}
}

View File

@ -214,21 +214,25 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="remoteClient"></param>
public void SelectPrim(uint primLocalID, IClientAPI remoteClient)
{
foreach (Entity ent in Entities.Values)
Console.WriteLine("prim selected :" + primLocalID);
foreach (EntityBase ent in Entities.Values)
{
if (ent.LocalId == primLocalID)
if (ent is SceneObject)
{
((OpenSim.Region.Environment.Scenes.Primitive)ent).GetProperites(remoteClient);
if (((SceneObject)ent).rootLocalID == primLocalID)
{
((OpenSim.Region.Environment.Scenes.SceneObject)ent).GetProperites(remoteClient);
break;
}
}
}
}
public void MoveObject(LLUUID objectID, LLVector3 offset, LLVector3 pos, IClientAPI remoteClient)
{
if (this.Entities.ContainsKey(objectID))
{
((Primitive)this.Entities[objectID]).GrapMovement(offset, pos, remoteClient);
((PrimitiveOld)this.Entities[objectID]).GrapMovement(offset, pos, remoteClient);
}
}
@ -266,7 +270,7 @@ namespace OpenSim.Region.Environment.Scenes
{
if (ent.LocalId == localID)
{
((OpenSim.Region.Environment.Scenes.Primitive)ent).UpdatePosition(pos);
((OpenSim.Region.Environment.Scenes.PrimitiveOld)ent).UpdatePosition(pos);
break;
}
}

View File

@ -68,7 +68,7 @@ namespace OpenSim.Region.Environment.Scenes
protected RegionCommsListener regionCommsHost;
protected CommunicationsManager commsManager;
protected Dictionary<LLUUID,Caps> capsHandlers = new Dictionary<LLUUID, Caps>();
protected Dictionary<LLUUID, Caps> capsHandlers = new Dictionary<LLUUID, Caps>();
protected BaseHttpServer httpListener;
public ParcelManager parcelManager;
@ -121,12 +121,12 @@ namespace OpenSim.Region.Environment.Scenes
scriptManager = new ScriptManager(this);
eventManager = new EventManager();
OpenSim.Framework.Console.MainLog.Instance.Verbose( "World.cs - creating new entitities instance");
Entities = new Dictionary<libsecondlife.LLUUID, Entity>();
OpenSim.Framework.Console.MainLog.Instance.Verbose("World.cs - creating new entitities instance");
Entities = new Dictionary<libsecondlife.LLUUID, EntityBase>();
Avatars = new Dictionary<LLUUID, ScenePresence>();
Prims = new Dictionary<LLUUID, Primitive>();
OpenSim.Framework.Console.MainLog.Instance.Verbose( "World.cs - creating LandMap");
OpenSim.Framework.Console.MainLog.Instance.Verbose("World.cs - creating LandMap");
Terrain = new TerrainEngine();
ScenePresence.LoadAnims();
@ -135,7 +135,7 @@ namespace OpenSim.Region.Environment.Scenes
}
catch (Exception e)
{
OpenSim.Framework.Console.MainLog.Instance.Error( "World.cs: Constructor failed with exception " + e.ToString());
OpenSim.Framework.Console.MainLog.Instance.Error("World.cs: Constructor failed with exception " + e.ToString());
}
}
#endregion
@ -218,49 +218,7 @@ namespace OpenSim.Region.Environment.Scenes
/// <returns></returns>
public bool Backup()
{
/*
try
{
// Terrain backup routines
if (Terrain.tainted > 0)
{
Terrain.tainted = 0;
OpenSim.Framework.Console.MainLog.Instance.Verbose( "World.cs: Backup() - Terrain tainted, saving.");
localStorage.SaveMap(Terrain.getHeights1D());
OpenSim.Framework.Console.MainLog.Instance.Verbose( "World.cs: Backup() - Terrain saved, informing Physics.");
lock (this.m_syncRoot)
{
phyScene.SetTerrain(Terrain.getHeights1D());
}
}
// Primitive backup routines
OpenSim.Framework.Console.MainLog.Instance.Verbose( "World.cs: Backup() - Backing up Primitives");
foreach (libsecondlife.LLUUID UUID in Entities.Keys)
{
Entities[UUID].BackUp();
}
//Parcel backup routines
ParcelData[] parcels = new ParcelData[parcelManager.parcelList.Count];
int i = 0;
foreach (OpenSim.Region.Parcel parcel in parcelManager.parcelList.Values)
{
parcels[i] = parcel.parcelData;
i++;
}
localStorage.SaveParcels(parcels);
// Backup successful
return true;
}
catch (Exception e)
{
// Backup failed
OpenSim.Framework.Console.MainLog.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "World.cs: Backup() - Backup Failed with exception " + e.ToString());
return false;
}
*/
return true;
}
#endregion
@ -432,7 +390,7 @@ namespace OpenSim.Region.Environment.Scenes
{
try
{
OpenSim.Framework.Console.MainLog.Instance.Verbose( "World.cs: LoadPrimsFromStorage() - Loading primitives");
OpenSim.Framework.Console.MainLog.Instance.Verbose("World.cs: LoadPrimsFromStorage() - Loading primitives");
this.localStorage.LoadPrimitives(this);
}
catch (Exception e)
@ -469,13 +427,12 @@ namespace OpenSim.Region.Environment.Scenes
{
try
{
Primitive prim = new Primitive(m_regionHandle, this, addPacket, ownerID, this._primCount);
this.Entities.Add(prim.uuid, prim);
SceneObject sceneOb = new SceneObject(m_regionHandle, this, addPacket, ownerID, this._primCount);
this.Entities.Add(sceneOb.rootUUID, sceneOb);
this._primCount++;
// Trigger event for listeners
eventManager.TriggerOnNewPrimitive(prim);
// eventManager.TriggerOnNewPrimitive(prim);
}
catch (Exception e)
{
@ -500,11 +457,11 @@ namespace OpenSim.Region.Environment.Scenes
client.OnChatFromViewer += this.SimChat;
client.OnRequestWearables += this.InformClientOfNeighbours;
client.OnAddPrim += this.AddNewPrim;
client.OnUpdatePrimPosition += this.UpdatePrimPosition;
//client.OnUpdatePrimPosition += this.UpdatePrimPosition;
client.OnRequestMapBlocks += this.RequestMapBlocks;
client.OnTeleportLocationRequest += this.RequestTeleportLocation;
//remoteClient.OnObjectSelect += this.SelectPrim;
client.OnGrapUpdate += this.MoveObject;
client.OnObjectSelect += this.SelectPrim;
// client.OnGrapUpdate += this.MoveObject;
client.OnNameFromUUIDRequest += this.commsManager.HandleUUIDNameRequest;
/* remoteClient.OnParcelPropertiesRequest += new ParcelPropertiesRequest(parcelManager.handleParcelPropertiesRequest);
@ -523,10 +480,10 @@ namespace OpenSim.Region.Environment.Scenes
{
ScenePresence newAvatar = null;
OpenSim.Framework.Console.MainLog.Instance.Verbose( "World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent");
OpenSim.Framework.Console.MainLog.Instance.Verbose("World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent");
newAvatar = new ScenePresence(client, this, this.m_regInfo);
OpenSim.Framework.Console.MainLog.Instance.Verbose( "World.cs:AddViewerAgent() - Adding new avatar to world");
OpenSim.Framework.Console.MainLog.Instance.Verbose( "World.cs:AddViewerAgent() - Starting RegionHandshake ");
OpenSim.Framework.Console.MainLog.Instance.Verbose("World.cs:AddViewerAgent() - Adding new avatar to world");
OpenSim.Framework.Console.MainLog.Instance.Verbose("World.cs:AddViewerAgent() - Starting RegionHandshake ");
PhysicsVector pVec = new PhysicsVector(newAvatar.Pos.X, newAvatar.Pos.Y, newAvatar.Pos.Z);
lock (this.m_syncRoot)
@ -634,7 +591,7 @@ namespace OpenSim.Region.Environment.Scenes
public void RegisterRegionWithComms()
{
GridInfo gridSettings = new GridInfo();
this.regionCommsHost = this.commsManager.GridServer.RegisterRegion(this.m_regInfo,gridSettings);
this.regionCommsHost = this.commsManager.GridServer.RegisterRegion(this.m_regInfo, gridSettings);
if (this.regionCommsHost != null)
{
this.regionCommsHost.OnExpectUser += this.NewUserConnection;
@ -757,7 +714,9 @@ namespace OpenSim.Region.Environment.Scenes
agent.child = true;
this.commsManager.InterRegion.InformRegionOfChildAgent(regionHandle, agent);
this.commsManager.InterRegion.ExpectAvatarCrossing(regionHandle, remoteClient.AgentId, position);
remoteClient.SendRegionTeleport(regionHandle, 13, reg.ExternalEndPoint, 4, (1 << 4));
}
//remoteClient.SendTeleportCancel();
}

View File

@ -44,7 +44,7 @@ namespace OpenSim.Region.Environment.Scenes
{
public abstract class SceneBase : IWorld
{
public Dictionary<libsecondlife.LLUUID, Entity> Entities;
public Dictionary<libsecondlife.LLUUID, EntityBase> Entities;
protected Dictionary<uint, IClientAPI> m_clientThreads;
protected ulong m_regionHandle;
protected string m_regionName;

View File

@ -15,7 +15,7 @@ namespace OpenSim.Region.Environment.Scenes
public delegate void OnNewPresenceDelegate(ScenePresence presence);
public event OnNewPresenceDelegate OnNewPresence;
public delegate void OnNewPrimitiveDelegate(Primitive prim);
public delegate void OnNewPrimitiveDelegate(PrimitiveOld prim);
public event OnNewPrimitiveDelegate OnNewPrimitive;
public delegate void OnRemovePresenceDelegate(libsecondlife.LLUUID uuid);
@ -29,7 +29,7 @@ namespace OpenSim.Region.Environment.Scenes
}
}
public void TriggerOnNewPrimitive(Primitive prim)
public void TriggerOnNewPrimitive(PrimitiveOld prim)
{
if (OnNewPrimitive != null)
OnNewPrimitive(prim);

View File

@ -37,22 +37,46 @@ using OpenSim.Framework.Inventory;
namespace OpenSim.Region.Environment.Scenes
{
public class SceneObject : Entity
public class SceneObject : EntityBase
{
private LLUUID rootUUID;
//private Dictionary<LLUUID, Primitive> ChildPrimitives = new Dictionary<LLUUID, Primitive>();
private Dictionary<LLUUID, Primitive> ChildPrimitives = new Dictionary<LLUUID, Primitive>(); //list of all primitive id's that are part of this group
protected Primitive rootPrimitive;
private Scene m_world;
protected ulong regionHandle;
protected ulong m_regionHandle;
private bool physicsEnabled = false;
private PhysicsScene m_PhysScene;
private PhysicsActor m_PhysActor;
public LLUUID rootUUID
{
get
{
this.uuid = this.rootPrimitive.uuid;
return this.uuid;
}
}
public uint rootLocalID
{
get
{
this.m_localId = this.rootPrimitive.LocalId;
return this.LocalId;
}
}
/// <summary>
///
/// </summary>
public SceneObject()
public SceneObject(ulong regionHandle, Scene world, ObjectAddPacket addPacket, LLUUID ownerID, uint localID)
{
m_regionHandle = regionHandle;
m_world = world;
this.Pos = addPacket.ObjectData.RayEnd;
this.CreateFromPacket(addPacket, ownerID, localID);
}
/// <summary>
///
/// </summary>
@ -61,7 +85,9 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="localID"></param>
public void CreateFromPacket(ObjectAddPacket addPacket, LLUUID agentID, uint localID)
{
this.rootPrimitive = new Primitive( this.regionHandle, this.m_world, addPacket, agentID, localID);
this.rootPrimitive = new Primitive( this.m_regionHandle, this.m_world, addPacket, agentID, localID, true, this, this);
this.children.Add(rootPrimitive);
this.ChildPrimitives.Add(this.rootUUID, this.rootPrimitive);
}
/// <summary>
@ -76,11 +102,19 @@ namespace OpenSim.Region.Environment.Scenes
/// <summary>
///
/// </summary>
public override void update()
/// <param name="primID"></param>
/// <returns></returns>
public Primitive HasChildPrim(LLUUID primID)
{
if (this.ChildPrimitives.ContainsKey(primID))
{
return this.ChildPrimitives[primID];
}
return null;
}
/// <summary>
///
/// </summary>
@ -89,6 +123,18 @@ namespace OpenSim.Region.Environment.Scenes
}
/// <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;
this.rootPrimitive.SendTerseUpdateForAllChildren(remoteClient);
}
/// <summary>
///
/// </summary>
@ -100,25 +146,25 @@ namespace OpenSim.Region.Environment.Scenes
proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1];
proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock();
proper.ObjectData[0].ItemID = LLUUID.Zero;
proper.ObjectData[0].CreationDate = (ulong)this.rootPrimitive.primData.CreationDate;
proper.ObjectData[0].CreatorID = this.rootPrimitive.primData.OwnerID;
proper.ObjectData[0].CreationDate = (ulong)this.rootPrimitive.CreationDate;
proper.ObjectData[0].CreatorID = this.rootPrimitive.OwnerID;
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 = LLUUID.Zero;
proper.ObjectData[0].ObjectID = this.uuid;
proper.ObjectData[0].OwnerID = this.rootPrimitive.primData.OwnerID;
proper.ObjectData[0].ObjectID = this.rootUUID;
proper.ObjectData[0].OwnerID = this.rootPrimitive.OwnerID;
proper.ObjectData[0].TouchName = new byte[0];
proper.ObjectData[0].TextureID = new byte[0];
proper.ObjectData[0].SitName = new byte[0];
proper.ObjectData[0].Name = new byte[0];
proper.ObjectData[0].Description = new byte[0];
proper.ObjectData[0].OwnerMask = this.rootPrimitive.primData.OwnerMask;
proper.ObjectData[0].NextOwnerMask = this.rootPrimitive.primData.NextOwnerMask;
proper.ObjectData[0].GroupMask = this.rootPrimitive.primData.GroupMask;
proper.ObjectData[0].EveryoneMask = this.rootPrimitive.primData.EveryoneMask;
proper.ObjectData[0].BaseMask = this.rootPrimitive.primData.BaseMask;
proper.ObjectData[0].OwnerMask = this.rootPrimitive.OwnerMask;
proper.ObjectData[0].NextOwnerMask = this.rootPrimitive.NextOwnerMask;
proper.ObjectData[0].GroupMask = this.rootPrimitive.GroupMask;
proper.ObjectData[0].EveryoneMask = this.rootPrimitive.EveryoneMask;
proper.ObjectData[0].BaseMask = this.rootPrimitive.BaseMask;
client.OutPacket(proper);

View File

@ -31,8 +31,16 @@ using System.Text;
namespace OpenSim.Physics.Manager
{
public delegate void PositionUpdate(PhysicsVector position);
public delegate void VelocityUpdate(PhysicsVector velocity);
public delegate void OrientationUpdate(Axiom.MathLib.Quaternion orientation);
public abstract class PhysicsActor
{
public event PositionUpdate OnPositionUpdate;
public event VelocityUpdate OnVelocityUpdate;
public event OrientationUpdate OnOrientationUpdate;
public static PhysicsActor Null
{
get