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


Python Timer.tick方法代码示例

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


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

示例1: convert_model_data

# 需要导入模块: from utils import Timer [as 别名]
# 或者: from utils.Timer import tick [as 别名]
def convert_model_data(subpath):
    tm = Timer()
    fullpath = os.path.join(baseDir, subpath)

    objects = {}
    mtllib = None
    vertices = []
    texcoords = [[0, 0]]
    normals = []
    mtlBaseDir = os.path.split(fullpath)[0]

    lineID = 0
    for line in open(fullpath, "r"):
        lineID += 1
        # print lineID
        if line.startswith('#'): continue
        v = line.split()
        if not v: continue

        if v[0] == 'o' or v[0] == 'g':
            name = v[1].split('_')[0]
            obj = _Object(name)
            objects[obj.name] = obj
        elif v[0] == 'usemtl':
            materialName = v[1]
            obj.material = mtllib.get(materialName)
        elif v[0] == 'v':
            assert len(v) == 4
            v = map(float, v[1:4])
            vertices.append(v)
        elif v[0] == 'vn':
            assert len(v) == 4
            v = map(float, v[1:4])
            normals.append(v)
        elif v[0] == 'vt':
            assert len(v) == 3
            v = map(float, v[1:3])
            texcoords.append(v)
        elif v[0] == 'mtllib':
            mtllib = MaterialLib.load(os.path.realpath(
                os.path.join(mtlBaseDir, v[1])))
        elif v[0] == 'f':
            indices = v[1:]
            assert len(indices) == 3, 'please use triangle faces'
            # each index tuple: (v, t, n)
            for x in indices:
                x = x.split('/')
                vi, ti, ni = map(int, x)
                obj.vdata.extend(
                    texcoords[ti] + normals[ni-1] + vertices[vi-1])
    data = {
        'objects': objects,
        'mtllib': mtllib,
    }
    print 'convert {}, time: {}ms'.format(subpath, tm.tick())
    return data
开发者ID:ZhanruiLiang,项目名称:mirrorman,代码行数:58,代码来源:objReader.py

示例2: load_models

# 需要导入模块: from utils import Timer [as 别名]
# 或者: from utils.Timer import tick [as 别名]
def load_models():
    tm = Timer()
    if config.GZIP_LEVEL is not None:
        infile = gzip.open(config.DAT_PATH, 'rb', config.GZIP_LEVEL)
    else:
        infile = open(config.DAT_PATH, 'rb')
    # data = infile.read()
    modeldatas = cPickle.loads(infile.read())
    infile.close()
    print 'load dat time: {}ms'.format(tm.tick())
    for filepath, data in modeldatas.iteritems():
        models[filepath] = load_single(filepath, data)
开发者ID:ZhanruiLiang,项目名称:mirrorman,代码行数:14,代码来源:objReader.py

示例3: make_dat

# 需要导入模块: from utils import Timer [as 别名]
# 或者: from utils.Timer import tick [as 别名]
def make_dat():
    data = {}
    tm = Timer()
    for subpath in config.MODEL_SUBPATHS:
        if subpath.endswith(os.path.sep):
            for f in os.listdir(os.path.join(baseDir, subpath)):
                if extract_num(f) is not None:
                    fpath = os.path.join(subpath, f)
                    data[fpath] = convert_model_data(fpath)
                    # break # dummy
        else:
            data[subpath] = convert_model_data(subpath)
    print 'total convert time: {}ms'.format(tm.tick())
    if config.GZIP_LEVEL is not None:
        print 'compressing...'
        outf = gzip.open(config.DAT_PATH, 'wb', config.GZIP_LEVEL)
    else:
        print 'writing...'
        outf = open(config.DAT_PATH, 'wb')
    cPickle.dump(data, outf, -1)
    outf.close()
    print 'write {}, time: {}ms'.format(config.DAT_PATH, tm.tick())
开发者ID:ZhanruiLiang,项目名称:mirrorman,代码行数:24,代码来源:objReader.py

示例4: init

# 需要导入模块: from utils import Timer [as 别名]
# 或者: from utils.Timer import tick [as 别名]
def init():
    tm = Timer()
    global screen
    pygame.display.init()

    glutInit()

    screen = pygame.display.set_mode(config.SCREEN_SIZE, 
            pygame.HWSURFACE | pygame.OPENGL | pygame.DOUBLEBUF)

    glEnable(GL_DEPTH_TEST)
    glEnable(GL_RESCALE_NORMAL)
    glEnable(GL_TEXTURE_2D)

    glShadeModel(GL_SMOOTH)

    glClearColor(*config.BACK_COLOR)

    glLight(GL_LIGHT0, GL_AMBIENT, (.5, .5, .5, 1.))
    glLight(GL_LIGHT0, GL_DIFFUSE, (.8, .8, .8, 1.))
    glLight(GL_LIGHT0, GL_SPECULAR, (.5, .5, .5, 1.))
    glLightModelfv(GL_LIGHT_MODEL_AMBIENT, (.4, .4, .4, 1.))
    #if you want to adjust light intensity, edit here
    glLightf(GL_LIGHT0, GL_CONSTANT_ATTENUATION, .1)
    
    glEnable(GL_LIGHTING)
    glEnable(GL_LIGHT0)
    
    glLineWidth(1)
    glMatrixMode(GL_MODELVIEW)

    glEnableClientState(GL_VERTEX_ARRAY)
    glEnableClientState(GL_NORMAL_ARRAY)
    glEnableClientState(GL_TEXTURE_COORD_ARRAY)

    print 'Display init time:', tm.tick()
开发者ID:ZhanruiLiang,项目名称:mirrorman,代码行数:38,代码来源:display.py


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