Code: Select all
//Create Newton World
NewtonWorld* nWorld=NewtonCreate();
Code: Select all
//In the Main
//Create Timer Variable
unsigned int lasttick=0;
//Create a cube node
ISceneNode* boxNode=smgr->addCubeSceneNode();
//Create collision manager
NewtonCollision *collision=NewtonCreateBox(nWorld,0,0,0,0,0);
//Create the newton body for the boxNode irrlicht node
NewtonBody* body=NewtonCreateBody(nWorld,collision);
//Release the collision node
NewtonReleaseCollision(nWorld,collision);
//No idea here
NewtonBodySetUserData(body,boxNode);
//set mass of cube?
NewtonBodySetMassMatrix(body,100.0,1.0,1.0,1.0);
//No idea
matrix4 mat;
mat.setTranslation(vector3df(0,0,0));
NewtonBodySetMatrix(body,&mat.pointer()[0]);
//No idea
float omega[3]={1.0,2.0,1.0};
NewtonBodySetOmega(body,&omega[0]);
Code: Select all
//In the main draw while loop
//update newton world in a timely fashion
if (device->getTimer()->getTime() > lasttick + 10)
{
lasttick = device->getTimer()->getTime();
NewtonUpdate(nWorld, 0.01f);
}
//No Idea
float matrix[4][4];
NewtonBodyGetMatrix(body, &matrix[0][0]);
//Not sure, but rotating the cube?
matrix4 mat;
memcpy(mat.pointer(), matrix, sizeof(float)*16);
boxNode->setPosition(mat.getTranslation());
boxNode->setRotation(mat.getRotationDegrees());
Any help is appreciated! If anyone could help me write a simple example, such as creating a floor object and a single cube object that is created above it, would be most helpful. All I really need is a bare-bones basic little example to get started, most of the ones I have found simply do not work with the new version of newton.
One thing I noticed is that there are a lot of NULL arguments that I cannot initialize that way. Like the world creation line:
Code: Select all
NewtonWorld* nWorld=NewtonCreate(NULL,NULL);
Code: Select all
NewtonWorld* nWorld=NewtonCreate();
Code: Select all
NewtonCollision *collision=NewtonCreateBox(nWorld,0,0,0,0,NULL);
Code: Select all
NewtonCollision *collision=NewtonCreateBox(nWorld,0,0,0,0,0);