more cleanup

pull/21/head
Marc Zinnschlag 14 years ago
parent bdd995ec91
commit 0f2df4e2b8

@ -353,9 +353,6 @@ void OMW::Engine::go()
mOgre.configure(!isFile(ogreCfg.c_str()), cfgUserDir, plugCfg, false); mOgre.configure(!isFile(ogreCfg.c_str()), cfgUserDir, plugCfg, false);
//addResourcesDirectory (mDataDir / "Meshes");
//addResourcesDirectory (mDataDir / "Textures");
// This has to be added BEFORE MyGUI is initialized, as it needs // This has to be added BEFORE MyGUI is initialized, as it needs
// to find core.xml here. // to find core.xml here.
addResourcesDirectory(mResDir / "mygui"); addResourcesDirectory(mResDir / "mygui");

@ -34,7 +34,7 @@ namespace MWClass
if (!model.empty()) if (!model.empty())
{ {
MWRender::Rendering rendering (cellRender, ref->ref); MWRender::Rendering rendering (cellRender, ref->ref);
cellRender.insertMesh("meshes\\" + model); cellRender.insertMesh("meshes\\" + model);
cellRender.insertActorPhysics(); cellRender.insertActorPhysics();
ref->mData.setHandle (rendering.end (ref->mData.isEnabled())); ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
} }

@ -7,7 +7,6 @@
#include "../mwworld/refdata.hpp" #include "../mwworld/refdata.hpp"
#include <OgreMath.h> #include <OgreMath.h>
#include <Ogre.h>
namespace Ogre namespace Ogre
{ {
@ -43,7 +42,6 @@ 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, 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, 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 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; virtual void scaleMesh(Ogre::Vector3 axis, std::string sceneNodeName[], int elements) = 0;

@ -273,21 +273,6 @@ std::string ExteriorCellRender::insertEnd (bool enable)
return handle; 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 // configure lighting according to cell
void ExteriorCellRender::configureAmbient() void ExteriorCellRender::configureAmbient()

@ -71,7 +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, 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 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 rotateMesh(Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName[], int elements);
virtual void scaleMesh(Ogre::Vector3 axis, std::string sceneNodeName[], int elements); virtual void scaleMesh(Ogre::Vector3 axis, std::string sceneNodeName[], int elements);

@ -180,32 +180,13 @@ 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) void InteriorCellRender::insertMesh(const std::string &mesh)
{ {
assert (insert); assert (insert);
//if(mesh == "\\Meshes\\bald_MJ_hat.NIF")
// NIFLoader::load(mesh, ""); NIFLoader::load(mesh);
//else MovableObject *ent = scene.getMgr()->createEntity(mesh);
NIFLoader::load(mesh); insert->attachObject(ent);
MovableObject *ent = scene.getMgr()->createEntity(mesh);
insert->attachObject(ent);
if (mInsertMesh.empty()) if (mInsertMesh.empty())
mInsertMesh = mesh; mInsertMesh = mesh;

@ -6,7 +6,6 @@
#include "OgreColourValue.h" #include "OgreColourValue.h"
#include <OgreSceneNode.h> #include <OgreSceneNode.h>
#include <Ogre.h>
namespace Ogre namespace Ogre
{ {
@ -68,7 +67,6 @@ namespace MWRender
virtual void rotateMesh(Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName[], int elements); 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); virtual void scaleMesh(Ogre::Vector3 axis, std::string sceneNodeName[], int elements);
/// insert a mesh related to the most recent insertBegin call. /// 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);
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);
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, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements, bool translateFirst);

@ -63,7 +63,7 @@ namespace MWSound
*/ */
OEManagerPtr mgr; OEManagerPtr mgr;
SoundPtr music; SoundPtr music;
/* This class calls update() on the sound manager each frame /* This class calls update() on the sound manager each frame
using and Ogre::FrameListener using and Ogre::FrameListener
*/ */
@ -84,11 +84,11 @@ namespace MWSound
// finding. It takes DOS paths (any case, \\ slashes or / slashes) // finding. It takes DOS paths (any case, \\ slashes or / slashes)
// relative to the sound dir, and translates them into full paths // relative to the sound dir, and translates them into full paths
// of existing files in the filesystem, if they exist. // of existing files in the filesystem, if they exist.
bool FSstrict; bool FSstrict;
FileFinder::FileFinder files; FileFinder::FileFinder files;
FileFinder::FileFinderStrict strict; FileFinder::FileFinderStrict strict;
FileFinder::FileFinder musicpath; FileFinder::FileFinder musicpath;
FileFinder::FileFinderStrict musicpathStrict; FileFinder::FileFinderStrict musicpathStrict;
SoundImpl(Ogre::Root *root, Ogre::Camera *camera, SoundImpl(Ogre::Root *root, Ogre::Camera *camera,
const ESMS::ESMStore &str, const ESMS::ESMStore &str,
@ -98,9 +98,9 @@ namespace MWSound
, cameraTracker(mgr) , cameraTracker(mgr)
, store(str) , store(str)
, files(soundDir), strict(soundDir) , files(soundDir), strict(soundDir)
,musicpath(musicDir), musicpathStrict(musicDir) ,musicpath(musicDir), musicpathStrict(musicDir)
{ {
FSstrict = fsstrict; FSstrict = fsstrict;
cout << "Sound output: " << SOUND_OUT << endl; cout << "Sound output: " << SOUND_OUT << endl;
cout << "Sound decoder: " << SOUND_IN << endl; cout << "Sound decoder: " << SOUND_IN << endl;
// Attach the camera to the camera tracker // Attach the camera to the camera tracker
@ -131,72 +131,74 @@ namespace MWSound
bool hasFile(const std::string &str, bool music = false) bool hasFile(const std::string &str, bool music = false)
{ {
if(FSstrict == false){ if(FSstrict == false)
if(music){ {
if(musicpath.has(str)) return true; if(music)
// Not found? Try with .mp3 {
return musicpath.has(toMp3(str)); if(musicpath.has(str)) return true;
}
else // Not found? Try with .mp3
{ return musicpath.has(toMp3(str));
if(files.has(str)) return true; }
return files.has(toMp3(str)); else
} {
} if(files.has(str)) return true;
else return files.has(toMp3(str));
{ }
if(music){ }
if(musicpathStrict.has(str)) return true; else
// Not found? Try with .mp3 {
return musicpathStrict.has(toMp3(str)); if(music)
} {
else if(musicpathStrict.has(str)) return true;
{
if(strict.has(str)) return true; // Not found? Try with .mp3
return strict.has(toMp3(str)); return musicpathStrict.has(toMp3(str));
} }
else
} {
} if(strict.has(str)) return true;
return strict.has(toMp3(str));
}
}
}
// Convert a Morrowind sound path (eg. Fx\funny.wav) to full path // Convert a Morrowind sound path (eg. Fx\funny.wav) to full path
// with proper slash conversion (eg. datadir/Sound/Fx/funny.wav) // with proper slash conversion (eg. datadir/Sound/Fx/funny.wav)
std::string convertPath(const std::string &str, bool music = false) std::string convertPath(const std::string &str, bool music = false)
{ {
if(FSstrict == false){ if(FSstrict == false)
// Search and return {
if(music && musicpath.has(str)) // Search and return
return musicpath.lookup(str); if(music && musicpath.has(str))
else if(files.has(str)) return musicpath.lookup(str);
return files.lookup(str); else if(files.has(str))
return files.lookup(str);
// Try mp3 if the wav wasn't found // Try mp3 if the wav wasn't found
std::string mp3 = toMp3(str); std::string mp3 = toMp3(str);
if(music && musicpath.has(mp3)) if(music && musicpath.has(mp3))
return musicpath.lookup(mp3); return musicpath.lookup(mp3);
else if(files.has(mp3)) else if(files.has(mp3))
return files.lookup(mp3); return files.lookup(mp3);
} }
else
else {
{ if(music && musicpathStrict.has(str))
if(music && musicpathStrict.has(str)) return musicpathStrict.lookup(str);
return musicpathStrict.lookup(str); else if(strict.has(str))
else if(strict.has(str)) return strict.lookup(str);
return strict.lookup(str);
// Try mp3 if the wav wasn't found
std::string mp3 = toMp3(str);
// Try mp3 if the wav wasn't found if(music && musicpathStrict.has(mp3))
std::string mp3 = toMp3(str); return musicpathStrict.lookup(mp3);
if(music && musicpathStrict.has(mp3)) else if(strict.has(str))
return musicpathStrict.lookup(mp3); return strict.lookup(mp3);
else if(strict.has(str)) }
return strict.lookup(mp3);
} // Give up
return "";
// Give up
return "";
} }
// Convert a soundId to file name, and modify the volume // Convert a soundId to file name, and modify the volume
@ -377,9 +379,8 @@ namespace MWSound
const ESMS::ESMStore &store, const ESMS::ESMStore &store,
boost::filesystem::path dataDir, boost::filesystem::path dataDir,
bool useSound, bool fsstrict) bool useSound, bool fsstrict)
: mData(NULL) : mData(NULL), fsStrict (fsstrict)
{ {
fsStrict = fsstrict;
MP3Lookup(dataDir / "Music/Explore/"); MP3Lookup(dataDir / "Music/Explore/");
if(useSound) if(useSound)
mData = new SoundImpl(root, camera, store, (dataDir / "Sound").string(), (dataDir / "Music").string(), fsstrict); mData = new SoundImpl(root, camera, store, (dataDir / "Sound").string(), (dataDir / "Music").string(), fsstrict);
@ -391,13 +392,14 @@ namespace MWSound
delete mData; delete mData;
} }
void SoundManager::streamMusic(const std::string& filename){ void SoundManager::streamMusic(const std::string& filename)
if(mData->hasFile(filename, true)) {
{ if(mData->hasFile(filename, true))
std::string fullpath = mData->convertPath(filename, true); {
streamMusicFull(fullpath); std::string fullpath = mData->convertPath(filename, true);
} streamMusicFull(fullpath);
} }
}
void SoundManager::MP3Lookup(boost::filesystem::path dir) void SoundManager::MP3Lookup(boost::filesystem::path dir)
@ -476,7 +478,7 @@ namespace MWSound
return !mData->isPlaying(ptr, "_say_sound"); return !mData->isPlaying(ptr, "_say_sound");
} }
void SoundManager::playSound (const std::string& soundId, float volume, float pitch) void SoundManager::playSound (const std::string& soundId, float volume, float pitch)
{ {
if(!mData) return; if(!mData) return;

@ -27,27 +27,28 @@ namespace MWSound
// Hide implementation details - engine.cpp is compiling // Hide implementation details - engine.cpp is compiling
// enough as it is. // enough as it is.
struct SoundImpl; struct SoundImpl;
SoundImpl *mData; SoundImpl *mData;
std::vector<boost::filesystem::path> files; std::vector<boost::filesystem::path> files;
bool fsStrict; bool fsStrict;
void streamMusicFull (const std::string& filename);
void streamMusicFull (const std::string& filename);
///< Play a soundifle ///< Play a soundifle
/// \param absolute filename /// \param absolute filename
public: public:
SoundManager(Ogre::Root*, Ogre::Camera*, const ESMS::ESMStore &store, SoundManager(Ogre::Root*, Ogre::Camera*, const ESMS::ESMStore &store,
boost::filesystem::path dataDir, bool useSound, bool fsstrict); boost::filesystem::path dataDir, bool useSound, bool fsstrict);
~SoundManager(); ~SoundManager();
void streamMusic(const std::string& filename); void streamMusic(const std::string& filename);
///< Play a soundifle ///< Play a soundifle
/// \param filename name of a sound file in "Music/" in the data directory. /// \param filename name of a sound file in "Music/" in the data directory.
void startRandomTitle(); void startRandomTitle();
void MP3Lookup(boost::filesystem::path dir); void MP3Lookup(boost::filesystem::path dir);
//struct SoundImpl;
bool isMusicPlaying(); bool isMusicPlaying();
SoundImpl getMData(); SoundImpl getMData();
@ -59,7 +60,7 @@ namespace MWSound
bool sayDone (MWWorld::Ptr reference) const; bool sayDone (MWWorld::Ptr reference) const;
///< Is actor not speaking? ///< Is actor not speaking?
void playSound (const std::string& soundId, float volume, float pitch); void playSound (const std::string& soundId, float volume, float pitch);
///< Play a sound, independently of 3D-position ///< Play a sound, independently of 3D-position

@ -66,14 +66,13 @@ class DirArchive: public Ogre::FileSystemArchive
public: public:
DirArchive(const String& name) DirArchive(const String& name)
: FileSystemArchive(name, "Dir") : FileSystemArchive(name, "Dir"), currentdir (name)
{ {
mType = "Dir"; mType = "Dir";
currentdir = name; std::string s = name;
std::string s = name; cutoff = s.size() + 1;
cutoff = s.size() + 1; if(fsstrict == false)
if(fsstrict == false) populateMap(currentdir);
populateMap(currentdir);
} }
void populateMap(boost::filesystem::path d){ void populateMap(boost::filesystem::path d){
@ -134,11 +133,10 @@ class DirArchive: public Ogre::FileSystemArchive
copy.erase(0, 1); copy.erase(0, 1);
} }
if(fsstrict == true) if(fsstrict == true)
{ {
//std::cout << "fsstrict " << copy << "\n"; //std::cout << "fsstrict " << copy << "\n";
return FileSystemArchive::exists(copy); return FileSystemArchive::exists(copy);
}
}
int last = copy.size() - 1; int last = copy.size() - 1;
@ -185,9 +183,10 @@ class DirArchive: public Ogre::FileSystemArchive
copy.erase(0, 1); copy.erase(0, 1);
} }
if(fsstrict == true){ if(fsstrict == true)
return FileSystemArchive::open(copy, readonly); {
} return FileSystemArchive::open(copy, readonly);
}
int last = copy.size() - 1; int last = copy.size() - 1;
@ -199,7 +198,7 @@ class DirArchive: public Ogre::FileSystemArchive
break; break;
} }
std::string folder = copy.substr(0, i); //folder with no slash std::string folder = copy.substr(0, i); //folder with no slash
std::vector<std::string> current = mlocal[folder]; std::vector<std::string> current = mlocal[folder];
for(std::vector<std::string>::iterator iter = current.begin(); iter != current.end(); iter++) for(std::vector<std::string>::iterator iter = current.begin(); iter != current.end(); iter++)

@ -14,7 +14,6 @@
#include "components/esm/records.hpp" #include "components/esm/records.hpp"
#include "components/esm/loadcell.hpp" #include "components/esm/loadcell.hpp"
#include <list> #include <list>
#include <Ogre.h>
#include <iostream> #include <iostream>
#include <stdexcept> #include <stdexcept>
@ -30,8 +29,6 @@ namespace ESMS
// The object that this instance is based on. // The object that this instance is based on.
const X* base; const X* base;
Ogre::Entity *model;
/* Information about this instance, such as 3D location and /* Information about this instance, such as 3D location and
rotation and individual type-dependent data. rotation and individual type-dependent data.
*/ */

@ -20,9 +20,9 @@ class FileFinderT
void add(const boost::filesystem::path &pth) void add(const boost::filesystem::path &pth)
{ {
std::string file = pth.string(); std::string file = pth.string();
std::string key = file.substr(cut); std::string key = file.substr(cut);
owner->table[key] = file; owner->table[key] = file;
} }
}; };
@ -50,13 +50,13 @@ public:
bool has(const std::string& file) const bool has(const std::string& file) const
{ {
return table.find(file) != table.end(); return table.find(file) != table.end();
} }
// Find the full path from a relative path. // Find the full path from a relative path.
const std::string &lookup(const std::string& file) const const std::string &lookup(const std::string& file) const
{ {
return table.find(file)->second; return table.find(file)->second;
} }
}; };

@ -23,7 +23,7 @@ namespace Files
return left<right; return left<right;
std::size_t min = std::min (left.length(), right.length()); std::size_t min = std::min (left.length(), right.length());
std::locale loc; std::locale loc;
for (std::size_t i=0; i<min; ++i) for (std::size_t i=0; i<min; ++i)
{ {

@ -26,7 +26,6 @@
#include "controlled.hpp" #include "controlled.hpp"
#include <iostream> #include <iostream>
#include <Ogre.h>
namespace Nif namespace Nif
{ {
@ -435,266 +434,71 @@ public:
class NiKeyframeData : public Record class NiKeyframeData : public Record
{ {
public:
//Rotations
std::vector<Ogre::Quaternion> quats; void read(NIFFile *nif)
std::vector<Ogre::Vector3> tbc; {
std::vector<float> rottime; // Rotations first
int rtype; int count = nif->getInt();
if(count)
//Translations {
std::vector<Ogre::Vector3> translist1; int type = nif->getInt();
std::vector<Ogre::Vector3> translist2;
std::vector<Ogre::Vector3> translist3; if(type == 1)
std::vector<Ogre::Vector3> transtbc; nif->skip(count*4*5); // time + quaternion
std::vector<float> transtime; else if(type == 3)
int ttype; nif->skip(count*4*8); // rot1 + tension+bias+continuity
else if(type == 4)
//Scalings {
for(int j=0;j<count;j++)
std::vector<float> scalefactor; {
std::vector<float> scaletime; nif->getFloat(); // time
std::vector<float> forwards; for(int i=0; i<3; i++)
std::vector<float> backwards; {
std::vector<Ogre::Vector3> tbcscale; int cnt = nif->getInt();
int stype; int type = nif->getInt();
if(type == 1)
public: nif->skip(cnt*4*2); // time + unknown
else if(type == 2)
void read(NIFFile *nif) nif->skip(cnt*4*4); // time + unknown vector
{ else nif->fail("Unknown sub-rotation type");
// Rotations first }
int count = nif->getInt(); }
//std::vector<Ogre::Quaternion> quat(count); }
//std::vector<float> rottime(count); else nif->fail("Unknown rotation type in NiKeyframeData");
std::cout << "r"; }
if(count)
{ // Then translation
count = nif->getInt();
//TYPE1 LINEAR_KEY
//TYPE2 QUADRATIC_KEY if(count)
//TYPE3 TBC_KEY {
//TYPE4 XYZ_ROTATION_KEY int type = nif->getInt();
//TYPE5 UNKNOWN_KEY
rtype = nif->getInt(); if(type == 1)
//std::cout << "Count: " << count << "Type: " << type << "\n"; nif->getFloatLen(count*4); // time + translation
else if(type == 2)
if(rtype == 1) nif->getFloatLen(count*10); // trans1 + forward + backward
{ else if(type == 3)
//We need to actually read in these values instead of skipping them nif->getFloatLen(count*7); // trans1 + tension,bias,continuity
//nif->skip(count*4*5); // time + quaternion else nif->fail("Unknown translation type");
for (int i = 0; i < count; i++) { }
float time = nif->getFloat();
float w = nif->getFloat(); // Finally, scalings
float x = nif->getFloat(); count = nif->getInt();
float y = nif->getFloat(); if(count)
float z = nif->getFloat(); {
Ogre::Quaternion quat = Ogre::Quaternion(Ogre::Real(w), Ogre::Real(x), Ogre::Real(y), Ogre::Real(z)); int type = nif->getInt();
quats.push_back(quat);
rottime.push_back(time); int size = 0;
//if(time == 0.0 || time > 355.5) if(type == 1) size = 2; // time+scale
// std::cout <<"Time:" << time << "W:" << w <<"X:" << x << "Y:" << y << "Z:" << z << "\n"; else if(type == 2) size = 4; // 1 + forward + backward (floats)
} else if(type == 3) size = 5; // 1 + tbc
} else nif->fail("Unknown scaling type");
else if(rtype == 3) nif->getFloatLen(count*size);
{ //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++)
{
nif->getFloat(); // time
for(int i=0; i<3; i++)
{
int cnt = nif->getInt();
int type = nif->getInt();
if(type == 1)
nif->skip(cnt*4*2); // time + unknown
else if(type == 2)
nif->skip(cnt*4*4); // time + unknown vector
else nif->fail("Unknown sub-rotation type");
}
}
}
else nif->fail("Unknown rotation type in NiKeyframeData");
}
//first = false;
// Then translation
count = nif->getInt();
if(count)
{
ttype = nif->getInt();
//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");
}
// Finally, scalings
count = nif->getInt();
if(count)
{
stype = nif->getInt();
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 } // Namespace
#endif #endif

@ -1068,11 +1068,6 @@ void NIFLoader::loadResource(Resource *resource)
// Handle the node // Handle the node
handleNode(node, 0, NULL, bounds, 0); handleNode(node, 0, NULL, bounds, 0);
short handle = 0;
//skel->setBlendMode(Ogre::SkeletonAnimationBlendMode::ANIMBLEND_CUMULATIVE);
bool first = true;
// set the bounding value. // set the bounding value.
if (bounds.isValid()) if (bounds.isValid())
{ {
@ -1081,16 +1076,6 @@ void NIFLoader::loadResource(Resource *resource)
mesh->_setBoundingSphereRadius(bounds.getRadius()); mesh->_setBoundingSphereRadius(bounds.getRadius());
} }
// set skeleton
if (!mSkel.isNull() && mesh->isLoaded())
{
mesh->_notifySkeleton(mSkel);
std::cout << "Skeleton notified\n";
}
// set skeleton // set skeleton
// if (!skel.isNull()) // if (!skel.isNull())
// mesh->setSkeletonName(getSkeletonName()); // mesh->setSkeletonName(getSkeletonName());

@ -73,11 +73,11 @@ class NIFLoader : Ogre::ManualResourceLoader
virtual void loadResource(Ogre::Resource *resource); virtual void loadResource(Ogre::Resource *resource);
static Ogre::MeshPtr load(const std::string &name, static Ogre::MeshPtr load(const std::string &name,
const std::string &group="General"); const std::string &group="General");
Ogre::Vector3 convertVector3(const Nif::Vector& vec); Ogre::Vector3 convertVector3(const Nif::Vector& vec);
Ogre::Quaternion convertRotation(const Nif::Matrix& rot); Ogre::Quaternion convertRotation(const Nif::Matrix& rot);
@ -113,7 +113,7 @@ class NIFLoader : Ogre::ManualResourceLoader
{ {
return resourceName + ".skel"; return resourceName + ".skel";
} }
// This is the interface to the Ogre resource system. It allows us to // This is the interface to the Ogre resource system. It allows us to
// load NIFs from BSAs, in the file system and in any other place we // load NIFs from BSAs, in the file system and in any other place we
// tell Ogre to look (eg. in zip or rar files.) It's also used to // tell Ogre to look (eg. in zip or rar files.) It's also used to
@ -131,11 +131,7 @@ class NIFLoader : Ogre::ManualResourceLoader
int counter; int counter;
int numbers; int numbers;
int stack; int stack;
bool anim;
int handle2;
Ogre::Animation* animcore;
Ogre::Animation* animcore2;
// pointer to the ogre mesh which is currently build // pointer to the ogre mesh which is currently build
Ogre::Mesh *mesh; Ogre::Mesh *mesh;

Loading…
Cancel
Save