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?)