2013-02-24 13:52:23 -08:00
|
|
|
#ifndef OPENMW_COMPONENTS_NIFBULLET_BULLETNIFLOADER_HPP
|
|
|
|
#define OPENMW_COMPONENTS_NIFBULLET_BULLETNIFLOADER_HPP
|
2011-01-13 17:51:50 +01:00
|
|
|
|
2012-07-17 09:27:12 +02:00
|
|
|
#include <cassert>
|
2011-01-13 17:51:50 +01:00
|
|
|
#include <string>
|
2015-05-10 00:28:51 +02:00
|
|
|
#include <set>
|
2015-05-12 03:02:15 +02:00
|
|
|
#include <iostream>
|
|
|
|
#include <map>
|
2011-01-13 17:51:50 +01:00
|
|
|
|
2015-05-07 21:17:15 +02:00
|
|
|
#include <osg/Matrixf>
|
2015-05-12 03:02:15 +02:00
|
|
|
#include <osg/BoundingBox>
|
|
|
|
#include <osg/ref_ptr>
|
|
|
|
#include <osg/Referenced>
|
2015-05-07 21:17:15 +02:00
|
|
|
|
2015-05-12 03:02:15 +02:00
|
|
|
#include <components/nif/niffile.hpp>
|
2015-11-16 23:30:10 +01:00
|
|
|
#include <components/resource/bulletshape.hpp>
|
2011-01-13 17:51:50 +01:00
|
|
|
|
2015-05-27 22:32:11 +02:00
|
|
|
class btTriangleMesh;
|
|
|
|
class btCompoundShape;
|
|
|
|
class btCollisionShape;
|
|
|
|
|
2011-01-13 17:51:50 +01:00
|
|
|
namespace Nif
|
|
|
|
{
|
|
|
|
class Node;
|
2015-03-06 21:36:42 +13:00
|
|
|
struct Transformation;
|
|
|
|
struct NiTriShape;
|
2011-01-13 17:51:50 +01:00
|
|
|
}
|
|
|
|
|
2011-06-19 18:45:23 +02:00
|
|
|
namespace NifBullet
|
|
|
|
{
|
2011-01-13 17:51:50 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
*Load bulletShape from NIF files.
|
|
|
|
*/
|
2015-05-12 03:02:15 +02:00
|
|
|
class BulletNifLoader
|
2011-01-13 17:51:50 +01:00
|
|
|
{
|
|
|
|
public:
|
2015-05-12 03:02:15 +02:00
|
|
|
BulletNifLoader();
|
2013-07-31 18:46:32 +02:00
|
|
|
|
2015-05-12 03:02:15 +02:00
|
|
|
virtual ~BulletNifLoader();
|
2011-01-13 17:51:50 +01:00
|
|
|
|
2013-02-20 05:35:52 +01:00
|
|
|
void warn(const std::string &msg)
|
2011-04-01 23:35:56 +02:00
|
|
|
{
|
|
|
|
std::cerr << "NIFLoader: Warn:" << msg << "\n";
|
|
|
|
}
|
2011-01-13 17:51:50 +01:00
|
|
|
|
2013-02-20 05:35:52 +01:00
|
|
|
void fail(const std::string &msg)
|
2011-04-01 23:35:56 +02:00
|
|
|
{
|
|
|
|
std::cerr << "NIFLoader: Fail: "<< msg << std::endl;
|
2013-02-20 05:35:52 +01:00
|
|
|
abort();
|
2011-04-01 23:35:56 +02:00
|
|
|
}
|
2011-01-13 17:51:50 +01:00
|
|
|
|
2015-11-16 23:30:10 +01:00
|
|
|
osg::ref_ptr<Resource::BulletShape> load(const Nif::NIFFilePtr file);
|
2015-05-12 03:02:15 +02:00
|
|
|
|
2011-01-13 17:51:50 +01:00
|
|
|
private:
|
2015-05-12 03:02:15 +02:00
|
|
|
bool findBoundingBox(const Nif::Node* node, int flags = 0);
|
2011-01-13 17:51:50 +01:00
|
|
|
|
2015-05-12 03:02:15 +02:00
|
|
|
void handleNode(Nif::Node const *node, int flags, bool isCollisionNode, bool isAnimated=false, bool autogenerated=false);
|
2011-03-23 13:42:28 +01:00
|
|
|
|
2015-01-11 20:34:26 +01:00
|
|
|
bool hasAutoGeneratedCollision(const Nif::Node *rootNode);
|
2011-01-13 17:51:50 +01:00
|
|
|
|
2015-05-07 21:17:15 +02:00
|
|
|
void handleNiTriShape(const Nif::NiTriShape *shape, int flags, const osg::Matrixf& transform, bool isAnimated);
|
2011-01-13 17:51:50 +01:00
|
|
|
|
2014-06-23 20:43:24 +02:00
|
|
|
btCompoundShape* mCompoundShape;
|
|
|
|
|
|
|
|
btTriangleMesh* mStaticMesh;
|
|
|
|
|
2015-11-16 23:30:10 +01:00
|
|
|
osg::ref_ptr<Resource::BulletShape> mShape;
|
2011-01-13 17:51:50 +01:00
|
|
|
};
|
|
|
|
|
2011-06-19 18:45:23 +02:00
|
|
|
}
|
|
|
|
|
2011-01-13 17:51:50 +01:00
|
|
|
#endif
|