Added support for Bullet Physics simulation using irrBullet.
Added support for Bullet Physics simulation using irrBullet.

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,20 +3,26 @@
 
 SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
 
-FIND_PACKAGE (Irrlicht REQUIRED)
-INCLUDE_DIRECTORIES(${Irrlicht_INCLUDE_DIR} include/)
-LINK_DIRECTORIES(${Irrlicht_LIBRARY_DIR})
+FIND_PACKAGE(Irrlicht REQUIRED)
+FIND_PACKAGE(IrrBullet REQUIRED)
+FIND_PACKAGE(Bullet REQUIRED)
+INCLUDE_DIRECTORIES(${Irrlicht_INCLUDE_DIR} ${IrrBullet_INCLUDE_DIR} ${BULLET_INCLUDE_DIRS} include/)
+LINK_DIRECTORIES(${Irrlicht_LIBRARY_DIR} ${IrrBullet_LIBRARY_DIR})
 
 SET(irrkk_SRCS
   src/App.cpp
+  src/BulletApp.cpp
   )
 
 SET(irrkk_H
   include/App.h
+  include/BulletApp.h
   )
 
 ADD_LIBRARY(irrkk SHARED ${irrkk_SRCS})
 TARGET_LINK_LIBRARIES(irrkk
   ${Irrlicht_LIBRARY}
+  ${IrrBullet_LIBRARY}
+  ${BULLET_LIBRARIES}
   )
 

--- /dev/null
+++ b/cmake/FindIrrBullet.cmake
@@ -1,1 +1,21 @@
+FIND_PATH(IrrBullet_INCLUDE_DIR irrlicht.h /usr/include/irrlicht /usr/local/include/irrlicht /usr/local/include) 
 
+FIND_PATH(IrrBullet_LIBRARY_DIR libirrBullet.so libirrBullet.a PATH /usr/lib /usr/local/lib) 
+
+IF (IrrBullet_INCLUDE_DIR AND IrrBullet_LIBRARY_DIR)
+  SET(IrrBullet_FOUND TRUE)
+  
+  SET(IrrBullet_LIBRARY irrBullet)
+
+ENDIF (IrrBullet_INCLUDE_DIR AND IrrBullet_LIBRARY_DIR)
+
+IF (IrrBullet_FOUND)
+  IF (NOT IrrBullet_FIND_QUIETLY)
+    MESSAGE(STATUS "Found IrrBullet: ${IrrBullet_LIBRARY_DIR}")
+  ENDIF (NOT IrrBullet_FIND_QUIETLY)
+ELSE (IrrBullet_FOUND)
+  IF (IrrBullet_FIND_REQUIRED)
+    MESSAGE(FATAL_ERROR "Could not find IrrBullet")
+  ENDIF (IrrBullet_FIND_REQUIRED)
+ENDIF (IrrBullet_FOUND)
+

--- a/cmake/FindIrrlicht.cmake
+++ b/cmake/FindIrrlicht.cmake
@@ -1,10 +1,9 @@
-FIND_PATH(Irrlicht_INCLUDE_DIR irrlicht.h /usr/include/irrlicht /usr/local/include/irrlicht /usr/local/include ${Irrlicht_DIR}/include) 
+FIND_PATH(Irrlicht_INCLUDE_DIR irrlicht.h /usr/include/irrlicht /usr/local/include/irrlicht /usr/local/include) 
 
-FIND_PATH(Irrlicht_LIBRARY_DIR libIrrlicht.so libIrrlicht.a PATH /usr/lib /usr/local/lib ${Irrlicht_DIR}/lib/Linux) 
+FIND_PATH(Irrlicht_LIBRARY_DIR libIrrlicht.so libIrrlicht.a PATH /usr/lib /usr/local/lib) 
 
 IF (Irrlicht_INCLUDE_DIR AND Irrlicht_LIBRARY_DIR)
   SET(Irrlicht_FOUND TRUE)
-  MESSAGE(STATUS "Found Dir")
   
   SET(SYSTEMSPECIFIC_LIBRARIES)
   IF(UNIX)

--- /dev/null
+++ b/cmake/Findirrkk.cmake
@@ -1,1 +1,19 @@
+FIND_PATH(irrkk_INCLUDE_DIR irrlicht.h /usr/include/irrlicht /usr/local/include/irrlicht /usr/local/include) 
 
+FIND_PATH(irrkk_LIBRARY_DIR libirrkk.so libirrkk.a PATH /usr/lib /usr/local/lib) 
+
+IF (irrkk_INCLUDE_DIR AND irrkk_LIBRARY_DIR)
+  SET(irrkk_FOUND TRUE)
+  SET(irrkk_LIBRARY irrkk)
+ENDIF (irrkk_INCLUDE_DIR AND irrkk_LIBRARY_DIR)
+
+IF (irrkk_FOUND)
+  IF (NOT irrkk_FIND_QUIETLY)
+    MESSAGE(STATUS "Found irrkk: ${irrkk_LIBRARY_DIR}")
+  ENDIF (NOT irrkk_FIND_QUIETLY)
+ELSE (irrkk_FOUND)
+  IF (irrkk_FIND_REQUIRED)
+    MESSAGE(FATAL_ERROR "Could not find irrkk")
+  ENDIF (irrkk_FIND_REQUIRED)
+ENDIF (irrkk_FOUND)
+

--- a/include/App.h
+++ b/include/App.h
@@ -19,7 +19,15 @@
   bool OnEvent(const SEvent &event);
 
 protected:
+  /** Events **/
+  
   virtual void init();
+
+  virtual void beginRender();
+  virtual void doRender();
+  virtual void endRender();
+
+  /** Accessors **/
   IrrlichtDevice* device();
   ISceneManager* smgr();
   IVideoDriver* driver();

--- /dev/null
+++ b/include/BulletApp.h
@@ -1,1 +1,27 @@
+#ifndef BULLETAPP_H_
+#define BULLETAPP_H_
 
+#include <irrbullet.h>
+
+#include "App.h"
+
+class BulletApp : public App
+{
+public:
+  BulletApp();
+  ~BulletApp();
+
+protected:
+  virtual void init();
+  virtual void beginRender();
+  virtual void doRender();
+
+  irrBulletWorld* bullet();
+
+private:
+  irrBulletWorld *_bullet;
+  u32 TimeStamp;
+};
+
+#endif // BULLETAPP_H_
+

--- a/src/App.cpp
+++ b/src/App.cpp
@@ -15,11 +15,14 @@
 
   while(_device->run())
     {
+      beginRender();
       // Render everything
       _device->getVideoDriver()->beginScene(true,true,SColor(255,0,0,255));
+      doRender();
       _device->getSceneManager()->drawAll();
       _device->getGUIEnvironment()->drawAll();
       _device->getVideoDriver()->endScene();
+      endRender();
     }
 
   return true;
@@ -34,6 +37,15 @@
   _smgr=_device->getSceneManager();
   _driver=_device->getVideoDriver();
 }
+
+void App::beginRender()
+{ }
+
+void App::doRender()
+{ }
+
+void App::endRender()
+{ }
 
 bool App::OnEvent(const SEvent &event)
 {

file:b/src/BulletApp.cpp (new)
--- /dev/null
+++ b/src/BulletApp.cpp
@@ -1,1 +1,44 @@
+#include "BulletApp.h"
 
+BulletApp::BulletApp()
+  : App::App(),_bullet(0)
+{ }
+
+BulletApp::~BulletApp()
+{
+  //delete _bullet;
+}
+
+irrBulletWorld* BulletApp::bullet()
+{
+  return _bullet;
+}
+
+void BulletApp::init()
+{
+  App::init();
+  _bullet=createIrrBulletWorld(device(),true,true);
+  TimeStamp=0;
+}
+
+void BulletApp::beginRender()
+{
+  App::beginRender();
+
+  // Run physics
+  if(TimeStamp>0)
+    {
+      u32 DeltaTime = device()->getTimer()->getTime()-TimeStamp;
+      _bullet->stepSimulation(DeltaTime*0.001f,120);
+    }
+
+  TimeStamp = device()->getTimer()->getTime();
+}
+
+void BulletApp::doRender()
+{
+  App::doRender();
+  _bullet->debugDrawWorld(true);
+  _bullet->debugDrawProperties(true);
+}
+