I am trying to experiment with a ball trying to deform a plane with 2 times subdivision. I am trying to get the vertex that is near the hit area of the ball, but after parousing through the API, I found out that there are currently no built-in methods for this (i.e. hitPolygon, hitVertex). I have Blender version 2.66. How can I possibly accomplish this?
This is checked as SOLVED already, but just in case. I believe you could get the polygons that are hit with KX_PolyProxy.collide. But somehow it won’t work. When the plane gets hit, all polygons have collide?? I don’t understand, but this should work:
move_z = 0.1
def deformVertices(mesh, polygon):
matId = polygon.getMaterialIndex()
for index in range(polygon.getNumVertex()):
vertex_index = polygon.getVertexIndex(index)
vertex = mesh.getVertex(matId, vertex_index)
vertex.z -= move_z
def deformMesh(cont):
if not cont.sensors[0].positive:
return
own = cont.owner
mesh = own.meshes[0]
for index in range(mesh.numPolygons):
polygon = mesh.getPolygon(index)
if polygon.collide:
deformVertices(mesh, polygon)
own.reinstancePhysicsMesh(own, mesh)
Edit: This module is attached to a Collision Sensor.