Sign in to follow this  
riruilo

Wha's wrong with this ODE code?

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this