I am pretty desparate to find a fairly simple way of using newton with irrlicht and creating collision detection with a irr scene (only 1 mesh, the terrain). I need to be able to walk over the terrain, and up and down hills/mountains to a certain extent. I am using irrlicht and newton, without any wrappers (do I need a wrapper???) I was wondering if there is a fairly simple way I could get the triangles from the irr mesh and create collision detection.
Here is my current code:
Code: Select all
#include <irrlicht.h>
#include <iostream>
#include "newton.h"
using namespace irr;
using namespace video;
using namespace core;
using namespace gui;
using namespace scene;
using namespace io;
using namespace std;
#pragma comment(lib, "Irrlicht.lib")
int main()
{
IrrlichtDevice* device =
createDevice(EDT_OPENGL, core::dimension2d<s32>(640, 480),32,true);
if (device == 0)
return 1;
device->setWindowCaption(L"Target Practice 3D [");
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
ICameraSceneNode* camera = 0;
ICursorControl* cursor = device->getCursorControl();
smgr->loadScene("3d1.irr");
camera = smgr->addCameraSceneNodeFPS(0, 100.000000f, 5000.0f,-1,0,0,false,0.25f);
camera->setFarValue(50000.0f);
core::vector3df camerapos = camera->getPosition();
// and draw everything.
int lastFPS = -1;
while(device->run())
if (device->isWindowActive())
{
driver->beginScene(true, true, video::SColor(0,0,0,0));
smgr->drawAll();
driver->endScene();
cursor->setVisible(false);
int fps = driver->getFPS();
if (lastFPS != fps)
{
core::stringw str = L"Target Practice 3D";
str += driver->getName();
str += "] FPS:";
str += fps;
device->setWindowCaption(str.c_str());
lastFPS = fps;
}
}
device->drop();
return 0;
}
Exactly how and where would I use/put code to allow collision detection from 3d1.irr to stop the camera going through the ground? And allow it to climb up/down mountains/hills/trenches?
Any help would be GREATLY appreciated as I am only in year 9 and started c++ 2 months ago.
If I decided to use a simple 3ds mesh instead of using irr, would collision detection be any easier? If so, please share.
Thanks so much.