1
$\begingroup$

In the Blender Game Engine I need to know if two vertexes are connected by and edge. However, the mesh is made of polylines (segments), not polygons, thus I can not use KX_MeshProxy.getPolygon(index). How can I access this information? The mesh in the picture is not the one I use, it is just an example.

enter image description here

$\endgroup$

1 Answer 1

1
$\begingroup$

The BGE does not know edges. The BGE knows polygons (faces) which are defined by 3 or 4 vertices.

An edge in this context is a semantic interpretation of a line between two vertices. It does not exist as object nor is it used anywhere. The render engine simply does not need it.

You need to know in the BGE the faces do not necessarily share the same vertices even when in Blender it seams like that.

I can give you a general guideline:

  • Iterate over the polygons of the mesh.

  • A polygon has 3 or 4 vertices. An "virtual" edge are two consecutive vertices plus the edge between the last and the first vertex. You will get as many edges as the polygon has vertices

  • Now you should have all edges (with begin and end vertices) of all polygons.

  • You can match them to each other by comparing the vertex positions. Be aware edges have a direction. You need to consider the reverse of an edge when comparing.

$\endgroup$
8
  • $\begingroup$ My mesh has no faces, it is made of consecutive segments, but they never close up, thus they do not form any face. Does this mean that the mesh is ignored by the game engine? $\endgroup$ Commented Nov 9, 2016 at 16:44
  • 1
    $\begingroup$ If it is visible you get faces (as this is what you see). Otherwise you can try to access the vertices from the mesh via Python. If they are not there, you can't uses them. - just did a test - you need faces to get the vertices. $\endgroup$
    – Monster
    Commented Nov 10, 2016 at 7:57
  • $\begingroup$ It is interesting why you think you need this sort of object in your game. (there might be other ways to handle your situation). $\endgroup$
    – Monster
    Commented Nov 10, 2016 at 8:01
  • $\begingroup$ I use it as a graph for pathfinding. I can derive the graph from a mesh (one point of the graph for each face of the mesh) but this needs more calculation. $\endgroup$ Commented Nov 10, 2016 at 10:32
  • 1
    $\begingroup$ When you really want it inside the BGE I suggest to extrude all edges. This way you get faces that are loaded into the BGE. $\endgroup$
    – Monster
    Commented Nov 11, 2016 at 7:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .