Esempio n. 1
0
def convert_axis(axis):
    l = []
    l.append(Spyder.Coordinate(0, 0, 0))
    l.append(Spyder.Coordinate(1, 0, 0))
    l.append(Spyder.Coordinate(0, 1, 0))
    l.append(Spyder.Coordinate(0, 0, 1))

    a = Spyder.AxisSystem()
    a.origin += (0.5, 0, 0)
    a.rotateY(-90)
    c = Spyder.Cylinder(0.2, 1, axis=a, material="red")
    l.append(c)
    a = Spyder.AxisSystem()
    a.origin += (0, 0.5, 0)
    a.rotateX(90)
    c = Spyder.Cylinder(0.2, 1, axis=a, material="green")
    l.append(c)
    a = Spyder.AxisSystem()
    a.origin += (0, 0, 0.5)
    c = Spyder.Cylinder(0.2, 1, axis=a, material="blue")
    l.append(c)

    og = Spyder.ObjectGroup3D(l, axis)

    return og
Esempio n. 2
0
def random_matrix_generator():
    while 1:
        a = Spyder.AxisSystem()
        a.rotateZ(360 * random())
        a.origin = Spyder.Coordinate(15 * random() - 7.5, 15 * random() - 7.5,
                                     0)
        yield dragonfly.scene.matrix(a, "AxisSystem")
Esempio n. 3
0
def show_object(obj):
    # only works for objects without face-specific materials
    #TODO: texturecoords

    cf = configure("scene")
    cf.start_block()
    cf.import_from_parentblock("materials")
    vertices = [(c.x, c.y, c.z) for c in obj.vertices]
    faces = [tuple(f.vertices) for f in obj.faces]
    normals = []
    for f in obj.faces:
        normal = f.normal
        if f.normal is None:
            verts = [obj.vertices[n] for n in f.vertices]
            normal = spyder.tarantula.calc_normal(verts)
        normals.append((normal.x, normal.y, normal.z))
    if obj.lighting == "flat":
        normals = None  ###
        cf.create_mesh_per_face("mesh", vertices, faces, normals, None, None, None, obj.material)
    else:
        vertexnormals = []
        for vnr in range(len(vertices)):
            avgnormal = Spyder.Coordinate(0, 0, 0)
            for fnr, f in enumerate(faces):
                if vnr in f: avgnormal += normals[fnr]
            avgnormal = avgnormal.normalize()
            vertexnormals.append((avgnormal.x, avgnormal.y, avgnormal.z))
        cf.create_mesh_per_vertex("mesh", vertices, vertexnormals, None, None, faces, obj.material)

    cf.add_model_SPYDER("mesh", "model", axissystem=obj.axis)
    cf.end_block()
    return cf
Esempio n. 4
0
class myscene(myspyderframe):
    a = Spyder.AxisSystem()
    a *= 0.25
    a.origin += (-8, 42, 0)
    env = Spyder.Model3D("models/environment", "egg", a)

    a = Spyder.AxisSystem()
    a *= 0.005
    mypanda = Spyder.Actor3D("models/panda-model", "egg", [("walk", "models/panda-walk4", "egg")], a,
                             entityname="mypanda")

    a = Spyder.AxisSystem()
    a *= 0.005
    pandaclass = Spyder.ActorClass3D("models/panda-model", "egg", [("walk", "models/panda-walk4", "egg")], a,
                                     actorclassname="pandaclass")

    box = Spyder.Box2D(50, 470, 96, 96)
    icon = Spyder.Icon("pandaicon.png", "pandaicon", box, transparency=True)

    c = Spyder.Coordinate(5, -3, 0)
    c2 = Spyder.Coordinate(-5, -3, 3)

    del a, box