void Self_OnChat(string message, byte audible, byte type, byte sourcetype, string fromName, LLUUID id, LLUUID ownerid, LLVector3 position) { if (message.Length > 0) { _speechSynthesizer.SpeakAsync(message); } }
void Self_OnChat(string message, byte audible, byte type, byte sourcetype, string fromName, LLUUID id, LLUUID ownerid, LLVector3 position) { if (message.Length > 0 && TestClient.Master == fromName) { TestClient.Self.Chat(message, 0, MainAvatar.ChatType.Normal); } }
/// <summary> /// Update client's Position and LookAt from incoming packet /// </summary> /// <param name="packet">Incoming AgentMovementCompletePacket</param> /// <param name="simulator">[UNUSED]</param> private void MovementCompleteHandler(Packet packet, Simulator simulator) { AgentMovementCompletePacket movement = (AgentMovementCompletePacket)packet; this.Position = movement.Data.Position; this.LookAt = movement.Data.LookAt; }
public override string Execute(string[] args, LLUUID fromAgentID) { if (args.Length == 1) { try { string treeName = args[0].Trim(new char[] { ' ' }); ObjectManager.Tree tree = (ObjectManager.Tree)Enum.Parse(typeof(ObjectManager.Tree), treeName); LLVector3 treePosition = new LLVector3(Client.Self.Position.X, Client.Self.Position.Y, Client.Self.Position.Z); treePosition.Z += 3.0f; Client.Objects.AddTree(Client.Network.CurrentSim, new LLVector3(0.5f, 0.5f, 0.5f), LLQuaternion.Identity, treePosition, tree, Client.GroupID, false); return "Attempted to rez a " + treeName + " tree"; } catch (Exception) { return "Type !tree for usage"; } } string usage = "Usage: !tree ["; foreach (string value in Enum.GetNames(typeof(ObjectManager.Tree))) { usage += value + ","; } usage = usage.TrimEnd(new char[] { ',' }); usage += "]"; return usage; }
/// <summary> /// Aims at the specified position, enters mouselook, presses and /// releases the left mouse button, and leaves mouselook /// </summary> /// <param name="target">Target to shoot at</param> /// <returns></returns> public static bool Shoot(SecondLife client, LLVector3 target) { if (client.Self.Movement.TurnToward(target)) return Shoot(client); else return false; }
/// <summary> /// Send new AgentUpdate packet to update our current camera /// position and rotation /// </summary> /// <param name="reliable">Whether to require server acknowledgement /// of this packet</param> /// <param name="simulator">Simulator to send the update to</param> public void SendUpdate(bool reliable, Simulator simulator) { LLVector3 origin = Camera.Position; LLVector3 xAxis = Camera.LeftAxis; LLVector3 yAxis = Camera.AtAxis; LLVector3 zAxis = Camera.UpAxis; // Attempted to sort these in a rough order of how often they might change if (agentControls == 0 && yAxis == LastCameraYAxis && origin == LastCameraCenter && State == lastState && HeadRotation == LastHeadRotation && BodyRotation == LastBodyRotation && xAxis == LastCameraXAxis && Camera.Far == LastFar && zAxis == LastCameraZAxis) { ++duplicateCount; } else { duplicateCount = 0; } if (Client.Settings.CONTINUOUS_AGENT_UPDATES || duplicateCount < 10) { // Store the current state to do duplicate checking in the future LastHeadRotation = HeadRotation; LastBodyRotation = BodyRotation; LastCameraYAxis = yAxis; LastCameraCenter = origin; LastCameraXAxis = xAxis; LastCameraZAxis = zAxis; LastFar = Camera.Far; lastState = State; // Build the AgentUpdate packet and send it AgentUpdatePacket update = new AgentUpdatePacket(); update.Header.Reliable = reliable; update.AgentData.AgentID = Client.Self.AgentID; update.AgentData.SessionID = Client.Self.SessionID; update.AgentData.HeadRotation = HeadRotation; update.AgentData.BodyRotation = BodyRotation; update.AgentData.CameraAtAxis = yAxis; update.AgentData.CameraCenter = origin; update.AgentData.CameraLeftAxis = xAxis; update.AgentData.CameraUpAxis = zAxis; update.AgentData.Far = Camera.Far; update.AgentData.State = (byte)State; update.AgentData.ControlFlags = agentControls; update.AgentData.Flags = (byte)Flags; Client.Network.SendPacket(update, simulator); ResetControlFlags(); } }
public UserProfile() { Circuits = new Dictionary<LLUUID, uint>(); Inventory = new AgentInventory(); homeregionhandle = Helpers.UIntsToLong((997 * 256), (996 * 256)); homepos = new LLVector3(); homelookat = new LLVector3(); }
protected void Orthonormalize() { // Make sure the axis are orthagonal and normalized xAxis = LLVector3.Norm(xAxis); yAxis -= xAxis * (xAxis * yAxis); yAxis = LLVector3.Norm(yAxis); zAxis = LLVector3.Cross(xAxis, yAxis); }
/// <summary> /// Constructor /// </summary> /// <param name="client">Instance of type SecondLife to associate with this GridManager instance</param> public GridManager(SecondLife client) { Client = client; SunDirection = LLVector3.Zero; Client.Network.RegisterCallback(PacketType.MapBlockReply, new NetworkManager.PacketCallback(MapBlockReplyHandler)); Client.Network.RegisterCallback(PacketType.SimulatorViewerTimeMessage, new NetworkManager.PacketCallback(TimeMessageHandler)); }
/// <summary> /// Calculates the distance between two vectors /// </summary> public static float VecDist(LLVector3 pointA, LLVector3 pointB) { float xd = pointB.X - pointA.X; float yd = pointB.Y - pointA.Y; float zd = pointB.Z - pointA.Z; return((float)Math.Sqrt(xd * xd + yd * yd + zd * zd)); }
void Self_OnChat(string message, MainAvatar.ChatAudibleLevel audible, MainAvatar.ChatType type, MainAvatar.ChatSourceType sourcetype, string fromName, LLUUID id, LLUUID ownerid, LLVector3 position) { if (message.Length > 0 && Client.MasterKey == id) { Client.Self.Chat(message, 0, MainAvatar.ChatType.Normal); } }
public void LookAt(LLVector3 origin, LLVector3 target, LLVector3 upDirection) { this.origin = origin; LLVector3 at = new LLVector3(target - origin); at = LLVector3.Norm(at); LookDirection(at, upDirection); }
/// <summary> /// Constructor /// </summary> /// <param name="client">Instance of type SecondLife to associate with this GridManager instance</param> public GridManager(SecondLife client) { Client = client; Regions = new Dictionary <string, GridRegion>(); SunDirection = new LLVector3(); Client.Network.RegisterCallback(PacketType.MapBlockReply, new PacketCallback(MapBlockReplyHandler)); Client.Network.RegisterCallback(PacketType.SimulatorViewerTimeMessage, new PacketCallback(TimeMessageHandler)); }
/// <summary> /// Constructor /// </summary> /// <param name="client">Instance of type SecondLife to associate with this GridManager instance</param> public GridManager(SecondLife client) { Client = client; Regions = new Dictionary<string, GridRegion>(); SunDirection = new LLVector3(); Client.Network.RegisterCallback(PacketType.MapBlockReply, new PacketCallback(MapBlockReplyHandler)); Client.Network.RegisterCallback(PacketType.SimulatorViewerTimeMessage, new PacketCallback(TimeMessageHandler)); }
public CoordinateFrame(LLVector3 origin, LLVector3 direction) { this.origin = origin; LookDirection(direction); if (!IsFinite()) { throw new ArgumentException("Non-finite in CoordinateFrame constructor"); } }
public void SetPositionOrientation(LLVector3 position, float roll, float pitch, float yaw) { Frame.Origin = position; Frame.ResetAxes(); Frame.Roll(roll); Frame.Pitch(pitch); Frame.Yaw(yaw); }
/// <summary> /// Creates a new Entity (should not occur on it's own) /// </summary> public Entity() { uuid = new libsecondlife.LLUUID(); localid = 0; m_pos = new LLVector3(); velocity = new LLVector3(); rotation = new Quaternion(); m_name = "(basic entity)"; children = new List<Entity>(); }
/// <summary> /// Get sim time from the appropriate packet /// </summary> /// <param name="packet">Incoming SimulatorViewerTimeMessagePacket from SL</param> /// <param name="simulator">Unused</param> private void TimeMessageHandler(Packet packet, Simulator simulator) { SimulatorViewerTimeMessagePacket time = (SimulatorViewerTimeMessagePacket)packet; sunPhase = time.TimeInfo.SunPhase; sunDirection = time.TimeInfo.SunDirection; sunAngVelocity = time.TimeInfo.SunAngVelocity; // TODO: Does anyone have a use for the time stuff? }
/// <summary> /// Aims at the specified position, enters mouselook, presses and /// releases the left mouse button, and leaves mouselook /// </summary> /// <param name="target">Target to shoot at</param> /// <returns></returns> public bool Shoot(LLVector3 target) { if (TurnToward(target)) { return(Shoot()); } else { return(false); } }
public ChatEventArgs(string message, ChatAudibleLevel audible, ChatType type, ChatSourceType sourceType, string fromName, LLUUID id, LLUUID ownerid, LLVector3 position) { this.message = message; this.audible = audible; this.type = type; this.sourceType = sourceType; this.fromName = fromName; this.id = id; this.ownerid = ownerid; this.position = position; }
/// <summary> /// /// </summary> /// <param name="o"></param> /// <returns></returns> public override bool Equals(object o) { if (!(o is LLVector3)) { return(false); } LLVector3 vector = (LLVector3)o; return(X == vector.X && Y == vector.Y && Z == vector.Z); }
public CoordinateFrame(LLVector3 origin) { this.origin = origin; xAxis = X_AXIS; yAxis = Y_AXIS; zAxis = Z_AXIS; if (!this.origin.IsFinite()) { throw new ArgumentException("Non-finite in CoordinateFrame constructor"); } }
public CoordinateFrame(LLVector3 origin, LLVector3 xAxis, LLVector3 yAxis, LLVector3 zAxis) { this.origin = origin; this.xAxis = xAxis; this.yAxis = yAxis; this.zAxis = zAxis; if (!IsFinite()) { throw new ArgumentException("Non-finite in CoordinateFrame constructor"); } }
public CoordinateFrame(LLVector3 origin, LLMatrix3 rotation) { this.origin = origin; xAxis = rotation[0]; yAxis = rotation[1]; zAxis = rotation[2]; if (!IsFinite()) { throw new ArgumentException("Non-finite in CoordinateFrame constructor"); } }
private void FromBytes(byte[] data, int pos) { int i = pos; Softness = ((data[i] & 0x80) >> 6) | ((data[i + 1] & 0x80) >> 7); Tension = (data[i++] & 0x7F) / 10.0f; Drag = (data[i++] & 0x7F) / 10.0f; Gravity = (data[i++] / 10.0f) - 10.0f; Wind = data[i++] / 10.0f; Force = new LLVector3(data, i); }
public void Rotate(LLMatrix3 m) { xAxis = LLVector3.Rot(xAxis, m); yAxis = LLVector3.Rot(yAxis, m); Orthonormalize(); if (!IsFinite()) { throw new Exception("Non-finite in CoordinateFrame.Rotate()"); } }
private void init() { OwnerID = new LLUUID(); AABBMin = new LLVector3(); AABBMax = new LLVector3(); Bitmap = new byte[512]; MediaID = new LLUUID(); GroupID = new LLUUID(); AuthBuyerID = new LLUUID(); SnapshotID = new LLUUID(); UserLocation = new LLVector3(); UserLookAt = new LLVector3(); }
private void init() { OwnerID = LLUUID.Zero; AABBMin = LLVector3.Zero; AABBMax = LLVector3.Zero; Bitmap = new byte[512]; MediaID = LLUUID.Zero; GroupID = LLUUID.Zero; AuthBuyerID = LLUUID.Zero; SnapshotID = LLUUID.Zero; UserLocation = LLVector3.Zero; UserLookAt = LLVector3.Zero; }
public CoordinateFrame(LLVector3 origin, LLQuaternion rotation) { LLMatrix3 m = new LLMatrix3(rotation); this.origin = origin; xAxis = m[0]; yAxis = m[1]; zAxis = m[2]; if (!IsFinite()) { throw new ArgumentException("Non-finite in CoordinateFrame constructor"); } }
public void Self_OnChat(string message, ChatAudibleLevel audible, ChatType type, ChatSourceType sourcetype, string fromName, LLUUID id, LLUUID ownerid, LLVector3 position) { Console.WriteLine(fromName+":" + message); if (message.Length > 0 && message.ToLower().Contains(Client.Self.FirstName.ToLower()) && Client.Self.AgentID != id) { WebRequest request = WebRequest.Create("http://www.mr-technicl.com/slfutura.php?nick="+ fromName + "&message="+ message); WebResponse response = request.GetResponse(); StreamReader input = new StreamReader(response.GetResponseStream()); string say = input.ReadToEnd(); input.Close(); libsecondlife.Utilities.Realism.Chat(Client, say, ChatType.Normal, 25); } }
/// <summary> /// Plays a sound /// </summary> /// <param name="soundID">UUID of the sound to be played.</param> /// <param name="handle">handle id for the sim to be played in.</param> /// <param name="position">position for the sound to be played at. Normally the avatar.</param> /// <param name="gain">volume of the sound, from 0.0 to 1.0</param> public void SoundTrigger(LLUUID soundID, ulong handle, LLVector3 position, float gain) { SoundTriggerPacket soundtrigger = new SoundTriggerPacket(); soundtrigger.SoundData = new SoundTriggerPacket.SoundDataBlock(); soundtrigger.SoundData.SoundID = soundID; soundtrigger.SoundData.ObjectID = LLUUID.Zero; soundtrigger.SoundData.OwnerID = LLUUID.Zero; soundtrigger.SoundData.ParentID = LLUUID.Zero; soundtrigger.SoundData.Handle = handle; soundtrigger.SoundData.Position = position; soundtrigger.SoundData.Gain = gain; Client.Network.SendPacket(soundtrigger); }
/// <summary> /// /// </summary> /// <param name="prim"></param> /// <param name="position"></param> /// <param name="avatarPosition"></param> public void RezObject(PrimObject prim, LLVector3 position, LLVector3 rayStart, LLUUID groupID) { ObjectAddPacket add = new ObjectAddPacket(); add.AgentData.AgentID = Client.Network.AgentID; add.AgentData.SessionID = Client.Network.SessionID; add.AgentData.GroupID = groupID; // TODO: Why 2? add.ObjectData.AddFlags = 2; add.ObjectData.BypassRaycast = 1; add.ObjectData.Material = (byte)prim.Material; add.ObjectData.PathBegin = PrimObject.PathBeginByte(prim.PathBegin); add.ObjectData.PathCurve = (byte)prim.PathCurve; add.ObjectData.PathEnd = PrimObject.PathEndByte(prim.PathEnd); add.ObjectData.PathRadiusOffset = PrimObject.PathRadiusOffsetByte(prim.PathRadiusOffset); add.ObjectData.PathRevolutions = PrimObject.PathRevolutionsByte(prim.PathRevolutions); add.ObjectData.PathScaleX = PrimObject.PathScaleByte(prim.PathScaleX); add.ObjectData.PathScaleY = PrimObject.PathScaleByte(prim.PathScaleY); add.ObjectData.PathShearX = PrimObject.PathShearByte(prim.PathShearX); add.ObjectData.PathShearY = PrimObject.PathShearByte(prim.PathShearY); add.ObjectData.PathSkew = PrimObject.PathSkewByte(prim.PathSkew); add.ObjectData.PathTaperX = PrimObject.PathTaperByte(prim.PathTaperX); add.ObjectData.PathTaperY = PrimObject.PathTaperByte(prim.PathTaperY); add.ObjectData.PathTwist = PrimObject.PathTwistByte(prim.PathTwist); add.ObjectData.PathTwistBegin = PrimObject.PathTwistByte(prim.PathTwistBegin); add.ObjectData.PCode = (byte)prim.PCode; add.ObjectData.ProfileBegin = PrimObject.ProfileBeginByte(prim.ProfileBegin); add.ObjectData.ProfileCurve = (byte)prim.ProfileCurve; add.ObjectData.ProfileEnd = PrimObject.ProfileEndByte(prim.ProfileEnd); add.ObjectData.ProfileHollow = (byte)prim.ProfileHollow; add.ObjectData.RayEnd = position; add.ObjectData.RayEndIsIntersection = 0; add.ObjectData.RayStart = rayStart; add.ObjectData.RayTargetID = LLUUID.GenerateUUID(); add.ObjectData.Rotation = prim.Rotation; add.ObjectData.Scale = prim.Scale; add.ObjectData.State = (byte)prim.State; if (prim.Textures != null) { add.ObjectData.TextureEntry = prim.Textures.ToBytes(); } else { add.ObjectData.TextureEntry = new byte[0]; } Client.Network.SendPacket(add); }
/// <summary> /// /// </summary> /// <param name="regionHandle"></param> /// <param name="position"></param> /// <param name="lookAt"></param> /// <returns></returns> public bool Teleport(ulong regionHandle, LLVector3 position, LLVector3 lookAt) { TeleportStat = TeleportStatus.None; TeleportLocationRequestPacket teleport = new TeleportLocationRequestPacket(); teleport.AgentData.AgentID = Client.Network.AgentID; teleport.AgentData.SessionID = Client.Network.SessionID; teleport.Info.LookAt = lookAt; teleport.Info.Position = position; teleport.Info.RegionHandle = regionHandle; Client.Log("Teleporting to region " + regionHandle.ToString(), Helpers.LogLevel.Info); // Start the timeout check TeleportTimeout = false; TeleportTimer.Start(); Client.Network.SendPacket(teleport); while (TeleportStat != TeleportStatus.Failed && TeleportStat != TeleportStatus.Finished && !TeleportTimeout) { Client.Tick(); } TeleportTimer.Stop(); if (TeleportTimeout) { TeleportMessage = "Teleport timed out."; TeleportStat = TeleportStatus.Failed; if (OnTeleport != null) { OnTeleport(TeleportMessage, TeleportStat); } } else { if (OnTeleport != null) { OnTeleport(TeleportMessage, TeleportStat); } } return(TeleportStat == TeleportStatus.Finished); }
/// <summary> /// Handle friend location updates /// </summary> /// <param name="packet">The Packet</param> /// <param name="simulator">The Simulator</param> public void OnFindAgentReplyHandler(Packet packet, Simulator simulator) { if (OnFriendFound != null) { FindAgentPacket reply = (FindAgentPacket)packet; float x, y; LLUUID prey = reply.AgentBlock.Prey; ulong regionHandle = Helpers.GlobalPosToRegionHandle((float)reply.LocationBlock[0].GlobalX, (float)reply.LocationBlock[0].GlobalY, out x, out y); LLVector3 xyz = new LLVector3(x, y, 0f); try { OnFriendFound(prey, regionHandle, xyz); } catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); } } }
/// <summary> /// /// </summary> /// <param name="regionHandle"></param> /// <param name="position"></param> /// <param name="lookAt"></param> /// <param name="tc"></param> public void BeginTeleport(ulong regionHandle, LLVector3 position, LLVector3 lookAt, TeleportCallback tc) { OnBeginTeleport = tc; TeleportLocationRequestPacket teleport = new TeleportLocationRequestPacket(); teleport.AgentData.AgentID = Client.Network.AgentID; teleport.AgentData.SessionID = Client.Network.SessionID; teleport.Info.LookAt = lookAt; teleport.Info.Position = position; teleport.Info.RegionHandle = regionHandle; Client.Log("Teleporting to region " + regionHandle.ToString(), Helpers.LogLevel.Info); Client.Network.SendPacket(teleport); }
public ChatEventArgs( string message, SLChatType type, LLVector3 sourcePos, SLSourceType sourceType, LLUUID sourceId, LLUUID ownerId, string fromName, bool audible, byte command, LLUUID commandId) { _message = message; _type = type; _sourcePos = sourcePos; _sourceType = sourceType; _sourceId = sourceId; _ownerId = ownerId; _fromName = fromName; _audible = audible; _command = command; _commandId = commandId; }
/// <summary> /// /// </summary> /// <param name="at">Looking direction, must be a normalized vector</param> /// <param name="upDirection">Up direction, must be a normalized vector</param> public void LookDirection(LLVector3 at, LLVector3 upDirection) { // The two parameters cannot be parallel LLVector3 left = LLVector3.Cross(upDirection, at); if (left == LLVector3.Zero) { // Prevent left from being zero at.X += 0.01f; at = LLVector3.Norm(at); left = LLVector3.Cross(upDirection, at); } left = LLVector3.Norm(left); xAxis = at; yAxis = left; zAxis = LLVector3.Cross(at, left); }
private void MyOnFrame(IScriptContext context) { LLVector3 pos = context.Entity.Pos; IScriptReadonlyEntity avatar; if (context.TryGetRandomAvatar(out avatar)) { LLVector3 avatarPos = avatar.Pos; float x = pos.X + ((float)avatarPos.X.CompareTo(pos.X)) / 2; float y = pos.Y + ((float)avatarPos.Y.CompareTo(pos.Y)) / 2; LLVector3 newPos = new LLVector3(x, y, pos.Z); context.Entity.Pos = newPos; } }
public static FlexibleData FromLLSD(LLSD llsd) { FlexibleData flex = new FlexibleData(); if (llsd.Type == LLSDType.Map) { LLSDMap map = (LLSDMap)llsd; flex.Softness = map["simulate_lod"].AsInteger(); flex.Gravity = (float)map["gravity"].AsReal(); flex.Drag = (float)map["air_friction"].AsReal(); flex.Wind = (float)map["wind_sensitivity"].AsReal(); flex.Tension = (float)map["tension"].AsReal(); flex.Force = LLVector3.FromLLSD(map["user_force"]); } return(flex); }
/// <summary> /// /// </summary> /// <param name="simName"></param> /// <param name="position"></param> /// <param name="lookAt"></param> /// <returns></returns> public bool Teleport(string simName, LLVector3 position, LLVector3 lookAt) { int attempts = 0; TeleportStat = TeleportStatus.None; simName = simName.ToLower(); GridRegion region = Client.Grid.GetGridRegion(simName); if (region != null) { return(Teleport(region.RegionHandle, position, lookAt)); } else { while (attempts++ < 5) { region = Client.Grid.GetGridRegion(simName); if (region != null) { return(Teleport(region.RegionHandle, position, lookAt)); } else { // Request the region info again Client.Grid.AddSim(simName); System.Threading.Thread.Sleep(1000); } } } if (OnTeleport != null) { TeleportMessage = "Unable to resolve name: " + simName; TeleportStat = TeleportStatus.Failed; OnTeleport(TeleportMessage, TeleportStat); } return(false); }
/// <summary> /// Constructor, aka 'CallBack Central' - Setup callbacks for packets related to our avatar /// </summary> /// <param name="client"></param> public MainAvatar(SecondLife client) { PacketCallback callback; Client = client; TeleportMessage = ""; // Create emtpy vectors for now HomeLookAt = HomePosition = Position = LookAt = new LLVector3(); Rotation = new LLQuaternion(); // Coarse location callback Client.Network.RegisterCallback(PacketType.CoarseLocationUpdate, new PacketCallback(CoarseLocationHandler)); // Teleport callbacks callback = new PacketCallback(TeleportHandler); Client.Network.RegisterCallback(PacketType.TeleportStart, callback); Client.Network.RegisterCallback(PacketType.TeleportProgress, callback); Client.Network.RegisterCallback(PacketType.TeleportFailed, callback); Client.Network.RegisterCallback(PacketType.TeleportFinish, callback); // Instant Message callback Client.Network.RegisterCallback(PacketType.ImprovedInstantMessage, new PacketCallback(InstantMessageHandler)); // Chat callback Client.Network.RegisterCallback(PacketType.ChatFromSimulator, new PacketCallback(ChatHandler)); TeleportTimer = new Timer(18000); TeleportTimer.Elapsed += new ElapsedEventHandler(TeleportTimerEvent); TeleportTimeout = false; // Movement complete callback Client.Network.RegisterCallback(PacketType.AgentMovementComplete, new PacketCallback(MovementCompleteHandler)); // Health callback Client.Network.RegisterCallback(PacketType.HealthMessage, new PacketCallback(HealthHandler)); // Money callbacks callback = new PacketCallback(BalanceHandler); Client.Network.RegisterCallback(PacketType.MoneyBalanceReply, callback); Client.Network.RegisterCallback(PacketType.MoneySummaryReply, callback); Client.Network.RegisterCallback(PacketType.AdjustBalance, callback); }
/// <summary> /// Calculate the rotation between two vectors /// </summary> /// <param name="a">Directional vector, such as 1,0,0 for the forward face</param> /// <param name="b">Target vector - normalize first with VecNorm</param> public static LLQuaternion RotBetween(LLVector3 a, LLVector3 b) { //A and B should both be normalized //dotProduct is 0 if a and b are perpendicular. I think that's normal? float dotProduct = (a.X * b.X) + (a.Y * b.Y) + (a.Z * b.Z); LLVector3 crossProduct = new LLVector3(); crossProduct.X = a.Y * b.Z - a.Z * b.Y; crossProduct.Y = a.Z * b.X - a.X * b.Z; crossProduct.Z = a.X * b.Y - a.Y * b.X; //float scalarProduct = (a.X * b.Y) + (a.Y * b.Z) + (a.Z * b.X); //not used? float magProduct = VecMag(a) * VecMag(b); double angle = Math.Acos(dotProduct / magProduct); LLVector3 axis = VecNorm(crossProduct); float s = (float)Math.Sin(angle / 2); return(new LLQuaternion(axis.X * s, axis.Y * s, axis.Z * s, (float)Math.Cos(angle / 2))); }
public PrimData(byte[] data) { int i =0; this.OwnerID = new LLUUID(data, i); i += 16; this.PCode = data[i++]; this.PathBegin = (ushort)(data[i++] + (data[i++] << 8)); this.PathEnd = (ushort)(data[i++] + (data[i++] << 8)); this.PathScaleX = data[i++]; this.PathScaleY = data[i++]; this.PathShearX = data[i++]; this.PathShearY = data[i++]; this.PathSkew = (sbyte)data[i++]; this.ProfileBegin = (ushort)(data[i++] + (data[i++] << 8)); this.ProfileEnd = (ushort)(data[i++] + (data[i++] << 8)); this.Scale = new LLVector3(data, i); i += 12; this.PathCurve = data[i++]; this.ProfileCurve = data[i++]; this.ParentID = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24)); this.ProfileHollow = (ushort)(data[i++] + (data[i++] << 8)); this.PathRadiusOffset = (sbyte)data[i++]; this.PathRevolutions = data[i++]; this.PathTaperX = (sbyte)data[i++]; this.PathTaperY =(sbyte) data[i++]; this.PathTwist = (sbyte) data[i++]; this.PathTwistBegin = (sbyte) data[i++]; ushort length = (ushort)(data[i++] + (data[i++] << 8)); this.Texture = new byte[length]; Array.Copy(data, i, Texture, 0, length); i += length; this.CreationDate = (Int32)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24)); this.OwnerMask = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24)); this.NextOwnerMask = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24)); this.GroupMask = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24)); this.EveryoneMask = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24)); this.BaseMask = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24)); this.Position = new LLVector3(data, i); i += 12; this.Rotation = new LLQuaternion(data,i, true); i += 12; this.LocalID = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24)); this.FullID = new LLUUID(data, i); i += 16; }
protected void doStuff(string sim, LLVector3 coords) { Client.Grid.OnRegionAdd += new GridRegionCallback(GridRegionHandler); Console.WriteLine("Caching estate sims..."); Client.Grid.AddEstateSims(); System.Threading.Thread.Sleep(3000); if (RegionHandle == 0) { Client.Grid.BeginGetGridRegion(sim, new GridRegionCallback(GridRegionHandler)); int start = Environment.TickCount; while (RegionHandle == 0) { Client.Tick(); if (Environment.TickCount - start > 10000) { Console.WriteLine("Region handle lookup failed"); Disconnect(); return; } } } Client.Self.OnTeleport += new TeleportCallback(Avatar_OnTeleportMessage); DoneTeleporting = false; Client.Self.Teleport(RegionHandle, coords); while (!DoneTeleporting) { Client.Tick(); } }
/// <summary> /// Rez an object from inventory /// </summary> /// <param name="simulator">Simulator to place object in</param> /// <param name="rotation">Rotation of the object when rezzed</param> /// <param name="position">Vector of where to place object</param> /// <param name="item">InventoryObject object containing item details</param> /// <param name="groupOwner">LLUUID of group to own the object</param> public LLUUID RequestRezFromInventory(Simulator simulator, LLQuaternion rotation, LLVector3 position, InventoryObject item, LLUUID groupOwner) { return RequestRezFromInventory(simulator, rotation, position, item, groupOwner, LLUUID.Random(), false); }
/// <summary> /// Rez an object from inventory /// </summary> /// <param name="simulator">Simulator to place object in</param> /// <param name="rotation">Rotation of the object when rezzed</param> /// <param name="position">Vector of where to place object</param> /// <param name="item">InventoryObject object containing item details</param> public LLUUID RequestRezFromInventory(Simulator simulator, LLQuaternion rotation, LLVector3 position, InventoryObject item) { return RequestRezFromInventory(simulator, rotation, position, item, _Client.Self.ActiveGroup, LLUUID.Random(), false); }
public int GetRectangularDeviation(LLVector3 aabbmin, LLVector3 aabbmax, int area) { int xlength = (int)(aabbmax.X - aabbmin.X); int ylength = (int)(aabbmax.Y - aabbmin.Y); int aabbarea = xlength * ylength; return (aabbarea - area) / 16; }
/// <summary> /// /// </summary> /// <param name="map"></param> /// <param name="localid"></param> /// <returns></returns> public WaterType GetWaterType(int[,] map, int localid) { if (!Client.Settings.STORE_LAND_PATCHES) { Client.Log("GetWaterType() will not work without Settings.STORE_LAND_PATCHES set to true", Helpers.LogLevel.Error); return WaterType.Unknown; } else if (!Client.Network.Connected && Client.Network.CurrentSim != null) { Client.Log("GetWaterType() can only be used with an online client", Helpers.LogLevel.Error); return WaterType.Unknown; } bool underwater = false; bool abovewater = false; for (int y = 0; y < 64; y++) { for (int x = 0; x < 64; x++) { if (map[y, x] == localid) { for (int y1 = 0; y1 < 4; y1++) { for (int x1 = 0; x1 < 4; x1++) { float height; int tries = 0; CheckHeight: tries++; if (Client.Terrain.TerrainHeightAtPoint(Client.Network.CurrentSim.Handle, x * 4 + x1, y * 4 + y1, out height)) { if (height < Client.Network.CurrentSim.WaterHeight) { underwater = true; } else { abovewater = true; } } else if (tries > 4) { Client.Log("Too many tries on this terrain block, skipping", Helpers.LogLevel.Warning); continue; } else { Client.Log(String.Format("Terrain height is null at {0},{1} retrying", x * 4 + x1, y * 4 + y1), Helpers.LogLevel.Info); // Terrain at this point hasn't been downloaded, move the camera to this spot // and try again LLVector3 position = new LLVector3((float)(x * 4 + x1), (float)(y * 4 + y1), Client.Self.SimPosition.Z); Client.Self.Movement.Camera.Position = position; Client.Self.Movement.SendUpdate(true); Thread.Sleep(1000); goto CheckHeight; } } } } } } if (underwater && abovewater) { return WaterType.Waterfront; } else if (abovewater) { return WaterType.Dry; } else if (underwater) { return WaterType.Underwater; } else { Client.Log("Error decoding terrain for parcel " + localid, Helpers.LogLevel.Error); return WaterType.Unknown; } }
/// <summary> /// /// </summary> /// <param name="map"></param> /// <param name="localid"></param> /// <returns></returns> public float GetHeightRange(int[,] map, int localid) { float min = Single.MaxValue; float max = 0.0f; for (int y = 0; y < 64; y++) { for (int x = 0; x < 64; x++) { if (map[y, x] == localid) { for (int y1 = 0; y1 < 4; y1++) { for (int x1 = 0; x1 < 4; x1++) { float height; int tries = 0; CheckHeight: if (Client.Terrain.TerrainHeightAtPoint(Client.Network.CurrentSim.Handle, x * 4 + x1, y * 4 + y1, out height)) { if (height < min) min = height; if (height > max) max = height; } else if (tries > 4) { Client.Log("Too many tries on this terrain block, skipping", Helpers.LogLevel.Warning); continue; } else { Client.Log(String.Format("Terrain height is null at {0},{1} retrying", x * 4 + x1, y * 4 + y1), Helpers.LogLevel.Info); // Terrain at this point hasn't been downloaded, move the camera to this spot // and try again LLVector3 position = new LLVector3((float)(x * 4 + x1), (float)(y * 4 + y1), Client.Self.SimPosition.Z); Client.Self.Movement.Camera.Position = position; Client.Self.Movement.SendUpdate(true); Thread.Sleep(1000); goto CheckHeight; } } } } } } if (min != Single.MaxValue) { return max - min; } else { Client.Log("Error decoding terrain for parcel " + localid, Helpers.LogLevel.Error); return Single.NaN; } }
public void StayInSim(ulong handle, LLVector3 desiredPosition) { SimHandle = handle; Position = desiredPosition; CheckTimer.Start(); }
/// <summary> /// Plays a sound in the specified sim /// </summary> /// <param name="soundID">UUID of the sound to be played.</param> /// <param name="sim">UUID of the sound to be played.</param> /// <param name="position">position for the sound to be played at. Normally the avatar.</param> /// <param name="gain">volume of the sound, from 0.0 to 1.0</param> public void SoundTrigger(LLUUID soundID, Simulator sim, LLVector3 position, float gain) { SoundTrigger(soundID, sim.Handle, position, 1.0f); }
private bool Inventory_OnInventoryObjectReceived(LLUUID fromAgentID, string fromAgentName, uint parentEstateID, LLUUID regionID, LLVector3 position, DateTime timestamp, AssetType type, LLUUID objectID, bool fromTask) { if (MasterKey != LLUUID.Zero) { if (fromAgentID != MasterKey) return false; } else if (GroupMembers != null && !GroupMembers.ContainsKey(fromAgentID)) { return false; } return true; }
// SayToUser: send a message to the user as in-world chat private static void SayToUser(string message) { Hashtable blocks = new Hashtable(); Hashtable fields; fields = new Hashtable(); fields["FromName"] = "Analyst"; fields["SourceID"] = new LLUUID(true); fields["OwnerID"] = agentID; fields["SourceType"] = (byte)2; fields["ChatType"] = (byte)1; fields["Audible"] = (byte)1; fields["Position"] = new LLVector3(0, 0, 0); fields["Message"] = message; blocks[fields] = "ChatData"; Packet packet = PacketBuilder.BuildPacket("ChatFromSimulator", protocolManager, blocks, Helpers.MSG_RELIABLE); proxy.InjectPacket(packet, Direction.Incoming); }
/// <summary> /// Plays a sound in the current region /// </summary> /// <param name="soundID">UUID of the sound to be played.</param> /// <param name="position">position for the sound to be played at. Normally the avatar.</param> /// <param name="gain">volume of the sound, from 0.0 to 1.0</param> public void SoundTrigger(LLUUID soundID, LLVector3 position, float gain) { SoundTrigger(soundID, Client.Network.CurrentSim.Handle, position, 1.0f); }
/// <summary> /// Plays a sound in the current region at full volume /// </summary> /// <param name="soundID">UUID of the sound to be played.</param> /// <param name="position">position for the sound to be played at. Normally the avatar.</param> public void SoundTrigger(LLUUID soundID, LLVector3 position) { SoundTrigger(soundID, Client.Self.SimPosition, 1.0f); }
/// <summary> /// Rez an object from inventory /// </summary> /// <param name="simulator">Simulator to place object in</param> /// <param name="rotation">Rotation of the object when rezzed</param> /// <param name="position">Vector of where to place object</param> /// <param name="item">InventoryObject object containing item details</param> /// <param name="groupOwner">LLUUID of group to own the object</param> /// <param name="queryID">User defined queryID to correlate replies</param> /// <param name="requestObjectDetails">if set to true the simulator /// will automatically send object detail packet(s) back to the client</param> public LLUUID RequestRezFromInventory(Simulator simulator, LLQuaternion rotation, LLVector3 position, InventoryObject item, LLUUID groupOwner, LLUUID queryID, bool requestObjectDetails) { RezObjectPacket add = new RezObjectPacket(); add.AgentData.AgentID = _Client.Self.AgentID; add.AgentData.SessionID = _Client.Self.SessionID; add.AgentData.GroupID = groupOwner; add.RezData.FromTaskID = LLUUID.Zero; add.RezData.BypassRaycast = 1; add.RezData.RayStart = position; add.RezData.RayEnd = position; add.RezData.RayTargetID = LLUUID.Zero; add.RezData.RayEndIsIntersection = false; add.RezData.RezSelected = requestObjectDetails; add.RezData.RemoveItem = false; add.RezData.ItemFlags = item.Flags; add.RezData.GroupMask = (uint)item.Permissions.GroupMask; add.RezData.EveryoneMask = (uint)item.Permissions.EveryoneMask; add.RezData.NextOwnerMask = (uint)item.Permissions.NextOwnerMask; add.InventoryData.ItemID = item.UUID; add.InventoryData.FolderID = item.ParentUUID; add.InventoryData.CreatorID = item.CreatorID; add.InventoryData.OwnerID = item.OwnerID; add.InventoryData.GroupID = item.GroupID; add.InventoryData.BaseMask = (uint)item.Permissions.BaseMask; add.InventoryData.OwnerMask = (uint)item.Permissions.OwnerMask; add.InventoryData.GroupMask = (uint)item.Permissions.GroupMask; add.InventoryData.EveryoneMask = (uint)item.Permissions.EveryoneMask; add.InventoryData.NextOwnerMask = (uint)item.Permissions.NextOwnerMask; add.InventoryData.GroupOwned = item.GroupOwned; add.InventoryData.TransactionID = queryID; add.InventoryData.Type = (sbyte)item.InventoryType; add.InventoryData.InvType = (sbyte)item.InventoryType; add.InventoryData.Flags = item.Flags; add.InventoryData.SaleType = (byte)item.SaleType; add.InventoryData.SalePrice = item.SalePrice; add.InventoryData.Name = Helpers.StringToField(item.Name); add.InventoryData.Description = Helpers.StringToField(item.Description); add.InventoryData.CreationDate = (int)Helpers.DateTimeToUnixTime(item.CreationDate); _Client.Network.SendPacket(add, simulator); return queryID; }
/// <summary> /// Plays a sound /// </summary> /// <param name="soundID">UUID of the sound to be played.</param> /// <param name="handle">handle id for the sim to be played in.</param> /// <param name="position">position for the sound to be played at. Normally the avatar.</param> /// <param name="gain">volume of the sound, from 0.0 to 1.0</param> public void SoundTrigger(LLUUID soundID, ulong handle , LLVector3 position, float gain) { SoundTriggerPacket soundtrigger = new SoundTriggerPacket(); soundtrigger.SoundData = new SoundTriggerPacket.SoundDataBlock(); soundtrigger.SoundData.SoundID = soundID; soundtrigger.SoundData.ObjectID = LLUUID.Zero; soundtrigger.SoundData.OwnerID = LLUUID.Zero; soundtrigger.SoundData.ParentID = LLUUID.Zero; soundtrigger.SoundData.Handle = handle; soundtrigger.SoundData.Position = position; soundtrigger.SoundData.Gain = gain; Client.Network.SendPacket(soundtrigger); }
private void Network_OnLoginResponse(bool loginSuccess, bool redirect, string message, string reason, LoginResponseData reply) { id = reply.AgentID; sessionID = reply.SessionID; secureSessionID = reply.SecureSessionID; firstName = reply.FirstName; lastName = reply.LastName; startLocation = reply.StartLocation; agentAccess = reply.AgentAccess; Movement.Camera.LookDirection(reply.LookAt); homePosition = reply.HomePosition; homeLookAt = reply.HomeLookAt; }