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;
|
const std::string &model = ref->base->model;
|
||||||
assert (ref->base != NULL);
|
assert (ref->base != NULL);
|
||||||
if(!model.empty()){
|
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);
|
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_";
|
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";
|
std::string smodel = "meshes\\base_anim.nif";
|
||||||
if(beast)
|
if(beast)
|
||||||
smodel = "meshes\\base_animkna.nif";
|
smodel = "meshes\\base_animkna.nif";
|
||||||
physics.insertActorPhysics(ptr, smodel);
|
physics.insertActorPhysics(ptr, smodel);*/
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,7 +155,7 @@ namespace MWRender{
|
||||||
*addr = absVertPos.x;
|
*addr = absVertPos.x;
|
||||||
*(addr+1) = absVertPos.y;
|
*(addr+1) = absVertPos.y;
|
||||||
*(addr+2) = absVertPos.z;
|
*(addr+2) = absVertPos.z;
|
||||||
std::cout << "We are actually 2\n";
|
|
||||||
//std::cout << "Vertex" << verIndex << "Weight: " << boneinfo.weights[i].weight << "was seen twice\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;
|
std::vector<Nif::NiKeyframeData>::iterator iter;
|
||||||
int slot = 0;
|
int slot = 0;
|
||||||
|
@ -345,6 +355,7 @@ namespace MWRender{
|
||||||
if(time < iter->getStartTime() || time < startTime || time > iter->getStopTime())
|
if(time < iter->getStartTime() || time < startTime || time > iter->getStopTime())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
slot++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(skel->hasBone(iter->getBonename())){
|
if(skel->hasBone(iter->getBonename())){
|
||||||
|
@ -388,11 +399,12 @@ namespace MWRender{
|
||||||
skel->_updateTransforms();
|
skel->_updateTransforms();
|
||||||
skel->_notifyManualBonesDirty();
|
skel->_notifyManualBonesDirty();
|
||||||
|
|
||||||
Ogre::Entity* ent = base;
|
|
||||||
|
|
||||||
ent->getAllAnimationStates()->_notifyDirty();
|
|
||||||
ent->_updateAnimation();
|
|
||||||
ent->_notifyMoved();
|
entity->getAllAnimationStates()->_notifyDirty();
|
||||||
|
entity->_updateAnimation();
|
||||||
|
entity->_notifyMoved();
|
||||||
}
|
}
|
||||||
slot++;
|
slot++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,9 @@ class Animation{
|
||||||
int shapeNumber;
|
int shapeNumber;
|
||||||
std::vector<std::vector<int>> shapeIndexI;
|
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;
|
std::map<std::string,float> textmappings;
|
||||||
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(Ogre::Entity* model);
|
||||||
bool timeIndex( float time, std::vector<float> times, int & i, int & j, float & x );
|
bool timeIndex( float time, std::vector<float> times, int & i, int & j, float & x );
|
||||||
std::string getUniqueID(std::string mesh);
|
std::string getUniqueID(std::string mesh);
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,6 @@ CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr, MWWorld::Environme
|
||||||
//a.tindexJ.push_back(0);
|
//a.tindexJ.push_back(0);
|
||||||
}
|
}
|
||||||
loop = false;
|
loop = false;
|
||||||
skel = base->getSkeleton();
|
|
||||||
stopTime = transformations->begin()->getStopTime();
|
stopTime = transformations->begin()->getStopTime();
|
||||||
//a.startTime = NIFLoader::getSingletonPtr()->getTime(item.smodel, "IdleSneak: Start");
|
//a.startTime = NIFLoader::getSingletonPtr()->getTime(item.smodel, "IdleSneak: Start");
|
||||||
startTime = transformations->begin()->getStartTime();
|
startTime = transformations->begin()->getStartTime();
|
||||||
|
@ -50,18 +49,9 @@ void CreatureAnimation::runAnimation(float timepassed){
|
||||||
|
|
||||||
//Handle the shapes dependent on animation transforms
|
//Handle the shapes dependent on animation transforms
|
||||||
time += timepassed;
|
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();
|
handleAnimationTransforms(base);
|
||||||
base->_updateAnimation();
|
handleShapes(shapes, base, base->getSkeleton());
|
||||||
base->_notifyMoved();
|
|
||||||
|
|
||||||
handleAnimationTransforms();
|
|
||||||
handleShapes(shapes, base, skel);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
namespace MWRender{
|
namespace MWRender{
|
||||||
|
|
||||||
class CreatureAnimation: public Animation{
|
class CreatureAnimation: public Animation{
|
||||||
std::vector<Nif::NiTriShapeCopy>* shapes; //All the NiTriShapeData for this creature
|
|
||||||
public:
|
public:
|
||||||
~CreatureAnimation();
|
~CreatureAnimation();
|
||||||
CreatureAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend);
|
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)
|
if(beast)
|
||||||
smodel = "meshes\\base_animkna.nif";
|
smodel = "meshes\\base_animkna.nif";
|
||||||
|
|
||||||
Ogre::SceneNode* insert = ptr.getRefData().getBaseNode();
|
insert = ptr.getRefData().getBaseNode();
|
||||||
assert(insert);
|
assert(insert);
|
||||||
|
|
||||||
NifOgre::NIFLoader::load(smodel);
|
NifOgre::NIFLoader::load(smodel);
|
||||||
|
@ -67,7 +67,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O
|
||||||
//a.tindexJ.push_back(0);
|
//a.tindexJ.push_back(0);
|
||||||
}
|
}
|
||||||
loop = false;
|
loop = false;
|
||||||
skel = base->getSkeleton();
|
|
||||||
stopTime = transformations->begin()->getStopTime();
|
stopTime = transformations->begin()->getStopTime();
|
||||||
//a.startTime = NIFLoader::getSingletonPtr()->getTime(item.smodel, "IdleSneak: Start");
|
//a.startTime = NIFLoader::getSingletonPtr()->getTime(item.smodel, "IdleSneak: Start");
|
||||||
startTime = transformations->begin()->getStartTime();
|
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;
|
std::string meshNumbered = mesh + getUniqueID(mesh + suffix) + suffix;
|
||||||
NIFLoader::load(meshNumbered);
|
NIFLoader::load(meshNumbered);
|
||||||
|
|
||||||
hand = mRend.getScene()->createEntity(meshNumbered);
|
Ogre::Entity* ent = mRend.getScene()->createEntity(meshNumbered);
|
||||||
insert->attachObject(hand);
|
insert->attachObject(ent);
|
||||||
//entityparts.push_back(ent);
|
entityparts.push_back(ent);
|
||||||
std::vector<Nif::NiTriShapeCopy>* shapes = ((NIFLoader::getSingletonPtr())->getShapes(mesh + "0000" + suffix));
|
shapes = ((NIFLoader::getSingletonPtr())->getShapes(mesh + "0000" + suffix));
|
||||||
if(shapes){
|
if(shapes){
|
||||||
shapeparts.push_back(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
|
//Handle the shapes dependent on animation transforms
|
||||||
if(animate){
|
if(animate){
|
||||||
time += timepassed;
|
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<std::vector<Nif::NiTriShapeCopy>*>::iterator shapepartsiter = shapeparts.begin();
|
||||||
std::vector<Ogre::Entity*>::iterator entitypartsiter = entityparts.begin();
|
std::vector<Ogre::Entity*>::iterator entitypartsiter = entityparts.begin();
|
||||||
int i = 0;
|
//int i = 0;
|
||||||
while(shapepartsiter != shapeparts.end() && entitypartsiter != entityparts.end())
|
while(shapepartsiter != shapeparts.end())
|
||||||
{
|
{
|
||||||
std::vector<Nif::NiTriShapeCopy>* shapes = *shapepartsiter;
|
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";
|
//std::cout << "Shape part size" << shapes->size() << "\n";
|
||||||
shapepartsiter++;
|
shapepartsiter++;
|
||||||
entitypartsiter++;
|
entitypartsiter++;
|
||||||
|
|
|
@ -17,6 +17,7 @@ namespace MWRender{
|
||||||
class NpcAnimation: public Animation{
|
class NpcAnimation: public Animation{
|
||||||
std::vector<Ogre::Entity*> entityparts;
|
std::vector<Ogre::Entity*> entityparts;
|
||||||
Ogre::Entity* hand;
|
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
|
std::vector<std::vector<Nif::NiTriShapeCopy>*> shapeparts; //All the NiTriShape data that we need for animating this particular npc
|
||||||
public:
|
public:
|
||||||
NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend);
|
NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend);
|
||||||
|
|
Loading…
Reference in a new issue