.Newton Wrapper for Blitz3D

Blitz3D Forums/Blitz3D Userlibs/.Newton Wrapper for Blitz3D

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

phBodyGetSleep%(body%) - fixed. You're right, i've mixed up it.

phWorldSetSolverModel, phWorldSetFrictionModel and phWorldMagnetize were added to help.

phWorldSetSolverModel(model%)
Set solver model of simulation.
- model=0 is the exact mode. This is good for application where precision is more important than speed, ex: realistic simulation.
- model=1 is the adaptive mode, the solver is not as exact but the simulation will still maintain a high degree of accuracy. This mode is good for applications were a good degree of stability is important but not as important as speed.
- Model>=2 is the Linear mode. The solver will not try to reduce the joints relative acceleration errors to below some limit, instead it will perform up to n passes over the joint configuration each time reducing the acceleration error, but it will terminate when the number of passes is exhausted regardless of the error magnitude. In general this is the fastest mode and is is good for applications where speed is the only important factor, ex: video games.


phWorldSetFrictionModel(model%)
Set friction model of simulation.
- model = 0 is the exact model. Friction forces are calculated in each frame. This model is good for applications where precision is more important than speed, ex: realistic simulation.
- model = 1 is the adaptive model. Here values from previous frames are used to determine the maximum friction values of the current frame. This is about 10% faster than the exact model however it may introduce strange friction behaviors. For example a bouncing object tumbling down a ramp will act as a friction less object because the contacts do not have continuity. In general each time a new contact is generated the friction value is zero, only if the contact persist a non zero friction values is used. The second effect is that if a normal force is very strong, and if the contact is suddenly destroyed, a very strong friction force will be generated at the contact point making the object react in a non-familiar way.

phWorldMagnetize(x#,y#,z#,r#,a0#,a1#,a2#,max#)
Add magnet force to the bodies in the world. The magnet is at point (x#,y#,z#), the maximum distance of magnet force is r#, the force is equal to f# = a0# + a1#/dist + a2#/dist/dist (dist is the distance between magnet and the body) and limited to max# value.

About large timestep (0.05). I've used it to be sure of maximum timestep :)

"Also can the number of contacts be set per body ?" - What contacts do you mean? The number of collision contacts can only be readed from the engine and can't be set.

About domino. Your ODE-code takes about 2-5 ms, Newton code takes about 1-10 ms. And I must notice that Newton solver becames a bit slower when there is a large island in the scene. Island is the group of connected bodies. So 4 towers of 5 cubes are faster that 2 towers of 10 cubes. It is newton weakness and I can't do anything in the wrapper.