如何使用vuforia触摸360度旋转3D AR对象?

时间:2015-09-18 11:18:23

标签: unity3d augmented-reality vuforia

您好我在Unity中使用vuforia sdk ..我有一个AR Object。如何通过触摸旋转对象360度(旋转所有边)? 。到目前为止,我可以使用以下代码左右旋转..

谢谢!

using UnityEngine;
using System.Collections;

public class Rotate : MonoBehaviour {
    public Bounds bounds;
    public float speed = 1.0F;
    // Use this for initialization
    void Start () {
        var collider = gameObject.GetComponent<BoxCollider> ();
        if (collider == null) {
            collider = gameObject.AddComponent<BoxCollider>();
            Debug.Log("No Collider is Detected");
        }
        bounds = collider.bounds;

    }

    // Update is called once per frame
    void Update () {

        if(Input.GetMouseButton(0)){
            if(bounds.size.magnitude > 0){
                var dtx = Input.GetAxis("Mouse X")*speed;
                var dty = Input.GetAxis("Mouse Y")*speed;
                var pivot = bounds.center;

                transform.RotateAround(pivot,Vector3.up,dtx);
                transform.RotateAround(pivot,Vector3.left,dty);
                transform.Rotate(Vector3.up * Time.deltaTime * speed);
            }
        }
    }
}

0 个答案:

没有答案