...
Get a torus object's polygons, store them in a list container, and print out their number:
Code Block | ||
---|---|---|
| ||
# Get the "Torus01" object and its polygons/faces polygonObject = scene.getObject("Torus01") polygons = polygonObject.getFaces() # Print out the "Torus01" node's number of polygons scene.message("Number of polygons: "+str(len(polygons))) |
...
Get a torus object's vertices, store them in a list container, and print out their number:
Code Block | ||
---|---|---|
| ||
# Get the "Torus01" object and its vertices polygonObject = scene.getObject("Torus01") vertices = polygonObject.getVertices() # Print out the "Torus01" node's number of vertices scene.message("Number of vertices: "+str(len(vertices))) |
...
Get a torus object's polygons, store them in a list container, and get the three vertices of each polygon. Then, calculate each polygon's midpoint and place a particle there:
Code Block | ||
---|---|---|
| ||
# Get the "Torus01" object, its faces, and vertices # Define a null position # Get the "Container01" node polygonObject = scene.getObject("Torus01") polygons = polygonObject.getFaces() vertices = polygonObject.getVertices() vertexPosition vertexPositions = Vector.new(0,0,0) container = scene.get_PB_Emitter("Container01") # Loop through the polygons for polygon in polygons: # Indices are the current polygon's vertices # Get the three individual vertices vertexIndices = polygon.getIndices() vertex0 = vertices[vertexIndices[0]] vertex1 = vertices[vertexIndices[1]] vertex2 = vertices[vertexIndices[2]] # Get the individual vertex positions vertex0Pos = vertex0.getPosition() vertex1Pos = vertex1.getPosition() vertex2Pos = vertex2.getPosition() vertexPositions # Add the three position vectors # Calculate the XYZ averages and apply them to the vertexPosition vector vertexPosition = vertex0Pos + vertex1Pos + vertex2Pos vertexPositionsvertexPosition.set(vertexPositionsvertexPosition.x / 3.0, vertexPositionsvertexPosition.y / 3.0, vertexPositionsvertexPosition.z / 3.0) # Add a particles at vertexPosition with velocity 0 container.addParticle(vertexPositionsvertexPosition, Vector.new(0,0,0)) |