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 <iostream>
8 #include <map>
9 
10 #include <osg/Matrixf>
11 #include <osg/BoundingBox>
12 #include <osg/ref_ptr>
13 #include <osg/Referenced>
14 
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  std::cerr << "NIFLoader: Warn:" << msg << "\n";
45  }
46 
47  void fail(const std::string &msg)
48  {
49  std::cerr << "NIFLoader: Fail: "<< msg << std::endl;
50  abort();
51  }
52 
53  osg::ref_ptr<Resource::BulletShape> load(const Nif::NIFFilePtr file);
54 
55 private:
56  bool findBoundingBox(const Nif::Node* node, int flags = 0);
57 
58  void handleNode(Nif::Node const *node, int flags, bool isCollisionNode, bool isAnimated=false, bool autogenerated=false);
59 
60  bool hasAutoGeneratedCollision(const Nif::Node *rootNode);
61 
62  void handleNiTriShape(const Nif::NiTriShape *shape, int flags, const osg::Matrixf& transform, bool isAnimated);
63 
64  btCompoundShape* mCompoundShape;
65 
66  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
bool hasAutoGeneratedCollision(const Nif::Node *rootNode)
Definition: bulletnifloader.cpp:157
void handleNode(Nif::Node const *node, int flags, bool isCollisionNode, bool isAnimated=false, bool autogenerated=false)
Definition: bulletnifloader.cpp:175
void handleNiTriShape(const Nif::NiTriShape *shape, int flags, const osg::Matrixf &transform, bool isAnimated)
Definition: bulletnifloader.cpp:245
virtual ~BulletNifLoader()
Definition: bulletnifloader.cpp:48
bool findBoundingBox(const Nif::Node *node, int flags=0)
Definition: bulletnifloader.cpp:125
void warn(const std::string &msg)
Definition: bulletnifloader.hpp:42
osg::ref_ptr< Resource::BulletShape > load(const Nif::NIFFilePtr file)
Definition: bulletnifloader.cpp:52
BulletNifLoader()
Definition: bulletnifloader.cpp:42
Definition: node.hpp:147
Definition: bulletnifloader.hpp:35
boost::shared_ptr< const Nif::NIFFile > NIFFilePtr
Definition: niffile.hpp:95
Definition: node.hpp:23
btCompoundShape * mCompoundShape
Definition: bulletnifloader.hpp:64
btTriangleMesh * mStaticMesh
Definition: bulletnifloader.hpp:66