Custom "pipe shape" and sphere

henu
Posts: 2
Joined: Sat Jan 22, 2011 4:21 pm

Custom "pipe shape" and sphere

Post by henu »

Hi Bullet community! :)

I'm new to Bullet Physics Library, and I'm wondering how easy it is to implement your own collision shapes.

For my application, I would like to create my own collision shape, that would represent a pipe that objects can go through. They should of course also hit outer surface of it. Pipes would be static and only shape that can collide with them would be sphere, so calculating collision point, collision normal, how deep it is, etc. is piece of cake, and I can do that without any help. Also the shapes would be designed so that there could be only one collision point between pipe and sphere at a time, so this makes the task even easier.

However, since I don't know much else about collisions (in physics simulation), I would like to know is there many other things that I need to do? Is point/normal/depth of collision enough?

I tried to look inheritance graph of already implemented shapes, and if I understood correctly, all concave shapes were constructed from triangles. Their base class (btConcaveShape) also had some triangle functions, so I though that maybe whole btConcaveShape is for triangle shapes only, which my pipe is not. So should I inherit my shape straight from btCollisionShape?

Anyway, the main idea of this post was to ask, am I doing things at least some how correctly? Or am I totally screwing things up? :D Also, if you can give any other things or point me to some tutorial, that would be great too. From manual, I found out that there is some sphere-sphere collision tutorial about how to register collision algorithms. I will check that later, but I didn't find much else information.
RBD
Posts: 141
Joined: Tue Sep 16, 2008 11:31 am

Re: Custom "pipe shape" and sphere

Post by RBD »

For a pipe you could just break the sides down into (compound) box primitives, that would be fast and efficient... the more boxes, the higher the pipe's curve precision. It's easy to lay them out, assuming z is pipe direction, something like (unverified): r = majorradius-minorradius; for(i = 0; i <= 2pi; i += stepsize) { x = r*cos(i); y = r*sin(i); rz = i;} where stepsize = 2pi/segments = your desired precision. Box: x = r, y = 2*(tan(pi/segments)*majorradius), z = height.
henu
Posts: 2
Joined: Sat Jan 22, 2011 4:21 pm

Re: Custom "pipe shape" and sphere

Post by henu »

Uhh... I appreciate your help but... Do you really think I'm so stupid that I haven't figured out that obvious hack by myself? :D It would be nice to gain more knowledge about Bullet and physics engines, so that is why I would prefer to try implementing my own shape. :)
winspear
Posts: 77
Joined: Thu Nov 26, 2009 6:32 pm

Re: Custom "pipe shape" and sphere

Post by winspear »

If the pipe shape is going to be static, then then just use the btBvhTriangleMeshShape with mass as 0 and it should work just fine. Static shapes which are concave work good in Bullet.
Just to show you one example, take a look at this simulation that I made sometime back. I just imported a cup shape from 3dsmax and initialized it as btBvhTriangleMeshShape.

http://somapanam.wordpress.com/2011/02/ ... neth-over/

Thanks
V