Preliminary movement added to sugilite, forwards walking only and no animations.

Sugilite
MW 2007-06-15 13:11:26 +00:00
parent 2bcd37aa94
commit 95676b2988
14 changed files with 224 additions and 99 deletions

View File

@ -55,6 +55,7 @@ namespace OpenSim.Framework.Interfaces
public delegate void UpdatePrimRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient);
public delegate void StatusChange(bool status);
public delegate void NewAvatar(IClientAPI remoteClient, LLUUID agentID, bool status);
public delegate void UpdateAgent(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation);
public delegate void ParcelPropertiesRequest(int start_x, int start_y, int end_x, int end_y, int sequence_id, bool snap_selection, IClientAPI remote_client);
public delegate void ParcelDivideRequest(int west, int south, int east, int north, IClientAPI remote_client);
@ -75,7 +76,7 @@ namespace OpenSim.Framework.Interfaces
event GenericCall OnRegionHandShakeReply;
event GenericCall OnRequestWearables;
event GenericCall2 OnCompleteMovementToRegion;
event GenericCall3 OnAgentUpdate;
event UpdateAgent OnAgentUpdate;
event GenericCall OnRequestAvatarsData;
event GenericCall4 OnAddPrim;
event UpdateShape OnUpdatePrimShape;
@ -125,10 +126,12 @@ namespace OpenSim.Framework.Interfaces
void SendChatMessage(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID);
void SendLayerData(float[] map);
void MoveAgentIntoRegion(RegionInfo regInfo);
void SendAvatarData(RegionInfo regionInfo, string firstName, string lastName, LLUUID avatarID, uint avatarLocalID, LLVector3 Pos);
void InformClientOfNeighbour(ulong neighbourHandle, System.Net.IPAddress neighbourIP, ushort neighbourPort);
AgentCircuitData RequestClientInfo();
void SendAvatarData(RegionInfo regionInfo, string firstName, string lastName, LLUUID avatarID, uint avatarLocalID, LLVector3 Pos);
void SendAvatarTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLVector3 velocity);
void AttachObject(uint localID, LLQuaternion rotation, byte attachPoint);
void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimData primData, LLVector3 pos, LLQuaternion rotation, LLUUID textureID);
void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimData primData, LLVector3 pos, LLUUID textureID);

View File

@ -42,8 +42,20 @@ namespace OpenSim.Region.Scenes
/// </summary>
public override void update()
{
if (this.newForce)
{
this.SendTerseUpdateToALLClients();
_updateCount = 0;
}
else if (movementflag != 0)
{
_updateCount++;
if (_updateCount > 3)
{
this.SendTerseUpdateToALLClients();
_updateCount = 0;
}
}
}
/// <summary>
@ -116,15 +128,6 @@ namespace OpenSim.Region.Scenes
}
/// <summary>
/// Very likely to be deleted soon!
/// </summary>
/// <returns></returns>
public ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateTerseBlock()
{
return null;
}
/// <summary>
///
/// </summary>

View File

@ -61,6 +61,7 @@ namespace OpenSim.Region.Scenes
private ulong m_regionHandle;
private Dictionary<uint, IClientAPI> m_clientThreads;
private bool childAvatar = false;
private bool newForce = false;
protected RegionInfo m_regionInfo;
/// <summary>
@ -78,6 +79,7 @@ namespace OpenSim.Region.Scenes
this.uuid = theClient.AgentId;
m_regionInfo = reginfo;
m_regionHandle = reginfo.RegionHandle;
OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Avatar.cs - Loading details from grid (DUMMY)");
ControllingClient = theClient;
this.firstname = ControllingClient.FirstName;
@ -99,8 +101,8 @@ namespace OpenSim.Region.Scenes
//ControllingClient.OnSetAppearance += new SetAppearance(this.SetAppearance);
ControllingClient.OnCompleteMovementToRegion += new GenericCall2(this.CompleteMovement);
ControllingClient.OnCompleteMovementToRegion += new GenericCall2(this.SendInitialPosition);
/* ControllingClient.OnAgentUpdate += new GenericCall3(this.HandleAgentUpdate);
ControllingClient.OnStartAnim += new StartAnim(this.SendAnimPack);
ControllingClient.OnAgentUpdate += new UpdateAgent(this.HandleAgentUpdate);
/* ControllingClient.OnStartAnim += new StartAnim(this.SendAnimPack);
ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange);
ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement);
*/
@ -135,32 +137,52 @@ namespace OpenSim.Region.Scenes
/// </summary>
public override void addForces()
{
lock (this.forcesList)
{
newForce = false;
if (this.forcesList.Count > 0)
{
for (int i = 0; i < this.forcesList.Count; i++)
{
NewForce force = this.forcesList[i];
PhysicsVector phyVector = new PhysicsVector(force.X, force.Y, force.Z);
lock (m_world.SyncRoot)
{
this._physActor.Velocity = phyVector;
}
this.updateflag = true;
this.velocity = new LLVector3(force.X, force.Y, force.Z); //shouldn't really be doing this
// but as we are setting the velocity (rather than using real forces) at the moment it is okay.
this.newForce = true;
}
for (int i = 0; i < this.forcesList.Count; i++)
{
this.forcesList.RemoveAt(0);
}
}
}
}
/// <summary>
/// likely to removed very soon
/// </summary>
/// <param name="name"></param>
public static void SetupTemplate(string name)
public void SendTerseUpdateToClient(IClientAPI RemoteClient)
{
}
/// <summary>
/// likely to removed very soon
/// </summary>
/// <param name="objdata"></param>
protected static void SetDefaultPacketValues(ObjectUpdatePacket.ObjectDataBlock objdata)
{
RemoteClient.SendAvatarTerseUpdate(this.m_regionHandle, 64096, this.localid, new LLVector3(this.Pos.X, this.Pos.Y, this.Pos.Z), new LLVector3(this._physActor.Velocity.X, this._physActor.Velocity.Y, this._physActor.Velocity.Z));
}
/// <summary>
///
/// </summary>
public void SendTerseUpdateToALLClients()
{
List<Avatar> avatars = this.m_world.RequestAvatarList();
for (int i = 0; i < avatars.Count; i++)
{
this.SendTerseUpdateToClient(avatars[i].ControllingClient);
}
}
/// <summary>
/// Complete Avatar's movement into the region
/// </summary>
public void CompleteMovement()
{
this.ControllingClient.MoveAgentIntoRegion(m_regionInfo);
@ -187,9 +209,55 @@ namespace OpenSim.Region.Scenes
/// <summary>
///
/// </summary>
public void SendRegionHandshake()
/// <param name="pack"></param>
public void HandleAgentUpdate(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation)
{
if ((flags & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_AT_POS) != 0)
{
Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(bodyRotation.W, bodyRotation.X, bodyRotation.Y, bodyRotation.Z);
if (((movementflag & 1) == 0) || (q != this.bodyRot))
{
//we should add a new force to the list
// but for now we will deal with velocities
NewForce newVelocity = new NewForce();
Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(1, 0, 0);
Axiom.MathLib.Vector3 direc = q * v3;
direc.Normalize();
//work out velocity for sim physics system
direc = direc * ((0.03f) * 128f);
if (this._physActor.Flying)
direc *= 4;
newVelocity.X = direc.x;
newVelocity.Y = direc.y;
newVelocity.Z = direc.z;
this.forcesList.Add(newVelocity);
movementflag = 1;
this.bodyRot = q;
}
}
else
{
if (movementflag == 16)
{
movementflag = 0;
}
if ((movementflag) != 0)
{
NewForce newVelocity = new NewForce();
newVelocity.X = 0;
newVelocity.Y = 0;
newVelocity.Z = 0;
this.forcesList.Add(newVelocity);
movementflag = 0;
this.movementflag = 16;
}
}
}
/// <summary>

View File

@ -123,14 +123,8 @@ namespace OpenSim.Region.Scenes
OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "World.cs - creating LandMap");
TerrainManager = new TerrainManager(new SecondLife());
Terrain = new TerrainEngine();
Avatar.SetupTemplate("avatar-texture.dat");
Avatar.LoadAnims();
//this.SetDefaultScripts();
//this.LoadScriptEngines();
}
catch (Exception e)
{

View File

@ -36,7 +36,7 @@ using libsecondlife;
namespace OpenSim
{
public interface OpenSimNetworkHandler
public interface ClientStackNetworkHandler
{
void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode);// EndPoint packetSender);
void RemoveClientCircuit(uint circuitcode);

View File

@ -47,7 +47,7 @@ namespace OpenSim
public event GenericCall OnRequestWearables;
public event SetAppearance OnSetAppearance;
public event GenericCall2 OnCompleteMovementToRegion;
public event GenericCall3 OnAgentUpdate;
public event UpdateAgent OnAgentUpdate;
public event StartAnim OnStartAnim;
public event GenericCall OnRequestAvatarsData;
public event LinkObjects OnLinkObjects;
@ -393,6 +393,26 @@ namespace OpenSim
}
/// <summary>
///
/// </summary>
/// <param name="regionHandle"></param>
/// <param name="timeDilation"></param>
/// <param name="localID"></param>
/// <param name="position"></param>
/// <param name="velocity"></param>
public void SendAvatarTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLVector3 velocity)
{
ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = this.CreateAvatarImprovedBlock(localID, position, velocity);
ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
terse.RegionData.RegionHandle = regionHandle;
terse.RegionData.TimeDilation = timeDilation;
terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
terse.ObjectData[0] = terseBlock;
this.OutPacket(terse);
}
#endregion
#region Primitive Packet/data Sending Methods
@ -491,6 +511,83 @@ namespace OpenSim
#region Helper Methods
protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateAvatarImprovedBlock(uint localID, LLVector3 pos, LLVector3 velocity)
{
byte[] bytes = new byte[60];
int i = 0;
ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock();
dat.TextureEntry = new byte[0];// AvatarTemplate.TextureEntry;
uint ID = 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 = pos.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);
internDirec = new Axiom.MathLib.Vector3(velocity.X, velocity.Y, 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);
}
/// <summary>
///
/// </summary>

View File

@ -168,7 +168,8 @@ namespace OpenSim
case PacketType.AgentUpdate:
if (OnAgentUpdate != null)
{
OnAgentUpdate(Pack);
AgentUpdatePacket agenUpdate = (AgentUpdatePacket) Pack;
OnAgentUpdate(this, agenUpdate.AgentData.ControlFlags, agenUpdate.AgentData.BodyRotation );
}
break;
case PacketType.AgentAnimation:

View File

@ -130,6 +130,9 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="ClientStackNetworkHandler.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ClientView.AgentAssetUpload.cs">
<SubType>Code</SubType>
</Compile>
@ -151,21 +154,15 @@
<Compile Include="NetworkServersInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="OpenSimNetworkHandler.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="PacketServer.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="RegionServerBase.cs">
<Compile Include="RegionApplicationBase.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="UDPServer.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="UserConfigUtility.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="VersionInfo.cs">
<SubType>Code</SubType>
</Compile>

View File

@ -11,6 +11,7 @@
<resources prefix="OpenSim.RegionServer" dynamicprefix="true" >
</resources>
<sources failonempty="true">
<include name="ClientStackNetworkHandler.cs" />
<include name="ClientView.AgentAssetUpload.cs" />
<include name="ClientView.API.cs" />
<include name="ClientView.cs" />
@ -18,11 +19,9 @@
<include name="ClientView.ProcessPackets.cs" />
<include name="ClientViewBase.cs" />
<include name="NetworkServersInfo.cs" />
<include name="OpenSimNetworkHandler.cs" />
<include name="PacketServer.cs" />
<include name="RegionServerBase.cs" />
<include name="RegionApplicationBase.cs" />
<include name="UDPServer.cs" />
<include name="UserConfigUtility.cs" />
<include name="VersionInfo.cs" />
<include name="Assets/InventoryCache.cs" />
</sources>

View File

@ -40,13 +40,13 @@ namespace OpenSim
{
public class PacketServer
{
private OpenSimNetworkHandler _networkHandler;
private ClientStackNetworkHandler _networkHandler;
private IWorld _localWorld;
public Dictionary<uint, ClientView> ClientThreads = new Dictionary<uint, ClientView>();
public Dictionary<uint, IClientAPI> ClientAPIs = new Dictionary<uint, IClientAPI>();
protected uint serverPort;
public PacketServer(OpenSimNetworkHandler networkHandler, uint port)
public PacketServer(ClientStackNetworkHandler networkHandler, uint port)
{
_networkHandler = networkHandler;
this.serverPort = port;

View File

@ -52,7 +52,7 @@ using OpenSim.GenericConfig;
namespace OpenSim
{
public class RegionServerBase
public class RegionApplicationBase
{
protected IGenericConfig localConfig;
protected PhysicsManager physManager;
@ -78,12 +78,12 @@ namespace OpenSim
protected ConsoleBase m_console;
public RegionServerBase()
public RegionApplicationBase()
{
}
public RegionServerBase(bool sandBoxMode, bool startLoginServer, string physicsEngine, bool useConfigFile, bool silent, string configFile)
public RegionApplicationBase(bool sandBoxMode, bool startLoginServer, string physicsEngine, bool useConfigFile, bool silent, string configFile)
{
this.configFileSetup = useConfigFile;
m_sandbox = sandBoxMode;

View File

@ -52,7 +52,7 @@ using OpenSim.GenericConfig;
namespace OpenSim
{
public class UDPServer : OpenSimNetworkHandler
public class UDPServer : ClientStackNetworkHandler
{
protected Dictionary<EndPoint, uint> clientCircuits = new Dictionary<EndPoint, uint>();
public Socket Server;

View File

@ -1,37 +0,0 @@
/*
* 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;
namespace OpenSim
{
public class UserConfigUtility
{
}
}

View File

@ -57,7 +57,7 @@ using OpenGrid.Framework.Communications;
namespace OpenSim
{
public class OpenSimMain : RegionServerBase, conscmd_callback
public class OpenSimMain : RegionApplicationBase, conscmd_callback
{
private CheckSumServer checkServer;
protected RegionServerCommsManager commsManager;