예제 #1
0
    //public void ScaleToActualSize() {
    //    if (transform.localScale == actualSize) return;
    //    if (interactionBehaviour.isGrasped) {
    //        ScaleAroundGraspAbs(actualSize);
    //        return;
    //    }
    //    transform.localScale = actualSize;
    //}

    public void ScaleAroundGraspAbs(Vector3 absoluteScale)
    {
        if (!interactionBehaviour.isGrasped)
        {
            return;
        }
        InteractionController interactionController = interactionBehaviour.graspingController;

        Vector3 graspingPoint = interactionController.GetGraspPoint();

        interactionBehaviour.graspedPoseHandler.ClearControllers();
        Vector3 pivotPointInLocalSpace = transform.InverseTransformPoint(graspingPoint);

        transform.localScale = absoluteScale;
        Vector3 scaledPivotPointWorldSpace = transform.TransformPoint(pivotPointInLocalSpace);
        Vector3 diff = graspingPoint - scaledPivotPointWorldSpace;

        transform.position = transform.position + diff;
        interactionBehaviour.rigidbody.position = interactionBehaviour.rigidbody.position + diff;

        interactionBehaviour.graspedPoseHandler.ClearControllers();
        interactionBehaviour.graspedPoseHandler.AddController(interactionController);
    }