public MaterialAnimation.SamplerKeyGroup GetSamplerData(MaterialAnimation materialAnimation) { MaterialAnimation.SamplerKeyGroup sampler = new MaterialAnimation.SamplerKeyGroup(materialAnimation); sampler.Text = samplerNameTB.Text; sampler.Constant = constantChkBox.Checked; return(sampler); }
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { if (ActiveMaterialAnim == null || !IsLoaded) { return; } var node = treeView1.SelectedNode; if (node.Tag is MaterialAnimation.Material) { } if (node.Tag is MaterialAnimation.SamplerKeyGroup) { activeSampler = (MaterialAnimation.SamplerKeyGroup)node.Tag; ReloadAnimationView(); } }
private void LoadAniamtion(MaterialAnimation anim, MaterialAnimation.SamplerKeyGroup activeSampler) { if (activeSampler == null || IsLoading) { return; } int imageIndex = 0; imgList.Images.Clear(); Images.Clear(); KeyFrames.Clear(); listViewCustom1.SmallImageList = imgList; listViewCustom1.Items.Clear(); listViewCustom1.View = View.SmallIcon; Thread Thread = new Thread((ThreadStart)(() => { IsLoading = true; for (int Frame = 0; Frame <= anim.FrameCount; Frame++) { //Constants always show so break after first frame if (activeSampler.Constant && Frame != 0) { break; } var keyFrame = activeSampler.GetKeyFrame(Frame); if (keyFrame.IsKeyed || activeSampler.Constant) { string TextureKey = activeSampler.GetActiveTextureNameByIndex((int)keyFrame.Value); var tex = activeSampler.GetActiveTexture((int)keyFrame.Value); if (tex != null) { Bitmap temp = tex.GetBitmap(); Images.Add(Frame, temp); KeyFrames.Add(Frame); if (listViewCustom1.InvokeRequired) { listViewCustom1.Invoke((MethodInvoker) delegate { // Running on the UI thread listViewCustom1.Items.Add($"{Frame} / {anim.FrameCount} \n" + tex.Text, imageIndex++); imgList.Images.Add(temp); var dummy = imgList.Handle; }); } else { listViewCustom1.Items.Add($"{Frame} / {anim.FrameCount} \n" + tex.Text, imageIndex++); } } else { if (listViewCustom1.InvokeRequired) { listViewCustom1.Invoke((MethodInvoker) delegate { listViewCustom1.Items.Add($"{Frame} / {anim.FrameCount} \n" + TextureKey, imageIndex++); }); } else { listViewCustom1.Items.Add($"{Frame} / {anim.FrameCount} \n" + TextureKey, imageIndex++); } } } } IsLoading = false; })); Thread.Start(); }
private void LoadAniamtion(MaterialAnimation anim, MaterialAnimation.SamplerKeyGroup activeSampler) { if (activeSampler == null || IsLoading) { return; } imgList.Images.Clear(); Images.Clear(); KeyFrames.Clear(); listViewCustom1.SmallImageList = imgList; listViewCustom1.Items.Clear(); listViewCustom1.View = View.SmallIcon; int ImageIndex = 0; for (int Frame = 0; Frame <= anim.FrameCount; Frame++) { //Constants always show so break after first frame if (activeSampler.Constant && Frame != 0) { break; } var keyFrame = activeSampler.GetKeyFrame(Frame); if (keyFrame.IsKeyed || activeSampler.Constant) { AddKeyFrame((int)keyFrame.Value, Frame, ImageIndex++); } } if (Thread != null && Thread.IsAlive) { Thread.Abort(); } Thread = new Thread((ThreadStart)(() => { for (int Frame = 0; Frame <= anim.FrameCount; Frame++) { //Constants always show so break after first frame if (activeSampler.Constant && Frame != 0) { break; } var keyFrame = activeSampler.GetKeyFrame(Frame); if (keyFrame.IsKeyed || activeSampler.Constant) { AddKeyFrameImage((int)keyFrame.Value, Frame); } } IsLoading = true; if (listViewCustom1.InvokeRequired) { listViewCustom1.Invoke((MethodInvoker) delegate { if (listViewCustom1.Items.Count > 0) { listViewCustom1.Items[0].Selected = true; listViewCustom1.Select(); } }); } else { if (listViewCustom1.Items.Count > 0) { listViewCustom1.Items[0].Selected = true; listViewCustom1.Select(); } } IsLoading = false; })); Thread.Start(); }