Moving Sphere on Pipe?

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
redrubi
Posts: 1
Joined: Mon Aug 08, 2011 2:44 pm

Moving Sphere on Pipe?

Post by redrubi »

Hello guys,

I have a sphere and a long pipe, both are models created from 3ds Max. Now I want to control my Sphere move anywhere on the outside surface of the pipe. How can I attach the sphere on the pipe and move it around? Need your help! :)
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Moving Sphere on Pipe?

Post by Norbo »

If the pipe can be represented implicitly by some curve and an offset, it should be pretty easy. The curve defines the 'track' for the ball. You can conceptually consider the ball to be moving along one dimension from the perspective of the curve (the dimension along the curve). The offset from the curve to the sphere can be rotated around the curve, and then transformed into world space using the curve's data.

If you have no metadata at all, and it's just a mesh, it's a little more tricky. You could ray cast from the sphere center in the pipe's direction, though this requires some knowledge of where the pipe is based on previous frames or further queries.

In either case, here's a couple of general tips for problems you'll likely run into for a project like this.
-Setting the position/orientation of an object teleports it. Collision response cannot handle teleportation, because there's no velocity to operate on. If you need collision response, then the objects most fully controlled by velocity/forces.
-If the game requires high speed and requirements of fitting very closely to the pipe, and doesn't require precise collision response, then the best bet is to make the sphere kinematic and control its position through teleportation. After changing the collision rules (http://bepuphysics.codeplex.com/wikipag ... umentation) on the kinematic, it will collect contacts with other static geometry and you can analyze those contacts for gameplay logic.
Post Reply