A cannon's bullets are now destroyable.
A cannon's bullets are now destroyable.

file:b/BulletObject.cpp (new)
--- /dev/null
+++ b/BulletObject.cpp
@@ -1,1 +1,20 @@
+#include "BulletObject.h"
 
+BulletObject::BulletObject(vector3df pos,vector3df vel,ISceneManager *smgr,irrBulletWorld *bullet)
+  : DestroyableObject()
+{
+  IMeshSceneNode *bulletNode=smgr->addSphereSceneNode(0.1f);
+  bulletNode->setPosition(pos);
+  bulletNode->setMaterialFlag(video::EMF_LIGHTING, true);
+  bulletNode->setMaterialFlag(video::EMF_NORMALIZE_NORMALS, true);
+  setSceneNode(bulletNode);
+
+  ICollisionShape *bulletShape=new ISphereShape(bulletNode,20,false);
+  IRigidBody *bulletBody=bullet->addRigidBody(bulletShape);
+  bulletBody->setLinearVelocity(vel);
+  setRigidBody(bulletBody);
+}
+
+BulletObject::~BulletObject()
+{ }
+

file:b/BulletObject.h (new)
--- /dev/null
+++ b/BulletObject.h
@@ -1,1 +1,14 @@
+#ifndef BULLETOBJECT_H_
+#define BULLETOBJECT_H_
 
+#include "DestroyableObject.h"
+
+class BulletObject : public DestroyableObject
+{
+public:
+  BulletObject(vector3df pos,vector3df vel,ISceneManager *smgr,irrBulletWorld *bullet);
+  ~BulletObject();
+};
+
+#endif // BULLETOBJECT_H_
+

--- a/CannonSceneNode.cpp
+++ b/CannonSceneNode.cpp
@@ -1,4 +1,5 @@
 #include "CannonSceneNode.h"
+#include "BulletObject.h"
 
 CannonSceneNode::CannonSceneNode(ISceneNode *parent,ISceneManager *smgr,irrBulletWorld *bullet)
   : ISceneNode(parent,smgr,-1),_smgr(smgr),_bullet(bullet),_power(9)
@@ -78,14 +79,9 @@
 {
   vector3df dir=vector3df(-sin(_yRotation*M_PI/180)*cos(_xRotation*M_PI/180),sin(_xRotation*M_PI/180),-cos(_yRotation*M_PI/180)*cos(_xRotation*M_PI/180));
 
-  IMeshSceneNode *bullet=_smgr->addSphereSceneNode(0.1f);
-  bullet->setPosition(getPosition()+2*dir);
-  bullet->setMaterialFlag(video::EMF_LIGHTING, true);
-  bullet->setMaterialFlag(video::EMF_NORMALIZE_NORMALS, true);
- 
-  ICollisionShape *bulletShape=new ISphereShape(bullet,20,false);
-  IRigidBody *bulletBody=_bullet->addRigidBody(bulletShape);
-  bulletBody->setLinearVelocity(_power*dir);
-  bulletBody->addAffector(_heightTest);
+  BulletObject *bullet=new BulletObject(getPosition()+2*dir,
+					_power*dir,
+					_smgr,
+					_bullet);
 }
 

file:a/Makefile -> file:b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-OBJS=main.o App.o CannonSceneNode.o CannonSceneNodeAnimator.o DestroyableObject.o CrateObject.o Level.o WallLevel.o HeightDeletionAffector.o
+OBJS=main.o App.o CannonSceneNode.o CannonSceneNodeAnimator.o DestroyableObject.o CrateObject.o BulletObject.o Level.o WallLevel.o HeightDeletionAffector.o
 APP=cannon
 
 CFLAGS=-I/home/kkrizka/dev/irrlicht-svn/include/irrlicht -I/home/kkrizka/dev/irrbullet-svn/include/irrBullet -g `pkg-config bullet --cflags`