Two things about Newton...

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Innopeor
Posts: 27
Joined: Wed Aug 20, 2008 5:28 pm

Two things about Newton...

Post 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...
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Post by sudi »

We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
Innopeor
Posts: 27
Joined: Wed Aug 20, 2008 5:28 pm

Post 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?
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Bullet, ODE, Physx, Havok
Image Image Image
Innopeor
Posts: 27
Joined: Wed Aug 20, 2008 5:28 pm

Post by Innopeor »

JP wrote:Bullet, ODE, Physx, Havok
You may suggest one of those in particular for a newbie?
Taymo
Posts: 55
Joined: Mon May 22, 2006 1:06 am
Location: Colorado Springs - CTU
Contact:

Post 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.
Ride the Spiral Development:
spiralride.blogspot.com
Innopeor
Posts: 27
Joined: Wed Aug 20, 2008 5:28 pm

Post 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..
Innopeor
Posts: 27
Joined: Wed Aug 20, 2008 5:28 pm

Post 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...
Innopeor
Posts: 27
Joined: Wed Aug 20, 2008 5:28 pm

Post 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);
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Post 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.
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
Taymo
Posts: 55
Joined: Mon May 22, 2006 1:06 am
Location: Colorado Springs - CTU
Contact:

Post 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.
Ride the Spiral Development:
spiralride.blogspot.com
Post Reply