forked from mirror/openmw-tes3mp
clean up
This commit is contained in:
parent
e35aee0f89
commit
9b910dda94
8 changed files with 240 additions and 247 deletions
|
@ -43,7 +43,6 @@ namespace MWClass
|
|||
ptr.get<ESM::NPC>();
|
||||
|
||||
|
||||
const std::string &model = ref->base->model;
|
||||
assert (ref->base != NULL);
|
||||
std::string headID = ref->base->head;
|
||||
std::string bodyRaceID = headID.substr(0, headID.find_last_of("head_") - 4);
|
||||
|
|
|
@ -112,14 +112,11 @@ namespace MWRender{
|
|||
|
||||
Nif::NiTriShapeCopy& copy = *allshapesiter;
|
||||
std::vector<Ogre::Vector3>* allvertices = ©.vertices;
|
||||
std::vector<Ogre::Vector3>* allnormals = ©.normals;
|
||||
|
||||
|
||||
|
||||
//std::set<unsigned int> vertices;
|
||||
//std::set<unsigned int> normals;
|
||||
//std::vector<Nif::NiSkinData::BoneInfoCopy> boneinfovector = copy.boneinfo;
|
||||
std::map<int, std::vector<Nif::NiSkinData::IndividualWeight>>* verticesToChange = ©.vertsToWeights;
|
||||
std::map<int, std::vector<Nif::NiSkinData::IndividualWeight> >* verticesToChange = ©.vertsToWeights;
|
||||
|
||||
//std::cout << "Name " << copy.sname << "\n";
|
||||
Ogre::HardwareVertexBufferSharedPtr vbuf = creaturemodel->getMesh()->getSubMesh(copy.sname)->vertexData->vertexBufferBinding->getBuffer(0);
|
||||
|
@ -135,7 +132,7 @@ namespace MWRender{
|
|||
if(copy.vertices.size() == initialVertices.size())
|
||||
{
|
||||
//Create if it doesn't already exist
|
||||
if(shapeIndexI.size() == shapeNumber)
|
||||
if(shapeIndexI.size() == static_cast<std::size_t> (shapeNumber))
|
||||
{
|
||||
std::vector<int> vec;
|
||||
shapeIndexI.push_back(vec);
|
||||
|
@ -178,7 +175,7 @@ namespace MWRender{
|
|||
|
||||
if(verticesToChange->size() > 0){
|
||||
|
||||
for(std::map<int, std::vector<Nif::NiSkinData::IndividualWeight>>::iterator iter = verticesToChange->begin();
|
||||
for(std::map<int, std::vector<Nif::NiSkinData::IndividualWeight> >::iterator iter = verticesToChange->begin();
|
||||
iter != verticesToChange->end(); iter++)
|
||||
{
|
||||
std::vector<Nif::NiSkinData::IndividualWeight> inds = iter->second;
|
||||
|
@ -217,7 +214,7 @@ namespace MWRender{
|
|||
Ogre::Vector3 absVertPos = (vecPos + vecRot * currentVertex) * inds[0].weight;
|
||||
|
||||
|
||||
for(int i = 1; i < inds.size(); i++){
|
||||
for(std::size_t i = 1; i < inds.size(); i++){
|
||||
boneinfocopy = &(allshapesiter->boneinfo[inds[i].boneinfocopyindex]);
|
||||
if(useHandles)
|
||||
bonePtr = skel->getBone(boneinfocopy->bonehandle);
|
||||
|
@ -253,7 +250,8 @@ namespace MWRender{
|
|||
*(addr+2) = absVertPos.z;
|
||||
}
|
||||
|
||||
/*for (unsigned int i = 0; i < boneinfovector.size(); i++)
|
||||
#if 0
|
||||
for (unsigned int i = 0; i < boneinfovector.size(); i++)
|
||||
{
|
||||
Nif::NiSkinData::BoneInfoCopy boneinfo = boneinfovector[i];
|
||||
if(skel->hasBone(boneinfo.bonename)){
|
||||
|
@ -292,7 +290,7 @@ namespace MWRender{
|
|||
|
||||
}
|
||||
|
||||
/*if(normals.find(verIndex) == normals.end())
|
||||
if(normals.find(verIndex) == normals.end())
|
||||
{
|
||||
Ogre::Vector3 absNormalsPos = vecRot * allnormals[verIndex];
|
||||
absNormalsPos = absNormalsPos * boneinfo.weights[j].weight;
|
||||
|
@ -314,8 +312,8 @@ namespace MWRender{
|
|||
*(addr+1) = absNormalsPos.y;
|
||||
*(addr+2) = absNormalsPos.z;
|
||||
|
||||
}*/
|
||||
|
||||
}
|
||||
#endif
|
||||
//}
|
||||
//}
|
||||
|
||||
|
@ -546,7 +544,7 @@ namespace MWRender{
|
|||
//base->_updateAnimation();
|
||||
base->_notifyMoved();
|
||||
}
|
||||
for(int i = 0; i < entityparts.size(); i++){
|
||||
for(std::size_t i = 0; i < entityparts.size(); i++){
|
||||
skel = entityparts[i]->getSkeleton();
|
||||
if(skel->hasBone(iter->getBonename())){
|
||||
Ogre::Bone* bone = skel->getBone(iter->getBonename());
|
||||
|
|
|
@ -14,7 +14,7 @@ CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr, MWWorld::Environme
|
|||
ESMS::LiveCellRef<ESM::Creature, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Creature>();
|
||||
|
||||
assert (ref->base != NULL);
|
||||
assert (ref->base != NULL);
|
||||
if(!ref->base->model.empty()){
|
||||
const std::string &mesh = "meshes\\" + ref->base->model;
|
||||
std::string meshNumbered = mesh + getUniqueID(mesh) + ">|";
|
||||
|
@ -22,9 +22,9 @@ CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr, MWWorld::Environme
|
|||
base = mRend.getScene()->createEntity(meshNumbered);
|
||||
std::string meshZero = mesh + "0000>|";
|
||||
|
||||
if(transformations = (NIFLoader::getSingletonPtr())->getAnim(meshZero)){
|
||||
if((transformations = (NIFLoader::getSingletonPtr())->getAnim(meshZero))){
|
||||
|
||||
for(int init = 0; init < transformations->size(); init++){
|
||||
for(std::size_t init = 0; init < transformations->size(); init++){
|
||||
rindexI.push_back(0);
|
||||
tindexI.push_back(0);
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O
|
|||
//stay in the same place when we skipanim, or open a gui window
|
||||
|
||||
|
||||
if(transformations = (NIFLoader::getSingletonPtr())->getAnim(smodel)){
|
||||
if((transformations = (NIFLoader::getSingletonPtr())->getAnim(smodel))){
|
||||
|
||||
for(unsigned int init = 0; init < transformations->size(); init++){
|
||||
rindexI.push_back(0);
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace MWRender {
|
|||
|
||||
|
||||
RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const boost::filesystem::path& resDir, OEngine::Physic::PhysicEngine* engine, MWWorld::Environment& environment)
|
||||
:mRendering(_rend), mObjects(mRendering), mDebugging(engine), mActors(mRendering, environment)
|
||||
:mRendering(_rend), mObjects(mRendering), mActors(mRendering, environment), mDebugging(engine)
|
||||
{
|
||||
mRendering.createScene("PlayerCam", 55, 5);
|
||||
mSkyManager = MWRender::SkyManager::create(mRendering.getWindow(), mRendering.getCamera(), resDir);
|
||||
|
|
|
@ -103,7 +103,7 @@ struct NiTriShapeCopy
|
|||
std::vector<Ogre::Vector3> vertices;
|
||||
std::vector<Ogre::Vector3> normals;
|
||||
std::vector<Nif::NiSkinData::BoneInfoCopy> boneinfo;
|
||||
std::map<int, std::vector<Nif::NiSkinData::IndividualWeight>> vertsToWeights;
|
||||
std::map<int, std::vector<Nif::NiSkinData::IndividualWeight> > vertsToWeights;
|
||||
Nif::NiMorphData morph;
|
||||
};
|
||||
|
||||
|
|
|
@ -1003,39 +1003,38 @@ void NIFLoader::handleNode(Nif::Node *node, int flags,
|
|||
}
|
||||
|
||||
if (e->recType == RC_NiTextKeyExtraData){
|
||||
Nif::NiTextKeyExtraData* extra = dynamic_cast<Nif::NiTextKeyExtraData*> (e);
|
||||
Nif::NiTextKeyExtraData* extra = dynamic_cast<Nif::NiTextKeyExtraData*> (e);
|
||||
|
||||
std::ofstream file;
|
||||
std::ofstream file;
|
||||
|
||||
if(mOutputAnimFiles){
|
||||
std::string cut = "";
|
||||
for(unsigned int i = 0; i < name.length(); i++)
|
||||
{
|
||||
if(!(name.at(i) == '\\' || name.at(i) == '/' || name.at(i) == '>' || name.at(i) == '<' || name.at(i) == '?' || name.at(i) == '*' || name.at(i) == '|' || name.at(i) == ':' || name.at(i) == '"'))
|
||||
{
|
||||
cut += name.at(i);
|
||||
}
|
||||
}
|
||||
std::string cut = "";
|
||||
for(unsigned int i = 0; i < name.length(); i++)
|
||||
{
|
||||
if(!(name.at(i) == '\\' || name.at(i) == '/' || name.at(i) == '>' || name.at(i) == '<' || name.at(i) == '?' || name.at(i) == '*' || name.at(i) == '|' || name.at(i) == ':' || name.at(i) == '"'))
|
||||
{
|
||||
cut += name.at(i);
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "Outputting " << cut << "\n";
|
||||
std::cout << "Outputting " << cut << "\n";
|
||||
|
||||
file.open((verbosePath + "/Indices" + cut + ".txt").c_str());
|
||||
file.open((verbosePath + "/Indices" + cut + ".txt").c_str());
|
||||
}
|
||||
|
||||
for(std::vector<Nif::NiTextKeyExtraData::TextKey>::iterator textiter = extra->list.begin(); textiter != extra->list.end(); textiter++)
|
||||
{
|
||||
for(std::vector<Nif::NiTextKeyExtraData::TextKey>::iterator textiter = extra->list.begin(); textiter != extra->list.end(); textiter++)
|
||||
{
|
||||
std::string text = textiter->text.toString();
|
||||
|
||||
std::string text = textiter->text.toString();
|
||||
replace(text.begin(), text.end(), '\n', '/');
|
||||
|
||||
replace(text.begin(), text.end(), '\n', '/');
|
||||
|
||||
text.erase(std::remove(text.begin(), text.end(), '\r'), text.end());
|
||||
int i = 0;
|
||||
text.erase(std::remove(text.begin(), text.end(), '\r'), text.end());
|
||||
std::size_t i = 0;
|
||||
while(i < text.length()){
|
||||
while(i < text.length() && text.at(i) == '/' ){
|
||||
i++;
|
||||
}
|
||||
int first = i;
|
||||
std::size_t first = i;
|
||||
int length = 0;
|
||||
while(i < text.length() && text.at(i) != '/' ){
|
||||
i++;
|
||||
|
@ -1045,15 +1044,15 @@ void NIFLoader::handleNode(Nif::Node *node, int flags,
|
|||
//length = text.length() - first;
|
||||
std::string sub = text.substr(first, length);
|
||||
|
||||
if(mOutputAnimFiles)
|
||||
if(mOutputAnimFiles)
|
||||
file << "Time: " << textiter->time << "|" << sub << "\n";
|
||||
|
||||
textmappings[sub] = textiter->time;
|
||||
textmappings[sub] = textiter->time;
|
||||
}
|
||||
}
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
|
||||
Bone *bone = 0;
|
||||
|
@ -1260,26 +1259,23 @@ void NIFLoader::loadResource(Resource *resource)
|
|||
if(addAnim)
|
||||
{
|
||||
for(int i = 0; i < nif.numRecords(); i++)
|
||||
{
|
||||
Nif::NiKeyframeController *f = dynamic_cast<Nif::NiKeyframeController*>(nif.getRecord(i));
|
||||
{
|
||||
Nif::NiKeyframeController *f = dynamic_cast<Nif::NiKeyframeController*>(nif.getRecord(i));
|
||||
|
||||
Nif::Node *n = dynamic_cast<Nif::Node*>(nif.getRecord(i));
|
||||
if(f != NULL)
|
||||
{
|
||||
hasAnim = true;
|
||||
Nif::Node *o = dynamic_cast<Nif::Node*>(f->target.getPtr());
|
||||
Nif::NiKeyframeDataPtr data = f->data;
|
||||
if(f != NULL)
|
||||
{
|
||||
hasAnim = true;
|
||||
Nif::Node *o = dynamic_cast<Nif::Node*>(f->target.getPtr());
|
||||
Nif::NiKeyframeDataPtr data = f->data;
|
||||
|
||||
if (f->timeStart == 10000000000000000)
|
||||
continue;
|
||||
data->setBonename(o->name.toString());
|
||||
data->setStartTime(f->timeStart);
|
||||
data->setStopTime(f->timeStop);
|
||||
if (f->timeStart == 10000000000000000)
|
||||
continue;
|
||||
data->setBonename(o->name.toString());
|
||||
data->setStartTime(f->timeStart);
|
||||
data->setStopTime(f->timeStop);
|
||||
|
||||
allanim.push_back(data.get());
|
||||
|
||||
|
||||
}
|
||||
allanim.push_back(data.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
// set the bounding value.
|
||||
|
@ -1290,18 +1286,18 @@ void NIFLoader::loadResource(Resource *resource)
|
|||
mesh->_setBoundingSphereRadius(bounds.getRadius());
|
||||
}
|
||||
if(hasAnim && addAnim){
|
||||
allanimmap[name] = allanim;
|
||||
alltextmappings[name] = textmappings;
|
||||
}
|
||||
if(!mSkel.isNull() && shapes.size() > 0 && addAnim)
|
||||
{
|
||||
allshapesmap[name] = shapes;
|
||||
allanimmap[name] = allanim;
|
||||
alltextmappings[name] = textmappings;
|
||||
}
|
||||
if(!mSkel.isNull() && shapes.size() > 0 && addAnim)
|
||||
{
|
||||
allshapesmap[name] = shapes;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(flip){
|
||||
mesh->_setBounds(mBoundingBox, false);
|
||||
}
|
||||
mesh->_setBounds(mBoundingBox, false);
|
||||
}
|
||||
|
||||
if (!mSkel.isNull())
|
||||
{
|
||||
|
@ -1310,7 +1306,7 @@ void NIFLoader::loadResource(Resource *resource)
|
|||
}
|
||||
|
||||
void NIFLoader::addInMesh(Ogre::Mesh* input){
|
||||
addin.push_back(input);
|
||||
addin.push_back(input);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1341,20 +1337,20 @@ This function points to existing texture and IndexData buffers
|
|||
|
||||
std::vector<Nif::NiKeyframeData>* NIFLoader::getAnim(std::string lowername){
|
||||
|
||||
std::map<std::string,std::vector<Nif::NiKeyframeData>,ciLessBoost>::iterator iter = allanimmap.find(lowername);
|
||||
std::map<std::string,std::vector<Nif::NiKeyframeData>,ciLessBoost>::iterator iter = allanimmap.find(lowername);
|
||||
std::vector<Nif::NiKeyframeData>* pass = 0;
|
||||
if(iter != allanimmap.end())
|
||||
pass = &(iter->second);
|
||||
return pass;
|
||||
if(iter != allanimmap.end())
|
||||
pass = &(iter->second);
|
||||
return pass;
|
||||
|
||||
}
|
||||
std::vector<Nif::NiTriShapeCopy>* NIFLoader::getShapes(std::string lowername){
|
||||
|
||||
std::map<std::string,std::vector<Nif::NiTriShapeCopy>,ciLessBoost>::iterator iter = allshapesmap.find(lowername);
|
||||
std::map<std::string,std::vector<Nif::NiTriShapeCopy>,ciLessBoost>::iterator iter = allshapesmap.find(lowername);
|
||||
std::vector<Nif::NiTriShapeCopy>* pass = 0;
|
||||
if(iter != allshapesmap.end())
|
||||
pass = &(iter->second);
|
||||
return pass;
|
||||
if(iter != allshapesmap.end())
|
||||
pass = &(iter->second);
|
||||
return pass;
|
||||
}
|
||||
|
||||
std::map<std::string, float>* NIFLoader::getTextIndices(std::string lowername){
|
||||
|
|
|
@ -109,7 +109,7 @@ class NIFLoader : Ogre::ManualResourceLoader
|
|||
const std::string &group="General");
|
||||
//void insertMeshInsideBase(Ogre::Mesh* mesh);
|
||||
std::vector<Nif::NiKeyframeData>* getAnim(std::string name);
|
||||
std::vector<Nif::NiTriShapeCopy>* getShapes(std::string name);
|
||||
std::vector<Nif::NiTriShapeCopy>* getShapes(std::string name);
|
||||
std::map<std::string, float>* getTextIndices(std::string name);
|
||||
void addInMesh(Ogre::Mesh* input);
|
||||
|
||||
|
@ -121,7 +121,7 @@ class NIFLoader : Ogre::ManualResourceLoader
|
|||
void setVerbosePath(std::string path);
|
||||
|
||||
private:
|
||||
NIFLoader() : mNormaliseNormals(false), resourceGroup("General"), resourceName(""), flip(false),
|
||||
NIFLoader() : resourceName(""), resourceGroup("General"), flip(false), mNormaliseNormals(false),
|
||||
mFlipVertexWinding(false), mOutputAnimFiles(false) {}
|
||||
NIFLoader(NIFLoader& n) {}
|
||||
|
||||
|
@ -167,7 +167,7 @@ class NIFLoader : Ogre::ManualResourceLoader
|
|||
std::string verbosePath;
|
||||
std::string resourceName;
|
||||
std::string resourceGroup;
|
||||
Ogre::Matrix4 mTransform;
|
||||
Ogre::Matrix4 mTransform;
|
||||
Ogre::AxisAlignedBox mBoundingBox;
|
||||
bool flip;
|
||||
bool mNormaliseNormals;
|
||||
|
@ -184,13 +184,13 @@ class NIFLoader : Ogre::ManualResourceLoader
|
|||
std::string name;
|
||||
std::string triname;
|
||||
std::vector<Nif::NiKeyframeData> allanim;
|
||||
std::map<std::string,float> textmappings;
|
||||
std::map<std::string,std::map<std::string,float>,ciLessBoost> alltextmappings;
|
||||
std::map<std::string,std::vector<Nif::NiKeyframeData>,ciLessBoost> allanimmap;
|
||||
std::map<std::string,std::vector<Nif::NiTriShapeCopy>,ciLessBoost> allshapesmap;
|
||||
std::map<std::string,float> textmappings;
|
||||
std::map<std::string,std::map<std::string,float>,ciLessBoost> alltextmappings;
|
||||
std::map<std::string,std::vector<Nif::NiKeyframeData>,ciLessBoost> allanimmap;
|
||||
std::map<std::string,std::vector<Nif::NiTriShapeCopy>,ciLessBoost> allshapesmap;
|
||||
std::vector<Ogre::Mesh*> addin;
|
||||
std::vector<Nif::NiKeyframeData> mAnim;
|
||||
std::vector<Nif::NiTriShapeCopy> mS;
|
||||
std::vector<Nif::NiTriShapeCopy> mS;
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue