• Advertisement
Sign in to follow this  

Wha's wrong with this ODE code?

This topic is 2897 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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;
}

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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 ;)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement