Skip to content

Commit

Permalink
ENGINES: Play head animations for full body models in K1/K2
Browse files Browse the repository at this point in the history
  • Loading branch information
vkremianskii committed Jun 12, 2018
1 parent ae837ff commit ec5bd19
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 12 deletions.
32 changes: 26 additions & 6 deletions src/engines/kotor/creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

#include "src/graphics/aurora/modelnode.h"
#include "src/graphics/aurora/model.h"
#include "src/graphics/aurora/animationchannel.h"

#include "src/engines/aurora/util.h"
#include "src/engines/aurora/model.h"
Expand Down Expand Up @@ -315,6 +316,9 @@ void Creature::loadBody(PartModels &parts) {

_model->setTag(_tag);
_model->setClickable(isClickable());

if (_modelType != "B" && _modelType != "P")
_model->addAnimationChannel(Graphics::Aurora::kAnimationChannelHead);
}

void Creature::loadHead(PartModels &parts) {
Expand Down Expand Up @@ -469,9 +473,17 @@ void Creature::playDefaultHeadAnimation() {
if (!_model)
return;

Graphics::Aurora::Model *head = _model->getAttachedModel("headhook");
if (head)
head->playDefaultAnimation();
Graphics::Aurora::AnimationChannel *headChannel = 0;

if (_modelType == "B" || _modelType == "P") {
Graphics::Aurora::Model *head = _model->getAttachedModel("headhook");
if (head)
headChannel = head->getAnimationChannel(Graphics::Aurora::kAnimationChannelAll);
} else
headChannel = _model->getAnimationChannel(Graphics::Aurora::kAnimationChannelHead);

if (headChannel)
headChannel->playDefaultAnimation();
}

void Creature::playAnimation(const Common::UString &anim, bool restart, float length, float speed) {
Expand All @@ -483,9 +495,17 @@ void Creature::playHeadAnimation(const Common::UString &anim, bool restart, floa
if (!_model)
return;

Graphics::Aurora::Model *head = _model->getAttachedModel("headhook");
if (head)
head->playAnimation(anim, restart, length, speed);
Graphics::Aurora::AnimationChannel *headChannel = 0;

if (_modelType == "B" || _modelType == "P") {
Graphics::Aurora::Model *head = _model->getAttachedModel("headhook");
if (head)
headChannel = head->getAnimationChannel(Graphics::Aurora::kAnimationChannelAll);
} else
headChannel = _model->getAnimationChannel(Graphics::Aurora::kAnimationChannelHead);

if (headChannel)
headChannel->playAnimation(anim, restart, length, speed);
}

void Creature::setDefaultAnimations() {
Expand Down
32 changes: 26 additions & 6 deletions src/engines/kotor2/creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

#include "src/graphics/aurora/modelnode.h"
#include "src/graphics/aurora/model.h"
#include "src/graphics/aurora/animationchannel.h"

#include "src/engines/aurora/util.h"
#include "src/engines/aurora/model.h"
Expand Down Expand Up @@ -243,6 +244,9 @@ void Creature::loadBody(PartModels &parts) {

_model->setTag(_tag);
_model->setClickable(isClickable());

if (_modelType != "B" && _modelType != "P")
_model->addAnimationChannel(Graphics::Aurora::kAnimationChannelHead);
}

void Creature::loadHead(PartModels &parts) {
Expand Down Expand Up @@ -329,9 +333,17 @@ void Creature::playDefaultHeadAnimation() {
if (!_model)
return;

Graphics::Aurora::Model *head = _model->getAttachedModel("headhook");
if (head)
head->playDefaultAnimation();
Graphics::Aurora::AnimationChannel *headChannel = 0;

if (_modelType == "B" || _modelType == "P") {
Graphics::Aurora::Model *head = _model->getAttachedModel("headhook");
if (head)
headChannel = head->getAnimationChannel(Graphics::Aurora::kAnimationChannelAll);
} else
headChannel = _model->getAnimationChannel(Graphics::Aurora::kAnimationChannelHead);

if (headChannel)
headChannel->playDefaultAnimation();
}

void Creature::playAnimation(const Common::UString &anim, bool restart, float length, float speed) {
Expand All @@ -343,9 +355,17 @@ void Creature::playHeadAnimation(const Common::UString &anim, bool restart, floa
if (!_model)
return;

Graphics::Aurora::Model *head = _model->getAttachedModel("headhook");
if (head)
head->playAnimation(anim, restart, length, speed);
Graphics::Aurora::AnimationChannel *headChannel = 0;

if (_modelType == "B" || _modelType == "P") {
Graphics::Aurora::Model *head = _model->getAttachedModel("headhook");
if (head)
headChannel = head->getAnimationChannel(Graphics::Aurora::kAnimationChannelAll);
} else
headChannel = _model->getAnimationChannel(Graphics::Aurora::kAnimationChannelHead);

if (headChannel)
headChannel->playAnimation(anim, restart, length, speed);
}

void Creature::setDefaultAnimations() {
Expand Down

0 comments on commit ec5bd19

Please sign in to comment.