def main(): scene = Scene() scene.screen.size = (800,600) startOpengl(scene.screen.size[0],scene.screen.size[1]) global main_program print 'Initializing main shaders' main_program = initShaders("shaders/3ds.vert", "shaders/3ds.frag", "shaders/detail-3ds.geom") global sec_program print 'Initializing secondary shaders' sec_program = initShaders("shaders/parallaxOcclusionSelfShadow.vert", "shaders/parallaxOcclusionSelfShadow.frag") scene.active_program = main_program # scene.active_program = initShaders("shaders/3ds.vert", "shaders/3ds.frag") # scene.active_program = initShaders("shaders/parallax.vert", "shaders/parallax.frag") # scene.active_program = initShaders("shaders/relief.vert", "shaders/relief.frag") scene.initShadowFB() # teapot_index = scene.loadObjModel('models/teapot.obj') # if teapot_index == None: # print 'Error loading model' # exit(-1) # teapot = scene.models[teapot_index] # for m in teapot.models: # m.material.ambient = vec4(1,0.2,0.2,1) # tm = m.material.texture1_map # nm = m.material.normal_map # hm = m.material.height_map # tm.name = 'textures/masonry_wall-texture.jpg' # hm.name = 'textures/masonry_wall-height_map.jpg' # nm.name = 'textures/masonry_wall-normal_map.jpg' # sc = 4 # tm.scale = (sc,sc) # hm.scale = (sc,sc) # nm.scale = (sc,sc) # tm.set = True # hm.set = True # nm.set = True # floor_index = scene.loadObjModel('models/floor.obj') floor_index = scene.loadObjModel('models/grid.obj') if floor_index == None: print 'Error loading model' exit(-1) floor = scene.models[floor_index] floor.props.pos = vec3(0,-0.5,3) floor.props.scale = vec3(1) for m in floor.models: m.material.bump_height = 0.015 m.material.ambient = vec4(0.8,0.8,1,1) m.material.shininess = 0 tm = m.material.texture1_map nm = m.material.normal_map hm = m.material.height_map # tm.name = 'textures/grass-texture.jpg' tm.name = 'textures/masonry_wall-texture.jpg' hm.name = 'textures/masonry_wall-height_map.jpg' # hm.name = 'textures/heightmap1-1024.jpg' # nm.name = 'textures/masonry_wall-normal_map.jpg' # tm.name = 'textures/brickwork-texture.jpg' # hm.name = 'textures/brickwork-height_map.jpg' # nm.name = 'textures/brickwork-normal_map.jpg' sc = 0.5 tm.scale = (sc,sc) hm.scale = (sc,sc) nm.scale = (sc,sc) tm.set = True hm.set = True nm.set = False # sm = m.material.shininess_map # sm.name = 'textures/brickwork-bump_map.jpg' # sm.scale = (sc,sc) # sm.set = True # rm = m.material.reflection_map # rm.set_textures('textures/cubemap/sky_x_pos.jpg', # 'textures/cubemap/sky_x_neg.jpg', # 'textures/cubemap/sky_y_pos.jpg', # 'textures/cubemap/sky_y_neg.jpg', # 'textures/cubemap/sky_z_pos.jpg', # 'textures/cubemap/sky_z_neg.jpg') # rm.set = True scene.initCubemap('textures/cubemap/sky_x_pos.jpg', 'textures/cubemap/sky_x_neg.jpg', 'textures/cubemap/sky_y_pos.jpg', 'textures/cubemap/sky_y_neg.jpg', 'textures/cubemap/sky_z_pos.jpg', 'textures/cubemap/sky_z_neg.jpg') scene.loadModelTextures() scene.cam.pos = vec3(0.,1,3.) scene.lights.ambient.intensity = 0.6 # spot_light = scene.lights.new_spot_light() # spot_light.pos = vec3(0,5,0) # spot_light.dir = vec3(0,-1,0).normalize() # spot_light.reach = 10 # spot_light.dist_dimming = 0.5 # spot_light.ang_dimming = 0.5 # spot_light.color = vec3(1,1,1) spot_light = scene.new_spot_light() spot_light.pos = vec3(0,10,10) spot_light.dir = vec3(0,-1,-1).normalize() spot_light.reach = 40 spot_light.dist_dimming = 0.2 spot_light.ang_dimming = 0.2 spot_light.color = vec3(1,1,1) glutDisplayFunc(lambda : scene.drawScene()) glutIdleFunc(lambda : scene.drawScene()) glutReshapeFunc(lambda w,h: reshape(w,h,scene)) glutKeyboardFunc(lambda key,x,y : keyPressed(key,x,y,scene)) glutMotionFunc(lambda x,y : mouseFunc(x,y,scene)) # glutPassiveMotionFunc(lambda x,y : mouseFunc(x,y,scene,screen_size)) glutWarpPointer(250,250) glutMouseFunc glutMainLoop()
def main(): scene = Scene() scene.screen.size = (800, 600) startOpengl(scene.screen.size[0], scene.screen.size[1]) global main_program print 'Initializing main shaders' main_program = initShaders("shaders/3ds.vert", "shaders/3ds.frag", "shaders/detail-3ds.geom") global sec_program print 'Initializing secondary shaders' sec_program = initShaders("shaders/parallaxOcclusionSelfShadow.vert", "shaders/parallaxOcclusionSelfShadow.frag") scene.active_program = main_program # scene.active_program = initShaders("shaders/3ds.vert", "shaders/3ds.frag") # scene.active_program = initShaders("shaders/parallax.vert", "shaders/parallax.frag") # scene.active_program = initShaders("shaders/relief.vert", "shaders/relief.frag") scene.initShadowFB() # teapot_index = scene.loadObjModel('models/teapot.obj') # if teapot_index == None: # print 'Error loading model' # exit(-1) # teapot = scene.models[teapot_index] # for m in teapot.models: # m.material.ambient = vec4(1,0.2,0.2,1) # tm = m.material.texture1_map # nm = m.material.normal_map # hm = m.material.height_map # tm.name = 'textures/masonry_wall-texture.jpg' # hm.name = 'textures/masonry_wall-height_map.jpg' # nm.name = 'textures/masonry_wall-normal_map.jpg' # sc = 4 # tm.scale = (sc,sc) # hm.scale = (sc,sc) # nm.scale = (sc,sc) # tm.set = True # hm.set = True # nm.set = True # floor_index = scene.loadObjModel('models/floor.obj') floor_index = scene.loadObjModel('models/grid.obj') if floor_index == None: print 'Error loading model' exit(-1) floor = scene.models[floor_index] floor.props.pos = vec3(0, -0.5, 3) floor.props.scale = vec3(1) for m in floor.models: m.material.bump_height = 0.015 m.material.ambient = vec4(0.8, 0.8, 1, 1) m.material.shininess = 0 tm = m.material.texture1_map nm = m.material.normal_map hm = m.material.height_map # tm.name = 'textures/grass-texture.jpg' tm.name = 'textures/masonry_wall-texture.jpg' hm.name = 'textures/masonry_wall-height_map.jpg' # hm.name = 'textures/heightmap1-1024.jpg' # nm.name = 'textures/masonry_wall-normal_map.jpg' # tm.name = 'textures/brickwork-texture.jpg' # hm.name = 'textures/brickwork-height_map.jpg' # nm.name = 'textures/brickwork-normal_map.jpg' sc = 0.5 tm.scale = (sc, sc) hm.scale = (sc, sc) nm.scale = (sc, sc) tm.set = True hm.set = True nm.set = False # sm = m.material.shininess_map # sm.name = 'textures/brickwork-bump_map.jpg' # sm.scale = (sc,sc) # sm.set = True # rm = m.material.reflection_map # rm.set_textures('textures/cubemap/sky_x_pos.jpg', # 'textures/cubemap/sky_x_neg.jpg', # 'textures/cubemap/sky_y_pos.jpg', # 'textures/cubemap/sky_y_neg.jpg', # 'textures/cubemap/sky_z_pos.jpg', # 'textures/cubemap/sky_z_neg.jpg') # rm.set = True scene.initCubemap('textures/cubemap/sky_x_pos.jpg', 'textures/cubemap/sky_x_neg.jpg', 'textures/cubemap/sky_y_pos.jpg', 'textures/cubemap/sky_y_neg.jpg', 'textures/cubemap/sky_z_pos.jpg', 'textures/cubemap/sky_z_neg.jpg') scene.loadModelTextures() scene.cam.pos = vec3(0., 1, 3.) scene.lights.ambient.intensity = 0.6 # spot_light = scene.lights.new_spot_light() # spot_light.pos = vec3(0,5,0) # spot_light.dir = vec3(0,-1,0).normalize() # spot_light.reach = 10 # spot_light.dist_dimming = 0.5 # spot_light.ang_dimming = 0.5 # spot_light.color = vec3(1,1,1) spot_light = scene.new_spot_light() spot_light.pos = vec3(0, 10, 10) spot_light.dir = vec3(0, -1, -1).normalize() spot_light.reach = 40 spot_light.dist_dimming = 0.2 spot_light.ang_dimming = 0.2 spot_light.color = vec3(1, 1, 1) glutDisplayFunc(lambda: scene.drawScene()) glutIdleFunc(lambda: scene.drawScene()) glutReshapeFunc(lambda w, h: reshape(w, h, scene)) glutKeyboardFunc(lambda key, x, y: keyPressed(key, x, y, scene)) glutMotionFunc(lambda x, y: mouseFunc(x, y, scene)) # glutPassiveMotionFunc(lambda x,y : mouseFunc(x,y,scene,screen_size)) glutWarpPointer(250, 250) glutMouseFunc glutMainLoop()
def main(): screen_size = startOpengl() program = initShaders("shaders/grass.vert", "shaders/grass.frag") scene = Scene() scene.active_program = program model_index = scene.loadObjModel('models/floor.obj') if model_index == None: print 'Error loading model' exit(-1) model = scene.models[model_index] model.props.pos = vec3(0,-0.5,3) model.props.scale = vec3(1) for m in model.models: m.material.bump_height = 0.05 tm = m.material.texture1_map nm = m.material.normal_map hm = m.material.height_map # tm.name = 'textures/uvmap.png' tm.mag_filter = GL_NEAREST tm.min_filter = GL_NEAREST_MIPMAP_NEAREST nm.mag_filter = GL_NEAREST nm.min_filter = GL_NEAREST_MIPMAP_NEAREST hm.mag_filter = GL_NEAREST hm.min_filter = GL_NEAREST_MIPMAP_NEAREST tm.name = 'textures/grass-texture.jpg' hm.name = 'textures/grass-height_map.jpg' nm.name = 'textures/grass-height_map.jpg' # hm.name = 'textures/height_example.jpg' # nm.name = 'textures/height_example.jpg' # tm.name = 'textures/brickwork-texture.jpg' # hm.name = 'textures/brickwork-height_map.jpg' # nm.name = 'textures/brickwork-normal_map.jpg' # tm.name = 'textures/masonry_wall-texture.jpg' # hm.name = 'textures/masonry_wall-height_map.jpg' # nm.name = 'textures/masonry_wall-normal_map.jpg' sc = 20 tm.scale = (sc,sc) hm.scale = (sc,sc) nm.scale = (sc,sc) tm.set = True hm.set = True nm.set = True # sm = m.material.shininess_map # sm.name = 'textures/brickwork-bump_map.jpg' # sm.scale = (sc,sc) # sm.set = True # rm = m.material.reflection_map # rm.set_textures('textures/cubemap/sky_x_pos.jpg', # 'textures/cubemap/sky_x_neg.jpg', # 'textures/cubemap/sky_y_pos.jpg', # 'textures/cubemap/sky_y_neg.jpg', # 'textures/cubemap/sky_z_pos.jpg', # 'textures/cubemap/sky_z_neg.jpg') # rm.set = True scene.initCubemap('textures/cubemap/sky_x_pos.jpg', 'textures/cubemap/sky_x_neg.jpg', 'textures/cubemap/sky_y_pos.jpg', 'textures/cubemap/sky_y_neg.jpg', 'textures/cubemap/sky_z_pos.jpg', 'textures/cubemap/sky_z_neg.jpg') scene.loadModelTextures() scene.cam.pos = vec3(0.,0.,3) screen = Screen() screen.size = screen_size glutDisplayFunc(lambda : drawScene(scene)) glutIdleFunc(lambda : drawScene(scene)) glutReshapeFunc(lambda w,h: reshape(w,h,screen)) glutKeyboardFunc(lambda key,x,y : keyPressed(key,x,y,scene)) glutMotionFunc(lambda x,y : mouseFunc(x,y,scene,screen)) # glutPassiveMotionFunc(lambda x,y : mouseFunc(x,y,scene,screen_size)) glutWarpPointer(250,250) glutMouseFunc glutMainLoop()
def main(): screen_size = startOpengl() program = initShaders("shaders/grass.vert", "shaders/grass.frag") scene = Scene() scene.active_program = program model_index = scene.loadObjModel('models/floor.obj') if model_index == None: print 'Error loading model' exit(-1) model = scene.models[model_index] model.props.pos = vec3(0, -0.5, 3) model.props.scale = vec3(1) for m in model.models: m.material.bump_height = 0.05 tm = m.material.texture1_map nm = m.material.normal_map hm = m.material.height_map # tm.name = 'textures/uvmap.png' tm.mag_filter = GL_NEAREST tm.min_filter = GL_NEAREST_MIPMAP_NEAREST nm.mag_filter = GL_NEAREST nm.min_filter = GL_NEAREST_MIPMAP_NEAREST hm.mag_filter = GL_NEAREST hm.min_filter = GL_NEAREST_MIPMAP_NEAREST tm.name = 'textures/grass-texture.jpg' hm.name = 'textures/grass-height_map.jpg' nm.name = 'textures/grass-height_map.jpg' # hm.name = 'textures/height_example.jpg' # nm.name = 'textures/height_example.jpg' # tm.name = 'textures/brickwork-texture.jpg' # hm.name = 'textures/brickwork-height_map.jpg' # nm.name = 'textures/brickwork-normal_map.jpg' # tm.name = 'textures/masonry_wall-texture.jpg' # hm.name = 'textures/masonry_wall-height_map.jpg' # nm.name = 'textures/masonry_wall-normal_map.jpg' sc = 20 tm.scale = (sc, sc) hm.scale = (sc, sc) nm.scale = (sc, sc) tm.set = True hm.set = True nm.set = True # sm = m.material.shininess_map # sm.name = 'textures/brickwork-bump_map.jpg' # sm.scale = (sc,sc) # sm.set = True # rm = m.material.reflection_map # rm.set_textures('textures/cubemap/sky_x_pos.jpg', # 'textures/cubemap/sky_x_neg.jpg', # 'textures/cubemap/sky_y_pos.jpg', # 'textures/cubemap/sky_y_neg.jpg', # 'textures/cubemap/sky_z_pos.jpg', # 'textures/cubemap/sky_z_neg.jpg') # rm.set = True scene.initCubemap('textures/cubemap/sky_x_pos.jpg', 'textures/cubemap/sky_x_neg.jpg', 'textures/cubemap/sky_y_pos.jpg', 'textures/cubemap/sky_y_neg.jpg', 'textures/cubemap/sky_z_pos.jpg', 'textures/cubemap/sky_z_neg.jpg') scene.loadModelTextures() scene.cam.pos = vec3(0., 0., 3) screen = Screen() screen.size = screen_size glutDisplayFunc(lambda: drawScene(scene)) glutIdleFunc(lambda: drawScene(scene)) glutReshapeFunc(lambda w, h: reshape(w, h, screen)) glutKeyboardFunc(lambda key, x, y: keyPressed(key, x, y, scene)) glutMotionFunc(lambda x, y: mouseFunc(x, y, scene, screen)) # glutPassiveMotionFunc(lambda x,y : mouseFunc(x,y,scene,screen_size)) glutWarpPointer(250, 250) glutMouseFunc glutMainLoop()