示例#1
0
def area_continue(context, op, considerFinish):
    o = context.object
    if not getWallFromEmpty(context, op, o):
        op.report({'ERROR'}, "To continue the area, select an EMPTY object belonging to the wall")
        return {'CANCELLED'}
    # get Blender area object
    areaObj = getAreaObject(context)
    # check we if empty has been already used for the area
    for m in areaObj.modifiers:
        if m.type == "HOOK" and m.object == o:
            used = True
            break
    else:
        used = False
    if used:
        if not considerFinish or len(areaObj.data.vertices)<3:
            op.report({'ERROR'}, "The area already has a vertex here, select another EMPTY object")
            return {'CANCELLED'}
        if considerFinish:
            area_finish(context, op)
    else:
        getAreaInstance(context, op).extend(o)
        context.scene.objects.active = o
        if not op._handle:
            # start drawing
示例#2
0
def area_begin(context, op):
    o = context.object
    if not getWallFromEmpty(context, op, o):
        op.report({'ERROR'}, "To begin an area, select an EMPTY object belonging to the wall")
        return {'CANCELLED'}
    # an area Blender object will be created in the following call
    getAreaInstance(context, op, o)
示例#3
0
 def invoke(self, context, event):
     o = context.object
     wall = getWallFromEmpty(context, self, o)
     if not wall:
         self.report({"ERROR"}, "To insert a door, select an EMPTY object located at a segment of the wall")
     self.o = o
     self.wall = wall
     
     context.window_manager.fileselect_add(self)
     return {"RUNNING_MODAL"}
示例#4
0
    def invoke(self, context, event):
        o = context.object
        wall = getWallFromEmpty(context, self, o)
        if not wall:
            self.report({"ERROR"}, "To insert a door, select an EMPTY object located at a segment of the wall")
        self.o = o
        self.wall = wall

        context.window_manager.fileselect_add(self)
        return {"RUNNING_MODAL"}
示例#5
0
 
 def execute(self, context):
     o = context.scene.objects.active
     area = None
     wall = getWallFromEmpty(context, self, o)
     if not wall:
         self.report({"ERROR"}, "To begin an area, select an EMPTY object belonging to the wall")
         return {'CANCELLED'}
     o = getAreaInstance(context, self).make(o, wall)
     if self.assignUv:
         area = getItem(context, self, o)
         area.assignUv()
     
     if self.createWalls:
         if not area:
             area = getItem(context, self, o)
         finish = FinFlat(context, self)
         finish.createFromArea(area)
         if self.assignUv:
             finish.assignUv()
     
     bpy.ops.object.select_all(action="DESELECT")
     makeActiveSelected(context, o)
示例#6
0
 def extend(self, empty):
     context = self.context
     
     # get Blender object for the area
     obj = getAreaObject(self.context)
     bm = getBmesh(obj)
     bm.verts.ensure_lookup_table()
     _vert = bm.verts[-1]
     
     # find the Blender object for the empty that controls the last created area vertex
     prevEmpty = obj.modifiers[obj["last"]].object
     
     # If empty and prevEmpty belong to the same wall,
     # check if we need to create in-between verts for the area,
     # i.e. empty and prevEmpty aren't adjacent
     inbetweens = []
     if empty.parent == prevEmpty.parent and empty["m"] == prevEmpty["m"]:
         wall = getWallFromEmpty(context, self.op, empty)
         if not (wall.getNext(empty) == prevEmpty or wall.getPrevious(empty) == prevEmpty):
             # find Blender empty objects for <wall>, located between empty and prevEmpty
             empties = []
             # first searching in the forward direction
             e = prevEmpty
             while True:
                 e = wall.getNext(e)
                 if e == empty or not e:
                     break
                 empties.append(e)
             
             isClosed = wall.isClosed()
             if isClosed:
                 # keep list of empties
                 _empties = empties
             
             if not e or isClosed:
                 # now try in the backward direction
                 empties = []
                 e = prevEmpty
                 while True:
                     e = wall.getPrevious(e)
                     if e == empty:
                         break
                     empties.append(e)
             # for the closed wall check whick path is shorter, in the forward or backward directions
             if isClosed and len(empties) > len(_empties): 
                 empties = _empties
             # finally, create area verts for EMTPYs
             for e in empties:
                 group = e["g"]
                 vert = bm.verts.new(self.getLocation(e))
                 assignGroupToVerts(obj, bm.verts.layers.deform[0], group, vert)
                 _vert = vert
                 inbetweens.append((e, group))
             
     group = empty["g"]
     obj["last"] = group
     vert = bm.verts.new(self.getLocation(empty))
     assignGroupToVerts(obj, bm.verts.layers.deform[0], group, vert)
     
     bm.to_mesh(obj.data)
     bm.free()
     
     # without scene.update() hook modifiers will not work correctly
     # this step is probably optional here, however it's required in AreaBegin.execute()
     context.scene.update()
     if inbetweens:
         for e,g in inbetweens:
             addHookModifier(obj, g, e, g)
     addHookModifier(obj, group, empty, group)
示例#7
0
 def getWallPart(self, o):
     parts = self.wallParts
     if not o["m"] in parts:
         parts[o["m"]] = getWallFromEmpty(None, None, o)
     return parts[o["m"]]