🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

ODE, problems with collision detection..

Started by
0 comments, last by Woodsman 19 years, 10 months ago
EDIT: Okay, finally figured this out.. Why doesn't it mention anywhere that you still need to attach the bodies to the contact joint? Thought that'd be passed in with ContactGeom... Oh well. Why aren't there any good tutorials for ODE? Okay, somehow I can't get this to work.. I thought I'd make myself familiar with ODE and wanted to make a Pong game for that. A weird choice, maybe, but here I am. Basically, it works fine up to the point where I am supposed to create the contact joint. I create it, it doesn't complain, but my ball just keeps flying on through the wall / paddle / whatever. What am I doing wrong? Here are the relevant sections of my code:

void Game::CheckCollisions()
{
	for(std::vector<CL_SharedPtr<Object> >::iterator it=Objects.begin();it!=Objects.end();it++)
	{
		dContactGeom contactgeom;
		dContact contact;

		int num=dCollide(MyBall->GetGeom(),(*it)->GetGeom(),1,&contactgeom,sizeof(dContactGeom));
		if(num!=0)
		{
			bool MakeCollision=false;
			memset(&contact,0,sizeof(dContact));
			contact.geom=contactgeom;
			switch((*it)->GetType())
			{
			case 1: //Wall
				contact.surface.mode=dContactBounce;
				contact.surface.bounce=1;
				contact.surface.bounce_vel=0;
				MakeCollision=true;
				break;
			case 2: //Paddle
				contact.surface.mode=dContactBounce;
				contact.surface.bounce=1;
				contact.surface.bounce_vel=0;
				MakeCollision=true;
				break;
			}
			if(MakeCollision)
				dJointCreateContact(World,collisionjoints,&contact);
		}

	}
}

void Game::Update()
{
	CheckCollisions();
	dWorldQuickStep (World, 5);
	dJointGroupEmpty(collisionjoints);
	for(std::vector<CL_SharedPtr<Object> >::iterator it=Objects.begin();it!=Objects.end();it++)
		(*it)->Update();
}
[Edited by - Wuntvor on August 13, 2004 6:59:23 AM]
Advertisement
Quote: Original post by Wuntvor
Why aren't there any good tutorials for ODE?

The included samples are pretty informative and the mailing list is very good. I've even found an opengl & ODE simple game (whose source I haven't really had the chance to look at. That aside though, you're unfortunately correct.
If a plant cannot live according to its nature, it dies; so a man.

This topic is closed to new replies.

Advertisement