forked from mirror/openmw-tes3mp
Made combined ogre/bsa/nif test, started working on NIFLoader
parent
cbb5252387
commit
908ef1c6ca
@ -0,0 +1,44 @@
|
||||
/*
|
||||
OpenMW - The completely unofficial reimplementation of Morrowind
|
||||
Copyright (C) 2008-2010 Nicolay Korslund
|
||||
Email: < korslund@gmail.com >
|
||||
WWW: http://openmw.sourceforge.net/
|
||||
|
||||
This file (cpp_bsaarchive.h) is part of the OpenMW package.
|
||||
|
||||
OpenMW is distributed as free software: you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License
|
||||
version 3, as published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
version 3 along with this program. If not, see
|
||||
http://www.gnu.org/licenses/ .
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _BSA_ARCHIVE_H_
|
||||
#define _BSA_ARCHIVE_H_
|
||||
|
||||
/** Insert the archive manager for .bsa files into the OGRE resource
|
||||
loading system. You only need to call this function once.
|
||||
|
||||
After calling it, you can do:
|
||||
|
||||
ResourceGroupManager::getSingleton().
|
||||
addResourceLocation("Morrowind.bsa", "BSA", "General");
|
||||
|
||||
or add BSA files to resources.cfg, etc. You can also use the
|
||||
shortcut addBSA() below, which will call insertBSAFactory() for
|
||||
you.
|
||||
*/
|
||||
void insertBSAFactory();
|
||||
|
||||
/// Add the given BSA file to the Ogre resource system.
|
||||
void addBSA(const char* file, const char* group="General");
|
||||
|
||||
#endif
|
@ -0,0 +1,81 @@
|
||||
/*
|
||||
OpenMW - The completely unofficial reimplementation of Morrowind
|
||||
Copyright (C) 2008-2010 Nicolay Korslund
|
||||
Email: < korslund@gmail.com >
|
||||
WWW: http://openmw.sourceforge.net/
|
||||
|
||||
This file (ogre_nif_loader.cpp) is part of the OpenMW package.
|
||||
|
||||
OpenMW is distributed as free software: you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License
|
||||
version 3, as published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
version 3 along with this program. If not, see
|
||||
http://www.gnu.org/licenses/ .
|
||||
|
||||
*/
|
||||
|
||||
#include "ogre_nif_loader.h"
|
||||
#include <Ogre.h>
|
||||
|
||||
#include "../mangle/vfs/servers/ogre_vfs.h"
|
||||
#include "../nif/nif_file.h"
|
||||
|
||||
// For warning messages
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
using namespace Ogre;
|
||||
using namespace Nif;
|
||||
using namespace Mangle::VFS;
|
||||
|
||||
// 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.)
|
||||
OgreVFS *vfs;
|
||||
|
||||
// Singleton instance used by load()
|
||||
static NIFLoader g_sing;
|
||||
|
||||
static void warn(const string &msg)
|
||||
{
|
||||
cout << "WARNING (NIF): " << msg << endl;
|
||||
}
|
||||
|
||||
void NIFLoader::loadResource(Resource *resource)
|
||||
{
|
||||
// Set up the VFS if it hasn't been done already
|
||||
if(!vfs) vfs = new OgreVFS("General");
|
||||
|
||||
// Get the mesh
|
||||
Mesh *mesh = dynamic_cast<Mesh*>(resource);
|
||||
assert(mesh);
|
||||
|
||||
// Look it up
|
||||
const String &name = mesh->getName();
|
||||
if(!vfs->isFile(name))
|
||||
{
|
||||
warn("File not found: " + name);
|
||||
return;
|
||||
}
|
||||
|
||||
// Load the NIF
|
||||
cout << "Loading " << name << endl;
|
||||
NIFFile nif(vfs->open(name), name);
|
||||
|
||||
int n = nif.numRecords();
|
||||
cout << "Number of records: " << n << endl;
|
||||
if(n)
|
||||
cout << "First record type: " << nif.getRecord(0)->recType.toString() << endl;
|
||||
}
|
||||
|
||||
MeshPtr NIFLoader::load(const char* name, const char* group)
|
||||
{
|
||||
return MeshManager::getSingleton().createManual(name, group, &g_sing);
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
/*
|
||||
OpenMW - The completely unofficial reimplementation of Morrowind
|
||||
Copyright (C) 2008-2010 Nicolay Korslund
|
||||
Email: < korslund@gmail.com >
|
||||
WWW: http://openmw.sourceforge.net/
|
||||
|
||||
This file (ogre_nif_loader.h) is part of the OpenMW package.
|
||||
|
||||
OpenMW is distributed as free software: you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License
|
||||
version 3, as published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
version 3 along with this program. If not, see
|
||||
http://www.gnu.org/licenses/ .
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _OGRE_NIF_LOADER_H_
|
||||
#define _OGRE_NIF_LOADER_H_
|
||||
|
||||
#include <OgreResource.h>
|
||||
#include <OgreMesh.h>
|
||||
#include <assert.h>
|
||||
|
||||
/** Manual resource loader for NIF meshes. This is the main class
|
||||
responsible for translating the internal NIF mesh structure into
|
||||
something Ogre can use. Later it will also handle the insertion of
|
||||
collision meshes into Bullet / OgreBullet.
|
||||
|
||||
You have to insert meshes manually into Ogre like this:
|
||||
|
||||
NIFLoader::load("somemesh.nif");
|
||||
|
||||
Afterwards, you can use the mesh name "somemesh.nif" normally to
|
||||
create entities etc.
|
||||
*/
|
||||
struct NIFLoader : Ogre::ManualResourceLoader
|
||||
{
|
||||
void loadResource(Ogre::Resource *resource);
|
||||
|
||||
static Ogre::MeshPtr load(const char* name, const char* group="General");
|
||||
};
|
||||
|
||||
#endif
|
@ -1,3 +1,3 @@
|
||||
Manually loading mesh mesh1.mm
|
||||
Manually loading mesh mesh2.mm
|
||||
Manually loading mesh mesh3.mm
|
||||
Loading meshes\a\towershield_steel.nif
|
||||
Number of records: 10
|
||||
First record type: NiNode
|
||||
|
Loading…
Reference in New Issue