collision problem

paulm12

22-10-2006 20:51:34

I have the following code

body* frame = mScene->createStaticBody(
"frame1",
"frame_Material #32.mesh",
new meshShape("frame_Material #32.mesh", mScene),
Vector3 (100,0,0)
);
frame->mNode->pitch( Degree( -90 ) );

Ball = mScene->createBody("Ball","sphere.1m.mesh",new sphereShape(1),50.0f,Vector3(0,200,-10));
Ball->mNode->setScale(62,62,62);


I anticipated that the ball would bounce off the static body 'frame', I can't seem to figure out what i'm doing wrong... I#ve looked at a few things... this is probably pretty basic... but I just can't see... cheers

betajaen

22-10-2006 21:51:04

Aha, It should be:

new sphereShape(62.0f)

Your resizing the node, but not setting the size of the collision model to the same.

paulm12

22-10-2006 23:29:28

ok, great...cheers!! i still think i'm not understanding part of this...sorry!!

If I change this to

// Set up the ball
Ball = mScene->createBody("Ball","sphere.1m.mesh",new sphereShape(20.0f),500.0f,Vector3(0,200,-10));
Ball->mNode->setScale(20,20,20);


it only collides with part of the other body and if I change it to

// Set up the ball
Ball = mScene->createBody("Ball","sphere.1m.mesh",new sphereShape(10.0f),500.0f,Vector3(0,200,-10));
Ball->mNode->setScale(10,10,10);


it passes through again....

by the way betajaen, your book is very helpful for getting into this stuff, is there a final version on the cards?? I'd buy it

betajaen

23-10-2006 09:09:45

That seems normal to me.

What does the other body look like, collision model wise? Turn on debug mode and let's see it.

Ridhan

23-10-2006 13:24:11

I've got a question about the meshSphape type. How do i resize these shapes?

Putted a mesh on Nxogre and used a meshShape, then i downscaled the mesh 'cos it was king-kong sized. But then i ran nxogre...and looks like the mesh was sent through space and it was floating around :oops:
My guess is that the meshShape is still at the original size, but i don't know how to downscale it....it must be so easy :(

betajaen

23-10-2006 13:45:32

You don't. You resize it in an 3D modeler, it's static for a reason - it never moves or resizes or anything.

Anyway, you should resize everything before hand it's a lot neater. ;)

Ridhan

23-10-2006 15:10:26

Thanks I'll do so then.

You left me with a doubt though.

Are you saying that a meshShape is only used with static bodies only?

:? ...if that so, that means that I need to use capsules for my dynamic meshes??

betajaen

23-10-2006 15:22:39

Yep, meshShapes are only for static bodies.

But you can use pretty much any other shape(cube, sphere, capsule, convex and so on), or many combinations of at the same time for dynamics.

In Physics Engines the simpler the shape the faster the simulation is anyway, so just think of it as a form of optimisation.

Ridhan

23-10-2006 15:34:48

Thanks again :wink:

paulm12

10-11-2006 15:42:46

I basically have these:

// Set up the ball
Ball = mScene->createBody("Ball","sphere.1m.mesh",new sphereShape(2.0f),5.0f,Vector3(0,2,0));
Ball->mNode->setScale(2.0f,2.0f,2.0f);

//set up the test area
body *b1 = mScene->createStaticBody("b1","cube.1m.mesh",new cubeShape(Vector3(16,8,2)),Vector3(0,0.5,-16));
b1->mNode->scale(16,8,2);
body *b2 = mScene->createStaticBody("b2","cube.1m.mesh",new cubeShape(Vector3(16,8,2)),Vector3(0,0.5,16));
b2->mNode->scale(16,8,2);
body *b3 = mScene->createStaticBody("b3","cube.1m.mesh",new cubeShape(Vector3(16,1,32)),Vector3(0,0,0));
b3->mNode->scale(16,0,32);
body *b4 = mScene->createStaticBody("b4","cube.1m.mesh",new cubeShape(Vector3(2,8,32)),Vector3(-8,0.5,0));
b4->mNode->scale(2,8,32);
body *b5 = mScene->createStaticBody("b5","cube.1m.mesh",new cubeShape(Vector3(2,8,32)),Vector3(8,0.5,0));
b5->mNode->scale(2,8,32);


But the collisions are way off... I took a screenshot to show how far off the collisions are. The above code seems right to me, so i'm really confused.!!

betajaen

10-11-2006 16:10:53

Woah old thread. Sounds like a collision problem.

Turn on debug mode and post a screenshot.

paulm12

10-11-2006 19:01:41

I assume you mean debug rendering.... yeah old thread, same problem, i''ve just had other stuff do to....but back into trying to learn nxogre..thanks

dont know if this helps in anyway? but here is a screenshot with debug rendering on....


In the direction shown the collision seems to happen too late, at the other end it's too early, and it happens with the ball not touching the wall...thanks