def create_image_plane(self, context, material):
    img = material.texture_slots[0].texture.image
    px, py = img.size

    # can't load data
    if px == 0 or py == 0:
        px = py = 1

    x = px / py
    y = 1.0

    if self.use_dimension:
        x = (px * (1.0 / self.factor)) * 0.5
        y = (py * (1.0 / self.factor)) * 0.5

    verts = (
        (-x, -y, 0.0),
        (+x, -y, 0.0),
        (+x, +y, 0.0),
        (-x, +y, 0.0),
    )
    faces = ((0, 1, 2, 3), )

    mesh_data = bpy.data.meshes.new(img.name)
    mesh_data.from_pydata(verts, [], faces)
    mesh_data.update()
    add_object_data(context, mesh_data, operator=self)
    plane = context.scene.objects.active
    plane.data.uv_textures.new()
    plane.data.materials.append(material)
    plane.data.uv_textures[0].data[0].image = img

    material.game_settings.use_backface_culling = False
    material.game_settings.alpha_blend = 'ALPHA'
    return plane
示例#2
0
def add_pyramid_object(self, context):
    verts, faces = makePyramid(self.initial_size, self.step_height, self.step_width, self.number_steps)

    mesh_data = bpy.data.meshes.new(name="Pyramid")
    mesh_data.from_pydata(verts, [], faces)
    mesh_data.update()
    res = add_object_data(context, mesh_data, operator=self)
示例#3
0
def add_object(self, context):
    scale_x = self.scale.x
    scale_y = self.scale.y

    verts = [Vector((-1 * scale_x, 1 * scale_y, 0)),
             Vector((1 * scale_x, 1 * scale_y, 0)),
             Vector((1 * scale_x, -1 * scale_y, 0)),
             Vector((-1 * scale_x, -1 * scale_y, 0)),
            ]

    edges = []
    faces = [[0, 1, 2, 3]]

    mesh_data = bpy.data.meshes.new(name='New Object Mesh')
    mesh_data.from_pydata(verts, edges, faces)
    add_object_data(context, mesh_data, operator=self)
示例#4
0
def add_pyramid_object(self, context):
    verts, faces = makePyramid(self.initial_size, self.step_height,
                               self.step_width, self.number_steps)

    mesh_data = bpy.data.meshes.new(name="Pyramid")
    mesh_data.from_pydata(verts, [], faces)
    mesh_data.update()
    res = add_object_data(context, mesh_data, operator=self)
def add_object(self, context):
    scale_x = self.scale.x
    scale_y = self.scale.y

    verts = [
        Vector((-1 * scale_x, 1 * scale_y, 0)),
        Vector((1 * scale_x, 1 * scale_y, 0)),
        Vector((1 * scale_x, -1 * scale_y, 0)),
        Vector((-1 * scale_x, -1 * scale_y, 0)),
    ]

    edges = []
    faces = [[0, 1, 2, 3]]

    mesh_data = bpy.data.meshes.new(name='New Object Mesh')
    mesh_data.from_pydata(verts, edges, faces)
    add_object_data(context, mesh_data, operator=self)
示例#6
0
def add_object(self, context):
    scale_x = self.scale.x
    scale_y = self.scale.y

    verts = [Vector((-1 * scale_x, 1 * scale_y, 0)),
             Vector((1 * scale_x, 1 * scale_y, 0)),
             Vector((1 * scale_x, -1 * scale_y, 0)),
             Vector((-1 * scale_x, -1 * scale_y, 0)),
            ]

    edges = []
    faces = [[0, 1, 2, 3]]

    mesh = bpy.data.meshes.new(name='New Object Mesh')
    mesh.from_pydata(verts, edges, faces)
    # useful for development when the mesh may be invalid.
    # mesh.validate(verbose=True)
    add_object_data(context, mesh, operator=self)
def add_object(self, context):
    fc = []
    vr = []
    kx = []
    mx = self.gen
    my = self.yuk
    k1 = self.kl1 / 100
    y = my * 4 + 4
    k2 = self.kl2 / 100
    k3 = self.fk / 200

    u = self.kl1 / 100
    X = [0, round(u, 2)]
    if mx > 0:
        u += self.gnx0 / 100
        X.append(round(u, 2))
        u += k2
        X.append(round(u, 2))
    if mx > 1:
        u += self.gnx1 / 100
        X.append(round(u, 2))
        u += k2
        X.append(round(u, 2))
    if mx > 2:
        u += self.gnx2 / 100
        X.append(round(u, 2))
        u += k2
        X.append(round(u, 2))
    if mx > 3:
        u += self.gnx3 / 100
        X.append(round(u, 2))
        u += k2
        X.append(round(u, 2))
    if mx > 4:
        u += self.gnx4 / 100
        X.append(round(u, 2))
        u += k2
        X.append(round(u, 2))
    if mx > 5:
        u += self.gnx5 / 100
        X.append(round(u, 2))
        u += k2
        X.append(round(u, 2))
    if mx > 6:
        u += self.gnx6 / 100
        X.append(round(u, 2))
        u += k2
        X.append(round(u, 2))
    if mx > 7:
        u += self.gnx7 / 100
        X.append(round(u, 2))
        u += k2
        X.append(round(u, 2))
    X[-1] = X[-2] + k1

    u = self.kl1 / 100
    Z = [0, round(u, 2)]
    if my > 0:
        u += self.gny0 / 100
        Z.append(round(u, 2))
        u += k2
        Z.append(round(u, 2))
    if my > 1:
        u += self.gny1 / 100
        Z.append(round(u, 2))
        u += k2
        Z.append(round(u, 2))
    if my > 2:
        u += self.gny2 / 100
        Z.append(round(u, 2))
        u += k2
        Z.append(round(u, 2))
    if my > 3:
        u += self.gny3 / 100
        Z.append(round(u, 2))
        u += k2
        Z.append(round(u, 2))
    if my > 4:
        u += self.gny4 / 100
        Z.append(round(u, 2))
        u += k2
        Z.append(round(u, 2))
    Z[-1] = Z[-2] + k1

    u = X[-1] / 2

    kp = []
    kp.append(self.k00)
    kp.append(self.k10)
    kp.append(self.k20)
    kp.append(self.k30)
    kp.append(self.k40)
    kx.append(kp)
    kp = []
    kp.append(self.k01)
    kp.append(self.k11)
    kp.append(self.k21)
    kp.append(self.k31)
    kp.append(self.k41)
    kx.append(kp)
    kp = []
    kp.append(self.k02)
    kp.append(self.k12)
    kp.append(self.k22)
    kp.append(self.k32)
    kp.append(self.k42)
    kx.append(kp)
    kp = []
    kp.append(self.k03)
    kp.append(self.k13)
    kp.append(self.k23)
    kp.append(self.k33)
    kp.append(self.k43)
    kx.append(kp)
    kp = []
    kp.append(self.k04)
    kp.append(self.k14)
    kp.append(self.k24)
    kp.append(self.k34)
    kp.append(self.k44)
    kx.append(kp)
    kp = []
    kp.append(self.k05)
    kp.append(self.k15)
    kp.append(self.k25)
    kp.append(self.k35)
    kp.append(self.k45)
    kx.append(kp)
    kp = []
    kp.append(self.k06)
    kp.append(self.k16)
    kp.append(self.k26)
    kp.append(self.k36)
    kp.append(self.k46)
    kx.append(kp)
    kp = []
    kp.append(self.k07)
    kp.append(self.k17)
    kp.append(self.k27)
    kp.append(self.k37)
    kp.append(self.k47)
    kx.append(kp)
    cam = []
    mer = []

    for x in X:
        for z in Z:
            vr.append([x - u, -k1 / 2, z])
            vr.append([x - u, k1 / 2, z])
    for x in range(0, mx * 2 + 1):
        for z in range(0, my * 2 + 1):
            if x % 2 == 0:
                t = 0
                d = 0
            else:
                t = 1
                d = 1
            if z % 2 == 0:
                l = 0
                r = 0
            else:
                l = 1
                r = 1
            if z == 0: d = 1
            if z == my * 2: t = 1
            if x == 0: l = 1
            if x == mx * 2: r = 1
            if x % 2 == 0 or z % 2 == 0: kub(fc, y, z, x, l, r, t, d)
    #Bolme
    for x in range(0, mx * 2):
        for z in range(0, my * 2):
            if x % 2 == 1 and z % 2 == 1:
                d = Z[z]
                t = Z[z + 1]
                l = X[x] - u
                r = X[x + 1] - u
                ac = 0
                if kx[int(x / 2)][int(z / 2)] == True:
                    ac = k1 - 0.01
                    vr.append([l, k1 / 2 + ac, d])
                    vr.append([l, -k1 / 2 + ac, d])
                    vr.append([l + k1, k1 / 2 + ac, d + k1])
                    vr.append([l + k1, -k1 / 2 + ac, d + k1])
                    vr.append([r, k1 / 2 + ac, d])
                    vr.append([r, -k1 / 2 + ac, d])
                    vr.append([r - k1, k1 / 2 + ac, d + k1])
                    vr.append([r - k1, -k1 / 2 + ac, d + k1])
                    vr.append([r, k1 / 2 + ac, t])
                    vr.append([r, -k1 / 2 + ac, t])
                    vr.append([r - k1, k1 / 2 + ac, t - k1])
                    vr.append([r - k1, -k1 / 2 + ac, t - k1])
                    vr.append([l, k1 / 2 + ac, t])
                    vr.append([l, -k1 / 2 + ac, t])
                    vr.append([l + k1, k1 / 2 + ac, t - k1])
                    vr.append([l + k1, -k1 / 2 + ac, t - k1])
                    l += k1
                    r -= k1
                    d += k1
                    t -= k1
                    n = len(vr)
                    fc.append([n - 1, n - 2, n - 6, n - 5])
                    fc.append([n - 5, n - 6, n - 10, n - 9])
                    fc.append([n - 9, n - 10, n - 14, n - 13])
                    fc.append([n - 2, n - 1, n - 13, n - 14])
                    fc.append([n - 2, n - 4, n - 8, n - 6])
                    fc.append([n - 6, n - 8, n - 12, n - 10])
                    fc.append([n - 10, n - 12, n - 16, n - 14])
                    fc.append([n - 4, n - 2, n - 14, n - 16])
                    fc.append([n - 3, n - 1, n - 5, n - 7])
                    fc.append([n - 7, n - 5, n - 9, n - 11])
                    fc.append([n - 11, n - 9, n - 13, n - 15])
                    fc.append([n - 1, n - 3, n - 15, n - 13])
                    fc.append([n - 4, n - 3, n - 7, n - 8])
                    fc.append([n - 8, n - 7, n - 11, n - 12])
                    fc.append([n - 12, n - 11, n - 15, n - 16])
                    fc.append([n - 3, n - 4, n - 16, n - 15])
                #Fitil
                vr.append([l, k3 + ac, d])
                vr.append([l, -k3 + ac, d])
                vr.append([l + k3 * 2, k3 + ac, d + k3 * 2])
                vr.append([l + k3 * 2, -k3 + ac, d + k3 * 2])
                vr.append([r, k3 + ac, d])
                vr.append([r, -k3 + ac, d])
                vr.append([r - k3 * 2, k3 + ac, d + k3 * 2])
                vr.append([r - k3 * 2, -k3 + ac, d + k3 * 2])
                vr.append([r, k3 + ac, t])
                vr.append([r, -k3 + ac, t])
                vr.append([r - k3 * 2, k3 + ac, t - k3 * 2])
                vr.append([r - k3 * 2, -k3 + ac, t - k3 * 2])
                vr.append([l, k3 + ac, t])
                vr.append([l, -k3 + ac, t])
                vr.append([l + k3 * 2, k3 + ac, t - k3 * 2])
                vr.append([l + k3 * 2, -k3 + ac, t - k3 * 2])
                n = len(vr)
                fc.append([n - 1, n - 2, n - 6, n - 5])
                fc.append([n - 5, n - 6, n - 10, n - 9])
                fc.append([n - 9, n - 10, n - 14, n - 13])
                fc.append([n - 2, n - 1, n - 13, n - 14])
                fc.append([n - 2, n - 4, n - 8, n - 6])
                fc.append([n - 6, n - 8, n - 12, n - 10])
                fc.append([n - 10, n - 12, n - 16, n - 14])
                fc.append([n - 4, n - 2, n - 14, n - 16])
                fc.append([n - 3, n - 1, n - 5, n - 7])
                fc.append([n - 7, n - 5, n - 9, n - 11])
                fc.append([n - 11, n - 9, n - 13, n - 15])
                fc.append([n - 1, n - 3, n - 15, n - 13])
                #Cam
                vr.append([l + k3 * 2, 0.003 + ac, d + k3 * 2])
                vr.append([l + k3 * 2, -0.003 + ac, d + k3 * 2])
                vr.append([r - k3 * 2, 0.003 + ac, d + k3 * 2])
                vr.append([r - k3 * 2, -0.003 + ac, d + k3 * 2])
                vr.append([r - k3 * 2, 0.003 + ac, t - k3 * 2])
                vr.append([r - k3 * 2, -0.003 + ac, t - k3 * 2])
                vr.append([l + k3 * 2, 0.003 + ac, t - k3 * 2])
                vr.append([l + k3 * 2, -0.003 + ac, t - k3 * 2])
                n = len(vr)
                fc.append([n - 1, n - 3, n - 4, n - 2])
                fc.append([n - 3, n - 5, n - 6, n - 4])
                fc.append([n - 5, n - 7, n - 8, n - 6])
                fc.append([n - 7, n - 1, n - 2, n - 8])
                fc.append([n - 3, n - 1, n - 7, n - 5])
                fc.append([n - 2, n - 4, n - 6, n - 8])
                n = len(fc)
                cam.append(n - 1)
                cam.append(n - 2)
                cam.append(n - 3)
                cam.append(n - 4)
                cam.append(n - 5)
                cam.append(n - 6)
    #Mermer
    if self.mr == True:
        mrh = -self.mr1 / 100
        mrg = self.mr2 / 100
        mdv = (self.mr3 / 200) + mrg
        msv = -(mdv + (self.mr4 / 100))
        vr.append([-u, mdv, 0])
        vr.append([u, mdv, 0])
        vr.append([-u, msv, 0])
        vr.append([u, msv, 0])
        vr.append([-u, mdv, mrh])
        vr.append([u, mdv, mrh])
        vr.append([-u, msv, mrh])
        vr.append([u, msv, mrh])
        n = len(vr)
        fc.append([n - 1, n - 2, n - 4, n - 3])
        fc.append([n - 3, n - 4, n - 8, n - 7])
        fc.append([n - 6, n - 5, n - 7, n - 8])
        fc.append([n - 2, n - 1, n - 5, n - 6])
        fc.append([n - 4, n - 2, n - 6, n - 8])
        fc.append([n - 5, n - 1, n - 3, n - 7])
        n = len(fc)
        mer.append(n - 1)
        mer.append(n - 2)
        mer.append(n - 3)
        mer.append(n - 4)
        mer.append(n - 5)
        mer.append(n - 6)
#OBJE -----------------------------------------------------------
    mesh = bpy.data.meshes.new(name='Pencere')
    mesh.from_pydata(vr, [], fc)
    mesh.materials.append(MPVC())
    mesh.materials.append(MCam())
    mesh.materials.append(MMer())
    for i in cam:
        mesh.faces[i].material_index = 1
    for i in mer:
        mesh.faces[i].material_index = 2
    mesh.update(calc_edges=True)
    add_object_data(context, mesh, operator=self)
    if bpy.context.mode != 'EDIT_MESH':
        bpy.ops.object.editmode_toggle()
        bpy.ops.object.editmode_toggle()