dont know why its doing this but when i try to make a triangle selector the program generates a microsoft error report and closes.
i have debugged the program down to the line of code that is generating the error.
mapSelector = smgr->createTerrainTriangleSelector(terrain, 0);
mapSelector is a pointer in the private: area of a class called game, the code is part of the same class. so there should be no access problems, and it seems to work with all of the other pointers i have.
my code is as followes
Code: Select all
#include <irrlicht.h>
#include <iostream>
using namespace irr;
#pragma comment(lib, "Irrlicht.lib")
class game
{
public:
void setup()
{
device = createDevice(video::EDT_OPENGL, core::dimension2d<s32>(800, 600),32,false);
printf("DONE!");
smgr = device->getSceneManager();
driver = device->getVideoDriver();
env = device->getGUIEnvironment();
}
void addCamera()
{
//initate the key map
SKeyMap keyMap[8];
//fill the key map
keyMap[0].Action = EKA_MOVE_FORWARD;
keyMap[0].KeyCode = KEY_UP;
keyMap[1].Action = EKA_MOVE_FORWARD;
keyMap[1].KeyCode = KEY_KEY_W;
keyMap[2].Action = EKA_MOVE_BACKWARD;
keyMap[2].KeyCode = KEY_DOWN;
keyMap[3].Action = EKA_MOVE_BACKWARD;
keyMap[3].KeyCode = KEY_KEY_S;
keyMap[4].Action = EKA_STRAFE_LEFT;
keyMap[4].KeyCode = KEY_LEFT;
keyMap[5].Action = EKA_STRAFE_LEFT;
keyMap[5].KeyCode = KEY_KEY_A;
keyMap[6].Action = EKA_STRAFE_RIGHT;
keyMap[6].KeyCode = KEY_RIGHT;
keyMap[7].Action = EKA_STRAFE_RIGHT;
keyMap[7].KeyCode = KEY_KEY_D;
camera = smgr->addCameraSceneNodeFPS(0, 100, 500, -1, keyMap, 8);
camera->setPosition(core::vector3df(1900*2,300*2,3700*2));
camera->setTarget(core::vector3df(2397*2,343*2,2700*2));
camera->setFarValue(12000.0f);
}
void hideCursor()
{
device->getCursorControl()->setVisible(false);
}
void addTerain()
{
scene::ITerrainSceneNode* terrain = smgr->addTerrainSceneNode( "media/moonmap2.bmp");
terrain->setScale(core::vector3df(60, 5, 60));
terrain->setMaterialFlag(video::EMF_LIGHTING, true);
terrain->setMaterialTexture(0, driver->getTexture("media/moontexture.jpg"));
terrain->setMaterialTexture(1, driver->getTexture("media/detailmap3.jpg"));
}
void addTerrinTriangleSelector()
{
mapSelector = smgr->createTerrainTriangleSelector(terrain, 0);
terrain->setTriangleSelector(mapSelector);
mapSelector->drop();
scene::ISceneNodeAnimator* anim2 = smgr->createCollisionResponseAnimator(
mapSelector, camera, core::vector3df(60,100,60),
core::vector3df(0,-1,0),
core::vector3df(0,50,0));
camera->addAnimator(anim2);
}
void addCameraCollision()
{
}
void run()
{
int lastFPS =-1;
while(device->run())
if (device->isWindowActive())
{
driver->beginScene(true, true, 0 );
smgr->drawAll();
env->drawAll();
driver->endScene();
int fps = driver->getFPS();
if (lastFPS != fps)
{
core::stringw str = L"Terrain Renderer - Irrlicht Engine [";
str += driver->getName();
str += "] FPS:";
str += fps;
device->setWindowCaption(str.c_str());
lastFPS = fps;
}
}
device->drop();
}
private:
IrrlichtDevice* device;
scene::ISceneManager* smgr;
video::IVideoDriver* driver;
gui::IGUIEnvironment* env;
scene::ICameraSceneNode* camera;
scene::ITerrainSceneNode* terrain;
protected:
scene::ITriangleSelector* mapSelector;
};
int main()
{
game Game;
Game.setup();
Game.addCamera();
Game.hideCursor();
Game.addTerain();
Game.addTerrinTriangleSelector();
Game.addCameraCollision();
Game.run();
system("PAUSE");
return 0;
}
Bochek