Ejemplo n.º 1
0
    public void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            _isControllingTorus = !_isControllingTorus;
        }

        if (_isControllingTorus)
        {
            // Move the torus.
            transform.Translate(_camera.transform.TransformDirection(SpaceNavigator.Translation), Space.World);
            transform.rotation = SpaceNavigator.RotationInLocalCoordSys(_camera) * transform.rotation;

            // Move the camera.
            _camera.Translate(SpaceNavigator.Translation, Space.Self);
            _camera.LookAt(_LookAtTarget);
        }
        else
        {
            // Perform azimuth in world coordinates.
            _camera.RotateAround(transform.position, Vector3.up, SpaceNavigator.Rotation.Yaw() * Mathf.Rad2Deg);
            // Perform pitch in local coordinates.
            _camera.RotateAround(transform.position, _camera.transform.right, SpaceNavigator.Rotation.Pitch() * Mathf.Rad2Deg);
        }
    }
Ejemplo n.º 2
0
    private void Telekinesis(SceneView sceneView)
    {
        // Store the selection's transforms because the user could have edited them since we last used them via the inspector.
        if (_wasIdle)
        {
            StoreSelectionTransforms();
        }

        foreach (Transform transform in Selection.GetTransforms(SelectionMode.TopLevel | SelectionMode.Editable))
        {
            if (!_unsnappedRotations.ContainsKey(transform))
            {
                continue;
            }

            Transform reference;
            switch (_coordSys)
            {
            case CoordinateSystem.Camera:
                reference = sceneView.camera.transform;
                break;

            case CoordinateSystem.World:
                reference = null;
                break;

            case CoordinateSystem.Parent:
                reference = transform.parent;
                break;

            case CoordinateSystem.Local:
                reference = transform;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            if (reference == null)
            {
                // Move the object in world coordinates.
                _unsnappedTranslations[transform] += SpaceNavigator.Translation;
                _unsnappedRotations[transform]     = SpaceNavigator.Rotation * _unsnappedRotations[transform];
            }
            else
            {
                // Move the object in the reference coordinate system.
                Vector3 worldTranslation = reference.TransformPoint(SpaceNavigator.Translation) -
                                           reference.position;
                _unsnappedTranslations[transform] += worldTranslation;
                _unsnappedRotations[transform]     = SpaceNavigator.RotationInLocalCoordSys(reference) * _unsnappedRotations[transform];
            }

            // Perform rotation with or without snapping.
            transform.rotation = _snapRotation ? SnapRotation(_unsnappedRotations[transform], _snapAngle) : _unsnappedRotations[transform];
            transform.position = _snapTranslation ? SnapTranslation(_unsnappedTranslations[transform], _snapDistance) : _unsnappedTranslations[transform];
        }
    }
Ejemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        //Matriz de rotación
        Matrix4x4 m = Matrix4x4.Rotate(Camera_GameObject_inst.transform.rotation);
        Vector3   v3_nuevaTranslacion = m.MultiplyPoint3x4(SpaceNavigator.Translation);

        //Debug.Log("SN transl=" + v3_nuevaTranslacion);
        gameObject.transform.position += v3_nuevaTranslacion;

        //gameObject.transform.RotateAroundLocal(Vector3.up, )
        //Debug.Log("SN rot=" + SpaceNavigator.RotationInLocalCoordSys(Camera_GameObject_inst.transform).eulerAngles);

        //Camera_GameObject_inst.transform.rotation
        Quaternion delta_rot = SpaceNavigator.RotationInLocalCoordSys(Camera_GameObject_inst.transform);

        gameObject.transform.rotation = delta_rot * gameObject.transform.rotation;

        //Debug.Log("transl mag=" + v3_nuevaTranslacion.magnitude.ToString("0.000000"));
        //Debug.Log("rot mag=" + delta_rot.eulerAngles.magnitude.ToString("0.000000"));
        Debug.Log("Length dientes=" + dientes.Length);

        foreach (GameObject diente_inst in dientes)
        {
            //diente_inst.metaRotAbierto = delta_rot * diente_inst.metaRotAbierto;
            diente_inst.GetComponent <ClawBehaviour>().bMovLock = false;
            if (v3_nuevaTranslacion.magnitude > 0.001 || delta_rot.eulerAngles.magnitude > 0.001)
            {
                diente_inst.GetComponent <ClawBehaviour>().bMovLock = true;
            }
        }

        //Rango de traslación: -0.13 a 0.20
        //Up es Y

        /*Debug.Log(SpaceNavigator.Translation.x.ToString("0.00000") + " | " +
         *        SpaceNavigator.Translation.y.ToString("0.00000") + " |  " +
         *        SpaceNavigator.Translation.z.ToString("0.00000") );*/
    }