Multiple objects colliding with the landscape

SFAOK

12-07-2006 16:15:46

In the tutorials you can fire cylinders from the camera using the space bar. So I've managed to setup OgreNewt within my simulation and everything works fine, with the afformentioned cylinder firing enabled.

Now the reason I want OgreNewt in my code outside of simulating physics is to have collision detection for my creature's legs. What I plan to do is physically simulate the feet of the creatures and have them 'plant' or 'anchor' themselves when they touch the landscape.

The first thing I'm trying to do is have a collision callback method that stops the space bar fired cylinders when they touch the surface, or have them turn red or whatever - in other words I want to have the code so that after the first collision with the surface, something happens in effect (which will eventually be used for the leg tips).

So I've got it setup at the moment like this :


int collisionMatCallback::userProcess()
{
// first, find which body represents the conveyor belt!
OgreNewt::Body* object;

if (m_body0->getType() == mTestID)
{
collisionFlag = true;
}



void collisionMatCallback::userEnd()
{
if(collisionFlag == true)
cout << "\nBang!";

}


Or in other words, when a cylinder hits the surface, 'Bang' is printed out.

Now the problem I have is that when I fire 10 cylinders off the edge of the map, and then fire the 11th onto the landscape I still get a Bang. How would I differentiate between the different cylinders? Do I need to create a different Material ID for all of them, or am I missing a trick?

How would I then access the specific object's body properties, or change its material? Any help would be great.

walaber

14-07-2006 08:12:09

you can use the "ID" integer to differentiate between different body types. once you know the body type, you can "get back" to your bigger object through the "userData" system.

for example, if you create a bunch of IDs, you can tell inside the callback which body is the cylinder.

then if you have a large class that holds the detailed parameters of this particular cylinder, you can get set it up to get a pointer through the userData system.

ask if you need more details.

SFAOK

08-08-2006 16:08:46

Thanks I managed to solve that problem in the end.

Here comes another question....

I've got it setup now so that I can drop 'bombs' on the landscape, and when they stike the surface a puff of smoke is created at that point. They also freeze when they hit the surface like they are stuck in the ground.

However, after bombing the surface for a while (could be 5 seconds, could be 10 minutes) suddenly a bomb bounces off the surface and any bomb that is created after it will do the same - i.e they don't take any notice of the collision callback (i.e the userProcess function that detects when a bomb hits the surface, freezes it and spawns a particle system).

Any ideas what might be causing this? There doesn't seem to be anything in my code that would case it directly.

walaber

08-08-2006 18:34:08

there is a good chance you are outside the limits of the world size. have you set the size of the world to contain your entire ground mesh?

SFAOK

09-08-2006 13:14:45

there is a good chance you are outside the limits of the world size. have you set the size of the world to contain your entire ground mesh?I don't believe that's the problem because the objects bounce off the surface and roll down the terrain once the problem starts. It also seems to not be dependant on where the bombs are. I could setup the camera in one place and fire arcs of bombs onto the landscape and after a while it will ignore the userProcess function like it wasn't there.

It also doesn't seem to be dependant on how many bombs have been spawned - sometimes it does it after 10, sometimes after 500...

walaber

09-08-2006 18:35:11

hmm... it must be in your code somewhere then... somehow the materials are not getting properly applied or something. of course the possibility of a bug in Newton is certainly possible as well. (or OgreNewt for that matter!)