//test to random float to see if the sphere scales using the variable //create a grabbing mechanic. controller needs to grab the armature of the sphere. the distance the controller travels is what gets assigned to the //sphere in realtimeSmooth // Use this for initialization void FixedUpdate() { if (CheckingReference) { if (sphere == null) { sphere = GameObject.FindGameObjectWithTag("Mesh"); } if (scriptRef == null) { scriptRef = sphere.GetComponent <VRTK_InteractableObject> (); } if (PointerRef == null) { PointerRef = GameObject.FindGameObjectWithTag("controllerRight").GetComponent <VRTK_UIPointer> (); } if (UIref == null) { UIref = GameObject.FindGameObjectWithTag("UINref").GetComponent <UINavigationSystem> (); sculpt = UIref.Scalexyz; rotate = UIref.Rotatexyz; UniformScale = UIref.uniformScale; GrabToggle = UIref.Grab; } if (controllerPos == null) { controllerPos = GameObject.FindGameObjectWithTag("controllerRight"); } } }
// Use this for initialization void Start() { SpawnPosition = GameObject.FindGameObjectWithTag("SpawnPosition").transform; PMD = GameObject.FindGameObjectWithTag("PMD").GetComponent <PaintMeshDeformer>(); undoNredo = GameObject.FindGameObjectWithTag("SLUR").GetComponent <UndoAndRedo> (); UIref = GameObject.FindGameObjectWithTag("UINref").GetComponent <UINavigationSystem> (); dm = GameObject.FindGameObjectWithTag("SM").GetComponent <VRSmooth> (); tooltip = GameObject.FindGameObjectWithTag("tooltip").GetComponent <VRTK_ControllerTooltips> (); }
// Use this for initialization void Start() { for (int i = 0; i < MainTools.Length; i++) { ToolList.Push(MainTools [i]); } PMD = GameObject.FindGameObjectWithTag("PMD").GetComponent <PaintMeshDeformer> (); UINAV = GameObject.FindGameObjectWithTag("UINref").GetComponent <UINavigationSystem>(); foreach (GameObject tl in MainTools) { tl.SetActive(false); } MainTools [0].SetActive(true); //goals = GameObject.FindGameObjectsWithTag ("goals"); foreach (GameObject gl in goals) { gl.SetActive(false); } goals [0].SetActive(true); //required points to moved to next goal, then new tools get unlock Exp.RequiredsculptEXP = ExpGlobalAmount; Exp.RequiredscaleEXP = ExpGlobalAmount / 2; Exp.RequiredrotateEXP = ExpGlobalAmount / 2; Exp.RequiredcreaseEXP = ExpGlobalAmount / 2; Exp.RequiredgrabEXP = ExpGlobalAmount / 2; Exp.RequiredsymmetryEXP = ExpGlobalAmount / 2; Exp.RequiredsmoothEXP = ExpGlobalAmount / 2; Exp.RequiredpaintEXP = ExpGlobalAmount; foreach (Slider sli in expPointsliders) { sli.maxValue = ExpGlobalAmount; } for (int i = 0; i < toolsboolean.Length; i++) { toolsboolean [i] = false; } }
public void AssignedMeshTrasformReference() { sphere = GameObject.FindGameObjectWithTag("Mesh"); _rotation = Vector3.zero; PMD = GameObject.FindGameObjectWithTag("PMD").GetComponent <PaintMeshDeformer>(); _controllerPos = GameObject.FindGameObjectWithTag("controllerRight").GetComponent <Transform>(); scriptRef = sphere.GetComponent <VRTK_InteractableObject> (); PointerRef = GameObject.FindGameObjectWithTag("controllerRight").GetComponent <VRTK_UIPointer> (); UIref = GameObject.FindGameObjectWithTag("UINref").GetComponent <UINavigationSystem> (); if (UIref == null) { UIref = GameObject.FindGameObjectWithTag("UINref").GetComponent <UINavigationSystem> (); } controllerPos = GameObject.FindGameObjectWithTag("controllerRight"); sculpt = UIref.Scalexyz; rotate = UIref.Rotatexyz; UniformScale = UIref.uniformScale; GrabToggle = UIref.Grab; CheckingReference = true; }
// Update is called once per frame void FixedUpdate() { try{ RaycastHit tooltipRayCast; //tooltip to show the player where the buttons are located on the controller if (Physics.Raycast(Raypoint.position, Raypoint.forward, out tooltipRayCast, 100f)) { if (tooltipRayCast.collider.tag == "UI" && !tooltipUIIsActive) { //tooltip.touchpadText = "Touchpad"; tooltip.UpdateText(VRTK_ControllerTooltips.TooltipButtons.TouchpadTooltip, "Press Touchpad"); tooltip.UpdateText(VRTK_ControllerTooltips.TooltipButtons.TriggerTooltip, ""); if (tooltip == null) { tooltip = GameObject.FindGameObjectWithTag("tooltip").GetComponent <VRTK_ControllerTooltips> (); } //tooltip.triggerText = ""; tooltipUIIsActive = true; tooltipMESHsActive = false; //tooltip.touchpadText = "Touchpad"; //Debug.Log("tag is UI = " + tooltip.touchpadText); } else if (tooltipRayCast.collider.tag == "Mesh" && !tooltipMESHsActive && UIN.isActive) { tooltip.UpdateText(VRTK_ControllerTooltips.TooltipButtons.TriggerTooltip, "Press Trigger"); tooltip.UpdateText(VRTK_ControllerTooltips.TooltipButtons.TouchpadTooltip, ""); if (tooltip == null) { tooltip = GameObject.FindGameObjectWithTag("tooltip").GetComponent <VRTK_ControllerTooltips> (); } //tooltip.touchpadText = ""; tooltipMESHsActive = true; tooltipUIIsActive = false; //tooltip.triggerText = "Trigger"; //Debug.Log("tag is UI = " + tooltip.triggerText); //Debug.Log("tag is Mesh"); } else if (tooltipRayCast.collider.tag != "UI") { tooltip.UpdateText(VRTK_ControllerTooltips.TooltipButtons.TouchpadTooltip, ""); tooltipUIIsActive = false; } } //manages which tool is being used //using an enum switch (currentTool) { //if sculpt is pressed, this finds the collider with a mesh tag. and //gets the meshfilter so it can be modified. case Tools.Sculpt: try { hit = point.pointerRenderer.GetDestinationHit(); if (hit.transform.gameObject.tag != "Non-Modifiable") { //Debug.Log(hit.collider.name); filter = hit.collider.GetComponent <MeshFilter>(); if (filter) { if (filter != unappliedMesh) { ApplyMeshCollider(); unappliedMesh = filter; } //Mesh Symmetry. simple but it works Vector3 relativePoint = filter.transform.InverseTransformPoint(hit.point); Vector3 inversePoint = relativePoint; inversePoint.x = -relativePoint.x; if (isTriggerOn) { //Debug.Log("is trigger on? " + isTriggerOn); DeformMesh(filter.mesh, relativePoint, pull * Time.deltaTime, radius); if (MeshSymmetryToggle.isOn) { DeformMesh(filter.mesh, inversePoint, pull * Time.deltaTime, radius); } } } } } catch (System.NullReferenceException) { } break; case Tools.Scale: try{ if (MeshTransform == null) { MeshTransform = GameObject.FindGameObjectWithTag("Mesh").GetComponent <GetMeshTransform> (); } //Debug.Log("Scaling"); MeshTransform.Scale(); }catch (Exception ex) { if (ex is NullReferenceException || ex is UnassignedReferenceException) { return; } } break; case Tools.Rotate: try{ if (MeshTransform == null) { MeshTransform = GameObject.FindGameObjectWithTag("Mesh").GetComponent <GetMeshTransform> (); } //Debug.Log("Rotating"); MeshTransform.Rotate(); }catch (Exception ex) { if (ex is NullReferenceException || ex is UnassignedReferenceException) { return; } } break; case Tools.Crease: try { if (UIN == null) { UIN = GameObject.FindGameObjectWithTag("UINref").GetComponent <UINavigationSystem> (); } AddorSubtract.value = 1; pull = -UIN.CreaseStrength.value; radius = .03f; hit = point.pointerRenderer.GetDestinationHit(); if (hit.transform.gameObject.tag != "Non-Modifiable") { filter = hit.collider.GetComponent <MeshFilter>(); if (filter) { if (filter != unappliedMesh) { ApplyMeshCollider(); unappliedMesh = filter; } //Mesh Symmetry. simple but it works Vector3 relativePoint = filter.transform.InverseTransformPoint(hit.point); Vector3 inversePoint = relativePoint; inversePoint.x = -relativePoint.x; if (isTriggerOn) { //Debug.Log("trigger on"); DeformMesh(filter.mesh, relativePoint, pull * Time.deltaTime, radius); //filter.gameObject.GetComponent<MeshCollider> ().sharedMesh = filter.mesh; if (MeshSymmetryToggle.isOn) { radius = .03f; //Debug.Log(pull + " pull value"); DeformMesh(filter.mesh, inversePoint, pull * Time.deltaTime, radius); //filter.gameObject.GetComponent<MeshCollider> ().sharedMesh = filter.mesh; } } } } } catch (System.NullReferenceException) { } break; //get out case Tools.Grab: try{ if (MeshTransform == null) { MeshTransform = GameObject.FindGameObjectWithTag("Mesh").GetComponent <GetMeshTransform> (); } //if (GrabToggle.isOn) { MeshTransform.Grab(); //Debug.Log("Moving"); }catch (Exception ex) { if (ex is NullReferenceException || ex is UnassignedReferenceException) { return; } } break; case Tools.Symmetry: try{ //MeshSymmetryToggle.isOn = true; }catch (Exception ex) { if (ex is NullReferenceException || ex is UnassignedReferenceException) { return; } } break; case Tools.Smooth: //Debug.Log("Moving"); try{ isInSmoothPage = true; if (dm == null) { dm.ClayMesh = ClayMesh.GetComponent <MeshFilter>(); dm = GameObject.FindGameObjectWithTag("Mesh").GetComponent <VRSmooth> (); } }catch (Exception ex) { if (ex is NullReferenceException || ex is UnassignedReferenceException) { return; } } break; case Tools.Paint: //Debug.Log("paint ON"); try{ if (texpaint == null) { texpaint = GameObject.FindGameObjectWithTag("TP").GetComponent <VRTexturePainter> (); } texpaint.enabled = true; }catch (Exception ex) { if (ex is NullReferenceException || ex is UnassignedReferenceException) { return; } } break; } }catch (Exception ex) { if (ex is NullReferenceException || ex is UnassignedReferenceException) { return; } } }
void Awake() { tooltip = GameObject.FindGameObjectWithTag("tooltip").GetComponent <VRTK_ControllerTooltips> (); //tooltip.touchpadText = "Touchpad"; UIN = GameObject.FindGameObjectWithTag("UINref").GetComponent <UINavigationSystem>(); }
// Update is called once per frame void Update() { Navref = UINRef.GetComponent <UINavigationSystem> (); }