Exemplo n.º 1
0
        public META3D(METAboltInstance instance, ObjectsListItem obtectitem)
        {
            InitializeComponent();

            SetExceptionReporter();
            Application.ThreadException += new ThreadExceptionHandler().ApplicationThreadException;

            Disposed += new EventHandler(META3D_Disposed);

            this.RootPrimLocalID = obtectitem.Prim.LocalID;

            selitem = obtectitem.Prim;

            string msg1 = "Drag (left mouse down) to rotate object\n" +
                            "ALT+Drag to Zoom\n" +
                            "Ctrl+Drag to Pan\n" +
                            "Wheel in/out to Zoom in/out\n\n" +
                            "Click camera then object for snapshot";

            toolTip = new Popup(customToolTip = new CustomToolTip(instance, msg1));
            toolTip.AutoClose = false;
            toolTip.FocusOnOpen = false;
            toolTip.ShowingAnimation = toolTip.HidingAnimation = PopupAnimations.Blend;

            UseMultiSampling = false;

            this.instance = instance;
            client = this.instance.Client;
            //netcom = this.instance.Netcom;
            isobject = true;
            this.objectitem = obtectitem;

            TexturePointers[0] = 0;

            renderer = new MeshmerizerR();
            textRendering = new TextRendering(instance);

            client.Objects.TerseObjectUpdate += new EventHandler<TerseObjectUpdateEventArgs>(Objects_TerseObjectUpdate);
            client.Objects.ObjectUpdate += new EventHandler<PrimEventArgs>(Objects_ObjectUpdate);
            client.Objects.ObjectDataBlockUpdate += new EventHandler<ObjectDataBlockUpdateEventArgs>(Objects_ObjectDataBlockUpdate);
            client.Network.SimChanged += new EventHandler<SimChangedEventArgs>(SIM_OnSimChanged);
            client.Self.TeleportProgress += new EventHandler<TeleportEventArgs>(Self_TeleportProgress);
        }
Exemplo n.º 2
0
        //private void DisplayObjects()
        //{
        //    if (eventsremoved) AddObjectEvents();
        //    lbxPrims.Items.Clear();
        //    try
        //    {
        //        Vector3 location = instance.SIMsittingPos();
        //        pBar3.Visible = true;
        //        pB1.Visible = true;
        //        pB1.Value = 0;
        //        pB1.Maximum = ItemsProps.Count;
        //        lock (ItemsProps)
        //        {
        //            //Vector3 location = instance.SIMsittingPos();
        //            foreach (KeyValuePair<uint, ObjectsListItem> entry in ItemsProps)
        //            {
        //                ObjectsListItem item = entry.Value;
        //                if (item.Prim.ParentID == 0) //root prims only
        //                {
        //                    Vector3 pos = item.Prim.Position;
        //                    if (Vector3.Distance(location,pos) < range)
        //                    {
        //                        lock (lbxPrims.Items)
        //                        {
        //                            lbxPrims.BeginUpdate();
        //                            lbxPrims.Items.Add(item);
        //                            lbxPrims.EndUpdate();
        //                        }
        //                    }
        //                }
        //                if (pB1.Value < ItemsProps.Count) pB1.Value += 1;
        //            }
        //        }
        //        pB1.Visible = false;
        //        pBar3.Visible = false;
        //        //lblStatus.Visible = true;
        //        //lbxPrims.SortList();
        //        //lblStatus.Visible = false;
        //        //lbxPrims.Visible = true;
        //        //lbxChildren.Visible = true;
        //        txtSearch.Enabled = true;
        //        //tlbStatus.Text = listItems.Count.ToString() + " objects";
        //        tlbDisplay.Text = lbxPrims.Items.Count.ToString(CultureInfo.CurrentCulture) + " objects";
        //    }
        //    catch (Exception ex)
        //    {
        //        //string exp = exc.Message;
        //        reporter.Show(ex);
        //    }
        //}
        private void SearchFor(string text)
        {
            RemoveObjectEvents();

            lbxPrims.Items.Clear();
            pB1.Visible = true;

            string query = text.ToLower(CultureInfo.CurrentCulture);
            //bool inmem = false;

            List<Primitive> results =
                client.Network.CurrentSim.ObjectsPrimitives.FindAll(
                new Predicate<Primitive>(delegate(Primitive prim)
                {
                    try
                    {
                        //evil comparison of death!
                        return (prim.ParentID == 0 && prim.Properties != null) &&
                            (prim.Properties.Name.ToLower(CultureInfo.CurrentCulture).Contains(query) ||
                            prim.Properties.Description.ToLower(CultureInfo.CurrentCulture).Contains(query) ||
                            prim.Properties.OwnerID.ToString().ToLower(CultureInfo.CurrentCulture).Contains(query) ||
                            prim.Text.ToLower(CultureInfo.CurrentCulture).Contains(query) ||
                            prim.ID.ToString().ToLower(CultureInfo.CurrentCulture).Contains(query) ||
                            prim.Properties.CreatorID.ToString().ToLower(CultureInfo.CurrentCulture).Contains(query));
                    }
                    catch
                    {
                        return false;
                    }
                }));

            pB1.Maximum = results.Count;

            lock (listItems)
            {
                foreach (Primitive prim in results)
                {
                    try
                    {
                        ObjectsListItem item = new ObjectsListItem(prim, client, lbxPrims);

                        if (!listItems.ContainsKey(prim.LocalID))
                        {
                            listItems.Add(prim.LocalID, item);

                            item.PropertiesReceived += new EventHandler(item_PropertiesReceived);
                            item.RequestProperties();
                            //inmem = true;
                        }
                        else
                        {
                            if (pB1.Value < results.Count) pB1.Value += 1;

                            lock (lbxPrims.Items)
                            {
                                lbxPrims.BeginUpdate();
                                lbxPrims.Items.Remove(item);
                                lbxPrims.Items.Add(item);
                                lbxPrims.EndUpdate();
                            }
                        }
                    }
                    catch
                    {
                        ;
                    }
                }
            }

            //if (!inmem)
            //{
                pB1.Value = 0;
                pB1.Visible = false;
                lbxPrims.SortList();
            //}

            //tlbStatus.Text = listItems.Count.ToString() + " objects";
            tlbDisplay.Text = lbxPrims.Items.Count.ToString(CultureInfo.CurrentCulture) + " objects";
        }
Exemplo n.º 3
0
        private void DisplaySelected()
        {
            try
            {
                lbxTask.Items.Clear();

                button6.Enabled = groupBox1.Enabled = gbxInworld.Enabled = (lbxPrims.SelectedItem != null);

                int iDx = lbxPrims.SelectedIndex;

                if (iDx < 0)
                {
                    //btnTP.Enabled = false;
                    return;
                }

                ObjectsListItem item = (ObjectsListItem)lbxPrims.Items[iDx];

                Primitive sPr = new Primitive();
                sPr = item.Prim;

                if (sPr.Properties == null)
                {
                    //client.Objects.SelectObject(client.Network.CurrentSim, sPr.LocalID);
                    client.Objects.SelectObject(client.Network.CurrentSim, sPr.LocalID, true);
                    //client.Objects.RequestObject(client.Network.CurrentSim, sPr.LocalID);
                    return;
                }

                //btnTP.Enabled = true;

                lblOwner.Text = sPr.Properties.OwnerID.ToString();
                lblUUID.Text = sPr.Properties.ObjectID.ToString();

                if (instance.State.SitPrim != UUID.Zero)
                {
                    if (sPr.ID == instance.State.SitPrim)
                    {
                        btnSitOn.Text = "&Stand";
                    }
                    else
                    {
                        btnSitOn.Text = "&Sit";
                    }
                }
                else
                {
                    btnSitOn.Text = "&Sit";
                }

                // Get the owner name
                UUID lookup = sPr.Properties.OwnerID;
                if (!instance.avnames.ContainsKey(lookup))
                {
                    client.Avatars.RequestAvatarName(lookup);
                    pictureBox1.Cursor = Cursors.Default;
                }
                else
                {
                    label9.Text = instance.avnames[lookup];
                    pictureBox1.Enabled = true;
                    pictureBox1.Cursor = Cursors.Hand;
                }

                txtCreator.Text = "??? (click on selected object)";

                lookup = sPr.Properties.CreatorID;

                if (lookup != UUID.Zero)
                {
                    if (!instance.avnames.ContainsKey(lookup))
                    {
                        client.Avatars.RequestAvatarName(lookup);
                        pictureBox2.Cursor = Cursors.Default;
                    }
                    else
                    {
                        txtCreator.Text = instance.avnames[lookup];
                        pictureBox2.Enabled = true;
                        pictureBox2.Cursor = Cursors.Hand;
                    }

                    label21.Text = sPr.Properties.CreatorID.ToString();
                }
                else
                {
                    pictureBox2.Enabled = false;
                    pictureBox2.Cursor = Cursors.Default;
                }

                btnReturn.Enabled = btnTake.Enabled = true;

                PermissionMask sPerm = sPr.Properties.Permissions.NextOwnerMask;
                PermissionMask sOPerm = sPr.Properties.Permissions.OwnerMask;

                string sEp = sPerm.ToString();
                string sOEp = sOPerm.ToString();

                if (sPr.Properties.SaleType != 0)
                {
                    label3.Text = "L$" + sPr.Properties.SalePrice.ToString(CultureInfo.CurrentCulture);
                }
                else
                {
                    label3.Text = "Not for sale";
                }

                label11.Text = sPr.Text;
                textBox2.Text = sPr.Properties.Name;
                label15.Text = sPr.Properties.Description;

                Vector3 primpos = new Vector3(Vector3.Zero);
                primpos = sPr.Position;
                //// Calculate the distance here in metres
                //int pX = (int)primpos.X;
                //int pY = (int)primpos.Y;
                //int pZ = (int)primpos.Z;

                //int sX = (int)client.Self.SimPosition.X;
                //int sY = (int)client.Self.SimPosition.Y;
                //int sZ = (int)client.Self.SimPosition.Z;

                int vZ = (int)primpos.Z - (int)instance.SIMsittingPos().Z;

                //int vX = sX - pX;
                //int vY = sY - pY;

                //int pX2 = vX * vX;
                //int pY2 = vY * vY;
                //int h2 = pX2 + pY2;

                //int hyp1 = (int)Math.Sqrt(h2);
                //int hyp = instance.Distance3D(sX, sY, sZ, pX, pY, pZ);

                double dist = Math.Round(Vector3.Distance(instance.SIMsittingPos(), primpos), MidpointRounding.ToEven);

                label13.Text = " " + dist.ToString(CultureInfo.CurrentCulture) + "m - [ Elev.:" + vZ.ToString(CultureInfo.CurrentCulture) + "m]";

                label5.Text = "L$" + sPr.Properties.OwnershipCost.ToString(CultureInfo.CurrentCulture);
                //label3.Text = sPr.Properties.SaleType.ToString();

                // Owner perms
                if (sOEp.Contains("Modify"))
                {
                    checkBox6.Checked = true;
                }
                else
                {
                    checkBox6.Checked = false;
                }

                if (sOEp.Contains("Copy"))
                {
                    checkBox5.Checked = true;
                }
                else
                {
                    checkBox5.Checked = false;
                }

                if (sOEp.Contains("Transfer"))
                {
                    checkBox4.Checked = true;
                }
                else
                {
                    checkBox4.Checked = false;
                }

                // Next Owner perms
                if (sEp.Contains("Modify"))
                {
                    checkBox1.Checked = true;
                }
                else
                {
                    checkBox1.Checked = false;
                }

                if (sEp.Contains("Copy"))
                {
                    checkBox2.Checked = true;
                }
                else
                {
                    checkBox2.Checked = false;
                }

                if (sEp.Contains("Transfer"))
                {
                    checkBox3.Checked = true;
                }
                else
                {
                    checkBox3.Checked = false;
                }

                //if (btnTP.Enabled)
                //    btnTP.Enabled = false;

                lkLocation.Text = "";

                //sPr.Flags = LLObject.ObjectFlags.Scripted;
                //client.Objects.RequestObject("", sPr.LocalID);
                //client.Objects.SelectObject();

                pBar1.Visible = true;
                pBar1.Refresh();

                label22.Text = "Local ID: " + sPr.LocalID.ToString(CultureInfo.CurrentCulture);

                // Populate child items here
                lbxChildren.BeginUpdate();
                lbxChildren.Items.Clear();

                button3.Visible = button7.Visible = false;

                List<Primitive> results = client.Network.CurrentSim.ObjectsPrimitives.FindAll(
                    delegate(Primitive prim)
                    {
                        return (prim.ParentID == sPr.LocalID);
                    }
                );

                if (results != null && results.Count > 0)
                {
                    foreach (var prim in results)
                    {
                        ObjectsListItem citem = new ObjectsListItem(prim, client, lbxChildren);

                        if (!childItems.ContainsKey(prim.LocalID))
                        {
                            childItems.Add(prim.LocalID, citem);
                        }
                    }
                }

                foreach (KeyValuePair<uint, ObjectsListItem> kvp in childItems)
                {
                    if (sPr.LocalID == kvp.Value.Prim.ParentID)
                    {
                        //ObjectsListItem citem = new ObjectsListItem(kvp.Value.Prim, client, lbxChildren);
                        //sPr.
                        //citem.PropertiesReceived += new EventHandler(citem_PropertiesReceived);
                        //citem.RequestProperties();
                        lbxChildren.Items.Add(kvp.Value);
                    }
                }

                lbxChildren.EndUpdate();
                pBar1.Visible = false;

                SetPerm(sPr);

                //if (sPr.Properties.OwnerID != client.Self.AgentID)
                //{
                //    //checkBox1.Enabled = checkBox2.Enabled = checkBox3.Enabled = label11.Enabled = label15.Enabled = textBox2.Enabled = false;
                //    label11.Enabled = label15.Enabled = textBox2.Enabled = false;
                //}
                //else
                //{
                //    //checkBox1.Enabled = checkBox2.Enabled = checkBox3.Enabled = label11.Enabled = label15.Enabled = textBox2.Enabled = true;
                //    label11.Enabled = label15.Enabled = textBox2.Enabled = true;
                //}

                sloading = false;
            }
            catch (Exception ex)
            {
                Logger.Log(ex.Message, Helpers.LogLevel.Error);
            }

            string msg1 = label11.Text;
            toolTip = new Popup(customToolTip = new CustomToolTip(instance, msg1));
            toolTip.AutoClose = false;
            toolTip.FocusOnOpen = false;
            toolTip.ShowingAnimation = toolTip.HidingAnimation = PopupAnimations.Blend;

            lbxPrims.SelectedItem = lbxPrims.SelectedItem;
            lbxPrims.Select();
        }
Exemplo n.º 4
0
        //Separate thread
        private void Objects_OnNewPrim(object sender, PrimEventArgs e)
        {
            //if (!this.IsHandleCreated) return;

            if (e.Simulator.Handle != client.Network.CurrentSim.Handle || e.Prim.Position == Vector3.Zero || e.Prim is Avatar) return;

            try
            {
                if (e.Prim.ParentID != 0)
                {
                    lock (childItems)
                    {
                        ObjectsListItem citem = new ObjectsListItem(e.Prim, client, lbxChildren);

                        if (!childItems.ContainsKey(e.Prim.LocalID))
                        {
                            try
                            {
                                childItems.Add(e.Prim.LocalID, citem);
                            }
                            catch
                            {
                                ;
                            }
                        }
                    }
                }
                else
                {
                    BeginInvoke(new MethodInvoker(delegate()
                            {
                                lock (listItems)
                                {
                                    ObjectsListItem item = new ObjectsListItem(e.Prim, client, lbxPrims);

                                    Vector3 location = new Vector3(Vector3.Zero);
                                    location = instance.SIMsittingPos();
                                    Vector3 pos = new Vector3(Vector3.Zero);
                                    pos = item.Prim.Position;

                                    float dist = Vector3.Distance(location, pos);

                                    if (dist < range)
                                    {
                                        try
                                        {
                                            if (!listItems.ContainsKey(e.Prim.LocalID))
                                            {
                                                listItems.Add(e.Prim.LocalID, item);

                                                item.PropertiesReceived += new EventHandler(iitem_PropertiesReceived);
                                                item.RequestProperties();
                                            }
                                            //else
                                            //{
                                            //    listItems.Remove(e.Prim.LocalID);
                                            //    listItems.Add(e.Prim.LocalID, item);

                                            //    lock (lbxPrims.Items)
                                            //    {
                                            //        lbxPrims.BeginUpdate();

                                            //        if (lbxPrims.Items.Contains(item))
                                            //        {
                                            //            lbxPrims.Items.Remove(item);
                                            //        }

                                            //        lbxPrims.Items.Add(item);
                                            //        lbxPrims.EndUpdate();
                                            //    }

                                            //    lbxPrims.SortList();
                                            //}
                                        }
                                        catch
                                        {
                                            ;
                                        }

                                        //BeginInvoke(new MethodInvoker(delegate()
                                        //{
                                        //    pB1.Maximum += 1;
                                        //}));
                                    }
                                }
                            }));
                }
            }
            catch
            {
                ;
            }
        }
Exemplo n.º 5
0
        private void AddAllObjects()
        {
            if (InvokeRequired)
            {
                BeginInvoke(new MethodInvoker(delegate()
                {
                    AddAllObjects();
                }));
            }

            //pB1.Maximum = 0;

            if (eventsremoved) AddObjectEvents();

            Cursor.Current = Cursors.WaitCursor;

            pB1.Visible = true;
            //bool inmem = false;

            lbxPrims.location = instance.SIMsittingPos();
            lbxPrims.SortByName = false;
            //pBar3.Visible = true;
            //lbxPrims.SortList();
            //pBar3.Visible = false;

            //int ocnt = 1;

            try
            {
                lock (listItems)
                {
                    Vector3 location = new Vector3(Vector3.Zero);
                    location = instance.SIMsittingPos();

                client.Network.CurrentSim.ObjectsPrimitives.ForEach(
                new Action<Primitive>(
                delegate(Primitive prim)
                {
                    Vector3 pos = new Vector3(Vector3.Zero);
                    pos = prim.Position;

                    float dist = Vector3.Distance(location, pos);

                    //// Work around for the Magnum problem
                    //if (ocnt < 4)
                    //{
                    //    //instance.State.SetPointing(true, prim.ID);
                    //    //instance.State.SetPointing(false, prim.ID);

                    //    Vector3 target = new Vector3(Vector3.Zero);
                    //    target = prim.Position; // the object to look at

                    //    client.Self.Movement.TurnToward(target);

                    //    ocnt += 1;
                    //}

                    if (((int)dist < (int)range) && (prim.Position != Vector3.Zero))
                    {
                        ObjectsListItem item = new ObjectsListItem(prim, client, lbxPrims);

                        if (prim.ParentID == 0) //root prims only
                        {
                            if (!listItems.ContainsKey(prim.LocalID))
                            {
                                lock (listItems)
                                {
                                    listItems.Add(prim.LocalID, item);

                                    item.PropertiesReceived += new EventHandler(iitem_PropertiesReceived);
                                    item.RequestProperties();
                                    //inmem = true;
                                }

                                //pB1.Maximum += 1;
                            }
                            else
                            {
                                lock (listItems)
                                {
                                    listItems.Remove(prim.LocalID);
                                    listItems.Add(prim.LocalID, item);

                                    lock (lbxPrims.Items)
                                    {
                                        lbxPrims.BeginUpdate();
                                        lbxPrims.Items.Remove(item);
                                        lbxPrims.Items.Add(item);
                                        lbxPrims.EndUpdate();
                                    }
                                }
                            }
                        }
                        else
                        {
                            ObjectsListItem citem = new ObjectsListItem(prim, client, lbxChildren);

                            if (!childItems.ContainsKey(prim.LocalID))
                            {
                                lock (childItems)
                                {
                                    childItems.Add(prim.LocalID, citem);
                                }
                            }
                            else
                            {
                                lock (childItems)
                                {
                                    childItems.Remove(prim.LocalID);
                                    childItems.Add(prim.LocalID, citem);
                                }
                            }
                        }
                    }
                }));
                }

                //if (!inmem)
                //{
                    //pB1.Value = 0;
                    //pB1.Visible = false;
                    groupBox2.Enabled = true;
                    groupBox3.Enabled = true;
                    //lbxPrims.SortList();
                //}

                lblStatus.Visible = false;
                lbxPrims.Visible = true;
                lbxChildren.Visible = true;
                txtSearch.Enabled = true;

                //lbxPrims.SortList();

                pB1.Visible = false;

                //tlbStatus.Text = listItems.Count.ToString() + " objects";
                tlbDisplay.Text = lbxPrims.Items.Count.ToString(CultureInfo.CurrentCulture) + " objects";
            }
            catch (Exception ex)
            {
                //string exp = exc.Message;
                reporter.Show(ex);
            }

            Cursor.Current = Cursors.Default;
        }