Пример #1
0
        public void PathBegin()
        {
            for (byte i = 0; i < byte.MaxValue; i++)
            {
                float floatValue = PrimObject.PathBeginFloat(i);
                byte  result     = PrimObject.PathBeginByte(floatValue);

                Assert.IsTrue(result == i, "Started with " + i + ", float value was " + floatValue +
                              ", and ended up with " + result);
            }
        }
Пример #2
0
        private void cmdImport_Click(object sender, System.EventArgs e)
        {
            OpenFileDialog openDialog = new OpenFileDialog();

            openDialog.Title       = "Open Prim.Blender File";
            openDialog.Filter      = "All files (*.*)|*.*|Prim files (*.prims)|*.prims";
            openDialog.FilterIndex = 2;

            if (openDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            XmlDocument xml  = new XmlDocument();
            XmlNodeList list = null;

            try
            {
                // Try to load the xml file
                xml.Load(openDialog.FileName);

                //If there is a document and it has children,
                if (xml != null && xml.HasChildNodes)
                {
                    //Get the children into the temp list
                    list = xml.GetElementsByTagName("primitive");
                }
                else
                {
                    txtLog.AppendText("ERROR: Failed to parse " + openDialog.FileName + "\n");
                    return;
                }
            }
            catch (Exception err)
            {
                txtLog.AppendText("ERROR: " + err.ToString() + "\n");
                return;
            }

            foreach (XmlNode node in list)
            {
                txtLog.AppendText("Parsing primitive " + node.Attributes["key"].Value + "\n");

                XmlNode properties = node["properties"];

                PrimObject prim = new PrimObject(new LLUUID("8955674724cb43ed920b47caed15465f"));

                prim.Material = Convert.ToUInt16(properties["material"].Attributes["val"].Value);
                prim.Name     = node.Attributes["key"].Value;
                // Either PathBegin/End or ProfileBegin/End should be dimple
                prim.PathBegin        = PrimObject.PathBeginByte(Convert.ToSingle(properties["cut"].Attributes["x"].Value));
                prim.PathEnd          = PrimObject.PathEndByte(Convert.ToSingle(properties["cut"].Attributes["y"].Value));
                prim.PathRadiusOffset = PrimObject.PathRadiusOffsetByte(Convert.ToSingle(properties["radiusoffset"].Attributes["val"].Value));
                prim.PathRevolutions  = PrimObject.PathRevolutionsByte(Convert.ToSingle(properties["revolutions"].Attributes["val"].Value));
                prim.PathScaleX       = PrimObject.PathScaleByte(Convert.ToSingle(properties["topsize"].Attributes["x"].Value));
                prim.PathScaleY       = PrimObject.PathScaleByte(Convert.ToSingle(properties["topsize"].Attributes["y"].Value));
                prim.PathShearX       = PrimObject.PathShearByte(Convert.ToSingle(properties["topshear"].Attributes["x"].Value));
                prim.PathShearY       = PrimObject.PathShearByte(Convert.ToSingle(properties["topshear"].Attributes["y"].Value));
                prim.PathSkew         = PrimObject.PathSkewByte(Convert.ToSingle(properties["skew"].Attributes["val"].Value));
                prim.PathTaperX       = PrimObject.PathTaperByte(Convert.ToSingle(properties["taper"].Attributes["x"].Value));
                prim.PathTaperY       = PrimObject.PathTaperByte(Convert.ToSingle(properties["taper"].Attributes["y"].Value));
                prim.PathTwist        = PrimObject.PathTwistByte(Convert.ToSingle(properties["twist"].Attributes["y"].Value));
                prim.PathTwistBegin   = PrimObject.PathTwistByte(Convert.ToSingle(properties["twist"].Attributes["x"].Value));
                prim.ProfileBegin     = PrimObject.ProfileBeginByte(Convert.ToSingle(properties["cut"].Attributes["x"].Value));
                prim.ProfileEnd       = PrimObject.ProfileEndByte(Convert.ToSingle(properties["cut"].Attributes["y"].Value));
                ushort curve = Convert.ToUInt16(properties["type"].Attributes["val"].Value);
                switch (curve)
                {
                case 0:
                    // Box
                    prim.ProfileCurve = 1;
                    prim.PathCurve    = 16;
                    break;

                case 1:
                    // Cylinder
                    prim.ProfileCurve = 0;
                    prim.PathCurve    = 16;
                    break;

                case 2:
                    // Prism
                    prim.ProfileCurve = 3;
                    prim.PathCurve    = 16;
                    break;

                case 3:
                    // Sphere
                    prim.ProfileCurve = 5;
                    prim.PathCurve    = 32;
                    break;

                case 4:
                    // Torus
                    prim.ProfileCurve = 0;
                    prim.PathCurve    = 32;
                    break;

                case 5:
                    // Tube
                    prim.ProfileCurve = 1;
                    prim.PathCurve    = 32;
                    break;

                case 6:
                    // Ring
                    prim.ProfileCurve = 3;
                    prim.PathCurve    = 16;
                    break;
                }
                prim.ProfileHollow = Convert.ToUInt32(properties["hollow"].Attributes["val"].Value);
                prim.Rotation      = new LLQuaternion(
                    Convert.ToSingle(properties["rotation"].Attributes["x"].Value),
                    Convert.ToSingle(properties["rotation"].Attributes["y"].Value),
                    Convert.ToSingle(properties["rotation"].Attributes["z"].Value),
                    Convert.ToSingle(properties["rotation"].Attributes["s"].Value));
                prim.Scale = new LLVector3(
                    Convert.ToSingle(properties["size"].Attributes["x"].Value),
                    Convert.ToSingle(properties["size"].Attributes["y"].Value),
                    Convert.ToSingle(properties["size"].Attributes["z"].Value));

                LLVector3 position = new LLVector3(
                    Convert.ToSingle(properties["position"].Attributes["x"].Value) + (float)Client.Avatar.Position.X,
                    Convert.ToSingle(properties["position"].Attributes["y"].Value) + (float)Client.Avatar.Position.Y,
                    Convert.ToSingle(properties["position"].Attributes["z"].Value) + (float)Client.Avatar.Position.Z + 50.0F);
                prim.Position = position;

                CurrentPrim     = prim;
                WaitingOnUpdate = true;

                Client.CurrentRegion.RezObject(prim, position, new LLVector3(Client.Avatar.Position));

                while (WaitingOnUpdate)
                {
                    System.Threading.Thread.Sleep(100);
                    Application.DoEvents();
                }

                txtLog.AppendText("Rezzed primitive with UUID " + CurrentPrim.UUID + " and ID " + CurrentPrim.ID + " \n");

                Hashtable blocks = new Hashtable();
                Hashtable fields = new Hashtable();

                /*fields["ObjectLocalID"] = CurrentPrim.ID;
                 * blocks[fields] = "ObjectData";
                 *
                 * fields = new Hashtable();
                 *
                 * fields["AgentID"] = Client.Network.AgentID;
                 * blocks[fields] = "AgentData";
                 *
                 * Packet packet = PacketBuilder.BuildPacket("ObjectSelect", Client.Protocol, blocks, Helpers.MSG_RELIABLE);
                 * Client.Network.SendPacket(packet);
                 *
                 * System.Threading.Thread.Sleep(100);*/
                Packet packet;

                byte[] byteArray = new byte[12];
                Array.Copy(position.GetBytes(), byteArray, 12);

                fields["Data"]          = byteArray;
                fields["Type"]          = (byte)9;
                fields["ObjectLocalID"] = CurrentPrim.ID;
                blocks[fields]          = "ObjectData";

                fields = new Hashtable();

                fields["AgentID"] = Client.Network.AgentID;
                blocks[fields]    = "AgentData";

                packet = PacketBuilder.BuildPacket("MultipleObjectUpdate", Client.Protocol, blocks, Helpers.MSG_RELIABLE);
                Client.Network.SendPacket(packet);
                Client.Network.SendPacket(packet);
                Client.Network.SendPacket(packet);

                System.Threading.Thread.Sleep(500);
            }
        }