public CFDClosestPt(float x, float y, ImportCsv cfdData, ImportCsv cfdOrigin) { this.cfdData = cfdData; this.cfdOrigin = cfdOrigin; float min = 99999999; for (int i = 0; i < cfdData.Count; i++) { float xTest = Math.Abs(x - (cfdData.Itemf(i, 0) + cfdOrigin.Itemf(0, 0))); // +x float yTest = Math.Abs(y - (cfdData.Itemf(i, 1) + cfdOrigin.Itemf(0, 2))); // +z float dist = (float)Math.Sqrt(Math.Pow(xTest, 2) + Math.Pow(yTest, 2)); if (dist < min) { min = dist; this.id = i; } } this.Vx = cfdData.Itemf(this.id, 2); this.Vy = cfdData.Itemf(this.id, 3); this.Vz = cfdData.Itemf(this.id, 4); this.V = Mathf.Sqrt(this.Vx * this.Vx + this.Vy * this.Vy + this.Vz * this.Vz); this.T = cfdData.Itemf(this.id, 6); this.PMV = cfdData.Itemf(this.id, 7); this.PPD = 100 - 95 * Mathf.Exp(-0.03353f * Mathf.Pow(this.PMV, 4f) - 0.2179f * Mathf.Pow(this.PMV, 2f)); this.PPS = 100 - this.PPD; }
void ApplyMovements() { if (enableFreeRoam) { PlayerObj.GetComponent <Navigation>().setMovementMode(0); } else { ImportCsv loc = new ImportCsv(WWWLoader.active_download_path + "jumplocations"); jumpLocations = new Vector3[loc.Count]; for (int i = 0; i < loc.Count; i++) { jumpLocations[i] = new Vector3(loc.Itemf(i, 0), loc.Itemf(i, 1), loc.Itemf(i, 2)); } //create jumpProgressBars as necessary for (int i = 0; i < jumpLocations.Length; i++) { GameObject canvas = (GameObject)Instantiate(Resources.Load("prefabs/MovementCanvas"), new Vector3(jumpLocations[i].x, jumpLocations[i].y, jumpLocations[i].z), Quaternion.identity); canvas.GetComponentInChildren <RadialProgressBar>().roomControl = this; movementCanvases.Add(canvas.GetComponent <Canvas>()); } rotateMovementCanvases(transform.position); PlayerObj.GetComponent <Navigation>().setMovementMode(1); } }
void ApplyHumanLayer() { ImportCsv Human = new ImportCsv(WWWLoader.active_download_path + "humancoords"); for (int i = 0; i < Human.Count; i++) { HumanCoords.Add(new Vector4(Human.Itemf(i, 0), Human.Itemf(i, 1), Human.Itemf(i, 2), Human.Itemf(i, 3))); } if (showHuman) { List <GameObject> hPrefab = new List <GameObject> (); hPrefab.Add((GameObject)Resources.Load("prefabs/Human Prefabs/HumanFig")); hPrefab.Add((GameObject)Resources.Load("prefabs/Human Prefabs/HumanFig (2)")); hPrefab.Add((GameObject)Resources.Load("prefabs/Human Prefabs/HumanFig (3)")); hPrefab.Add((GameObject)Resources.Load("prefabs/Human Prefabs/HumanFig (4)")); hPrefab.Add((GameObject)Resources.Load("prefabs/Human Prefabs/HumanFig (5)")); ImportCsv cfdData = new ImportCsv(WWWLoader.active_download_path + "cfd"); ImportCsv cfdOrigin = new ImportCsv(WWWLoader.active_download_path + "cfdorigin"); for (int i = 0; i < HumanCoords.Count; i++) { //"TODO" instantiating with y to be 0.14 and not coord.y as a quick fix int index = UnityEngine.Random.Range(0, hPrefab.Count); GameObject person = (GameObject)Instantiate(hPrefab[index], new Vector3(HumanCoords[i].x, HumanCoords[i].y, HumanCoords[i].z), Quaternion.Euler(0.0f, HumanCoords[i].w, 0.0f)); person.name = "Person" + i; //Match location coordinates with closest CFD data CFDClosestPt CFD = new CFDClosestPt(HumanCoords[i].x, HumanCoords[i].z, cfdData, cfdOrigin); Vector3 extWind = new Vector3(CFD.Vx * 0.8f, CFD.Vz * 0.8f, CFD.Vy * 0.8f); Vector3 ranWind = new Vector3(CFD.Vx * 0.4f, CFD.Vz * 0.4f, CFD.Vy * 0.4f); //Cloth Setting GameObject WindCloth = person.transform.Find("Skirt (1)").gameObject; //GameObject WindCloth = (GameObject)Instantiate(GameObject.Find("WindCloth"), new Vector3(HumanCoords[i].x, 0.638f, HumanCoords[i].z), Quaternion.Euler(270f, HumanCoords[i].w + 180f, 0.0f)); WindCloth.GetComponent <Cloth>().externalAcceleration = extWind * 6; WindCloth.GetComponent <Cloth>().randomAcceleration = ranWind * 6; GameObject Hair = person.transform.Find("Hair (2)").gameObject; //GameObject WindCloth = (GameObject)Instantiate(GameObject.Find("WindCloth"), new Vector3(HumanCoords[i].x, 0.638f, HumanCoords[i].z), Quaternion.Euler(270f, HumanCoords[i].w + 180f, 0.0f)); Hair.GetComponent <Cloth>().externalAcceleration = extWind * 8; Hair.GetComponent <Cloth>().randomAcceleration = ranWind * 8; GameObject Hair2 = person.transform.Find("Hair (3)").gameObject; //GameObject WindCloth = (GameObject)Instantiate(GameObject.Find("WindCloth"), new Vector3(HumanCoords[i].x, 0.638f, HumanCoords[i].z), Quaternion.Euler(270f, HumanCoords[i].w + 180f, 0.0f)); Hair2.GetComponent <Cloth>().externalAcceleration = extWind * 8; Hair2.GetComponent <Cloth>().randomAcceleration = ranWind * 8; person.GetComponent <TooltipPopup>().setTooltip(CFD.PPS.ToString("F0"), CFD.T.ToString("F1"), CFD.V.ToString("F2"), CFD.PMV); //set mood based on PMV here //random from 0-100 inclusive person.GetComponent <HumanEmoticon>().setMood(CFD.PMV); } } }
void ApplyNoise() { ImportCsv Noise = new ImportCsv(WWWLoader.active_download_path + "noisecoords"); List <Vector4> NoiseCoords = new List <Vector4>(); for (int i = 0; i < Noise.Count; i++) { NoiseCoords.Add(new Vector4(Noise.Itemf(i, 0), Noise.Itemf(i, 1), Noise.Itemf(i, 2), Noise.Itemf(i, 3))); } if (enableNoise) { for (int i = 0; i < NoiseCoords.Count; i++) { string path = "prefabs/NoisePresets/"; switch ((int)NoiseCoords [i].w) { case 4: path += "NoiseSourceEnclosed"; break; case 3: path += "NoiseSourceTelevision"; break; case 2: path += "NoiseSourceSeaside"; break; case 1: path += "NoiseSourceNeighbourhood"; break; default: path += "NoiseSourceCity"; break; } //"TODO" instantiating with y to be 0.14 and not coord.y as a quick fix GameObject person = (GameObject)Instantiate(Resources.Load(path), new Vector3(NoiseCoords[i].x, NoiseCoords[i].y, NoiseCoords[i].z), Quaternion.identity); person.name = "Noise" + i; } } }
// Use this for initialization void Start() { renderMat = false; showFurn = false; showHuman = false; showView = false; enableNoise = false; enableFreeRoam = false; //Read from Defaults ImportCsv Defaults = new ImportCsv(WWWLoader.active_download_path + "layersettings", ":"); if (!PlayerPrefs.HasKey("RenderMat")) { for (int i = 0; i < Defaults.Count; i++) { switch (Defaults.Item(i, 0)) { case "Material": toggleMat.isOn = bool.Parse(Defaults.Item(i, 2)); break; case "Furniture": toggleFurn.isOn = bool.Parse(Defaults.Item(i, 2)); break; case "Human": toggleHuman.isOn = bool.Parse(Defaults.Item(i, 2)); break; case "FreeMovement": toggleFreeRoam.isOn = bool.Parse(Defaults.Item(i, 2)); break; case "View": toggleView.isOn = bool.Parse(Defaults.Item(i, 2)); break; case "Noise": toggleNoise.isOn = bool.Parse(Defaults.Item(i, 2)); break; case "MovementSpeed": movementSpeed = Defaults.Itemf(i, 1); PlayerPrefs.SetFloat("MovementSpeed", movementSpeed); break; case "LightIntensity": lightIntensity = Defaults.Itemf(i, 1); PlayerPrefs.SetFloat("LightIntensity", lightIntensity); break; default: break; } } } else { //read from PlayerPrefs if (PlayerPrefs.GetInt("RenderMat") == 1) { toggleMat.isOn = PlayerPrefs.GetInt("RenderMat") == 1; //this toggles the trigger } if (PlayerPrefs.GetInt("ShowFurn") == 1) { toggleFurn.isOn = PlayerPrefs.GetInt("ShowFurn") == 1; } if (PlayerPrefs.GetInt("ShowHuman") == 1) { toggleHuman.isOn = PlayerPrefs.GetInt("ShowHuman") == 1; } if (PlayerPrefs.GetInt("ShowView") == 1) { toggleView.isOn = PlayerPrefs.GetInt("ShowView") == 1; } if (PlayerPrefs.GetInt("EnableNoise") == 1) { toggleNoise.isOn = PlayerPrefs.GetInt("EnableNoise") == 1; } if (PlayerPrefs.GetInt("EnableFreeRoam") == 1) { toggleFreeRoam.isOn = PlayerPrefs.GetInt("EnableFreeRoam") == 1; } } //set enabled or disabled for (int i = 0; i < Defaults.Count; i++) { switch (Defaults.Item(i, 0)) { case "Material": setToggleStatus(toggleMat, bool.Parse(Defaults.Item(i, 1))); break; case "Furniture": setToggleStatus(toggleFurn, bool.Parse(Defaults.Item(i, 1))); break; case "Human": setToggleStatus(toggleHuman, bool.Parse(Defaults.Item(i, 1))); break; case "FreeMovement": setToggleStatus(toggleFreeRoam, bool.Parse(Defaults.Item(i, 1))); break; case "View": setToggleStatus(toggleView, bool.Parse(Defaults.Item(i, 1))); break; case "Noise": setToggleStatus(toggleNoise, bool.Parse(Defaults.Item(i, 1))); break; default: break; } } }