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 <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
|
|
|
|
2018-07-11 01:05:19 +03:00
|
|
|
#include <BulletCollision/CollisionShapes/btCompoundShape.h>
|
|
|
|
|
2018-08-14 19:42:41 +04:00
|
|
|
#include <components/debug/debuglog.hpp>
|
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
|
|
|
|
{
|
2020-12-28 12:19:22 +04:00
|
|
|
struct Node;
|
2015-03-06 21:36:42 +13:00
|
|
|
struct Transformation;
|
|
|
|
struct NiTriShape;
|
2019-08-08 13:11:24 +03:00
|
|
|
struct NiTriStrips;
|
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:
|
2013-02-20 05:35:52 +01:00
|
|
|
void warn(const std::string &msg)
|
2011-04-01 23:35:56 +02:00
|
|
|
{
|
2020-11-14 03:42:15 +03:00
|
|
|
Log(Debug::Warning) << "NIFLoader: Warn: " << msg;
|
2011-04-01 23:35:56 +02:00
|
|
|
}
|
2011-01-13 17:51:50 +01:00
|
|
|
|
2021-04-29 21:30:25 +02:00
|
|
|
[[noreturn]] void fail(const std::string &msg)
|
2011-04-01 23:35:56 +02:00
|
|
|
{
|
2018-08-14 19:42:41 +04:00
|
|
|
Log(Debug::Error) << "NIFLoader: Fail: "<< msg;
|
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
|
|
|
|
2018-07-08 22:22:34 +03:00
|
|
|
osg::ref_ptr<Resource::BulletShape> load(const Nif::File& file);
|
2015-05-12 03:02:15 +02:00
|
|
|
|
2011-01-13 17:51:50 +01:00
|
|
|
private:
|
2020-11-14 03:42:15 +03:00
|
|
|
bool findBoundingBox(const Nif::Node* node, const std::string& filename);
|
2011-01-13 17:51:50 +01:00
|
|
|
|
2018-07-11 01:05:19 +03: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 13:42:28 +01:00
|
|
|
|
2018-10-26 12:51:04 +04:00
|
|
|
bool hasAutoGeneratedCollision(const Nif::Node *rootNode);
|
2011-01-13 17:51:50 +01:00
|
|
|
|
2019-08-08 19:02:08 +03:00
|
|
|
void handleNiTriShape(const Nif::Node *nifNode, int flags, const osg::Matrixf& transform, bool isAnimated, bool avoid);
|
2011-01-13 17:51:50 +01:00
|
|
|
|
2018-07-11 00:13:32 +03:00
|
|
|
std::unique_ptr<btCompoundShape> mCompoundShape;
|
2014-06-23 20:43:24 +02:00
|
|
|
|
2018-07-11 00:13:32 +03:00
|
|
|
std::unique_ptr<btTriangleMesh> mStaticMesh;
|
2014-06-23 20:43:24 +02:00
|
|
|
|
2018-07-11 01:05:19 +03:00
|
|
|
std::unique_ptr<btTriangleMesh> mAvoidStaticMesh;
|
|
|
|
|
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
|