Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import bpy
- import bmesh
- class SubdivisionModel:
- def __init__(self, vertices):
- self._vertices = vertices
- self._quads = []
- def subdivide(self):
- # A list of the new quads we will be creating. We will replace the old quads
- # with these when we're done
- newQuads = []
- # These data-structures will hold the intermediary vertices for edge midpoints
- # and face centers. We will need ready access to these after we generate them
- edgeMids = {}
- quadCtrList = []
- oldVertexCount = len(self._vertices)
- # STEP ONE: Generate face points
- # -----------------------------------------------------------
- for quadVerts in self._quads:
- polyCount = len(quadVerts)
- # create the center point
- ctr = vec3(0, 0, 0)
- for idx in quadVerts:
- ctr = ctr.add(self._vertices[idx])
- ctr = ctr.div_f(polyCount)
- centerIdx = self.addVertex(ctr)
- quadCtrList.append(centerIdx)
- cube = bpy.data.objects["Cube"]
- vertices = [v.co for v in cube.data.vertices]
- ss = SubdivisionModel(vertices=vertices)
- bm = bmesh.new()
- print(type(cube))
- cube.mode_set(mode="EDIT")
- cube.mode_set(mode="OBJECT")
- bm.free()
- # for _ in range(step_count):
- # ss.subdivide()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement