-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathBreakable.cpp
55 lines (45 loc) · 1.15 KB
/
Breakable.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "Breakable.h"
Breakable::Breakable()
{
}
Breakable::~Breakable()
{
}
void Breakable::init(SceneNode* node,int health,int strength,Real mass)
{
if (node)
return;
brnode = node;
if (health==0)
return;
mHealth = health;
if (strength==0)
return;
mStrength = strength;
mSceneMgr = global::getSingleton().getSceneManager();
mWorld = global::getSingleton().getWorld();
OgreNewt::Collision* col = new OgreNewt::CollisionPrimitives::Box(mWorld, brnode->_getWorldAABB()->getSize() );
bod = new OgreNewt::Body( mWorld, col );
bod->attachToNode( brnode );
bod->setPositionOrientation( brnode->getPosition(), brnode->getOrientation() );
delete col;
Vector3 inertia = OgreNewt::MomentOfInertia::CalcBoxSolid( mass, brnode->_getWorldAABB()->getSize() );
bod->setMassMatrix( mass, inertia );
String n = brnode->getName();
bod->setName(n);
bod->setCustomForceAndTorqueCallback<Breakable>( &Breakable::breakable_callback ,this);
PhysObject* po;
po->bod = bod;
global::getSingleton().addPhysObject(po);
POs::getSingleton().addPO(po);
}
void brk();
{
breaknow =true;
}
void addChunk(String model);
{
}
void breakable_callback(OgreNewt::Body* me)
{
}