You can cycle through your body/joints using the following functions...
dBodyGetNumJoints(body)
dBodyGetJoint(body,index)
dJointGetBody(joint,index)
dAreConnected(body1,body2)
The best way is to use an array or type 'beforehand' so that you don't have to iterate through loads of bodies and joints, thus wasting precious processing time.
For example, in the rope demo you know that all bodies in the Sphere(1...10) array are connected using joints in the Joint(1...10) array. If you disconnect any of the joints, set the joint array value to zero for that joint. Now iterate through the arrays until you hit zero, then you have your list of connected bodies both direct and indirect.
dBodyGetNumJoints(body)
dBodyGetJoint(body,index)
dJointGetBody(joint,index)
dAreConnected(body1,body2)
The best way is to use an array or type 'beforehand' so that you don't have to iterate through loads of bodies and joints, thus wasting precious processing time.
For example, in the rope demo you know that all bodies in the Sphere(1...10) array are connected using joints in the Joint(1...10) array. If you disconnect any of the joints, set the joint array value to zero for that joint. Now iterate through the arrays until you hit zero, then you have your list of connected bodies both direct and indirect.