hi, i've been having alot of problems trying to get Newton to work full stop, not to mension i'd like it to be used for 2d physics....

i guess i am doing something wrong. hope someone can help.

on engine load.

[pascal]
var
min,max : Single;
begin
NewtonWorld := NewtonCreate(nil, nil);

min := -25000;
max := 25000;
NewtonSetWorldSize(NewtonWorld, @min, @max); //temp until i finish the map loader.
NewtonSetSolverModel(NewtonWorld, 0);
[/pascal]


i then load x amount of `civilians`

[pascal]
New(civ);
civ.Initialise(NewtonWorld, @SpriteEngine);
[/pascal]

which is as follows:

[pascal]
procedure TAICivilian.Initialise(newtonW: PNewtonWorld; se: PCoSpriteEngine);
var
Inertia : TCoVector3;
Value : TCoVector3;
Force : TCoVector3;

Collision: PNewtonCollision;
begin
Sprite := se.NewSprite('.\aiciv.PNG', 512, 64);
Sprite.X := 512;
Sprite.Y := 360;
Mass := 1;

Collision := NewtonCreateBox(newtonW, 64, 64, 64, nil); //temp
Sprite.NewtonBody := NewtonCreateBody(newtonW, Collision);
NewtonReleaseCollision(newtonW, Collision);

//all temp values until i get newton working.
Inertia.x := Mass * (64 * 64 + 64 * 64) / 12;
Inertia.y := Mass * (64 * 64 + 64 * 64) / 12;
Inertia.z := Mass * (64 * 64 + 64 * 64) / 12;
NewtonBodySetMassMatrix(Sprite.NewtonBody, Mass, Inertia.x, Inertia.y, Inertia.z);

F_Matrix[3,0] := Sprite.X;
F_Matrix[3,1] := Sprite.Y;
F_Matrix[3,2] := 0;
NewtonBodySetMatrix(Sprite.NewtonBody, @F_Matrix[0,0]);
NewtonBodySetForceAndTorqueCallback(Sprite.NewtonB ody, ForceAndTorqueCallback);
end;
[/pascal]


on each frame i call to move the civilians

[pascal]
procedure TAICivilian.Move(delta: Double);
var
matWorld: TCoMatrix;
begin
NewtonBodyGetMatrix(Sprite.NewtonBody, @matWorld[0,0]);
Sprite.X := matWorld[3,0];
Sprite.Y := matWorld[3,1];
[/pascal]

after move is called they are then drawn

[pascal]
procedure TCoSprite.Draw(Dev: IDirect3DDevice9);
var
rcSource: TRect;
vPosition: TD3DXVector2;
begin
rcSource.Left := (F_CurFrame * F_Width)-64;
rcSource.Right := F_CurFrame * F_Width;

rcSource.Top := F_TextureY;
rcSource.Bottom := F_Height;

with vPosition do begin
x := F_X;
y := F_Y;
end;

F_Sprite._Begin(D3DXSPRITE_ALPHABLEND);
F_Sprite.Draw( F_Texture, @rcSource, nil, @vPosition, $f0f0f0f0 );
F_Sprite._End;
end;
[/pascal]

and finally, at the end of frame NewtonUpdate is called... and so... nothing happens, sprites do not move at all. and i've been trying alsorts of things to get it to work.


-Colin