updated animation window

This commit is contained in:
turanszkij
2017-04-27 23:41:24 +02:00
parent 84ada93938
commit 0ce25159ac
2 changed files with 92 additions and 1 deletions
+85 -1
View File
@@ -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);
}
}
+7
View File
@@ -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;
};