2013-02-24 21:52:23 +00:00
|
|
|
#ifndef OPENMW_COMPONENTS_NIFBULLET_BULLETNIFLOADER_HPP
|
|
|
|
#define OPENMW_COMPONENTS_NIFBULLET_BULLETNIFLOADER_HPP
|
2011-01-13 16:51:50 +00:00
|
|
|
|
2012-07-17 07:27:12 +00:00
|
|
|
#include <cassert>
|
2011-01-13 16:51:50 +00:00
|
|
|
#include <string>
|
2015-05-09 22:28:51 +00:00
|
|
|
#include <set>
|
2015-05-12 01:02:15 +00:00
|
|
|
#include <map>
|
2011-01-13 16:51:50 +00:00
|
|
|
|
2015-05-07 19:17:15 +00:00
|
|
|
#include <osg/Matrixf>
|
2015-05-12 01:02:15 +00:00
|
|
|
#include <osg/BoundingBox>
|
|
|
|
#include <osg/ref_ptr>
|
|
|
|
#include <osg/Referenced>
|
2015-05-07 19:17:15 +00:00
|
|
|
|
2018-07-10 22:05:19 +00:00
|
|
|
#include <BulletCollision/CollisionShapes/btCompoundShape.h>
|
|
|
|
|
2018-08-14 15:42:41 +00:00
|
|
|
#include <components/debug/debuglog.hpp>
|
2015-05-12 01:02:15 +00:00
|
|
|
#include <components/nif/niffile.hpp>
|
2015-11-16 22:30:10 +00:00
|
|
|
#include <components/resource/bulletshape.hpp>
|
2011-01-13 16:51:50 +00:00
|
|
|
|
2015-05-27 20:32:11 +00:00
|
|
|
class btTriangleMesh;
|
|
|
|
class btCompoundShape;
|
|
|
|
class btCollisionShape;
|
|
|
|
|
2011-01-13 16:51:50 +00:00
|
|
|
namespace Nif
|
|
|
|
{
|
|
|
|
class Node;
|
2015-03-06 08:36:42 +00:00
|
|
|
struct Transformation;
|
|
|
|
struct NiTriShape;
|
2019-08-08 10:11:24 +00:00
|
|
|
struct NiTriStrips;
|
2011-01-13 16:51:50 +00:00
|
|
|
}
|
|
|
|
|
2011-06-19 16:45:23 +00:00
|
|
|
namespace NifBullet
|
|
|
|
{
|
2011-01-13 16:51:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
*Load bulletShape from NIF files.
|
|
|
|
*/
|
2015-05-12 01:02:15 +00:00
|
|
|
class BulletNifLoader
|
2011-01-13 16:51:50 +00:00
|
|
|
{
|
|
|
|
public:
|
2013-02-20 04:35:52 +00:00
|
|
|
void warn(const std::string &msg)
|
2011-04-01 21:35:56 +00:00
|
|
|
{
|
2020-11-14 00:42:15 +00:00
|
|
|
Log(Debug::Warning) << "NIFLoader: Warn: " << msg;
|
2011-04-01 21:35:56 +00:00
|
|
|
}
|
2011-01-13 16:51:50 +00:00
|
|
|
|
2013-02-20 04:35:52 +00:00
|
|
|
void fail(const std::string &msg)
|
2011-04-01 21:35:56 +00:00
|
|
|
{
|
2018-08-14 15:42:41 +00:00
|
|
|
Log(Debug::Error) << "NIFLoader: Fail: "<< msg;
|
2013-02-20 04:35:52 +00:00
|
|
|
abort();
|
2011-04-01 21:35:56 +00:00
|
|
|
}
|
2011-01-13 16:51:50 +00:00
|
|
|
|
2018-07-08 19:22:34 +00:00
|
|
|
osg::ref_ptr<Resource::BulletShape> load(const Nif::File& file);
|
2015-05-12 01:02:15 +00:00
|
|
|
|
2011-01-13 16:51:50 +00:00
|
|
|
private:
|
2020-11-14 00:42:15 +00:00
|
|
|
bool findBoundingBox(const Nif::Node* node, const std::string& filename);
|
2011-01-13 16:51:50 +00:00
|
|
|
|
2018-07-10 22:05:19 +00:00
|
|
|
void handleNode(const std::string& fileName, Nif::Node const *node, int flags, bool isCollisionNode,
|
|
|
|
bool isAnimated=false, bool autogenerated=false, bool avoid=false);
|
2011-03-23 12:42:28 +00:00
|
|
|
|
2018-10-26 08:51:04 +00:00
|
|
|
bool hasAutoGeneratedCollision(const Nif::Node *rootNode);
|
2011-01-13 16:51:50 +00:00
|
|
|
|
2019-08-08 16:02:08 +00:00
|
|
|
void handleNiTriShape(const Nif::Node *nifNode, int flags, const osg::Matrixf& transform, bool isAnimated, bool avoid);
|
2011-01-13 16:51:50 +00:00
|
|
|
|
2018-07-10 21:13:32 +00:00
|
|
|
std::unique_ptr<btCompoundShape> mCompoundShape;
|
2014-06-23 18:43:24 +00:00
|
|
|
|
2018-07-10 21:13:32 +00:00
|
|
|
std::unique_ptr<btTriangleMesh> mStaticMesh;
|
2014-06-23 18:43:24 +00:00
|
|
|
|
2018-07-10 22:05:19 +00:00
|
|
|
std::unique_ptr<btTriangleMesh> mAvoidStaticMesh;
|
|
|
|
|
2015-11-16 22:30:10 +00:00
|
|
|
osg::ref_ptr<Resource::BulletShape> mShape;
|
2011-01-13 16:51:50 +00:00
|
|
|
};
|
|
|
|
|
2011-06-19 16:45:23 +00:00
|
|
|
}
|
|
|
|
|
2011-01-13 16:51:50 +00:00
|
|
|
#endif
|