Obtain / Render edges of a 3D object

2

I have the following question regarding getting the positions of a particular edge of a 3D object.

Example, I have a track (car game) and I want to calculate, through a C # script, both sides of the track. See image:

I have the positions of all the vertices (which also exist in the center of the track), however I want the vertices that are only at the edge of the track.

Does anyone know which calculation to use?

    
asked by anonymous 12.03.2018 / 19:55

1 answer

0

With the data you provided, it seems impossible to solve the problem, however if the track has constant width (or you can know the width of the track at a particular vertex) there is a solution.

At each vertex you will check if there is any other vertex that is a distance from a track . Here is an example:

Vertices[] arrayVertices;
float larguraDaPista = 5;
for(int i = 0; i < arrayVertices.size(); i++){
    Vertice verticeATestar = arrayVertices[i];
    for(int j = i; j < arrayVertices.size(); j++){
        Vertice verticeParaComparar = arrayVertices[j];
        if (Vector3.Distance(verticeATestar, verticeParaComparar) == larguraDaPista){
        //São ambos limites
        }
    }
}
    
13.03.2018 / 09:20