mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-29 19:06:41 +00:00
Merge remote branch 'jhooks/animperform'
This commit is contained in:
commit
3d1cbcd4e7
4 changed files with 38 additions and 27 deletions
|
@ -276,6 +276,7 @@ namespace MWRender{
|
||||||
rotmult = bonePtr->getOrientation();
|
rotmult = bonePtr->getOrientation();
|
||||||
scale = bonePtr->getScale().x;
|
scale = bonePtr->getScale().x;
|
||||||
boneSequenceIter++;
|
boneSequenceIter++;
|
||||||
|
|
||||||
for(; boneSequenceIter != boneSequence.end(); boneSequenceIter++)
|
for(; boneSequenceIter != boneSequence.end(); boneSequenceIter++)
|
||||||
{
|
{
|
||||||
if(creaturemodel->getSkeleton()->hasBone(*boneSequenceIter)){
|
if(creaturemodel->getSkeleton()->hasBone(*boneSequenceIter)){
|
||||||
|
@ -330,7 +331,7 @@ namespace MWRender{
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
bool Animation::timeIndex( float time, std::vector<float> times, int & i, int & j, float & x ){
|
bool Animation::timeIndex( float time, const std::vector<float> & times, int & i, int & j, float & x ){
|
||||||
int count;
|
int count;
|
||||||
if ( (count = times.size()) > 0 )
|
if ( (count = times.size()) > 0 )
|
||||||
{
|
{
|
||||||
|
@ -388,6 +389,8 @@ namespace MWRender{
|
||||||
}
|
}
|
||||||
|
|
||||||
void Animation::handleAnimationTransforms(){
|
void Animation::handleAnimationTransforms(){
|
||||||
|
|
||||||
|
|
||||||
Ogre::SkeletonInstance* skel = base->getSkeleton();
|
Ogre::SkeletonInstance* skel = base->getSkeleton();
|
||||||
|
|
||||||
|
|
||||||
|
@ -404,10 +407,10 @@ namespace MWRender{
|
||||||
for(unsigned int i = 0; i < entityparts.size(); i++){
|
for(unsigned int i = 0; i < entityparts.size(); i++){
|
||||||
//Ogre::SkeletonInstance* skel = entityparts[i]->getSkeleton();
|
//Ogre::SkeletonInstance* skel = entityparts[i]->getSkeleton();
|
||||||
|
|
||||||
Ogre::Bone* b = skel->getRootBone();
|
//Ogre::Bone* b = skel->getRootBone();
|
||||||
b->setOrientation(Ogre::Real(.3),Ogre::Real(.3),Ogre::Real(.3), Ogre::Real(.3));//This is a trick
|
//b->setOrientation(Ogre::Real(.3),Ogre::Real(.3),Ogre::Real(.3), Ogre::Real(.3));//This is a trick
|
||||||
|
|
||||||
entityparts[i]->getAllAnimationStates()->_notifyDirty();
|
//entityparts[i]->getAllAnimationStates()->_notifyDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -424,18 +427,19 @@ namespace MWRender{
|
||||||
float x;
|
float x;
|
||||||
float x2;
|
float x2;
|
||||||
|
|
||||||
std::vector<Ogre::Quaternion> quats = iter->getQuat();
|
const std::vector<Ogre::Quaternion> & quats = iter->getQuat();
|
||||||
|
|
||||||
std::vector<float> ttime = iter->gettTime();
|
const std::vector<float> & ttime = iter->gettTime();
|
||||||
std::vector<float>::iterator ttimeiter = ttime.begin();
|
|
||||||
|
|
||||||
|
const std::vector<float> & rtime = iter->getrTime();
|
||||||
|
int rindexJ = rindexI[slot];
|
||||||
|
|
||||||
std::vector<float> rtime = iter->getrTime();
|
|
||||||
int rindexJ = 0;
|
|
||||||
timeIndex(time, rtime, rindexI[slot], rindexJ, x2);
|
timeIndex(time, rtime, rindexI[slot], rindexJ, x2);
|
||||||
int tindexJ = 0;
|
int tindexJ = tindexI[slot];
|
||||||
|
|
||||||
|
|
||||||
std::vector<Ogre::Vector3> translist1 = iter->getTranslist1();
|
const std::vector<Ogre::Vector3> & translist1 = iter->getTranslist1();
|
||||||
|
|
||||||
timeIndex(time, ttime, tindexI[slot], tindexJ, x);
|
timeIndex(time, ttime, tindexI[slot], tindexJ, x);
|
||||||
|
|
||||||
|
@ -443,34 +447,35 @@ namespace MWRender{
|
||||||
Ogre::Quaternion r;
|
Ogre::Quaternion r;
|
||||||
|
|
||||||
bool bTrans = translist1.size() > 0;
|
bool bTrans = translist1.size() > 0;
|
||||||
if(bTrans){
|
|
||||||
Ogre::Vector3 v1 = translist1[tindexI[slot]];
|
|
||||||
Ogre::Vector3 v2 = translist1[tindexJ];
|
|
||||||
t = (v1 + (v2 - v1) * x);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
bool bQuats = quats.size() > 0;
|
bool bQuats = quats.size() > 0;
|
||||||
if(bQuats){
|
|
||||||
r = Ogre::Quaternion::Slerp(x2, quats[rindexI[slot]], quats[rindexJ], true);
|
|
||||||
}
|
|
||||||
skel = base->getSkeleton();
|
|
||||||
if(skel->hasBone(iter->getBonename())){
|
if(skel->hasBone(iter->getBonename())){
|
||||||
Ogre::Bone* bone = skel->getBone(iter->getBonename());
|
Ogre::Bone* bone = skel->getBone(iter->getBonename());
|
||||||
if(bTrans)
|
if(bTrans){
|
||||||
|
Ogre::Vector3 v1 = translist1[tindexI[slot]];
|
||||||
|
Ogre::Vector3 v2 = translist1[tindexJ];
|
||||||
|
t = (v1 + (v2 - v1) * x);
|
||||||
bone->setPosition(t);
|
bone->setPosition(t);
|
||||||
if(bQuats)
|
|
||||||
|
}
|
||||||
|
if(bQuats){
|
||||||
|
r = Ogre::Quaternion::Slerp(x2, quats[rindexI[slot]], quats[rindexJ], true);
|
||||||
bone->setOrientation(r);
|
bone->setOrientation(r);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
skel->_updateTransforms();
|
|
||||||
base->getAllAnimationStates()->_notifyDirty();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
slot++;
|
slot++;
|
||||||
}
|
}
|
||||||
|
skel->_updateTransforms();
|
||||||
|
base->getAllAnimationStates()->_notifyDirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ class Animation{
|
||||||
static std::map<std::string, int> mUniqueIDs;
|
static std::map<std::string, int> mUniqueIDs;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::vector<std::vector<Nif::NiTriShapeCopy>* > shapeparts; //All the NiTriShape data that we need for animating an npc
|
std::vector<std::vector<Nif::NiTriShapeCopy>* > shapeparts; //All the NiTriShape data that we need for animating an npc
|
||||||
|
|
||||||
float time;
|
float time;
|
||||||
|
@ -55,7 +56,7 @@ class Animation{
|
||||||
Ogre::Entity* base;
|
Ogre::Entity* base;
|
||||||
void handleShapes(std::vector<Nif::NiTriShapeCopy>* allshapes, Ogre::Entity* creaturemodel, Ogre::SkeletonInstance *skel);
|
void handleShapes(std::vector<Nif::NiTriShapeCopy>* allshapes, Ogre::Entity* creaturemodel, Ogre::SkeletonInstance *skel);
|
||||||
void handleAnimationTransforms();
|
void handleAnimationTransforms();
|
||||||
bool timeIndex( float time, std::vector<float> times, int & i, int & j, float & x );
|
bool timeIndex( float time, const std::vector<float> & times, int & i, int & j, float & x );
|
||||||
std::string getUniqueID(std::string mesh);
|
std::string getUniqueID(std::string mesh);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -42,6 +42,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O
|
||||||
std::string bodyRaceID = headID.substr(0, headID.find_last_of("head_") - 4);
|
std::string bodyRaceID = headID.substr(0, headID.find_last_of("head_") - 4);
|
||||||
char secondtolast = bodyRaceID.at(bodyRaceID.length() - 2);
|
char secondtolast = bodyRaceID.at(bodyRaceID.length() - 2);
|
||||||
bool female = tolower(secondtolast) == 'f';
|
bool female = tolower(secondtolast) == 'f';
|
||||||
|
std::transform(bodyRaceID.begin(), bodyRaceID.end(), bodyRaceID.begin(), ::tolower);
|
||||||
bool beast = bodyRaceID == "b_n_khajiit_m_" || bodyRaceID == "b_n_khajiit_f_" || bodyRaceID == "b_n_argonian_m_" || bodyRaceID == "b_n_argonian_f_";
|
bool beast = bodyRaceID == "b_n_khajiit_m_" || bodyRaceID == "b_n_khajiit_f_" || bodyRaceID == "b_n_argonian_m_" || bodyRaceID == "b_n_argonian_f_";
|
||||||
|
|
||||||
/*std::cout << "Race: " << ref->base->race ;
|
/*std::cout << "Race: " << ref->base->race ;
|
||||||
|
@ -276,6 +277,7 @@ void NpcAnimation::runAnimation(float timepassed){
|
||||||
shapepartsiter++;
|
shapepartsiter++;
|
||||||
entitypartsiter++;
|
entitypartsiter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1330,7 +1330,10 @@ void NIFLoader::loadResource(Resource *resource)
|
||||||
|
|
||||||
(*iter)->addBoneAssignment(vba);
|
(*iter)->addBoneAssignment(vba);
|
||||||
}
|
}
|
||||||
mesh->_notifySkeleton(mSkel);
|
//Don't link on npc parts to eliminate redundant skeletons
|
||||||
|
//Will have to be changed later slightly for robes/skirts
|
||||||
|
if(triname == "")
|
||||||
|
mesh->_notifySkeleton(mSkel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue