Trying to animate creatures

actorid
Jason Hooks 14 years ago
parent d035441876
commit 2ac1cc8aee

@ -7,6 +7,7 @@
#include <utility>
#include <OgreVector3.h>
#include <Ogre.h>
#include "components/esm/records.hpp"
#include <components/esm_store/cell_store.hpp>
@ -90,6 +91,53 @@ bool OMW::Engine::frameStarted(const Ogre::FrameEvent& evt)
std::string effect;
MWWorld::Ptr::CellStore *current = mEnvironment.mWorld->getPlayer().getPlayer().getCell();
/*
ESMS::CellRefList<ESM::Creature,MWWorld::RefData>::List creatureData = (current->creatures).list;
ESMS::CellRefList<ESM::Creature,MWWorld::RefData>::List::iterator creaturedataiter = creatureData.begin();
for(int i = 0; i < creatureData.size(); i++)
{
//std::cout << "Testing" << i < "\n";
ESMS::LiveCellRef<ESM::Creature,MWWorld::RefData> item = *creaturedataiter;
Ogre::Entity* creaturemodel = item.model;
if(evt.timeSinceLastFrame == 0)
creaturemodel->getSkeleton()->setBindingPose();
creaturemodel->getSkeleton()->setBlendMode(Ogre::SkeletonAnimationBlendMode::ANIMBLEND_AVERAGE); //ANIMBLEND_AVERAGE
Ogre::AnimationState *mAnimationState = creaturemodel->getAnimationState("WholeThing");
mAnimationState->setWeight(.5);
mAnimationState->setLoop(true);
//npcmodel->getSkeleton()->
mAnimationState->setEnabled(true);
Ogre::AnimationState *mAnimationState2 = creaturemodel->getAnimationState("WholeThing2");
mAnimationState2->setLoop(true);
mAnimationState2->setWeight(.5);
mAnimationState2->setEnabled(true);
mAnimationState2->createBlendMask(creaturemodel->getSkeleton()->getNumBones(),1);
mAnimationState->createBlendMask(creaturemodel->getSkeleton()->getNumBones(),1);
for(int j = 2; j < creaturemodel->getSkeleton()->getNumBones(); j++)
{
mAnimationState->setBlendMaskEntry(j,1);
mAnimationState2->setBlendMaskEntry(j,1);
}
// set skeleton
std::cout << "TimePosition:" << mAnimationState->getTimePosition() << "\n";
mAnimationState->addTime(evt.timeSinceLastFrame);
mAnimationState2->addTime(evt.timeSinceLastFrame);
//npcmodel->_updateAnimation();
//mAnimationState2->setEnabled(true);
creaturedataiter++;
}*/
//If the region has changed
if(!(current->cell->data.flags & current->cell->Interior) && timer.elapsed() >= 10){
timer.restart();

@ -14,6 +14,7 @@
#include "components/esm/records.hpp"
#include "components/esm/loadcell.hpp"
#include <list>
#include <Ogre.h>
#include <iostream>
#include <stdexcept>
@ -29,6 +30,8 @@ namespace ESMS
// The object that this instance is based on.
const X* base;
Ogre::Entity *model;
/* Information about this instance, such as 3D location and
rotation and individual type-dependent data.
*/

@ -1225,20 +1225,15 @@ void NIFLoader::loadResource(Resource *resource)
}
/*
else if (n != NULL)
{
std::cout << "handle" << handle << "\n";
//handle++;
}*/
//std::cout <"BE\n";
}
// set skeleton
if (!mSkel.isNull())
if (!mSkel.isNull() && mesh->isLoaded())
{
mesh->_notifySkeleton(mSkel);
std::cout << "Skeleton notified\n";
}
// set skeleton

Loading…
Cancel
Save