forked from teamnwah/openmw-tes3coop
more cleanup
This commit is contained in:
parent
bdd995ec91
commit
0f2df4e2b8
16 changed files with 176 additions and 433 deletions
|
@ -353,9 +353,6 @@ void OMW::Engine::go()
|
|||
|
||||
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
|
||||
// to find core.xml here.
|
||||
addResourcesDirectory(mResDir / "mygui");
|
||||
|
|
|
@ -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()));
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
#include "../mwworld/refdata.hpp"
|
||||
#include <OgreMath.h>
|
||||
#include <Ogre.h>
|
||||
|
||||
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) = 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,21 +273,6 @@ 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()
|
||||
|
|
|
@ -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);
|
||||
//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,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)
|
||||
{
|
||||
assert (insert);
|
||||
//if(mesh == "\\Meshes\\bald_MJ_hat.NIF")
|
||||
// NIFLoader::load(mesh, "");
|
||||
//else
|
||||
NIFLoader::load(mesh);
|
||||
MovableObject *ent = scene.getMgr()->createEntity(mesh);
|
||||
insert->attachObject(ent);
|
||||
assert (insert);
|
||||
|
||||
NIFLoader::load(mesh);
|
||||
MovableObject *ent = scene.getMgr()->createEntity(mesh);
|
||||
insert->attachObject(ent);
|
||||
|
||||
if (mInsertMesh.empty())
|
||||
mInsertMesh = mesh;
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
#include "OgreColourValue.h"
|
||||
#include <OgreSceneNode.h>
|
||||
#include <Ogre.h>
|
||||
|
||||
namespace Ogre
|
||||
{
|
||||
|
@ -68,7 +67,6 @@ 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);
|
||||
|
|
|
@ -63,7 +63,7 @@ namespace MWSound
|
|||
*/
|
||||
OEManagerPtr mgr;
|
||||
SoundPtr music;
|
||||
|
||||
|
||||
/* This class calls update() on the sound manager each frame
|
||||
using and Ogre::FrameListener
|
||||
*/
|
||||
|
@ -84,11 +84,11 @@ namespace MWSound
|
|||
// finding. It takes DOS paths (any case, \\ slashes or / slashes)
|
||||
// relative to the sound dir, and translates them into full paths
|
||||
// of existing files in the filesystem, if they exist.
|
||||
bool FSstrict;
|
||||
bool FSstrict;
|
||||
FileFinder::FileFinder files;
|
||||
FileFinder::FileFinderStrict strict;
|
||||
FileFinder::FileFinder musicpath;
|
||||
FileFinder::FileFinderStrict musicpathStrict;
|
||||
FileFinder::FileFinderStrict strict;
|
||||
FileFinder::FileFinder musicpath;
|
||||
FileFinder::FileFinderStrict musicpathStrict;
|
||||
|
||||
SoundImpl(Ogre::Root *root, Ogre::Camera *camera,
|
||||
const ESMS::ESMStore &str,
|
||||
|
@ -98,9 +98,9 @@ namespace MWSound
|
|||
, cameraTracker(mgr)
|
||||
, store(str)
|
||||
, files(soundDir), strict(soundDir)
|
||||
,musicpath(musicDir), musicpathStrict(musicDir)
|
||||
,musicpath(musicDir), musicpathStrict(musicDir)
|
||||
{
|
||||
FSstrict = fsstrict;
|
||||
FSstrict = fsstrict;
|
||||
cout << "Sound output: " << SOUND_OUT << endl;
|
||||
cout << "Sound decoder: " << SOUND_IN << endl;
|
||||
// Attach the camera to the camera tracker
|
||||
|
@ -131,72 +131,74 @@ namespace MWSound
|
|||
|
||||
bool hasFile(const std::string &str, bool music = false)
|
||||
{
|
||||
if(FSstrict == false){
|
||||
if(music){
|
||||
if(musicpath.has(str)) return true;
|
||||
// Not found? Try with .mp3
|
||||
return musicpath.has(toMp3(str));
|
||||
}
|
||||
else
|
||||
{
|
||||
if(files.has(str)) return true;
|
||||
return files.has(toMp3(str));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(music){
|
||||
if(musicpathStrict.has(str)) return true;
|
||||
// Not found? Try with .mp3
|
||||
return musicpathStrict.has(toMp3(str));
|
||||
}
|
||||
else
|
||||
{
|
||||
if(strict.has(str)) return true;
|
||||
return strict.has(toMp3(str));
|
||||
}
|
||||
if(FSstrict == false)
|
||||
{
|
||||
if(music)
|
||||
{
|
||||
if(musicpath.has(str)) return true;
|
||||
|
||||
}
|
||||
}
|
||||
// Not found? Try with .mp3
|
||||
return musicpath.has(toMp3(str));
|
||||
}
|
||||
else
|
||||
{
|
||||
if(files.has(str)) return true;
|
||||
return files.has(toMp3(str));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(music)
|
||||
{
|
||||
if(musicpathStrict.has(str)) return true;
|
||||
|
||||
// Not found? Try with .mp3
|
||||
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
|
||||
// with proper slash conversion (eg. datadir/Sound/Fx/funny.wav)
|
||||
std::string convertPath(const std::string &str, bool music = false)
|
||||
{
|
||||
if(FSstrict == false){
|
||||
// Search and return
|
||||
if(music && musicpath.has(str))
|
||||
return musicpath.lookup(str);
|
||||
else if(files.has(str))
|
||||
return files.lookup(str);
|
||||
if(FSstrict == false)
|
||||
{
|
||||
// Search and return
|
||||
if(music && musicpath.has(str))
|
||||
return musicpath.lookup(str);
|
||||
else if(files.has(str))
|
||||
return files.lookup(str);
|
||||
|
||||
// Try mp3 if the wav wasn't found
|
||||
std::string mp3 = toMp3(str);
|
||||
if(music && musicpath.has(mp3))
|
||||
return musicpath.lookup(mp3);
|
||||
else if(files.has(mp3))
|
||||
return files.lookup(mp3);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(music && musicpathStrict.has(str))
|
||||
return musicpathStrict.lookup(str);
|
||||
else if(strict.has(str))
|
||||
return strict.lookup(str);
|
||||
|
||||
// Try mp3 if the wav wasn't found
|
||||
std::string mp3 = toMp3(str);
|
||||
if(music && musicpath.has(mp3))
|
||||
return musicpath.lookup(mp3);
|
||||
else if(files.has(mp3))
|
||||
return files.lookup(mp3);
|
||||
}
|
||||
// Try mp3 if the wav wasn't found
|
||||
std::string mp3 = toMp3(str);
|
||||
if(music && musicpathStrict.has(mp3))
|
||||
return musicpathStrict.lookup(mp3);
|
||||
else if(strict.has(str))
|
||||
return strict.lookup(mp3);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if(music && musicpathStrict.has(str))
|
||||
return musicpathStrict.lookup(str);
|
||||
else if(strict.has(str))
|
||||
return strict.lookup(str);
|
||||
|
||||
|
||||
// Try mp3 if the wav wasn't found
|
||||
std::string mp3 = toMp3(str);
|
||||
if(music && musicpathStrict.has(mp3))
|
||||
return musicpathStrict.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
|
||||
|
@ -377,9 +379,8 @@ namespace MWSound
|
|||
const ESMS::ESMStore &store,
|
||||
boost::filesystem::path dataDir,
|
||||
bool useSound, bool fsstrict)
|
||||
: mData(NULL)
|
||||
: mData(NULL), fsStrict (fsstrict)
|
||||
{
|
||||
fsStrict = fsstrict;
|
||||
MP3Lookup(dataDir / "Music/Explore/");
|
||||
if(useSound)
|
||||
mData = new SoundImpl(root, camera, store, (dataDir / "Sound").string(), (dataDir / "Music").string(), fsstrict);
|
||||
|
@ -391,13 +392,14 @@ namespace MWSound
|
|||
delete mData;
|
||||
}
|
||||
|
||||
void SoundManager::streamMusic(const std::string& filename){
|
||||
if(mData->hasFile(filename, true))
|
||||
{
|
||||
std::string fullpath = mData->convertPath(filename, true);
|
||||
streamMusicFull(fullpath);
|
||||
}
|
||||
}
|
||||
void SoundManager::streamMusic(const std::string& filename)
|
||||
{
|
||||
if(mData->hasFile(filename, true))
|
||||
{
|
||||
std::string fullpath = mData->convertPath(filename, true);
|
||||
streamMusicFull(fullpath);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SoundManager::MP3Lookup(boost::filesystem::path dir)
|
||||
|
@ -476,7 +478,7 @@ namespace MWSound
|
|||
return !mData->isPlaying(ptr, "_say_sound");
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SoundManager::playSound (const std::string& soundId, float volume, float pitch)
|
||||
{
|
||||
if(!mData) return;
|
||||
|
|
|
@ -27,27 +27,28 @@ namespace MWSound
|
|||
// Hide implementation details - engine.cpp is compiling
|
||||
// enough as it is.
|
||||
struct SoundImpl;
|
||||
|
||||
|
||||
SoundImpl *mData;
|
||||
std::vector<boost::filesystem::path> files;
|
||||
bool fsStrict;
|
||||
void streamMusicFull (const std::string& filename);
|
||||
bool fsStrict;
|
||||
|
||||
void streamMusicFull (const std::string& filename);
|
||||
///< Play a soundifle
|
||||
/// \param absolute filename
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
SoundManager(Ogre::Root*, Ogre::Camera*, const ESMS::ESMStore &store,
|
||||
boost::filesystem::path dataDir, bool useSound, bool fsstrict);
|
||||
~SoundManager();
|
||||
|
||||
void streamMusic(const std::string& filename);
|
||||
///< Play a soundifle
|
||||
void streamMusic(const std::string& filename);
|
||||
///< Play a soundifle
|
||||
/// \param filename name of a sound file in "Music/" in the data directory.
|
||||
|
||||
void startRandomTitle();
|
||||
void MP3Lookup(boost::filesystem::path dir);
|
||||
//struct SoundImpl;
|
||||
|
||||
bool isMusicPlaying();
|
||||
|
||||
SoundImpl getMData();
|
||||
|
@ -59,7 +60,7 @@ namespace MWSound
|
|||
bool sayDone (MWWorld::Ptr reference) const;
|
||||
///< Is actor not speaking?
|
||||
|
||||
|
||||
|
||||
|
||||
void playSound (const std::string& soundId, float volume, float pitch);
|
||||
///< Play a sound, independently of 3D-position
|
||||
|
|
|
@ -66,14 +66,13 @@ class DirArchive: public Ogre::FileSystemArchive
|
|||
public:
|
||||
|
||||
DirArchive(const String& name)
|
||||
: FileSystemArchive(name, "Dir")
|
||||
{
|
||||
mType = "Dir";
|
||||
currentdir = name;
|
||||
std::string s = name;
|
||||
cutoff = s.size() + 1;
|
||||
if(fsstrict == false)
|
||||
populateMap(currentdir);
|
||||
: FileSystemArchive(name, "Dir"), currentdir (name)
|
||||
{
|
||||
mType = "Dir";
|
||||
std::string s = name;
|
||||
cutoff = s.size() + 1;
|
||||
if(fsstrict == false)
|
||||
populateMap(currentdir);
|
||||
|
||||
}
|
||||
void populateMap(boost::filesystem::path d){
|
||||
|
@ -134,11 +133,10 @@ class DirArchive: public Ogre::FileSystemArchive
|
|||
copy.erase(0, 1);
|
||||
}
|
||||
if(fsstrict == true)
|
||||
{
|
||||
//std::cout << "fsstrict " << copy << "\n";
|
||||
return FileSystemArchive::exists(copy);
|
||||
|
||||
}
|
||||
{
|
||||
//std::cout << "fsstrict " << copy << "\n";
|
||||
return FileSystemArchive::exists(copy);
|
||||
}
|
||||
|
||||
|
||||
int last = copy.size() - 1;
|
||||
|
@ -185,9 +183,10 @@ class DirArchive: public Ogre::FileSystemArchive
|
|||
copy.erase(0, 1);
|
||||
}
|
||||
|
||||
if(fsstrict == true){
|
||||
return FileSystemArchive::open(copy, readonly);
|
||||
}
|
||||
if(fsstrict == true)
|
||||
{
|
||||
return FileSystemArchive::open(copy, readonly);
|
||||
}
|
||||
|
||||
|
||||
int last = copy.size() - 1;
|
||||
|
@ -199,7 +198,7 @@ class DirArchive: public Ogre::FileSystemArchive
|
|||
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];
|
||||
|
||||
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/loadcell.hpp"
|
||||
#include <list>
|
||||
#include <Ogre.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
|
@ -30,8 +29,6 @@ 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.
|
||||
*/
|
||||
|
|
|
@ -20,9 +20,9 @@ class FileFinderT
|
|||
|
||||
void add(const boost::filesystem::path &pth)
|
||||
{
|
||||
std::string file = pth.string();
|
||||
std::string key = file.substr(cut);
|
||||
owner->table[key] = file;
|
||||
std::string file = pth.string();
|
||||
std::string key = file.substr(cut);
|
||||
owner->table[key] = file;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -50,13 +50,13 @@ public:
|
|||
|
||||
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.
|
||||
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;
|
||||
|
||||
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)
|
||||
{
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
|
||||
#include "controlled.hpp"
|
||||
#include <iostream>
|
||||
#include <Ogre.h>
|
||||
|
||||
namespace Nif
|
||||
{
|
||||
|
@ -435,266 +434,71 @@ public:
|
|||
|
||||
class NiKeyframeData : public Record
|
||||
{
|
||||
|
||||
//Rotations
|
||||
std::vector<Ogre::Quaternion> quats;
|
||||
std::vector<Ogre::Vector3> tbc;
|
||||
std::vector<float> rottime;
|
||||
int rtype;
|
||||
public:
|
||||
|
||||
//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;
|
||||
void read(NIFFile *nif)
|
||||
{
|
||||
// Rotations first
|
||||
int count = nif->getInt();
|
||||
if(count)
|
||||
{
|
||||
int type = nif->getInt();
|
||||
|
||||
//Scalings
|
||||
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)
|
||||
{
|
||||
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");
|
||||
}
|
||||
|
||||
std::vector<float> scalefactor;
|
||||
std::vector<float> scaletime;
|
||||
std::vector<float> forwards;
|
||||
std::vector<float> backwards;
|
||||
std::vector<Ogre::Vector3> tbcscale;
|
||||
int stype;
|
||||
// Then translation
|
||||
count = nif->getInt();
|
||||
|
||||
public:
|
||||
if(count)
|
||||
{
|
||||
int type = nif->getInt();
|
||||
|
||||
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)
|
||||
{
|
||||
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
|
||||
else nif->fail("Unknown translation type");
|
||||
}
|
||||
|
||||
//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";
|
||||
// Finally, scalings
|
||||
count = nif->getInt();
|
||||
if(count)
|
||||
{
|
||||
int type = nif->getInt();
|
||||
|
||||
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++)
|
||||
{
|
||||
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;
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // Namespace
|
||||
#endif
|
||||
|
|
|
@ -1068,11 +1068,6 @@ 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())
|
||||
{
|
||||
|
@ -1081,16 +1076,6 @@ void NIFLoader::loadResource(Resource *resource)
|
|||
mesh->_setBoundingSphereRadius(bounds.getRadius());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// set skeleton
|
||||
if (!mSkel.isNull() && mesh->isLoaded())
|
||||
{
|
||||
mesh->_notifySkeleton(mSkel);
|
||||
std::cout << "Skeleton notified\n";
|
||||
}
|
||||
|
||||
// set skeleton
|
||||
// if (!skel.isNull())
|
||||
// mesh->setSkeletonName(getSkeletonName());
|
||||
|
|
|
@ -73,11 +73,11 @@ class NIFLoader : Ogre::ManualResourceLoader
|
|||
|
||||
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");
|
||||
|
||||
|
||||
|
||||
|
||||
Ogre::Vector3 convertVector3(const Nif::Vector& vec);
|
||||
Ogre::Quaternion convertRotation(const Nif::Matrix& rot);
|
||||
|
||||
|
@ -113,7 +113,7 @@ class NIFLoader : Ogre::ManualResourceLoader
|
|||
{
|
||||
return resourceName + ".skel";
|
||||
}
|
||||
|
||||
|
||||
// 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
|
||||
// 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 numbers;
|
||||
int stack;
|
||||
bool anim;
|
||||
int handle2;
|
||||
Ogre::Animation* animcore;
|
||||
Ogre::Animation* animcore2;
|
||||
|
||||
|
||||
|
||||
// pointer to the ogre mesh which is currently build
|
||||
Ogre::Mesh *mesh;
|
||||
|
|
Loading…
Reference in a new issue