Exemplo n.º 1
0
    void IEditorImageTargetBehaviour.InitializeImageTarget(ImageTarget imageTarget)
    {
        mTrackable = mImageTarget = imageTarget;
        mVirtualButtonBehaviours = new Dictionary <int, VirtualButtonBehaviour>();

        // do not change the aspect ratio of user defined targets, these are set by the algorithm internally
        if (imageTarget.ImageTargetType == ImageTargetType.PREDEFINED)
        {
            // Handle any changes to the image target in the scene
            // that are not reflected in the config file
            Vector2 imgTargetUnitySize = GetSize();

            imageTarget.SetSize(imgTargetUnitySize);
        }
        else // instead, set the aspect of the unity object to the value of the user defined target
        {
            Vector2 udtSize = imageTarget.GetSize();

            // set the size of the target to the value returned from cloud reco:
            transform.localScale =
                new Vector3(udtSize.x,
                            udtSize.x,
                            udtSize.x);

            IEditorImageTargetBehaviour editorThis = this;
            editorThis.CorrectScale();

            editorThis.SetAspectRatio(udtSize.y / udtSize.x);
        }
    }
Exemplo n.º 2
0
    private ImageTargetAbstractBehaviour CreateImageTargetBehaviour(ImageTarget imageTarget)
    {
        GameObject gameObject = new GameObject();
        ImageTargetAbstractBehaviour behaviour  = BehaviourComponentFactory.Instance.AddImageTargetBehaviour(gameObject);
        IEditorImageTargetBehaviour  behaviour2 = behaviour;

        Debug.Log(string.Concat(new object[] { "Creating Image Target with values: \n ID:           ", imageTarget.ID, "\n Name:         ", imageTarget.Name, "\n Path:         ", behaviour2.DataSetPath, "\n Size:         ", imageTarget.GetSize().x, "x", imageTarget.GetSize().y }));
        behaviour2.SetNameForTrackable(imageTarget.Name);
        behaviour2.SetDataSetPath(behaviour2.DataSetPath);
        Vector2 size = imageTarget.GetSize();
        float   x    = Mathf.Max(size.x, size.y);

        behaviour2.transform.localScale = new Vector3(x, x, x);
        behaviour2.CorrectScale();
        behaviour2.SetAspectRatio(size.y / size.x);
        behaviour2.InitializeImageTarget(imageTarget);
        return(behaviour);
    }
Exemplo n.º 3
0
    private ImageTargetBehaviour CreateImageTargetBehaviour(ImageTarget imageTarget)
    {
        GameObject           imageTargetObject = new GameObject();
        ImageTargetBehaviour newITB            =
            imageTargetObject.AddComponent <ImageTargetBehaviour>();

        IEditorImageTargetBehaviour newEditorITB = newITB;

        Debug.Log("Creating Image Target with values: " +
                  "\n ID:           " + imageTarget.ID +
                  "\n Name:         " + imageTarget.Name +
                  "\n Path:         " + newEditorITB.DataSetPath +
                  "\n Size:         " + imageTarget.GetSize().x + "x" + imageTarget.GetSize().y);

        // Set Image Target attributes.
        newEditorITB.SetNameForTrackable(imageTarget.Name);
        newEditorITB.SetDataSetPath(newEditorITB.DataSetPath);
        newEditorITB.transform.localScale = new Vector3(imageTarget.GetSize().x, 1.0f, imageTarget.GetSize().y);
        newEditorITB.CorrectScale();
        newEditorITB.SetAspectRatio(imageTarget.GetSize()[1] / imageTarget.GetSize()[0]);
        newEditorITB.InitializeImageTarget(imageTarget);

        return(newITB);
    }
Exemplo n.º 4
0
 // Recalculates the aspect ratio of the Image Target from a size vector.
 // Automatically updates mesh as well.
 public static void UpdateAspectRatio(IEditorImageTargetBehaviour it, Vector2 size)
 {
     it.SetAspectRatio(size[1] / size[0]);
     UpdateMesh(it);
 }
Exemplo n.º 5
0
 // Recalculates the aspect ratio of the Image Target from a size vector.
 // Automatically updates mesh as well.
 public static void UpdateAspectRatio(IEditorImageTargetBehaviour it, Vector2 size)
 {
     it.SetAspectRatio(size[1] / size[0]);
     UpdateMesh(it);
 }