Log in or register to post comments

Keep 3d Object

October 29, 2013 - 7:17am #1
I am creating a scene with five target, one child each one. When you start the scene and the target is lost, some instruccions about AR appear. When the target is found, instructions dissapear, and  the object is shown. 
The problem is that my objects are too big and the target is lost too fast, so I need keep the objects too when the marker.
 
I have tried solve with these scripts, I have achieved that instructions only be shown when scene commence. When the marker found the target and lost it again don't be present again, but objects don't display.
 
What can I do?? These are script I have used 
 
Sorry for my english

The fist Script

 
private TrackableBehaviour mTrackableBehaviour;
private EventosMarcador eventosMarcador;
    
    void Start()
    {
eventosMarcador=
ControladorDelJuego.ObtenerComponente<EventosMarcador>("ControladorDelJuego");
        mTrackableBehaviour = GetComponent<TrackableBehaviour>();
        if (mTrackableBehaviour)
        {
            mTrackableBehaviour.RegisterTrackableEventHandler(this);
        }
OnTrackingLost();
    }
 
  public void OnTrackableStateChanged(
                                    TrackableBehaviour.Status previousStatus,
                                    TrackableBehaviour.Status newStatus)
    {
        if (newStatus == TrackableBehaviour.Status.DETECTED ||
            newStatus == TrackableBehaviour.Status.TRACKED)
        {
            OnTrackingFound();
eventosMarcador.MarcadorEncontrado();
        }
        else
        {
            OnTrackingLost();
eventosMarcador.MarcadorPerdido();
        }
    }
 
    private void OnTrackingFound()
    { 
        Renderer[] rendererComponents = GetComponentsInChildren<Renderer>(true);
        Collider[] colliderComponents = GetComponentsInChildren<Collider>(true);
 
        foreach (Renderer component in rendererComponents)
        { component.enabled = true;}
      foreach (Collider component in colliderComponents)
        { component.enabled = true; }
        Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " found");
    }
 
 
    private void OnTrackingLost()
    {
        Renderer[] rendererComponents = GetComponentsInChildren<Renderer>(true);
        Collider[] colliderComponents = GetComponentsInChildren<Collider>(true);
 
        foreach (Renderer component in rendererComponents)
        { component.enabled = false;}
 
        foreach (Collider component in colliderComponents)
        {component.enabled = false; }
        Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " lost");
    }
}
 
 

The secondScript,

In my opinion, the problem is where I have written in red, I have to access to the child of the target since a script component that isn't place in the target.

public class EventosMarcador : MonoBehaviour {
 
 
public GUITexture notificacion;
public GameObject hijo;
private bool detener;
public TrackableBehaviour theTrackable;
 
void Start ()
 
 
void Update () 
{
if(detener&& Time.frameCount >= 2) {
Time.timeScale = 0f;
}
if(Input.GetKeyDown( KeyCode.Q)){
MarcadorPerdido( );
}else if (Input.GetKeyDown( KeyCode.W)){
MarcadorEncontrado();
}
}
public void MarcadorEncontrado() 
{
if(notificacion != null){
notificacion.enabled = false;
}
 
Time.timeScale = 1f;
detener=false;
}
 
public void MarcadorPerdido () {
if(notificacion != null){
if (Time.timeScale==0f)
{notificacion.enabled = true;}
else{
GameObject trackableGameObject = theTrackable.gameObject;
                   Transform child = trackableGameObject.transform.GetChild(0);
          child.gameObject.active = true;              
        }}
}
}
 
 
 

Keep 3d Object

March 12, 2017 - 9:15am #8

can u please share the script

Keep 3d Object

October 30, 2013 - 6:01am #7

I have read some about including this lines in otrher post, but I dont know how.

if ( m_PoseType == PoseType.Camera) 

camera.transform.localPosition = m_CamOutOfScenePosition;

Please help, I need to solve this problem soon...

 

Keep 3d Object

October 29, 2013 - 4:04pm #6

Is a big model, the target is fixed on the floor, and  the user moves the mobile to see the complete  model so lost the target, I would like the model returns to position A, the original one

Keep 3d Object

October 29, 2013 - 3:55pm #5

So let's say that the target is originally recognized at position A and moves through the camera's field of view to position B, after which it moves outside of the camera image and detection is lost. Do you want the model to return to position A, or stay at position B which would be at the edge of the screen.

Keep 3d Object

October 29, 2013 - 3:11pm #4
I want the model is in the original position in the destination in spite of the target isn't there.
This script is used for many scenes that's why I used some some variable to specify the model.

I don't know really well how to do what you explain

Keep 3d Object

October 29, 2013 - 3:11pm #3
I want the model is in the original position in the destination in spite of the target isn't there.
This script is used for many scenes that's why I used some some variable to specify the model.

I don't know really well how to do what you explain

Keep 3d Object

October 29, 2013 - 2:40pm #2

What is the position you want the model to be positioned at?

You may need to reassign the transform.parent of the model to the .transform of the ARCamera in order to make the model a child of the camera, and position it in the camera's local space. This will enable you to keep the model in a constant position in the camera view.

Log in or register to post comments