A place to discuss everything related to Newton Dynamics.
Moderators: Sascha Willems, walaber
by ledahut » Mon Sep 20, 2010 8:22 am
1/
I would like to know if the id returned by NewtonMaterialCreateGroupID is always incremented:
- Code: Select all
id[1]:=NewtonMaterialCreateGroupID (world);
id[2]:=NewtonMaterialCreateGroupID (world);
...
id[275]:=NewtonMaterialCreateGroupID (world);
Is id[275] will be always equals to 275 or it can be different?
---
2/
I would like to create conveyor belt [I already looked into the forum] but I want a constant speed for each contactJoint.
I tried:
- Code: Select all
speed:=NewtonMaterialGetContactTangentSpeed(material,0);
if speed<2 then
NewtonMaterialSetContactTangentAcceleration(material,1,0);
But my body shake and I can't get a really good conveyor behavior [even by playing with contact friction].
Compare to ODE
http://opende.sourceforge.net/wiki/inde ... 29#Contact [see dContactMotion] where we can directly set velocity to the contact point.
A function NewtonMaterial
SetContactTangentSpeed would be realy good for my application.
---
3/
I tried to set velocity to body in ContactProcessCallback:
- Code: Select all
if Convoyeur then
begin
Dir := VectorMake(0, 0, -speed / 2, 0); // -Z Direction
Body := NewtonJointGetBody1(contact);
NewtonBodySetVelocity(Body, @Dir);
end
else
begin
Dir := VectorMake(0, 0, 0, 0); // 0
Body := NewtonJointGetBody1(contact);
NewtonBodySetVelocity(Body, @Dir);
end;
It work good but I need to put a zero velocity to stop my conveyor [In ForceAndTorqueCallback the fact of not calling NewtonBodySetVelocity will make the body only move by its inertia].
-
ledahut
-
- Posts: 98
- Joined: Mon Jun 21, 2010 8:03 am
- Location: France
by Julio Jerez » Mon Sep 20, 2010 11:16 am
Newton does not really work that way.
You cannot really set a velocity at a contact point; you can however set the contact tangent acceleration
Basically you can read the tangent speed and subtracted for the velocity at the of the floor of the conveyor and divide it by the time step.
The set this as the contact tangent acceleration, you also need to alight the contact tangent to the direction of motion of the conveyor
If you want to use a Material system the is more like the one you mention in you can just using the default material call back and instead use the Collision shape ID to implement you own contact callback system.
Check Tutorial_201_AbvanceMaterial in the wiki tutorial, is use a system just like that.
That material system is more like normal commercial physics engine use, and you have more control.
-
Julio Jerez
- Moderator

-
- Posts: 12452
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by ledahut » Wed Sep 22, 2010 4:53 am
Thank you, now I use timestep which is better.
Of course I have aligned my tangent direction before set acceleration.
Here a little exemple:
- Code: Select all
ContactSpeed := NewtonMaterialGetContactTangentSpeed(material, 0);
NewtonMaterialSetContactTangentAcceleration(material,(DesiredVelocity - ContactSpeed ) / timestep, 0); //Velocity divided by time equal acceleration
---
In my breakpoint I discover something strange:
- Code: Select all
ThisContact := NewtonContactJointGetFirstContact(contact);
material := NewtonContactGetMaterial(ThisContact);
material* and ThisContact* point the same address

-
ledahut
-
- Posts: 98
- Joined: Mon Jun 21, 2010 8:03 am
- Location: France
by Julio Jerez » Wed Sep 22, 2010 8:37 am
I do not nothing though. a contact and a materail contain different information.
-
Julio Jerez
- Moderator

-
- Posts: 12452
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
Return to General Discussion
Who is online
Users browsing this forum: No registered users and 403 guests