Exemplo n.º 1
0
    void runAnimation(String AnimationName)
    {
        switch (SelectObject.combinationName)
        {
        case "Screw_Nut_Interaction":
            break;

        case "Gear":
            break;

        case "Belt and Pulley":
            Functions_BeltandPulley CustomFunctions = new Functions_BeltandPulley();
            CustomFunctions = JsonUtility.FromJson <Functions_BeltandPulley>(info);
            Function_BeltandPulley CustomFunction = new Function_BeltandPulley();
            for (int i = 0; i < CustomFunctions.functions.Count; i++)
            {
                if ((CustomFunctions.functions[i].combination_name == "Belt and Pulley") && (CustomFunctions.functions[i].Animation_name == AnimationName))
                {
                    CustomFunction = CustomFunctions.functions[i];
                    SelectObject.runAnimation_BeltandPulley(int.Parse(CustomFunction.big_pulley_speed));
                }
            }
            break;

        case "Transmission":
            break;
        }
    }
Exemplo n.º 2
0
    /*public void onDropdownCilck ()
     * {
     *  save.enabled = true;
     *  save.image.color = Color.green;
     *  functionName = functionDropdown.options[functionDropdown.value].text;
     *  funcEnable = false;
     *  switch (SelectObject.combinationName)
     *  {
     *      case "Screw_Nut_Interaction":
     *          switch (functionName)
     *          {
     *              case "Choose Function":
     *                  value.gameObject.SetActive(false);
     *                  break;
     *              case "targetNormal":
     *                  functionNumber = 3;
     *                  funcEnable = true;
     *                  CustomFunction_Screw_Nut_Interaction.targetNormal = "";
     *                  value.gameObject.SetActive(false);
     *                  break;
     *              case "startpt":
     *                  functionNumber = 0;
     *                  funcEnable = true;
     *                  CustomFunction_Screw_Nut_Interaction.startpt = "";
     *                  value.gameObject.SetActive(false);
     *                  break;
     *              case "endpt":
     *                  functionNumber = 1;
     *                  funcEnable = true;
     *                  CustomFunction_Screw_Nut_Interaction.endpt = "";
     *                  value.gameObject.SetActive(false);
     *                  break;
     *              case "contactpt":
     *                  functionNumber = 2;
     *                  funcEnable = true;
     *                  CustomFunction_Screw_Nut_Interaction.contactpt = "";
     *                  value.gameObject.SetActive(false);
     *                  break;
     *              case "speed":
     *                  value.gameObject.SetActive(true);
     *                  value.enabled = true;
     *                  value.text = default;
     *                  break;
     *          }
     *          break;
     *      case "Gear":
     *          switch (functionName)
     *          {
     *              case "Choose Function":
     *                  value.gameObject.SetActive(false);
     *                  break;
     *              case "gearAngle":
     *                  functionNumber = 0;
     *                  funcEnable = true;
     *                  CustomFunction_Gear.gearAngle = "";
     *                  value.gameObject.SetActive(false);
     *                  break;
     *              case "surfaceNormal":
     *                  functionNumber = 1;
     *                  funcEnable = true;
     *                  CustomFunction_Gear.surfaceNormal = "";
     *                  value.gameObject.SetActive(false);
     *                  break;
     *              case "speed":
     *                  value.gameObject.SetActive(true);
     *                  value.enabled = true;
     *                  value.text = default;
     *                  break;
     *          }
     *          break;
     *      case "Belt and Pulley":
     *          switch (functionName)
     *          {
     *              case "Choose Function":
     *                  value.gameObject.SetActive(false);
     *                  break;
     *              case "big_pulley_radius":
     *                  functionNumber = 0;
     *                  funcEnable = true;
     *                  value.gameObject.SetActive(false);
     *                  break;
     *              case "small_pulley_radius":
     *                  functionNumber = 1;
     *                  funcEnable = true;
     *                  value.gameObject.SetActive(false);
     *                  break;
     *              case "surfaceNormal":
     *                  functionNumber = 2;
     *                  funcEnable = true;
     *                  value.gameObject.SetActive(false);
     *                  break;
     *              case "big_pulley_speed":
     *                  value.gameObject.SetActive(true);
     *                  value.enabled = true;
     *                  value.text = default;
     *                  break;
     *          }
     *          break;
     *  }
     * }*/

    /*public void onChangeValue()
     * {
     *  if (EventSystem.current.currentSelectedGameObject.name == "Animation")
     *  {
     *      animation.enabled = false;
     *      switch (SelectObject.combinationName)
     *      {
     *          case "Screw_Nut_Interaction":
     *              CustomFunction_Screw_Nut_Interaction.combination_name = SelectObject.combinationName;
     *              CustomFunction_Screw_Nut_Interaction.Animation_name = animation.text;
     *              break;
     *          case "Gear":
     *              CustomFunction_Gear.combination_name = SelectObject.combinationName;
     *              CustomFunction_Gear.Animation_name = animation.text;
     *              break;
     *          case "Belt and Pulley":
     *              CustomFunction_BeltandPulley.combination_name = SelectObject.combinationName;
     *              CustomFunction_BeltandPulley.Animation_name = animation.text;
     *              break;
     *      }
     *  }
     *  else if (EventSystem.current.currentSelectedGameObject.name == "Value")
     *  {
     *      switch (SelectObject.combinationName)
     *      {
     *          case "Screw_Nut_Interaction":
     *              switch (functionName)
     *              {
     *                  case "speed":
     *                      CustomFunction_Screw_Nut_Interaction.speed = value.text;
     *                      break;
     *              }
     *              break;
     *          case "Gear":
     *              switch (functionName)
     *              {
     *                  case "speed":
     *                      CustomFunction_Gear.speed = value.text;
     *                      break;
     *              }
     *              break;
     *          case "Belt and Pulley":
     *              switch (functionName)
     *              {
     *                  case "big_pulley_speed":
     *                      CustomFunction_BeltandPulley.big_pulley_speed = value.text;
     *                      break;
     *              }
     *              break;
     *      }
     *  }
     * }*/

    public void saveFunctions()
    {
        var path     = "C:\\Users\\anany\\OneDrive\\Documents\\CGS_Final_Project\\CGS_Final_Project\\Assets\\Resources\\";
        var fileName = "";

        switch (SelectObject.combinationName)
        {
        case "Screw_Nut_Interaction":
            fileName = textAsset_Screw_Nut_Interaction.name + ".txt";
            info     = textAsset_Screw_Nut_Interaction.text;
            Functions_Screw_Nut_Interaction CustomFunctions_Screw_Nut_Interaction = new Functions_Screw_Nut_Interaction();
            CustomFunctions_Screw_Nut_Interaction = JsonUtility.FromJson <Functions_Screw_Nut_Interaction>(info);
            Debug.Log(CustomFunctions_Screw_Nut_Interaction.functions.Count);
            CustomFunctions_Screw_Nut_Interaction.functions.Add(CustomFunction_Screw_Nut_Interaction);
            info = JsonUtility.ToJson(CustomFunctions_Screw_Nut_Interaction);
            break;

        case "Gear":
            fileName = textAsset_Gear.name + ".txt";
            info     = textAsset_Gear.text;
            Functions_Gear CustomFunctions_Gear = new Functions_Gear();
            CustomFunctions_Gear = JsonUtility.FromJson <Functions_Gear>(info);
            Debug.Log(CustomFunctions_Gear.functions.Count);
            CustomFunctions_Gear.functions.Add(CustomFunction_Gear);
            info = JsonUtility.ToJson(CustomFunctions_Gear);
            break;

        case "Belt and Pulley":
            fileName = textAsset_BeltandPulley.name + ".txt";
            info     = textAsset_BeltandPulley.text;
            Functions_BeltandPulley CustomFunctions_BeltandPulley = new Functions_BeltandPulley();
            CustomFunctions_BeltandPulley = JsonUtility.FromJson <Functions_BeltandPulley>(info);
            Debug.Log(CustomFunctions_BeltandPulley.functions.Count);
            CustomFunctions_BeltandPulley.functions.Add(CustomFunction_BeltandPulley);
            info = JsonUtility.ToJson(CustomFunctions_BeltandPulley);
            break;

        case "Transmission":
            fileName = textAsset_Transmission.name + ".txt";
            info     = textAsset_Transmission.text;
            Functions_Transmission CustomFunctions_Transmission = new Functions_Transmission();
            CustomFunctions_Transmission = JsonUtility.FromJson <Functions_Transmission>(info);
            Debug.Log(CustomFunctions_Transmission.functions.Count);
            CustomFunctions_Transmission.functions.Add(CustomFunction_Transmission);
            info = JsonUtility.ToJson(CustomFunctions_Transmission);
            break;
        }
        try
        {
            Debug.Log(path + fileName);
            System.IO.File.WriteAllText(path + fileName, info);
        }
        catch (System.Exception exception)
        {
            string ErrorMessages = "File Write Error\n" + exception.Message;
            Debug.LogError(ErrorMessages);
        }
    }
    // Imports animation rules from AnimationRule class (or from text file containing AnimationRule info)
    // Sets animeReady flag indicating animation ready to play in Update()
    //[ExposeInEditor(RuntimeOnly = false)]
    public void ImportRule()
    {
        var fileName = "";

        switch (SelectObject.combinationName)
        {
        case "Screw_Nut_Interaction":
            fileName = textAsset_Screw_Nut_Interaction.name + ".txt";
            info     = textAsset_Screw_Nut_Interaction.text;
            Functions_Screw_Nut_Interaction CustomFunctions_Screw_Nut_Interaction = new Functions_Screw_Nut_Interaction();
            CustomFunctions_Screw_Nut_Interaction = JsonUtility.FromJson <Functions_Screw_Nut_Interaction>(info);
            for (int i = 0; i < CustomFunctions_Screw_Nut_Interaction.functions.Count; i++)
            {
                if ((CustomFunctions_Screw_Nut_Interaction.functions[i].combination_name == SelectObject.combinationName) && (CustomFunctions_Screw_Nut_Interaction.functions[i].Animation_name == SaveFunction_BeltandPulley.animationName))
                {
                    CustomFunction_Screw_Nut_Interaction = CustomFunctions_Screw_Nut_Interaction.functions[i];
                }
            }

            rule = new AnimationRule(highlighter.animationRule.objNames);
            //Create markers
            rule.sourceRotation = StringToQuaternion(CustomFunction_Screw_Nut_Interaction.sourceRotation);
            rule.sourceNormal   = StringToVector3(CustomFunction_Screw_Nut_Interaction.sourceNormal);
            rule.targetCentroid = StringToVector3(CustomFunction_Screw_Nut_Interaction.targetCentroid);
            rule.targetNormal   = StringToVector3(CustomFunction_Screw_Nut_Interaction.targetNormal);
            rule.sourcePosition = StringToVector3(CustomFunction_Screw_Nut_Interaction.sourcePosition);
            rule.startpt        = StringToVector3(CustomFunction_Screw_Nut_Interaction.startpt);
            rule.endpt          = StringToVector3(CustomFunction_Screw_Nut_Interaction.endpt);
            rule.contactpt      = StringToVector3(CustomFunction_Screw_Nut_Interaction.contactpt);

            GameObject sourceObj = GameObject.Find("Screw");
            GameObject targetObj = GameObject.Find("Nut");
            marker_start                  = Instantiate(marker, transform.TransformPoint(rule.startpt), Quaternion.identity);
            marker_start.name             = "start";
            marker_end                    = Instantiate(marker, transform.TransformPoint(rule.endpt), Quaternion.identity);
            marker_end.name               = "end";
            marker_start.transform.parent = sourceObj.transform;
            marker_end.transform.parent   = sourceObj.transform;

            marker_contact = Instantiate(marker, targetObj.transform.TransformPoint(rule.contactpt), Quaternion.identity);

            marker_contact.name             = "contact";
            marker_contact.transform.parent = targetObj.transform;
            AlignObjectsNoviceClick();

            if (SaveFunction_BeltandPulley.animationRun == true)
            {
                animeReady = true;
            }
            else
            {
                animeReady = false;
            }
            break;

        case "Gear":
            fileName = textAsset_Gear.name + ".txt";
            info     = textAsset_Gear.text;
            Functions_Gear CustomFunctions_Gear = new Functions_Gear();
            CustomFunctions_Gear = JsonUtility.FromJson <Functions_Gear>(info);
            for (int i = 0; i < CustomFunctions_Gear.functions.Count; i++)
            {
                if ((CustomFunctions_Gear.functions[i].combination_name == SelectObject.combinationName) && (CustomFunctions_Gear.functions[i].Animation_name == SaveFunction_BeltandPulley.animationName))
                {
                    CustomFunction_Gear = CustomFunctions_Gear.functions[i];
                }
            }

            rule              = new AnimationRule();
            rule.gearAngle    = float.Parse(CustomFunction_Gear.speed);
            rule.targetNormal = StringToVector3(CustomFunction_Gear.surfaceNormal);
            Transform[] gears = GameObject.Find("Gear").GetComponentsInChildren <Transform>();
            if (SaveFunction_BeltandPulley.animationRun == true)
            {
                animeReady = true;
                GearSetup(rule.targetNormal, rule.gearAngle, gears);
            }
            else
            {
                animeReady = false;
                GearSetup(rule.targetNormal, rule.gearAngle, gears);
            }
            break;

        case "Belt and Pulley":
            fileName = textAsset_BeltandPulley.name + ".txt";
            info     = textAsset_BeltandPulley.text;
            Functions_BeltandPulley CustomFunctions_BeltandPulley = new Functions_BeltandPulley();
            CustomFunctions_BeltandPulley = JsonUtility.FromJson <Functions_BeltandPulley>(info);
            for (int i = 0; i < CustomFunctions_BeltandPulley.functions.Count; i++)
            {
                if ((CustomFunctions_BeltandPulley.functions[i].combination_name == SelectObject.combinationName) && (CustomFunctions_BeltandPulley.functions[i].Animation_name == SaveFunction_BeltandPulley.animationName))
                {
                    CustomFunction_BeltandPulley = CustomFunctions_BeltandPulley.functions[i];
                }
            }
            rule_BeltandPulley = new AnimationRule_BeltandPulley(highlighter.animationRule_BeltandPulley.objNames);
            //Create markers
            rule_BeltandPulley.surfaceNormal = StringToVector3(CustomFunction_BeltandPulley.surfaceNormal);
            if (SaveFunction_BeltandPulley.animationRun == true)
            {
                animeReady = true;
            }
            else
            {
                animeReady = false;
            }
            break;
        }
    }
Exemplo n.º 4
0
    void PopulateDropdown(Dropdown dropdown)
    {
        options.Clear();
        if (dropdown.name == "FunctionDropdown")
        {
            String[] optionsArray = new String[] { };
            switch (SelectObject.combinationName)
            {
            case "Screw_Nut_Interaction":
                optionsArray = new String[] { "targetNormal", "startpt", "endpt", "contactpt", "speed" };
                break;

            case "Gear":
                optionsArray = new String[] { "gearAngle", "surfaceNormal", "speed" };
                break;

            case "Belt and Pulley":
                optionsArray = new String[] { "big_pulley_radius", "small_pulley_radius", "surfaceNormal", "big_pulley_speed" };
                break;

            case "Transmission":
                optionsArray = new String[] { "targetNormal", "startpt", "endpt", "contactpts", "speed1", "gearAngle", "surfaceNormal", "speed2", "big_pulley_radius", "small_pulley_radius" };
                break;
            }
            options.Add("Choose Function");
            foreach (var option in optionsArray)
            {
                options.Add(option); // Or whatever you want for a label
            }
        }
        else if (dropdown.name == "AnimationDropdown")
        {
            options.Add("Choose Animation");
            var path     = "C:\\Users\\anany\\OneDrive\\Documents\\CGS_Final_Project\\CGS_Final_Project\\Assets\\Resources\\";
            var fileName = "";
            switch (SelectObject.combinationName)
            {
            case "Screw_Nut_Interaction":
                fileName = textAsset_Screw_Nut_Interaction.name + ".txt";
                info     = textAsset_Screw_Nut_Interaction.text;
                Functions_Screw_Nut_Interaction CustomFunctions_Screw_Nut_Interaction = new Functions_Screw_Nut_Interaction();
                CustomFunctions_Screw_Nut_Interaction = JsonUtility.FromJson <Functions_Screw_Nut_Interaction>(info);
                for (int i = 0; i < CustomFunctions_Screw_Nut_Interaction.functions.Count; i++)
                {
                    if (CustomFunctions_Screw_Nut_Interaction.functions[i].combination_name == SelectObject.combinationName)
                    {
                        options.Add(CustomFunctions_Screw_Nut_Interaction.functions[i].Animation_name);
                    }
                }
                break;

            case "Gear":
                fileName = textAsset_Gear.name + ".txt";
                info     = textAsset_Gear.text;
                Functions_Gear CustomFunctions_Gear = new Functions_Gear();
                CustomFunctions_Gear = JsonUtility.FromJson <Functions_Gear>(info);
                for (int i = 0; i < CustomFunctions_Gear.functions.Count; i++)
                {
                    if (CustomFunctions_Gear.functions[i].combination_name == SelectObject.combinationName)
                    {
                        options.Add(CustomFunctions_Gear.functions[i].Animation_name);
                    }
                }
                break;

            case "Belt and Pulley":
                fileName = textAsset_BeltandPulley.name + ".txt";
                info     = textAsset_BeltandPulley.text;
                Functions_BeltandPulley CustomFunctions_BeltandPulley = new Functions_BeltandPulley();
                CustomFunctions_BeltandPulley = JsonUtility.FromJson <Functions_BeltandPulley>(info);
                for (int i = 0; i < CustomFunctions_BeltandPulley.functions.Count; i++)
                {
                    if (CustomFunctions_BeltandPulley.functions[i].combination_name == SelectObject.combinationName)
                    {
                        options.Add(CustomFunctions_BeltandPulley.functions[i].Animation_name);
                    }
                }
                break;

            case "Transmission":
                fileName = textAsset_Transmission.name + ".txt";
                info     = textAsset_Transmission.text;
                Functions_Transmission CustomFunctions_Transmission = new Functions_Transmission();
                CustomFunctions_Transmission = JsonUtility.FromJson <Functions_Transmission>(info);
                for (int i = 0; i < CustomFunctions_Transmission.functions.Count; i++)
                {
                    if (CustomFunctions_Transmission.functions[i].combination_name == SelectObject.combinationName)
                    {
                        options.Add(CustomFunctions_Transmission.functions[i].Animation_name);
                    }
                }
                break;
            }
        }
        dropdown.ClearOptions();
        dropdown.AddOptions(options);
    }
    // Imports animation rules from AnimationRule class (or from text file containing AnimationRule info)
    // Sets animeReady flag indicating animation ready to play in Update()
    //[ExposeInEditor(RuntimeOnly = false)]
    public void ImportRule()
    {
        var fileName = "";

        switch (SelectObject.combinationName)
        {
        case "Screw_Nut_Interaction":
            fileName = textAsset_Screw_Nut_Interaction.name + ".txt";
            info     = textAsset_Screw_Nut_Interaction.text;
            Functions_Screw_Nut_Interaction CustomFunctions_Screw_Nut_Interaction = new Functions_Screw_Nut_Interaction();
            CustomFunctions_Screw_Nut_Interaction = JsonUtility.FromJson <Functions_Screw_Nut_Interaction>(info);
            for (int i = 0; i < CustomFunctions_Screw_Nut_Interaction.functions.Count; i++)
            {
                if ((CustomFunctions_Screw_Nut_Interaction.functions[i].combination_name == SelectObject.combinationName) && (CustomFunctions_Screw_Nut_Interaction.functions[i].Animation_name == SaveFunction_Novice.animationName))
                {
                    CustomFunction_Screw_Nut_Interaction = CustomFunctions_Screw_Nut_Interaction.functions[i];
                }
            }

            rule = new AnimationRule_Novice();
            //Create markers
            rule.sourceRotation = StringToQuaternion(CustomFunction_Screw_Nut_Interaction.sourceRotation);
            rule.sourceNormal   = StringToVector3(CustomFunction_Screw_Nut_Interaction.sourceNormal);
            rule.targetCentroid = StringToVector3(CustomFunction_Screw_Nut_Interaction.targetCentroid);
            rule.targetNormal   = StringToVector3(CustomFunction_Screw_Nut_Interaction.targetNormal);
            rule.sourcePosition = StringToVector3(CustomFunction_Screw_Nut_Interaction.sourcePosition);
            rule.startpt        = StringToVector3(CustomFunction_Screw_Nut_Interaction.startpt);
            rule.endpt          = StringToVector3(CustomFunction_Screw_Nut_Interaction.endpt);
            rule.contactpt      = StringToVector3(CustomFunction_Screw_Nut_Interaction.contactpt);

            GameObject sourceObj = GameObject.Find("Screw");
            GameObject targetObj = GameObject.Find("Nut");
            marker_start                  = Instantiate(marker, transform.TransformPoint(rule.startpt), Quaternion.identity);
            marker_start.name             = "start";
            marker_end                    = Instantiate(marker, transform.TransformPoint(rule.endpt), Quaternion.identity);
            marker_end.name               = "end";
            marker_start.transform.parent = sourceObj.transform;
            marker_end.transform.parent   = sourceObj.transform;

            marker_contact = Instantiate(marker, targetObj.transform.TransformPoint(rule.contactpt), Quaternion.identity);

            marker_contact.name             = "contact";
            marker_contact.transform.parent = targetObj.transform;
            AlignObjectsNoviceClick();

            if (SaveFunction_Novice.animationRun == true)
            {
                animeReady = true;
            }
            else
            {
                animeReady = false;
            }
            break;

        case "Gear":
            fileName = textAsset_Gear.name + ".txt";
            info     = textAsset_Gear.text;
            Functions_Gear CustomFunctions_Gear = new Functions_Gear();
            CustomFunctions_Gear = JsonUtility.FromJson <Functions_Gear>(info);
            for (int i = 0; i < CustomFunctions_Gear.functions.Count; i++)
            {
                if ((CustomFunctions_Gear.functions[i].combination_name == SelectObject.combinationName) && (CustomFunctions_Gear.functions[i].Animation_name == SaveFunction_Novice.animationName))
                {
                    CustomFunction_Gear = CustomFunctions_Gear.functions[i];
                }
            }

            rule              = new AnimationRule_Novice();
            rule.gearAngle    = float.Parse(CustomFunction_Gear.speed);
            rule.targetNormal = StringToVector3(CustomFunction_Gear.surfaceNormal);
            Transform[] gears = GameObject.Find("Gear").GetComponentsInChildren <Transform>();
            if (SaveFunction_Novice.animationRun == true)
            {
                animeReady = true;
                GearSetup(rule.targetNormal, rule.gearAngle, gears);
            }
            else
            {
                animeReady = false;
                GearSetup(rule.targetNormal, rule.gearAngle, gears);
            }
            break;

        case "Belt and Pulley":
            fileName = textAsset_BeltandPulley.name + ".txt";
            info     = textAsset_BeltandPulley.text;
            Functions_BeltandPulley CustomFunctions_BeltandPulley = new Functions_BeltandPulley();
            CustomFunctions_BeltandPulley = JsonUtility.FromJson <Functions_BeltandPulley>(info);
            for (int i = 0; i < CustomFunctions_BeltandPulley.functions.Count; i++)
            {
                if ((CustomFunctions_BeltandPulley.functions[i].combination_name == SelectObject.combinationName) && (CustomFunctions_BeltandPulley.functions[i].Animation_name == SaveFunction_Novice.animationName))
                {
                    CustomFunction_BeltandPulley = CustomFunctions_BeltandPulley.functions[i];
                }
            }
            rule_BeltandPulley = new AnimationRule_BeltandPulley();
            //Create markers
            rule_BeltandPulley.surfaceNormal = StringToVector3(CustomFunction_BeltandPulley.surfaceNormal);
            if (SaveFunction_Novice.animationRun == true)
            {
                animeReady = true;
            }
            else
            {
                animeReady = false;
            }
            break;

        case "Transmission":
            fileName = textAsset_Transmission.name + ".txt";
            info     = textAsset_Transmission.text;
            Functions_Transmission CustomFunctions_Transmission = new Functions_Transmission();
            CustomFunctions_Transmission = JsonUtility.FromJson <Functions_Transmission>(info);
            for (int i = 0; i < CustomFunctions_Transmission.functions.Count; i++)
            {
                if ((CustomFunctions_Transmission.functions[i].combination_name == SelectObject.combinationName) && (CustomFunctions_Transmission.functions[i].Animation_name == SaveFunction_Novice.animationName))
                {
                    CustomFunction_Transmission = CustomFunctions_Transmission.functions[i];
                }
            }
            Debug.Log(CustomFunction_Transmission.speed1);
            if (CustomFunction_Transmission.speed1 != "")
            {
                transmission = true;
                List <string> contactpts = new List <string>();
                string[]      points     = new String[] { };
                points = CustomFunction_Transmission.contactpts.Split(';');
                for (int i = 0; i < 6; i++)
                {
                    contactpts.Add(points[i]);
                    rule = new AnimationRule_Novice(highlighter.animationRule.objNames);
                    //Create markers
                    //Transform sourceObj = GameObject.Find(rule.objNames[0]).transform;
                    Transform targetObj_Transmission = GameObject.Find("Transmission").transform.Find("Handle_Gear2/Plate");

                    /*rule.targetNormal = targetObj_Transmission.TransformVector(highlighter.animationRule.targetNormal);
                     * rule.sourceNormal = transform.TransformVector(highlighter.animationRule.sourceNormal);
                     * //rule.targetCentroid = targetObj.TransformPoint(highlighter.animationRule.targetCentroid);
                     * rule.targetCentroid = targetObj_Transmission.TransformPoint(highlighter.animationRule.contactlist[i]);
                     * rule.startpt = highlighter.animationRule.startpt;
                     * rule.endpt = highlighter.animationRule.endpt;
                     * rule.contactpt = highlighter.animationRule.contactlist[i];*/

                    //Create markers
                    //rule.sourceRotation = StringToQuaternion(CustomFunction_Screw_Nut_Interaction.sourceRotation);

                    rule.targetCentroid = targetObj_Transmission.TransformPoint(StringToVector3(contactpts[i]));
                    rule.targetNormal   = targetObj_Transmission.TransformVector(StringToVector3(CustomFunction_Transmission.targetNormal));
                    rule.sourcePosition = StringToVector3(CustomFunction_Transmission.sourcePosition);
                    rule.startpt        = StringToVector3(CustomFunction_Transmission.startpt);
                    rule.endpt          = StringToVector3(CustomFunction_Transmission.endpt);
                    rule.contactpt      = StringToVector3(contactpts[i]);

                    Transform sourceObj_Transmission = GameObject.Find("Transmission/Handle_Gear2/Plate/Screw_02_" + i).transform;
                    //GameObject targetObj = GameObject.Find("Nut");
                    rule.sourceNormal = sourceObj_Transmission.TransformVector(StringToVector3(CustomFunction_Transmission.sourceNormal));

                    marker_start                  = Instantiate(marker, sourceObj_Transmission.transform.TransformPoint(rule.startpt), Quaternion.identity);
                    marker_start.name             = "start";
                    marker_end                    = Instantiate(marker, sourceObj_Transmission.transform.TransformPoint(rule.endpt), Quaternion.identity);
                    marker_end.name               = "end";
                    marker_start.transform.parent = sourceObj_Transmission.transform;
                    marker_end.transform.parent   = sourceObj_Transmission.transform;

                    marker_contact = Instantiate(marker, targetObj_Transmission.TransformPoint(rule.contactpt), Quaternion.identity);

                    marker_contact.name             = "contact";
                    marker_contact.transform.parent = targetObj_Transmission;

                    sourceObj_Transmission.rotation = Quaternion.FromToRotation(-rule.sourceNormal, rule.targetNormal) * sourceObj_Transmission.rotation;
                    sourceObj_Transmission.position = rule.targetCentroid + rule.targetNormal;
                    //AlignObjects(rule);
                }
                if (SaveFunction_Novice.animationRun == true)
                {
                    animeReady = true;
                }
                else
                {
                    animeReady = false;
                }
            }
            else
            {
                transmission      = false;
                rule              = new AnimationRule_Novice(highlighter.animationRule.objNames);
                rule.gearAngle    = float.Parse(CustomFunction_Transmission.speed2);
                rule.targetNormal = StringToVector3(CustomFunction_Transmission.surfaceNormal);
                GameObject gearTransmission = GameObject.Find("Transmission/Gear");
                Debug.Log(gearTransmission.name);
                Transform[] gearsTransmission = gearTransmission.GetComponentsInChildren <Transform>();
                if (SaveFunction_Novice.animationRun == true)
                {
                    animeReady = true;
                    GearSetup(rule.targetNormal, rule.gearAngle, gearsTransmission);
                }
                else
                {
                    animeReady = false;
                    GearSetup(rule.targetNormal, rule.gearAngle, gearsTransmission);
                }
            }
            break;
        }
    }