// Use this for initialization void Start() { if (_DepthManager.getData() != null) { int width = _DepthManager.getWidth(); int height = _DepthManager.getHeight(); gameObject.transform.position = new Vector3(width / 2, -height / 2, 2); gameObject.transform.localScale = new Vector3(width, height, 1); } }
// Use this for initialization void Start() { flowerLists = new ArrayList[3]; for (int i = 0; i < flowerLists.Length; i++) { flowerLists[i] = new ArrayList(); } if (_DepthManager.getData() != null) { width = _DepthManager.getWidth(); height = _DepthManager.getHeight(); } cellWidth = width / dispHoriz; cellHeight = height / dispVert; Debug.Log("dispHoriz: " + dispHoriz + ", dispVert: " + dispVert); Debug.Log("cellWidth: " + cellWidth + ", cellHeight: " + cellHeight); int spaceCount = dispHoriz * dispVert; emptySpaces = spaceCount; // Instantiating large flowers (3 x 3) while (spaceCount > emptySpaces * 2 / 3) { GameObject flowerClone = Instantiate(flower); //flowerClone.transform.localScale.Set(gridWidth * 3, gridHeight * 3, 1); flowerClone.transform.localScale.Set(cellWidth, cellHeight, 1); flowerLists[0].Add(flowerClone); spaceCount -= 9; } // Instantiating medium flowers (2 x 2) while (spaceCount > emptySpaces / 3) { GameObject flowerClone = Instantiate(flower); //flowerClone.transform.localScale.Set(gridWidth * 2, gridHeight * 2, 1); flowerClone.transform.localScale.Set(cellWidth, cellHeight, 1); flowerLists[1].Add(flowerClone); spaceCount -= 4; } // Instantiating small flowers (1 x 1) while (spaceCount > 0) { GameObject flowerClone = Instantiate(flower); flowerClone.transform.localScale.Set(cellWidth, cellHeight, 1); flowerLists[2].Add(flowerClone); spaceCount--; } //grid = new Space[gridWidth, gridHeight]; grid = new bool[gridWidth, gridHeight]; setupGrid(); moveFlowers(width, height); }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Space) || scenerySamples < _ScenerySamples) { makeScenery(); } if (Input.GetKeyDown(KeyCode.R)) { resetScenery(); } if (Input.GetKeyDown(KeyCode.P)) { if (paused) { paused = false; } else { paused = true; } } if (Input.GetKeyDown(KeyCode.LeftShift) || Input.GetKeyDown(KeyCode.RightShift)) { shiftKeyDown = true; } else if (Input.GetKeyUp(KeyCode.LeftShift) || Input.GetKeyUp(KeyCode.RightShift)) { shiftKeyDown = false; } if (shiftKeyDown) { bool printCutOff = false; if (Input.GetKeyDown(KeyCode.PageUp)) { frontCutOff += _CutOffIncrement; printCutOff = true; } else if (Input.GetKeyDown(KeyCode.PageDown)) { frontCutOff -= _CutOffIncrement; printCutOff = true; } if (frontCutOff <= backCutOff) { frontCutOff = backCutOff + _CutOffIncrement; if (frontCutOff <= _MaxDistance) { frontCutOff = _MaxDistance; backCutOff = frontCutOff - _CutOffIncrement; } } if (printCutOff) { Debug.Log("Front Cut Off: " + frontCutOff + ", Back Cut Off: " + backCutOff); } bool printScale = false; if (Input.GetKeyDown(KeyCode.UpArrow)) { heightScale += _ScaleIncrement; printScale = true; if (heightScale > _MaxScale) { heightScale = _MaxScale; } } else if (Input.GetKeyDown(KeyCode.DownArrow)) { heightScale -= _ScaleIncrement; printScale = true; if (heightScale < _MinScale) { heightScale = _MinScale; } } else if (Input.GetKeyDown(KeyCode.LeftArrow)) { widthScale -= _ScaleIncrement; printScale = true; if (widthScale < _MinScale) { widthScale = _MinScale; } } else if (Input.GetKeyDown(KeyCode.RightArrow)) { widthScale += _ScaleIncrement; printScale = true; if (widthScale > _MaxScale) { widthScale = _MaxScale; } } if (printScale) { Debug.Log("Width Scale: " + widthScale * 100 + "%, Height Scale: " + heightScale * 100 + "%"); } } else { bool printCutOff = false; if (Input.GetKeyDown(KeyCode.PageUp)) { backCutOff += _CutOffIncrement; printCutOff = true; } else if (Input.GetKeyDown(KeyCode.PageDown)) { backCutOff -= _CutOffIncrement; printCutOff = true; } if (backCutOff >= frontCutOff) { backCutOff = frontCutOff - _CutOffIncrement; } if (printCutOff) { Debug.Log("Front Cut Off: " + frontCutOff + ", Back Cut Off: " + backCutOff); } bool printOffset = false; if (Input.GetKeyDown(KeyCode.UpArrow)) { yOffset -= _OffsetIncrement; printOffset = true; } else if (Input.GetKeyDown(KeyCode.DownArrow)) { yOffset += _OffsetIncrement; printOffset = true; } else if (Input.GetKeyDown(KeyCode.LeftArrow)) { xOffset -= _OffsetIncrement; printOffset = true; } else if (Input.GetKeyDown(KeyCode.RightArrow)) { xOffset += _OffsetIncrement; printOffset = true; } if (printOffset) { Debug.Log("X_Offset: " + xOffset + ", Y_Offset: " + yOffset); } } if (paused) { return; } blobList.Clear(); for (int i = 0; i < _GroupsToDetect; i++) { blobGroupRoster[i] = 0; } depthData = _DepthManager.getData(); if (depthData == null) { return; // This means _Sensor is null } makeBlobs(depthData, _DepthManager.getWidth(), _DepthManager.getHeight()); filterBlobs(); makeGroups(); filterGroups(); moveCubes(); //moveSpheres(); bloomFlowers(); }