PDA

View Full Version : ODE, Basic start on Linux with Lazarus



tsr
01-07-2007, 06:10 PM
Hello everyone!

I have problem to make simplest application using ODE on Linux.
Do somebody have some working source code?

If I wrote in OnFormCreate:

dMassSetBox (SomeMass,1,SIDE,SIDE,SIDE);

I've got Acces Violation at rune time. Before it I creating World, and Body...

technomage
01-07-2007, 06:18 PM
Can you post some more code (i.e the form create).

I seem to remember this problem when I started out with ODE. But I can't remember what fixed it....

tsr
01-07-2007, 06:21 PM
procedure TForm1.FormCreate(Sender: TObject);
var
_m: TdMass;
begin
BackBuff := TBitmap.Create;
with BackBuff do
begin
Width := BackBuf_W;
Height := BackBuf_H;
Canvas.Pen.Width := 2;
Canvas.Pen.Color := clYellow;
Canvas.Brush.Color := clBlack;
end;

World := dWorldCreate();
Space := dHashSpaceCreate(nil);
ContactGroup := dJointGroupCreate (0);
dWorldSetGravity (World,0,9.81,0);

Body1 := dBodyCreate (World);
dBodySetPosition (Body1,0.2,1,0);
dMassSetBox (_m,1,SIDE,SIDE,SIDE); // Acces Violation
dMassAdjust (_m,1); // Acces Violation

dBodySetMass (Body1,@_m);

Timer.Enabled := True;
end;

technomage
01-07-2007, 06:35 PM
Can't see anything wrong with the code.

Do you have the correct version of ODE compiled and installed?

tsr
01-07-2007, 07:24 PM
You are great! :D

I had 5.5-5 ODE version from Ubuntu repository. I've removed it and installed newest 0.8 and now it pretty works.

Thanks a lot.

tsr
02-07-2007, 10:29 PM
Another basic problem.

Body2 := dBodyCreate (World);
dBodySetPosition (Body2,1,2,0);
dMassSetBox (_m2,1,SIDE,SIDE,SIDE);
dMassAdjust (_m2,0.2);
dBodySetMass(Body2, @_m2);

Joint1 := dJointCreateBall (World, 0);
dJointSetBallAnchor (Joint1, 1, 2, 0);
dJointAttach (Joint1, Body2, nil);

Joint1 should make Body2 unmovable in point x=1, y=2, z=0 but this body fly to the point 0,0,0. Function dJointSetBallAnchor isn't for this?

technomage
03-07-2007, 11:58 AM
I'm not totally sure how to use Joints, so I can't help there I'm afraid (I avoided joints totally when I was using ODE)

Anyone else got any ideas?

tsr
03-07-2007, 02:22 PM
I have an idea 8)
First I have to write dJointAttach, and after attaching dJointSetBallAnchor. It is not clear to me why but it works in this order.