18 hours ago, Nypyren said:
I think you'd need to make a reference vector that is perpendicular to your navmesh edges, right (a "surface normal")? You could cross product two of your edges on the current cell. If you know they are always in a specific order, that means the cross product of edge[0] and edge[1] should be fairly consistent between cells.
If your navmesh is always flat (or nearly flat), the normals of all of your navmesh cells should be close to the same direction ("up"). It may be simpler to just always use "up" in this case to bypass having to compute the cross product of the cell's edges each time you need it.
Alternatively if the navmesh never changes, you could at the very least precompute the normal vector of each cell when it is created.
8 hours ago, lawnjelly said:
I don't know about anyone else, but it's still clear as mud about what you are trying to do. The angle between 2 cells of a navigation mesh? Cells have several things which could be a vector. The surface normal, edges, connections between centres etc. A diagram would be very useful here, and what are you intending to do with this 'angle'?
You're right; I think I could have given more informations. Here's what I have :
Each connection :
-
Cell
-
Other cell
-
Edge left vertex (counterclockwise according to the mesh's normal)
-
Edge right vertex (counterclockwise according to the mesh's normal)
Each cell :
-
Centroid
-
Normal
-
Connections
-
Vertices
Another important thing to note is that the navmesh is 3D and cyclic, meaning that the cells can form a cube where each cell has connections on all its 4 edges. This means that I cannot simply use the UP vector unfortunately.
I have a generated navigation mesh that is made of 3D and possibly cyclic cells. Each cell is an irregular convex polygon where all its vertices share a common plane. Thus, even though a cell is in 3D, it can be represented in 2D.
The navigation mesh is generated from an also generated dungeon. Because one only navigates inside the dungeon in our game, the navigation mesh is generated from the inside of the dungeon, meaning that all surfaces inside the cube are cells.
Having thought about it, I think the most useful way to compute the angle is using the normals. Useful in the sense that I am able to determine if the inclination is upwards or downwards according to the normal of the mesh that owns the connection. Two parallel normals and of the same direction should compute an angle of 0. An upwards inclination should be negative because of the reference n vector and a downwards inclination should be positive. In other words, the angle should be between [-π,π].
2 hours ago, alvaro said:
This thread is about defining angles in 3D with the features of these 2D angles I just described. Unfortunately, there is no notion of clockwise in 3D in general. It is very likely that the OP has a picture in mind that is essentially 2D (e.g., a floor), and what needs to be done is project to a plane and use the 2D definition.
I'm more an "image person" than a "word person" so that must be why it's kinda hard for me to explain my situation. The 2D picture I imagine in my head is a 2D plane projection where I see two connected cells from the side and thus they are visualized as a line. I see the normals of the two connected cells starting from their centroids. Also, both cells share a vertex (in 2D, an edge in 3D). What I need is the inclinations angle.
Here's a magnificient drawing made in Paint :