mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-27 04:10:24 +00:00
Trying to animate creatures
This commit is contained in:
parent
d035441876
commit
2ac1cc8aee
3 changed files with 55 additions and 9 deletions
|
@ -7,6 +7,7 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include <OgreVector3.h>
|
#include <OgreVector3.h>
|
||||||
|
#include <Ogre.h>
|
||||||
|
|
||||||
#include "components/esm/records.hpp"
|
#include "components/esm/records.hpp"
|
||||||
#include <components/esm_store/cell_store.hpp>
|
#include <components/esm_store/cell_store.hpp>
|
||||||
|
@ -90,6 +91,53 @@ bool OMW::Engine::frameStarted(const Ogre::FrameEvent& evt)
|
||||||
std::string effect;
|
std::string effect;
|
||||||
|
|
||||||
MWWorld::Ptr::CellStore *current = mEnvironment.mWorld->getPlayer().getPlayer().getCell();
|
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 the region has changed
|
||||||
if(!(current->cell->data.flags & current->cell->Interior) && timer.elapsed() >= 10){
|
if(!(current->cell->data.flags & current->cell->Interior) && timer.elapsed() >= 10){
|
||||||
timer.restart();
|
timer.restart();
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include "components/esm/records.hpp"
|
#include "components/esm/records.hpp"
|
||||||
#include "components/esm/loadcell.hpp"
|
#include "components/esm/loadcell.hpp"
|
||||||
#include <list>
|
#include <list>
|
||||||
|
#include <Ogre.h>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
@ -29,6 +30,8 @@ namespace ESMS
|
||||||
// The object that this instance is based on.
|
// The object that this instance is based on.
|
||||||
const X* base;
|
const X* base;
|
||||||
|
|
||||||
|
Ogre::Entity *model;
|
||||||
|
|
||||||
/* Information about this instance, such as 3D location and
|
/* Information about this instance, such as 3D location and
|
||||||
rotation and individual type-dependent data.
|
rotation and individual type-dependent data.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1225,20 +1225,15 @@ void NIFLoader::loadResource(Resource *resource)
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
else if (n != NULL)
|
//std::cout <"BE\n";
|
||||||
{
|
|
||||||
std::cout << "handle" << handle << "\n";
|
|
||||||
//handle++;
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// set skeleton
|
// set skeleton
|
||||||
if (!mSkel.isNull())
|
if (!mSkel.isNull() && mesh->isLoaded())
|
||||||
{
|
{
|
||||||
mesh->_notifySkeleton(mSkel);
|
mesh->_notifySkeleton(mSkel);
|
||||||
|
std::cout << "Skeleton notified\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// set skeleton
|
// set skeleton
|
||||||
|
|
Loading…
Reference in a new issue