mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 21:53:51 +00:00
Some cleanup
This commit is contained in:
parent
6de0847b86
commit
1da519a914
4 changed files with 28 additions and 39 deletions
|
@ -124,8 +124,7 @@ namespace MWRender{
|
|||
//std::cout << "Name " << copy.sname << "\n";
|
||||
Ogre::HardwareVertexBufferSharedPtr vbuf = creaturemodel->getMesh()->getSubMesh(copy.sname)->vertexData->vertexBufferBinding->getBuffer(0);
|
||||
Ogre::Real* pReal = static_cast<Ogre::Real*>(vbuf->lock(Ogre::HardwareBuffer::HBL_NORMAL));
|
||||
//Ogre::HardwareVertexBufferSharedPtr vbufNormal = creaturemodel->getMesh()->getSubMesh(copy.sname)->vertexData->vertexBufferBinding->getBuffer(1);
|
||||
// Ogre::Real* pRealNormal = static_cast<Ogre::Real*>(vbufNormal->lock(Ogre::HardwareBuffer::HBL_NORMAL));
|
||||
|
||||
|
||||
std::vector<Ogre::Vector3> initialVertices = copy.morph.getInitialVertices();
|
||||
//Each shape has multiple indices
|
||||
|
@ -184,13 +183,14 @@ namespace MWRender{
|
|||
std::vector<Nif::NiSkinData::IndividualWeight> inds = iter->second;
|
||||
int verIndex = iter->first;
|
||||
Ogre::Vector3 currentVertex = (*allvertices)[verIndex];
|
||||
Ogre::Vector3 currentNormal = (*allnormals)[verIndex];
|
||||
Nif::NiSkinData::BoneInfoCopy* boneinfocopy = &(allshapesiter->boneinfo[inds[0].boneinfocopyindex]);
|
||||
Ogre::Bone *bonePtr = 0;
|
||||
|
||||
|
||||
|
||||
Ogre::Vector3 vecPos; //= bonePtr->_getDerivedPosition() + bonePtr->_getDerivedOrientation() * boneinfocopy->trafo.trans;
|
||||
Ogre::Quaternion vecRot; //= bonePtr->_getDerivedOrientation() * boneinfocopy->trafo.rotation;
|
||||
Ogre::Vector3 vecPos;
|
||||
Ogre::Quaternion vecRot;
|
||||
std::map<Nif::NiSkinData::BoneInfoCopy*, PosAndRot>::iterator result = vecRotPos.find(boneinfocopy);
|
||||
|
||||
if(result == vecRotPos.end()){
|
||||
|
@ -215,6 +215,7 @@ namespace MWRender{
|
|||
Ogre::Vector3 absVertPos = (vecPos + vecRot * currentVertex) * inds[0].weight;
|
||||
|
||||
|
||||
|
||||
for(int i = 1; i < inds.size(); i++){
|
||||
boneinfocopy = &(allshapesiter->boneinfo[inds[i].boneinfocopyindex]);
|
||||
result = vecRotPos.find(boneinfocopy);
|
||||
|
@ -240,11 +241,13 @@ namespace MWRender{
|
|||
|
||||
absVertPos += (vecPos + vecRot * currentVertex) * inds[i].weight;
|
||||
|
||||
|
||||
}
|
||||
Ogre::Real* addr = (pReal + 3 * verIndex);
|
||||
*addr = absVertPos.x;
|
||||
*(addr+1) = absVertPos.y;
|
||||
*(addr+2) = absVertPos.z;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -321,7 +324,7 @@ namespace MWRender{
|
|||
|
||||
}
|
||||
vbuf->unlock();
|
||||
//vbufNormal->unlock();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -394,18 +397,15 @@ namespace MWRender{
|
|||
|
||||
base->getAllAnimationStates()->_notifyDirty();
|
||||
//base->_updateAnimation();
|
||||
base->_notifyMoved();
|
||||
//base->_notifyMoved();
|
||||
|
||||
for(unsigned int i = 0; i < entityparts.size(); i++){
|
||||
Ogre::SkeletonInstance* skel = entityparts[i]->getSkeleton();
|
||||
//Ogre::SkeletonInstance* skel = entityparts[i]->getSkeleton();
|
||||
|
||||
Ogre::Bone* b = skel->getRootBone();
|
||||
b->setOrientation(Ogre::Real(.3),Ogre::Real(.3),Ogre::Real(.3), Ogre::Real(.3));//This is a trick
|
||||
|
||||
skel->_updateTransforms();
|
||||
|
||||
entityparts[i]->getAllAnimationStates()->_notifyDirty();
|
||||
entityparts[i]->_notifyMoved();
|
||||
}
|
||||
|
||||
|
||||
|
@ -416,9 +416,7 @@ namespace MWRender{
|
|||
if(time < iter->getStartTime() || time < startTime || time > iter->getStopTime())
|
||||
{
|
||||
slot++;
|
||||
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
float x;
|
||||
|
@ -439,7 +437,6 @@ namespace MWRender{
|
|||
|
||||
timeIndex(time, ttime, tindexI[slot], tindexJ, x);
|
||||
|
||||
//std::cout << "X: " << x << " X2: " << x2 << "\n";
|
||||
Ogre::Vector3 t;
|
||||
Ogre::Quaternion r;
|
||||
|
||||
|
@ -454,7 +451,6 @@ namespace MWRender{
|
|||
bool bQuats = quats.size() > 0;
|
||||
if(bQuats){
|
||||
r = Ogre::Quaternion::Slerp(x2, quats[rindexI[slot]], quats[rindexJ], true);
|
||||
//bone->setOrientation(r);
|
||||
}
|
||||
skel = base->getSkeleton();
|
||||
if(skel->hasBone(iter->getBonename())){
|
||||
|
@ -467,10 +463,8 @@ namespace MWRender{
|
|||
|
||||
|
||||
skel->_updateTransforms();
|
||||
//skel->_notifyManualBonesDirty();
|
||||
base->getAllAnimationStates()->_notifyDirty();
|
||||
//base->_updateAnimation();
|
||||
base->_notifyMoved();
|
||||
|
||||
}
|
||||
|
||||
slot++;
|
||||
|
|
|
@ -43,13 +43,6 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O
|
|||
char secondtolast = bodyRaceID.at(bodyRaceID.length() - 2);
|
||||
bool female = tolower(secondtolast) == 'f';
|
||||
bool beast = bodyRaceID == "b_n_khajiit_m_" || bodyRaceID == "b_n_khajiit_f_" || bodyRaceID == "b_n_argonian_m_" || bodyRaceID == "b_n_argonian_f_";
|
||||
/*std::cout << "Race: " << ref->base->race ;
|
||||
if(female){
|
||||
std::cout << " Sex: Female" << " Height: " << race->data.height.female << "\n";
|
||||
}
|
||||
else{
|
||||
std::cout << " Sex: Male" << " Height: " << race->data.height.male << "\n";
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
|
@ -66,7 +59,6 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O
|
|||
base->setSkipAnimationStateUpdate(true); //Magical line of code, this makes the bones
|
||||
//stay in the same place when we skipanim, or open a gui window
|
||||
|
||||
|
||||
if(transformations = (NIFLoader::getSingletonPtr())->getAnim(smodel)){
|
||||
|
||||
for(unsigned int init = 0; init < transformations->size(); init++){
|
||||
|
@ -188,6 +180,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O
|
|||
if(hair)
|
||||
insertBoundedPart("meshes\\" + hair->model, "Head");
|
||||
|
||||
|
||||
if (chest){
|
||||
insertFreePart("meshes\\" + chest->model, ">\"", insert);
|
||||
|
||||
|
@ -214,6 +207,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O
|
|||
}
|
||||
|
||||
Ogre::Entity* NpcAnimation::insertBoundedPart(const std::string &mesh, std::string bonename){
|
||||
|
||||
NIFLoader::load(mesh);
|
||||
Entity* ent = mRend.getScene()->createEntity(mesh);
|
||||
|
||||
|
|
|
@ -220,14 +220,14 @@ void NIFLoader::createMaterial(const String &name,
|
|||
|
||||
|
||||
//Hardware Skinning code, textures may be the wrong color if enabled
|
||||
/* if(!mSkel.isNull()){
|
||||
material->removeAllTechniques();
|
||||
|
||||
/*material->removeAllTechniques();
|
||||
|
||||
Ogre::Technique* tech = material->createTechnique();
|
||||
//tech->setSchemeName("blahblah");
|
||||
Pass* pass = tech->createPass();
|
||||
pass->setVertexProgram("Ogre/HardwareSkinningFourWeights");
|
||||
}*/
|
||||
pass->setVertexProgram("Ogre/BasicVertexPrograms/AmbientOneTexture");*/
|
||||
|
||||
|
||||
// This assigns the texture to this material. If the texture name is
|
||||
// a file name, and this file exists (in a resource directory), it
|
||||
|
@ -889,6 +889,7 @@ void NIFLoader::handleNiTriShape(NiTriShape *shape, int flags, BoundsFinder &bou
|
|||
boneIndex++;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1154,6 +1155,10 @@ void NIFLoader::loadResource(Resource *resource)
|
|||
bool hasAnim = false;
|
||||
bool baddin = false;
|
||||
bNiTri = true;
|
||||
if(name == "meshes\\base_anim.nif" || name == "meshes\\base_animkna.nif")
|
||||
{
|
||||
bNiTri = false;
|
||||
}
|
||||
|
||||
if(suffix == '*')
|
||||
{
|
||||
|
@ -1304,15 +1309,13 @@ void NIFLoader::loadResource(Resource *resource)
|
|||
mesh->_setBounds(mBoundingBox, false);
|
||||
}
|
||||
|
||||
if (!mSkel.isNull())
|
||||
if (!mSkel.isNull() )
|
||||
{
|
||||
mesh->_notifySkeleton(mSkel);
|
||||
}
|
||||
}
|
||||
|
||||
void NIFLoader::addInMesh(Ogre::Mesh* input){
|
||||
addin.push_back(input);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -111,7 +111,6 @@ class NIFLoader : Ogre::ManualResourceLoader
|
|||
std::vector<Nif::NiKeyframeData>* getAnim(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);
|
||||
|
||||
|
||||
Ogre::Vector3 convertVector3(const Nif::Vector& vec);
|
||||
|
@ -188,7 +187,6 @@ class NIFLoader : Ogre::ManualResourceLoader
|
|||
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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue