Porting to Newton and have a few questions.

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Porting to Newton and have a few questions.

Postby Adversus » Tue Oct 12, 2010 8:50 am

First off well done I really love the interface and the sdk. Newton is so much easier to use than Other engines however I have a few questions:

1. At the moment I'm generating a static mesh tree collision using the method in the irrlicht example on the wiki however it's a bit slow to do it at run-time.
Is there away to store this information off-line and then to load it in as a binary file?

2. How do you disable angular physics so things behaves as a particle?
Should I just set the angular damping to one or do I have to do something in the force call-back?
Surely either of these two solutions is slightly inefficient?

3. Is there away that I can flag collision/objects so it only collides with those that I then tell it to?

3. How do I create collision without any physics resolution so it tells me when another body over-laps with it but doesn't do any resoultion?

4. Is there away to make it graphics frame-rate independant so I can lock the physics update to a set fps without having to do it myself?

Thanks for any help and big thanks for Newton,

Cheers,
John.
Adversus
 
Posts: 29
Joined: Tue Oct 12, 2010 8:39 am

Re: Porting from Bullet to Newton and have a few questions.

Postby ledahut » Tue Oct 12, 2010 10:21 am

1/ Maybe in next version: 2.25

2/ What kind of particle? can't you just use the barycenter of a small newton sphere?

3/ Set MaterialPair [add your special bodies to a group and the others one to the other group] then use NewtonMaterialSetDefaultCollidable

3' / Look API database on the wiki, section "Collision Miscelaneous function"

4/ Just call newton-update function outside render event (or paint frame event, whatever you call it). For example in a new thread.
ledahut
 
Posts: 98
Joined: Mon Jun 21, 2010 8:03 am
Location: France

Re: Porting from Bullet to Newton and have a few questions.

Postby JernejL » Tue Oct 12, 2010 11:03 am

#1: ledahut is wrong, you can serialize the built trimeshes and cache them with NewtonCollisionSerialize.

#2: you can disable linear and angular dampening see NewtonBodySetAngularDamping and NewtonBodySetLinearDamping

#3: you can set materials as non-collideable or tell newton to ignore any body pair from collision during AABB overlap callback: see NewtonOnAABBOverlap set using NewtonMaterialSetCollisionCallback

#3: ( 2x3? :) ) in newton this is called a trigger volume, see NewtonCollisionSetAsTriggerVolume.

#3: That is something you implement in your game engine, newton supports framerate independancy, but it is up to your engine to support it.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Porting from Bullet to Newton and have a few questions.

Postby Julio Jerez » Tue Oct 12, 2010 11:18 am

Adversus wrote:4. Is there away to make it graphics frame-rate independant so I can lock the physics update to a set fps without having to do it myself?


You are in luck because 2.25 the supports libraries comes with a formal implementation of the Background Thread that can run Newton or any other prossess inpendend of Graphyics in two ways,
1- in a back ground thread (really good for performance on multicores systems)
2- seqencial with the game logic, but frame rate indepdendent

you can download a temporary SDK here and see base class dThread
http://www.newtondynamics.com/downloads ... c-2.25.zip
basically all you need to do is subclass dthread class like this (from the demo)

Code: Select all
class dSimulationThread: public dThread
{
   public:
   dSimulationThread();
   ~dSimulationThread();

   virtual unsigned RunMyTask ();
   bool m_asycronousUpdate;
   dFloat m_physicsTime;
};


then youm main loop do no have to be awere of any physic update

you need to add few varible to you object fo rteh smoot inteplations
here hwo it is done in teh demos

Code: Select all
class DemoEntity: public .....
{
public:
   DemoEntity(DemoEntity* parent);
   virtual ~DemoEntity(void);

...
...
                 virtual void Render() const;

   void InterpolateMatrix (DemoEntityManager& world, dFloat param);

protected:
   dMatrix m_matrix;      // interpolate matrix
   dVector m_curPosition;   // position one physics simulation step in the future
   dVector m_nextPosition;             // position at the current physics simulation step
   dQuaternion m_curRotation;          // rotation one physics simulation step in the future 
   dQuaternion m_nextRotation;         // rotation at the current physics simulation step 
   unsigned m_lock;                           // critical section for asyncronus matrix updates.

               ...
};


It is very eassy chekc out teh demo in the SDK.
I have a Implemenet tshi in Ogre, and also in the Wiki totorial (sequcial update, you can dwload that if you want)
and I have frame rates of over 1600 fps in complex scene, even these the physic stake 8 oet even 12 milisconds.
It is fast that is not even funny.
Julio Jerez
Moderator
Moderator
 
Posts: 12452
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Porting from Bullet to Newton and have a few questions.

Postby Adversus » Tue Oct 12, 2010 11:47 am

Guys that's absoulte amazing.

Thanks for all the replies. I should be sorted now.

btw Julio - It's actually for an iPhone game so the new SDK probably won't be of us however would there be any benifit running it on a separate thread on the iPhone?

At the moment my game runs on separate thread from the main thread so it doesn't require a timer, this gives a more consistent fps however I think Apple might have banned people from doing that.
Adversus
 
Posts: 29
Joined: Tue Oct 12, 2010 8:39 am

Re: Porting from Bullet to Newton and have a few questions.

Postby Adversus » Tue Oct 12, 2010 11:52 am

Oh no wait a min.

2. It's not angular damping I want disabled but angular physics full stop as the physics can be greatly simplified if this isn't required.

I could just set it as the barycenter and just not set the rotation however this seems wasteful.

I am running this on an iPhone so having simple particle physics instead of full rigid body physics would be good.

Thanks,
John.
Adversus
 
Posts: 29
Joined: Tue Oct 12, 2010 8:39 am

Re: Porting from Bullet to Newton and have a few questions.

Postby Julio Jerez » Tue Oct 12, 2010 1:35 pm

are you looking for a 2d physics simulation?
Julio Jerez
Moderator
Moderator
 
Posts: 12452
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Porting from Bullet to Newton and have a few questions.

Postby Adversus » Tue Oct 12, 2010 2:01 pm

No, I just have some objects that act as particles so they don't need full angular physics.
Adversus
 
Posts: 29
Joined: Tue Oct 12, 2010 8:39 am

Re: Porting from Bullet to Newton and have a few questions.

Postby Julio Jerez » Tue Oct 12, 2010 2:19 pm

ha I see, in tha case you can do two things.
Netwon do not have that kind of functionality. the only way to do in newton is by using a Custom3dof to cancel teh angles.
Julio Jerez
Moderator
Moderator
 
Posts: 12452
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Porting from Bullet to Newton and have a few questions.

Postby JernejL » Tue Oct 12, 2010 4:25 pm

You can create simple spheres and ignore their collisions & orientation.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Porting from Bullet to Newton and have a few questions.

Postby Adversus » Fri Oct 15, 2010 8:28 am

In the callbacks I just ignored the rotations. Thanks guys.

One last question, does the offset matrix have any issues.

Once I use this everything appears much more unstable.
Adversus
 
Posts: 29
Joined: Tue Oct 12, 2010 8:39 am

Re: Porting from Bullet to Newton and have a few questions.

Postby Adversus » Fri Oct 15, 2010 9:01 am

Sorry it was a bug in my code.
Adversus
 
Posts: 29
Joined: Tue Oct 12, 2010 8:39 am

Re: Porting from Bullet to Newton and have a few questions.

Postby Adversus » Fri Oct 15, 2010 6:13 pm

Actually no it is more unstable. Perhaps it's the way I'm cancelling the rotation.

Code: Select all
void NewtonBodyTransformCallback( const NewtonBody* body, const dFloat* matrix, int threadIndex)
{
   // get the graphic object form the rigid body
   PhysicsNode *physicsNode = (PhysicsNode*) NewtonBodyGetUserData( body );
   assert(physicsNode);

   // use angular factor?
   if( !physicsNode->GetAngularFlag() )
   {
      // strip out the rotational component
      matrix4 transMat( physicsNode->GetParent().GetMatrix() );
      transMat.setTranslation( vector3df(matrix[12],matrix[13],matrix[14]) );
      // set the parent
      physicsNode->GetParent().SetMatrix( transMat );
   }
   else
      // set the parent
      physicsNode->GetParent().SetMatrix( (matrix4&) (*matrix) );
}


Is this ok or should I do it another way?
Adversus
 
Posts: 29
Joined: Tue Oct 12, 2010 8:39 am

Re: Porting from Bullet to Newton and have a few questions.

Postby Julio Jerez » Fri Oct 15, 2010 7:09 pm

if you are ingnoring trhe rotation then you must write back to the rigid body the new rotation so that the next frame start from the rotation.
Julio Jerez
Moderator
Moderator
 
Posts: 12452
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Porting from Bullet to Newton and have a few questions.

Postby Adversus » Tue Nov 02, 2010 3:18 pm

Finnally getting round to fixing this.

Actually this doesn't work. i.e. just setting and resetting the matrix. The collision looks right when drawn but I can push through the walls.

I'm looking at using the CustomKinematicController. Is there an example that anyone knows I can use?

Would that be a good choice or is there any reason to write my own custom joint i.e. like the 6dof one?

Cheers,
John.
Adversus
 
Posts: 29
Joined: Tue Oct 12, 2010 8:39 am

Next

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 140 guests

cron