Skip to content

Instantly share code, notes, and snippets.

@IRCSS
Created May 20, 2020 09:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IRCSS/d59ed3a41cdf5aea852633d0d6190f6f to your computer and use it in GitHub Desktop.
Save IRCSS/d59ed3a41cdf5aea852633d0d6190f6f to your computer and use it in GitHub Desktop.
### creates a series of planes lined up along one axis. I use this as a basis for a particle system when
### I dont have access to compute shader or a cache friendly enviroment
import bpy
import bmesh
#mesh arrays
m_verts = []
m_faces = []
m_number_of_planes=900
m_distance_between_planes=1
for i in range(0, m_number_of_planes):
m_verts.append((i*m_distance_between_planes, -1.0, -1.0))
m_verts.append((i*m_distance_between_planes, -1.0, 1.0))
m_verts.append((i*m_distance_between_planes, 1.0, 1.0))
m_verts.append((i*m_distance_between_planes, 1.0, -1.0))
m_face_one=(i*4+0, i*4 +3, i*4 + 1)
m_face_two=(i*4+1, i*4 +3, i*4 + 2)
m_faces.append(m_face_one)
m_faces.append(m_face_two)
m_mesh = bpy.data.meshes.new("planes_lined_up")
m_object = bpy.data.objects.new(m_mesh.name,m_mesh)
m_scene = bpy.context.scene
bpy.context.collection.objects.link(m_object)
m_mesh.from_pydata(m_verts,[],m_faces)
m_mesh.update(calc_edges=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment