void Update() { if (Controller.GetPressUp(SteamVR_Controller.ButtonMask.ApplicationMenu)) { if (!MeshDeformation.experiment_running) { GameObject go = GameObject.Find("start_text"); go.GetComponent <Renderer>().enabled = false; for (int i = 0; i < 2; i++) { MeshDeformation script = meshScripts[i]; script.mesh_file_location = beams[mesh_indices[cur_mesh_index, i]]; script.emb_mesh_file_location = beams[beams.Length - 1]; script.ms_delay = ms_delays[mesh_indices[cur_mesh_index, i]]; script.YM_factor = YM_factors[mesh_indices[cur_mesh_index, i]]; script.myStart(); } MeshDeformation.experiment_running = true; return; } for (int i = 0; i < 2; i++) { MeshDeformation script = meshScripts[i]; if (script.controllerStates[0].isGrabbing) { logChosenBar(i); resetObjects(); return; // Can only grab one object at a time so return here } } } }
void resetObjects() { cur_mesh_index++; if (cur_mesh_index == mesh_indices.GetLength(0)) { //We are done GameObject go = GameObject.Find("thank_you_text"); go.GetComponent <Renderer>().enabled = true; for (int i = 0; i < 2; i++) { MeshDeformation script = meshScripts[i]; script.meshThreadFinished = true; } return; } for (int i = 0; i < 2; i++) { MeshDeformation script = meshScripts[i]; script.mesh_file_location = beams[mesh_indices[cur_mesh_index, i]]; script.ms_delay = ms_delays[mesh_indices[cur_mesh_index, i]]; script.YM_factor = YM_factors[mesh_indices[cur_mesh_index, i]]; script.reset_timestamp = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond; script.reset_object_pending = true; // Need to do this so we don't reset the object while the thread is running } //SteamVR_Fade.View(Color.white, 1000f); //SteamVR_Skybox.SetOverride(); }
void HandleInputLower(Ray inputRay) { //Ray inputRay = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(inputRay, out hit)) { MeshDeformation deformer = hit.collider.GetComponent <MeshDeformation>(); if (deformer) { Vector3 point = hit.point; point += hit.normal * forceOffset; deformer.AddHeight(point, hit.normal, -force, radius); } } }
// Update is called once per frame /* * void Update () { * if (Input.GetMouseButton(0)) { * //HandleSlap(); * HandleInputLower(); * } * if (Input.GetMouseButton(1)) { * HandleInputRaise(); * } * } */ void HandleSlap() { Ray inputRay = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(inputRay, out hit)) { MeshDeformation deformer = hit.collider.GetComponent <MeshDeformation> (); if (deformer) { Vector3 point = hit.point; point += hit.normal * forceOffset; deformer.AddDeformingForce(point, force); } } }
private void RandomMesh() { float minRand = -200f; float maxRand = 200f; Mesh m = GetComponent <MeshFilter>().sharedMesh; MeshDeformation md = GetComponent <MeshDeformation>(); ColorVertexes cv = GetComponent <ColorVertexes>(); //raise and lower at random print("GenTerr vernum = " + m.vertices.Length); Vector3[] v = m.vertices; for (int i = 0; i < v.Length; i++) { float force = Random.Range(minRand, maxRand); md.GenAddHeight(v[i], v[i] + v[i], force, 1000); } cv.UpdateColors(); }
public void HandleInput(Ray inputRay, float mult) { /* * Ray inputRay = Camera.main.ScreenPointToRay (Input.mousePosition); */ RaycastHit hit; if (Physics.Raycast(inputRay, out hit)) { print(hit.transform.name); MeshDeformation deformer = hit.collider.GetComponent <MeshDeformation>(); if (deformer) { Vector3 point = hit.point; point += hit.normal * forceOffset; deformer.AddHeight(point, hit.normal, force * mult, radius); } } }
void HandleInput() { Ray inputRay = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(inputRay, out hit)) { MeshDeformation deformer = hit.collider.GetComponent <MeshDeformation>(); //Debug.Log("object: "+ hit.collider.gameObject.name); if (deformer) { //Debug.Log("hit at point: "+ hit.point); Vector3 point = hit.point; point += hit.normal * forceOffset; deformer.AddDeformingForce(point, force); } } }
void AddDeformerTo(GameObject obj, float rayRange) { Vector3 downVec = (-obj.transform.up); float rayDirectionOffsetFromObject = 0.1f; RaycastHit hit; if (Physics.Raycast(obj.transform.position + (downVec * rayDirectionOffsetFromObject), downVec, out hit, rayRange)) { // Use to debug the Physics.RayCast. //Debug.DrawRay(obj.transform.position + (downVec * rayDirectionOffsetFromObject), downVec * rayRange, Color.red); MeshDeformation deformer = hit.collider.GetComponent <MeshDeformation>(); //Debug.Log("object: "+ hit.collider.gameObject.name); if (deformer) { //Debug.Log("hit at point: "+ hit.point); Vector3 point = hit.point; point += hit.normal * forceOffset; deformer.AddDeformingForce(point, force); } } }
public void GeneratePlanet() { ColorVertexes cv = GetComponent <ColorVertexes>(); cv.DirtLevel = terrainRadius - 3; cv.GrassLevel = terrainRadius + 1; cv.RockLevel = terrainRadius + 4; cv.SnowLevel = terrainRadius + 7; CubeSphere cs = GetComponent <CubeSphere>(); cs.radius = terrainRadius; cs.gridSize = detailLevel; cs.Build(); MeshDeformation md = GetComponent <MeshDeformation>(); md.Build(); GetComponent <GenerateTerrain>().GenTerrain(); //water transform.GetChild(0).localScale = new Vector3(terrainRadius * 2, terrainRadius * 2, terrainRadius * 2); transform.GetChild(0).gameObject.SetActive(true); //atmos transform.GetChild(1).localScale = new Vector3((terrainRadius + atmosphereRadius) * 2, (terrainRadius + atmosphereRadius) * 2, (terrainRadius + atmosphereRadius) * 2); transform.GetChild(1).gameObject.SetActive(true); //clouds //ParticleSystem.ShapeModule shapeModule = transform.GetChild(2).GetComponent<ParticleSystem>().shape; //shapeModule.radius = atmosphereRadius + terrainRadius; //ParticleSystem.MainModule mainMondule = transform.GetChild(2).GetComponent<ParticleSystem>().main; //mainMondule.maxParticles = (int)atmosphereRadius * 2; //objects GetComponent <PlanetObjectsHandler>().Build(); }
private void Start() { Rigidbody = GetComponent <Rigidbody>(); _deformation = GetComponent <MeshDeformation>(); }
private void Awake() { mTarget = (MeshDeformation)target; }