mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-22 04:39:43 +00:00
Unique Identifiers for Creatures and NPC Free Parts
This commit is contained in:
parent
93a4060346
commit
6d10c76b06
8 changed files with 53 additions and 21 deletions
|
@ -1,6 +1,6 @@
|
|||
#include "actors.hpp"
|
||||
#include <OgreSceneNode.h>
|
||||
#include <components/nifogre/ogre_nif_loader.hpp>
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,9 +1,30 @@
|
|||
#include "animation.hpp"
|
||||
|
||||
|
||||
namespace MWRender{
|
||||
std::map<std::string, int> Animation::mUniqueIDs;
|
||||
Animation::~Animation(){
|
||||
base = 0;
|
||||
}
|
||||
std::string Animation::getUniqueID(std::string mesh){
|
||||
int counter;
|
||||
if(mUniqueIDs.find(mesh) == mUniqueIDs.end()){
|
||||
counter = mUniqueIDs[mesh] = 0;
|
||||
}
|
||||
else
|
||||
counter = mUniqueIDs[mesh]++;
|
||||
|
||||
std::stringstream out;
|
||||
if(counter > 99 && counter < 1000)
|
||||
out << "0";
|
||||
else if(counter > 9)
|
||||
out << "00";
|
||||
else
|
||||
out << "000";
|
||||
out << counter;
|
||||
return out.str();
|
||||
}
|
||||
|
||||
void Animation::handleShapes(std::vector<Nif::NiTriShapeCopy>* allshapes, Ogre::Entity* creaturemodel, Ogre::SkeletonInstance *skel){
|
||||
shapeNumber = 0;
|
||||
std::vector<Nif::NiTriShapeCopy>::iterator allshapesiter;
|
||||
|
|
|
@ -7,13 +7,17 @@
|
|||
#include "../mwworld/actiontalk.hpp"
|
||||
#include "../mwworld/environment.hpp"
|
||||
#include <components/nif/node.hpp>
|
||||
#include <map>
|
||||
|
||||
namespace MWRender{
|
||||
|
||||
class Animation{
|
||||
|
||||
protected:
|
||||
|
||||
OEngine::Render::OgreRenderer &mRend;
|
||||
MWWorld::Environment& mEnvironment;
|
||||
MWWorld::Environment& mEnvironment;
|
||||
static std::map<std::string, int> mUniqueIDs;
|
||||
|
||||
float time;
|
||||
float startTime;
|
||||
|
@ -36,9 +40,12 @@ class Animation{
|
|||
std::map<std::string,float> textmappings;
|
||||
Ogre::Entity* base;
|
||||
void handleShapes(std::vector<Nif::NiTriShapeCopy>* allshapes, Ogre::Entity* creaturemodel, Ogre::SkeletonInstance *skel);
|
||||
bool timeIndex( float time, std::vector<float> times, int & i, int & j, float & x );
|
||||
std::string getUniqueID(std::string mesh);
|
||||
public:
|
||||
Animation(MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend): mRend(_rend), mEnvironment(_env){};
|
||||
bool timeIndex( float time, std::vector<float> times, int & i, int & j, float & x );
|
||||
|
||||
|
||||
~Animation();
|
||||
|
||||
};
|
||||
|
|
|
@ -18,11 +18,12 @@ CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr, MWWorld::Environme
|
|||
assert (ref->base != NULL);
|
||||
if(!ref->base->model.empty()){
|
||||
const std::string &mesh = "meshes\\" + ref->base->model;
|
||||
std::string meshNumbered = mesh + getUniqueID(mesh) + ">|";
|
||||
NifOgre::NIFLoader::load(meshNumbered);
|
||||
base = mRend.getScene()->createEntity(meshNumbered);
|
||||
std::string meshZero = mesh + "0000>|";
|
||||
|
||||
NifOgre::NIFLoader::load(mesh);
|
||||
base = mRend.getScene()->createEntity(mesh);
|
||||
|
||||
if(transformations = (NIFLoader::getSingletonPtr())->getAnim(mesh)){
|
||||
if(transformations = (NIFLoader::getSingletonPtr())->getAnim(meshZero)){
|
||||
|
||||
for(int init = 0; init < transformations->size(); init++){
|
||||
rindexI.push_back(0);
|
||||
|
|
|
@ -173,23 +173,25 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O
|
|||
insertBoundedPart("meshes\\" + hair->model, "Head");
|
||||
|
||||
if (chest){
|
||||
insertFreePart("meshes\\" + chest->model + "|\"", insert);
|
||||
insertFreePart("meshes\\" + chest->model, ">\"", insert);
|
||||
|
||||
|
||||
}
|
||||
if (handr){
|
||||
insertFreePart("meshes\\" + handr->model + "|?", insert);
|
||||
insertFreePart("meshes\\" + handr->model , ">?", insert);
|
||||
|
||||
}
|
||||
if (handl){
|
||||
insertFreePart("meshes\\" + handl->model + "|>", insert);
|
||||
insertFreePart("meshes\\" + handl->model, ">>", insert);
|
||||
|
||||
}
|
||||
if(tail){
|
||||
insertFreePart("meshes\\" + tail->model + "|*", insert);
|
||||
insertFreePart("meshes\\" + tail->model, ">*", insert);
|
||||
}
|
||||
if(feet){
|
||||
insertFreePart("meshes\\" + feet->model + "|<", insert);
|
||||
insertFreePart("meshes\\" + feet->model + "|:", insert);
|
||||
std::string num = getUniqueID(feet->model);
|
||||
insertFreePart("meshes\\" + feet->model,"><", insert);
|
||||
insertFreePart("meshes\\" + feet->model,">:", insert);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -200,12 +202,14 @@ Ogre::Entity* NpcAnimation::insertBoundedPart(const std::string &mesh, std::stri
|
|||
base->attachObjectToBone(bonename, ent);
|
||||
return ent;
|
||||
}
|
||||
void NpcAnimation::insertFreePart(const std::string &mesh, Ogre::SceneNode* insert){
|
||||
NIFLoader::load(mesh);
|
||||
Entity* ent = mRend.getScene()->createEntity(mesh);
|
||||
void NpcAnimation::insertFreePart(const std::string &mesh, const std::string suffix, Ogre::SceneNode* insert){
|
||||
std::string meshNumbered = mesh + getUniqueID(mesh + suffix) + suffix;
|
||||
NIFLoader::load(meshNumbered);
|
||||
|
||||
Entity* ent = mRend.getScene()->createEntity(meshNumbered);
|
||||
insert->attachObject(ent);
|
||||
entityparts.push_back(ent);
|
||||
std::vector<Nif::NiTriShapeCopy>* shapes = ((NIFLoader::getSingletonPtr())->getShapes(mesh));
|
||||
std::vector<Nif::NiTriShapeCopy>* shapes = ((NIFLoader::getSingletonPtr())->getShapes(mesh + "0000" + suffix));
|
||||
if(shapes){
|
||||
shapeparts.push_back(shapes);
|
||||
handleShapes(shapes, ent, skel);
|
||||
|
|
|
@ -22,7 +22,7 @@ class NpcAnimation: public Animation{
|
|||
NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend);
|
||||
~NpcAnimation();
|
||||
Ogre::Entity* insertBoundedPart(const std::string &mesh, std::string bonename);
|
||||
void insertFreePart(const std::string &mesh, Ogre::SceneNode* insert);
|
||||
void insertFreePart(const std::string &mesh, const std::string suffix, Ogre::SceneNode* insert);
|
||||
};
|
||||
}
|
||||
#endif
|
|
@ -1150,7 +1150,7 @@ void NIFLoader::loadResource(Resource *resource)
|
|||
else if(suffix == '>')
|
||||
{
|
||||
baddin = true;
|
||||
bNiTri = false;
|
||||
bNiTri = true;
|
||||
std::string sub = name.substr(name.length() - 6, 4);
|
||||
|
||||
if(sub.compare("0000") != 0)
|
||||
|
|
|
@ -44,8 +44,7 @@
|
|||
#include <vector>
|
||||
#include <list>
|
||||
// For warning messages
|
||||
#include <iostream>
|
||||
|
||||
#include <iostream>5
|
||||
// float infinity
|
||||
#include <limits>
|
||||
using namespace boost::algorithm;
|
||||
|
|
Loading…
Reference in a new issue