Download: Link
Edit: The license in there is somewhat wrong....u r ofcourse allowed to use that code but the rest still applies
Edit: redownload please
Example:
Code: Select all
#include <ILogger.h>
#include <IPhysicsInterface.h>
#include <IPhysicMaterial.h>
#include <IPhysicObject.h>
#include <IPhysicShape.h>
#include <irrlicht.h>
class Callback : public AppFrame::physic::IPhysicMaterial
{
public:
virtual int hitCollisionBox(AppFrame::physic::IPhysicObject* own, AppFrame::physic::IPhysicObject* body)
{
AppFrame::ILogger::log("I will soon hit an object bc our boundingboxes are intersecting");
//return 0 if u dont't want them to calc collision
return 1;
}
virtual void collide(AppFrame::physic::IPhysicObject* own, AppFrame::physic::IPhysicObject* body, irr::core::vector3df point, irr::core::vector3df normal, irr::f32 normalspeed, irr::f32 tangentspeedspeed)
{
AppFrame::ILogger::log("da it happend i did hit something");
}
};
int main(int args, char* argv[])
{
irr::IrrlichtDevice* device = irr::createDevice();
irr::scene::ISceneManager* smgr = device->getSceneManager();
irr::video::IVideoDriver* driver = device->getVideoDriver();
AppFrame::physic::IPhysicsInterface* manager = new AppFrame::physic::CPhysicsInterface(smgr, irr::core::aabbox3d<irr::s32>(-1000,-1000,-1000,1000,1000,1000));
manager->setWorldForce(irr::core::vector3df(0,-10,0));
AppFrame::physic::IPhysicShape* shape = manager->getShape(irr::core::aabbox3d<irr::f32>(-5,-5,-5,5,5,5), AppFrame::physic::E_SHAPE_BOX);
AppFrame::physic::IPhysicObject* object = manager->getDynamicObject(shape, AppFrame::physic::EPhysicMaterial_PLAYER, 60, irr::core::vector3df(0,100,0));
//setup callback for object
Callback * call = new Callback();
object->setMaterialCallback(call);
call->drop();
AppFrame::physic::IPhysicObject* object2 = manager->getDynamicObject(shape, AppFrame::physic::EPhysicMaterial_PLAYER, 60, irr::core::vector3df(0,0,0));
object2->setWorldForce(irr::core::vector3df(0,0,0));
object->setSceneNode(smgr->addCubeSceneNode(5));
smgr->addCameraSceneNodeFPS();
while(device->run())
{
manager->Update(device->getTimer()->getTime());
driver->beginScene(true, true, irr::video::SColor(255,255,255,255);
smgr->drawAll();
driver->endScene();
}
manager->addDynamicObjectToDeletion(object);
manager->addShapeToDeletion(shape);
manager->Update(0);
manager->drop();
device->drop();
return 0;
}