How can i position a NewtonBody?
This is my code:
Code: Select all
mat.setTranslation(vector3df(0,15,0));
Code: Select all
mat.setTranslation(vector3df(0,101,0));
i tried with a simple (setposition) but it return to
the default position because it have need of this void:
Code: Select all
void setTransform(const NewtonBody* body, const float* matrix)
{
// get the scene node form the body
ISceneNode* node = (ISceneNode*)NewtonBodyGetUserData(body);
//copy the transform matrix to a irrlicht matrix
matrix4 mat;
memcpy(mat.pointer(), matrix, sizeof(float)*16);
//move the scene node according to the matrix
node->setPosition(mat.getTranslation());
node->setRotation(mat.getRotationDegrees());
}
How can i make a newton collision on my terrain node?
I search for it because my sphere:
Code: Select all
// create sphere
coll = NewtonCreateSphere (nWorld, 5, 5, 5, NULL);
sphereNode = smgr->addSphereSceneNode(5);
sphereNode->setMaterialFlag(EMF_LIGHTING,true);
body1 = NewtonCreateBody(nWorld,coll);
NewtonBodySetUserData (body1,sphereNode);
NewtonBodySetForceAndTorqueCallback(body1, applyForceAndTorque);
NewtonBodySetMassMatrix (body1, 1.0f, 1.0f, 1.0f, 1.0f);
NewtonBodySetTransformCallback(body1, setTransform);
matrix4 mat;
mat.setTranslation(vector3df(0,15,0));
NewtonBodySetMatrix(body1, mat.pointer());
NewtonReleaseCollision (nWorld, coll);
NewtonBodySetUserData(body1, sphereNode);
PS. My English sucks, sorry for this...