Ejemplo n.º 1
0
        private void cmdConnect_Click(object sender, System.EventArgs e)
        {
            if (cmdConnect.Text == "Connect")
            {
                cmdConnect.Text      = "Disconnect";
                txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = false;

                Dictionary <string, object> loginParams = NetworkManager.DefaultLoginValues(txtFirstName.Text,
                                                                                            txtLastName.Text, txtPassword.Text, "00:00:00:00:00:00", "last",
                                                                                            "Win", "0", "accountant", "*****@*****.**");

                if (client.Network.Login(loginParams))
                {
                    Random rand = new Random();

                    lblName.Text = client.Network.LoginValues["first_name"] + " " +
                                   client.Network.LoginValues["last_name"];

                    client.Self.SetHeightWidth((ushort)rand.Next(0, 65535), (ushort)rand.Next(0, 65535));

                    // AgentSetAppearance
                    AgentSetAppearancePacket appearance = new AgentSetAppearancePacket();
                    appearance.VisualParam = new AgentSetAppearancePacket.VisualParamBlock[218];
                    // Setup some random appearance values
                    for (int i = 0; i < 218; i++)
                    {
                        appearance.VisualParam[i]            = new AgentSetAppearancePacket.VisualParamBlock();
                        appearance.VisualParam[i].ParamValue = (byte)rand.Next(255);
                    }
                    appearance.AgentData.AgentID       = client.Network.AgentID;
                    appearance.AgentData.SessionID     = client.Network.SessionID;
                    appearance.AgentData.SerialNum     = 1;
                    appearance.AgentData.Size          = new LLVector3(0.45F, 0.6F, 1.831094F);
                    appearance.ObjectData.TextureEntry = new byte[0];

                    client.Network.SendPacket(appearance);

                    txtFind.Enabled     = cmdFind.Enabled = true;
                    txtTransfer.Enabled = cmdTransfer.Enabled = true;
                }
                else
                {
                    MessageBox.Show(this, "Error logging in: " + client.Network.LoginError);
                    cmdConnect.Text      = "Connect";
                    txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = true;
                    txtFind.Enabled      = cmdFind.Enabled = false;
                    lblName.Text         = lblBalance.Text = "";
                    txtTransfer.Enabled  = cmdTransfer.Enabled = false;
                }
            }
            else
            {
                client.Network.Logout();
                cmdConnect.Text      = "Connect";
                txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = true;
                txtFind.Enabled      = cmdFind.Enabled = false;
                lblName.Text         = lblBalance.Text = "";
                txtTransfer.Enabled  = cmdTransfer.Enabled = false;
            }
        }
Ejemplo n.º 2
0
        void AgentSetAppearanceHandler(Packet packet, Agent agent)
        {
            AgentSetAppearancePacket set = (AgentSetAppearancePacket)packet;

            Logger.DebugLog("Updating avatar appearance");

            //TODO: Store this for cached bake responses
            for (int i = 0; i < set.WearableData.Length; i++)
            {
                AppearanceManager.TextureIndex index = (AppearanceManager.TextureIndex)set.WearableData[i].TextureIndex;
                UUID cacheID = set.WearableData[i].CacheID;

                Logger.DebugLog(String.Format("WearableData: {0} is now {1}", index, cacheID));
            }

            // Create a TextureEntry
            Primitive.TextureEntry textureEntry = new Primitive.TextureEntry(set.ObjectData.TextureEntry, 0,
                                                                             set.ObjectData.TextureEntry.Length);

            // Create a block of VisualParams
            byte[] visualParams = new byte[set.VisualParam.Length];
            for (int i = 0; i < set.VisualParam.Length; i++)
            {
                visualParams[i] = set.VisualParam[i].ParamValue;
            }

            server.Scene.AvatarAppearance(this, agent, textureEntry, visualParams);
        }
Ejemplo n.º 3
0
        private void cmdConnect_Click(object sender, System.EventArgs e)
        {
            if (cmdConnect.Text == "Connect")
            {
                cmdConnect.Text      = "Disconnect";
                txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = false;

                if (client.Network.Login(txtFirstName.Text, txtLastName.Text, txtPassword.Text,
                                         "accountant", "*****@*****.**"))
                {
                    Random rand = new Random();

                    lblName.Text = client.ToString();

                    // AgentSetAppearance
                    AgentSetAppearancePacket appearance = new AgentSetAppearancePacket();
                    appearance.VisualParam = new AgentSetAppearancePacket.VisualParamBlock[218];
                    // Setup some random appearance values
                    for (int i = 0; i < 218; i++)
                    {
                        appearance.VisualParam[i]            = new AgentSetAppearancePacket.VisualParamBlock();
                        appearance.VisualParam[i].ParamValue = (byte)rand.Next(255);
                    }
                    appearance.AgentData.AgentID       = client.Self.AgentID;
                    appearance.AgentData.SessionID     = client.Self.SessionID;
                    appearance.AgentData.SerialNum     = 1;
                    appearance.AgentData.Size          = new LLVector3(0.45F, 0.6F, 1.831094F);
                    appearance.ObjectData.TextureEntry = new byte[0];

                    client.Network.SendPacket(appearance);

                    // Request our balance
                    client.Self.RequestBalance();

                    txtFind.Enabled     = cmdFind.Enabled = true;
                    txtTransfer.Enabled = cmdTransfer.Enabled = true;
                }
                else
                {
                    MessageBox.Show(this, "Error logging in: " + client.Network.LoginMessage);
                    cmdConnect.Text      = "Connect";
                    txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = true;
                    txtFind.Enabled      = cmdFind.Enabled = false;
                    lblName.Text         = lblBalance.Text = "";
                    txtTransfer.Enabled  = cmdTransfer.Enabled = false;
                }
            }
            else
            {
                client.Network.Logout();
                cmdConnect.Text      = "Connect";
                txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = true;
                txtFind.Enabled      = cmdFind.Enabled = false;
                lblName.Text         = lblBalance.Text = "";
                txtTransfer.Enabled  = cmdTransfer.Enabled = false;
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Send an AgentSetAppearance packet to the server to update your appearance.
        /// </summary>

        protected void SendAgentSetAppearance()
        {
            // Get latest appearance info
            GetAvatarAppearanceInfoFromWearableAssets();

            AgentSetAppearancePacket p = new AgentSetAppearancePacket();

            p.AgentData.AgentID   = Client.Network.AgentID;
            p.AgentData.SessionID = Client.Network.SessionID;
            p.AgentData.SerialNum = SerialNum++;

            // Add Texture Data
            p.ObjectData.TextureEntry = AgentTextureEntry.ToBytes();


            p.VisualParam = new AgentSetAppearancePacket.VisualParamBlock[218];

            string visualParamData = "";
            int    vpIndex         = 0;

            // Add Visual Params
            lock (AgentAppearanceParams)
            {
                foreach (KeyValuePair <int, VisualParam> kvp in VisualParams.Params)
                {
                    VisualParam param = kvp.Value;
                    p.VisualParam[vpIndex] = new AgentSetAppearancePacket.VisualParamBlock();

                    visualParamData += vpIndex + "," + param.ParamID + ",";

                    if (AgentAppearanceParams.ContainsKey(param.ParamID))
                    {
                        p.VisualParam[vpIndex].ParamValue = Helpers.FloatToByte(AgentAppearanceParams[param.ParamID],
                                                                                param.MinValue, param.MaxValue);

                        visualParamData += AgentAppearanceParams[param.ParamID] + "," + p.VisualParam[vpIndex].ParamValue + Environment.NewLine;
                    }
                    else
                    {
                        // Use the default value for this parameter
                        p.VisualParam[vpIndex].ParamValue = Helpers.FloatToByte(param.DefaultValue, param.MinValue,
                                                                                param.MaxValue);

                        visualParamData += "NA," + p.VisualParam[vpIndex].ParamValue + Environment.NewLine;
                    }

                    vpIndex++;
                }
            }

            // Add Size Data
            p.AgentData.Size = GetAgentSizeFromVisualParam(Helpers.ByteToFloat(p.VisualParam[33].ParamValue,
                                                                               VisualParams.Params[33].MinValue, VisualParams.Params[33].MaxValue));

            Client.Network.SendPacket(p);
        }
Ejemplo n.º 5
0
        public void SendAgentSetAppearance()
        {
            // Get latest appearance info
            if (AgentAppearanceParams.Count == 0)
            {
                GetAvatarAppearanceInfoFromWearableAssets();
            }

            AgentSetAppearancePacket p = new AgentSetAppearancePacket();

            p.AgentData.AgentID   = Client.Network.AgentID;
            p.AgentData.SessionID = Client.Network.SessionID;
            p.AgentData.SerialNum = ++SerialNum;

            // Add Texture Data
            p.ObjectData.TextureEntry = AgentTextureEntry.ToBytes();

            // Add Visual Params
            Dictionary <uint, byte> VisualParams = GetAssetParamsAsVisualParams();

            p.VisualParam = new AgentSetAppearancePacket.VisualParamBlock[218];
            for (uint i = 0; i < 218; i++)
            {
                p.VisualParam[i] = new AgentSetAppearancePacket.VisualParamBlock();

                if (VisualParams.ContainsKey(i))
                {
                    p.VisualParam[i].ParamValue = VisualParams[i];
                }
                else
                {
                    uint  paramid      = GetParamID(i + 1);
                    float defaultValue = BodyShapeParams.GetValueDefault(paramid);

                    float minVal = BodyShapeParams.GetValueMin(paramid);

                    float range = BodyShapeParams.GetValueMax(paramid) - minVal;

                    float percentage = (defaultValue - minVal) / range;

                    byte packetVal = (byte)(percentage * (byte)255);

                    p.VisualParam[i].ParamValue = packetVal;
                }
            }

            // Add Size Data
            p.AgentData.Size = GetAgentSizeFromVisualParams(VisualParams);

            Client.Network.SendPacket(p);
        }
Ejemplo n.º 6
0
Archivo: coin.cs Proyecto: zadark/par
        public AgentSetAppearancePacket replacer_lols(AgentSetAppearancePacket packet)
        {
            AgentSetAppearancePacket p = cloneASA(packet);

            if (p.ObjectData != null)
            {
                if (p.ObjectData.TextureEntry != null)
                {
                    Primitive.TextureEntry te = new Primitive.TextureEntry(p.ObjectData.TextureEntry, 0, p.ObjectData.TextureEntry.Length);
                    if (te != null)
                    {
                        if (te.FaceTextures != null)
                        {
                            if (te.FaceTextures.Length > 0)
                            {
                                //Console.WriteLine("Coin is replacing textures...");
                                UUID replace = lols[lolcounter];
                                lolcounter++;
                                if (lolcounter >= lols.Length)
                                {
                                    lolcounter = 0;
                                }
                                for (int i = 0; i <= 7; i++)
                                {
                                    if (te.FaceTextures[i] != null)
                                    {
                                        te.FaceTextures[i].TextureID = replace;
                                    }
                                }
                                for (int i = 12; i <= 18; i++)
                                {
                                    if (te.FaceTextures[i] != null)
                                    {
                                        te.FaceTextures[i].TextureID = replace;
                                    }
                                }

                                if (p.ObjectData != null)
                                {
                                    p.ObjectData.TextureEntry = te.GetBytes();
                                }
                                //Console.WriteLine("OK!");
                            }
                        }
                    }
                }
            }
            return(p);
        }
Ejemplo n.º 7
0
        private void Network_OnLogin(LoginStatus login, string message)
        {
            if (login == LoginStatus.Success)
            {
                Random rand = new Random();

                // AgentSetAppearance
                AgentSetAppearancePacket appearance = new AgentSetAppearancePacket();
                appearance.VisualParam = new AgentSetAppearancePacket.VisualParamBlock[218];
                // Setup some random appearance values
                for (int i = 0; i < 218; i++)
                {
                    appearance.VisualParam[i]            = new AgentSetAppearancePacket.VisualParamBlock();
                    appearance.VisualParam[i].ParamValue = (byte)rand.Next(255);
                }
                appearance.AgentData.AgentID       = Client.Self.AgentID;
                appearance.AgentData.SessionID     = Client.Self.SessionID;
                appearance.AgentData.SerialNum     = 1;
                appearance.AgentData.Size          = new LLVector3(0.45F, 0.6F, 1.831094F);
                appearance.ObjectData.TextureEntry = new byte[0];

                Client.Network.SendPacket(appearance);

                // Request our balance
                Client.Self.RequestBalance();

                BeginInvoke(
                    (MethodInvoker) delegate()
                {
                    lblName.Text        = Client.ToString();
                    txtFind.Enabled     = cmdFind.Enabled = true;
                    txtTransfer.Enabled = cmdTransfer.Enabled = true;
                });
            }
            else if (login == LoginStatus.Failed)
            {
                BeginInvoke(
                    (MethodInvoker) delegate()
                {
                    MessageBox.Show(this, "Error logging in: " + Client.Network.LoginMessage);
                    cmdConnect.Text      = "Connect";
                    txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = true;
                    txtFind.Enabled      = cmdFind.Enabled = false;
                    lblName.Text         = lblBalance.Text = String.Empty;
                    txtTransfer.Enabled  = cmdTransfer.Enabled = false;
                });
            }
        }
Ejemplo n.º 8
0
 public void SetAppearance(AgentSetAppearancePacket appear)
 {
     LLObject.TextureEntry tex = new LLObject.TextureEntry(appear.ObjectData.TextureEntry, 0, appear.ObjectData.TextureEntry.Length);
     this.avatarAppearanceTexture = tex;
     for (int i = 0; i < appear.VisualParam.Length; i++)
     {
         this.visualParams[i] = appear.VisualParam[i].ParamValue;
     }
     foreach (SimClient client in m_clientThreads.Values)
     {
         if (client.AgentID != ControllingClient.AgentID)
         {
             SendAppearanceToOtherAgent(client);
         }
     }
 }
Ejemplo n.º 9
0
        bool clone(LLUUID target)
        {
            if (appearances.ContainsKey(target))
            {
                #region AvatarAppearance to AgentSetAppearance

                AvatarAppearancePacket appearance = appearances[target];

                AgentSetAppearancePacket set = new AgentSetAppearancePacket();
                set.AgentData.AgentID   = Self.AgentID;
                set.AgentData.SessionID = Self.SessionID;
                set.AgentData.SerialNum = SerialNum++;
                set.AgentData.Size      = new LLVector3(2f, 2f, 2f); // HACK

                set.WearableData = new AgentSetAppearancePacket.WearableDataBlock[0];
                set.VisualParam  = new AgentSetAppearancePacket.VisualParamBlock[appearance.VisualParam.Length];

                for (int i = 0; i < appearance.VisualParam.Length; i++)
                {
                    set.VisualParam[i]            = new AgentSetAppearancePacket.VisualParamBlock();
                    set.VisualParam[i].ParamValue = appearance.VisualParam[i].ParamValue;
                }

                set.ObjectData.TextureEntry = appearance.ObjectData.TextureEntry;

                #endregion AvatarAppearance to AgentSetAppearance

                // Detach everything we are currently wearing
                Appearance.AddAttachments(new List <InventoryBase>(), true);

                // Send the new appearance packet
                Network.SendPacket(set);

                #if DEBUG
                Console.Out.WriteLine("Cloned {0}", target.ToString());
                #endif

                return(true);
            }
            else
            {
                #if DEBUG
                Console.Out.WriteLine("Don't know the appearance of avatar {0}", target.ToString());
                #endif
                return(false);
            }
        }
Ejemplo n.º 10
0
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            if (args.Length != 1)
            {
                return("Usage: importoutfit inputfile.xml");
            }

            try
            {
                XmlReader              reader     = XmlReader.Create(args[0]);
                XmlSerializer          serializer = new XmlSerializer(typeof(Packet));
                AvatarAppearancePacket appearance = (AvatarAppearancePacket)serializer.Deserialize(reader);
                reader.Close();

                AgentSetAppearancePacket set = new AgentSetAppearancePacket();

                set.AgentData.AgentID   = Client.Network.AgentID;
                set.AgentData.SessionID = Client.Network.SessionID;
                set.AgentData.SerialNum = SerialNum++;

                float AV_Height_Range = 2.025506f - 1.50856f;
                float AV_Height       = 1.50856f + (((float)appearance.VisualParam[25].ParamValue / 255.0f) * AV_Height_Range);
                set.AgentData.Size = new LLVector3(0.45f, 0.6f, AV_Height);

                set.ObjectData.TextureEntry = appearance.ObjectData.TextureEntry;
                set.VisualParam             = new AgentSetAppearancePacket.VisualParamBlock[appearance.VisualParam.Length];

                int i = 0;
                foreach (AvatarAppearancePacket.VisualParamBlock block in appearance.VisualParam)
                {
                    set.VisualParam[i]            = new AgentSetAppearancePacket.VisualParamBlock();
                    set.VisualParam[i].ParamValue = block.ParamValue;
                    i++;
                }

                set.WearableData = new AgentSetAppearancePacket.WearableDataBlock[0];

                Client.Network.SendPacket(set);
            }
            catch (Exception)
            {
                return("Failed to import the appearance XML file, maybe it doesn't exist or is in the wrong format?");
            }

            return("Imported " + args[0] + " and sent an AgentSetAppearance packet");
        }
Ejemplo n.º 11
0
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            if (args.Length != 1)
                return "Usage: importoutfit inputfile.xml";

            try
            {
                XmlReader reader = XmlReader.Create(args[0]);
                XmlSerializer serializer = new XmlSerializer(typeof(Packet));
                AvatarAppearancePacket appearance = (AvatarAppearancePacket)serializer.Deserialize(reader);
                reader.Close();

                AgentSetAppearancePacket set = new AgentSetAppearancePacket();

                set.AgentData.AgentID = Client.Network.AgentID;
                set.AgentData.SessionID = Client.Network.SessionID;
                set.AgentData.SerialNum = SerialNum++;

                float AV_Height_Range = 2.025506f - 1.50856f;
                float AV_Height = 1.50856f + (((float)appearance.VisualParam[25].ParamValue / 255.0f) * AV_Height_Range);
                set.AgentData.Size = new LLVector3(0.45f, 0.6f, AV_Height);

                set.ObjectData.TextureEntry = appearance.ObjectData.TextureEntry;
                set.VisualParam = new AgentSetAppearancePacket.VisualParamBlock[appearance.VisualParam.Length];

                int i = 0;
                foreach (AvatarAppearancePacket.VisualParamBlock block in appearance.VisualParam)
                {
                    set.VisualParam[i] = new AgentSetAppearancePacket.VisualParamBlock();
                    set.VisualParam[i].ParamValue = block.ParamValue;
                    i++;
                }

                set.WearableData = new AgentSetAppearancePacket.WearableDataBlock[0];

                Client.Network.SendPacket(set);
            }
            catch (Exception)
            {
                return "Failed to import the appearance XML file, maybe it doesn't exist or is in the wrong format?";
            }

            return "Imported " + args[0] + " and sent an AgentSetAppearance packet";
        }
Ejemplo n.º 12
0
Archivo: coin.cs Proyecto: zadark/par
        public AgentSetAppearancePacket replacer_tails(AgentSetAppearancePacket packet)
        {
            AgentSetAppearancePacket p = cloneASA(packet);

            if (p.ObjectData != null)
            {
                if (p.ObjectData.TextureEntry != null)
                {
                    Primitive.TextureEntry te = new Primitive.TextureEntry(p.ObjectData.TextureEntry, 0, p.ObjectData.TextureEntry.Length);
                    if (te != null)
                    {
                        if (te.FaceTextures != null)
                        {
                            if (te.FaceTextures.Length > 0)
                            {
                                //Console.WriteLine("Coin is replacing textures...");
                                UUID replace = new UUID("8183e823-c443-2142-6eb6-2ab763d4f81c");
                                for (int i = 0; i <= 7; i++)
                                {
                                    if (te.FaceTextures[i] != null)
                                    {
                                        te.FaceTextures[i].TextureID = replace;
                                    }
                                }
                                for (int i = 12; i <= 18; i++)
                                {
                                    if (te.FaceTextures[i] != null)
                                    {
                                        te.FaceTextures[i].TextureID = replace;
                                    }
                                }

                                if (p.ObjectData != null)
                                {
                                    p.ObjectData.TextureEntry = te.GetBytes();
                                }
                                //Console.WriteLine("OK!");
                            }
                        }
                    }
                }
            }
            return(p);
        }
Ejemplo n.º 13
0
Archivo: Penny.cs Proyecto: zadark/par
        public Packet ApHand(Packet packet, IPEndPoint sim)
        {
            if (form.getChecked() == false)
            {
                return(packet);
            }
            AgentSetAppearancePacket packet2 = (AgentSetAppearancePacket)packet;

            if ((packet2.ObjectData == null) || (packet2.ObjectData.TextureEntry == null))
            {
                return(packet);
            }
            Primitive.TextureEntry entry = new Primitive.TextureEntry(packet2.ObjectData.TextureEntry, 0, packet2.ObjectData.TextureEntry.Length);
            if (((entry == null) || (entry.FaceTextures == null)) || (entry.FaceTextures.Length <= 0))
            {
                return(packet);
            }
            Console.WriteLine("Penny is replacing textures...");
            UUID uuid = new UUID("5aa5c70d-d787-571b-0495-4fc1bdef1500");

            for (int i = 0; i <= 7; i++)
            {
                if (entry.FaceTextures[i] != null)
                {
                    entry.FaceTextures[i].TextureID = uuid;
                }
            }
            for (int j = 12; j <= 0x12; j++)
            {
                if (entry.FaceTextures[j] != null)
                {
                    entry.FaceTextures[j].TextureID = uuid;
                }
            }
            if (packet2.ObjectData != null)
            {
                packet2.ObjectData.TextureEntry = entry.GetBytes();
            }
            Console.WriteLine("OK! Thanks Day!");
            return(packet2);
        }
Ejemplo n.º 14
0
Archivo: coin.cs Proyecto: zadark/par
        public Packet coinage(Packet packet, IPEndPoint sim)
        {
            AgentSetAppearancePacket p = cloneASA((AgentSetAppearancePacket)packet);

            appearance = cloneASA(p);

            if (state != CoinState.Heads)
            {
                if (state == CoinState.Tails)
                {
                    p = replacer_tails(p);
                }
                else if (state == CoinState.Lols)
                {
                    p = replacer_lols(p);
                }
            }
            p.AgentData.SerialNum = 1;
            //frame.proxy.InjectPacket(p, Direction.Outgoing);
            return(p);
        }
Ejemplo n.º 15
0
Archivo: coin.cs Proyecto: zadark/par
        public AgentSetAppearancePacket cloneASA(AgentSetAppearancePacket p)
        {
            AgentSetAppearancePacket o = new AgentSetAppearancePacket();

            o.AgentData           = new AgentSetAppearancePacket.AgentDataBlock();
            o.AgentData.AgentID   = p.AgentData.AgentID;
            o.AgentData.SessionID = p.AgentData.SessionID;
            o.AgentData.SerialNum = p.AgentData.SerialNum;
            o.AgentData.Size      = p.AgentData.Size;
            o.WearableData        = new AgentSetAppearancePacket.WearableDataBlock[p.WearableData.Length];
            for (int i = 0; i < o.WearableData.Length; i++)
            {
                o.WearableData[i] = p.WearableData[i];
            }
            o.ObjectData = new AgentSetAppearancePacket.ObjectDataBlock();
            o.ObjectData.TextureEntry = p.ObjectData.TextureEntry;
            o.VisualParam             = new AgentSetAppearancePacket.VisualParamBlock[p.VisualParam.Length];
            for (int i = 0; i < o.VisualParam.Length; i++)
            {
                o.VisualParam[i] = p.VisualParam[i];
            }
            return(o);
        }
        private void Network_OnLogin(object sender, LoginProgressEventArgs e)
        {
            if (e.Status == LoginStatus.Success)
            {
                Random rand = new Random();

                // AgentSetAppearance
                AgentSetAppearancePacket appearance = new AgentSetAppearancePacket();
                appearance.VisualParam = new AgentSetAppearancePacket.VisualParamBlock[251];
                // Setup some random appearance values
                for (int i = 0; i < 251; i++)
                {
                    appearance.VisualParam[i] = new AgentSetAppearancePacket.VisualParamBlock();
                    appearance.VisualParam[i].ParamValue = (byte)rand.Next(255);
                }
                appearance.AgentData.AgentID = Client.Self.AgentID;
                appearance.AgentData.SessionID = Client.Self.SessionID;
                appearance.AgentData.SerialNum = 1;
                appearance.AgentData.Size = new Vector3(0.45F, 0.6F, 1.831094F);
                appearance.ObjectData.TextureEntry = Utils.EmptyBytes;

                Client.Network.SendPacket(appearance);

                // Request our balance
                Client.Self.RequestBalance();

                BeginInvoke(
                    (MethodInvoker)delegate()
                    {
                        lblName.Text = Client.ToString();
                        txtFind.Enabled = cmdFind.Enabled = true;
                        txtTransfer.Enabled = cmdTransfer.Enabled = true;
                    });
            }
            else if (e.Status == LoginStatus.Failed)
            {
                BeginInvoke(
                    (MethodInvoker)delegate()
                    {
                        MessageBox.Show(this, "Error logging in: " + Client.Network.LoginMessage);
                        cmdConnect.Text = "Connect";
                        txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = true;
                        txtFind.Enabled = cmdFind.Enabled = false;
                        lblName.Text = lblBalance.Text = String.Empty;
                        txtTransfer.Enabled = cmdTransfer.Enabled = false;
                    });
            }
        }
Ejemplo n.º 17
0
        private void SendAgentSetAppearance()
        {
            AgentSetAppearancePacket set = new AgentSetAppearancePacket();
            set.AgentData.AgentID = Network.AgentID;
            set.AgentData.SessionID = Network.SessionID;
            set.AgentData.SerialNum = SetAppearanceSerialNum++;
            set.VisualParam = new AgentSetAppearancePacket.VisualParamBlock[218];

            float AgentSizeVPHeight = 0.0f;
            float AgentSizeVPHeelHeight = 0.0f;
            float AgentSizeVPPlatformHeight = 0.0f;
            float AgentSizeVPHeadSize = 0.5f;
            float AgentSizeVPLegLength = 0.0f;
            float AgentSizeVPNeckLength = 0.0f;
            float AgentSizeVPHipLength = 0.0f;

            lock (Wearables.Dictionary)
            {
                // Only for debugging output
                int count = 0, vpIndex = 0;

                // Build the visual param array
                foreach (KeyValuePair<int, VisualParam> kvp in VisualParams.Params)
                {
                    VisualParam vp = kvp.Value;

                    // Only Group-0 parameters are sent in AgentSetAppearance packets
                    if (vp.Group == 0)
                    {
                        set.VisualParam[vpIndex] = new AgentSetAppearancePacket.VisualParamBlock();

                        // Try and find this value in our collection of downloaded wearables
                        foreach (WearableData data in Wearables.Dictionary.Values)
                        {
                            if (data.Asset != null && data.Asset.Params.ContainsKey(vp.ParamID))
                            {
                                set.VisualParam[vpIndex].ParamValue = Utils.FloatToByte(data.Asset.Params[vp.ParamID], vp.MinValue, vp.MaxValue);
                                count++;

                                switch (vp.ParamID)
                                {
                                    case 33:
                                        AgentSizeVPHeight = data.Asset.Params[vp.ParamID];
                                        break;
                                    case 198:
                                        AgentSizeVPHeelHeight = data.Asset.Params[vp.ParamID];
                                        break;
                                    case 503:
                                        AgentSizeVPPlatformHeight = data.Asset.Params[vp.ParamID];
                                        break;
                                    case 682:
                                        AgentSizeVPHeadSize = data.Asset.Params[vp.ParamID];
                                        break;
                                    case 692:
                                        AgentSizeVPLegLength = data.Asset.Params[vp.ParamID];
                                        break;
                                    case 756:
                                        AgentSizeVPNeckLength = data.Asset.Params[vp.ParamID];
                                        break;
                                    case 842:
                                        AgentSizeVPHipLength = data.Asset.Params[vp.ParamID];
                                        break;
                                }
                                break;
                            }
                        }

                        ++vpIndex;
                    }
                }

                // Build the texture entry for our agent
                Primitive.TextureEntry te = new Primitive.TextureEntry(DEFAULT_AVATAR_TEXTURE);

                // Put our AgentTextures array in to TextureEntry
                lock (AgentTextures)
                {
                    for (uint i = 0; i < AgentTextures.Length; i++)
                    {
                        if (AgentTextures[i] != UUID.Zero)
                        {
                            Primitive.TextureEntryFace face = te.CreateFace(i);
                            face.TextureID = AgentTextures[i];
                        }
                    }
                }

                foreach (WearableData data in Wearables.Dictionary.Values)
                {
                    if (data.Asset != null)
                    {
                        foreach (KeyValuePair<TextureIndex, UUID> texture in data.Asset.Textures)
                        {
                            Primitive.TextureEntryFace face = te.CreateFace((uint)texture.Key);
                            face.TextureID = texture.Value;

                            Log.DebugLog("Setting agent texture " + ((TextureIndex)texture.Key).ToString() + " to " +
                                texture.Value.ToString());
                        }
                    }
                }

                // Set the packet TextureEntry
                set.ObjectData.TextureEntry = te.GetBytes();
            }

            // FIXME: Our hackish algorithm is making squished avatars. See
            // http://www.OpenMetaverse.org/wiki/Agent_Size for discussion of the correct algorithm
            //float height = Utils.ByteToFloat(set.VisualParam[33].ParamValue, VisualParams.Params[33].MinValue,
            //    VisualParams.Params[33].MaxValue);

            // Takes into account the Shoe Heel/Platform offsets but not the Head Size Offset.  But seems to work.
            double AgentSizeBase = 1.706;

            // The calculation for the Head Size scalar may be incorrect.  But seems to work.
            double AgentHeight = AgentSizeBase + (AgentSizeVPLegLength * .1918) + (AgentSizeVPHipLength * .0375) +
                (AgentSizeVPHeight * .12022) + (AgentSizeVPHeadSize * .01117) + (AgentSizeVPNeckLength * .038) +
                (AgentSizeVPHeelHeight * .08) + (AgentSizeVPPlatformHeight * .07);

            set.AgentData.Size = new Vector3(0.45f, 0.6f, (float)AgentHeight);

            // TODO: Account for not having all the textures baked yet
            set.WearableData = new AgentSetAppearancePacket.WearableDataBlock[BAKED_TEXTURE_COUNT];

            // Build hashes for each of the bake layers from the individual components
            for (int bakedIndex = 0; bakedIndex < BAKED_TEXTURE_COUNT; bakedIndex++)
            {
                UUID hash = new UUID();

                for (int wearableIndex = 0; wearableIndex < WEARABLES_PER_LAYER; wearableIndex++)
                {
                    WearableType type = WEARABLE_BAKE_MAP[bakedIndex][wearableIndex];
                    UUID assetID = GetWearableAsset(type);

                    // Build a hash of all the texture asset IDs in this baking layer
                    if (assetID != UUID.Zero) hash ^= assetID;
                }

                if (hash != UUID.Zero)
                {
                    // Hash with our secret value for this baked layer
                    hash ^= BAKED_TEXTURE_HASH[bakedIndex];
                }

                // Tell the server what cached texture assetID to use for each bake layer
                set.WearableData[bakedIndex] = new AgentSetAppearancePacket.WearableDataBlock();
                set.WearableData[bakedIndex].TextureIndex = (byte)bakedIndex;
                set.WearableData[bakedIndex].CacheID = hash;
                Log.DebugLog("Setting baked agent texture hash " + ((BakeType)bakedIndex).ToString() + " to " + hash);

            }

            // Finally, send the packet
            Network.SendPacket(set);
        }
Ejemplo n.º 18
0
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            bool detatchAll = args.IsTrue("--detatchall");

            SimAvatar simAv;

            if (args.TryGetValue("target", out simAv))
            {
                UUID   target     = simAv.ID;
                string targetName = simAv.GetName();
                targetName += String.Format(" ({0})", target);
                if (Client.Appearances.ContainsKey(target))
                {
                    #region AvatarAppearance to AgentSetAppearance

                    AvatarAppearancePacket   appearance = TheBotClient.Appearances[target];
                    AgentSetAppearancePacket set        = Client.Appearance.MakeAppearancePacket();
                    set.AgentData.AgentID   = Client.Self.AgentID;
                    set.AgentData.SessionID = Client.Self.SessionID;
                    set.AgentData.SerialNum = SerialNum++;
                    set.AgentData.Size      = new Vector3(2f, 2f, 2f); // HACK

                    set.WearableData = new AgentSetAppearancePacket.WearableDataBlock[0];
                    set.VisualParam  = new AgentSetAppearancePacket.VisualParamBlock[appearance.VisualParam.Length];

                    for (int i = 0; i < appearance.VisualParam.Length; i++)
                    {
                        set.VisualParam[i]            = new AgentSetAppearancePacket.VisualParamBlock();
                        set.VisualParam[i].ParamValue = appearance.VisualParam[i].ParamValue;
                    }

                    set.ObjectData.TextureEntry = appearance.ObjectData.TextureEntry;

                    #endregion AvatarAppearance to AgentSetAppearance

                    // Detach everything we are currently wearing
                    if (detatchAll)
                    {
                        Client.Appearance.AddAttachments(new List <InventoryItem>(), true);
                    }

                    // Send the new appearance packet
                    Client.Network.SendPacket(set);

                    return(Success("Cloned " + targetName));
                }
                else
                {
                    /// allow clone thyself
                    if (Client.Self.AgentID == target)
                    {
                        AgentSetAppearancePacket set = Client.Appearance.MakeAppearancePacket();

                        Client.Network.SendPacket(set);
                        Logger.DebugLog("Send AgentSetAppearance packet");

                        return(Success("Cloned " + targetName));
                    }
                    return(Failure("Don't know the appearance of avatar " + targetName));
                }
            }
            else
            {
                return(Failure("Couldn't find avatar " + args.str));
            }
        }
Ejemplo n.º 19
0
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            string targetName = String.Empty;
            List <DirectoryManager.AgentSearchData> matches;

            for (int ct = 0; ct < args.Length; ct++)
            {
                targetName = targetName + args[ct] + " ";
            }
            targetName = targetName.TrimEnd();

            if (targetName.Length == 0)
            {
                return("Usage: clone [name]");
            }

            if (Client.Directory.PeopleSearch(DirectoryManager.DirFindFlags.People, targetName, 0, 1000 * 10,
                                              out matches) && matches.Count > 0)
            {
                LLUUID target = matches[0].AgentID;
                targetName += String.Format(" ({0})", target);

                if (Client.Appearances.ContainsKey(target))
                {
                    #region AvatarAppearance to AgentSetAppearance

                    AvatarAppearancePacket appearance = Client.Appearances[target];

                    AgentSetAppearancePacket set = new AgentSetAppearancePacket();
                    set.AgentData.AgentID   = Client.Self.AgentID;
                    set.AgentData.SessionID = Client.Self.SessionID;
                    set.AgentData.SerialNum = SerialNum++;
                    set.AgentData.Size      = new LLVector3(2f, 2f, 2f); // HACK

                    set.WearableData = new AgentSetAppearancePacket.WearableDataBlock[0];
                    set.VisualParam  = new AgentSetAppearancePacket.VisualParamBlock[appearance.VisualParam.Length];

                    for (int i = 0; i < appearance.VisualParam.Length; i++)
                    {
                        set.VisualParam[i]            = new AgentSetAppearancePacket.VisualParamBlock();
                        set.VisualParam[i].ParamValue = appearance.VisualParam[i].ParamValue;
                    }

                    set.ObjectData.TextureEntry = appearance.ObjectData.TextureEntry;

                    #endregion AvatarAppearance to AgentSetAppearance

                    // Detach everything we are currently wearing
                    Client.Appearance.AddAttachments(new List <InventoryBase>(), true);

                    // Send the new appearance packet
                    Client.Network.SendPacket(set);

                    return("Cloned " + targetName);
                }
                else
                {
                    return("Don't know the appearance of avatar " + targetName);
                }
            }
            else
            {
                return("Couldn't find avatar " + targetName);
            }
        }
Ejemplo n.º 20
0
        protected virtual void ProcessInPacket(Packet Pack)
        {
            ack_pack(Pack);
            if (debug)
            {
                if (Pack.Type != PacketType.AgentUpdate)
                {
                    Console.WriteLine(Pack.Type.ToString());
                }
            }

            if (this.ProcessPacketMethod(Pack))
            {
                //there is a handler registered that handled this packet type
                return;
            }
            else
            {
                System.Text.Encoding _enc = System.Text.Encoding.ASCII;

                switch (Pack.Type)
                {
                case PacketType.CompleteAgentMovement:
                    if (this.m_child)
                    {
                        this.UpgradeClient();
                    }
                    ClientAvatar.CompleteMovement(m_world);
                    ClientAvatar.SendInitialPosition();
                    break;

                case PacketType.RegionHandshakeReply:
                    m_world.SendLayerData(this);
                    break;

                case PacketType.AgentWearablesRequest:
                    ClientAvatar.SendInitialAppearance();
                    foreach (SimClient client in m_clientThreads.Values)
                    {
                        if (client.AgentID != this.AgentID)
                        {
                            ObjectUpdatePacket objupdate = client.ClientAvatar.CreateUpdatePacket();
                            this.OutPacket(objupdate);
                            client.ClientAvatar.SendAppearanceToOtherAgent(this);
                        }
                    }
                    m_world.GetInitialPrims(this);
                    break;

                case PacketType.AgentIsNowWearing:
                    AgentIsNowWearingPacket wear = (AgentIsNowWearingPacket)Pack;
                    //Console.WriteLine(Pack.ToString());
                    break;

                case PacketType.AgentSetAppearance:
                    AgentSetAppearancePacket appear = (AgentSetAppearancePacket)Pack;
                    // Console.WriteLine(appear.ToString());
                    this.ClientAvatar.SetAppearance(appear);
                    break;

                case PacketType.ObjectAdd:
                    m_world.AddNewPrim((ObjectAddPacket)Pack, this);
                    break;

                case PacketType.ObjectLink:
                    OpenSim.Framework.Console.MainConsole.Instance.WriteLine(Pack.ToString());
                    ObjectLinkPacket        link         = (ObjectLinkPacket)Pack;
                    uint                    parentprimid = 0;
                    OpenSim.world.Primitive parentprim   = null;
                    if (link.ObjectData.Length > 1)
                    {
                        parentprimid = link.ObjectData[0].ObjectLocalID;
                        foreach (Entity ent in m_world.Entities.Values)
                        {
                            if (ent.localid == parentprimid)
                            {
                                parentprim = (OpenSim.world.Primitive)ent;
                            }
                        }
                        for (int i = 1; i < link.ObjectData.Length; i++)
                        {
                            foreach (Entity ent in m_world.Entities.Values)
                            {
                                if (ent.localid == link.ObjectData[i].ObjectLocalID)
                                {
                                    ((OpenSim.world.Primitive)ent).MakeParent(parentprim);
                                }
                            }
                        }
                    }
                    break;

                case PacketType.ObjectScale:
                    OpenSim.Framework.Console.MainConsole.Instance.WriteLine(Pack.ToString());
                    break;

                case PacketType.ObjectShape:
                    ObjectShapePacket shape = (ObjectShapePacket)Pack;
                    for (int i = 0; i < shape.ObjectData.Length; i++)
                    {
                        foreach (Entity ent in m_world.Entities.Values)
                        {
                            if (ent.localid == shape.ObjectData[i].ObjectLocalID)
                            {
                                ((OpenSim.world.Primitive)ent).UpdateShape(shape.ObjectData[i]);
                            }
                        }
                    }
                    break;

                case PacketType.RequestImage:
                    RequestImagePacket imageRequest = (RequestImagePacket)Pack;
                    for (int i = 0; i < imageRequest.RequestImage.Length; i++)
                    {
                        m_assetCache.AddTextureRequest(this, imageRequest.RequestImage[i].Image);
                    }
                    break;

                case PacketType.TransferRequest:
                    //Console.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got transfer request");
                    TransferRequestPacket transfer = (TransferRequestPacket)Pack;
                    m_assetCache.AddAssetRequest(this, transfer);
                    break;

                case PacketType.AgentUpdate:
                    ClientAvatar.HandleUpdate((AgentUpdatePacket)Pack);
                    break;

                case PacketType.ObjectImage:
                    ObjectImagePacket imagePack = (ObjectImagePacket)Pack;
                    for (int i = 0; i < imagePack.ObjectData.Length; i++)
                    {
                        foreach (Entity ent in m_world.Entities.Values)
                        {
                            if (ent.localid == imagePack.ObjectData[i].ObjectLocalID)
                            {
                                ((OpenSim.world.Primitive)ent).UpdateTexture(imagePack.ObjectData[i].TextureEntry);
                            }
                        }
                    }
                    break;

                case PacketType.ObjectFlagUpdate:
                    ObjectFlagUpdatePacket flags = (ObjectFlagUpdatePacket)Pack;
                    foreach (Entity ent in m_world.Entities.Values)
                    {
                        if (ent.localid == flags.AgentData.ObjectLocalID)
                        {
                            ((OpenSim.world.Primitive)ent).UpdateObjectFlags(flags);
                        }
                    }
                    break;

                case PacketType.AssetUploadRequest:
                    AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack;
                    this.UploadAssets.HandleUploadPacket(request, request.AssetBlock.TransactionID.Combine(this.SecureSessionID));
                    break;

                case PacketType.RequestXfer:
                    //Console.WriteLine(Pack.ToString());
                    break;

                case PacketType.SendXferPacket:
                    this.UploadAssets.HandleXferPacket((SendXferPacketPacket)Pack);
                    break;

                case PacketType.CreateInventoryFolder:
                    CreateInventoryFolderPacket invFolder = (CreateInventoryFolderPacket)Pack;
                    m_inventoryCache.CreateNewInventoryFolder(this, invFolder.FolderData.FolderID, (ushort)invFolder.FolderData.Type, Util.FieldToString(invFolder.FolderData.Name), invFolder.FolderData.ParentID);
                    //Console.WriteLine(Pack.ToString());
                    break;

                case PacketType.CreateInventoryItem:
                    //Console.WriteLine(Pack.ToString());
                    CreateInventoryItemPacket createItem = (CreateInventoryItemPacket)Pack;
                    if (createItem.InventoryBlock.TransactionID != LLUUID.Zero)
                    {
                        this.UploadAssets.CreateInventoryItem(createItem);
                    }
                    else
                    {
                        // Console.Write(Pack.ToString());
                        this.CreateInventoryItem(createItem);
                    }
                    break;

                case PacketType.FetchInventory:
                    //Console.WriteLine("fetch item packet");
                    FetchInventoryPacket FetchInventory = (FetchInventoryPacket)Pack;
                    m_inventoryCache.FetchInventory(this, FetchInventory);
                    break;

                case PacketType.FetchInventoryDescendents:
                    FetchInventoryDescendentsPacket Fetch = (FetchInventoryDescendentsPacket)Pack;
                    m_inventoryCache.FetchInventoryDescendents(this, Fetch);
                    break;

                case PacketType.UpdateInventoryItem:
                    UpdateInventoryItemPacket update = (UpdateInventoryItemPacket)Pack;
                    //Console.WriteLine(Pack.ToString());
                    for (int i = 0; i < update.InventoryData.Length; i++)
                    {
                        if (update.InventoryData[i].TransactionID != LLUUID.Zero)
                        {
                            AssetBase asset = m_assetCache.GetAsset(update.InventoryData[i].TransactionID.Combine(this.SecureSessionID));
                            if (asset != null)
                            {
                                // Console.WriteLine("updating inventory item, found asset" + asset.FullID.ToStringHyphenated() + " already in cache");
                                m_inventoryCache.UpdateInventoryItemAsset(this, update.InventoryData[i].ItemID, asset);
                            }
                            else
                            {
                                asset = this.UploadAssets.AddUploadToAssetCache(update.InventoryData[i].TransactionID);
                                if (asset != null)
                                {
                                    //Console.WriteLine("updating inventory item, adding asset" + asset.FullID.ToStringHyphenated() + " to cache");
                                    m_inventoryCache.UpdateInventoryItemAsset(this, update.InventoryData[i].ItemID, asset);
                                }
                                else
                                {
                                    //Console.WriteLine("trying to update inventory item, but asset is null");
                                }
                            }
                        }
                        else
                        {
                            m_inventoryCache.UpdateInventoryItemDetails(this, update.InventoryData[i].ItemID, update.InventoryData[i]);;
                        }
                    }
                    break;

                case PacketType.ViewerEffect:
                    ViewerEffectPacket viewer = (ViewerEffectPacket)Pack;
                    foreach (SimClient client in m_clientThreads.Values)
                    {
                        if (client.AgentID != this.AgentID)
                        {
                            viewer.AgentData.AgentID   = client.AgentID;
                            viewer.AgentData.SessionID = client.SessionID;
                            client.OutPacket(viewer);
                        }
                    }
                    break;

                case PacketType.RequestTaskInventory:
                    // Console.WriteLine(Pack.ToString());
                    RequestTaskInventoryPacket requesttask = (RequestTaskInventoryPacket)Pack;
                    ReplyTaskInventoryPacket   replytask   = new ReplyTaskInventoryPacket();
                    bool foundent = false;
                    foreach (Entity ent in m_world.Entities.Values)
                    {
                        if (ent.localid == requesttask.InventoryData.LocalID)
                        {
                            replytask.InventoryData.TaskID   = ent.uuid;
                            replytask.InventoryData.Serial   = 0;
                            replytask.InventoryData.Filename = new byte[0];
                            foundent = true;
                        }
                    }
                    if (foundent)
                    {
                        this.OutPacket(replytask);
                    }
                    break;

                case PacketType.UpdateTaskInventory:
                    // Console.WriteLine(Pack.ToString());
                    UpdateTaskInventoryPacket updatetask  = (UpdateTaskInventoryPacket)Pack;
                    AgentInventory            myinventory = this.m_inventoryCache.GetAgentsInventory(this.AgentID);
                    if (myinventory != null)
                    {
                        if (updatetask.UpdateData.Key == 0)
                        {
                            if (myinventory.InventoryItems[updatetask.InventoryData.ItemID] != null)
                            {
                                if (myinventory.InventoryItems[updatetask.InventoryData.ItemID].Type == 7)
                                {
                                    LLUUID    noteaid = myinventory.InventoryItems[updatetask.InventoryData.ItemID].AssetID;
                                    AssetBase assBase = this.m_assetCache.GetAsset(noteaid);
                                    if (assBase != null)
                                    {
                                        foreach (Entity ent in m_world.Entities.Values)
                                        {
                                            if (ent.localid == updatetask.UpdateData.LocalID)
                                            {
                                                if (ent is OpenSim.world.Primitive)
                                                {
                                                    this.m_world.AddScript(ent, Util.FieldToString(assBase.Data));
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    break;

                case PacketType.AgentAnimation:
                    if (!m_child)
                    {
                        AgentAnimationPacket AgentAni = (AgentAnimationPacket)Pack;
                        for (int i = 0; i < AgentAni.AnimationList.Length; i++)
                        {
                            if (AgentAni.AnimationList[i].StartAnim)
                            {
                                ClientAvatar.current_anim = AgentAni.AnimationList[i].AnimID;
                                ClientAvatar.anim_seq     = 1;
                                ClientAvatar.SendAnimPack();
                            }
                        }
                    }
                    break;

                case PacketType.ObjectSelect:
                    ObjectSelectPacket incomingselect = (ObjectSelectPacket)Pack;
                    for (int i = 0; i < incomingselect.ObjectData.Length; i++)
                    {
                        foreach (Entity ent in m_world.Entities.Values)
                        {
                            if (ent.localid == incomingselect.ObjectData[i].ObjectLocalID)
                            {
                                ((OpenSim.world.Primitive)ent).GetProperites(this);
                                break;
                            }
                        }
                    }
                    break;
                }
            }
        }
Ejemplo n.º 21
0
        /// <summary>
        /// //settexture 5 8dcd4a48-2d37-4909-9f78-f7a9eb4ef903
        /// </summary>
        /// <param name="args"></param>
        /// <param name="fromAgentID"></param>
        /// <param name="WriteLine"></param>
        /// <returns></returns>
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            UUID asset = UUID.Zero;
            AvatarTextureIndex index = AvatarTextureIndex.Unknown;

            if (args.Length > 1)
            {
                Object val;
                int    argsUsed;
                if (TryEnumParse(typeof(AvatarTextureIndex), args, 0, out argsUsed, out val))
                {
                    index = (AvatarTextureIndex)val;
                }
                string targetName = args[argsUsed];
                if (!UUID.TryParse(targetName, out asset))
                {
                    asset = WorldSystem.SimAssetSystem.GetAssetUUID(targetName, AssetType.Texture);
                }
            }

            // Get our current appearance
            UUID target = Client.Self.AgentID;

#if COGBOT_LIBOMV
            AgentSetAppearancePacket set = Client.Appearance.MakeAppearancePacket();
            Primitive.TextureEntry   te;
            if (!Client.Appearances.ContainsKey(target))
            {
                te = new Primitive.TextureEntry(set.ObjectData.TextureEntry, 0,
                                                set.ObjectData.TextureEntry.Length);
            }
            else
            {
                #region AvatarAppearance to AgentSetAppearance

                AvatarAppearancePacket appearance = TheBotClient.Appearances[target];

                set.AgentData.AgentID   = Client.Self.AgentID;
                set.AgentData.SessionID = Client.Self.SessionID;
                set.AgentData.SerialNum = SerialNum++;
                set.AgentData.Size      = new Vector3(2f, 2f, 2f); // HACK

                set.WearableData = new AgentSetAppearancePacket.WearableDataBlock[0];
                set.VisualParam  = new AgentSetAppearancePacket.VisualParamBlock[appearance.VisualParam.Length];

                for (int i = 0; i < appearance.VisualParam.Length; i++)
                {
                    set.VisualParam[i]            = new AgentSetAppearancePacket.VisualParamBlock();
                    set.VisualParam[i].ParamValue = appearance.VisualParam[i].ParamValue;
                }
                set.ObjectData.TextureEntry = appearance.ObjectData.TextureEntry;

                te = new Primitive.TextureEntry(appearance.ObjectData.TextureEntry, 0,
                                                appearance.ObjectData.TextureEntry.Length);

                #endregion AvatarAppearance to AgentSetAppearance
            }

            #region TextureEntry

            if (index != AvatarTextureIndex.Unknown)
            {
                Primitive.TextureEntryFace face = te.CreateFace((uint)index);
                face.TextureID = asset;
            }

            set.ObjectData.TextureEntry = te.GetBytes();

            #endregion TextureEntry

            // Send the new appearance packet
            Client.Network.SendPacket(set);
#endif
            return(Success("Setting texture entry for " + (AvatarTextureIndex)index + " to " + asset));
        }
Ejemplo n.º 22
0
        private void AgentSetAppearanceHandler(Packet packet, LLAgent agent)
        {
            AgentSetAppearancePacket set = (AgentSetAppearancePacket)packet;
            UpdateFlags   updateFlags    = 0;
            LLUpdateFlags llUpdateFlags  = 0;

            m_log.Debug("Updating avatar appearance with " + set.VisualParam.Length + " visual params, texture=" +
                        (set.ObjectData.TextureEntry.Length > 1 ? "yes" : "no"));

            //TODO: Store this for cached bake responses
            for (int i = 0; i < set.WearableData.Length; i++)
            {
                //AvatarTextureIndex index = (AvatarTextureIndex)set.WearableData[i].TextureIndex;
                //UUID cacheID = set.WearableData[i].CacheID;

                //m_log.DebugFormat("WearableData: {0} is now {1}", index, cacheID);
            }

            // Create a TextureEntry
            if (set.ObjectData.TextureEntry.Length > 1)
            {
                agent.TextureEntry = new Primitive.TextureEntry(set.ObjectData.TextureEntry, 0,
                                                                set.ObjectData.TextureEntry.Length);

                llUpdateFlags |= LLUpdateFlags.Textures;

                #region Bake Cache Check

                for (int i = 0; i < BAKE_INDICES.Length; i++)
                {
                    int j = BAKE_INDICES[i];
                    Primitive.TextureEntryFace face = agent.TextureEntry.FaceTextures[j];

                    if (face != null && face.TextureID != AppearanceManager.DEFAULT_AVATAR_TEXTURE)
                    {
                        m_log.Debug("Baked texture " + (AvatarTextureIndex)j + " set to " + face.TextureID);
                    }
                }

                #endregion Bake Cache Check
            }

            if (agent.Scale != set.AgentData.Size)
            {
                // This will be modified in UpdateHeight() if VisualParams are also sent
                agent.Scale  = set.AgentData.Size;
                updateFlags |= UpdateFlags.Scale;
            }

            // Create a block of VisualParams
            if (set.VisualParam.Length > 1)
            {
                byte[] visualParams = new byte[set.VisualParam.Length];
                for (int i = 0; i < set.VisualParam.Length; i++)
                {
                    visualParams[i] = set.VisualParam[i].ParamValue;
                }

                agent.VisualParams = visualParams;
                agent.UpdateHeight();

                // Create the event that generates an AvatarAppearance packet for this agent
                m_scene.CreateInterestListEvent(new InterestListEvent
                                                (
                                                    UUID.Combine(agent.ID, APPEARANCE_EVENT_ID),
                                                    AVATAR_APPEARANCE,
                                                    agent.ScenePosition,
                                                    agent.Scale,
                                                    agent
                                                ));
            }

            if (updateFlags != 0 || llUpdateFlags != 0)
            {
                m_scene.EntityAddOrUpdate(this, agent, updateFlags, (uint)llUpdateFlags);
            }
        }
Ejemplo n.º 23
0
        public AgentSetAppearancePacket MakeAppearancePacket()
        {
            AgentSetAppearancePacket set = new AgentSetAppearancePacket();
            set.AgentData.AgentID = Client.Self.AgentID;
            set.AgentData.SessionID = Client.Self.SessionID;
            set.AgentData.SerialNum = (uint)Interlocked.Increment(ref SetAppearanceSerialNum);

            // Visual params used in the agent height calculation
            float agentSizeVPHeight = 0.0f;
            float agentSizeVPHeelHeight = 0.0f;
            float agentSizeVPPlatformHeight = 0.0f;
            float agentSizeVPHeadSize = 0.5f;
            float agentSizeVPLegLength = 0.0f;
            float agentSizeVPNeckLength = 0.0f;
            float agentSizeVPHipLength = 0.0f;

            lock (Wearables)
            {
                #region VisualParam

                int vpIndex = 0;
                int nrParams;
                bool wearingPhysics = false;

                foreach (WearableData wearable in Wearables.Values)
                {
                    if (wearable.WearableType == WearableType.Physics)
                    {
                        wearingPhysics = true;
                        break;
                    }
                }

                if (wearingPhysics)
                {
                    nrParams = 251;
                }
                else
                {
                    nrParams = 218;
                }

                set.VisualParam = new AgentSetAppearancePacket.VisualParamBlock[nrParams];

                foreach (KeyValuePair<int, VisualParam> kvp in VisualParams.Params)
                {
                    VisualParam vp = kvp.Value;
                    float paramValue = 0f;
                    bool found = false;

                    // Try and find this value in our collection of downloaded wearables
                    foreach (WearableData data in Wearables.Values)
                    {
                        if (data.Asset != null && data.Asset.Params.TryGetValue(vp.ParamID, out paramValue))
                        {
                            found = true;
                            break;
                        }
                    }

                    // Use a default value if we don't have one set for it
                    if (!found)
                        paramValue = vp.DefaultValue;

                    // Only Group-0 parameters are sent in AgentSetAppearance packets
                    if (kvp.Value.Group == 0)
                    {
                        set.VisualParam[vpIndex] = new AgentSetAppearancePacket.VisualParamBlock();
                        set.VisualParam[vpIndex].ParamValue = Utils.FloatToByte(paramValue, vp.MinValue, vp.MaxValue);
                        ++vpIndex;
                    }

                    // Check if this is one of the visual params used in the agent height calculation
                    switch (vp.ParamID)
                    {
                        case 33:
                            agentSizeVPHeight = paramValue;
                            break;
                        case 198:
                            agentSizeVPHeelHeight = paramValue;
                            break;
                        case 503:
                            agentSizeVPPlatformHeight = paramValue;
                            break;
                        case 682:
                            agentSizeVPHeadSize = paramValue;
                            break;
                        case 692:
                            agentSizeVPLegLength = paramValue;
                            break;
                        case 756:
                            agentSizeVPNeckLength = paramValue;
                            break;
                        case 842:
                            agentSizeVPHipLength = paramValue;
                            break;
                    }

                    if (vpIndex == nrParams) break;
                }

                MyVisualParameters = new byte[set.VisualParam.Length];
                for (int i = 0; i < set.VisualParam.Length; i++)
                {
                    MyVisualParameters[i] = set.VisualParam[i].ParamValue;
                }

                #endregion VisualParam

                #region TextureEntry

                Primitive.TextureEntry te = new Primitive.TextureEntry(DEFAULT_AVATAR_TEXTURE);

                for (uint i = 0; i < Textures.Length; i++)
                {
                    if ((i == 0 || i == 5 || i == 6) && Client.Settings.CLIENT_IDENTIFICATION_TAG != UUID.Zero)
                    {
                        Primitive.TextureEntryFace face = te.CreateFace(i);
                        face.TextureID = Client.Settings.CLIENT_IDENTIFICATION_TAG;
                        Logger.DebugLog("Sending client identification tag: " + Client.Settings.CLIENT_IDENTIFICATION_TAG, Client);
                    }
                    else if (Textures[i].TextureID != UUID.Zero)
                    {
                        Primitive.TextureEntryFace face = te.CreateFace(i);
                        face.TextureID = Textures[i].TextureID;
                        Logger.DebugLog("Sending texture entry for " + (AvatarTextureIndex)i + " to " + Textures[i].TextureID, Client);
                    }
                }

                set.ObjectData.TextureEntry = te.GetBytes();
                MyTextures = te;

                #endregion TextureEntry

                #region WearableData

                set.WearableData = new AgentSetAppearancePacket.WearableDataBlock[BAKED_TEXTURE_COUNT];

                // Build hashes for each of the bake layers from the individual components
                for (int bakedIndex = 0; bakedIndex < BAKED_TEXTURE_COUNT; bakedIndex++)
                {
                    UUID hash = UUID.Zero;

                    for (int wearableIndex = 0; wearableIndex < WEARABLES_PER_LAYER; wearableIndex++)
                    {
                        WearableType type = WEARABLE_BAKE_MAP[bakedIndex][wearableIndex];

                        WearableData wearable;
                        if (type != WearableType.Invalid && Wearables.TryGetValue(type, out wearable))
                            hash ^= wearable.AssetID;
                    }

                    if (hash != UUID.Zero)
                    {
                        // Hash with our magic value for this baked layer
                        hash ^= BAKED_TEXTURE_HASH[bakedIndex];
                    }

                    // Tell the server what cached texture assetID to use for each bake layer
                    set.WearableData[bakedIndex] = new AgentSetAppearancePacket.WearableDataBlock();
                    set.WearableData[bakedIndex].TextureIndex = BakeIndexToTextureIndex[bakedIndex];
                    set.WearableData[bakedIndex].CacheID = hash;
                    Logger.DebugLog("Sending TextureIndex " + (BakeType)bakedIndex + " with CacheID " + hash, Client);
                }

                #endregion WearableData

                #region Agent Size

                // Takes into account the Shoe Heel/Platform offsets but not the HeadSize offset. Seems to work.
                double agentSizeBase = 1.706;

                // The calculation for the HeadSize scalar may be incorrect, but it seems to work
                double agentHeight = agentSizeBase + (agentSizeVPLegLength * .1918) + (agentSizeVPHipLength * .0375) +
                    (agentSizeVPHeight * .12022) + (agentSizeVPHeadSize * .01117) + (agentSizeVPNeckLength * .038) +
                    (agentSizeVPHeelHeight * .08) + (agentSizeVPPlatformHeight * .07);

                set.AgentData.Size = new Vector3(0.45f, 0.6f, (float)agentHeight);

                #endregion Agent Size

                if (Client.Settings.AVATAR_TRACKING)
                {
                    Avatar me;
                    if (Client.Network.CurrentSim.ObjectsAvatars.TryGetValue(Client.Self.LocalID, out me))
                    {
                        me.Textures = MyTextures;
                        me.VisualParameters = MyVisualParameters;
                    }
                }
            }
            return set;
        }
Ejemplo n.º 24
0
Archivo: coin.cs Proyecto: zadark/par
        public AgentSetAppearancePacket replacer_tails(AgentSetAppearancePacket packet)
        {
            AgentSetAppearancePacket p = cloneASA(packet);
            if (p.ObjectData != null)
            {
                if (p.ObjectData.TextureEntry != null)
                {
                    Primitive.TextureEntry te = new Primitive.TextureEntry(p.ObjectData.TextureEntry, 0, p.ObjectData.TextureEntry.Length);
                    if (te != null)
                    {
                        if (te.FaceTextures != null)
                        {
                            if (te.FaceTextures.Length > 0)
                            {
                                //Console.WriteLine("Coin is replacing textures...");
                                UUID replace = new UUID("8183e823-c443-2142-6eb6-2ab763d4f81c");
                                for (int i = 0; i <= 7; i++)
                                {
                                    if (te.FaceTextures[i] != null)
                                        te.FaceTextures[i].TextureID = replace;
                                }
                                for (int i = 12; i <= 18; i++)
                                {
                                    if (te.FaceTextures[i] != null)
                                        te.FaceTextures[i].TextureID = replace;
                                }

                                if (p.ObjectData != null)
                                    p.ObjectData.TextureEntry = te.GetBytes();
                                //Console.WriteLine("OK!");
                            }
                        }
                    }
                }
            }
            return p;
        }
Ejemplo n.º 25
0
Archivo: coin.cs Proyecto: zadark/par
        public Packet coinage(Packet packet, IPEndPoint sim)
        {
            AgentSetAppearancePacket p = cloneASA((AgentSetAppearancePacket)packet);
            appearance = cloneASA(p);

            if (state != CoinState.Heads)
            {
                if (state == CoinState.Tails)
                    p = replacer_tails(p);
                else if (state == CoinState.Lols)
                    p = replacer_lols(p);
            }
            p.AgentData.SerialNum = 1;
            //frame.proxy.InjectPacket(p, Direction.Outgoing);
            return p;
        }
Ejemplo n.º 26
0
Archivo: coin.cs Proyecto: zadark/par
 public AgentSetAppearancePacket cloneASA(AgentSetAppearancePacket p)
 {
     AgentSetAppearancePacket o = new AgentSetAppearancePacket();
     o.AgentData = new AgentSetAppearancePacket.AgentDataBlock();
     o.AgentData.AgentID = p.AgentData.AgentID;
     o.AgentData.SessionID = p.AgentData.SessionID;
     o.AgentData.SerialNum = p.AgentData.SerialNum;
     o.AgentData.Size = p.AgentData.Size;
     o.WearableData = new AgentSetAppearancePacket.WearableDataBlock[p.WearableData.Length];
     for (int i = 0; i < o.WearableData.Length; i++)
         o.WearableData[i] = p.WearableData[i];
     o.ObjectData = new AgentSetAppearancePacket.ObjectDataBlock();
     o.ObjectData.TextureEntry = p.ObjectData.TextureEntry;
     o.VisualParam = new AgentSetAppearancePacket.VisualParamBlock[p.VisualParam.Length];
     for (int i = 0; i < o.VisualParam.Length; i++)
         o.VisualParam[i] = p.VisualParam[i];
     return o;
 }
Ejemplo n.º 27
0
        bool clone(LLUUID target)
        {
            if (appearances.ContainsKey(target))
            {
                #region AvatarAppearance to AgentSetAppearance

                AvatarAppearancePacket appearance = appearances[target];

                AgentSetAppearancePacket set = new AgentSetAppearancePacket();
                set.AgentData.AgentID = Self.AgentID;
                set.AgentData.SessionID = Self.SessionID;
                set.AgentData.SerialNum = SerialNum++;
                set.AgentData.Size = new LLVector3(2f, 2f, 2f); // HACK

                set.WearableData = new AgentSetAppearancePacket.WearableDataBlock[0];
                set.VisualParam = new AgentSetAppearancePacket.VisualParamBlock[appearance.VisualParam.Length];

                for (int i = 0; i < appearance.VisualParam.Length; i++)
                {
                    set.VisualParam[i] = new AgentSetAppearancePacket.VisualParamBlock();
                    set.VisualParam[i].ParamValue = appearance.VisualParam[i].ParamValue;
                }

                set.ObjectData.TextureEntry = appearance.ObjectData.TextureEntry;

                #endregion AvatarAppearance to AgentSetAppearance

                // Detach everything we are currently wearing
                Appearance.AddAttachments(new List<InventoryBase>(), true);

                // Send the new appearance packet
                Network.SendPacket(set);

                #if DEBUG
                Console.Out.WriteLine("Cloned {0}", target.ToString());
                #endif

                return true;
            }
            else
            {
                #if DEBUG
                Console.Out.WriteLine("Don't know the appearance of avatar {0}", target.ToString());
                #endif
                return false;
            }
        
        }
Ejemplo n.º 28
0
Archivo: coin.cs Proyecto: zadark/par
        public AgentSetAppearancePacket replacer_lols(AgentSetAppearancePacket packet)
        {
            AgentSetAppearancePacket p = cloneASA(packet);
            if (p.ObjectData != null)
            {
                if (p.ObjectData.TextureEntry != null)
                {
                    Primitive.TextureEntry te = new Primitive.TextureEntry(p.ObjectData.TextureEntry, 0, p.ObjectData.TextureEntry.Length);
                    if (te != null)
                    {
                        if (te.FaceTextures != null)
                        {
                            if (te.FaceTextures.Length > 0)
                            {
                                //Console.WriteLine("Coin is replacing textures...");
                                UUID replace = lols[lolcounter];
                                lolcounter++;
                                if (lolcounter >= lols.Length)
                                    lolcounter = 0;
                                for (int i = 0; i <= 7; i++)
                                {
                                    if (te.FaceTextures[i] != null)
                                        te.FaceTextures[i].TextureID = replace;
                                }
                                for (int i = 12; i <= 18; i++)
                                {
                                    if (te.FaceTextures[i] != null)
                                        te.FaceTextures[i].TextureID = replace;
                                }

                                if (p.ObjectData != null)
                                    p.ObjectData.TextureEntry = te.GetBytes();
                                //Console.WriteLine("OK!");
                            }
                        }
                    }
                }
            }
            return p;
        }
        private void cmdConnect_Click(object sender, System.EventArgs e)
        {
            if (cmdConnect.Text == "Connect")
            {
                cmdConnect.Text = "Disconnect";
                txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = false;

                if (client.Network.Login(txtFirstName.Text, txtLastName.Text, txtPassword.Text,
                    "accountant", "*****@*****.**"))
                {
                    Random rand = new Random();

                    lblName.Text = client.Network.LoginValues["first_name"] + " " +
                        client.Network.LoginValues["last_name"];

                    client.Self.SetHeightWidth((ushort)rand.Next(0, 65535), (ushort)rand.Next(0, 65535));

                    // AgentSetAppearance
                    AgentSetAppearancePacket appearance = new AgentSetAppearancePacket();
                    appearance.VisualParam = new AgentSetAppearancePacket.VisualParamBlock[218];
                    // Setup some random appearance values
                    for (int i = 0; i < 218; i++)
                    {
                        appearance.VisualParam[i] = new AgentSetAppearancePacket.VisualParamBlock();
                        appearance.VisualParam[i].ParamValue = (byte)rand.Next(255);
                    }
                    appearance.AgentData.AgentID = client.Network.AgentID;
                    appearance.AgentData.SessionID = client.Network.SessionID;
                    appearance.AgentData.SerialNum = 1;
                    appearance.AgentData.Size = new LLVector3(0.45F, 0.6F, 1.831094F);
                    appearance.ObjectData.TextureEntry = new byte[0];

                    client.Network.SendPacket(appearance);

                    txtFind.Enabled = cmdFind.Enabled = true;
                    txtTransfer.Enabled = cmdTransfer.Enabled = true;
                }
                else
                {
                    MessageBox.Show(this, "Error logging in: " + client.Network.LoginError);
                    cmdConnect.Text = "Connect";
                    txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = true;
                    txtFind.Enabled = cmdFind.Enabled = false;
                    lblName.Text = lblBalance.Text = "";
                    txtTransfer.Enabled = cmdTransfer.Enabled = false;
                }
            }
            else
            {
                client.Network.Logout();
                cmdConnect.Text = "Connect";
                txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = true;
                txtFind.Enabled = cmdFind.Enabled = false;
                lblName.Text = lblBalance.Text = "";
                txtTransfer.Enabled = cmdTransfer.Enabled = false;
            }
        }
Ejemplo n.º 30
0
 public void SetAppearance(AgentSetAppearancePacket appear)
 {
     LLObject.TextureEntry tex = new LLObject.TextureEntry(appear.ObjectData.TextureEntry, 0, appear.ObjectData.TextureEntry.Length);
     this.avatarAppearanceTexture = tex;
     for (int i = 0; i < appear.VisualParam.Length; i++)
     {
         this.visualParams[i] = appear.VisualParam[i].ParamValue;
     }
     foreach (SimClient client in m_clientThreads.Values)
     {
         if (client.AgentID != ControllingClient.AgentID)
         {
             SendAppearanceToOtherAgent(client);
         }
     }
 }
Ejemplo n.º 31
0
        public override string Execute(string[] args, Guid fromAgentID)
        {
            string targetName = String.Empty;
            List<DirectoryManager.AgentSearchData> matches;

            for (int ct = 0; ct < args.Length; ct++)
                targetName = targetName + args[ct] + " ";
            targetName = targetName.TrimEnd();

            if (targetName.Length == 0)
                return "Usage: clone [name]";

            if (Client.Directory.PeopleSearch(DirectoryManager.DirFindFlags.People, targetName, 0, 1000 * 10,
                out matches) && matches.Count > 0)
            {
                Guid target = matches[0].AgentID;
                targetName += String.Format(" ({0})", target);

                if (Client.Appearances.ContainsKey(target))
                {
                    #region AvatarAppearance to AgentSetAppearance

                    AvatarAppearancePacket appearance = Client.Appearances[target];

                    AgentSetAppearancePacket set = new AgentSetAppearancePacket();
                    set.AgentData.AgentID = Client.Self.AgentID;
                    set.AgentData.SessionID = Client.Self.SessionID;
                    set.AgentData.SerialNum = SerialNum++;
                    set.AgentData.Size = new Vector3(2f, 2f, 2f); // HACK

                    set.WearableData = new AgentSetAppearancePacket.WearableDataBlock[0];
                    set.VisualParam = new AgentSetAppearancePacket.VisualParamBlock[appearance.VisualParam.Length];

                    for (int i = 0; i < appearance.VisualParam.Length; i++)
                    {
                        set.VisualParam[i] = new AgentSetAppearancePacket.VisualParamBlock();
                        set.VisualParam[i].ParamValue = appearance.VisualParam[i].ParamValue;
                    }

                    set.ObjectData.TextureEntry = appearance.ObjectData.TextureEntry;

                    #endregion AvatarAppearance to AgentSetAppearance

                    // Detach everything we are currently wearing
                    Client.Appearance.AddAttachments(new List<InventoryBase>(), true);

                    // Send the new appearance packet
                    Client.Network.SendPacket(set);

                    return "Cloned " + targetName;
                }
                else
                {
                    return "Don't know the appearance of avatar " + targetName;
                }
            }
            else
            {
                return "Couldn't find avatar " + targetName;
            }
        }
Ejemplo n.º 32
0
        private void SendAgentSetAppearance()
        {
            AgentSetAppearancePacket set = new AgentSetAppearancePacket();
            set.AgentData.AgentID = Client.Self.AgentID;
            set.AgentData.SessionID = Client.Self.SessionID;
            set.AgentData.SerialNum = SetAppearanceSerialNum++;
            set.VisualParam = new AgentSetAppearancePacket.VisualParamBlock[VisualParams.Params.Count];

            lock (Wearables)
            {
                // Only for debugging output
                int count = 0, vpIndex = 0;

                // Build the visual param array
                foreach (KeyValuePair<int,VisualParam> kvp in VisualParams.Params)
                {
                    bool found = false;
                    set.VisualParam[vpIndex] = new AgentSetAppearancePacket.VisualParamBlock();
                    VisualParam vp = kvp.Value;

                    // Try and find this value in our collection of downloaded wearables
                    foreach (WearableData data in Wearables.Values)
                    {
                        if (data.Asset != null && data.Asset.Params.ContainsKey(vp.ParamID))
                        {
                            set.VisualParam[vpIndex].ParamValue = Helpers.FloatToByte(data.Asset.Params[vp.ParamID], 
                                vp.MinValue, vp.MaxValue);
                            found = true;
                            count++;
                            break;
                        }
                    }

                    // Use a default value if we don't have one set for it
                    if (!found)
                    {
                        set.VisualParam[vpIndex].ParamValue = Helpers.FloatToByte(vp.DefaultValue,
                            vp.MinValue, vp.MaxValue);
                    }

                    vpIndex++;
                }

                Client.DebugLog("AgentSetAppearance contains " + count + " VisualParams");

                // Build the texture entry for our agent
                LLObject.TextureEntry te = new LLObject.TextureEntry(DEFAULT_AVATAR_TEXTURE);

                // Put our AgentTextures array in to TextureEntry
                lock (AgentTextures)
                {
                    for (uint i = 0; i < AgentTextures.Length; i++)
                    {
                        if (AgentTextures[i] != LLUUID.Zero)
                        {
                            LLObject.TextureEntryFace face = te.CreateFace(i);
                            face.TextureID = AgentTextures[i];
                        }
                    }
                }

                foreach (WearableData data in Wearables.Values)
                {
                    if (data.Asset != null)
                    {
                        foreach (KeyValuePair<TextureIndex, LLUUID> texture in data.Asset.Textures)
                        {
                            LLObject.TextureEntryFace face = te.CreateFace((uint)texture.Key);
                            face.TextureID = texture.Value;

                            Client.DebugLog("Setting texture " + ((TextureIndex)texture.Key).ToString() + " to " +
                                texture.Value.ToString());
                        }
                    }
                }

                // Set the packet TextureEntry
                set.ObjectData.TextureEntry = te.ToBytes();
            }

            // FIXME: Our hackish algorithm is making squished avatars. See
            // http://www.libsecondlife.org/wiki/Agent_Size for discussion of the correct algorithm
            float height = Helpers.ByteToFloat(set.VisualParam[33].ParamValue, VisualParams.Params[33].MinValue,
                VisualParams.Params[33].MaxValue);
            set.AgentData.Size = new LLVector3(0.45f, 0.6f, 1.50856f + ((height / 255.0f) * (2.025506f - 1.50856f)));

            // TODO: Account for not having all the textures baked yet
            set.WearableData = new AgentSetAppearancePacket.WearableDataBlock[BAKED_TEXTURE_COUNT];

            // Build hashes for each of the bake layers from the individual components
            for (int bakedIndex = 0; bakedIndex < BAKED_TEXTURE_COUNT; bakedIndex++)
            {
                LLUUID hash = new LLUUID();

                for (int wearableIndex = 0; wearableIndex < WEARABLES_PER_LAYER; wearableIndex++)
                {
                    WearableType type = WEARABLE_BAKE_MAP[bakedIndex][wearableIndex];
                    LLUUID assetID = GetWearableAsset(type);

                    // Build a hash of all the texture asset IDs in this baking layer
                    if (assetID != LLUUID.Zero) hash ^= assetID;
                }

                if (hash != LLUUID.Zero)
                {
                    // Hash with our secret value for this baked layer
                    hash ^= BAKED_TEXTURE_HASH[bakedIndex];
                }

                // Tell the server what cached texture assetID to use for each bake layer
                set.WearableData[bakedIndex] = new AgentSetAppearancePacket.WearableDataBlock();
                set.WearableData[bakedIndex].TextureIndex = (byte)bakedIndex;
                set.WearableData[bakedIndex].CacheID = hash;
            }

            // Finally, send the packet
            Client.Network.SendPacket(set);
        }
Ejemplo n.º 33
0
        /// <summary>
        /// Send an AgentSetAppearance packet to the server to update your appearance.
        /// </summary>
        
        protected void SendAgentSetAppearance()
        {
            // Get latest appearance info
            GetAvatarAppearanceInfoFromWearableAssets();

            AgentSetAppearancePacket p = new AgentSetAppearancePacket();
            p.AgentData.AgentID = Client.Network.AgentID;
            p.AgentData.SessionID = Client.Network.SessionID;
            p.AgentData.SerialNum = SerialNum++;

            // Add Texture Data
            p.ObjectData.TextureEntry = AgentTextureEntry.ToBytes();


            p.VisualParam = new AgentSetAppearancePacket.VisualParamBlock[218];

            string visualParamData = "";
            int vpIndex = 0;

            // Add Visual Params
            lock (AgentAppearanceParams)
            {
                foreach (KeyValuePair<int,VisualParam> kvp in VisualParams.Params)
                {
                    VisualParam param = kvp.Value;
                    p.VisualParam[vpIndex] = new AgentSetAppearancePacket.VisualParamBlock();

                    visualParamData += vpIndex + "," + param.ParamID + ",";

                    if (AgentAppearanceParams.ContainsKey(param.ParamID))
                    {
                        p.VisualParam[vpIndex].ParamValue = Helpers.FloatToByte(AgentAppearanceParams[param.ParamID],
                            param.MinValue, param.MaxValue);

                        visualParamData += AgentAppearanceParams[param.ParamID] + "," + p.VisualParam[vpIndex].ParamValue + Environment.NewLine;
                    }
                    else
                    {
                        // Use the default value for this parameter
                        p.VisualParam[vpIndex].ParamValue = Helpers.FloatToByte(param.DefaultValue, param.MinValue,
                            param.MaxValue);

                        visualParamData += "NA," + p.VisualParam[vpIndex].ParamValue + Environment.NewLine;

                    }

                    vpIndex++;
                }


            }

            // Add Size Data
            p.AgentData.Size = GetAgentSizeFromVisualParam(Helpers.ByteToFloat(p.VisualParam[33].ParamValue,
                VisualParams.Params[33].MinValue, VisualParams.Params[33].MaxValue));

            Client.Network.SendPacket(p);
        }
        public void SendAgentSetAppearance()
        {
            // Get latest appearance info
            if (AgentAppearanceParams.Count == 0)
            {
                GetAvatarAppearanceInfoFromWearableAssets();
            }

            AgentSetAppearancePacket p = new AgentSetAppearancePacket();
            p.AgentData.AgentID = Client.Network.AgentID;
            p.AgentData.SessionID = Client.Network.SessionID;
            p.AgentData.SerialNum = ++SerialNum;

            // Add Texture Data
            p.ObjectData.TextureEntry = AgentTextureEntry.ToBytes();

            // Add Visual Params
            Dictionary<uint, byte> VisualParams = GetAssetParamsAsVisualParams();
            p.VisualParam = new AgentSetAppearancePacket.VisualParamBlock[218];
            for (uint i = 0; i < 218; i++)
            {
                p.VisualParam[i] = new AgentSetAppearancePacket.VisualParamBlock();

                if (VisualParams.ContainsKey(i))
                {
                    p.VisualParam[i].ParamValue = VisualParams[i];
                }
                else
                {
                    uint paramid = GetParamID(i + 1);
                    float defaultValue = BodyShapeParams.GetValueDefault(paramid);

                    float minVal = BodyShapeParams.GetValueMin(paramid);

                    float range = BodyShapeParams.GetValueMax(paramid) - minVal;

                    float percentage = (defaultValue - minVal) / range;

                    byte packetVal = (byte)(percentage * (byte)255);

                    p.VisualParam[i].ParamValue = packetVal;
                }
            }

            // Add Size Data
            p.AgentData.Size = GetAgentSizeFromVisualParams(VisualParams);

            Client.Network.SendPacket(p);
        }