Log in or register to post comments

Where is positioning in relation to Image Target Handled

June 29, 2012 - 7:38am #1

As stated in the topic

I have a model showing up which is good. If i look at it from the top then its centered on the image target which is what i want. My problem is that after I change the angle the model moves in a weird way. It shows the model at the angle it is supposed to but it looks like it moves it off of the Image target. For instance i move the phone down so that i can see the model from the front which i do but as i move it down the model slides off of the ImageTarget and more towards me so after a certain point it looks like it off the image target entirely. 

Does the on Tracking found and on Tracking lost function in DefaultTrackableEventHandler handle this or is it some other function deeper in the code.

 

Thanks for all the help that has been provided so far.

Where is positioning in relation to Image Target Handled

June 29, 2012 - 2:31pm #7

Thanks,

I just found out after all this time that the viewing angle thing is not a problem for this project. So thank you very much for all your help.

Where is positioning in relation to Image Target Handled

June 29, 2012 - 2:22pm #6

That looks fine. What you may be seeing is pose distortion at shallow viewing angles. Is this occurring when you approach the plane of the target w/ the camera perpendicular to that plane?

Tracking is most precise within an envelope of viewing angles. If you need to be able to view your model head-on, such that the camera will be close to the plane of the target, I'd suggest using a MultiTarget arranged so that there is a child target facing the camera.

 

Where is positioning in relation to Image Target Handled

June 29, 2012 - 12:40pm #5

It may. Can you post an example of the code you're using to instantiate and position the model? Have you confirmed that these are being parented by their respective ImageTargets.

Where is positioning in relation to Image Target Handled

June 29, 2012 - 11:27am #4

The code below is my own implementation of the trackable events handler.

This is where i instantiate the model and parent it to its ImageTarget. At least I beleive it is where it gets parented because I no longer have any problems when 2 image targets are shown and moving 1 moves both models.

 

    private void OnTrackingFound()

    {

        Renderer[] rendererComponents = GetComponentsInChildren<Renderer>();

        // Enable rendering:

        foreach (Renderer component in rendererComponents) {

            component.enabled = true;

}

Debug.Log("Trackable " + this.mTrackableBehaviour.TrackableName + " found");

if(m3dModel == null)

{

Debug.Log("Trackable Name in Handler = " + this.mTrackableBehaviour.TrackableName );

m3dModel = Instantiate(Resources.Load("Models/" + mTrackableBehaviour.TrackableName, typeof(GameObject))) as GameObject;

m3dModel.renderer.material.mainTexture = (Texture)(Resources.Load("Textures/" + mTrackableBehaviour.TrackableName, typeof(Texture)));

m3dModel.transform.parent = this.transform;

//Must change local scale to be more effective on all items

m3dModel.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);

//Also must change below local position to more reflect its on image target

m3dModel.transform.localPosition = new Vector3(0.0f,0.0f,0.0f);

m3dModel.transform.position = this.transform.position;

m3dModel.transform.Rotate(new Vector3(0.0f,210.0f,0.0f));

m3dModel.renderer.material.shader = Shader.Find("DoubleSided");

m3dModel.renderer.enabled = true;

//Add a collider for touch actions

m3dModel.AddComponent<SphereCollider>();

m3dModel.AddComponent<TouchManager>();

}

else

{

m3dModel.GetComponent<TouchManager>().enabled = true;

m3dModel.GetComponent<SphereCollider>().enabled = true;

m3dModel.renderer.enabled = true;

}

    }

    private void OnTrackingLost()

    {

        Renderer[] rendererComponents = GetComponentsInChildren<Renderer>();

        // Disable rendering:

        foreach (Renderer component in rendererComponents) {

            component.enabled = false;

        }

if(m3dModel != null)

{

m3dModel.renderer.enabled = false;

m3dModel.GetComponent<TouchManager>().enabled = false;

m3dModel.GetComponent<SphereCollider>().enabled = false;

}

        Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " lost");

    }

As you can see the model (m3dModel) is parented using transform.parent = this.transform;

Where is positioning in relation to Image Target Handled

June 29, 2012 - 11:09am #3

I am using Unity 3.5 and programming on Android. Currently I have found the Position Trackable but I cannot see when it is called as the logs do not print out. Also I am instantiating all my models dynamically if that has anything to do with this.

Where is positioning in relation to Image Target Handled

June 29, 2012 - 9:40am #2

Which version of Unity are you using, and which extension version ( iOS or Android )? There's an issue between Unity 3.5.2 and iOS that can cause models to become offset.

To answer your question, the event handlers control rendering but the pose of the model is handled by the ImageTracker for ImageTargets.

Log in or register to post comments