//-------------------------------------------------------------- ofVec3f ofxBulletJoint::getPivotAWorldPos() { btQuaternion rotQuat = _joint->getCalculatedTransformA().getRotation(); btVector3 btaxis = rotQuat.getAxis(); btVector3 frameA = _joint->getFrameOffsetA().getOrigin(); ofVec3f dir = ofVec3f(frameA.getX(), frameA.getY(), frameA.getZ()); dir.normalize(); dir.rotateRad(rotQuat.getAngle(), ofVec3f(btaxis.getX(), btaxis.getY(), btaxis.getZ() )); dir *= -frameA.length(); return dir + getPivotBWorldPos(); }
//-------------------------------------------------------------- // draws the length of the joint and locations of pivots, but if bodies are sprung more than the length, // will not connect all the way // void ofxBulletJoint::drawJointConstraints() { ofVec3f pa = getPivotAWorldPos(); ofVec3f pb = getPivotBWorldPos(); ofLine( pa, pb ); ofSetColor(255, 0, 0); ofDrawSphere(pa, .5); ofSetColor(0, 0, 255); ofDrawSphere(pb, .5); }
//-------------------------------------------------------------- // draws the length of the joint and locations of pivots, but if bodies are sprung more than the length, // will not connect all the way // void ofxBulletJoint::drawJointConstraints() { ofVec3f pa = getPivotAWorldPos(); ofVec3f pb = getPivotBWorldPos(); glBegin(GL_LINES); glVertex3f(pa.x, pa.y, pa.z); glVertex3f(pb.x, pb.y, pb.z); glEnd(); ofSetColor(255, 0, 0); ofSphere(pa, .5); ofSetColor(0, 0, 255); ofSphere(pb, .5); }