If anyone wants to help please let me know!! (this code is already well ready for use)
Watch - http://www.youtube.com/watch?v=6jKCFBVLFxE
Download - http://sourceforge.net/project/showfile ... _id=237582
Project Homepage - http://www.nighsoft.com/index.php?game=libs&page=irrar
This is the code using IrrAR 0.1 for that youtube example:
Code: Select all
#include "irrAR.h"
#define WIN_WIDTH 352
#define WIN_HEIGHT 288
IrrlichtDevice *device;
IVideoDriver* driver;
ISceneManager* smgr;
IARManager* armgr;
class MyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(const SEvent &event)
{
if (event.EventType == EET_KEY_INPUT_EVENT && !event.KeyInput.PressedDown)
{
switch(event.KeyInput.Key)
{
case KEY_ESCAPE:
device->closeDevice();
return true;
}
}
return false;
}
};
int main()
{
bool fullscreen = false;
MyEventReceiver receiver;
device = createDevice( video::EDT_OPENGL, dimension2d<s32>(WIN_WIDTH, WIN_HEIGHT), 16, fullscreen, false, false, &receiver);
driver = device->getVideoDriver();
smgr = device->getSceneManager();
device->setWindowCaption(L"IrrAR Demo by Nighsoft");
//something for 3d reference
IAnimatedMesh* mesh = smgr->getMesh("media/sydney.md2");
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode(mesh);
if (node)
{
node->setMaterialTexture( 0, driver->getTexture("media/sydney.bmp") );
node->setMaterialFlag(EMF_LIGHTING, false);
node->setMD2Animation(scene::EMAT_POINT);
node->setPosition(vector3df(0,50,0));
node->setScale(vector3df(2,2,2));
}
IAnimatedMeshSceneNode* fairy = smgr->addAnimatedMeshSceneNode(smgr->getMesh("media/faerie.md2"));
if (fairy)
{
fairy->setMaterialTexture(0, driver->getTexture("media/faerie2.bmp"));
fairy->setMaterialFlag(video::EMF_LIGHTING, false);
fairy->setMD2Animation(scene::EMAT_POINT);
fairy->setScale(vector3df(2,2,2));
fairy->setPosition(vector3df(0,45,0));
fairy->setRotation(vector3df(0,180,0));
}
//camera stuff
vector3df camera_pos = vector3df(0,0,0);
vector3df camera_target = vector3df(0,0,1);
ICameraSceneNode* camera = smgr->addCameraSceneNode(0, camera_pos, camera_target);
//AR stuff
IARManager* armgr = new IARManager(device);
//init the camera
armgr->beginCamera("ardata/camera_para.dat","ardata/WDM_camera_flipV.xml");
//node for the lady, attached the the hiro pattern
armgr->addARSceneNode("ardata/patt.hiro", node);
//node for the fairy, attached the the sample1 pattern
armgr->addARSceneNode("ardata/patt.sample1", fairy);
//now fix our camera to display right
armgr->fixCamera(camera);
while(device->run())
{
driver->beginScene(true, true, SColor(255,100,101,140));
armgr->run();
driver->draw2DImage(armgr->getCameraTexture(), position2d<s32>(0,0));
smgr->drawAll();
driver->endScene();
}
device->drop();
return 0;
}