コード例 #1
0
def get_collider_bvh(context, ivy):
    opt = ivy.ivy
    if opt.has_collider:
        # collider in ivy space returns theoretically the
        # correct mesh. But somehow rotations still mock
        # up the collsions.
        bm = collider_in_ivy_space(context, ivy)
        bvh = BVHTree()
        bvh = bvh.FromBMesh(bm)
        # from object does not take transforms into account
        #bvh = bvh.FromObject(context.scene.objects[opt.collider], context.scene)
        return bvh
    else:
        return None
コード例 #2
0
def setup_self(self, context):
    '''
    Setup:
    Set needed Values and prepare and store some data.
    '''
    self.curve = context.active_object
    groups = bpy.data.groups
    names = [n.strip() for n in self.leafgroupname.split(',')]
    self.dupli_groups = [groups[n] for n in names if n in groups]

    #printd(self.dupli_groups)
    seed(self.seed)
    noise.seed_set(self.seed)

    #this is only if the scripts are not together in a moduke
    #if 'curve_ivy_animated' in context.user_preferences.addons.keys():
    self.ivy_loaded = True
    #printd('Animated Ivy Addon loaded ok', self.ivy_loaded)
    self.ivyopt = self.curve.ivy
    #else:
    #self.ivy_loaded = False

    ### CHECK FOR COLLIDER
    selected = context.selected_objects
    if len(selected) == 2:
        collider = [ob for ob in selected if ob != self.curve][-1]
        collider.select = False
        if collider.type == 'MESH':
            bm = bmesh.new()
            bm.from_object(collider, context.scene)
            bm.transform(collider.matrix_world)
            bm.transform(self.curve.matrix_world.inverted())
            bvh = BVHTree()
            bvh = bvh.FromBMesh(bm)
            self.bvh = bvh
    else:
        self.bvh = None

    ### TAKE ANIMATION FROM GROWING IVY IF AVAILABLE
    if self.ivy_loaded:
        if self.ivyopt.added_as_ivy:  #was indeed intended as growing ivy
            if self.ivyopt.animated:
                print('taking animation from ivy')
                self.animated = self.ivyopt.animated
                self.start = self.ivyopt.start
                self.end = self.ivyopt.end

    #if no leafgroup found create simple leaf
    if not self.dupli_groups:
        pass