/// <summary>
    /// this function actually moves models on their associated targe using 'MoveModelOnTarget' function.
    /// </summary>
    public void UpdateModelStatus()
    {
        foreach (GameObject model in modelList)
        {
            NCARModelInfo modelInfo = model.GetComponent <NCARModelInfo>();

            //if the model is combined to any other targets then its default target
            if (modelInfo.isModelCombined == true)
            {
                //and if the target has been changed
                if (modelInfo.previousTarget != modelInfo.currentTarget)
                {
                    //need this to exclude context model.
                    if (modelInfo.GetComponent <NCARTouchController>() != null)
                    {
                        modelInfo.GetComponent <NCARTouchController>().ResetAnimation();
                    }
                    MoveModelOnTarget(modelInfo, modelInfo.currentTarget);
                }
            }

            //if model is not combined to any other target
            else if (modelInfo.isModelCombined == false)
            {
                //and if the model does have the default target && target has been changed.
                if (modelInfo.defaultTarget != null && modelInfo.defaultTarget != modelInfo.currentTarget)
                {
                    //Move the model on its default taret
                    MoveModelOnTarget(modelInfo, model.GetComponent <NCARModelInfo>().defaultTarget);
                }

                // and if the model does not have the default target associated && target has been changed.
                if (modelInfo.defaultTarget == null && modelInfo.defaultTarget != modelInfo.currentTarget)
                {
                    model.transform.SetParent(goModelList.transform);
                    modelInfo.resetPosToDefault();
                }
                // set the target to its default
                modelInfo.currentTarget = modelInfo.defaultTarget;
            }

            if (modelInfo.currentTarget != null && modelInfo.currentTarget.GetComponent <NCARTrackableEventHandler>().IsTracked != true)
            {
                modelInfo.HideModel();
            }

            //set the preious target to the current one.
            modelInfo.previousTarget = modelInfo.currentTarget;
            //reset the combination target to false;
            model.GetComponent <NCARModelInfo>().isModelCombined = false;
        }
    }
    // this function calcuates the initial position of the model in relation to the target's local space.
    // it assuems that the target's transform is in world coordination.
    public Vector3 CalcInitialLocalPosOfModelToTarget(NCARModelInfo modelInfo, global::NCARTargetInfo targetInfo)
    {
        //this part is inverse of local to global (inverse function of TransformPoint)
        Quaternion rotTargetInit   = targetInfo.rotTargetInit;
        Vector3    scaleTargetInit = targetInfo.scaleTargetInit;
        Vector3    posTargetInit   = targetInfo.posTargetInit;
        Vector3    posModelInit    = modelInfo.posInit;

        Vector3 t = Quaternion.Inverse(rotTargetInit) * (posModelInit - posTargetInit);

        t = Vector3.Scale(new Vector3(1 / scaleTargetInit.x, 1 / scaleTargetInit.y, 1 / scaleTargetInit.z), t);
        return(t);
    }
    //based on the function above, this function moves the model onto the target setting it as the model's parent
    public void MoveModelOnTarget(NCARModelInfo modelInfo, global::NCARTargetInfo targetInfo)
    {
        Transform modelTransfrom = modelInfo.transform;
        Vector3   initLocal      = CalcInitialLocalPosOfModelToTarget(modelInfo, targetInfo);

        modelTransfrom.position = targetInfo.transform.TransformPoint(initLocal);
        modelTransfrom.rotation = (modelInfo.rotInit * targetInfo.transform.rotation) * Quaternion.Inverse(targetInfo.rotTargetInit);

        modelTransfrom.SetParent(targetInfo.transform);

        if (modelInfo.GetComponent <NCARTouchController>() != null)
        {
            modelInfo.GetComponent <NCARTouchController>().setInitialLocalPosition();
        }

        modelInfo.currentTarget = targetInfo;

        //show model in case it was hidden;
        modelInfo.ShowModel();
    }
 /// <summary>
 /// This function changes the current target of ModelInfo Class and set a flag to see if the model is combined to any other targets other than its default target
 /// </summary>
 /// <param name="modelInfo">Model info.</param>
 /// <param name="targetInfo">Target info.</param>
 public void ChangeModelTarget(NCARModelInfo modelInfo, NCARTargetInfo targetInfo)
 {
     modelInfo.currentTarget   = targetInfo;
     modelInfo.isModelCombined = true;
 }