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.
Mesh Objects are converted from Blender at scene load.
The Converter groups polygons by Material. A material holds:
The texture.
The Blender material.
The Tile properties
The face properties - (From the “Texture Face” panel)
Transparency & z sorting
Light layer
Polygon shape (triangle/quad)
Game Object
Vertices will be split by face if necessary. Vertices can only be shared between faces if:
They are at the same position
UV coordinates are the same
Their normals are the same (both polygons are “Set Smooth”)
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 objectfrom 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:
- getPolygon(index)
Gets the specified polygon from the mesh.
- Parameters:
index (integer) – polygon number
- Returns:
a polygon object.
- Return type: