From 0ce25159acfd2e4c257b69f0b6bf188c85b7fea6 Mon Sep 17 00:00:00 2001 From: turanszkij Date: Thu, 27 Apr 2017 23:41:24 +0200 Subject: [PATCH] updated animation window --- WickedEngine/AnimationWindow.cpp | 86 +++++++++++++++++++++++++++++++- WickedEngine/AnimationWindow.h | 7 +++ 2 files changed, 92 insertions(+), 1 deletion(-) diff --git a/WickedEngine/AnimationWindow.cpp b/WickedEngine/AnimationWindow.cpp index cd43d4244..acf48672c 100644 --- a/WickedEngine/AnimationWindow.cpp +++ b/WickedEngine/AnimationWindow.cpp @@ -11,13 +11,15 @@ AnimationWindow::AnimationWindow(wiGUI* gui) :GUI(gui) animWindow = new wiWindow(GUI, "Animation Window"); - animWindow->SetSize(XMFLOAT2(600, 300)); + animWindow->SetSize(XMFLOAT2(600, 450)); GUI->AddWidget(animWindow); float x = 200; float y = 0; float step = 35; + //////////////////////////////////// + actionsComboBox = new wiComboBox("Primary Action: "); actionsComboBox->SetSize(XMFLOAT2(300, 20)); actionsComboBox->SetPos(XMFLOAT2(x, y += step)); @@ -56,6 +58,7 @@ AnimationWindow::AnimationWindow(wiGUI* gui) :GUI(gui) }); animWindow->AddWidget(loopedCheckBox); + ///////////////////////////////////// actionsComboBox1 = new wiComboBox("Secondary Action 1: "); @@ -106,6 +109,60 @@ AnimationWindow::AnimationWindow(wiGUI* gui) :GUI(gui) weightSlider1->SetTooltip("Adjust the blend weight for the secondary action..."); animWindow->AddWidget(weightSlider1); + ///////////////////////////////////// + + + actionsComboBox2 = new wiComboBox("Secondary Action 2: "); + actionsComboBox2->SetSize(XMFLOAT2(300, 20)); + actionsComboBox2->SetPos(XMFLOAT2(x, y += step * 2)); + actionsComboBox2->OnSelect([&](wiEventArgs args) { + if (armature != nullptr && args.iValue >= 0) + { + armature->ChangeAction(args.sValue, blendSlider2->GetValue(), "SECONDARY2", weightSlider2->GetValue()); + } + }); + actionsComboBox2->SetEnabled(false); + actionsComboBox2->SetTooltip("Choose an animation clip for a secondary slot..."); + animWindow->AddWidget(actionsComboBox2); + + blendSlider2 = new wiSlider(0.0f, 60, 0, 100000, "Blend Frames 2: "); + blendSlider2->SetSize(XMFLOAT2(100, 30)); + blendSlider2->SetPos(XMFLOAT2(x, y += step)); + blendSlider2->OnSlide([&](wiEventArgs args) { + // no operation, will only be queried + }); + blendSlider2->SetEnabled(false); + blendSlider2->SetTooltip("Adjust the blend length in frames when changing actions..."); + animWindow->AddWidget(blendSlider2); + + loopedCheckBox2 = new wiCheckBox("Looped: "); + loopedCheckBox2->SetTooltip("Toggle animation looping behaviour."); + loopedCheckBox2->SetPos(XMFLOAT2(470, y)); + loopedCheckBox2->OnClick([&](wiEventArgs args) { + if (armature != nullptr) + { + AnimationLayer* layer2 = armature->GetAnimLayer("SECONDARY2"); + if (layer2 != nullptr) + { + layer2->looped = args.bValue; + } + } + }); + animWindow->AddWidget(loopedCheckBox2); + + weightSlider2 = new wiSlider(0.0f, 1.0f, 1.0f, 100000, "Blend Weight 2: "); + weightSlider2->SetSize(XMFLOAT2(100, 30)); + weightSlider2->SetPos(XMFLOAT2(x, y += step)); + weightSlider2->OnSlide([&](wiEventArgs args) { + // no operation, will only be queried + }); + weightSlider2->SetEnabled(false); + weightSlider2->SetTooltip("Adjust the blend weight for the secondary action..."); + animWindow->AddWidget(weightSlider2); + + + /////////////////////////////////////////////////// + animWindow->Translate(XMFLOAT3(100, 50, 0)); animWindow->SetVisible(false); @@ -125,6 +182,11 @@ AnimationWindow::~AnimationWindow() SAFE_DELETE(weightSlider1); SAFE_DELETE(blendSlider1); SAFE_DELETE(loopedCheckBox1); + + SAFE_DELETE(actionsComboBox2); + SAFE_DELETE(weightSlider2); + SAFE_DELETE(blendSlider2); + SAFE_DELETE(loopedCheckBox2); } void AnimationWindow::SetArmature(Armature* armature) @@ -163,6 +225,22 @@ void AnimationWindow::SetArmature(Armature* armature) loopedCheckBox1->SetCheck(layer1->looped); } loopedCheckBox1->SetEnabled(true); + + actionsComboBox2->ClearItems(); + actionsComboBox2->SetEnabled(true); + for (auto& x : armature->actions) + { + actionsComboBox2->AddItem(x.name); + } + actionsComboBox2->SetSelected(0); + blendSlider2->SetEnabled(true); + weightSlider2->SetEnabled(true); + AnimationLayer* layer2 = armature->GetAnimLayer("SECONDARY2"); + if (layer2 != nullptr) + { + loopedCheckBox2->SetCheck(layer2->looped); + } + loopedCheckBox2->SetEnabled(true); } else { @@ -176,5 +254,11 @@ void AnimationWindow::SetArmature(Armature* armature) blendSlider1->SetEnabled(false); weightSlider1->SetEnabled(false); loopedCheckBox1->SetEnabled(false); + + actionsComboBox2->ClearItems(); + actionsComboBox2->SetEnabled(false); + blendSlider2->SetEnabled(false); + weightSlider2->SetEnabled(false); + loopedCheckBox2->SetEnabled(false); } } diff --git a/WickedEngine/AnimationWindow.h b/WickedEngine/AnimationWindow.h index 4c0d09b20..9fd482111 100644 --- a/WickedEngine/AnimationWindow.h +++ b/WickedEngine/AnimationWindow.h @@ -23,9 +23,16 @@ public: wiSlider* blendSlider; wiCheckBox* loopedCheckBox; + // TODO: nicer way to control arbitrary amount of animation layers.... + wiComboBox* actionsComboBox1; wiSlider* blendSlider1; wiSlider* weightSlider1; wiCheckBox* loopedCheckBox1; + + wiComboBox* actionsComboBox2; + wiSlider* blendSlider2; + wiSlider* weightSlider2; + wiCheckBox* loopedCheckBox2; };