
#include <Irrlicht.h>
#include <IPhysics.h>

#pragma comment(lib, "Irrlicht.lib")
#pragma comment(lib, "IPhysics.lib")

int main()
{
	IrrlichtDevice* device = createDevice(EDT_OPENGL); //Initialize Irrlicht Object
	
	IVideoDriver* driver = device->getVideoDriver();
	ISceneManager* smgr = device->getSceneManager();

	CPhysics physics; //Initialize physics object
	physics.init(device);

	ISceneNode* staticCubeSceneNode = smgr->addCubeSceneNode(30);
	staticCubeSceneNode->setMaterialFlag(EMF_LIGHTING, false);
	staticCubeSceneNode->setMaterialTexture(0, driver->getTexture("../../Media/Crate.jpg"));

	SPhysicsPrimitive staticCube;
	staticCube.primitiveType = EPT_CUBE;
	staticCube.bodyType = EBT_STATIC;
	staticCube.size = vector3df(30, 30, 30);
	staticCube.node = staticCubeSceneNode;

	IPhysicsEntity* staticCubeEntity = physics.addEntity(&staticCube);
	staticCubeEntity->setPosition(vector3df(0,-45,100));


	ISceneNode* dynamicCubeSceneNode = smgr->addCubeSceneNode(30);
	dynamicCubeSceneNode->setMaterialFlag(EMF_LIGHTING, false);
	dynamicCubeSceneNode->setMaterialTexture(0, driver->getTexture("../../Media/Crate.jpg"));
	
	SPhysicsPrimitive dynamicCube;
	dynamicCube.primitiveType = EPT_CUBE;
	dynamicCube.bodyType = EBT_DYNAMIC;
	dynamicCube.size = vector3df(30, 30, 30);
	dynamicCube.node = dynamicCubeSceneNode;

	IPhysicsEntity* dynamicCubeEntity = physics.addEntity(&dynamicCube);
	dynamicCubeEntity->setPosition(vector3df(0,50,100));

	smgr->addCameraSceneNode();

	while (device->run())
	{
		if (device->isWindowActive())
		{
			driver->beginScene(true,true, SColor(255,0,0,0));

			smgr->drawAll();

			physics.update();

			driver->endScene();
		}
	}

	physics.close();

	return 0;
}
