Пример #1
0
        /// <summary>
        /// User clicked on an item in the list containing available heads and bodies.
        /// </summary>
        private void LstHeads_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (m_Skeleton == null)
            {
                m_Skeleton = new Skeleton(this.Device, ContentManager.GetResourceFromLongID(0x100000005));
                m_Skeleton.AssignChildren(ref m_Skeleton);
            }

            foreach(KeyValuePair<ulong, string> Pair in ContentManager.Resources)
            {
                if ((string)LstHeads.SelectedItem == Pair.Value)
                {
                    //HAndGroup files are used to group together different hand meshes and textures.
                    if (Pair.Value.Contains(".hag"))
                    {
                        Hag HandGroup = new Hag(ContentManager.GetResourceFromLongID(Pair.Key));

                        m_CurrentAppearance = new Appearance(ContentManager.GetResourceFromLongID(
                            HandGroup.Appearances[0]));

                        LstAppearances.Items.Clear();

                        foreach (ulong AppearanceID in HandGroup.Appearances)
                            LstAppearances.Items.Add(AppearanceID);

                        List<Binding> Bindings = new List<Binding>();

                        foreach (ulong BindingID in m_CurrentAppearance.BindingIDs)
                            Bindings.Add(new Binding(ContentManager.GetResourceFromLongID(BindingID)));

                        m_Tex = Texture2D.FromFile(this.Device, new MemoryStream(
                            ContentManager.GetResourceFromLongID(Bindings[0].TextureAssetID)));

                        m_CurrentMesh = new Mesh(ContentManager.GetResourceFromLongID(Bindings[0].MeshAssetID), false);
                        LoadMesh(m_CurrentMesh);
                    }
                    else
                    {
                        PurchasableObject PO = new PurchasableObject(ContentManager.GetResourceFromLongID(Pair.Key));

                        m_CurrentOutfit = new Outfit(ContentManager.GetResourceFromLongID(PO.OutfitID));
                        m_CurrentAppearance = new Appearance(
                            ContentManager.GetResourceFromLongID(m_CurrentOutfit.LightAppearanceID));

                        LstAppearances.Items.Clear();
                        LstAppearances.Items.Add(m_CurrentOutfit.LightAppearanceID);
                        LstAppearances.Items.Add(m_CurrentOutfit.MediumAppearanceID);
                        LstAppearances.Items.Add(m_CurrentOutfit.DarkAppearanceID);

                        List<Binding> Bindings = new List<Binding>();

                        foreach (ulong BindingID in m_CurrentAppearance.BindingIDs)
                            Bindings.Add(new Binding(ContentManager.GetResourceFromLongID(BindingID)));

                        m_Tex = Texture2D.FromFile(this.Device, new MemoryStream(
                            ContentManager.GetResourceFromLongID(Bindings[0].TextureAssetID)));

                        //The file selected was most likely a body-mesh, so apply the adult skeleton to it.
                        if (Pair.Value.Contains("bodies"))
                        {
                            m_CurrentMesh = new Mesh(ContentManager.GetResourceFromLongID(Bindings[0].MeshAssetID), true);
                            m_CurrentMesh.TransformVertices2(m_Skeleton.Bones[0], ref mSimpleEffect);
                            m_CurrentMesh.BlendVertices2();
                            LoadMesh(m_CurrentMesh);
                        }
                        else
                        {
                            m_CurrentMesh = new Mesh(ContentManager.GetResourceFromLongID(Bindings[0].MeshAssetID), false);
                            LoadMesh(m_CurrentMesh);
                        }
                    }

                    m_LoadComplete = true;
                }
            }
        }
Пример #2
0
        /// <summary>
        /// User clicked on an item in the list containing available appearances.
        /// </summary>
        private void LstAppearances_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (m_Skeleton == null)
            {
                m_Skeleton = new Skeleton(this.Device, ContentManager.GetResourceFromLongID(0x100000005));
                m_Skeleton.AssignChildren(ref m_Skeleton);
            }

            m_CurrentAppearance = new Appearance(ContentManager.GetResourceFromLongID(
                (ulong)LstAppearances.SelectedItem));

            List<Binding> Bindings = new List<Binding>();

            foreach (ulong BindingID in m_CurrentAppearance.BindingIDs)
                Bindings.Add(new Binding(ContentManager.GetResourceFromLongID(BindingID)));

            m_Tex = Texture2D.FromFile(this.Device, new MemoryStream(
                ContentManager.GetResourceFromLongID(Bindings[0].TextureAssetID)));

            string SelectedStr = (string)LstHeads.SelectedItem;
            if (SelectedStr.Contains("bodies"))
            {
                m_CurrentMesh = new Mesh(ContentManager.GetResourceFromLongID(Bindings[0].MeshAssetID), true);
                m_CurrentMesh.TransformVertices2(m_Skeleton.Bones[0], ref mSimpleEffect);
                m_CurrentMesh.BlendVertices2();
            }
            else
                m_CurrentMesh = new Mesh(ContentManager.GetResourceFromLongID(Bindings[0].MeshAssetID), false);

            LoadMesh(m_CurrentMesh);
        }