mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 22:23:51 +00:00
Changing a lot of things
This commit is contained in:
parent
509009e5c1
commit
47112ad7f9
7 changed files with 80 additions and 34 deletions
|
@ -1,7 +1,7 @@
|
|||
#include "actors.hpp"
|
||||
#include <OgreSceneNode.h>
|
||||
#include <components/nifogre/ogre_nif_loader.hpp>
|
||||
#include "../mwworld/world.hpp"
|
||||
|
||||
|
||||
|
||||
using namespace Ogre;
|
||||
|
@ -13,7 +13,7 @@ void Actors::setMwRoot(Ogre::SceneNode* root){
|
|||
}
|
||||
void Actors::insertNPC(const MWWorld::Ptr& ptr){
|
||||
insertBegin(ptr, true, true);
|
||||
MWRender::Animation anim = MWRender::NpcAnimation(ptr, mEnvironment, mRend);
|
||||
NpcAnimation* anim = new MWRender::NpcAnimation(ptr, mEnvironment, mRend);
|
||||
mAllActors.push_back(anim);
|
||||
|
||||
|
||||
|
@ -58,8 +58,9 @@ void Actors::insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_){
|
|||
}
|
||||
void Actors::insertCreature (const MWWorld::Ptr& ptr){
|
||||
insertBegin(ptr, true, true);
|
||||
MWRender::Animation anim = MWRender::CreatureAnimation(ptr, mEnvironment, mRend);
|
||||
CreatureAnimation* anim = new MWRender::CreatureAnimation(ptr, mEnvironment, mRend);
|
||||
mAllActors.push_back(anim);
|
||||
//mAllActors.push_back(&anim);
|
||||
}
|
||||
|
||||
bool Actors::deleteObject (const MWWorld::Ptr& ptr)
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace MWRender{
|
|||
std::map<MWWorld::Ptr::CellStore *, Ogre::SceneNode *> mCellSceneNodes;
|
||||
Ogre::SceneNode* mMwRoot;
|
||||
MWWorld::Environment& mEnvironment;
|
||||
std::list<Animation> mAllActors;
|
||||
std::list<MWRender::Animation*> mAllActors;
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -14,8 +14,24 @@ class Animation{
|
|||
OEngine::Render::OgreRenderer &mRend;
|
||||
MWWorld::Environment& mEnvironment;
|
||||
|
||||
float time;
|
||||
float startTime;
|
||||
float stopTime;
|
||||
bool loop;
|
||||
//Represents a rotation index for each bone
|
||||
std::vector<int>rindexI;
|
||||
//Represents a translation index for each bone
|
||||
std::vector<int>tindexI;
|
||||
|
||||
std::vector<Nif::NiKeyframeData> transformations;
|
||||
//Only shapes with morphing data will need a shape number
|
||||
int shapeNumber;
|
||||
std::vector<std::vector<int>> shapeIndexI;
|
||||
|
||||
Ogre::SkeletonInstance* skel;
|
||||
|
||||
|
||||
|
||||
std::vector<Nif::NiKeyframeData>* transformations;
|
||||
std::map<std::string,float> textmappings;
|
||||
Ogre::Entity* base;
|
||||
public:
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "npcanimation.hpp"
|
||||
#include "../mwworld/world.hpp"
|
||||
|
||||
|
||||
using namespace Ogre;
|
||||
using namespace NifOgre;
|
||||
namespace MWRender{
|
||||
|
@ -54,6 +55,15 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O
|
|||
NifOgre::NIFLoader::load(smodel);
|
||||
|
||||
base = mRend.getScene()->createEntity(smodel);
|
||||
|
||||
/*
|
||||
transformations = &(NIFLoader::getSingletonPtr())->getAnim(smodel);
|
||||
for(int init = 0; init < transformations->size(); init++){
|
||||
rindexI.push_back(0);
|
||||
//a.rindexJ.push_back(0);
|
||||
tindexI.push_back(0);
|
||||
//a.tindexJ.push_back(0);
|
||||
}*/
|
||||
insert->attachObject(base);
|
||||
|
||||
std::string headModel = "meshes\\" +
|
||||
|
@ -61,7 +71,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O
|
|||
|
||||
std::string hairModel = "meshes\\" +
|
||||
mEnvironment.mWorld->getStore().bodyParts.find(hairID)->model;
|
||||
|
||||
const ESM::BodyPart *chest = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "chest");
|
||||
const ESM::BodyPart *upperleg = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "upper leg");
|
||||
const ESM::BodyPart *groin = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "groin");
|
||||
const ESM::BodyPart *arml = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "upper arm"); //We need two
|
||||
|
@ -154,6 +164,15 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O
|
|||
insertBoundedPart("meshes\\" + head->model, "Head");
|
||||
if(hair)
|
||||
insertBoundedPart("meshes\\" + hair->model, "Head");
|
||||
|
||||
if (chest){
|
||||
insertFreePart("meshes\\" + chest->model + "|\"", insert);
|
||||
|
||||
}
|
||||
if (handr){
|
||||
insertFreePart("meshes\\" + handr->model + "|?", insert);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Ogre::Entity* NpcAnimation::insertBoundedPart(const std::string &mesh, std::string bonename){
|
||||
|
@ -162,5 +181,16 @@ 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);
|
||||
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));
|
||||
shapeparts.push_back(shapes);
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -3,6 +3,9 @@
|
|||
#include "animation.hpp"
|
||||
#include <components/nif/data.hpp>
|
||||
#include <components/nif/node.hpp>
|
||||
#include <components/nif/property.hpp>
|
||||
#include <components/nif/controller.hpp>
|
||||
#include <components/nif/extra.hpp>
|
||||
|
||||
#include "../mwworld/refdata.hpp"
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
@ -12,11 +15,14 @@
|
|||
namespace MWRender{
|
||||
|
||||
class NpcAnimation: public Animation{
|
||||
std::vector<std::vector<Nif::NiTriShapeCopy>> shapeparts; //All the NiTriShape data that we need for animating this particular npc
|
||||
std::vector<Ogre::Entity*> entityparts;
|
||||
|
||||
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);
|
||||
~NpcAnimation();
|
||||
Ogre::Entity* insertBoundedPart(const std::string &mesh, std::string bonename);
|
||||
void insertFreePart(const std::string &mesh, Ogre::SceneNode* insert);
|
||||
};
|
||||
}
|
||||
#endif
|
|
@ -1277,18 +1277,7 @@ void NIFLoader::loadResource(Resource *resource)
|
|||
{
|
||||
allshapesmap[name] = shapes;
|
||||
}
|
||||
if(baddin){
|
||||
/*if(addAnim){
|
||||
if(isBeast)
|
||||
npcknaSkel = mSkel;
|
||||
else
|
||||
npcSkel = mSkel;
|
||||
}*/
|
||||
for(int i = 0; i < addin.size(); i++){
|
||||
insertMeshInsideBase(addin[i]);
|
||||
}
|
||||
addin.clear();
|
||||
}
|
||||
|
||||
if(flip){
|
||||
mesh->_setBounds(mBoundingBox, false);
|
||||
}
|
||||
|
@ -1330,20 +1319,22 @@ This function also creates new position and normal buffers for submeshes.
|
|||
This function points to existing texture and IndexData buffers
|
||||
*/
|
||||
|
||||
std::vector<Nif::NiKeyframeData>& NIFLoader::getAnim(std::string lowername){
|
||||
std::vector<Nif::NiKeyframeData>* NIFLoader::getAnim(std::string 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())
|
||||
mAnim = iter->second;
|
||||
return mAnim;
|
||||
pass = &(iter->second);
|
||||
return pass;
|
||||
|
||||
}
|
||||
std::vector<Nif::NiTriShapeCopy>& NIFLoader::getShapes(std::string lowername){
|
||||
std::vector<Nif::NiTriShapeCopy>* NIFLoader::getShapes(std::string 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())
|
||||
mS = iter->second;
|
||||
return mS;
|
||||
pass = &(iter->second);
|
||||
return pass;
|
||||
}
|
||||
|
||||
float NIFLoader::getTime(std::string filename, std::string text){
|
||||
|
@ -1359,12 +1350,14 @@ float NIFLoader::getTime(std::string filename, std::string text){
|
|||
return -10000000.0;
|
||||
}
|
||||
|
||||
/*
|
||||
void NIFLoader::insertMeshInsideBase(Ogre::Mesh* input)
|
||||
{
|
||||
/*if(addin)
|
||||
{
|
||||
std::cout << "InsideBase:" << addin->getName() << "\n";
|
||||
}*/
|
||||
/*
|
||||
if(input)
|
||||
{
|
||||
std::vector<Nif::NiTriShapeCopy> shapes = NIFLoader::getSingletonPtr()->getShapes(input->getName());
|
||||
|
@ -1478,7 +1471,7 @@ void NIFLoader::insertMeshInsideBase(Ogre::Mesh* input)
|
|||
for (int j = 0; j < weights.size(); j++){
|
||||
std::cout << "Vertex: " << weights[j].vertex << " Weight: " << weights[j].weight << "\n";
|
||||
}*/
|
||||
}
|
||||
/*}
|
||||
}
|
||||
|
||||
if(position){
|
||||
|
@ -1578,7 +1571,7 @@ void NIFLoader::insertMeshInsideBase(Ogre::Mesh* input)
|
|||
assign.vertexIndex = 0;
|
||||
assign.weight = 1.0;
|
||||
subNew->addBoneAssignment(assign);*/
|
||||
|
||||
/*
|
||||
Ogre::SubMesh::BoneAssignmentIterator boneiter = sub->getBoneAssignmentIterator();
|
||||
while(boneiter.hasMoreElements())
|
||||
{
|
||||
|
@ -1592,7 +1585,7 @@ void NIFLoader::insertMeshInsideBase(Ogre::Mesh* input)
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
/* More code currently not in use, from the old D source. This was
|
||||
|
|
|
@ -108,9 +108,9 @@ class NIFLoader : Ogre::ManualResourceLoader
|
|||
|
||||
static Ogre::MeshPtr load(const std::string &name,
|
||||
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);
|
||||
//void insertMeshInsideBase(Ogre::Mesh* mesh);
|
||||
std::vector<Nif::NiKeyframeData>* getAnim(std::string name);
|
||||
std::vector<Nif::NiTriShapeCopy>* getShapes(std::string name);
|
||||
float getTime(std::string filename, std::string text);
|
||||
void addInMesh(Ogre::Mesh* input);
|
||||
|
||||
|
|
Loading…
Reference in a new issue