/// <summary> /// User clicked on an item in the list containing available heads. /// </summary> private void LstHeads_SelectedIndexChanged(object sender, EventArgs e) { if (m_Skeleton == null) m_Skeleton = new Skeleton(this.Device, ContentManager.GetResourceFromLongID(0x100000005), ref mWorldMat); string SelectedStr = (string)LstHeads.SelectedItem; string Type = SelectedStr.Split(":".ToCharArray())[0]; SelectedStr = SelectedStr.Split(":".ToCharArray())[1].Replace(" ", ""); foreach(KeyValuePair<ulong, string> Pair in ContentManager.Resources) { //HAndGroup files are used to group together different hand meshes and textures. if (Pair.Key == Convert.ToUInt64(SelectedStr, 16) && Type == "Hand") { 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_HandTex = Texture2D.FromFile(this.Device, new MemoryStream( ContentManager.GetResourceFromLongID(Bindings[0].TextureAssetID))); m_CurrentHandMesh = new Mesh(ContentManager.GetResourceFromLongID(Bindings[0].MeshAssetID), false); m_CurrentHandMesh.ProcessMesh(m_Skeleton); } else { //Check if the selected hexstring equals a ulong ID in ContentManager. if (Pair.Key == Convert.ToUInt64(SelectedStr, 16)) { 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_HeadTex = Texture2D.FromFile(this.Device, new MemoryStream( ContentManager.GetResourceFromLongID(Bindings[0].TextureAssetID))); m_CurrentHeadMesh = new Mesh(ContentManager.GetResourceFromLongID(Bindings[0].MeshAssetID), false); m_CurrentHeadMesh.ProcessMesh(m_Skeleton); } } } m_LoadHeadComplete = true; }
/// <summary> /// User clicked on an item in the list containing available heads. /// </summary> private void LstBodies_SelectedIndexChanged(object sender, EventArgs e) { if (m_Skeleton == null) m_Skeleton = new Skeleton(this.Device, ContentManager.GetResourceFromLongID(0x100000005), mWorldMat); string SelectedStr = (string)LstBodies.SelectedItem; string Type = SelectedStr.Split(":".ToCharArray())[0]; SelectedStr = SelectedStr.Split(":".ToCharArray())[1].Replace(" ", ""); foreach (KeyValuePair<ulong, string> Pair in ContentManager.Resources) { //Check if the selected hexstring equals a ulong ID in ContentManager. if (Pair.Key == Convert.ToUInt64(SelectedStr, 16)) { 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_BodyTex = 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_CurrentBodyMesh = new Mesh(ContentManager.GetResourceFromLongID(Bindings[0].MeshAssetID), true); m_CurrentBodyMesh.TransformVertices2(ref m_Skeleton, m_Skeleton.Bones[0], ref mWorldMat); m_CurrentBodyMesh.BlendVertices2(); m_CurrentBodyMesh.ProcessMesh(m_Skeleton); } } } m_LoadBodyComplete = true; }
/// <summary> /// User clicked on an item in the list containing available heads. /// </summary> private void LstBodies_SelectedIndexChanged(object sender, EventArgs e) { string SelectedStr = (string)LstBodies.SelectedItem; SelectedStr = SelectedStr.Split(":".ToCharArray())[1].Replace(" ", ""); m_BodySelected = true; m_HeadSelected = false; foreach (KeyValuePair<ulong, string> Pair in ContentManager.Resources) { //Check if the selected hexstring equals a ulong ID in ContentManager. if (Pair.Key == Convert.ToUInt64(SelectedStr, 16)) { 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_RenderSim.AddBodyTexture(this.Device, 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_RenderSim.AddBodyMesh(Bindings[0].MeshAssetID); break; } } } m_LoadBodyComplete = true; }