Code: Select all
int main(){
cout<<"starting"<<endl;
EventReceiver* er;
cout<<er<<endl;
IrrlichtDevice *device = createDevice(EDT_OPENGL, dimension2d<u32>(800,500), 32,false, false, true,er);//if I set the event receiver here, it crashes on this line
//device->setEventReceiver(er);//if I set the event receiver here, it crashes at the indicated line below
cout<<"end init"<<endl;
NewtonWorld *nWorld = NewtonCreate();
NewtonSetSolverModel(nWorld,0);
device->setWindowCaption(L"Basic Collision Detection with Newton GD");
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
SObject sphere;
SObject cube;
NewtonCube* nCube;
nCube->mesh = smgr->getMesh("C:/Models/testCube.b3d");//CRASHES HERE
nCube->node = smgr->addMeshSceneNode(nCube->mesh);
nCube->node->setPosition(vector3df(0,3,0));
nCube->node->getMaterial(0).EmissiveColor.set(255,255,255,255);
nCube->collision = NewtonCreateBox(nWorld, 2, 2, 2, NULL,NULL);
nCube->gravity=-4;
nCube->body = NewtonCreateBody(nWorld, nCube->collision);
matrix4 mat;
mat.setTranslation(vector3df(0,5,0));
NewtonBodySetMatrix(nCube->body, &mat.M[0]);
NewtonBodySetUserData(nCube->body,nCube);
NewtonBodySetMassMatrix(nCube->body,10,150,150,150);
NewtonBodySetTransformCallback(nCube->body,callbackTransform);
NewtonBodySetForceAndTorqueCallback(nCube->body, ApplyForceAndTorqueEvent);