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); } }
public void Awake() { SpaceNavigator.SetTranslationSensitivity(1); SpaceNavigator.SetRotationSensitivity(1); dientes = GameObject.FindGameObjectsWithTag("SingleClaw"); }
public void Awake() { SpaceNavigator.SetTranslationSensitivity(1); SpaceNavigator.SetRotationSensitivity(1); _camera = Camera.main.transform; _LookAtTarget = GameObject.FindGameObjectWithTag("Torus look at target").transform; }
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]; } }
// 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") );*/ }
void myMouse_MotionEvent(object sender, SpaceNavigator._3DxMouse.MotionEventArgs e) { if (e.TranslationVector != null) { // Swap axes from HID orientation to a right handed coordinate system that matches WPF model space SensorTranslation.X = e.TranslationVector.X; SensorTranslation.Y = -e.TranslationVector.Z; SensorTranslation.Z = e.TranslationVector.Y; } // Rotation Vector? if (e.RotationVector != null) { // Swap axes from HID orientation to a right handed coordinate system that matches WPF model space SensorRotation.X = e.RotationVector.X; SensorRotation.Y = -e.RotationVector.Z; SensorRotation.Z = e.RotationVector.Y; } }
void myMouse_ButtonEvent(object sender, SpaceNavigator._3DxMouse.ButtonEventArgs e) { CameraParameters cameraParams; if ((e.ButtonMask.Pressed & 1) == 1) { CameraRotateTarget = 0; } if ((e.ButtonMask.Pressed & 2) == 2) { cameraParams = new CameraParameters(0, 0, 360, 0, 0, 100); this.GotoTarget(cameraParams, false, false); } }