// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.S)) // key S means snapshot { Debug.Log("S key pressed!"); // store a snapshot of depth image //depthSnapshot = (short[]) dw.depthImg.Clone(); // deep copy depthSnapshot = new short[320 * 240]; arrayCopy(depthSnapshot, dw.depthImg); //initiate ROI vertics manually ROIVertex[0].Set(55, 3); //left top ROIVertex[1].Set(310, 195); //right bottom //initiate number of vertex pointCount = 2; } if (dw.pollDepth()) { Debug.Log("poll depth"); if (pointCount == 2) //two point(LT, RB) were detected { callGameObjByKinect(dw.depthImg); } } }
void Update() { if (!KinectDepth.pollDepth()) { return; } short[] depthImage = KinectDepth.depthImg; // get the heights of the terrain under this game object // we set each sample of the terrain in the size to the desired height for (int i = 0; i < depthW; i++) { for (int j = 0; j < depthH; j++) { int newi = 240 - j - 1; int newj = 320 - i - 1; float h = getHeight(depthImage, i, j); heights[newi, newj] = h; // TODO: optimize map[newi, newj, 0] = constrain(lmap(h, 0.0f, 0.2f, 0.3f, 0.0f), 0, 1); map[newi, newj, 1] = lmap(h, 0.2f, 0.7f, 1.0f, 0.5f); map[newi, newj, 2] = lmap(h, 0.6f, 1.0f, 0.5f, 1.0f); } } // set the new height t.terrainData.SetHeights(0, 0, heights); t.terrainData.SetAlphamaps(0, 0, map); // AssignSplatMap.Process(t); }
void Update() { if (_kinectDepthWrapper.pollDepth()) { applyDepthToMesh(_kinectDepthWrapper.depthImg); } }
// Update is called once per frame void Update() { if (dw.pollDepth()) { tex.SetPixels32(convertDepthToColor(dw.depthImg)); //tex.SetPixels32(convertPlayersToCutout(dw.segmentations)); tex.Apply(false); } }
public override bool pollDepth() { if (kinectSensor != null) { return(kinectSensor.pollDepth()); } return(false); }
// Update is called once per frame void Update() { if (dw.pollDepth()) { if (null != dw.depthImg) { tex.SetPixels32(convertDepthToColor(dw.depthImg)); tex.Apply(false); } } }
// Update is called once per frame void Update() { if (KinectDepth.pollDepth()) { DepthImage = KinectDepth.depthImg; CheckArrays(); CropImage(); FilerImage(); CalculateFloatValues(); UpdateMesh(); } }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.S)) // key S means snapshot { Debug.Log("S key pressed!"); // store a snapshot of depth image //depthSnapshot = (short[]) dw.depthImg.Clone(); // deep copy depthSnapshot = new short[320 * 240]; arrayCopy(depthSnapshot, dw.depthImg); //initiate ROI vertics manually ROIVertex[0].Set(55, 3); //left top ROIVertex[1].Set(310, 195); //right bottom //initiate number of vertex pointCount = 2; } if (dw.pollDepth()) { //Debug.Log(); if (pointCount == 2) //two point(LT, RB) were detected //drawRect(img,ROIVertex[0],ROIVertex[1]); // Vector2 screenPoint = findPointInROI(dw.depthImg); // if(screenPoint != null) // guiT.transform.position = new Vector3(screenPoint.x,screenPoint.y,0f); { callGameObjByKinect(dw.depthImg); } else { } //tex.SetPixels32(img); //text.guiText.text ="minimum depth value : " + minDepth.ToString()+"\n"+ // "x : " + minPoint.y +", y : " + minPoint.x; if (depthSnapshot != null) { //text.guiText.text += "\nsnapshot"; } //tex.SetPixels32(convertPlayersToCutout(dw.segmentations)); //tex.Apply(false); } }
// Update is called once per frame void Update() { if (sw.pollSkeleton()) { if (sw.playerState[player] != -4)//Check which player state { if (dw.pollDepth()) { //depthMapTex.SetPixels32(convertDepthToColor(dw.depthImg)); depthMapTex.SetPixels32(convertPlayersToCutout(dw.segmentations, dw.depthImg)); depthMapTex.Apply(); } } else { ClearTexture(depthMapTex); } } }
// Update is called once per frame void Update() { //mWater.transform.Translate(Vector3.up); /*if (mWater.transform.position.y > -5) * { * mWater.transform.Translate(-Vector3.up); * }*/ mDrainageCount = ++mDrainageCount % DRAINAGE_INTERVAL; float currentWaterY = mWater.transform.position.y; if (isRaining && currentWaterY < mMaxYPosWater) { if (mDrainageCount >= DRAINAGE_INTERVAL - 1) { mWater.transform.Translate(Vector3.up); } } if (!isRaining && currentWaterY > mMinYPosWater) { if (mDrainageCount >= DRAINAGE_INTERVAL - 1) { mWater.transform.Translate(-Vector3.up); } } if (KinectDepth.pollDepth()) { DepthImage = KinectDepth.depthImg; //loadDeep(GetComponent<Terrain>().terrainData, result, false); loadDeep(GetComponent <Terrain>().terrainData, DepthImage); Debug.Log("height: " + GetComponent <Terrain>().terrainData.alphamapHeight); Debug.Log("width: " + GetComponent <Terrain>().terrainData.alphamapWidth); //WriteTerrainHeightMap(); //renderTree(GetComponent<Terrain>().terrainData); } }
// Update is called once per frame void Update() { if (sw.pollSkeleton()) { switch (sw.playerState[player]) //Check which player state { case 0: // Tracking is ok if (dw.pollDepth()) { //depthMapTex.SetPixels32(convertDepthToColor(dw.depthImg)); depthMapTex.SetPixels32(convertPlayersToCutout(dw.segmentations, dw.depthImg)); depthMapTex.Apply(); } break; case -1: // too right //gameRunUi.ShowMessage("请左移"); break; case 1: // too left //gameRunUi.ShowMessage("请右移"); break; case -3: // too near //gameRunUi.ShowMessage("请后退"); break; case 3: // too far //gameRunUi.ShowMessage("请靠近"); break; case -4: // no user, waiting //gameRunUi.HideMessagePanel(); break; default: break; } } }
// Update is called once per frame void Update() { if (dw.pollDepth()) { Tw = terr.terrainData.heightmapWidth; Th = terr.terrainData.heightmapHeight; heights = terr.terrainData.GetHeights(0, 0, Tw, Th); //normalize, then extreme noise filter for (int ii = 0; ii < 320 * 240; ii++) { //get x and y coords int x = ii % 320; int y = ii / 320; float b = dw.depthImg[ii]; b = b / 7800; b = 1 - b; if (b > 0.7F) { heights[y, x] = 0; } else { heights[y, x] = b; } } //temporal filter, and set scene to modify terrain one every second if (Time.time - startTime < numSec) { if (count == 0) { tempHeights = (float[, ])heights.Clone(); } else { for (int Ty = 0; Ty < Th; Ty++) { for (int Tx = 0; Tx < Tw; Tx++) { tempHeights[Tx, Ty] += heights[Tx, Ty]; } } } count++; } else { factor = 1.0F / count; for (int Ty = 0; Ty < Th; Ty++) { for (int Tx = 0; Tx < Tw; Tx++) { tempHeights[Tx, Ty] *= factor; } } tempHeights = smooth(tempHeights, new Vector2(Tw, Th)); //smoothing filter applied terr.terrainData.SetHeights(0, 0, tempHeights); //set the terrain to display the updated heightmap count = 0; startTime = Time.time; } } }