private void Avatars_OnEffect(EffectType type, LLUUID sourceID, LLUUID targetID, LLVector3d targetPos, float duration, LLUUID id) { if (ShowEffects) Console.WriteLine( "ViewerEffect [{0}]: SourceID: {1} TargetID: {2} TargetPos: {3} Duration: {4} ID: {5}", type, sourceID.ToString(), targetID.ToString(), targetPos, duration, id.ToString()); }
private void Avatars_OnPointAt(LLUUID sourceID, LLUUID targetID, LLVector3d targetPos, MainAvatar.PointAtType pointType, float duration, LLUUID id) { if (ShowEffects) Console.WriteLine( "ViewerEffect [PointAt]: SourceID: {0} TargetID: {1} TargetPos: {2} Type: {3} Duration: {4} ID: {5}", sourceID.ToStringHyphenated(), targetID.ToStringHyphenated(), targetPos, pointType, duration, id.ToStringHyphenated()); }
private void Avatars_OnLookAt(LLUUID sourceID, LLUUID targetID, LLVector3d targetPos, LookAtType lookType, float duration, LLUUID id) { if (ShowEffects) Console.WriteLine( "ViewerEffect [LookAt]: SourceID: {0} TargetID: {1} TargetPos: {2} Type: {3} Duration: {4} ID: {5}", sourceID.ToString(), targetID.ToString(), targetPos, lookType, duration, id.ToString()); }
/// <summary> /// Process an incoming effect /// </summary> private void ViewerEffectHandler(Packet packet, Simulator simulator) { ViewerEffectPacket effect = (ViewerEffectPacket)packet; foreach (ViewerEffectPacket.EffectBlock block in effect.Effect) { EffectType type = (EffectType)block.Type; //LLColor color; //if (block.Color.Length == 4) //{ // color = new LLColor(block.Color, 0); //} //else //{ // Client.Log("Received a ViewerEffect.EffectBlock.Color array with " + block.Color.Length + // " bytes", Helpers.LogLevel.Warning); // color = LLColor.Black; //} // Each ViewerEffect type uses it's own custom binary format for additional data. Fun eh? switch (type) { case EffectType.Text: Logger.Log("Received a ViewerEffect of type " + type.ToString() + ", implement me!", Helpers.LogLevel.Warning, Client); break; case EffectType.Icon: Logger.Log("Received a ViewerEffect of type " + type.ToString() + ", implement me!", Helpers.LogLevel.Warning, Client); break; case EffectType.Connector: Logger.Log("Received a ViewerEffect of type " + type.ToString() + ", implement me!", Helpers.LogLevel.Warning, Client); break; case EffectType.FlexibleObject: Logger.Log("Received a ViewerEffect of type " + type.ToString() + ", implement me!", Helpers.LogLevel.Warning, Client); break; case EffectType.AnimalControls: Logger.Log("Received a ViewerEffect of type " + type.ToString() + ", implement me!", Helpers.LogLevel.Warning, Client); break; case EffectType.AnimationObject: Logger.Log("Received a ViewerEffect of type " + type.ToString() + ", implement me!", Helpers.LogLevel.Warning, Client); break; case EffectType.Cloth: Logger.Log("Received a ViewerEffect of type " + type.ToString() + ", implement me!", Helpers.LogLevel.Warning, Client); break; case EffectType.Glow: Logger.Log("Received a Glow ViewerEffect which is not implemented yet", Helpers.LogLevel.Warning, Client); break; case EffectType.Beam: case EffectType.Point: case EffectType.Trail: case EffectType.Sphere: case EffectType.Spiral: case EffectType.Edit: if (OnEffect != null) { if (block.TypeData.Length == 56) { LLUUID sourceAvatar = new LLUUID(block.TypeData, 0); LLUUID targetObject = new LLUUID(block.TypeData, 16); LLVector3d targetPos = new LLVector3d(block.TypeData, 32); try { OnEffect(type, sourceAvatar, targetObject, targetPos, block.Duration, block.ID); } catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); } } else { Logger.Log("Received a " + type.ToString() + " ViewerEffect with an incorrect TypeData size of " + block.TypeData.Length + " bytes", Helpers.LogLevel.Warning, Client); } } break; case EffectType.LookAt: if (OnLookAt != null) { if (block.TypeData.Length == 57) { LLUUID sourceAvatar = new LLUUID(block.TypeData, 0); LLUUID targetObject = new LLUUID(block.TypeData, 16); LLVector3d targetPos = new LLVector3d(block.TypeData, 32); LookAtType lookAt = (LookAtType)block.TypeData[56]; try { OnLookAt(sourceAvatar, targetObject, targetPos, lookAt, block.Duration, block.ID); } catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); } } else { Logger.Log("Received a LookAt ViewerEffect with an incorrect TypeData size of " + block.TypeData.Length + " bytes", Helpers.LogLevel.Warning, Client); } } break; case EffectType.PointAt: if (OnPointAt != null) { if (block.TypeData.Length == 57) { LLUUID sourceAvatar = new LLUUID(block.TypeData, 0); LLUUID targetObject = new LLUUID(block.TypeData, 16); LLVector3d targetPos = new LLVector3d(block.TypeData, 32); PointAtType pointAt = (PointAtType)block.TypeData[56]; try { OnPointAt(sourceAvatar, targetObject, targetPos, pointAt, block.Duration, block.ID); } catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); } } else { Logger.Log("Received a PointAt ViewerEffect with an incorrect TypeData size of " + block.TypeData.Length + " bytes", Helpers.LogLevel.Warning, Client); } } break; default: Logger.Log("Received a ViewerEffect with an unknown type " + type, Helpers.LogLevel.Warning, Client); break; } } }
/// <summary> /// Constructor, builds a single-precision vector from a /// double-precision one /// </summary> /// <param name="vector">A double-precision vector</param> public LLVector3(LLVector3d vector) { X = (float)vector.X; Y = (float)vector.Y; Z = (float)vector.Z; }
/// <summary> /// Create a particle beam between an avatar and an primitive /// </summary> /// <param name="sourceAvatar"><seealso cref="T:libsecondlife.LLUUID"/> of sources avatar</param> /// <param name="targetObject"><seealso cref="T:libsecondlife.LLUUID"/> of the target</param> /// <param name="globalOffset"><seealso cref="T:libsecondlife.LLVector3d"/>global offset</param> /// <param name="color"><seealso cref="T:libsecondlife.LLColor"/>Color values of beam</param> /// <param name="duration">a float representing the duration the beam will last</param> /// <param name="effectID"><seealso cref="T:libsecondlife.LLUUID"/> of the Effect</param> public void BeamEffect(LLUUID sourceAvatar, LLUUID targetObject, LLVector3d globalOffset, LLColor color, float duration, LLUUID effectID) { ViewerEffectPacket effect = new ViewerEffectPacket(); effect.AgentData.AgentID = Client.Self.AgentID; effect.AgentData.SessionID = Client.Self.SessionID; effect.Effect = new ViewerEffectPacket.EffectBlock[1]; effect.Effect[0] = new ViewerEffectPacket.EffectBlock(); effect.Effect[0].AgentID = Client.Self.AgentID; effect.Effect[0].Color = color.GetFloatBytes(); effect.Effect[0].Duration = duration; effect.Effect[0].ID = effectID; effect.Effect[0].Type = (byte)EffectType.Beam; byte[] typeData = new byte[56]; Buffer.BlockCopy(sourceAvatar.GetBytes(), 0, typeData, 0, 16); Buffer.BlockCopy(targetObject.GetBytes(), 0, typeData, 16, 16); Buffer.BlockCopy(globalOffset.GetBytes(), 0, typeData, 32, 24); effect.Effect[0].TypeData = typeData; Client.Network.SendPacket(effect); }
/// <summary> /// Start a particle stream between an agent and an object /// </summary> /// <param name="sourceAvatar"><seealso cref="LLUUID"/> Key of the source agent</param> /// <param name="targetObject"><seealso cref="LLUUID"/> Key of the target object</param> /// <param name="globalOffset">A <seealso cref="T:libsecondlife.LLVector3d"/> representing the beams offset from the source</param> /// <param name="type">A <seealso cref="T:PointAtType"/> which sets the avatars lookat animation</param> /// <param name="effectID"><seealso cref="T:libsecondlife.LLUUID"/> of the Effect</param> public void LookAtEffect(LLUUID sourceAvatar, LLUUID targetObject, LLVector3d globalOffset, LookAtType type, LLUUID effectID) { ViewerEffectPacket effect = new ViewerEffectPacket(); effect.AgentData.AgentID = Client.Self.AgentID; effect.AgentData.SessionID = Client.Self.SessionID; float duration; switch (type) { case LookAtType.Clear: duration = 0.0f; break; case LookAtType.Hover: duration = 1.0f; break; case LookAtType.FreeLook: duration = 2.0f; break; case LookAtType.Idle: duration = 3.0f; break; case LookAtType.AutoListen: case LookAtType.Respond: duration = 4.0f; break; case LookAtType.None: case LookAtType.Select: case LookAtType.Focus: case LookAtType.Mouselook: duration = Single.MaxValue / 2.0f; break; default: duration = 0.0f; break; } effect.Effect = new ViewerEffectPacket.EffectBlock[1]; effect.Effect[0] = new ViewerEffectPacket.EffectBlock(); effect.Effect[0].AgentID = Client.Self.AgentID; effect.Effect[0].Color = new byte[4]; effect.Effect[0].Duration = duration; effect.Effect[0].ID = effectID; effect.Effect[0].Type = (byte)EffectType.LookAt; byte[] typeData = new byte[57]; if (sourceAvatar != LLUUID.Zero) Buffer.BlockCopy(sourceAvatar.GetBytes(), 0, typeData, 0, 16); if (targetObject != LLUUID.Zero) Buffer.BlockCopy(targetObject.GetBytes(), 0, typeData, 16, 16); typeData[56] = (byte)type; effect.Effect[0].TypeData = typeData; Client.Network.SendPacket(effect); }
/// <summary> /// Start a particle stream between an agent and an object /// </summary> /// <param name="sourceAvatar"><seealso cref="LLUUID"/> Key of the source agent</param> /// <param name="targetObject"><seealso cref="LLUUID"/> Key of the target object</param> /// <param name="globalOffset"></param> /// <param name="type"><seealso cref="T:PointAtType"/></param> /// <param name="effectID"></param> public void PointAtEffect(LLUUID sourceAvatar, LLUUID targetObject, LLVector3d globalOffset, PointAtType type, LLUUID effectID) { ViewerEffectPacket effect = new ViewerEffectPacket(); effect.AgentData.AgentID = Client.Self.AgentID; effect.AgentData.SessionID = Client.Self.SessionID; effect.Effect = new ViewerEffectPacket.EffectBlock[1]; effect.Effect[0] = new ViewerEffectPacket.EffectBlock(); effect.Effect[0].AgentID = Client.Self.AgentID; effect.Effect[0].Color = new byte[4]; effect.Effect[0].Duration = (type == PointAtType.Clear) ? 0.0f : Single.MaxValue / 4.0f; effect.Effect[0].ID = effectID; effect.Effect[0].Type = (byte)EffectType.PointAt; byte[] typeData = new byte[57]; if (sourceAvatar != LLUUID.Zero) Buffer.BlockCopy(sourceAvatar.GetBytes(), 0, typeData, 0, 16); if (targetObject != LLUUID.Zero) Buffer.BlockCopy(targetObject.GetBytes(), 0, typeData, 16, 16); Buffer.BlockCopy(globalOffset.GetBytes(), 0, typeData, 32, 24); typeData[56] = (byte)type; effect.Effect[0].TypeData = typeData; Client.Network.SendPacket(effect); }
/// <summary> /// /// </summary> /// <param name="vector"></param> public LLVector3(LLVector3d vector) { X = (float)vector.X; Y = (float)vector.Y; Z = (float)vector.Z; }
void Avatars_OnPointAt(LLUUID sourceID, LLUUID targetID, LLVector3d targetPos, PointAtType pointType, float duration, LLUUID id) { if (sourceID == Client.MasterKey) { //Client.DebugLog("Master is now selecting " + targetID.ToString()); SelectedObject = targetID; } }
/// <summary> /// Process an incoming effect /// </summary> private void ViewerEffectHandler(Packet packet, Simulator simulator) { ViewerEffectPacket effect = (ViewerEffectPacket)packet; foreach (ViewerEffectPacket.EffectBlock block in effect.Effect) { MainAvatar.EffectType type = (MainAvatar.EffectType)block.Type; //LLColor color; //if (block.Color.Length == 4) //{ // color = new LLColor(block.Color, 0); //} //else //{ // Client.Log("Received a ViewerEffect.EffectBlock.Color array with " + block.Color.Length + // " bytes", Helpers.LogLevel.Warning); // color = LLColor.Black; //} // Each ViewerEffect type uses it's own custom binary format for additional data. Fun eh? switch (type) { case MainAvatar.EffectType.Text: Client.Log("Received a ViewerEffect of type " + type.ToString() + ", implement me!", Helpers.LogLevel.Warning); break; case MainAvatar.EffectType.Icon: Client.Log("Received a ViewerEffect of type " + type.ToString() + ", implement me!", Helpers.LogLevel.Warning); break; case MainAvatar.EffectType.Connector: Client.Log("Received a ViewerEffect of type " + type.ToString() + ", implement me!", Helpers.LogLevel.Warning); break; case MainAvatar.EffectType.FlexibleObject: Client.Log("Received a ViewerEffect of type " + type.ToString() + ", implement me!", Helpers.LogLevel.Warning); break; case MainAvatar.EffectType.AnimalControls: Client.Log("Received a ViewerEffect of type " + type.ToString() + ", implement me!", Helpers.LogLevel.Warning); break; case MainAvatar.EffectType.AnimationObject: Client.Log("Received a ViewerEffect of type " + type.ToString() + ", implement me!", Helpers.LogLevel.Warning); break; case MainAvatar.EffectType.Cloth: Client.Log("Received a ViewerEffect of type " + type.ToString() + ", implement me!", Helpers.LogLevel.Warning); break; case MainAvatar.EffectType.Glow: Client.Log("Received a Glow ViewerEffect which is not implemented yet", Helpers.LogLevel.Warning); break; case MainAvatar.EffectType.Beam: case MainAvatar.EffectType.Point: case MainAvatar.EffectType.Trail: case MainAvatar.EffectType.Sphere: case MainAvatar.EffectType.Spiral: case MainAvatar.EffectType.Edit: if (OnEffect != null) { if (block.TypeData.Length == 56) { LLUUID sourceAvatar = new LLUUID(block.TypeData, 0); LLUUID targetObject = new LLUUID(block.TypeData, 16); LLVector3d targetPos = new LLVector3d(block.TypeData, 32); try { OnEffect(type, sourceAvatar, targetObject, targetPos, block.Duration, block.ID); } catch (Exception e) { Client.Log(e.ToString(), Helpers.LogLevel.Error); } } else { Client.Log("Received a " + type.ToString() + " ViewerEffect with an incorrect TypeData size of " + block.TypeData.Length + " bytes", Helpers.LogLevel.Warning); } } break; case MainAvatar.EffectType.LookAt: if (OnLookAt != null) { if (block.TypeData.Length == 57) { LLUUID sourceAvatar = new LLUUID(block.TypeData, 0); LLUUID targetObject = new LLUUID(block.TypeData, 16); LLVector3d targetPos = new LLVector3d(block.TypeData, 32); MainAvatar.LookAtType lookAt = (MainAvatar.LookAtType)block.TypeData[56]; try { OnLookAt(sourceAvatar, targetObject, targetPos, lookAt, block.Duration, block.ID); } catch (Exception e) { Client.Log(e.ToString(), Helpers.LogLevel.Error); } } else { Client.Log("Received a LookAt ViewerEffect with an incorrect TypeData size of " + block.TypeData.Length + " bytes", Helpers.LogLevel.Warning); } } break; case MainAvatar.EffectType.PointAt: if (OnPointAt != null) { if (block.TypeData.Length == 57) { LLUUID sourceAvatar = new LLUUID(block.TypeData, 0); LLUUID targetObject = new LLUUID(block.TypeData, 16); LLVector3d targetPos = new LLVector3d(block.TypeData, 32); MainAvatar.PointAtType pointAt = (MainAvatar.PointAtType)block.TypeData[56]; try { OnPointAt(sourceAvatar, targetObject, targetPos, pointAt, block.Duration, block.ID); } catch (Exception e) { Client.Log(e.ToString(), Helpers.LogLevel.Error); } } else { Client.Log("Received a PointAt ViewerEffect with an incorrect TypeData size of " + block.TypeData.Length + " bytes", Helpers.LogLevel.Warning); } } break; default: Client.Log("Received a ViewerEffect with an unknown type " + type, Helpers.LogLevel.Warning); break; } } }
/// <summary> /// Calculates the distance between two vectors /// </summary> public static double Dist(LLVector3d pointA, LLVector3d pointB) { double xd = pointB.X - pointA.X; double yd = pointB.Y - pointA.Y; double zd = pointB.Z - pointA.Z; return Math.Sqrt(xd * xd + yd * yd + zd * zd); }
/// <summary> /// Constructor, builds a single-precision vector from a /// double-precision one /// </summary> /// <param name="vector">A double-precision vector</param> public LLVector3(LLVector3d vector) { conversionBuffer = null; X = (float)vector.X; Y = (float)vector.Y; Z = (float)vector.Z; }
public static bool TryParse(string val, out LLVector3d result) { try { result = Parse(val); return true; } catch (Exception) { result = new LLVector3d(); return false; } }
/// <summary> /// Copy constructor /// </summary> /// <param name="vector">Vector to copy</param> public LLVector3d(LLVector3d vector) { conversionBuffer = null; X = vector.X; Y = vector.Y; Z = vector.Z; }