Items with no label
3338 Discussões

Unity Wrapper C# - Get position of highest or lowest points of Depth

NSand5
Principiante
1.384 Visualizações

Camera Model D415

Firmware Version 05.11.06.250

Operating System & Version Windows 10

Platform PC

SDK Version2.latest

Language Unity c#

I am trying to get the in scene location (x,y,z) for the highest point/points from the depth points. My immediate goal is to assign a simple 3D object (cube) to the highest points and have them move as the as the position of the highest point changes realtime -> ie the Vector3 transform

 

I was planning on using something like this - which obviously wont work since the shader forces a vertex count. IS there a way to get the position of the points? or assign a cube to the highest point in the depth array?

using System.Collections; using System.Collections.Generic; using UnityEngine;   public class Zenith : MonoBehaviour { public MeshFilter RTMesh; public GameObject cube;   private Vector3[] verts; Vector3 TopVertex; // Start is called before the first frame update void Start() { }   // Update is called once per frame void Update() { verts = RTMesh.sharedMesh.vertices; TopVertex = new Vector3(0, float.NegativeInfinity, 0); for (int i = 0; i < verts.Length; i++) { Vector3 vect = transform.TransformPoint(verts[i]); if (vect.y > TopVertex.y) { TopVertex = vect; cube.transform.position = TopVertex; } } }   }

 

0 Kudos
1 Solução
MartyG
Colaborador honorário III
1.128 Visualizações

The ​RealSense GitHub, where you have also posted this question, is the best place to get advice on this subject. Good luck!

Ver solução na publicação original

2 Respostas
MartyG
Colaborador honorário III
1.129 Visualizações

The ​RealSense GitHub, where you have also posted this question, is the best place to get advice on this subject. Good luck!

NSand5
Principiante
1.128 Visualizações

Thank you MartyG. Already done.

Responder