Ok, basicly, to set it up so you can use the functions, you just link the newton.lib(I use
#pragma comment(lib, "Newton.lib")
). You have to set the library directory, and the include directory. After that, just put the dll in the executable directory. Now, getting it to work in gdk was really hard actually. I had to basicly take some tool box tools from the newton demos, and some code from irrlicht, and mix it and match. Then after that I got everything working. So heres what you'll need to make to get it to work: a 3 dimensional vector class where you have access to the 3 dimensions(X, Y, and Z), and you'll need a matrix class. The matrix is 4 dimensional. You'll need to add functions to position and rotate the matrix data, I (again, partially taken from irrlicht), have two methods called setTranslation() and setRotation(). Now, don't think you can go into irrlicht, then copy, and have everything work. Because I had to massively change stuff. I might as well post the headers because I've moved to working with PhysX now( it has features i need in my game...).
Now, an example of how you would set or get a bodies matrix, and apply it to a dgdk object.
// Newton Callbacks
void NewtonSetForceAndTorqueCallback(const NewtonBody* nBody)
{
// Make a vector for gravity.
dVector gravity = dVector(0.0f, -100.0f, 0.0f);
// Apply the force.
NewtonBodySetForce(body, &gravity.m_x);
}
void NewtonSetTransformCallback(const NewtonBody* nBody, const float* matrix)
{
// Get user data of the body(NewtonBodySetUserData(body, (void*)objID) is how is set.
int objID = (int)NewtonBodyGetUserData(nBody);
dMatrix4 mat;
// copy the data from the matrix passed by newton to our own matrix.
memcpy( &mat.M, matrix, sizeof(float)*16);
// get the rotation and position data from our matrix.
dVector pos = mat.getTranslation();
dVector rot = mat.getRotationDegrees();
// position and rotate the object based on our matrix's data.
dbPositionObject(objID, pos.m_x, pos.m_y, pos.m_z);
dbRotateObject(objID, rot.m_x, rot.m_y, rot.m_z);
}
I hope that helps. There will of course be more, but thats basicly the gist of it. Now, after that, you'll have to create the body, and set those as the callbacks like :
NewtonBodySetTransformCallBack(bodyPointer, NewtonSetTransformCallback);
NewtonBodySetForceAndTorqueCallBack(bodyPointer, NewtonSetForceAndTorqueCallback);
DNDK - Dark Newton Development Kit. In progress.