| 9 |
using MXP.Extentions.OpenMetaverseFragments.Proto; |
using MXP.Extentions.OpenMetaverseFragments.Proto; |
| 10 |
using OpenMetaverse; |
using OpenMetaverse; |
| 11 |
using MXP.Util; |
using MXP.Util; |
| 12 |
|
using MXP.Common.Proto; |
| 13 |
|
|
| 14 |
namespace IdealistViewer.Module |
namespace IdealistViewer.Module |
| 15 |
{ |
{ |
| 25 |
private VSimulator m_simulator; |
private VSimulator m_simulator; |
| 26 |
private bool m_translateChange = false; |
private bool m_translateChange = false; |
| 27 |
private bool m_orientateChange = false; |
private bool m_orientateChange = false; |
| 28 |
|
private bool m_walking = false; |
| 29 |
private Vector3 FORWARD = new Vector3(1, 0, 0); |
private Vector3 FORWARD = new Vector3(1, 0, 0); |
| 30 |
private Vector3 BACKWARD = new Vector3(-1, 0, 0); |
private Vector3 BACKWARD = new Vector3(-1, 0, 0); |
| 31 |
private Vector3 LEFT = new Vector3(0, 0, -1); |
private Vector3 LEFT = new Vector3(0, 0, -1); |
| 90 |
modifyRequest.ObjectFragment.OwnerId = m_userId.Guid; |
modifyRequest.ObjectFragment.OwnerId = m_userId.Guid; |
| 91 |
modifyRequest.ObjectFragment.TypeId = Guid.Empty; |
modifyRequest.ObjectFragment.TypeId = Guid.Empty; |
| 92 |
modifyRequest.ObjectFragment.TypeName = "Avatar"; |
modifyRequest.ObjectFragment.TypeName = "Avatar"; |
| 93 |
modifyRequest.ObjectFragment.Acceleration = new float[3]; |
modifyRequest.ObjectFragment.Acceleration = new MsdVector3f(); |
| 94 |
modifyRequest.ObjectFragment.AngularAcceleration = new float[4]; |
modifyRequest.ObjectFragment.AngularAcceleration = new MsdQuaternion4f(); |
| 95 |
modifyRequest.ObjectFragment.AngularVelocity = new float[4]; |
modifyRequest.ObjectFragment.AngularVelocity = new MsdQuaternion4f(); |
| 96 |
modifyRequest.ObjectFragment.BoundingSphereRadius = m_avatar.Scale.Length(); |
modifyRequest.ObjectFragment.BoundingSphereRadius = m_avatar.Scale.Length(); |
| 97 |
modifyRequest.ObjectFragment.Location = ToFloatVector(m_avatar.Position); |
modifyRequest.ObjectFragment.Location = ToOmVector(m_avatar.Position); |
| 98 |
modifyRequest.ObjectFragment.Mass = 1.0f; |
modifyRequest.ObjectFragment.Mass = 1.0f; |
| 99 |
modifyRequest.ObjectFragment.Orientation = ToFloatQuaternion(m_avatar.Rotation); |
modifyRequest.ObjectFragment.Orientation = ToOmQuaternion(m_avatar.Rotation); |
| 100 |
modifyRequest.ObjectFragment.Velocity = ToFloatVector(m_avatar.Velocity); |
modifyRequest.ObjectFragment.Velocity = ToOmVector(m_avatar.Velocity); |
| 101 |
OmAvatarExt avatarExt=new OmAvatarExt(); |
OmAvatarExt avatarExt=new OmAvatarExt(); |
| 102 |
//avatarExt.TargetLocation |
//avatarExt.TargetLocation |
| 103 |
|
|
| 104 |
if (m_translateChange) |
//if (m_translateChange) |
| 105 |
{ |
//{ |
| 106 |
Quaternion orientation = m_avatar.Rotation; |
Quaternion orientation = m_avatar.Rotation; |
| 107 |
Vector3 movementDirection = new Vector3(0,0,0); |
Vector3 movementDirection = new Vector3(0,0,0); |
| 108 |
if (m_forward) |
if (m_forward) |
| 130 |
movementDirection += DOWN * orientation; |
movementDirection += DOWN * orientation; |
| 131 |
} |
} |
| 132 |
avatarExt.MovementDirection = ToOmVector(movementDirection); |
avatarExt.MovementDirection = ToOmVector(movementDirection); |
| 133 |
} |
//} |
| 134 |
|
|
| 135 |
if (m_orientateChange) |
if (m_orientateChange) |
| 136 |
{ |
{ |
| 137 |
avatarExt.TargetOrientation=ToOmQuaternion(Quaternion.CreateFromAxisAngle(Vector3.UnitZ,m_heading)); |
avatarExt.TargetOrientation=ToOmQuaternion(Quaternion.CreateFromAxisAngle(Vector3.UnitZ,m_heading)); |
| 138 |
} |
} |
| 139 |
|
|
| 140 |
|
if (m_translateChange) |
| 141 |
|
{ |
| 142 |
|
m_walking = !m_walking; |
| 143 |
|
|
| 144 |
|
if (m_walking) |
| 145 |
|
{ |
| 146 |
|
m_avatarAnimations[m_avatar.ID] = new List<UUID>(); |
| 147 |
|
m_avatarAnimations[m_avatar.ID].Add(Animations.WALK); |
| 148 |
|
} |
| 149 |
|
else |
| 150 |
|
{ |
| 151 |
|
m_avatarAnimations[m_avatar.ID] = new List<UUID>(); |
| 152 |
|
m_avatarAnimations[m_avatar.ID].Add(Animations.STAND); |
| 153 |
|
} |
| 154 |
|
|
| 155 |
|
} |
| 156 |
|
|
| 157 |
|
|
| 158 |
modifyRequest.SetExtension<OmAvatarExt>(avatarExt); |
modifyRequest.SetExtension<OmAvatarExt>(avatarExt); |
| 159 |
|
|
| 160 |
m_client.Send(modifyRequest); |
m_client.Send(modifyRequest); |
| 196 |
private void LandPerceptionReceived(PerceptionEventMessage pe) |
private void LandPerceptionReceived(PerceptionEventMessage pe) |
| 197 |
{ |
{ |
| 198 |
ObjectFragment objectFragment = pe.ObjectFragment; |
ObjectFragment objectFragment = pe.ObjectFragment; |
| 199 |
m_log.Info("Received terrain: " + objectFragment.ObjectName + " (" + pe.ObjectFragment.StatePayloadLength + ")"); |
m_log.Info("Received terrain: " + objectFragment.ObjectName + " (" + pe.ObjectFragment.ExtensionLength + ")"); |
| 200 |
OmBitmapTerrainExt terrainExt = pe.GetExtension<OmBitmapTerrainExt>(); |
OmBitmapTerrainExt terrainExt = pe.GetExtension<OmBitmapTerrainExt>(); |
| 201 |
m_simulator.WaterHeight = terrainExt.WaterLevel; |
m_simulator.WaterHeight = terrainExt.WaterLevel; |
| 202 |
float[] map = CompressionUtil.DecompressHeightMap(terrainExt.HeightMap, terrainExt.Offset, terrainExt.Scale); |
float[] map = CompressUtil.DecompressHeightMap(terrainExt.HeightMap, terrainExt.Offset, terrainExt.Scale); |
| 203 |
for (int x = 0; x < terrainExt.Width; x += 16) |
for (int x = 0; x < terrainExt.Width; x += 16) |
| 204 |
{ |
{ |
| 205 |
for (int y = 0; y < terrainExt.Height; y += 16) |
for (int y = 0; y < terrainExt.Height; y += 16) |
| 231 |
primitive.OwnerID = new UUID(objectFragment.OwnerId); |
primitive.OwnerID = new UUID(objectFragment.OwnerId); |
| 232 |
primitive.RegionHandle = m_simulator.Handle; |
primitive.RegionHandle = m_simulator.Handle; |
| 233 |
|
|
| 234 |
primitive.Rotation = FromFloatQuaternion(objectFragment.Orientation); |
primitive.Rotation = FromOmQuaternion(objectFragment.Orientation); |
| 235 |
primitive.AngularVelocity = FromFloatQuaternionToEulerAngles(objectFragment.AngularVelocity); |
primitive.AngularVelocity = FromOmQuaternionToEulerAngles(objectFragment.AngularVelocity); |
| 236 |
|
|
| 237 |
primitive.Position = FromFloatVector(objectFragment.Location); |
primitive.Position = FromOmVector(objectFragment.Location); |
| 238 |
primitive.Velocity = FromFloatVector(objectFragment.Velocity); |
primitive.Velocity = FromOmVector(objectFragment.Velocity); |
| 239 |
primitive.Acceleration = FromFloatVector(objectFragment.Acceleration); |
primitive.Acceleration = FromOmVector(objectFragment.Acceleration); |
| 240 |
|
|
| 241 |
if (m_userId.Guid == objectFragment.OwnerId) |
if (m_userId.Guid == objectFragment.OwnerId) |
| 242 |
{ |
{ |
| 253 |
ObjectUpdate objectUpdate = new ObjectUpdate(); |
ObjectUpdate objectUpdate = new ObjectUpdate(); |
| 254 |
objectUpdate.LocalID = movementEvent.ObjectIndex; |
objectUpdate.LocalID = movementEvent.ObjectIndex; |
| 255 |
objectUpdate.Avatar = m_avatar.LocalID == movementEvent.ObjectIndex; |
objectUpdate.Avatar = m_avatar.LocalID == movementEvent.ObjectIndex; |
| 256 |
objectUpdate.Position = FromFloatVector(movementEvent.Location); |
objectUpdate.Position = FromOmVector(movementEvent.Location); |
| 257 |
objectUpdate.Rotation = FromFloatQuaternion(movementEvent.Orientation); |
objectUpdate.Rotation = FromOmQuaternion(movementEvent.Orientation); |
|
/* |
|
|
if (!(m_avatar.LocalID == movementEvent.ObjectIndex)) |
|
|
{ |
|
|
objectUpdate.Rotation = FromFloatQuaternion(movementEvent.Orientation); |
|
|
} |
|
|
else |
|
|
{ |
|
|
// Not respecting server sent orientation for own avatar. |
|
|
objectUpdate.Rotation = m_avatar.Rotation; |
|
|
} |
|
|
*/ |
|
| 258 |
objectUpdate.Velocity = new Vector3(); |
objectUpdate.Velocity = new Vector3(); |
| 259 |
objectUpdate.Acceleration = new Vector3(); |
objectUpdate.Acceleration = new Vector3(); |
| 260 |
objectUpdate.AngularVelocity = new Vector3(); |
objectUpdate.AngularVelocity = new Vector3(); |
| 275 |
primitive.OwnerID = new UUID(objectFragment.OwnerId); |
primitive.OwnerID = new UUID(objectFragment.OwnerId); |
| 276 |
primitive.RegionHandle = m_simulator.Handle; |
primitive.RegionHandle = m_simulator.Handle; |
| 277 |
|
|
| 278 |
primitive.Rotation = FromFloatQuaternion(objectFragment.Orientation); |
primitive.Rotation = FromOmQuaternion(objectFragment.Orientation); |
| 279 |
primitive.AngularVelocity = FromFloatQuaternionToEulerAngles(objectFragment.AngularVelocity); |
primitive.AngularVelocity = FromOmQuaternionToEulerAngles(objectFragment.AngularVelocity); |
| 280 |
|
|
| 281 |
primitive.Position = FromFloatVector(objectFragment.Location); |
primitive.Position = FromOmVector(objectFragment.Location); |
| 282 |
primitive.Velocity = FromFloatVector(objectFragment.Velocity); |
primitive.Velocity = FromOmVector(objectFragment.Velocity); |
| 283 |
primitive.Acceleration = FromFloatVector(objectFragment.Acceleration); |
primitive.Acceleration = FromOmVector(objectFragment.Acceleration); |
| 284 |
|
|
| 285 |
if (pe.HasExtension) |
if (pe.HasExtension) |
| 286 |
{ |
{ |
| 393 |
throw new Exception("Unknown PCode: "+value); |
throw new Exception("Unknown PCode: "+value); |
| 394 |
} |
} |
| 395 |
|
|
| 396 |
private Color4 FromOmColor(OmColor4f value) |
private Color4 FromOmColor(MsdColor4f value) |
| 397 |
{ |
{ |
| 398 |
return new Color4(value.R / 255, value.G / 255, value.B / 255, value.A / 255); |
return new Color4(value.R / 255, value.G / 255, value.B / 255, value.A / 255); |
| 399 |
} |
} |
| 400 |
|
|
| 401 |
private Vector3 FromFloatVector(float[] values) |
private Vector3 FromOmVector(MsdVector3f values) |
|
{ |
|
|
return new Vector3(values[0], values[1], values[2]); |
|
|
} |
|
|
|
|
|
private Vector3 FromOmVector(OmVector3f values) |
|
| 402 |
{ |
{ |
| 403 |
return new Vector3(values.X, values.Y, values.Z); |
return new Vector3(values.X, values.Y, values.Z); |
| 404 |
} |
} |
| 405 |
|
|
| 406 |
private Vector3 FromFloatQuaternionToEulerAngles(float[] values) |
private Vector3 FromOmQuaternionToEulerAngles(MsdQuaternion4f value) |
| 407 |
{ |
{ |
| 408 |
Quaternion quaternion = FromFloatQuaternion(values); |
Quaternion quaternion = FromOmQuaternion(value); |
| 409 |
float roll; |
float roll; |
| 410 |
float pitch; |
float pitch; |
| 411 |
float yaw; |
float yaw; |
| 413 |
return new Vector3(roll, pitch, yaw); |
return new Vector3(roll, pitch, yaw); |
| 414 |
} |
} |
| 415 |
|
|
| 416 |
private Quaternion FromFloatQuaternion(float[] values) |
private Quaternion FromOmQuaternion(MsdQuaternion4f quaternion) |
|
{ |
|
|
return new Quaternion(values[0], values[1], values[2],values[3]); |
|
|
} |
|
|
|
|
|
private Quaternion FromOmQuaternion(OmQuaternion4f quaternion) |
|
| 417 |
{ |
{ |
| 418 |
return new Quaternion(quaternion.X, quaternion.Y, quaternion.Z, quaternion.W); |
return new Quaternion(quaternion.X, quaternion.Y, quaternion.Z, quaternion.W); |
| 419 |
} |
} |
| 420 |
|
|
| 421 |
private OmVector3f ToOmVector(Vector3 value) |
private MsdVector3f ToOmVector(Vector3 value) |
| 422 |
{ |
{ |
| 423 |
OmVector3f encodedValue = new OmVector3f(); |
MsdVector3f encodedValue = new MsdVector3f(); |
| 424 |
encodedValue.X = value.X; |
encodedValue.X = value.X; |
| 425 |
encodedValue.Y = value.Y; |
encodedValue.Y = value.Y; |
| 426 |
encodedValue.Z = value.Z; |
encodedValue.Z = value.Z; |
| 427 |
return encodedValue; |
return encodedValue; |
| 428 |
} |
} |
| 429 |
|
|
| 430 |
private OmQuaternion4f ToOmQuaternion(Quaternion value) |
private MsdQuaternion4f ToOmQuaternion(Quaternion value) |
| 431 |
{ |
{ |
| 432 |
OmQuaternion4f encodedValue = new OmQuaternion4f(); |
MsdQuaternion4f encodedValue = new MsdQuaternion4f(); |
| 433 |
encodedValue.X = value.X; |
encodedValue.X = value.X; |
| 434 |
encodedValue.Y = value.Y; |
encodedValue.Y = value.Y; |
| 435 |
encodedValue.Z = value.Z; |
encodedValue.Z = value.Z; |
| 437 |
return encodedValue; |
return encodedValue; |
| 438 |
} |
} |
| 439 |
|
|
|
private float[] ToFloatVector(Vector3 value) |
|
|
{ |
|
|
float[] floatVector=new float[3]; |
|
|
floatVector[0]=value.X; |
|
|
floatVector[1]=value.Y; |
|
|
floatVector[2]=value.Z; |
|
|
return floatVector; |
|
|
} |
|
|
|
|
|
private float[] ToFloatQuaternion(Quaternion value) |
|
|
{ |
|
|
float[] floatQuaternion = new float[4]; |
|
|
floatQuaternion[0] = value.X; |
|
|
floatQuaternion[1] = value.Y; |
|
|
floatQuaternion[2] = value.Z; |
|
|
floatQuaternion[3] = value.W; |
|
|
return floatQuaternion; |
|
|
} |
|
|
|
|
|
private OmColor4f ToOmColor(byte[] value) |
|
|
{ |
|
|
OmColor4f encodedValue = new OmColor4f(); |
|
|
encodedValue.R = value[0]; |
|
|
encodedValue.G = value[1]; |
|
|
encodedValue.B = value[2]; |
|
|
encodedValue.A = value[3]; |
|
|
return encodedValue; |
|
|
} |
|
|
|
|
| 440 |
#region IProtocol Members |
#region IProtocol Members |
| 441 |
|
|
| 442 |
public void BeginLogin(string loginURI, string username, string password, string startlocation) |
public void BeginLogin(string loginURI, string username, string password, string startlocation) |
| 683 |
|
|
| 684 |
public OpenMetaverse.UUID GetSelfUUID |
public OpenMetaverse.UUID GetSelfUUID |
| 685 |
{ |
{ |
| 686 |
get { return m_avatar.ID; } |
get { return m_avatar!=null?m_avatar.ID:UUID.Zero; } |
| 687 |
} |
} |
| 688 |
|
|
| 689 |
public Dictionary<OpenMetaverse.UUID, OpenMetaverse.FriendInfo> Friends |
public Dictionary<OpenMetaverse.UUID, OpenMetaverse.FriendInfo> Friends |
| 690 |
{ |
{ |
| 691 |
get { throw new NotImplementedException(); } |
get { return new Dictionary<OpenMetaverse.UUID, OpenMetaverse.FriendInfo>(); } |
| 692 |
} |
} |
| 693 |
|
|
| 694 |
public Dictionary<UUID, List<UUID>> avatarAnimations = new Dictionary<UUID, List<UUID>>(); |
public Dictionary<UUID, List<UUID>> m_avatarAnimations = new Dictionary<UUID, List<UUID>>(); |
| 695 |
public Dictionary<UUID, List<UUID>> AvatarAnimations |
public Dictionary<UUID, List<UUID>> AvatarAnimations |
| 696 |
{ |
{ |
| 697 |
get |
get |
| 698 |
{ |
{ |
| 699 |
return avatarAnimations; |
return m_avatarAnimations; |
| 700 |
} |
} |
| 701 |
set |
set |
| 702 |
{ |
{ |
| 703 |
avatarAnimations = value; |
m_avatarAnimations = value; |
| 704 |
} |
} |
| 705 |
} |
} |
| 706 |
|
|
| 711 |
|
|
| 712 |
public void Say(string message) |
public void Say(string message) |
| 713 |
{ |
{ |
| 714 |
throw new NotImplementedException(); |
//throw new NotImplementedException(); |
| 715 |
} |
} |
| 716 |
|
|
| 717 |
public void SetCameraPosition(OpenMetaverse.Vector3[] camdata) |
public void SetCameraPosition(OpenMetaverse.Vector3[] camdata) |