...
Code Block |
---|
# Get the "Torus01" object and its polygons and vertices # Define a null vector and get the standsstandard particle node "Container01" polygonObject = scene.getObject("Torus01") polygons = polygonObject.getFaces() vertices = polygonObject.getVertices() vertexPosition = Vector.new(0,0,0) container = scene.get_PB_Emitter("Container01") # Loop through every polygon and get its associated 3 vertices for polygon in polygons: vertexIndices = polygon.getIndices() vertex0 = vertices[vertexIndices[0]] vertex1 = vertices[vertexIndices[1]] vertex2 = vertices[vertexIndices[2]] # Get the 3 vertex positions vertex0Pos = vertex0.getPosition() vertex1Pos = vertex1.getPosition() vertex2Pos = vertex2.getPosition() # Add all position vectors and calculate the average position (=polygon's midpoint) vertexPosition = vertex0Pos + vertex1Pos + vertex2Pos vertexPosition.set(vertexPosition.x / 3, vertexPosition.y / 3, vertexPosition.z / 3) # Place a new particle at "vertexPosition" with velocity 0 container.addParticle(vertexPosition, Vector.new(0,0,0)) |