more cleanup

actorid
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");

@ -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,29 +180,10 @@ 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, "");
//else
NIFLoader::load(mesh); NIFLoader::load(mesh);
MovableObject *ent = scene.getMgr()->createEntity(mesh); MovableObject *ent = scene.getMgr()->createEntity(mesh);
insert->attachObject(ent); insert->attachObject(ent);

@ -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);

@ -131,9 +131,12 @@ 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(music)
{
if(musicpath.has(str)) return true; if(musicpath.has(str)) return true;
// Not found? Try with .mp3 // Not found? Try with .mp3
return musicpath.has(toMp3(str)); return musicpath.has(toMp3(str));
} }
@ -145,8 +148,10 @@ namespace MWSound
} }
else else
{ {
if(music){ if(music)
{
if(musicpathStrict.has(str)) return true; if(musicpathStrict.has(str)) return true;
// Not found? Try with .mp3 // Not found? Try with .mp3
return musicpathStrict.has(toMp3(str)); return musicpathStrict.has(toMp3(str));
} }
@ -155,7 +160,6 @@ namespace MWSound
if(strict.has(str)) return true; if(strict.has(str)) return true;
return strict.has(toMp3(str)); return strict.has(toMp3(str));
} }
} }
} }
@ -163,14 +167,14 @@ namespace MWSound
// 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 // Search and return
if(music && musicpath.has(str)) if(music && musicpath.has(str))
return musicpath.lookup(str); return musicpath.lookup(str);
else if(files.has(str)) else if(files.has(str))
return files.lookup(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))
@ -178,7 +182,6 @@ namespace MWSound
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))
@ -186,7 +189,6 @@ namespace MWSound
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 // Try mp3 if the wav wasn't found
std::string mp3 = toMp3(str); std::string mp3 = toMp3(str);
if(music && musicpathStrict.has(mp3)) if(music && musicpathStrict.has(mp3))
@ -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,7 +392,8 @@ 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); std::string fullpath = mData->convertPath(filename, true);

@ -31,13 +31,13 @@ namespace MWSound
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();
@ -45,9 +45,10 @@ namespace MWSound
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();

@ -66,10 +66,9 @@ 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)
@ -137,7 +136,6 @@ class DirArchive: public Ogre::FileSystemArchive
{ {
//std::cout << "fsstrict " << copy << "\n"; //std::cout << "fsstrict " << copy << "\n";
return FileSystemArchive::exists(copy); return FileSystemArchive::exists(copy);
} }
@ -185,7 +183,8 @@ 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);
} }

@ -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.
*/ */

@ -26,7 +26,6 @@
#include "controlled.hpp" #include "controlled.hpp"
#include <iostream> #include <iostream>
#include <Ogre.h>
namespace Nif namespace Nif
{ {
@ -435,91 +434,21 @@ public:
class NiKeyframeData : public Record 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: public:
void read(NIFFile *nif) void read(NIFFile *nif)
{ {
// Rotations first // Rotations first
int count = nif->getInt(); int count = nif->getInt();
//std::vector<Ogre::Quaternion> quat(count);
//std::vector<float> rottime(count);
std::cout << "r";
if(count) if(count)
{ {
int type = nif->getInt();
//TYPE1 LINEAR_KEY if(type == 1)
//TYPE2 QUADRATIC_KEY nif->skip(count*4*5); // time + quaternion
//TYPE3 TBC_KEY else if(type == 3)
//TYPE4 XYZ_ROTATION_KEY nif->skip(count*4*8); // rot1 + tension+bias+continuity
//TYPE5 UNKNOWN_KEY else if(type == 4)
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++) for(int j=0;j<count;j++)
{ {
@ -538,69 +467,20 @@ public:
} }
else nif->fail("Unknown rotation type in NiKeyframeData"); else nif->fail("Unknown rotation type in NiKeyframeData");
} }
//first = false;
// Then translation // Then translation
count = nif->getInt(); count = nif->getInt();
if(count) if(count)
{ {
ttype = nif->getInt(); int type = nif->getInt();
//std::cout << "TransCount:" << count << " Type: " << type << "\n"; if(type == 1)
if(ttype == 1) { nif->getFloatLen(count*4); // time + translation
for (int i = 0; i < count; i++) { else if(type == 2)
float time = nif->getFloat(); nif->getFloatLen(count*10); // trans1 + forward + backward
float x = nif->getFloat(); else if(type == 3)
float y = nif->getFloat(); nif->getFloatLen(count*7); // trans1 + tension,bias,continuity
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"); else nif->fail("Unknown translation type");
} }
@ -608,93 +488,17 @@ public:
count = nif->getInt(); count = nif->getInt();
if(count) if(count)
{ {
stype = nif->getInt(); int type = nif->getInt();
for(int i = 0; i < count; i++){
//int size = 0; int size = 0;
if(stype >= 1 && stype < 4) if(type == 1) size = 2; // time+scale
{ else if(type == 2) size = 4; // 1 + forward + backward (floats)
float time = nif->getFloat(); else if(type == 3) size = 5; // 1 + tbc
float scale = nif->getFloat();
scaletime.push_back(time);
scalefactor.push_back(scale);
//size = 2; // time+scale
}
else nif->fail("Unknown scaling type"); else nif->fail("Unknown scaling type");
if(stype == 2){ nif->getFloatLen(count*size);
//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());

@ -131,10 +131,6 @@ 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

Loading…
Cancel
Save