Wha's wrong with this ODE code?

Started by
1 comment, last by riruilo 14 years, 2 months ago
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.

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;
}
I've seen things you people wouldn't believe. Attack ships on fire off the shoulder of Orion. I watched C-beams glitter in the dark near the Tannhauser gate. All those moments will be lost in time, like tears in rain. Time to die.
Advertisement
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.
Quote:Original post by Promethium
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.


You were right, thanks a lot ;)
I've seen things you people wouldn't believe. Attack ships on fire off the shoulder of Orion. I watched C-beams glitter in the dark near the Tannhauser gate. All those moments will be lost in time, like tears in rain. Time to die.

This topic is closed to new replies.

Advertisement