Split Avatar class into three partial classes (hopefully will make it easier to work on)

0.1-prestable
MW 2007-04-04 16:31:35 +00:00
parent 74484ed2ed
commit 76df9e626d
9 changed files with 471 additions and 404 deletions

View File

@ -166,6 +166,12 @@
<Compile Include="world\AvatarAnimations.cs"> <Compile Include="world\AvatarAnimations.cs">
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Compile Include="world\AvatarClient.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="world\AvatarUpdate.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="world\Entity.cs"> <Compile Include="world\Entity.cs">
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>

View File

@ -29,6 +29,8 @@
<include name="types/Triangle.cs" /> <include name="types/Triangle.cs" />
<include name="world/Avatar.cs" /> <include name="world/Avatar.cs" />
<include name="world/AvatarAnimations.cs" /> <include name="world/AvatarAnimations.cs" />
<include name="world/AvatarClient.cs" />
<include name="world/AvatarUpdate.cs" />
<include name="world/Entity.cs" /> <include name="world/Entity.cs" />
<include name="world/Primitive.cs" /> <include name="world/Primitive.cs" />
<include name="world/Primitive2.cs" /> <include name="world/Primitive2.cs" />

View File

@ -10,7 +10,7 @@ using Axiom.MathLib;
namespace OpenSim.world namespace OpenSim.world
{ {
public class Avatar : Entity public partial class Avatar : Entity
{ {
public static bool PhysicsEngineFlying = false; public static bool PhysicsEngineFlying = false;
public static AvatarAnimations Animations; public static AvatarAnimations Animations;
@ -32,6 +32,7 @@ namespace OpenSim.world
private ulong m_regionHandle; private ulong m_regionHandle;
private Dictionary<uint, SimClient> m_clientThreads; private Dictionary<uint, SimClient> m_clientThreads;
private string m_regionName; private string m_regionName;
private bool childShadowAvatar = false;
public Avatar(SimClient TheClient, World world, string regionName, Dictionary<uint, SimClient> clientThreads, ulong regionHandle) public Avatar(SimClient TheClient, World world, string regionName, Dictionary<uint, SimClient> clientThreads, ulong regionHandle)
{ {
@ -95,60 +96,6 @@ namespace OpenSim.world
} }
} }
public override void update()
{
libsecondlife.LLVector3 pos2 = new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z);
if (this.updateflag)
{
//need to send movement info
//so create the improvedterseobjectupdate packet
//use CreateTerseBlock()
ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = CreateTerseBlock();
ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
terse.RegionData.RegionHandle = m_regionHandle; // FIXME
terse.RegionData.TimeDilation = 64096;
terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
terse.ObjectData[0] = terseBlock;
foreach (SimClient client in m_clientThreads.Values)
{
client.OutPacket(terse);
}
updateflag = false;
//this._updateCount = 0;
}
else
{
if ((pos2 != this.positionLastFrame) || (this.movementflag == 16))
{
_updateCount++;
if (((!PhysicsEngineFlying) && (_updateCount > 3)) || (PhysicsEngineFlying) && (_updateCount > 0))
{
//It has been a while since last update was sent so lets send one.
ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = CreateTerseBlock();
ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
terse.RegionData.RegionHandle = m_regionHandle; // FIXME
terse.RegionData.TimeDilation = 64096;
terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
terse.ObjectData[0] = terseBlock;
foreach (SimClient client in m_clientThreads.Values)
{
client.OutPacket(terse);
}
_updateCount = 0;
}
if (this.movementflag == 16)
{
movementflag = 0;
}
}
}
this.positionLastFrame = pos2;
}
public static void SetupTemplate(string name) public static void SetupTemplate(string name)
{ {
int i = 0; int i = 0;
@ -190,128 +137,6 @@ namespace OpenSim.world
ControllingClient.OutPacket(mov); ControllingClient.OutPacket(mov);
} }
public void SendInitialPosition()
{
System.Text.Encoding _enc = System.Text.Encoding.ASCII;
//send a objectupdate packet with information about the clients avatar
ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
objupdate.RegionData.RegionHandle = m_regionHandle;
objupdate.RegionData.TimeDilation = 64096;
objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
objupdate.ObjectData[0] = AvatarTemplate;
//give this avatar object a local id and assign the user a name
objupdate.ObjectData[0].ID = this.localid;
this.uuid = objupdate.ObjectData[0].FullID = ControllingClient.AgentID;
objupdate.ObjectData[0].NameValue = _enc.GetBytes("FirstName STRING RW SV " + firstname + "\nLastName STRING RW SV " + lastname + " \0");
libsecondlife.LLVector3 pos2 = new LLVector3((float)this.Pos.X, (float)this.Pos.Y, (float)this.Pos.Z);
byte[] pb = pos2.GetBytes();
Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length);
m_world._localNumber++;
foreach (SimClient client in m_clientThreads.Values)
{
client.OutPacket(objupdate);
if (client.AgentID != ControllingClient.AgentID)
{
SendAppearanceToOtherAgent(client);
}
}
//this.ControllingClient.OutPacket(objupdate);
}
public void SendInitialAppearance()
{
AgentWearablesUpdatePacket aw = new AgentWearablesUpdatePacket();
aw.AgentData.AgentID = this.ControllingClient.AgentID;
aw.AgentData.SerialNum = 0;
aw.AgentData.SessionID = ControllingClient.SessionID;
aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[13];
AgentWearablesUpdatePacket.WearableDataBlock awb;
for (int i = 0; i < 13; i++)
{
awb = new AgentWearablesUpdatePacket.WearableDataBlock();
awb.WearableType = (byte)i;
awb.AssetID = this.Wearables[i].AssetID;
awb.ItemID = this.Wearables[i].ItemID;
aw.WearableData[i] = awb;
}
ControllingClient.OutPacket(aw);
}
public ObjectUpdatePacket CreateUpdatePacket()
{
System.Text.Encoding _enc = System.Text.Encoding.ASCII;
//send a objectupdate packet with information about the clients avatar
ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
objupdate.RegionData.RegionHandle = m_regionHandle;
objupdate.RegionData.TimeDilation = 64096;
objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
objupdate.ObjectData[0] = AvatarTemplate;
//give this avatar object a local id and assign the user a name
objupdate.ObjectData[0].ID = this.localid;
objupdate.ObjectData[0].FullID = ControllingClient.AgentID;
objupdate.ObjectData[0].NameValue = _enc.GetBytes("FirstName STRING RW SV " + firstname + "\nLastName STRING RW SV " + lastname + " \0");
libsecondlife.LLVector3 pos2 = new LLVector3((float)this._physActor.Position.X, (float)this._physActor.Position.Y, (float)this._physActor.Position.Z);
byte[] pb = pos2.GetBytes();
Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length);
return objupdate;
}
public void SendAppearanceToOtherAgent(SimClient userInfo)
{
AvatarAppearancePacket avp = new AvatarAppearancePacket();
avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[218];
//avp.ObjectData.TextureEntry=this.avatar_template.TextureEntry;// br.ReadBytes((int)numBytes);
//LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-0000-000000000005"));
//avp.ObjectData.TextureEntry = ntex.ToBytes();
avp.ObjectData.TextureEntry = this.avatarAppearanceTexture.ToBytes();
AvatarAppearancePacket.VisualParamBlock avblock = null;
for (int i = 0; i < 218; i++)
{
avblock = new AvatarAppearancePacket.VisualParamBlock();
avblock.ParamValue = visualParams[i];
avp.VisualParam[i] = avblock;
}
avp.Sender.IsTrial = false;
avp.Sender.ID = ControllingClient.AgentID;
userInfo.OutPacket(avp);
}
public void SetAppearance(AgentSetAppearancePacket appear)
{
LLObject.TextureEntry tex = new LLObject.TextureEntry(appear.ObjectData.TextureEntry, 0, appear.ObjectData.TextureEntry.Length);
this.avatarAppearanceTexture = tex;
for (int i = 0; i < appear.VisualParam.Length; i++)
{
this.visualParams[i] = appear.VisualParam[i].ParamValue;
}
foreach (SimClient client in m_clientThreads.Values)
{
if (client.AgentID != ControllingClient.AgentID)
{
SendAppearanceToOtherAgent(client);
}
}
}
public void HandleUpdate(AgentUpdatePacket pack) public void HandleUpdate(AgentUpdatePacket pack)
{ {
if (((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_FLY) != 0) if (((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_FLY) != 0)
@ -462,28 +287,7 @@ namespace OpenSim.world
} }
} }
// Sends animation update //really really should be moved somewhere else
public void SendAnimPack()
{
AvatarAnimationPacket ani = new AvatarAnimationPacket();
ani.AnimationSourceList = new AvatarAnimationPacket.AnimationSourceListBlock[1];
ani.AnimationSourceList[0] = new AvatarAnimationPacket.AnimationSourceListBlock();
ani.AnimationSourceList[0].ObjectID = ControllingClient.AgentID;
ani.Sender = new AvatarAnimationPacket.SenderBlock();
ani.Sender.ID = ControllingClient.AgentID;
ani.AnimationList = new AvatarAnimationPacket.AnimationListBlock[1];
ani.AnimationList[0] = new AvatarAnimationPacket.AnimationListBlock();
ani.AnimationList[0].AnimID = this.current_anim;
ani.AnimationList[0].AnimSequenceID = this.anim_seq;
//ControllingClient.OutPacket(ani);
foreach (SimClient client in m_clientThreads.Values)
{
client.OutPacket(ani);
}
}
//should be moved somewhere else
public void SendRegionHandshake(World RegionInfo) public void SendRegionHandshake(World RegionInfo)
{ {
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Avatar.cs:SendRegionHandshake() - Creating empty RegionHandshake packet"); OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Avatar.cs:SendRegionHandshake() - Creating empty RegionHandshake packet");
@ -520,89 +324,6 @@ namespace OpenSim.world
this.ControllingClient.OutPacket(handshake); this.ControllingClient.OutPacket(handshake);
} }
public ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateTerseBlock()
{
byte[] bytes = new byte[60];
int i = 0;
ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock();
dat.TextureEntry = new byte[0];// AvatarTemplate.TextureEntry;
libsecondlife.LLVector3 pos2 = new LLVector3(0, 0, 0);
lock (m_world.LockPhysicsEngine)
{
pos2 = new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z);
}
uint ID = this.localid;
bytes[i++] = (byte)(ID % 256);
bytes[i++] = (byte)((ID >> 8) % 256);
bytes[i++] = (byte)((ID >> 16) % 256);
bytes[i++] = (byte)((ID >> 24) % 256);
bytes[i++] = 0;
bytes[i++] = 1;
i += 14;
bytes[i++] = 128;
bytes[i++] = 63;
byte[] pb = pos2.GetBytes();
Array.Copy(pb, 0, bytes, i, pb.Length);
i += 12;
ushort InternVelocityX;
ushort InternVelocityY;
ushort InternVelocityZ;
Axiom.MathLib.Vector3 internDirec = new Axiom.MathLib.Vector3(0, 0, 0);
lock (m_world.LockPhysicsEngine)
{
internDirec = new Axiom.MathLib.Vector3(this._physActor.Velocity.X, this._physActor.Velocity.Y, this._physActor.Velocity.Z);
}
internDirec = internDirec / 128.0f;
internDirec.x += 1;
internDirec.y += 1;
internDirec.z += 1;
InternVelocityX = (ushort)(32768 * internDirec.x);
InternVelocityY = (ushort)(32768 * internDirec.y);
InternVelocityZ = (ushort)(32768 * internDirec.z);
ushort ac = 32767;
bytes[i++] = (byte)(InternVelocityX % 256);
bytes[i++] = (byte)((InternVelocityX >> 8) % 256);
bytes[i++] = (byte)(InternVelocityY % 256);
bytes[i++] = (byte)((InternVelocityY >> 8) % 256);
bytes[i++] = (byte)(InternVelocityZ % 256);
bytes[i++] = (byte)((InternVelocityZ >> 8) % 256);
//accel
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
//rot
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
//rotation vel
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
dat.Data = bytes;
return (dat);
}
public static void LoadAnims() public static void LoadAnims()
{ {
Avatar.Animations = new AvatarAnimations(); Avatar.Animations = new AvatarAnimations();

View File

@ -11,7 +11,6 @@ namespace OpenSim.world
public Dictionary<string, LLUUID> AnimsLLUUID = new Dictionary<string, LLUUID>(); public Dictionary<string, LLUUID> AnimsLLUUID = new Dictionary<string, LLUUID>();
public Dictionary<LLUUID, string> AnimsNames = new Dictionary<LLUUID, string>(); public Dictionary<LLUUID, string> AnimsNames = new Dictionary<LLUUID, string>();
public AvatarAnimations() public AvatarAnimations()
{ {
} }
@ -155,7 +154,6 @@ namespace OpenSim.world
AnimsLLUUID.Add("ANIM_AGENT_YES_HAPPY", new LLUUID("b8c8b2a3-9008-1771-3bfc-90924955ab2d")); AnimsLLUUID.Add("ANIM_AGENT_YES_HAPPY", new LLUUID("b8c8b2a3-9008-1771-3bfc-90924955ab2d"));
AnimsLLUUID.Add("ANIM_AGENT_YOGA_FLOAT", new LLUUID("42ecd00b-9947-a97c-400a-bbc9174c7aeb")); AnimsLLUUID.Add("ANIM_AGENT_YOGA_FLOAT", new LLUUID("42ecd00b-9947-a97c-400a-bbc9174c7aeb"));
foreach (KeyValuePair<string, LLUUID> kp in OpenSim.world.Avatar.Animations.AnimsLLUUID) foreach (KeyValuePair<string, LLUUID> kp in OpenSim.world.Avatar.Animations.AnimsLLUUID)
{ {
AnimsNames.Add(kp.Value, kp.Key); AnimsNames.Add(kp.Value, kp.Key);

View File

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Text;
using libsecondlife.Packets;
namespace OpenSim.world
{
partial class Avatar
{
private List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock> updateList = new List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>();
public void SendPacketToViewer(Packet packet)
{
this.ControllingClient.OutPacket(packet);
}
public void AddTerseUpdateToViewersList(ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock)
{
}
public void SendUpdateListToViewer()
{
}
}
}

View File

@ -0,0 +1,279 @@
using System;
using System.Collections.Generic;
using System.Text;
using libsecondlife;
using libsecondlife.Packets;
namespace OpenSim.world
{
partial class Avatar
{
public override void update()
{
libsecondlife.LLVector3 pos2 = new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z);
if (this.updateflag)
{
//need to send movement info
//so create the improvedterseobjectupdate packet
//use CreateTerseBlock()
ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = CreateTerseBlock();
ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
terse.RegionData.RegionHandle = m_regionHandle; // FIXME
terse.RegionData.TimeDilation = 64096;
terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
terse.ObjectData[0] = terseBlock;
foreach (SimClient client in m_clientThreads.Values)
{
client.OutPacket(terse);
}
updateflag = false;
//this._updateCount = 0;
}
else
{
if ((pos2 != this.positionLastFrame) || (this.movementflag == 16))
{
_updateCount++;
if (((!PhysicsEngineFlying) && (_updateCount > 3)) || (PhysicsEngineFlying) && (_updateCount > 0))
{
//It has been a while since last update was sent so lets send one.
ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = CreateTerseBlock();
ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
terse.RegionData.RegionHandle = m_regionHandle; // FIXME
terse.RegionData.TimeDilation = 64096;
terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
terse.ObjectData[0] = terseBlock;
foreach (SimClient client in m_clientThreads.Values)
{
client.OutPacket(terse);
}
_updateCount = 0;
}
if (this.movementflag == 16)
{
movementflag = 0;
}
}
}
this.positionLastFrame = pos2;
}
public ObjectUpdatePacket CreateUpdatePacket()
{
System.Text.Encoding _enc = System.Text.Encoding.ASCII;
//send a objectupdate packet with information about the clients avatar
ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
objupdate.RegionData.RegionHandle = m_regionHandle;
objupdate.RegionData.TimeDilation = 64096;
objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
objupdate.ObjectData[0] = AvatarTemplate;
//give this avatar object a local id and assign the user a name
objupdate.ObjectData[0].ID = this.localid;
objupdate.ObjectData[0].FullID = ControllingClient.AgentID;
objupdate.ObjectData[0].NameValue = _enc.GetBytes("FirstName STRING RW SV " + firstname + "\nLastName STRING RW SV " + lastname + " \0");
libsecondlife.LLVector3 pos2 = new LLVector3((float)this._physActor.Position.X, (float)this._physActor.Position.Y, (float)this._physActor.Position.Z);
byte[] pb = pos2.GetBytes();
Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length);
return objupdate;
}
public void SendInitialPosition()
{
System.Text.Encoding _enc = System.Text.Encoding.ASCII;
//send a objectupdate packet with information about the clients avatar
ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
objupdate.RegionData.RegionHandle = m_regionHandle;
objupdate.RegionData.TimeDilation = 64096;
objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
objupdate.ObjectData[0] = AvatarTemplate;
//give this avatar object a local id and assign the user a name
objupdate.ObjectData[0].ID = this.localid;
this.uuid = objupdate.ObjectData[0].FullID = ControllingClient.AgentID;
objupdate.ObjectData[0].NameValue = _enc.GetBytes("FirstName STRING RW SV " + firstname + "\nLastName STRING RW SV " + lastname + " \0");
libsecondlife.LLVector3 pos2 = new LLVector3((float)this.Pos.X, (float)this.Pos.Y, (float)this.Pos.Z);
byte[] pb = pos2.GetBytes();
Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length);
m_world._localNumber++;
foreach (SimClient client in m_clientThreads.Values)
{
client.OutPacket(objupdate);
if (client.AgentID != ControllingClient.AgentID)
{
SendAppearanceToOtherAgent(client);
}
}
}
public void SendInitialAppearance()
{
AgentWearablesUpdatePacket aw = new AgentWearablesUpdatePacket();
aw.AgentData.AgentID = this.ControllingClient.AgentID;
aw.AgentData.SerialNum = 0;
aw.AgentData.SessionID = ControllingClient.SessionID;
aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[13];
AgentWearablesUpdatePacket.WearableDataBlock awb;
for (int i = 0; i < 13; i++)
{
awb = new AgentWearablesUpdatePacket.WearableDataBlock();
awb.WearableType = (byte)i;
awb.AssetID = this.Wearables[i].AssetID;
awb.ItemID = this.Wearables[i].ItemID;
aw.WearableData[i] = awb;
}
ControllingClient.OutPacket(aw);
}
public void SendAppearanceToOtherAgent(SimClient userInfo)
{
AvatarAppearancePacket avp = new AvatarAppearancePacket();
avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[218];
avp.ObjectData.TextureEntry = this.avatarAppearanceTexture.ToBytes();
AvatarAppearancePacket.VisualParamBlock avblock = null;
for (int i = 0; i < 218; i++)
{
avblock = new AvatarAppearancePacket.VisualParamBlock();
avblock.ParamValue = visualParams[i];
avp.VisualParam[i] = avblock;
}
avp.Sender.IsTrial = false;
avp.Sender.ID = ControllingClient.AgentID;
userInfo.OutPacket(avp);
}
public void SetAppearance(AgentSetAppearancePacket appear)
{
LLObject.TextureEntry tex = new LLObject.TextureEntry(appear.ObjectData.TextureEntry, 0, appear.ObjectData.TextureEntry.Length);
this.avatarAppearanceTexture = tex;
for (int i = 0; i < appear.VisualParam.Length; i++)
{
this.visualParams[i] = appear.VisualParam[i].ParamValue;
}
foreach (SimClient client in m_clientThreads.Values)
{
if (client.AgentID != ControllingClient.AgentID)
{
SendAppearanceToOtherAgent(client);
}
}
}
public ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateTerseBlock()
{
byte[] bytes = new byte[60];
int i = 0;
ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock();
dat.TextureEntry = new byte[0];// AvatarTemplate.TextureEntry;
libsecondlife.LLVector3 pos2 = new LLVector3(0, 0, 0);
lock (m_world.LockPhysicsEngine)
{
pos2 = new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z);
}
uint ID = this.localid;
bytes[i++] = (byte)(ID % 256);
bytes[i++] = (byte)((ID >> 8) % 256);
bytes[i++] = (byte)((ID >> 16) % 256);
bytes[i++] = (byte)((ID >> 24) % 256);
bytes[i++] = 0;
bytes[i++] = 1;
i += 14;
bytes[i++] = 128;
bytes[i++] = 63;
byte[] pb = pos2.GetBytes();
Array.Copy(pb, 0, bytes, i, pb.Length);
i += 12;
ushort InternVelocityX;
ushort InternVelocityY;
ushort InternVelocityZ;
Axiom.MathLib.Vector3 internDirec = new Axiom.MathLib.Vector3(0, 0, 0);
lock (m_world.LockPhysicsEngine)
{
internDirec = new Axiom.MathLib.Vector3(this._physActor.Velocity.X, this._physActor.Velocity.Y, this._physActor.Velocity.Z);
}
internDirec = internDirec / 128.0f;
internDirec.x += 1;
internDirec.y += 1;
internDirec.z += 1;
InternVelocityX = (ushort)(32768 * internDirec.x);
InternVelocityY = (ushort)(32768 * internDirec.y);
InternVelocityZ = (ushort)(32768 * internDirec.z);
ushort ac = 32767;
bytes[i++] = (byte)(InternVelocityX % 256);
bytes[i++] = (byte)((InternVelocityX >> 8) % 256);
bytes[i++] = (byte)(InternVelocityY % 256);
bytes[i++] = (byte)((InternVelocityY >> 8) % 256);
bytes[i++] = (byte)(InternVelocityZ % 256);
bytes[i++] = (byte)((InternVelocityZ >> 8) % 256);
//accel
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
//rot
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
//rotation vel
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
dat.Data = bytes;
return (dat);
}
// Sends animation update
public void SendAnimPack()
{
AvatarAnimationPacket ani = new AvatarAnimationPacket();
ani.AnimationSourceList = new AvatarAnimationPacket.AnimationSourceListBlock[1];
ani.AnimationSourceList[0] = new AvatarAnimationPacket.AnimationSourceListBlock();
ani.AnimationSourceList[0].ObjectID = ControllingClient.AgentID;
ani.Sender = new AvatarAnimationPacket.SenderBlock();
ani.Sender.ID = ControllingClient.AgentID;
ani.AnimationList = new AvatarAnimationPacket.AnimationListBlock[1];
ani.AnimationList[0] = new AvatarAnimationPacket.AnimationListBlock();
ani.AnimationList[0].AnimID = this.current_anim;
ani.AnimationList[0].AnimSequenceID = this.anim_seq;
//ControllingClient.OutPacket(ani);
foreach (SimClient client in m_clientThreads.Values)
{
client.OutPacket(ani);
}
}
}
}

View File

@ -169,6 +169,72 @@ namespace OpenSim.world
} }
public void CreateFromPacket(ObjectAddPacket addPacket, LLUUID agentID, uint localID)
{
ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
objupdate.RegionData.RegionHandle = m_regionHandle;
objupdate.RegionData.TimeDilation = 64096;
objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
PrimData PData = new PrimData();
this.primData = PData;
this.primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
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 = 3;
objupdate.ObjectData[0].UpdateFlags = 32 + 65536 + 131072 + 256 + 4 + 8 + 2048 + 524288 + 268435456;
objupdate.ObjectData[0].TextureAnim = new byte[0];
objupdate.ObjectData[0].Sound = LLUUID.Zero;
LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005"));
this.primData.Texture = objupdate.ObjectData[0].TextureEntry = ntex.ToBytes();
objupdate.ObjectData[0].State = 0;
objupdate.ObjectData[0].Data = new byte[0];
PData.OwnerID = objupdate.ObjectData[0].OwnerID = agentID;
PData.PCode = objupdate.ObjectData[0].PCode = addPacket.ObjectData.PCode;
PData.PathBegin = objupdate.ObjectData[0].PathBegin = addPacket.ObjectData.PathBegin;
PData.PathEnd = objupdate.ObjectData[0].PathEnd = addPacket.ObjectData.PathEnd;
PData.PathScaleX = objupdate.ObjectData[0].PathScaleX = addPacket.ObjectData.PathScaleX;
PData.PathScaleY = objupdate.ObjectData[0].PathScaleY = addPacket.ObjectData.PathScaleY;
PData.PathShearX = objupdate.ObjectData[0].PathShearX = addPacket.ObjectData.PathShearX;
PData.PathShearY = objupdate.ObjectData[0].PathShearY = addPacket.ObjectData.PathShearY;
PData.PathSkew = objupdate.ObjectData[0].PathSkew = addPacket.ObjectData.PathSkew;
PData.ProfileBegin = objupdate.ObjectData[0].ProfileBegin = addPacket.ObjectData.ProfileBegin;
PData.ProfileEnd = objupdate.ObjectData[0].ProfileEnd = addPacket.ObjectData.ProfileEnd;
PData.Scale = objupdate.ObjectData[0].Scale = addPacket.ObjectData.Scale;
PData.PathCurve = objupdate.ObjectData[0].PathCurve = addPacket.ObjectData.PathCurve;
PData.ProfileCurve = objupdate.ObjectData[0].ProfileCurve = addPacket.ObjectData.ProfileCurve;
PData.ParentID = objupdate.ObjectData[0].ParentID = 0;
PData.ProfileHollow = objupdate.ObjectData[0].ProfileHollow = addPacket.ObjectData.ProfileHollow;
PData.PathRadiusOffset = objupdate.ObjectData[0].PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset;
PData.PathRevolutions = objupdate.ObjectData[0].PathRevolutions = addPacket.ObjectData.PathRevolutions;
PData.PathTaperX = objupdate.ObjectData[0].PathTaperX = addPacket.ObjectData.PathTaperX;
PData.PathTaperY = objupdate.ObjectData[0].PathTaperY = addPacket.ObjectData.PathTaperY;
PData.PathTwist = objupdate.ObjectData[0].PathTwist = addPacket.ObjectData.PathTwist;
PData.PathTwistBegin = objupdate.ObjectData[0].PathTwistBegin = addPacket.ObjectData.PathTwistBegin;
objupdate.ObjectData[0].ID = (uint)(localID);
objupdate.ObjectData[0].FullID = new LLUUID("edba7151-5857-acc5-b30b-f01efef" + (localID - 702000).ToString("00000"));
objupdate.ObjectData[0].ObjectData = new byte[60];
objupdate.ObjectData[0].ObjectData[46] = 128;
objupdate.ObjectData[0].ObjectData[47] = 63;
LLVector3 pos1 = addPacket.ObjectData.RayEnd;
//update position
byte[] pb = pos1.GetBytes();
Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 0, pb.Length);
//this.newPrimFlag = true;
this.primData.FullID = this.uuid = objupdate.ObjectData[0].FullID;
this.localid = objupdate.ObjectData[0].ID;
this.primData.Position = this.Pos = pos1;
this.OurPacket = objupdate;
}
public void SendFullUpdateToClient(SimClient RemoteClient) public void SendFullUpdateToClient(SimClient RemoteClient)
{ {

View File

@ -21,6 +21,8 @@ namespace OpenSim.world
{ {
public object LockPhysicsEngine = new object(); public object LockPhysicsEngine = new object();
public Dictionary<libsecondlife.LLUUID, Entity> Entities; public Dictionary<libsecondlife.LLUUID, Entity> Entities;
public Dictionary<libsecondlife.LLUUID, Avatar> Avatars;
public Dictionary<libsecondlife.LLUUID, Primitive> Prims;
public float[] LandMap; public float[] LandMap;
public ScriptEngine Scripts; public ScriptEngine Scripts;
public uint _localNumber = 0; public uint _localNumber = 0;
@ -50,6 +52,8 @@ namespace OpenSim.world
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs - creating new entitities instance"); OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs - creating new entitities instance");
Entities = new Dictionary<libsecondlife.LLUUID, Entity>(); Entities = new Dictionary<libsecondlife.LLUUID, Entity>();
Avatars = new Dictionary<LLUUID, Avatar>();
Prims = new Dictionary<LLUUID, Primitive>();
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs - creating LandMap"); OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs - creating LandMap");
TerrainManager = new TerrainManager(new SecondLife()); TerrainManager = new TerrainManager(new SecondLife());

View File

@ -1,5 +1,5 @@
Microsoft Visual Studio Solution File, Format Version 9.00 Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005 # Visual C# Express 2005
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim", "OpenSim\OpenSim.csproj", "{438A9556-0000-0000-0000-000000000000}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim", "OpenSim\OpenSim.csproj", "{438A9556-0000-0000-0000-000000000000}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim.Physics.OdePlugin", "OpenSim.Physics\OdePlugin\OpenSim.Physics.OdePlugin.csproj", "{63A05FE9-0000-0000-0000-000000000000}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim.Physics.OdePlugin", "OpenSim.Physics\OdePlugin\OpenSim.Physics.OdePlugin.csproj", "{63A05FE9-0000-0000-0000-000000000000}"
@ -41,42 +41,6 @@ Global
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(ProjectDependencies) = postSolution
({438A9556-0000-0000-0000-000000000000}).5 = ({8ACA2445-0000-0000-0000-000000000000})
({438A9556-0000-0000-0000-000000000000}).6 = ({A7CD0630-0000-0000-0000-000000000000})
({438A9556-0000-0000-0000-000000000000}).7 = ({8BE16150-0000-0000-0000-000000000000})
({438A9556-0000-0000-0000-000000000000}).8 = ({8BB20F0A-0000-0000-0000-000000000000})
({438A9556-0000-0000-0000-000000000000}).9 = ({632E1BFD-0000-0000-0000-000000000000})
({63A05FE9-0000-0000-0000-000000000000}).2 = ({8BE16150-0000-0000-0000-000000000000})
({E88EF749-0000-0000-0000-000000000000}).2 = ({8ACA2445-0000-0000-0000-000000000000})
({8BE16150-0000-0000-0000-000000000000}).3 = ({8ACA2445-0000-0000-0000-000000000000})
({8BE16150-0000-0000-0000-000000000000}).4 = ({A7CD0630-0000-0000-0000-000000000000})
({66591469-0000-0000-0000-000000000000}).3 = ({8ACA2445-0000-0000-0000-000000000000})
({66591469-0000-0000-0000-000000000000}).4 = ({A7CD0630-0000-0000-0000-000000000000})
({83C87BE6-0000-0000-0000-000000000000}).5 = ({8ACA2445-0000-0000-0000-000000000000})
({83C87BE6-0000-0000-0000-000000000000}).6 = ({A7CD0630-0000-0000-0000-000000000000})
({4F874463-0000-0000-0000-000000000000}).2 = ({8BE16150-0000-0000-0000-000000000000})
({B0027747-0000-0000-0000-000000000000}).5 = ({8ACA2445-0000-0000-0000-000000000000})
({B0027747-0000-0000-0000-000000000000}).6 = ({A7CD0630-0000-0000-0000-000000000000})
({8BB20F0A-0000-0000-0000-000000000000}).2 = ({8ACA2445-0000-0000-0000-000000000000})
({8BB20F0A-0000-0000-0000-000000000000}).3 = ({A7CD0630-0000-0000-0000-000000000000})
({988F0AC4-0000-0000-0000-000000000000}).3 = ({8BE16150-0000-0000-0000-000000000000})
({B55C0B5D-0000-0000-0000-000000000000}).3 = ({8ACA2445-0000-0000-0000-000000000000})
({B55C0B5D-0000-0000-0000-000000000000}).4 = ({A7CD0630-0000-0000-0000-000000000000})
({632E1BFD-0000-0000-0000-000000000000}).5 = ({8ACA2445-0000-0000-0000-000000000000})
({632E1BFD-0000-0000-0000-000000000000}).6 = ({A7CD0630-0000-0000-0000-000000000000})
({632E1BFD-0000-0000-0000-000000000000}).7 = ({E88EF749-0000-0000-0000-000000000000})
({632E1BFD-0000-0000-0000-000000000000}).8 = ({8BE16150-0000-0000-0000-000000000000})
({632E1BFD-0000-0000-0000-000000000000}).9 = ({8BB20F0A-0000-0000-0000-000000000000})
({E1B79ECF-0000-0000-0000-000000000000}).4 = ({8ACA2445-0000-0000-0000-000000000000})
({E1B79ECF-0000-0000-0000-000000000000}).5 = ({A7CD0630-0000-0000-0000-000000000000})
({7E494328-0000-0000-0000-000000000000}).5 = ({8ACA2445-0000-0000-0000-000000000000})
({7E494328-0000-0000-0000-000000000000}).6 = ({A7CD0630-0000-0000-0000-000000000000})
({546099CD-0000-0000-0000-000000000000}).4 = ({8ACA2445-0000-0000-0000-000000000000})
({546099CD-0000-0000-0000-000000000000}).5 = ({A7CD0630-0000-0000-0000-000000000000})
({21BFC8E2-0000-0000-0000-000000000000}).3 = ({8ACA2445-0000-0000-0000-000000000000})
({21BFC8E2-0000-0000-0000-000000000000}).4 = ({A7CD0630-0000-0000-0000-000000000000})
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{438A9556-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {438A9556-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{438A9556-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU {438A9556-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU