use of spacegraph.space3d.phys.constraint.Point2PointConstraint in project narchy by automenta.
the class OrbMouse method mouseGrabOn.
private ClosestRay mouseGrabOn() {
if (pickConstraint == null && pickedBody != null) {
pickedBody.setActivationState(Collidable.DISABLE_DEACTIVATION);
Body3D body = pickedBody;
v3 pickPos = new v3(rayCallback.hitPointWorld);
Transform tmpTrans = body.transform;
tmpTrans.inverse();
v3 localPivot = new v3(pickPos);
tmpTrans.transform(localPivot);
Point2PointConstraint p2p = new Point2PointConstraint(body, localPivot);
p2p.impulseClamp = 3f;
// save mouse position for dragging
gOldPickingPos.set(rayCallback.rayToWorld);
v3 eyePos = new v3(space.camPos);
v3 tmp = new v3();
tmp.sub(pickPos, eyePos);
gOldPickingDist = tmp.length();
// very weak constraint for picking
p2p.tau = 0.1f;
space.dyn.addConstraint(p2p);
pickConstraint = p2p;
// body.setActivationState(Collidable.DISABLE_DEACTIVATION);
// v3 pickPos = v(rayCallback.hitPointWorld);
//
// Transform tmpTrans = body.getCenterOfMassTransform(new Transform());
// tmpTrans.inverse();
// v3 localPivot = v(pickPos);
// tmpTrans.transform(localPivot);
// // save mouse position for dragging
// gOldPickingPos.set(rayCallback.rayToWorld);
// v3 eyePos = v(space.camPos);
// v3 tmp = v();
// tmp.sub(pickPos, eyePos);
// gOldPickingDist = tmp.length();
//
//
// // other exclusions?
// if (!(body.isStaticObject() || body.isKinematicObject())) {
// pickedBody = body;
//
//
// Point2PointConstraint p2p = new Point2PointConstraint(body, localPivot);
// space.dyn.addConstraint(p2p);
// pickConstraint = p2p;
//
// // very weak constraint for picking
// p2p.tau = 0.02f;
// } else {
// if (directDrag == null) {
// directDrag = body;
//
// }
// }
}
return rayCallback;
// }
}
Aggregations