KX_MeshProxy(EXP_Value)

base class — EXP_Value

class bge.types.KX_MeshProxy

A mesh object.

You can only read the vertex properties of a mesh object. In upbge 0.3+, KX_MeshProxy, KX_PolyProxy, and KX_VertexProxy are only a representation of the physics shape as it was when it was converted in BL_DataConversion. Previously this kind of meshes were used both for render and physics, but since 0.3+, it is only useful in limited cases. In most cases, bpy API should be used instead.

Note: The physics simulation doesn’t currently update KX_Mesh/Poly/VertexProxy.

  1. Mesh Objects are converted from Blender at scene load.

  2. The Converter groups polygons by Material. A material holds:

    1. The texture.

    2. The Blender material.

    3. The Tile properties

    4. The face properties - (From the “Texture Face” panel)

    5. Transparency & z sorting

    6. Light layer

    7. Polygon shape (triangle/quad)

    8. Game Object

  3. Vertices will be split by face if necessary. Vertices can only be shared between faces if:

    1. They are at the same position

    2. UV coordinates are the same

    3. Their normals are the same (both polygons are “Set Smooth”)

    4. They are the same color, for example: a cube has 24 vertices: 6 faces with 4 vertices per face.

The correct method of iterating over every KX_VertexProxy in a game object

from bge import logic

cont = logic.getCurrentController()
object = cont.owner

for mesh in object.meshes:
   for m_index in range(len(mesh.materials)):
      for v_index in range(mesh.getVertexArrayLength(m_index)):
         vertex = mesh.getVertex(m_index, v_index)
         # Do something with vertex here...
materials
Type:

list of KX_BlenderMaterial type

numPolygons
Type:

integer

numMaterials
Type:

integer

polygons

Returns the list of polygons of this mesh.

Type:

KX_PolyProxy list (read only)

getMaterialName(matid)

Gets the name of the specified material.

Parameters:

matid (integer) – the specified material.

Returns:

the attached material name.

Return type:

string

getTextureName(matid)

Gets the name of the specified material’s texture.

Parameters:

matid (integer) – the specified material

Returns:

the attached material’s texture name.

Return type:

string

getVertexArrayLength(matid)

Gets the length of the vertex array associated with the specified material.

There is one vertex array for each material.

Parameters:

matid (integer) – the specified material

Returns:

the number of vertices in the vertex array.

Return type:

integer

getVertex(matid, index)

Gets the specified vertex from the mesh object.

Parameters:
  • matid (integer) – the specified material

  • index (integer) – the index into the vertex array.

Returns:

a vertex object.

Return type:

KX_VertexProxy

getPolygon(index)

Gets the specified polygon from the mesh.

Parameters:

index (integer) – polygon number

Returns:

a polygon object.

Return type:

KX_PolyProxy