diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index 3ae1a0fa7..96d65e00d 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -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(vbuf->lock(Ogre::HardwareBuffer::HBL_NORMAL)); - //Ogre::HardwareVertexBufferSharedPtr vbufNormal = creaturemodel->getMesh()->getSubMesh(copy.sname)->vertexData->vertexBufferBinding->getBuffer(1); - // Ogre::Real* pRealNormal = static_cast(vbufNormal->lock(Ogre::HardwareBuffer::HBL_NORMAL)); + std::vector initialVertices = copy.morph.getInitialVertices(); //Each shape has multiple indices @@ -184,13 +183,14 @@ namespace MWRender{ std::vector 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::iterator result = vecRotPos.find(boneinfocopy); if(result == vecRotPos.end()){ @@ -213,6 +213,7 @@ namespace MWRender{ } Ogre::Vector3 absVertPos = (vecPos + vecRot * currentVertex) * inds[0].weight; + for(int i = 1; i < inds.size(); i++){ @@ -239,12 +240,14 @@ 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; - + 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++; diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 4776dc110..40db0006c 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -43,14 +43,7 @@ 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"; - }*/ - + std::string smodel = "meshes\\base_anim.nif"; @@ -65,7 +58,6 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O base = mRend.getScene()->createEntity(smodel); 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)){ @@ -116,7 +108,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O const ESM::BodyPart* wristr = wristl; const ESM::BodyPart* armr = arml; - + if(upperleg){ insertBoundedPart("meshes\\" + upperleg->model + "*|", "Left Upper Leg"); insertBoundedPart("meshes\\" + upperleg->model, "Right Upper Leg"); @@ -178,7 +170,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O if(clavicler) insertBoundedPart("meshes\\" + clavicler->model , "Right Clavicle", base);*/ - + if(neck) { insertBoundedPart("meshes\\" + neck->model, "Neck"); @@ -187,6 +179,7 @@ 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); @@ -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); diff --git a/components/nifogre/ogre_nif_loader.cpp b/components/nifogre/ogre_nif_loader.cpp index d836a27a4..4e3864a67 100644 --- a/components/nifogre/ogre_nif_loader.cpp +++ b/components/nifogre/ogre_nif_loader.cpp @@ -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 @@ -888,6 +888,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); -} + diff --git a/components/nifogre/ogre_nif_loader.hpp b/components/nifogre/ogre_nif_loader.hpp index fd1620822..b1e0943f5 100644 --- a/components/nifogre/ogre_nif_loader.hpp +++ b/components/nifogre/ogre_nif_loader.hpp @@ -111,7 +111,6 @@ class NIFLoader : Ogre::ManualResourceLoader std::vector* getAnim(std::string name); std::vector* getShapes(std::string name); std::map* 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,ciLessBoost> alltextmappings; std::map,ciLessBoost> allanimmap; std::map,ciLessBoost> allshapesmap; - std::vector addin; std::vector mAnim; std::vector mS;