OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
bulletnifloader.hpp
Go to the documentation of this file.
1 #ifndef OPENMW_COMPONENTS_NIFBULLET_BULLETNIFLOADER_HPP
2 #define OPENMW_COMPONENTS_NIFBULLET_BULLETNIFLOADER_HPP
3 
4 #include <cassert>
5 #include <string>
6 #include <set>
7 #include <map>
8 
9 #include <osg/Matrixf>
10 #include <osg/BoundingBox>
11 #include <osg/ref_ptr>
12 #include <osg/Referenced>
13 
17 
18 class btTriangleMesh;
19 class btCompoundShape;
20 class btCollisionShape;
21 
22 namespace Nif
23 {
24  class Node;
25  struct Transformation;
26  struct NiTriShape;
27 }
28 
29 namespace NifBullet
30 {
31 
36 {
37 public:
39 
40  virtual ~BulletNifLoader();
41 
42  void warn(const std::string &msg)
43  {
44  Log(Debug::Warning) << "NIFLoader: Warn:" << msg;
45  }
46 
47  void fail(const std::string &msg)
48  {
49  Log(Debug::Error) << "NIFLoader: Fail: "<< msg;
50  abort();
51  }
52 
53  osg::ref_ptr<Resource::BulletShape> load(const Nif::File& file);
54 
55 private:
56  bool findBoundingBox(const Nif::Node* node, int flags = 0);
57 
58  void handleNode(const std::string& fileName, Nif::Node const *node, int flags, bool isCollisionNode, bool isAnimated=false, bool autogenerated=false);
59 
60  const Nif::Node* getCollisionNode(const Nif::Node* rootNode);
61 
62  void handleNiTriShape(const Nif::NiTriShape *shape, int flags, const osg::Matrixf& transform, bool isAnimated);
63 
64  std::unique_ptr<btCompoundShape> mCompoundShape;
65 
66  std::unique_ptr<btTriangleMesh> mStaticMesh;
67 
68  osg::ref_ptr<Resource::BulletShape> mShape;
69 };
70 
71 }
72 
73 #endif
void fail(const std::string &msg)
Definition: bulletnifloader.hpp:47
osg::ref_ptr< Resource::BulletShape > mShape
Definition: bulletnifloader.hpp:68
Definition: debuglog.hpp:12
Definition: debuglog.hpp:13
void handleNiTriShape(const Nif::NiTriShape *shape, int flags, const osg::Matrixf &transform, bool isAnimated)
Definition: bulletnifloader.cpp:264
Definition: debuglog.hpp:22
virtual ~BulletNifLoader()
Definition: bulletnifloader.cpp:56
const Nif::Node * getCollisionNode(const Nif::Node *rootNode)
Definition: bulletnifloader.cpp:166
bool findBoundingBox(const Nif::Node *node, int flags=0)
Definition: bulletnifloader.cpp:134
void warn(const std::string &msg)
Definition: bulletnifloader.hpp:42
osg::ref_ptr< Resource::BulletShape > load(const Nif::File &file)
Definition: bulletnifloader.cpp:60
std::unique_ptr< btTriangleMesh > mStaticMesh
Definition: bulletnifloader.hpp:66
BulletNifLoader()
Definition: bulletnifloader.cpp:50
Definition: niffile.hpp:17
Definition: node.hpp:130
Definition: bulletnifloader.hpp:35
Definition: node.hpp:23
std::unique_ptr< btCompoundShape > mCompoundShape
Definition: bulletnifloader.hpp:64
void handleNode(const std::string &fileName, Nif::Node const *node, int flags, bool isCollisionNode, bool isAnimated=false, bool autogenerated=false)
Definition: bulletnifloader.cpp:193