Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Get a torus object's polygons and get the three vertices of each polygon. Then, calculate each polygon's midpoint and place a particle there:

 

...

Code Block

...

languagepy
polygonObject   = scene.getObject("Torus01")

...


polygons        = polygonObject.getFaces()

...


vertices        = polygonObject.getVertices()
vertexPosition  

...

=

...

 Vector.new(0,0,0)

...

container       = scene.get_PB_Emitter("Container01")
 

...


for polygon in polygons:
    vertexIndices  = polygon.getIndices()

...


    vertex0        = vertices[vertexIndices[0]]

...


    vertex1        = vertices[vertexIndices[1]]

...


    vertex2        = vertices[vertexIndices[2]]
 
    vertex0Pos     

...

=

...

 vertex0.getPosition()

...


    vertex1Pos     = vertex1.getPosition()

...


    vertex2Pos     = vertex2.getPosition()
 

...

    vertexPosition = vertex0Pos + vertex1Pos + vertex2Pos
    vertexPosition.set(vertexPosition.

...

x /

...

 3, vertexPosition.

...

y /

...

 3, vertexPosition.

...

z /

...

 3)
 

...

    container.addParticle(vertexPosition, Vector.new(0,0,0))