Add a rotating force for a body

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Add a rotating force for a body

Postby Carli » Tue Nov 24, 2009 3:19 pm

Hi,

I have some function that calls NewtonBodyAddImpulse.
it has 2 vector parameters: first the deltaforce (relative to the object), second the forceposition (relative to the object).

(1) is multiplied with the bodys matrix and the position offset is subtracted
(2) is multiplied with the bodys matrix

Code: Select all
function impuls2(home: PExecClass; pars:PData):TData; //holt die matrix eines objektes
var force:array[0..2] of single;
var pos:array[0..2] of single;
var matrix: array[0..3,0..3] of single;
type PVec3=^TVec3;
begin
 NewtonBodyGetMatrix(TWorldObject(home^.vars[0].o).newton,@matrix);
 force[0]:=pars[0].float;
 force[1]:=pars[1].float;
 force[2]:=pars[2].float;
 force:=SubtractVector(ApplyMatrixToVec3(matrix,force),PVec3(@matrix[3][0])^); //Impuls - (1)
 pos[0]:=pars[3].float;
 pos[1]:=pars[4].float;
 pos[2]:=pars[5].float;
 pos:=ApplyMatrixToVec3(matrix, pos);//Position - (2)
 NewtonBodyAddImpulse(TWorldObject(home^.vars[0].o).newton,@force,@pos);
 result:=novalue;
end;               


how can I add a rotating force with this? (or if not - with which function?)
Carli
 
Posts: 245
Joined: Fri Oct 02, 2009 5:28 am

Re: Add a rotating force for a body

Postby JernejL » Tue Nov 24, 2009 3:28 pm

Add 2 impulses on opposite sides of object, each facing a different direction.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Add a rotating force for a body

Postby Carli » Tue Nov 24, 2009 3:57 pm

It works only when the body is in the air. Maybe the friction of the bottom is too strong.
Carli
 
Posts: 245
Joined: Fri Oct 02, 2009 5:28 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 0 guests

cron