int main() {
printf("Hello World.\n");
dWorldID world_id=dWorldCreate();
dWorldSetGravity(world_id, 0,0,-9.81);
dBodyID body_id=dBodyCreate(world_id);
dBodySetPosition(body_id, 0, 10, 0);
dMass masa;
dMassSetSphere(&masa, 1, 10);
dBodySetMass(body_id, &masa);
// 20 actualizaciones por segundo, avanzamos 3 segundos
for (int i=0; i<60; i++) {
dWorldStep(world_id, 0.04);
printf("Y=%f\n", dBodyGetPosition(body_id)[1]);
}
dWorldDestroy(world_id);
printf("Pulsa una tecla para continuar.\n");
getchar();
return 0;
}
Wha's wrong with this ODE code?
Hi mates!
I'm trying ODE for first time and something does not work. I guess this is a falling ball, but I see the same Y value through the time.
Do you see anything strange?
Thanks in advance.
I'm no ODE expert, but it seems you are settings gravity to be on the Z axis
dWorldSetGravity(world_id, 0,0,-9.81);
and then move the body on the Y axis
dBodySetPosition(body_id, 0, 10, 0);
So naturally, Y wont change.
dWorldSetGravity(world_id, 0,0,-9.81);
and then move the body on the Y axis
dBodySetPosition(body_id, 0, 10, 0);
So naturally, Y wont change.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement