track_target=o, spot_exponent=10, kq=0.1), camera.PositionalLight(pos=(-0.54,1.3,2.5), diffuse=(0.9,0,0,1)), camera.PositionalLight(pos=(1.6,1.3,2.7), diffuse=(0,0.9,0,1)), camera.PositionalLight(pos=(-2.7,1.7,0.3), diffuse=(0,0,0.9,1)), ]) for i in range(1,len(context.camera.lights)): context.camera.lights[i].debug = True batch = pyglet.graphics.Batch() color_group = graphics.ColorGroup((0.5,0.5,0.5,1.0)) objs = [] for x in range(-3, 4): for z in range(-3, 4): sphere = geom.Cube(0.7) geom.transform(sphere, (x * 1.23, 0, z * 1.23)) geom.get_vlist(sphere, batch, color_group) context.add_object(core.Object(batch)) print """ You should see a small grid of objects with some colored lights over it. You should be able to click on the bulb of a light to move it around. The white light is a spotlight which remains focussed on the object floating above the grid. """ while not w.has_exit: pyglet.clock.tick()
vshaders.append(shader.VertexShader(VERTEX_SHADER)) if opts.fshader: for f in opts.fshader.split(','): data = open(f).read() fs = shader.FragmentShader(data) fshaders.append(fs) print 'creating program with:', vshaders + fshaders program = shader.createProgram(*(vshaders + fshaders)) batch = pyglet.graphics.Batch() shader_group = shader.ShaderGroup(program) color_group1 = graphics.ColorGroup((0.0,1.0,1.0), parent=shader_group) sphere1 = geom.Sphere( radius=0.63 ) geom.transform(sphere1, (-0.93,0,0)) geom.get_vlist(sphere1, batch, color_group1) color_group2 = graphics.ColorGroup((0.0,1.0,0.0), parent=shader_group) sphere2 = geom.Sphere( radius=0.63 ) geom.transform(sphere2, (0,-0.93,0)) geom.get_vlist(sphere2, batch, color_group2) color_group3 = graphics.ColorGroup((1.0,0.0,0.0), parent=shader_group) sphere3 = geom.Sphere( radius=0.63 ) geom.transform(sphere3, (0,0.93,0)) geom.get_vlist(sphere3, batch, color_group3) color_group4 = graphics.ColorGroup((1.0,0.0,1.0), parent=shader_group) sphere4 = geom.Sphere( radius=0.63 ) geom.transform(sphere4, (0.93,0,0))