mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-16 15:29:55 +00:00
Merge remote branch 'jhooks/directories' into directories
Conflicts: components/files/multidircollection.hpp
This commit is contained in:
commit
a95a0f821b
15 changed files with 574 additions and 26 deletions
|
@ -7,6 +7,7 @@
|
|||
#include <utility>
|
||||
|
||||
#include <OgreVector3.h>
|
||||
#include <Ogre.h>
|
||||
|
||||
#include "components/esm/records.hpp"
|
||||
#include <components/esm_store/cell_store.hpp>
|
||||
|
@ -92,6 +93,53 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
|
|||
std::string effect;
|
||||
|
||||
MWWorld::Ptr::CellStore *current = mEnvironment.mWorld->getPlayer().getPlayer().getCell();
|
||||
/*
|
||||
ESMS::CellRefList<ESM::Creature,MWWorld::RefData>::List creatureData = (current->creatures).list;
|
||||
ESMS::CellRefList<ESM::Creature,MWWorld::RefData>::List::iterator creaturedataiter = creatureData.begin();
|
||||
|
||||
for(int i = 0; i < creatureData.size(); i++)
|
||||
{
|
||||
//std::cout << "Testing" << i < "\n";
|
||||
ESMS::LiveCellRef<ESM::Creature,MWWorld::RefData> item = *creaturedataiter;
|
||||
Ogre::Entity* creaturemodel = item.model;
|
||||
|
||||
if(evt.timeSinceLastFrame == 0)
|
||||
creaturemodel->getSkeleton()->setBindingPose();
|
||||
creaturemodel->getSkeleton()->setBlendMode(Ogre::SkeletonAnimationBlendMode::ANIMBLEND_AVERAGE); //ANIMBLEND_AVERAGE
|
||||
Ogre::AnimationState *mAnimationState = creaturemodel->getAnimationState("WholeThing");
|
||||
mAnimationState->setWeight(.5);
|
||||
mAnimationState->setLoop(true);
|
||||
//npcmodel->getSkeleton()->
|
||||
|
||||
mAnimationState->setEnabled(true);
|
||||
|
||||
|
||||
|
||||
|
||||
Ogre::AnimationState *mAnimationState2 = creaturemodel->getAnimationState("WholeThing2");
|
||||
mAnimationState2->setLoop(true);
|
||||
mAnimationState2->setWeight(.5);
|
||||
mAnimationState2->setEnabled(true);
|
||||
|
||||
mAnimationState2->createBlendMask(creaturemodel->getSkeleton()->getNumBones(),1);
|
||||
mAnimationState->createBlendMask(creaturemodel->getSkeleton()->getNumBones(),1);
|
||||
for(int j = 2; j < creaturemodel->getSkeleton()->getNumBones(); j++)
|
||||
{
|
||||
mAnimationState->setBlendMaskEntry(j,1);
|
||||
mAnimationState2->setBlendMaskEntry(j,1);
|
||||
}
|
||||
// set skeleton
|
||||
std::cout << "TimePosition:" << mAnimationState->getTimePosition() << "\n";
|
||||
|
||||
mAnimationState->addTime(evt.timeSinceLastFrame);
|
||||
mAnimationState2->addTime(evt.timeSinceLastFrame);
|
||||
//npcmodel->_updateAnimation();
|
||||
//mAnimationState2->setEnabled(true);
|
||||
creaturedataiter++;
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
//If the region has changed
|
||||
if(!(current->cell->data.flags & current->cell->Interior) && timer.elapsed() >= 10){
|
||||
timer.restart();
|
||||
|
@ -248,6 +296,13 @@ void OMW::Engine::loadBSA()
|
|||
std::cout << "Adding " << iter->second.string() << std::endl;
|
||||
addBSA (iter->second.string());
|
||||
}
|
||||
|
||||
std::string m = mDataDir.string();
|
||||
std::cout << "Data dir" << m << "\n";
|
||||
addDir(m);
|
||||
//std::string s = "f\n";
|
||||
//std::cout <<"S: " << s.size() << "\n";
|
||||
|
||||
}
|
||||
|
||||
// add resources directory
|
||||
|
@ -345,8 +400,8 @@ void OMW::Engine::go()
|
|||
|
||||
mOgre.configure(!isFile(ogreCfg.c_str()), cfgUserDir, plugCfg, false);
|
||||
|
||||
addResourcesDirectory (mDataDir / "Meshes");
|
||||
addResourcesDirectory (mDataDir / "Textures");
|
||||
//addResourcesDirectory (mDataDir / "Meshes");
|
||||
//addResourcesDirectory (mDataDir / "Textures");
|
||||
|
||||
// This has to be added BEFORE MyGUI is initialized, as it needs
|
||||
// to find core.xml here.
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace MWClass
|
|||
if (!model.empty())
|
||||
{
|
||||
MWRender::Rendering rendering (cellRender, ref->ref);
|
||||
cellRender.insertMesh ("meshes\\" + model);
|
||||
cellRender.insertMesh("meshes\\" + model);
|
||||
cellRender.insertActorPhysics();
|
||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||
}
|
||||
|
|
|
@ -118,6 +118,8 @@ namespace MWClass
|
|||
Ogre::Vector3 pos2 = Ogre::Vector3( 0, .5, 75);
|
||||
|
||||
if (groin){
|
||||
cellRender.insertMesh("Meshes\\bald_MJ_hat.NIF"); //w/W_6th_Hammer.NIF
|
||||
//bald_MJ_hat.NIF
|
||||
cellRender.insertMesh("meshes\\" + groin->model, pos2, axis, kOgrePi, npcName + "groin", addresses, numbers);
|
||||
addresses2[numbers] = npcName + "groin";
|
||||
addresses[numbers++] = npcName + "groin";
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include "../mwworld/refdata.hpp"
|
||||
#include <OgreMath.h>
|
||||
#include <Ogre.h>
|
||||
|
||||
namespace Ogre
|
||||
{
|
||||
|
@ -42,6 +43,7 @@ namespace MWRender
|
|||
virtual void insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements, bool translateFirst) = 0;
|
||||
virtual void insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements) = 0;
|
||||
virtual void insertMesh(const std::string &mesh) = 0;
|
||||
//virtual Ogre::Entity* insertAndDeliverMesh(const std::string &mesh) = 0;
|
||||
|
||||
virtual void scaleMesh(Ogre::Vector3 axis, std::string sceneNodeName[], int elements) = 0;
|
||||
|
||||
|
|
|
@ -273,6 +273,21 @@ std::string ExteriorCellRender::insertEnd (bool enable)
|
|||
return handle;
|
||||
}
|
||||
|
||||
/*
|
||||
Ogre::Entity* ExteriorCellRender::insertAndDeliverMesh(const std::string &mesh)
|
||||
{
|
||||
assert (insert);
|
||||
|
||||
NIFLoader::load(mesh);
|
||||
Entity *ent = mScene.getMgr()->createEntity(mesh);
|
||||
ent->setDisplaySkeleton(true);
|
||||
|
||||
|
||||
mInsert->attachObject(ent);
|
||||
return ent;
|
||||
|
||||
}*/
|
||||
|
||||
// configure lighting according to cell
|
||||
|
||||
void ExteriorCellRender::configureAmbient()
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "OgreColourValue.h"
|
||||
#include <OgreMath.h>
|
||||
#include <Ogre.h>
|
||||
|
||||
namespace Ogre
|
||||
{
|
||||
|
@ -70,6 +71,7 @@ namespace MWRender
|
|||
virtual void insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements, bool translateFirst);
|
||||
|
||||
virtual void insertMesh(const std::string &mesh);
|
||||
//virtual Ogre::Entity* insertAndDeliverMesh(const std::string &mesh);
|
||||
virtual void rotateMesh(Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName[], int elements);
|
||||
virtual void scaleMesh(Ogre::Vector3 axis, std::string sceneNodeName[], int elements);
|
||||
|
||||
|
|
|
@ -180,11 +180,30 @@ void InteriorCellRender::insertMesh(const std::string &mesh, Ogre::Vector3 vec,
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Ogre::Entity* InteriorCellRender::insertAndDeliverMesh(const std::string &mesh)
|
||||
{
|
||||
|
||||
assert (insert);
|
||||
|
||||
NIFLoader::load(mesh);
|
||||
Entity *ent = scene.getMgr()->createEntity(mesh);
|
||||
ent->setDisplaySkeleton(true);
|
||||
|
||||
|
||||
insert->attachObject(ent);
|
||||
return ent;
|
||||
|
||||
}*/
|
||||
|
||||
|
||||
void InteriorCellRender::insertMesh(const std::string &mesh)
|
||||
{
|
||||
assert (insert);
|
||||
|
||||
NIFLoader::load(mesh);
|
||||
//if(mesh == "\\Meshes\\bald_MJ_hat.NIF")
|
||||
// NIFLoader::load(mesh, "");
|
||||
//else
|
||||
NIFLoader::load(mesh);
|
||||
MovableObject *ent = scene.getMgr()->createEntity(mesh);
|
||||
insert->attachObject(ent);
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "OgreColourValue.h"
|
||||
#include <OgreSceneNode.h>
|
||||
#include <Ogre.h>
|
||||
|
||||
namespace Ogre
|
||||
{
|
||||
|
@ -67,6 +68,7 @@ namespace MWRender
|
|||
virtual void rotateMesh(Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName[], int elements);
|
||||
virtual void scaleMesh(Ogre::Vector3 axis, std::string sceneNodeName[], int elements);
|
||||
/// insert a mesh related to the most recent insertBegin call.
|
||||
//virtual Ogre::Entity* insertAndDeliverMesh(const std::string &mesh);
|
||||
virtual void insertMesh(const std::string &mesh);
|
||||
virtual void insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements);
|
||||
virtual void insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements, bool translateFirst);
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
#include "bsa_archive.hpp"
|
||||
|
||||
#include <OgreFileSystem.h>
|
||||
#include <OgreArchive.h>
|
||||
#include <OgreArchiveFactory.h>
|
||||
#include <OgreArchiveManager.h>
|
||||
|
@ -33,6 +34,53 @@ using namespace Ogre;
|
|||
using namespace Mangle::Stream;
|
||||
|
||||
/// An OGRE Archive wrapping a BSAFile archive
|
||||
class DirArchive: public Ogre::FileSystemArchive
|
||||
{
|
||||
//FileSystemArchive* arc;
|
||||
public:
|
||||
|
||||
DirArchive(const String& name)
|
||||
: FileSystemArchive(name, "Dir")
|
||||
{ mType = "Dir";}
|
||||
|
||||
bool isCaseSensitive() const { return false; }
|
||||
|
||||
// The archive is loaded in the constructor, and never unloaded.
|
||||
void load() {}
|
||||
void unload() {}
|
||||
|
||||
bool exists(const String& filename) {
|
||||
std::string copy = filename;
|
||||
if(OGRE_PLATFORM != OGRE_PLATFORM_WIN32)
|
||||
{
|
||||
|
||||
for (int i = 0; i < filename.size(); i++)
|
||||
{
|
||||
if(copy.at(i) == '\\' ){
|
||||
copy.replace(i, 1, "/");
|
||||
}
|
||||
}
|
||||
}
|
||||
return FileSystemArchive::exists(copy);
|
||||
}
|
||||
|
||||
DataStreamPtr open(const String& filename, bool readonly = true) const
|
||||
{
|
||||
std::string copy = filename;
|
||||
if(OGRE_PLATFORM != OGRE_PLATFORM_WIN32){
|
||||
//std::cout << "In Open\n";
|
||||
for (int i = 0; i < filename.size(); i++)
|
||||
{
|
||||
if(copy.at(i) == '\\' ){
|
||||
copy.replace(i, 1, "/");
|
||||
}
|
||||
}
|
||||
}
|
||||
return FileSystemArchive::open(copy, readonly);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class BSAArchive : public Archive
|
||||
{
|
||||
BSAFile arc;
|
||||
|
@ -145,7 +193,26 @@ public:
|
|||
void destroyInstance( Archive* arch) { delete arch; }
|
||||
};
|
||||
|
||||
class DirArchiveFactory : public FileSystemArchiveFactory
|
||||
{
|
||||
public:
|
||||
const String& getType() const
|
||||
{
|
||||
static String name = "Dir";
|
||||
return name;
|
||||
}
|
||||
|
||||
Archive *createInstance( const String& name )
|
||||
{
|
||||
return new DirArchive(name);
|
||||
}
|
||||
|
||||
void destroyInstance( Archive* arch) { delete arch; }
|
||||
};
|
||||
|
||||
|
||||
static bool init = false;
|
||||
static bool init2 = false;
|
||||
static void insertBSAFactory()
|
||||
{
|
||||
if(!init)
|
||||
|
@ -155,6 +222,15 @@ static void insertBSAFactory()
|
|||
}
|
||||
}
|
||||
|
||||
static void insertDirFactory()
|
||||
{
|
||||
if(!init2)
|
||||
{
|
||||
ArchiveManager::getSingleton().addArchiveFactory( new DirArchiveFactory );
|
||||
init = true;
|
||||
}
|
||||
}
|
||||
|
||||
// The function below is the only publicly exposed part of this file
|
||||
|
||||
void addBSA(const std::string& name, const std::string& group)
|
||||
|
@ -163,3 +239,9 @@ void addBSA(const std::string& name, const std::string& group)
|
|||
ResourceGroupManager::getSingleton().
|
||||
addResourceLocation(name, "BSA", group);
|
||||
}
|
||||
void addDir(const std::string& name, const std::string& group)
|
||||
{
|
||||
insertDirFactory();
|
||||
ResourceGroupManager::getSingleton().
|
||||
addResourceLocation(name, "Dir", group);
|
||||
}
|
||||
|
|
|
@ -29,5 +29,6 @@
|
|||
/// Add the given BSA file as an input archive in the Ogre resource
|
||||
/// system.
|
||||
void addBSA(const std::string& file, const std::string& group="General");
|
||||
void addDir(const std::string& file, const std::string& group="General");
|
||||
|
||||
#endif
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "components/esm/records.hpp"
|
||||
#include "components/esm/loadcell.hpp"
|
||||
#include <list>
|
||||
#include <Ogre.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
|
@ -29,6 +30,8 @@ namespace ESMS
|
|||
// The object that this instance is based on.
|
||||
const X* base;
|
||||
|
||||
Ogre::Entity *model;
|
||||
|
||||
/* Information about this instance, such as 3D location and
|
||||
rotation and individual type-dependent data.
|
||||
*/
|
||||
|
|
|
@ -23,11 +23,12 @@ namespace Files
|
|||
return left<right;
|
||||
|
||||
std::size_t min = std::min (left.length(), right.length());
|
||||
std::locale loc;
|
||||
|
||||
for (std::size_t i=0; i<min; ++i)
|
||||
{
|
||||
char l = std::tolower (left[i]);
|
||||
char r = std::tolower (right[i]);
|
||||
char l = std::tolower (left[i], loc);
|
||||
char r = std::tolower (right[i], loc);
|
||||
|
||||
if (l<r)
|
||||
return true;
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
#define _NIF_DATA_H_
|
||||
|
||||
#include "controlled.hpp"
|
||||
#include <iostream>
|
||||
#include <Ogre.h>
|
||||
|
||||
namespace Nif
|
||||
{
|
||||
|
@ -433,20 +435,91 @@ public:
|
|||
|
||||
class NiKeyframeData : public Record
|
||||
{
|
||||
|
||||
//Rotations
|
||||
std::vector<Ogre::Quaternion> quats;
|
||||
std::vector<Ogre::Vector3> tbc;
|
||||
std::vector<float> rottime;
|
||||
int rtype;
|
||||
|
||||
//Translations
|
||||
std::vector<Ogre::Vector3> translist1;
|
||||
std::vector<Ogre::Vector3> translist2;
|
||||
std::vector<Ogre::Vector3> translist3;
|
||||
std::vector<Ogre::Vector3> transtbc;
|
||||
std::vector<float> transtime;
|
||||
int ttype;
|
||||
|
||||
//Scalings
|
||||
|
||||
std::vector<float> scalefactor;
|
||||
std::vector<float> scaletime;
|
||||
std::vector<float> forwards;
|
||||
std::vector<float> backwards;
|
||||
std::vector<Ogre::Vector3> tbcscale;
|
||||
int stype;
|
||||
|
||||
public:
|
||||
|
||||
void read(NIFFile *nif)
|
||||
{
|
||||
// Rotations first
|
||||
int count = nif->getInt();
|
||||
//std::vector<Ogre::Quaternion> quat(count);
|
||||
//std::vector<float> rottime(count);
|
||||
std::cout << "r";
|
||||
if(count)
|
||||
{
|
||||
int type = nif->getInt();
|
||||
|
||||
if(type == 1)
|
||||
nif->skip(count*4*5); // time + quaternion
|
||||
else if(type == 3)
|
||||
nif->skip(count*4*8); // rot1 + tension+bias+continuity
|
||||
else if(type == 4)
|
||||
//TYPE1 LINEAR_KEY
|
||||
//TYPE2 QUADRATIC_KEY
|
||||
//TYPE3 TBC_KEY
|
||||
//TYPE4 XYZ_ROTATION_KEY
|
||||
//TYPE5 UNKNOWN_KEY
|
||||
rtype = nif->getInt();
|
||||
//std::cout << "Count: " << count << "Type: " << type << "\n";
|
||||
|
||||
if(rtype == 1)
|
||||
{
|
||||
//We need to actually read in these values instead of skipping them
|
||||
//nif->skip(count*4*5); // time + quaternion
|
||||
for (int i = 0; i < count; i++) {
|
||||
float time = nif->getFloat();
|
||||
float w = nif->getFloat();
|
||||
float x = nif->getFloat();
|
||||
float y = nif->getFloat();
|
||||
float z = nif->getFloat();
|
||||
Ogre::Quaternion quat = Ogre::Quaternion(Ogre::Real(w), Ogre::Real(x), Ogre::Real(y), Ogre::Real(z));
|
||||
quats.push_back(quat);
|
||||
rottime.push_back(time);
|
||||
//if(time == 0.0 || time > 355.5)
|
||||
// std::cout <<"Time:" << time << "W:" << w <<"X:" << x << "Y:" << y << "Z:" << z << "\n";
|
||||
}
|
||||
}
|
||||
else if(rtype == 3)
|
||||
{ //Example - node 116 in base_anim.nif
|
||||
for (int i = 0; i < count; i++) {
|
||||
float time = nif->getFloat();
|
||||
float w = nif->getFloat();
|
||||
float x = nif->getFloat();
|
||||
float y = nif->getFloat();
|
||||
float z = nif->getFloat();
|
||||
|
||||
float tbcx = nif->getFloat();
|
||||
float tbcy = nif->getFloat();
|
||||
float tbcz = nif->getFloat();
|
||||
Ogre::Quaternion quat = Ogre::Quaternion(Ogre::Real(w), Ogre::Real(x), Ogre::Real(y), Ogre::Real(z));
|
||||
Ogre::Vector3 vec = Ogre::Vector3(tbcx, tbcy, tbcz);
|
||||
quats.push_back(quat);
|
||||
rottime.push_back(time);
|
||||
tbc.push_back(vec);
|
||||
//if(time == 0.0 || time > 355.5)
|
||||
// std::cout <<"Time:" << time << "W:" << w <<"X:" << x << "Y:" << y << "Z:" << z << "\n";
|
||||
}
|
||||
|
||||
//nif->skip(count*4*8); // rot1 + tension+bias+continuity
|
||||
}
|
||||
else if(rtype == 4)
|
||||
{
|
||||
for(int j=0;j<count;j++)
|
||||
{
|
||||
|
@ -465,18 +538,69 @@ public:
|
|||
}
|
||||
else nif->fail("Unknown rotation type in NiKeyframeData");
|
||||
}
|
||||
//first = false;
|
||||
|
||||
// Then translation
|
||||
count = nif->getInt();
|
||||
|
||||
if(count)
|
||||
{
|
||||
int type = nif->getInt();
|
||||
ttype = nif->getInt();
|
||||
|
||||
if(type == 1) nif->getFloatLen(count*4); // time + translation
|
||||
else if(type == 2)
|
||||
nif->getFloatLen(count*10); // trans1 + forward + backward
|
||||
else if(type == 3)
|
||||
nif->getFloatLen(count*7); // trans1 + tension,bias,continuity
|
||||
//std::cout << "TransCount:" << count << " Type: " << type << "\n";
|
||||
if(ttype == 1) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
float time = nif->getFloat();
|
||||
float x = nif->getFloat();
|
||||
float y = nif->getFloat();
|
||||
float z = nif->getFloat();
|
||||
Ogre::Vector3 trans = Ogre::Vector3(x, y, z);
|
||||
translist1.push_back(trans);
|
||||
transtime.push_back(time);
|
||||
}
|
||||
//nif->getFloatLen(count*4); // time + translation
|
||||
}
|
||||
else if(ttype == 2)
|
||||
{ //Example - node 116 in base_anim.nif
|
||||
for (int i = 0; i < count; i++) {
|
||||
float time = nif->getFloat();
|
||||
float x = nif->getFloat();
|
||||
float y = nif->getFloat();
|
||||
float z = nif->getFloat();
|
||||
float x2 = nif->getFloat();
|
||||
float y2 = nif->getFloat();
|
||||
float z2 = nif->getFloat();
|
||||
float x3 = nif->getFloat();
|
||||
float y3 = nif->getFloat();
|
||||
float z3 = nif->getFloat();
|
||||
Ogre::Vector3 trans = Ogre::Vector3(x, y, z);
|
||||
Ogre::Vector3 trans2 = Ogre::Vector3(x2, y2, z2);
|
||||
Ogre::Vector3 trans3 = Ogre::Vector3(x3, y3, z3);
|
||||
transtime.push_back(time);
|
||||
translist1.push_back(trans);
|
||||
translist2.push_back(trans2);
|
||||
translist3.push_back(trans3);
|
||||
}
|
||||
|
||||
//nif->getFloatLen(count*10); // trans1 + forward + backward
|
||||
}
|
||||
else if(ttype == 3){
|
||||
for (int i = 0; i < count; i++) {
|
||||
float time = nif->getFloat();
|
||||
float x = nif->getFloat();
|
||||
float y = nif->getFloat();
|
||||
float z = nif->getFloat();
|
||||
float t = nif->getFloat();
|
||||
float b = nif->getFloat();
|
||||
float c = nif->getFloat();
|
||||
Ogre::Vector3 trans = Ogre::Vector3(x, y, z);
|
||||
Ogre::Vector3 tbc = Ogre::Vector3(t, b, c);
|
||||
translist1.push_back(trans);
|
||||
transtbc.push_back(tbc);
|
||||
transtime.push_back(time);
|
||||
}
|
||||
//nif->getFloatLen(count*7); // trans1 + tension,bias,continuity
|
||||
}
|
||||
else nif->fail("Unknown translation type");
|
||||
}
|
||||
|
||||
|
@ -484,17 +608,93 @@ public:
|
|||
count = nif->getInt();
|
||||
if(count)
|
||||
{
|
||||
int type = nif->getInt();
|
||||
stype = nif->getInt();
|
||||
|
||||
int size = 0;
|
||||
if(type == 1) size = 2; // time+scale
|
||||
else if(type == 2) size = 4; // 1 + forward + backward (floats)
|
||||
else if(type == 3) size = 5; // 1 + tbc
|
||||
else nif->fail("Unknown scaling type");
|
||||
nif->getFloatLen(count*size);
|
||||
|
||||
for(int i = 0; i < count; i++){
|
||||
|
||||
|
||||
//int size = 0;
|
||||
if(stype >= 1 && stype < 4)
|
||||
{
|
||||
float time = nif->getFloat();
|
||||
float scale = nif->getFloat();
|
||||
scaletime.push_back(time);
|
||||
scalefactor.push_back(scale);
|
||||
//size = 2; // time+scale
|
||||
}
|
||||
else nif->fail("Unknown scaling type");
|
||||
if(stype == 2){
|
||||
//size = 4; // 1 + forward + backward (floats)
|
||||
float forward = nif->getFloat();
|
||||
float backward = nif->getFloat();
|
||||
forwards.push_back(forward);
|
||||
backwards.push_back(backward);
|
||||
}
|
||||
else if(stype == 3){
|
||||
float tbcx = nif->getFloat();
|
||||
float tbcy = nif->getFloat();
|
||||
float tbcz = nif->getFloat();
|
||||
Ogre::Vector3 vec = Ogre::Vector3(tbcx, tbcy, tbcz);
|
||||
tbcscale.push_back(vec);
|
||||
|
||||
//size = 5; // 1 + tbc
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
stype = 0;
|
||||
}
|
||||
int getRtype(){
|
||||
return rtype;
|
||||
}
|
||||
int getStype(){
|
||||
return stype;
|
||||
}
|
||||
int getTtype(){
|
||||
return ttype;
|
||||
}
|
||||
std::vector<Ogre::Quaternion> getQuat(){
|
||||
return quats;
|
||||
}
|
||||
std::vector<Ogre::Vector3> getrTbc(){
|
||||
return tbc;
|
||||
}
|
||||
std::vector<float> getrTime(){
|
||||
return rottime;
|
||||
}
|
||||
|
||||
std::vector<Ogre::Vector3> getTranslist1(){
|
||||
return translist1;
|
||||
}
|
||||
std::vector<Ogre::Vector3> getTranslist2(){
|
||||
return translist2;
|
||||
}
|
||||
std::vector<Ogre::Vector3> getTranslist3(){
|
||||
return translist3;
|
||||
}
|
||||
std::vector<float> gettTime(){
|
||||
return transtime;
|
||||
}
|
||||
std::vector<float> getScalefactor(){
|
||||
return scalefactor;
|
||||
}
|
||||
std::vector<float> getForwards(){
|
||||
return forwards;
|
||||
}
|
||||
std::vector<float> getBackwards(){
|
||||
return backwards;
|
||||
}
|
||||
std::vector<Ogre::Vector3> getScaleTbc(){
|
||||
return tbcscale;
|
||||
}
|
||||
|
||||
std::vector<float> getsTime(){
|
||||
return scaletime;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // Namespace
|
||||
#endif
|
||||
|
|
|
@ -1068,6 +1068,11 @@ void NIFLoader::loadResource(Resource *resource)
|
|||
// Handle the node
|
||||
handleNode(node, 0, NULL, bounds, 0);
|
||||
|
||||
|
||||
short handle = 0;
|
||||
//skel->setBlendMode(Ogre::SkeletonAnimationBlendMode::ANIMBLEND_CUMULATIVE);
|
||||
bool first = true;
|
||||
|
||||
// set the bounding value.
|
||||
if (bounds.isValid())
|
||||
{
|
||||
|
@ -1075,6 +1080,161 @@ void NIFLoader::loadResource(Resource *resource)
|
|||
bounds.maxX(), bounds.maxY(), bounds.maxZ()));
|
||||
mesh->_setBoundingSphereRadius(bounds.getRadius());
|
||||
}
|
||||
for(int i = 0; i < nif.numRecords(); i++)
|
||||
{
|
||||
|
||||
Nif::NiKeyframeController *f = dynamic_cast<Nif::NiKeyframeController*>(nif.getRecord(i));
|
||||
Nif::Node *n = dynamic_cast<Nif::Node*>(nif.getRecord(i));
|
||||
|
||||
|
||||
if(f != NULL)
|
||||
{
|
||||
Nif::NiKeyframeDataPtr data = f->data;
|
||||
std::cout << "Controller's Rtype:" << data->getRtype() << "Stype: " << data->getStype() << "Ttype:" << data->getTtype() << "\n";
|
||||
|
||||
if(first){
|
||||
|
||||
float end = f->timeStop;
|
||||
//std::cout <<"Creating WholeThing" << end << "\n";
|
||||
|
||||
//TRANSLATION
|
||||
if(!mSkel.isNull()){
|
||||
std::cout <<"Creating WholeThing" << end << "\n";
|
||||
animcore = mSkel->createAnimation("WholeThing", end);
|
||||
//animcore->setInterpolationMode(Ogre::Animation::IM_SPLINE);
|
||||
//animcore->setRotationInterpolationMode(Ogre::Animation::RIM_SPHERICAL);
|
||||
//animcore2->setRotationInterpolationMode(Ogre::Animation::RIM_LINEAR);
|
||||
|
||||
//ROTATION
|
||||
animcore2 = mSkel->createAnimation("WholeThing2", end);
|
||||
//animcore2->setInterpolationMode(Ogre::Animation::IM_SPLINE);
|
||||
//animcore2->setRotationInterpolationMode(Ogre::Animation::RIM_SPHERICAL);
|
||||
}
|
||||
std::cout <<"AFTER";
|
||||
first = false;
|
||||
}
|
||||
if(animcore && animcore2){
|
||||
Nif::Named *node = dynamic_cast<Nif::Named*> ( f->target.getPtr());
|
||||
std::cout << "The target rec: " << node->name.toString() << "\n";
|
||||
Ogre::NodeAnimationTrack* mTrack = animcore->createNodeTrack(handle, mSkel->getBone(node->name.toString()));
|
||||
Ogre::NodeAnimationTrack* mTrack2 = animcore2->createNodeTrack(handle++, mSkel->getBone(node->name.toString()));
|
||||
/* if (node->recType == RC_NiNode)
|
||||
{
|
||||
NodeList &list = ((NiNode*)node)->children;
|
||||
int n = list.length();
|
||||
|
||||
for (int i = n; i<=n; i++)
|
||||
{
|
||||
if(skel->hasBone((list[i]).name.toString()))
|
||||
mTrack3 = animcore2->createNodeTrack(handle++, skel->getBone((list[i]).name.toString()));
|
||||
|
||||
}
|
||||
}*/
|
||||
|
||||
std::vector<Ogre::Quaternion> quats = data->getQuat();
|
||||
std::vector<Ogre::Quaternion>::iterator quatIter = quats.begin();
|
||||
std::vector<float> rtime = data->getrTime();
|
||||
std::vector<float>::iterator rtimeiter = rtime.begin();
|
||||
|
||||
std::vector<float> ttime = data->gettTime();
|
||||
std::vector<float>::iterator ttimeiter = ttime.begin();
|
||||
std::vector<Ogre::Vector3> translist1 = data->getTranslist1();
|
||||
std::vector<Ogre::Vector3>::iterator transiter = translist1.begin();
|
||||
std::vector<Ogre::Vector3> translist2 = data->getTranslist2();
|
||||
std::vector<Ogre::Vector3>::iterator transiter2 = translist2.begin();
|
||||
std::vector<Ogre::Vector3> translist3 = data->getTranslist3();
|
||||
std::vector<Ogre::Vector3>::iterator transiter3 = translist3.begin();
|
||||
|
||||
|
||||
float tleft = 0;
|
||||
float rleft = 0.0;
|
||||
float ttotal = 0.0;
|
||||
float rtotal = 0;
|
||||
Ogre::TransformKeyFrame* mKey;
|
||||
Ogre::TransformKeyFrame* mKey2;
|
||||
float tused = 0.0;
|
||||
float rused = 0.0;
|
||||
Ogre::Quaternion lastquat;
|
||||
Ogre::Vector3 lasttrans;
|
||||
bool rend = false;
|
||||
bool tend = false;
|
||||
Ogre::Quaternion test;// = (skel->getBone(node->name.toString()))->getOrientation();
|
||||
for (int j = 0 ; j < ttime.size(); j++)
|
||||
{
|
||||
if(data->getTtype() >= 1 && data->getTtype() <= 5)
|
||||
{
|
||||
|
||||
Ogre::TransformKeyFrame* mKey = mTrack->createNodeKeyFrame(*ttimeiter);
|
||||
Ogre::Vector3 standard = *transiter;
|
||||
if(data->getTtype() == 2)
|
||||
standard = *transiter * *transiter2 * *transiter3;
|
||||
|
||||
mKey->setTranslate(standard);/*
|
||||
if(mTrack3)
|
||||
{
|
||||
Ogre::TransformKeyFrame* mKey3 = mTrack->createNodeKeyFrame(*ttimeiter);
|
||||
mKey3->setTranslate(standard);
|
||||
}*/
|
||||
//mKey->setRotation(Quaternion::ZERO);
|
||||
//mKey->setScale(Ogre::Vector3(1,1,1));
|
||||
transiter++; //START
|
||||
transiter2++;
|
||||
transiter3++;
|
||||
ttimeiter++;
|
||||
}
|
||||
}
|
||||
for (int j = 0 ; j < rtime.size(); j++)
|
||||
{
|
||||
if(data->getRtype() >= 1 && data->getRtype() <= 5)
|
||||
{
|
||||
Ogre::TransformKeyFrame* mKey2 = mTrack2->createNodeKeyFrame(*rtimeiter);
|
||||
test = *quatIter;
|
||||
|
||||
mKey2->setRotation(test);
|
||||
//mKey2->setTranslate(Ogre::Vector3(0,0,0));
|
||||
//mKey2->setScale(Ogre::Vector3(1,1,1));
|
||||
quatIter++;
|
||||
rtimeiter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
//mTrack = animcore->createNodeTrack(handle++, skel->getBone(node->name.toString()));
|
||||
|
||||
std::vector<float> stime = data->getsTime();
|
||||
std::vector<float>::iterator stimeiter = stime.begin();
|
||||
|
||||
std::vector<float> sfactor = data->getScalefactor();
|
||||
std::vector<float>::iterator sfactoriter = sfactor.begin();
|
||||
for (int i = 0 ; i < stime.size(); i++)
|
||||
{
|
||||
if(data->getStype() >= 1 && data->getStype() <= 5)
|
||||
{
|
||||
Ogre::TransformKeyFrame* mKey = mTrack->createNodeKeyFrame(*stimeiter);
|
||||
mKey->setScale(Ogre::Vector3(*sfactoriter, *sfactoriter, *sfactoriter));
|
||||
|
||||
sfactoriter++;
|
||||
stimeiter++;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
//std::cout <"BE\n";
|
||||
}
|
||||
|
||||
// set skeleton
|
||||
if (!mSkel.isNull() && mesh->isLoaded())
|
||||
{
|
||||
mesh->_notifySkeleton(mSkel);
|
||||
std::cout << "Skeleton notified\n";
|
||||
}
|
||||
|
||||
// set skeleton
|
||||
// if (!skel.isNull())
|
||||
|
|
|
@ -131,6 +131,10 @@ class NIFLoader : Ogre::ManualResourceLoader
|
|||
int counter;
|
||||
int numbers;
|
||||
int stack;
|
||||
bool anim;
|
||||
int handle2;
|
||||
Ogre::Animation* animcore;
|
||||
Ogre::Animation* animcore2;
|
||||
|
||||
|
||||
// pointer to the ogre mesh which is currently build
|
||||
|
|
Loading…
Reference in a new issue