public Primitive AddTempPrim(SimRegion R, string name, PrimType primType, Vector3 scale, Vector3 loc) { Primitive.ConstructionData CD = ObjectManager.BuildBasicShape(primType); CD.Material = Material.Light; CD.ProfileHole = HoleType.Triangle; bool success = false; Simulator simulator = R.TheSimulator; Primitive newPrim = null; // Register a handler for the creation event AutoResetEvent creationEvent = new AutoResetEvent(false); Quaternion rot = Quaternion.Identity; EventHandler<PrimEventArgs> callback = (s,e)=>//delegate(Simulator simulator0, Primitive prim, ulong regionHandle, ushort timeDilation) { var regionHandle = e.Simulator.Handle; var prim = e.Prim; if (regionHandle != R.RegionHandle) return; if ((loc - prim.Position).Length() > 3) { Debug("Not the prim " + (loc - prim.Position).Length()); return; } if (prim.PrimData.ProfileHole != HoleType.Triangle) { Debug("Not the prim? prim.PrimData.ProfileHole != HoleType.Triangle: {0}!={1}", prim.PrimData.ProfileHole, HoleType.Triangle); // return; // } if (Material.Light != prim.PrimData.Material) { Debug("Not the prim? Material.Light != prim.PrimData.Material: {0}!={1}", Material.Light, prim.PrimData.Material); // return; } if ((prim.Flags & PrimFlags.CreateSelected) == 0) { Debug("Not the prim? (prim.Flags & PrimFlags.CreateSelected) == 0) was {0}", prim.Flags); // return; } if (primType != prim.Type) { Debug("Not the prim? Material.Light != prim.PrimData.Material: {0}!={1}", Material.Light, prim.PrimData.Material); // return; } //if (prim.Scale != scale) return; // if (prim.Rotation != rot) return; // if (Material.Light != prim.PrimData.Material) return; //if (CD != prim.PrimData) return; newPrim = prim; creationEvent.Set(); }; client.Objects.ObjectUpdate += callback; // Start the creation setting process (with baking enabled or disabled) client.Objects.AddPrim(simulator, CD, UUID.Zero, loc, scale, rot, PrimFlags.CreateSelected | PrimFlags.Phantom | PrimFlags.Temporary); // Wait for the process to complete or time out if (creationEvent.WaitOne(1000 * 120, false)) success = true; // Unregister the handler client.Objects.ObjectUpdate -= callback; // Return success or failure message if (!success) { Debug("Timeout on new prim " + name); return null; } uint LocalID = newPrim.LocalID; client.Objects.SetName(simulator, LocalID, name); client.Objects.SetPosition(simulator, LocalID, loc); client.Objects.SetScale(simulator, LocalID, scale, true, true); client.Objects.SetRotation(simulator, LocalID, rot); client.Objects.SetFlags(simulator, LocalID, false, true, true, false); return newPrim; }
public override bool TeleportTo(SimRegion R, Vector3 local) { if (!IsControllable) { throw Error("GotoTarget !Client.Self.AgentID == Prim.ID"); } SimPosition pos = R.GetWaypointOf(local); Vector3d global = pos.GlobalPosition; StopMovingReal(); return Client.Self.Teleport(R.RegionHandle, local, local); //CmdResult s = Client.ExecuteCommand("teleport " + R.RegionName + "/" + local.X + "/" + local.Y + "/" + local.Z, Debug); //return s.Success; // Client.Self.Teleport(R.RegionName, local); }
private static void SetRegion(ulong h, SimRegion value) { if (_CurrentRegions.ContainsKey(h)) { SimRegion OLD = _CurrentRegions[h]; if (OLD == null || OLD == value) return; throw new ArgumentException("Bad region change " + OLD + " -> " + value); } _CurrentRegions[h] = value; }
public void SetRegionOffset(Vector2 v2, SimRegion value) { SetRegion(HandleOf(GetGridLocation() + v2), value); }
public static SimRegion GetRegion(ulong id, GridClient bc) { if (id == 0) { //throw new ArgumentException("GetRegion: region handle cant be zero"); } lock (_CurrentRegions) { SimRegion R; if (_CurrentRegions.TryGetValue(id, out R)) return R; if (_CurrentRegions.Count > 10) { // return null; } R = new SimRegion(id, bc); R.PathStore.SetGroundLevel(R.GetGroundLevel); _CurrentRegions[id] = R; return R; } }
public static void GetRegionAndLocal(Vector3d vector3D, out SimRegion region, out Vector3 local) { local = GlobalToLocalStatic(vector3D); region = GetRegion(vector3D); }