mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-20 03:53:52 +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";
|
//std::cout << "Name " << copy.sname << "\n";
|
||||||
Ogre::HardwareVertexBufferSharedPtr vbuf = creaturemodel->getMesh()->getSubMesh(copy.sname)->vertexData->vertexBufferBinding->getBuffer(0);
|
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::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();
|
std::vector<Ogre::Vector3> initialVertices = copy.morph.getInitialVertices();
|
||||||
//Each shape has multiple indices
|
//Each shape has multiple indices
|
||||||
|
@ -184,13 +183,14 @@ namespace MWRender{
|
||||||
std::vector<Nif::NiSkinData::IndividualWeight> inds = iter->second;
|
std::vector<Nif::NiSkinData::IndividualWeight> inds = iter->second;
|
||||||
int verIndex = iter->first;
|
int verIndex = iter->first;
|
||||||
Ogre::Vector3 currentVertex = (*allvertices)[verIndex];
|
Ogre::Vector3 currentVertex = (*allvertices)[verIndex];
|
||||||
|
Ogre::Vector3 currentNormal = (*allnormals)[verIndex];
|
||||||
Nif::NiSkinData::BoneInfoCopy* boneinfocopy = &(allshapesiter->boneinfo[inds[0].boneinfocopyindex]);
|
Nif::NiSkinData::BoneInfoCopy* boneinfocopy = &(allshapesiter->boneinfo[inds[0].boneinfocopyindex]);
|
||||||
Ogre::Bone *bonePtr = 0;
|
Ogre::Bone *bonePtr = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Ogre::Vector3 vecPos; //= bonePtr->_getDerivedPosition() + bonePtr->_getDerivedOrientation() * boneinfocopy->trafo.trans;
|
Ogre::Vector3 vecPos;
|
||||||
Ogre::Quaternion vecRot; //= bonePtr->_getDerivedOrientation() * boneinfocopy->trafo.rotation;
|
Ogre::Quaternion vecRot;
|
||||||
std::map<Nif::NiSkinData::BoneInfoCopy*, PosAndRot>::iterator result = vecRotPos.find(boneinfocopy);
|
std::map<Nif::NiSkinData::BoneInfoCopy*, PosAndRot>::iterator result = vecRotPos.find(boneinfocopy);
|
||||||
|
|
||||||
if(result == vecRotPos.end()){
|
if(result == vecRotPos.end()){
|
||||||
|
@ -215,6 +215,7 @@ namespace MWRender{
|
||||||
Ogre::Vector3 absVertPos = (vecPos + vecRot * currentVertex) * inds[0].weight;
|
Ogre::Vector3 absVertPos = (vecPos + vecRot * currentVertex) * inds[0].weight;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for(int i = 1; i < inds.size(); i++){
|
for(int i = 1; i < inds.size(); i++){
|
||||||
boneinfocopy = &(allshapesiter->boneinfo[inds[i].boneinfocopyindex]);
|
boneinfocopy = &(allshapesiter->boneinfo[inds[i].boneinfocopyindex]);
|
||||||
result = vecRotPos.find(boneinfocopy);
|
result = vecRotPos.find(boneinfocopy);
|
||||||
|
@ -240,11 +241,13 @@ namespace MWRender{
|
||||||
|
|
||||||
absVertPos += (vecPos + vecRot * currentVertex) * inds[i].weight;
|
absVertPos += (vecPos + vecRot * currentVertex) * inds[i].weight;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Ogre::Real* addr = (pReal + 3 * verIndex);
|
Ogre::Real* addr = (pReal + 3 * verIndex);
|
||||||
*addr = absVertPos.x;
|
*addr = absVertPos.x;
|
||||||
*(addr+1) = absVertPos.y;
|
*(addr+1) = absVertPos.y;
|
||||||
*(addr+2) = absVertPos.z;
|
*(addr+2) = absVertPos.z;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -321,7 +324,7 @@ namespace MWRender{
|
||||||
|
|
||||||
}
|
}
|
||||||
vbuf->unlock();
|
vbuf->unlock();
|
||||||
//vbufNormal->unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -394,18 +397,15 @@ namespace MWRender{
|
||||||
|
|
||||||
base->getAllAnimationStates()->_notifyDirty();
|
base->getAllAnimationStates()->_notifyDirty();
|
||||||
//base->_updateAnimation();
|
//base->_updateAnimation();
|
||||||
base->_notifyMoved();
|
//base->_notifyMoved();
|
||||||
|
|
||||||
for(unsigned int i = 0; i < entityparts.size(); i++){
|
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();
|
Ogre::Bone* b = skel->getRootBone();
|
||||||
b->setOrientation(Ogre::Real(.3),Ogre::Real(.3),Ogre::Real(.3), Ogre::Real(.3));//This is a trick
|
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]->getAllAnimationStates()->_notifyDirty();
|
||||||
entityparts[i]->_notifyMoved();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -416,9 +416,7 @@ namespace MWRender{
|
||||||
if(time < iter->getStartTime() || time < startTime || time > iter->getStopTime())
|
if(time < iter->getStartTime() || time < startTime || time > iter->getStopTime())
|
||||||
{
|
{
|
||||||
slot++;
|
slot++;
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float x;
|
float x;
|
||||||
|
@ -439,7 +437,6 @@ namespace MWRender{
|
||||||
|
|
||||||
timeIndex(time, ttime, tindexI[slot], tindexJ, x);
|
timeIndex(time, ttime, tindexI[slot], tindexJ, x);
|
||||||
|
|
||||||
//std::cout << "X: " << x << " X2: " << x2 << "\n";
|
|
||||||
Ogre::Vector3 t;
|
Ogre::Vector3 t;
|
||||||
Ogre::Quaternion r;
|
Ogre::Quaternion r;
|
||||||
|
|
||||||
|
@ -454,7 +451,6 @@ namespace MWRender{
|
||||||
bool bQuats = quats.size() > 0;
|
bool bQuats = quats.size() > 0;
|
||||||
if(bQuats){
|
if(bQuats){
|
||||||
r = Ogre::Quaternion::Slerp(x2, quats[rindexI[slot]], quats[rindexJ], true);
|
r = Ogre::Quaternion::Slerp(x2, quats[rindexI[slot]], quats[rindexJ], true);
|
||||||
//bone->setOrientation(r);
|
|
||||||
}
|
}
|
||||||
skel = base->getSkeleton();
|
skel = base->getSkeleton();
|
||||||
if(skel->hasBone(iter->getBonename())){
|
if(skel->hasBone(iter->getBonename())){
|
||||||
|
@ -467,10 +463,8 @@ namespace MWRender{
|
||||||
|
|
||||||
|
|
||||||
skel->_updateTransforms();
|
skel->_updateTransforms();
|
||||||
//skel->_notifyManualBonesDirty();
|
|
||||||
base->getAllAnimationStates()->_notifyDirty();
|
base->getAllAnimationStates()->_notifyDirty();
|
||||||
//base->_updateAnimation();
|
|
||||||
base->_notifyMoved();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
slot++;
|
slot++;
|
||||||
|
|
|
@ -43,13 +43,6 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O
|
||||||
char secondtolast = bodyRaceID.at(bodyRaceID.length() - 2);
|
char secondtolast = bodyRaceID.at(bodyRaceID.length() - 2);
|
||||||
bool female = tolower(secondtolast) == 'f';
|
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_";
|
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
|
base->setSkipAnimationStateUpdate(true); //Magical line of code, this makes the bones
|
||||||
//stay in the same place when we skipanim, or open a gui window
|
//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++){
|
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)
|
if(hair)
|
||||||
insertBoundedPart("meshes\\" + hair->model, "Head");
|
insertBoundedPart("meshes\\" + hair->model, "Head");
|
||||||
|
|
||||||
|
|
||||||
if (chest){
|
if (chest){
|
||||||
insertFreePart("meshes\\" + chest->model, ">\"", insert);
|
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){
|
Ogre::Entity* NpcAnimation::insertBoundedPart(const std::string &mesh, std::string bonename){
|
||||||
|
|
||||||
NIFLoader::load(mesh);
|
NIFLoader::load(mesh);
|
||||||
Entity* ent = mRend.getScene()->createEntity(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
|
//Hardware Skinning code, textures may be the wrong color if enabled
|
||||||
/* if(!mSkel.isNull()){
|
|
||||||
material->removeAllTechniques();
|
/*material->removeAllTechniques();
|
||||||
|
|
||||||
Ogre::Technique* tech = material->createTechnique();
|
Ogre::Technique* tech = material->createTechnique();
|
||||||
//tech->setSchemeName("blahblah");
|
//tech->setSchemeName("blahblah");
|
||||||
Pass* pass = tech->createPass();
|
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
|
// This assigns the texture to this material. If the texture name is
|
||||||
// a file name, and this file exists (in a resource directory), it
|
// 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++;
|
boneIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1154,6 +1155,10 @@ void NIFLoader::loadResource(Resource *resource)
|
||||||
bool hasAnim = false;
|
bool hasAnim = false;
|
||||||
bool baddin = false;
|
bool baddin = false;
|
||||||
bNiTri = true;
|
bNiTri = true;
|
||||||
|
if(name == "meshes\\base_anim.nif" || name == "meshes\\base_animkna.nif")
|
||||||
|
{
|
||||||
|
bNiTri = false;
|
||||||
|
}
|
||||||
|
|
||||||
if(suffix == '*')
|
if(suffix == '*')
|
||||||
{
|
{
|
||||||
|
@ -1304,15 +1309,13 @@ void NIFLoader::loadResource(Resource *resource)
|
||||||
mesh->_setBounds(mBoundingBox, false);
|
mesh->_setBounds(mBoundingBox, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mSkel.isNull())
|
if (!mSkel.isNull() )
|
||||||
{
|
{
|
||||||
mesh->_notifySkeleton(mSkel);
|
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::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);
|
std::map<std::string, float>* getTextIndices(std::string name);
|
||||||
void addInMesh(Ogre::Mesh* input);
|
|
||||||
|
|
||||||
|
|
||||||
Ogre::Vector3 convertVector3(const Nif::Vector& vec);
|
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::map<std::string,float>,ciLessBoost> alltextmappings;
|
||||||
std::map<std::string,std::vector<Nif::NiKeyframeData>,ciLessBoost> allanimmap;
|
std::map<std::string,std::vector<Nif::NiKeyframeData>,ciLessBoost> allanimmap;
|
||||||
std::map<std::string,std::vector<Nif::NiTriShapeCopy>,ciLessBoost> allshapesmap;
|
std::map<std::string,std::vector<Nif::NiTriShapeCopy>,ciLessBoost> allshapesmap;
|
||||||
std::vector<Ogre::Mesh*> addin;
|
|
||||||
std::vector<Nif::NiKeyframeData> mAnim;
|
std::vector<Nif::NiKeyframeData> mAnim;
|
||||||
std::vector<Nif::NiTriShapeCopy> mS;
|
std::vector<Nif::NiTriShapeCopy> mS;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue