Exemplo n.º 1
0
def cmd_shop(shop, shaderstring, shoptype = soho.ShopTypeDefault):
    # Declare an old style shader
    shader = soho.processShader(shaderstring, ForceEmbedVex, False, shoptype)
    if len(shader[1]):
        print shader[1]
    soho.indent()
    print 'cmd_shop', shop, shader[0]
Exemplo n.º 2
0
def cmd_loadotl(otls, from_text_block=False):
    cmd = 'cmd_loadotl '
    if from_text_block:
        cmd += '-t '
    for l in otls:
        soho.indent()
        soho.printArray(cmd, [l], '\n')
Exemplo n.º 3
0
def _api_dtype_call(directive, dtype, paramset=None):
    soho.indent()
    print(directive, ' "', dtype, '"', sep='', end='')
    if paramset:
        for param in paramset:
            print(' ', sep='', end='')
            param.print_str()
    print()
Exemplo n.º 4
0
def cmd_textblock(name, value, encoding=None):
    soho.indent()
    if encoding:
        print 'cmd_textblock -e', encoding, name
    else:
        print 'cmd_textblock', name
    print value
    print 'cmd_endtext'
Exemplo n.º 5
0
def cmd_reset(light=True, obj=True, fog=True):
    options = ''
    if light:
        options += ' -l'
    if obj:
        options += ' -o'
    if fog:
        options += ' -f'
    soho.indent(-1, 'cmd_reset %s' % options)
Exemplo n.º 6
0
def cmd_propertyV(style, parmlist):
    if style:
        for parm in parmlist:
            soho.indent()
            parm.printValue('cmd_property %s %s ' % (style, parm.Key), '\n')
    else:
        for parm in parmlist:
            soho.indent()
            parm.printValue('cmd_property %s %s '%(parm.Style, parm.Key), '\n')
Exemplo n.º 7
0
def cmd_shader(style, name, orgshader, shoptype = soho.ShopTypeDefault):
    # Processing  the shader may generate VEX code or COP maps and
    # will return the value in the second element of the tuple.  This
    # should be printed before the shader string.
    shader = soho.processShader(orgshader, ForceEmbedVex, False, shoptype)
    if len(shader[1]):
        print shader[1]
    soho.indent()
    print 'cmd_property', style, name, shader[0]
Exemplo n.º 8
0
def cmd_bundle(bundle, node_paths):
    soho.indent()
    print 'cmd_bundlecreate', bundle
    soho.addBundleDependency(bundle)
    start = 0
    step = 100
    while len(node_paths) > start:
        end = start + step
        print 'cmd_bundleadd', bundle, " ".join(node_paths[start:end])
        start = end
Exemplo n.º 9
0
def cmd_makecubemap(path, suffixes):
    soho.indent()
    # When there are spaces in the path names, the quote protection for this
    # command can be incredibly difficult.
    sys.stdout.write('''python -c 'import os; os.system("isixpack''')
    for s in suffixes:
        sys.stdout.write(' \\"%s%s\\"' % (path, s))
    sys.stdout.write(''' \\"%s\\"")'\n''' % path);
    for s in suffixes:
        soho.indent()
        sys.stdout.write('cmd_unlink -f "%s%s"\n' % ( path, s))
Exemplo n.º 10
0
def cmd_image(filename, device="", options=""):
    soho.makeFilePathDirsIfEnabled(filename)
    args = []
    if device:
        args.append("-f")
        args.append(device)
    if options:
        options = ' ' + options
    args.append(filename)
    istr = soho.arrayToString('cmd_image ', args, options)
    soho.indent(1, istr, None)
Exemplo n.º 11
0
def _api_named_dtype_call(directive, name, output, dtype, paramset=None):
    soho.indent()
    print(directive,
          '"{name}" "{output}" "{dtype}"'.format(name=name,
                                                 output=output,
                                                 dtype=dtype),
          end='')
    if paramset:
        for param in paramset:
            print(' ', param.as_str(), sep='', end='')
    print()
Exemplo n.º 12
0
def cmd_prefilter(path, prefilter_path, filter, count, ratio):
    soho.indent()
    # Create a temporary file in the same directory as the original map
    pathsplit = os.path.split(path)
    args = [ '"%s" prefilter' % path,
             'photon_file "%s"' % path,
             'prefiltered_file "%s"' % prefilter_path,
             'count %d' % count,
             'filter %s' % filter,
             'ratio %f' % ratio
           ]
    filterargs = ' '.join(args)
    sys.stdout.write('cmd_pcfilter %s\n' % (filterargs))
Exemplo n.º 13
0
def cmd_procedural(bounds, proc, shoptype = soho.ShopTypeDefault):
    soho.indent()
    shader = soho.processShader(proc[0], ForceEmbedVex, False, shoptype)
    if len(shader[1]):
        print shader[1]
    if bounds[0] <= bounds[3]:
        soho.printArray('cmd_procedural -m ', bounds[0:3], '')
        soho.printArray(              ' -M ', bounds[3:6], ' '),
    else:
        sys.stdout.write('cmd_procedural ')
    sys.stdout.write(shader[0])
    sys.stdout.write('\n')
    print
Exemplo n.º 14
0
def WorldEnd():
    soho.indent(-1, "WorldEnd", PBRT_COMMENT)
Exemplo n.º 15
0
def Comment(msg):
    soho.indent()
    print("# ", msg)
Exemplo n.º 16
0
def _api_call_with_cmds(directive, *args):
    soho.indent()
    print(directive, end='')
    soho.printArray(' ', args, '\n', False)
Exemplo n.º 17
0
def _api_call_with_iter(directive, args):
    soho.indent()
    print(directive, end='')
    soho.printArray(' [ ', args, ' ]\n')
Exemplo n.º 18
0
def WorldBegin():
    soho.indent(1, 'WorldBegin', PBRT_COMMENT)
Exemplo n.º 19
0
def WorldEnd():
    soho.indent(-1, 'WorldEnd', PBRT_COMMENT)
Exemplo n.º 20
0
def ObjectBegin(name):
    soho.indent(1, 'ObjectBegin "%s"' % name, PBRT_COMMENT)
Exemplo n.º 21
0
def ObjectEnd():
    soho.indent(-1, 'ObjectEnd', PBRT_COMMENT)
Exemplo n.º 22
0
def AttributeBegin():
    soho.indent(1, 'AttributeBegin', PBRT_COMMENT)
Exemplo n.º 23
0
def AttributeEnd():
    soho.indent(-1, 'AttributeEnd', PBRT_COMMENT)
Exemplo n.º 24
0
def TransformEnd():
    soho.indent(-1, 'TransformEnd', PBRT_COMMENT)
Exemplo n.º 25
0
def TransformBegin():
    soho.indent(1, 'TransformBegin', PBRT_COMMENT)
Exemplo n.º 26
0
def _api_call_with_cmds(directive, *args):
    soho.indent()
    print(directive, end="")
    soho.printArray(" ", args, "\n", False)
Exemplo n.º 27
0
def Comment(msg):
    soho.indent()
    print('# ', msg)
Exemplo n.º 28
0
def _api_call_with_iter(directive, args):
    soho.indent()
    print(directive, end="")
    soho.printArray(" [ ", args, " ]\n")
Exemplo n.º 29
0
def _api_call(directive):
    soho.indent()
    print(directive)
Exemplo n.º 30
0
def render(cam, now):
    """Main render entry point"""

    start_time = time.time()

    # For now we will not be using wranglers
    wrangler = None

    header()

    for name, value in wrangle_options(cam, wrangler, now):
        api.Option(name, value)

    val = []
    if cam.evalString("pbrt_colorspace", now, val):
        api.ColorSpace(val[0])

    print()

    api.Film(*wrangle_film(cam, wrangler, now))
    api.Filter(*wrangle_filter(cam, wrangler, now))
    api.Sampler(*wrangle_sampler(cam, wrangler, now))
    api.Integrator(*wrangle_integrator(cam, wrangler, now))
    api.Accelerator(*wrangle_accelerator(cam, wrangler, now))

    print()

    # We will stash the global exterior in case they need
    # to be compared against later.
    # Pre WorldBegin Mediums can't have AttributeBlocks and thus
    # need to be output relative to the camera's space.
    exterior = wrangle_preworld_medium(cam, wrangler, now)
    if exterior:
        api.MediumInterface("", exterior)
        print()

    # wrangle_camera will output api.Transforms
    api.Comment(cam.getName())
    api.Camera(*wrangle_camera(cam, wrangler, now))

    # Stash the camera's shutter as the default.
    scene_state.shutter = cam.wrangleFloat(wrangler, "shutter", now,
                                           [scene_state.shutter])[0]

    print()

    output_transform_times(cam, now)

    api.WorldBegin()

    print()

    # Output Lights
    api.Comment("=" * 50)
    api.Comment("Light Definitions")
    for light in soho.objectList("objlist:light"):
        api.Comment(light.getName())
        with api.AttributeBlock():
            val = []
            if light.evalString("pbrt_colorspace", now, val):
                api.ColorSpace(val[0])
            wrangle_light(light, wrangler, now)
        print()

    print()
    scene_renderables(now)
    print()

    # This was previously an api.WorldEnd() which would have provided the deindent
    soho.indent(-1)
    footer(start_time)

    return