iam new to newton

and for as far as i know you need to use the callback function to at gravity
but when i do that ill get a error:
invalid conversion from `void (*)(const NewtonBody*)' to `void (*)(const NewtonBody*, float, int)
here is my complete code its just a simple box..

- Code: Select all
#include <irrlicht/Irrlicht.h>
#include <Newton.h>
#include <iostream>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
static NewtonWorld* nWorld;
static NewtonBody* body;
IVideoDriver* driver = 0;
IrrlichtDevice *device = 0;
ISceneManager* smgr = 0;
ISceneNode *boxNode = 0;
ISceneNode *cam = 0;
unsigned int lasttick;
#define NEWTON_GRAVITY -1
void _cdecl ApplyForceAndTorqueEvent (const NewtonBody* body)
{
printf("test\n");
float mass;
float Ixx;
float Iyy;
float Izz;
float force[3];
float torque[3];
NewtonBodyGetMassMatrix (body, &mass, &Ixx, &Iyy, &Izz);
force[0] = 0.0f;
force[1] = NEWTON_GRAVITY * mass;
force[2] = 0.0f;
torque[0] = 0.0f;
torque[1] = 0.0f;
torque[2] = 0.0f;
NewtonBodyAddForce (body, force);
NewtonBodyAddTorque (body, torque);
}
void InitScene()
{
device = createDevice(EDT_OPENGL, dimension2d<u32>(640,480), 32, false);
driver = device->getVideoDriver();
smgr = device->getSceneManager();
nWorld = NewtonCreate();
boxNode = smgr->addAnimatedMeshSceneNode(smgr->getMesh("data/smallcube.3ds"));
boxNode->setMaterialTexture(0, driver->getTexture("data/crate.jpg"));
boxNode->setMaterialFlag(EMF_LIGHTING, false);
NewtonCollision *collision;
collision = NewtonCreateBox(nWorld, 0, 0, 0, 0, NULL);
body = NewtonCreateBody (nWorld, collision);
NewtonReleaseCollision (nWorld, collision);
NewtonBodySetUserData(body, boxNode);
NewtonBodySetMassMatrix (body, 100.0f, 1.0f, 1.0f, 1.0f);
matrix4 mat;
mat.setTranslation(vector3df(0,0,0));
NewtonBodySetMatrix(body, &mat.pointer()[0]);
float omega[3] = {1.0f, 2.0f, 1.0f};
NewtonBodySetOmega (body, &omega[0]);
NewtonBodySetForceAndTorqueCallback(body, ApplyForceAndTorqueEvent);
cam = smgr->addCameraSceneNodeFPS();
cam->setPosition(vector3df(0, 300, 0));
}
void DrawScene()
{
if (device->getTimer()->getTime() > lasttick + 10) {
lasttick = device->getTimer()->getTime();
NewtonUpdate(nWorld, 0.01f);
}
float matrix[4][4];
NewtonBodyGetMatrix(body, &matrix[0][0]);
matrix4 mat;
memcpy(mat.pointer(), matrix, sizeof(float)*16);
boxNode->setPosition(mat.getTranslation());
boxNode->setRotation(mat.getRotationDegrees());
}
int main()
{
InitScene();
while(device->run())
{
DrawScene();
printf("y: %f\n", boxNode->getPosition().Y);
driver->beginScene(true, true, video::SColor(0,0,0,0));
smgr->drawAll();
driver->endScene();
}
NewtonDestroy(nWorld);
device->drop();
return 0;
}