Page 1 of 1

Anchor point for pivot joint

Posted: Fri Jan 04, 2008 7:19 pm
by kolis
A small feature request. It would be nice to be able to set anchor points for the pivot joint, and it would also make it more consistent with the other joint types.

Re: Anchor point for pivot joint

Posted: Fri Jan 04, 2008 9:33 pm
by dc443
Does a Slide joint with min and max distance set to zero function in the same way? It should.

Re: Anchor point for pivot joint

Posted: Fri Jan 04, 2008 9:39 pm
by dc443
Interesting. I JUST wrote the code to display joints (for debug purposes and whatnot), and it appears that the pivot joint has local body coordinate anchor values. This following code works perfectly:

Code: Select all

else if (joint->type == PIVOT)
		{
			
			cpPivotJoint * pivotJoint = (cpPivotJoint*) joint;
			cpVect pos = cpBodyLocal2World(joint->a,pivotJoint->anchr1);
			glColor3f(1,0,1);
			glPointSize(4.0);
			glBegin(GL_POINTS);
			{
				glVertex2f(pos.x,pos.y);
			}
			glEnd();

		}
I guess you can try editing the anchor values after creating the joint. Maybe it'll work just fine.

Re: Anchor point for pivot joint

Posted: Sat Jan 05, 2008 4:48 am
by slembcke
1) You'd think so, but a slide joint with min/max set to 0 is not the same. Slide joints only work on one axis. You have to solve the constraint differently if you want it to work like a pivot. It probably would work, but I'd think it would be much less stable.

2) The reason why you only get one point for pivot joints is so that you cannot initialize the joint to an invalid state. If the anchor points are too far apart when you create the joint, it would pretty much explode (in the numeric sense) and maybe never recover.