A place to discuss everything related to Newton Dynamics.
Moderators: Sascha Willems, walaber
by Overhertz » Sun Jan 30, 2011 1:24 pm
hi, i'm looking for a solution to add a force to a body IF the body is currently touching something. i can't find a solution to this. anyone can help?
-

Overhertz
-
- Posts: 112
- Joined: Mon Jul 06, 2009 11:19 am
-
by Julio Jerez » Sun Jan 30, 2011 1:50 pm
that is what the phyiscs engine does.
there is no way to do that with ouy beraking the solver,
you can try chnegoin teh normal acceleration is a contact callack, bu I do not thnk I ever done that.
-
Julio Jerez
- Moderator

-
- Posts: 12452
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by JernejL » Sun Jan 30, 2011 2:00 pm
you can use the contacts iterator in the forcetorque callback to check if body has touched something in previous frame.
-

JernejL
-
- Posts: 1587
- Joined: Mon Dec 06, 2004 2:00 pm
- Location: Slovenia
-
by Overhertz » Sun Jan 30, 2011 2:07 pm
basically i want to do something like >
- Code: Select all
procedure VehicleForceAndTorqueCallback(const body: PNewtonBody; timestep: float; threadindex: integer); cdecl;
var
obj: TZLVehicle;
Mass : Single;
Inertia : Vector3df;
Force : Vector3df;
bodymat: Matrix4;
newvl: Vector3df;
outbl: Vector3df;
begin
obj := NewtonBodyGetUserData(body);
NewtonBodyGetMassMatrix(body, @Mass, @Inertia.x, @Inertia.y, @Inertia.z);
NewtonBodyGetMatrix(body, bodymat.pointer);
//if body of wheel x and y is touching something then >
if obj.Reverse = True then begin
newvl.x := -obj.fRevols*4; newvl.y := 0; newvl.z := 0;
end else begin
newvl.x := obj.fRevols*8; newvl.y := 0; newvl.z := 0;
end;
bodymat.rotateVect(outbl, newvl);
//
Force := getvector3df(outbl.x, (NEWTON_GRAVITY * Mass) + outbl.y, outbl.z);
NewtonBodyAddForce(body, @Force.X);
end;
i want to simulate force transferal from gripping wheels to the body, when the front wheels spin (without this force, they overspin and max speed at 50) i currently implemented this and it can give a realistic result for speed and performance without tweaking newton, my only problem is i need this force only transferred when the wheels are on the ground (in the air is a bit silly to grip something.... lol) however it works really well now, if i can get this solved then i will release a demo of it working.
-

Overhertz
-
- Posts: 112
- Joined: Mon Jul 06, 2009 11:19 am
-
Return to General Discussion
Who is online
Users browsing this forum: No registered users and 368 guests