Page 1 of 1

Two things about Newton...

Posted: Tue Sep 02, 2008 1:29 am
by Innopeor
First:
How can i position a NewtonBody?
This is my code:

Code: Select all

mat.setTranslation(vector3df(0,15,0));
if i modify it over 100:

Code: Select all

mat.setTranslation(vector3df(0,101,0));
i got a segmentation fault or it won't move.
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());

}
Second:
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);
seems trepassing the terrain.

PS. My English sucks, sorry for this...

Posted: Tue Sep 02, 2008 9:53 am
by sudi

Posted: Tue Sep 02, 2008 3:45 pm
by Innopeor
I search for another physic engine, because i found that nobody use newton...
The documentation about it's very poor and for a beginner not enough a simple "hello world"... Do you know a good alternative to newton with serious documentations, tutorials or examples?

Posted: Tue Sep 02, 2008 3:47 pm
by JP
Bullet, ODE, Physx, Havok

Posted: Tue Sep 02, 2008 5:24 pm
by Innopeor
JP wrote:Bullet, ODE, Physx, Havok
You may suggest one of those in particular for a newbie?

Posted: Tue Sep 02, 2008 5:29 pm
by Taymo
For a beginner I'd suggest ODE, it seems the most simple. PhysX, although not necessary, is made for hardware physics implementations, Havok is Half-Life 2's physics engine and I though it cost a fortune. Never looked at bullet.

The best thing to do is start with one (ODE) and if you don't like it try another. Personal experience is the best practice.

Posted: Tue Sep 02, 2008 5:46 pm
by Innopeor
Taymo wrote:For a beginner I'd suggest ODE, it seems the most simple. PhysX, although not necessary, is made for hardware physics implementations, Havok is Half-Life 2's physics engine and I though it cost a fortune. Never looked at bullet.

The best thing to do is start with one (ODE) and if you don't like it try another. Personal experience is the best practice.
Thanks, have you any example, tutorial or something that explain how to using it with irrlicht 1.4? I already searched on the forum for this..

Posted: Tue Sep 02, 2008 6:03 pm
by Innopeor
Confirmed, i don't found (on google and on this forum also) any example, tutorial or documentation about ode and irrlicht 1.4...

Posted: Tue Sep 02, 2008 6:25 pm
by Innopeor
update: I resolved my troubles with Newton :)

Code: Select all

   NewtonCollision *coll;
   ITerrainSceneNode* terrNode;
   NewtonBody* body3;

   // create terrain
   coll = NewtonCreateBox (nWorld, 5, 5, 5, NULL);

   terrNode = smgr->addTerrainSceneNode(
   "media/islehm.png");
   terrNode->setMaterialFlag(EMF_LIGHTING,true);

   terrNode->setScale(core::vector3df(150, 10.0f, 150)); //10, 1.0f, 10
   terrNode->setMaterialFlag(video::EMF_LIGHTING, true);
   terrNode->setPosition(core::vector3df(-1200,-80,-1400));
   terrNode->setMaterialType(terrNode->getMaterial(0).MaterialType == video::EMT_SOLID ?
   video::EMT_DETAIL_MAP : video::EMT_SOLID);
   terrNode->setMaterialTexture(0, driver->getTexture("media/terrain.jpg"));
   terrNode->setMaterialTexture(1, driver->getTexture("media/detail.png"));
   terrNode->setMaterialFlag(video::EMF_FOG_ENABLE, true);
   terrNode->scaleTexture(3.0f, 200.0f);

   body3 = NewtonCreateBody(nWorld,coll);
   NewtonBodySetUserData (body3,terrNode);

   //NewtonBodySetForceAndTorqueCallback(body2, applyForceAndTorque);
   NewtonBodySetMassMatrix (body3, 10000.0f, 1.0f, 1.0f, 1.0f);
   NewtonBodySetTransformCallback(body3, setTransform);

   matrix4 mat3;
   mat3.setTranslation(vector3df(0,-10,0));
   NewtonBodySetMatrix(body3, mat3.pointer());
   NewtonReleaseCollision (nWorld, coll);
   NewtonBodySetUserData(body3, terrNode);

Posted: Tue Sep 02, 2008 6:26 pm
by sudi
For a beginneri would suggest newton. Bc its the simplest of all these physic engines with alot of standard game related features. Softbodies and cloth stuff are not implemented but everything elses needed.

There are a lot of newton wrapper for irrlicht on the forum.

Posted: Wed Sep 03, 2008 12:27 am
by Taymo
Innopeor wrote:
Taymo wrote:For a beginner I'd suggest ODE, it seems the most simple. PhysX, although not necessary, is made for hardware physics implementations, Havok is Half-Life 2's physics engine and I though it cost a fortune. Never looked at bullet.

The best thing to do is start with one (ODE) and if you don't like it try another. Personal experience is the best practice.
Thanks, have you any example, tutorial or something that explain how to using it with irrlicht 1.4? I already searched on the forum for this..
The tutorial section would be a good place to start. Below the normal tutorials, are tutorials on integrating other libs. ODE, Newton, a PhysX all have their own tutorial.