mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 20:44:14 +02:00
Allow setting masked joints for each animation.
This commit is contained in:
parent
20a931178d
commit
0e15c82e49
5 changed files with 51 additions and 0 deletions
|
@ -513,6 +513,7 @@ void MyAvatar::saveData(QSettings* settings) {
|
|||
settings->setValue("url", pointer->getURL());
|
||||
settings->setValue("fps", pointer->getFPS());
|
||||
settings->setValue("priority", pointer->getPriority());
|
||||
settings->setValue("maskedJoints", pointer->getMaskedJoints());
|
||||
}
|
||||
settings->endArray();
|
||||
|
||||
|
@ -579,6 +580,7 @@ void MyAvatar::loadData(QSettings* settings) {
|
|||
handle->setURL(settings->value("url").toUrl());
|
||||
handle->setFPS(loadSetting(settings, "fps", 30.0f));
|
||||
handle->setPriority(loadSetting(settings, "priority", 1.0f));
|
||||
handle->setMaskedJoints(settings->value("maskedJoints").toStringList());
|
||||
}
|
||||
settings->endArray();
|
||||
|
||||
|
|
|
@ -1684,6 +1684,11 @@ void AnimationHandle::setPriority(float priority) {
|
|||
}
|
||||
}
|
||||
|
||||
void AnimationHandle::setMaskedJoints(const QStringList& maskedJoints) {
|
||||
_maskedJoints = maskedJoints;
|
||||
_jointMappings.clear();
|
||||
}
|
||||
|
||||
void AnimationHandle::setRunning(bool running) {
|
||||
if ((_running = running)) {
|
||||
if (!_model->_runningAnimations.contains(_self)) {
|
||||
|
@ -1716,6 +1721,15 @@ void AnimationHandle::simulate(float deltaTime) {
|
|||
if (_jointMappings.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (!_maskedJoints.isEmpty()) {
|
||||
const FBXGeometry& geometry = _model->getGeometry()->getFBXGeometry();
|
||||
for (int i = 0; i < _jointMappings.size(); i++) {
|
||||
int& mapping = _jointMappings[i];
|
||||
if (mapping != -1 && _maskedJoints.contains(geometry.joints.at(mapping).name)) {
|
||||
mapping = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const FBXGeometry& animationGeometry = _animation->getGeometry();
|
||||
|
|
|
@ -393,6 +393,9 @@ public:
|
|||
void setLoop(bool loop) { _loop = loop; }
|
||||
bool getLoop() const { return _loop; }
|
||||
|
||||
void setMaskedJoints(const QStringList& maskedJoints);
|
||||
const QStringList& getMaskedJoints() const { return _maskedJoints; }
|
||||
|
||||
void setRunning(bool running);
|
||||
bool isRunning() const { return _running; }
|
||||
|
||||
|
@ -414,6 +417,7 @@ private:
|
|||
float _fps;
|
||||
float _priority;
|
||||
bool _loop;
|
||||
QStringList _maskedJoints;
|
||||
bool _running;
|
||||
QVector<int> _jointMappings;
|
||||
float _frameIndex;
|
||||
|
|
|
@ -100,6 +100,13 @@ AnimationPanel::AnimationPanel(AnimationsDialog* dialog, const AnimationHandlePo
|
|||
_priority->setValue(handle->getPriority());
|
||||
connect(_priority, SIGNAL(valueChanged(double)), SLOT(updateHandle()));
|
||||
|
||||
QHBoxLayout* maskedJointBox = new QHBoxLayout();
|
||||
layout->addRow("Masked Joints:", maskedJointBox);
|
||||
maskedJointBox->addWidget(_maskedJoints = new QLineEdit(handle->getMaskedJoints().join(", ")), 1);
|
||||
connect(_maskedJoints, SIGNAL(returnPressed()), SLOT(updateHandle()));
|
||||
maskedJointBox->addWidget(_chooseMaskedJoints = new QPushButton("Choose"));
|
||||
connect(_chooseMaskedJoints, SIGNAL(clicked(bool)), SLOT(chooseMaskedJoints()));
|
||||
|
||||
QPushButton* remove = new QPushButton("Delete");
|
||||
layout->addRow(remove);
|
||||
connect(remove, SIGNAL(clicked(bool)), SLOT(removeHandle()));
|
||||
|
@ -118,10 +125,31 @@ void AnimationPanel::chooseURL() {
|
|||
emit _url->returnPressed();
|
||||
}
|
||||
|
||||
void AnimationPanel::chooseMaskedJoints() {
|
||||
QMenu menu;
|
||||
QStringList maskedJoints = _handle->getMaskedJoints();
|
||||
foreach (const QString& jointName, Application::getInstance()->getAvatar()->getJointNames()) {
|
||||
QAction* action = menu.addAction(jointName);
|
||||
action->setCheckable(true);
|
||||
action->setChecked(maskedJoints.contains(jointName));
|
||||
}
|
||||
QAction* action = menu.exec(_chooseMaskedJoints->mapToGlobal(QPoint(0, 0)));
|
||||
if (action) {
|
||||
if (action->isChecked()) {
|
||||
maskedJoints.append(action->text());
|
||||
} else {
|
||||
maskedJoints.removeOne(action->text());
|
||||
}
|
||||
_handle->setMaskedJoints(maskedJoints);
|
||||
_maskedJoints->setText(maskedJoints.join(", "));
|
||||
}
|
||||
}
|
||||
|
||||
void AnimationPanel::updateHandle() {
|
||||
_handle->setURL(_url->text());
|
||||
_handle->setFPS(_fps->value());
|
||||
_handle->setPriority(_priority->value());
|
||||
_handle->setMaskedJoints(_maskedJoints->text().split(QRegExp("\\s*,\\s*")));
|
||||
}
|
||||
|
||||
void AnimationPanel::removeHandle() {
|
||||
|
|
|
@ -53,6 +53,7 @@ public:
|
|||
private slots:
|
||||
|
||||
void chooseURL();
|
||||
void chooseMaskedJoints();
|
||||
void updateHandle();
|
||||
void removeHandle();
|
||||
|
||||
|
@ -63,6 +64,8 @@ private:
|
|||
QLineEdit* _url;
|
||||
QDoubleSpinBox* _fps;
|
||||
QDoubleSpinBox* _priority;
|
||||
QLineEdit* _maskedJoints;
|
||||
QPushButton* _chooseMaskedJoints;
|
||||
bool _applying;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue