当前位置: 首页>>代码示例>>Python>>正文


Python Scene.loadObjModel方法代码示例

本文整理汇总了Python中scene.Scene.loadObjModel方法的典型用法代码示例。如果您正苦于以下问题:Python Scene.loadObjModel方法的具体用法?Python Scene.loadObjModel怎么用?Python Scene.loadObjModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在scene.Scene的用法示例。


在下文中一共展示了Scene.loadObjModel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from scene import Scene [as 别名]
# 或者: from scene.Scene import loadObjModel [as 别名]
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',
#.........这里部分代码省略.........
开发者ID:lscandolo,项目名称:PyOpenGL-Tests,代码行数:103,代码来源:display.py

示例2: main

# 需要导入模块: from scene import Scene [as 别名]
# 或者: from scene.Scene import loadObjModel [as 别名]
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()
开发者ID:lscandolo,项目名称:PyOpenGL-Tests,代码行数:100,代码来源:grass.py


注:本文中的scene.Scene.loadObjModel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。