forked from mirror/openmw-tes3mp
A different way
This commit is contained in:
parent
653d999ac4
commit
a6b88b48ec
8 changed files with 51 additions and 46 deletions
|
@ -47,7 +47,7 @@ namespace MWClass
|
|||
const std::string &model = ref->base->model;
|
||||
assert (ref->base != NULL);
|
||||
if(!model.empty()){
|
||||
physics.insertActorPhysics(ptr, "meshes\\" + model);
|
||||
// physics.insertActorPhysics(ptr, "meshes\\" + model);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -49,11 +49,11 @@ namespace MWClass
|
|||
std::string bodyRaceID = headID.substr(0, headID.find_last_of("head_") - 4);
|
||||
bool beast = bodyRaceID == "b_n_khajiit_m_" || bodyRaceID == "b_n_khajiit_f_" || bodyRaceID == "b_n_argonian_m_" || bodyRaceID == "b_n_argonian_f_";
|
||||
|
||||
|
||||
/*
|
||||
std::string smodel = "meshes\\base_anim.nif";
|
||||
if(beast)
|
||||
smodel = "meshes\\base_animkna.nif";
|
||||
physics.insertActorPhysics(ptr, smodel);
|
||||
physics.insertActorPhysics(ptr, smodel);*/
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -155,7 +155,7 @@ namespace MWRender{
|
|||
*addr = absVertPos.x;
|
||||
*(addr+1) = absVertPos.y;
|
||||
*(addr+2) = absVertPos.z;
|
||||
std::cout << "We are actually 2\n";
|
||||
|
||||
//std::cout << "Vertex" << verIndex << "Weight: " << boneinfo.weights[i].weight << "was seen twice\n";
|
||||
|
||||
}
|
||||
|
@ -335,8 +335,18 @@ namespace MWRender{
|
|||
|
||||
}
|
||||
|
||||
void Animation::handleAnimationTransforms(){
|
||||
void Animation::handleAnimationTransforms(Ogre::Entity* entity){
|
||||
Ogre::SkeletonInstance* skel = entity->getSkeleton();
|
||||
|
||||
Ogre::Bone* b = skel->getRootBone();
|
||||
b->setOrientation(.3,.3,.3,.3); //This is a trick
|
||||
skel->getManualBonesDirty();
|
||||
skel->_updateTransforms();
|
||||
skel->_notifyManualBonesDirty();
|
||||
|
||||
entity->getAllAnimationStates()->_notifyDirty();
|
||||
entity->_updateAnimation();
|
||||
entity->_notifyMoved();
|
||||
|
||||
std::vector<Nif::NiKeyframeData>::iterator iter;
|
||||
int slot = 0;
|
||||
|
@ -345,6 +355,7 @@ namespace MWRender{
|
|||
if(time < iter->getStartTime() || time < startTime || time > iter->getStopTime())
|
||||
{
|
||||
continue;
|
||||
slot++;
|
||||
}
|
||||
|
||||
if(skel->hasBone(iter->getBonename())){
|
||||
|
@ -388,11 +399,12 @@ namespace MWRender{
|
|||
skel->_updateTransforms();
|
||||
skel->_notifyManualBonesDirty();
|
||||
|
||||
Ogre::Entity* ent = base;
|
||||
|
||||
ent->getAllAnimationStates()->_notifyDirty();
|
||||
ent->_updateAnimation();
|
||||
ent->_notifyMoved();
|
||||
|
||||
|
||||
entity->getAllAnimationStates()->_notifyDirty();
|
||||
entity->_updateAnimation();
|
||||
entity->_notifyMoved();
|
||||
}
|
||||
slot++;
|
||||
}
|
||||
|
|
|
@ -33,7 +33,9 @@ class Animation{
|
|||
int shapeNumber;
|
||||
std::vector<std::vector<int>> shapeIndexI;
|
||||
|
||||
Ogre::SkeletonInstance* skel;
|
||||
//Ogre::SkeletonInstance* skel;
|
||||
std::vector<Nif::NiTriShapeCopy>* shapes; //All the NiTriShapeData for this creature
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -41,7 +43,7 @@ class Animation{
|
|||
std::map<std::string,float> textmappings;
|
||||
Ogre::Entity* base;
|
||||
void handleShapes(std::vector<Nif::NiTriShapeCopy>* allshapes, Ogre::Entity* creaturemodel, Ogre::SkeletonInstance *skel);
|
||||
void handleAnimationTransforms();
|
||||
void handleAnimationTransforms(Ogre::Entity* model);
|
||||
bool timeIndex( float time, std::vector<float> times, int & i, int & j, float & x );
|
||||
std::string getUniqueID(std::string mesh);
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@ CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr, MWWorld::Environme
|
|||
//a.tindexJ.push_back(0);
|
||||
}
|
||||
loop = false;
|
||||
skel = base->getSkeleton();
|
||||
stopTime = transformations->begin()->getStopTime();
|
||||
//a.startTime = NIFLoader::getSingletonPtr()->getTime(item.smodel, "IdleSneak: Start");
|
||||
startTime = transformations->begin()->getStartTime();
|
||||
|
@ -50,18 +49,9 @@ void CreatureAnimation::runAnimation(float timepassed){
|
|||
|
||||
//Handle the shapes dependent on animation transforms
|
||||
time += timepassed;
|
||||
Ogre::Bone* b = skel->getRootBone();
|
||||
b->setOrientation(.3,.3,.3,.3); //This is a trick
|
||||
skel->getManualBonesDirty();
|
||||
skel->_updateTransforms();
|
||||
skel->_notifyManualBonesDirty();
|
||||
|
||||
base->getAllAnimationStates()->_notifyDirty();
|
||||
base->_updateAnimation();
|
||||
base->_notifyMoved();
|
||||
|
||||
handleAnimationTransforms();
|
||||
handleShapes(shapes, base, skel);
|
||||
handleAnimationTransforms(base);
|
||||
handleShapes(shapes, base, base->getSkeleton());
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
namespace MWRender{
|
||||
|
||||
class CreatureAnimation: public Animation{
|
||||
std::vector<Nif::NiTriShapeCopy>* shapes; //All the NiTriShapeData for this creature
|
||||
|
||||
public:
|
||||
~CreatureAnimation();
|
||||
CreatureAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend);
|
||||
|
|
|
@ -50,7 +50,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O
|
|||
if(beast)
|
||||
smodel = "meshes\\base_animkna.nif";
|
||||
|
||||
Ogre::SceneNode* insert = ptr.getRefData().getBaseNode();
|
||||
insert = ptr.getRefData().getBaseNode();
|
||||
assert(insert);
|
||||
|
||||
NifOgre::NIFLoader::load(smodel);
|
||||
|
@ -67,7 +67,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O
|
|||
//a.tindexJ.push_back(0);
|
||||
}
|
||||
loop = false;
|
||||
skel = base->getSkeleton();
|
||||
|
||||
stopTime = transformations->begin()->getStopTime();
|
||||
//a.startTime = NIFLoader::getSingletonPtr()->getTime(item.smodel, "IdleSneak: Start");
|
||||
startTime = transformations->begin()->getStartTime();
|
||||
|
@ -207,13 +207,13 @@ void NpcAnimation::insertFreePart(const std::string &mesh, const std::string suf
|
|||
std::string meshNumbered = mesh + getUniqueID(mesh + suffix) + suffix;
|
||||
NIFLoader::load(meshNumbered);
|
||||
|
||||
hand = mRend.getScene()->createEntity(meshNumbered);
|
||||
insert->attachObject(hand);
|
||||
//entityparts.push_back(ent);
|
||||
std::vector<Nif::NiTriShapeCopy>* shapes = ((NIFLoader::getSingletonPtr())->getShapes(mesh + "0000" + suffix));
|
||||
Ogre::Entity* ent = mRend.getScene()->createEntity(meshNumbered);
|
||||
insert->attachObject(ent);
|
||||
entityparts.push_back(ent);
|
||||
shapes = ((NIFLoader::getSingletonPtr())->getShapes(mesh + "0000" + suffix));
|
||||
if(shapes){
|
||||
shapeparts.push_back(shapes);
|
||||
handleShapes(shapes, hand, skel);
|
||||
handleShapes(shapes, ent, base->getSkeleton());
|
||||
}
|
||||
|
||||
|
||||
|
@ -228,25 +228,25 @@ void NpcAnimation::runAnimation(float timepassed){
|
|||
//Handle the shapes dependent on animation transforms
|
||||
if(animate){
|
||||
time += timepassed;
|
||||
Ogre::Bone* b = skel->getRootBone();
|
||||
b->setOrientation(.3,.3,.3,.3); //This is a trick
|
||||
skel->getManualBonesDirty();
|
||||
skel->_updateTransforms();
|
||||
skel->_notifyManualBonesDirty();
|
||||
|
||||
base->getAllAnimationStates()->_notifyDirty();
|
||||
base->_updateAnimation();
|
||||
base->_notifyMoved();
|
||||
|
||||
|
||||
handleAnimationTransforms();
|
||||
|
||||
handleAnimationTransforms(base);
|
||||
// handleAnimationTransforms(base);
|
||||
//handleAnimationTransforms(hand);
|
||||
//
|
||||
std::vector<std::vector<Nif::NiTriShapeCopy>*>::iterator shapepartsiter = shapeparts.begin();
|
||||
std::vector<Ogre::Entity*>::iterator entitypartsiter = entityparts.begin();
|
||||
int i = 0;
|
||||
while(shapepartsiter != shapeparts.end() && entitypartsiter != entityparts.end())
|
||||
//int i = 0;
|
||||
while(shapepartsiter != shapeparts.end())
|
||||
{
|
||||
std::vector<Nif::NiTriShapeCopy>* shapes = *shapepartsiter;
|
||||
handleShapes(shapes, *entitypartsiter, skel);
|
||||
//insert->
|
||||
//insert->detachObject(hand->getName());
|
||||
Ogre::Entity* theentity = *entitypartsiter;
|
||||
handleAnimationTransforms(theentity);
|
||||
handleShapes(shapes, theentity, theentity->getSkeleton());
|
||||
//insert->attachObject(hand);
|
||||
//std::cout << "Shape part size" << shapes->size() << "\n";
|
||||
shapepartsiter++;
|
||||
entitypartsiter++;
|
||||
|
|
|
@ -17,6 +17,7 @@ namespace MWRender{
|
|||
class NpcAnimation: public Animation{
|
||||
std::vector<Ogre::Entity*> entityparts;
|
||||
Ogre::Entity* hand;
|
||||
Ogre::SceneNode* insert;
|
||||
std::vector<std::vector<Nif::NiTriShapeCopy>*> shapeparts; //All the NiTriShape data that we need for animating this particular npc
|
||||
public:
|
||||
NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend);
|
||||
|
|
Loading…
Reference in a new issue