Log in or register to post comments

3D Objects Always There

March 17, 2012 - 11:28am #1

I've tried this twice on two different Unity projects so far. The first worked perfectly. The second one does not work. My 3D objects are always visible, as opposed to showing only when the target is being tracked. It appears the target is never found, since the 3D objects never change their orientations relative to the target.

I've followed the Compiling a Simple Project instructions several times now, and all settings and all files are identical in project that works and the one that doesn't work. I'm using one of the sample targets. What can cause this behavior?

Re: 3D Objects Always There

March 18, 2012 - 12:18pm #8

So does the model appear and then disappear before a target is detected? I'm wondering if this relates to the initialization of your app.

You can also try unchecking the Mesh Renderer on your model. It will be enabled at runtime when the target is detected.

Re: 3D Objects Always There

March 18, 2012 - 8:42am #7

I deleted everything and started over from scratch (i.e., the original project). Now it works, sort of.

It starts out with the 3D objects visible and only turns them on and off AFTER the target is acquired the first time. After that, it works. I think this at least part of the problem, as the other project starts with the object invisible and only shows them when the target is acquired. I have no idea why before it never acquired the target. At least I'm getting closer.

Re: 3D Objects Always There

March 17, 2012 - 7:23pm #6

Not sure why I assumed that you were building for Android - Eclipse is for Android.

For the iPad you can use the XCode console ( View > Debug Area > Activate Console ). Run the project from XCode, or using Build & Run from Unity, and debug messages from the attached device will be displayed in the XCode Console window.

The relevant script is DefaultTrackableEventHandler.cs which is attached to each ImageTarget.

Here is the code..

    private void OnTrackingFound()
    {
        Renderer[] rendererComponents = GetComponentsInChildren<Renderer>();

        // Enable rendering:
        foreach (Renderer component in rendererComponents) {
            component.enabled = true;
        }

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


    private void OnTrackingLost()
    {
        Renderer[] rendererComponents = GetComponentsInChildren<Renderer>();

        // Disable rendering:
        foreach (Renderer component in rendererComponents) {
            component.enabled = false;
        }

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

You can see that this is simply iterating through the Renderer components of the Trackable's child objects and enabling them.

* if you're using multiple targets in a scene, you have to configure the ImageTargetBehaviour of each one.

A screen shot of your expanded project Hierarchy would be helpful.

Re: 3D Objects Always There

March 17, 2012 - 6:57pm #5
DavidBeard wrote:

Those settings shouldn't produce the behavior that you're seeing. Though for debugging purposes, it would be a good idea to work w/ a standard configuration (e.g. Perspective Projection ) so as not to introduce new variables.

Which version of the Unity Extension SDK are you using?

And what messages are you seeing in your Eclipse DDMS Console? You'll see Trackable [ name ] found / lost when the tracking state changes.

I'm using 1.5.9.

I don't know what the Eclipse DDMS Console is. I see those messages in the Unity console about the trackable being found when run in Unity. I was looking for a way to show that info when running on iPad, but couldn't find anything like that. I couldn't even find the script generating those messages when running in Unity.

Re: 3D Objects Always There

March 17, 2012 - 4:49pm #4

Those settings shouldn't produce the behavior that you're seeing. Though for debugging purposes, it would be a good idea to work w/ a standard configuration (e.g. Perspective Projection ) so as not to introduce new variables.

Which version of the Unity Extension SDK are you using?

And what messages are you seeing in your Eclipse DDMS Console? You'll see Trackable [ name ] found / lost when the tracking state changes.

Re: 3D Objects Always There

March 17, 2012 - 4:00pm #3
DavidBeard wrote:

Make sure that you 3D models are child objects of the target (i.e. they are added to the target in the Hierarchy). Also confirm that both your ARCamera and ImageTargets are set-up to use the correct trackables dataset.

All of those things are set up correctly.

Are there any camera settings that might affect this problem? I've changed some settings, including near/far clipping planes, orthographic projection, depth. I've not yet gone back and tried every possible combination of settings. Are there any camera settings I should not change from the prefab settings?

Re: 3D Objects Always There

March 17, 2012 - 11:50am #2

Make sure that you 3D models are child objects of the target (i.e. they are added to the target in the Hierarchy). Also confirm that both your ARCamera and ImageTargets are set-up to use the correct trackables dataset.

Log in or register to post comments