protected override void OnZAxisPlay(AnimationRule animationRule) { transform.localScale = new Vector3( transform.localScale.x, transform.localScale.y, transform.localScale.z + animationRule.zAxisDeformationModifier); }
public void ImportRule() { rule = new AnimationRule(highlighter.animationRule.objNames); //Create markers rule.targetNormal = highlighter.animationRule.targetNormal; rule.startpt = highlighter.animationRule.startpt; rule.endpt = highlighter.animationRule.endpt; rule.contactpt = highlighter.animationRule.contactpt; GameObject sourceObj = GameObject.Find(rule.objNames[0]); GameObject targetObj = GameObject.Find(rule.objNames[1]); 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; animeReady = true; }
//[ExposeInEditor(RuntimeOnly = false)] public void ImportGearRule() { rule = new AnimationRule(); rule.gearAngle = highlighter.animationRule.gearAngle; rule.targetNormal = highlighter.animationRule.targetNormal; Transform[] gears = gameObject.GetComponentsInChildren <Transform>(); GearSetup(rule.targetNormal, rule.gearAngle, gears); animeReady = true; }
// Start is called before the first frame update void Start() { cam = Camera.main; animationRule = new AnimationRule(); if (cam == null) { Debug.Log("camera null reference"); } }
public AnimationRule GetСorrectTransform(float multiplier) { AnimationRule ruleWithCorrectTransform = new AnimationRule(); ruleWithCorrectTransform.animationTime = animationTime; ruleWithCorrectTransform.xAxis = xAxis; ruleWithCorrectTransform.yAxis = yAxis; ruleWithCorrectTransform.zAxis = zAxis; ruleWithCorrectTransform.xAxisDeformationModifier = multiplier * xAxisDeformationModifier; ruleWithCorrectTransform.yAxisDeformationModifier = multiplier * yAxisDeformationModifier; ruleWithCorrectTransform.zAxisDeformationModifier = multiplier * zAxisDeformationModifier; return(ruleWithCorrectTransform); }
public AnimationRule GetСorrectTransform(Vector3 objectTransform) { AnimationRule ruleWithCorrectTransform = new AnimationRule(); ruleWithCorrectTransform.animationTime = animationTime; ruleWithCorrectTransform.xAxis = xAxis; ruleWithCorrectTransform.yAxis = yAxis; ruleWithCorrectTransform.zAxis = zAxis; ruleWithCorrectTransform.xAxisDeformationModifier = objectTransform.x * xAxisDeformationModifier; ruleWithCorrectTransform.yAxisDeformationModifier = objectTransform.y * yAxisDeformationModifier; ruleWithCorrectTransform.zAxisDeformationModifier = objectTransform.z * zAxisDeformationModifier; return(ruleWithCorrectTransform); }
// 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; } }
protected abstract void OnZAxisPlay(AnimationRule animationRule);