コード例 #1
0
ファイル: runGilligan.py プロジェクト: zjingcong/eclipse
def RetrieveThingInWater(f):
    thing_in_water_path = os.path.join(
        ASSPATH, '{name}.{frame}.obj'.format(name=ASSNANE,
                                             frame=util.formattedFrame(f)))
    # thing_in_water_path = "../assets/toysubmarine/model/products/geom/0001/obj/lo/toysubmarine." + util.formattedFrame(f) +".obj"
    thing_in_water = poly.Polygonal('thing_in_water')
    thing_in_water.set('objpath', thing_in_water_path)
    thing_in_water.visible = False
    return thing_in_water
コード例 #2
0
ファイル: waveShape.py プロジェクト: zjingcong/eclipse
def sim(input_frange, wave_parms):
    beginJob()

    # thirsty.FPS = 30.0
    thirsty.FPS = 24.0
    timestep = 1.0/float( thirsty.FPS )
    frame_range = [4]
    # if len(sys.argv) > 1:
    #     import gilligan.thurston.frange as frange
    #     frame_range = frange.Frange( sys.argv[1] )

    import gilligan.thurston.frange as frange
    frame_range = frange.Frange(input_frange)

    thirsty.F = 1

    simscene = CreateWaterSims('scene3', wave_parms)
    simscene.set('frame', 'thirsty.F' )


    simscene.generate_object()

    # Need to assemble basewave from swell and pm
    merged_ocean = simmerge.WaveMerge('base_ocean')
    merged_ocean.add_wave( simscene.get_sim('swell_waves') )
    merged_ocean.add_wave( simscene.get_sim('small_waves') )
    merged_ocean.generate_object()
    merged_ocean.verbose = True

    ew = simscene.get_sim('thing_in_water_waves')
    sw = simscene.get_sim('swell_waves')
    pw = simscene.get_sim('small_waves')
    ew.verbose = True
    ew.set('surface_geom', merged_ocean)


    #
    #  Update ocean to current time
    #  including ewave interaction with ocean
    #

    frame_list = frame_range.frames

    for f in range(1,frame_range.end+1):
        LogIt(__file__, colors.color_magenta + "\n\n********************************** F R A M E  " + str(f) + " *****************************************\n" + colors.color_white)
        thirsty.F = int(f)
        LogIt(__file__, colors.color_yellow + "\n\n\tS I M U L A T I O N\n" + colors.color_white)
        merged_ocean.update(timestep)
        water_thing = RetrieveThingInWater(f)
        ew.set('height_source_geom', water_thing)
        ew.set('compute_height_source', True)
        ew.update(timestep)
        LogIt(__file__, colors.color_yellow + "\n\n\tS I M U L A T I O N   F I N I S H E D\n" + colors.color_white)
        if f in frame_list:
            if ew.verbose:
                # fname = "../products/ewave_sim/" + ew.label + "." + util.formattedFrame(f) + ".exr"
                fname = "sim/" + ew.label + "." + util.formattedFrame(f) + ".exr"
                fname = os.path.join(PRODUCTSPATH, fname)
                ew.write_displacement(fname)
                sw.write_displacement(os.path.join(PRODUCTSPATH, 'sim/swell_wave.{}.exr'.format(util.formattedFrame(f))))
                pw.write_displacement(os.path.join(PRODUCTSPATH, 'sim/small_wave.{}.exr'.format(util.formattedFrame(f))))


    #
    # ###############################
    # #
    # #  Render phase
    # #
    # ###############################
    #
    #         LogIt(__file__, colors.color_yellow + "\n\n\tR E N D E R\n" + colors.color_white)
    #         renderscene = scene.Scene('renderscene')
    #         renderscene.set('frame', 'thirsty.F' )
    #
    #
    #
    #
    # #
    # #  Camera placement wrt to ocean surface
    # #
    #         camera = CreateCamera( simscene.get_sim('swell_waves'), water_thing )
    #         camera.change_label('ocean_camera')
    #         renderscene.add_camera(camera)
    #
    #
    # #
    # #  Shaders for resuse
    # #
    #
    #         import gilligan.thurston.material as material
    #         import gilligan.ash.python.ashUtils as au
    # ###### PUSH ############
    #         push = material.PushToOutputStack()
    #
    # ###### ATMOSPHERE ############
    #         atmos_lapse_rate = 50.0  # 0.1 km
    #         atmos_bottom = [0,0,0 ]
    #         atmos_up = [0,1,0]
    #         # atmos_color = [ 5.0,5.0,5.0, 0 ]
    #         atmos_color = [5.0, 5.0, 5.0, 1]
    #         # atmos_atten = [ 0.00015, 0.00013, 0.00013, 0 ]  # medium haze
    #         atmos_atten = [0.00015, 0.00013, 0.00013, 1]  # medium haze
    #         atmosphere = material.PlanarAtmosphere('atmosphere')
    #         atmosphere.set('bottompoint', atmos_bottom)
    #         atmosphere.set('up', atmos_up)
    #         atmosphere.set('lapserate', atmos_lapse_rate)
    #         atmosphere.set('color', atmos_color)
    #         atmosphere.set('attenuation', atmos_atten)
    #
    # ###### WATER VOLUME ############
    #         watervolume_bottom = [0,0,0]
    #         watervolume_up = [0,1,0]
    #         watervolume_lapse_rate = 10000.0
    #         # watervolume_color = [0.0, 0.6 * 2.5, 1.1 * 2.5, 0]
    #         watervolume_color = [ 0.0, 0.6*2.5, 1.1*2.5, 1 ]
    #         # watervolume_atten = [0.35 / 3.0, 0.1 / 3.0, 0.1 / 3.0, ]
    #         watervolume_atten = [ 0.35/3.0,0.1/3.0,0.1/3.0, 1 ]
    #         watervolume = material.WaterVolume('water_volume')
    #         watervolume.set('up', watervolume_up)
    #         watervolume.set('color',watervolume_color)
    #         watervolume.set('attenuation',watervolume_atten)
    #
    #
    #
    # #
    # #   Set up scene elements
    # #
    #
    # # ###### SHIP ############
    # # #### Container Ship
    # #         con_ship_texture = au.Texture( "../assets/ship/products/mearsk_arun_scaled/geom/0001/obj/lo/MEARSK_ARUN_OBJ/SHIP.exr"  )
    # #         con_ship_color = material.TexturedSpectralColor('container_ship_textured_spectral_color')
    # #         con_ship_color.set("texture", con_ship_texture)
    # #         con_ship_mat = material.Material('container_ship_material')
    # #         con_ship_mat.add_shader( atmosphere )
    # #         con_ship_mat.add_shader( con_ship_color )
    # #         con_ship_mat.add_shader( push )
    # #         con_ship_path = "../assets/ship/products/mearsk_arun_scaled/geom/0001/obj/lo/con_ship.obj"
    # #         con_ship = poly.Polygonal('container_ship')
    # #         con_ship.set('objpath', con_ship_path)
    # #         con_ship.material = con_ship_mat
    # #         con_ship.visible = True
    # #         renderscene.add_geometry(con_ship)
    # # #### Containers
    # #         container_texture = au.Texture("../assets/ship/products/mearsk_arun_scaled/geom/0001/obj/lo/MEARSK_ARUN_OBJ/Cont1.exr"  )
    # #         container_color = material.TexturedSpectralColor('containers_textured_spectral_color')
    # #         container_color.set("texture", container_texture)
    # #         container_mat = material.Material('containers_material')
    # #         container_mat.add_shader( atmosphere )
    # #         container_mat.add_shader( container_color )
    # #         container_mat.add_shader( push )
    # #         container_path = "../assets/ship/products/mearsk_arun_scaled/geom/0001/obj/lo/containers.obj"
    # #         container = poly.Polygonal('containers')
    # #         container.set('objpath', container_path)
    # #         container.material = container_mat
    # #         container.visible = True
    # #         renderscene.add_geometry(container)
    #
    #
    # ###### GROUND PLANE ############
    # #
    # #  Material
    # #
    #         # groundplane_color = [0.7 * 2.5, 0.4 * 2.5, 0.3 * 2.5, 0]
    #         groundplane_color = [ 0.7*2.5, 0.4*2.5, 0.3*2.5, 1 ]
    #         groundplane_lambertian = material.SpectralConstant('ground_plane_spectral_constant')
    #         groundplane_lambertian.set("color", groundplane_color)
    #         groundplane_mat = material.Material('ground_plane_material')
    #         groundplane_mat.add_shader( atmosphere )
    #         groundplane_mat.add_shader( watervolume )
    #         groundplane_mat.add_shader( groundplane_lambertian )
    #         groundplane_mat.add_shader( push )
    # #
    # # Geometry
    # #
    #         groundplane_path = os.path.join(ASSPATH, "groundplane/products/groundplane/geom/0001/obj/lo/groundplane.obj")
    #         # groundplane_path = os.path.join("../assets/groundplane/products/groundplane/geom/0001/obj/lo/groundplane.obj"
    #         groundplane = poly.Polygonal('ground_plane')
    #         groundplane.set('objpath', groundplane_path)
    #         groundplane.material = groundplane_mat
    #         groundplane.visible = True
    #         renderscene.add_geometry(groundplane)
    #
    #
    #
    # ###### SKYDOME ############
    # #
    # #  Material
    # #
    #         skydome_texture_path = os.path.join(ASSPATH, "skydome/products/skyhdri/image/0001/exr/5000x2500/hdrmaps_com_free_052.exr")
    #         skydome_texture = au.Texture( skydome_texture_path )
    #         # skydome_texture = au.Texture( "../assets/skydome/products/skyhdri/image/0001/exr/5000x2500/hdrmaps_com_free_052.exr" )
    #         skydome_map = material.TexturedMap('skydome_texturedmap')
    #         skydome_map.set("texture", skydome_texture)
    #         skydome_mat = material.Material('skydome_material')
    #         skydome_mat.add_shader( atmosphere)
    #         skydome_mat.add_shader( skydome_map )
    #         skydome_mat.add_shader( push )
    # #
    # # Geometry
    # #
    #         skydome_path = os.path.join(ASSPATH, "skydome/products/skydome/geom/0001/obj/lo/skydome.obj")
    #         # skydome_path = "../assets/skydome/products/skydome/geom/0001/obj/lo/skydome.obj"
    #         skydome = poly.Polygonal('skydome')
    #         skydome.set('objpath', skydome_path)
    #         skydome.material = skydome_mat
    #         skydome.visible = True
    #         renderscene.add_geometry(skydome)
    #
    #
    #
    # ###### THING IN WATER ############
    # #
    # #  Material
    # #
    #         lambertiansamples = 1
    #         # tiw_color = [ 1.0, 1.0, 5.0/255.0, 0 ]
    #         tiw_color = [1.0, 0.0, 0.0, 0]
    #         thing_in_water_color = material.SpectralLambertian('thing_in_water_lambertian')
    #         thing_in_water_color.set("color",tiw_color)
    #         thing_in_water_color.set("samples",lambertiansamples)
    #         thing_in_water_mat = material.Material('thing_in_water_material')
    #         thing_in_water_mat.add_shader( atmosphere )
    #         thing_in_water_mat.add_shader( watervolume )
    #         thing_in_water_mat.add_shader( thing_in_water_color )
    #         thing_in_water_mat.add_shader( push )
    # #
    # # Geometry
    # #
    #         thing_in_water = RetrieveThingInWater(f)
    #         thing_in_water.material = thing_in_water_mat
    #         renderscene.add_geometry(thing_in_water)
    #
    #
    #
    # ###### OCEAN ############
    # #
    # #  Material
    # #
    #
    # ### whitecaps from ewave
    #         import gilligan.thurston.texture as texture
    #         whitecaptex = texture.ImageTexture()
    #         whitecaptex.set('image',ew.whitecap_map )
    #         dynamics_whitecaps = material.OceanProceduralWhitecaps("wake_whitecaps")
    #         dynamics_whitecaps.set('texture', whitecaptex )
    #         dynamics_whitecaps.set('llc',ew.get('whitecaps_llc'))
    #         dynamics_whitecaps.set('urc',ew.get('whitecaps_urc'))
    #         dynamics_whitecaps.set('asymmetry',0.0)
    #         dynamics_whitecaps.set('surface',ew)
    #
    #         ocean_fresnel = material.OceanSurface()
    #         ocean_fresnel.set("iorabove",1.0)
    #         ocean_fresnel.set("iorbelow",1.34)
    #         ocean_fresnel.set("glitterroughness",0.0)
    #         ocean_mat = material.Material('ocean_surface_material')
    #         ocean_mat.add_shader( atmosphere )
    #         ocean_mat.add_shader( watervolume )
    #         if ew.get('compute_whitecaps'):
    #             LogIt(__file__, "using ewave whitecaps")
    #             ocean_mat.add_shader(dynamics_whitecaps)
    #         ocean_mat.add_shader( ocean_fresnel )
    #         ocean_mat.add_shader( push )
    # #
    # # Geometry
    # #
    #         oceanmesh = simmesh.WaveLODMesh('ocean_lod_mesh')
    #         oceanmesh.set('basewavesurface', merged_ocean )
    #         oceanmesh.set('topwavesurface', ew )
    #         oceanmesh.set('frustumcagestart',[-20.0,20.0,-10.0])
    #         oceanmesh.set('frustumcageend',[-6000.0,6000.0,8000.0])
    #         # oceanmesh.set('frustumcageend', [-3000.0, 3000.0, 4000.0])
    #         oceanmesh.set('resolution',0.03)
    #         # oceanmesh.set('loddoubledistance',14.0)
    #         oceanmesh.set('loddoubledistance', 5.0)
    #         eye = camera.get('eye')
    #         oceanmesh.set('start',[ eye[0],eye[2] ])
    #         view = camera.get('view')
    #         viewdir = [ view[0] - eye[0], view[2]-eye[2] ]
    #         viewdirmag = math.sqrt( viewdir[0]*viewdir[0] + viewdir[1]*viewdir[1] )
    #         viewdir[0] = viewdir[0]/viewdirmag
    #         viewdir[1] = viewdir[1]/viewdirmag
    #         LogIt(__file__, "oceanmesh view direction: " + str(viewdir) )
    #         oceanmesh.set('rangedirection', viewdir )
    #         oceanmesh.generate_object()
    #         oceanmesh.update(timestep)
    #
    # # --------------------------------------------------
    #         # write out ocean mesh geometry
    #         # write_obj(filename)
    #         if WRITEOBJ:
    #             obj_filename = os.path.join(PRODUCTSPATH, 'oceanmesh/ocean_{name}.{frame}.obj'.format(name=PRODNAME, frame=util.formattedFrame(f)))
    #             oceanmesh.write_obj(obj_filename)
    # # --------------------------------------------------
    #
    #         ocean = gmesh.Mesh('ocean_surface_mesh')
    #         ocean.set('trimesh', oceanmesh  )
    #         ocean.material = ocean_mat
    #         ocean.visible = True
    # # update mesh data to prepare for rendering
    #         ocean.generate_object()
    #         oceanmesh.reset_object()
    # #need the ocean geometry for the watervolume shader
    #         watervolume.SetWaterSurface(ocean)
    #         renderscene.add_geometry(ocean)
    #
    #
    #
    #
    # ### show the scene parameters going into the render
    #         renderscene.print_parameters()
    #
    #
    # ###### RENDER THE SCENE ############
    #         image = cam.Image('ocean_image')
    #         image.set('width', 960)
    #         image.set('height', 540)
    #         import gilligan.thurston.render.maryann as maryann
    #         renderer = maryann.MaryAnn('surfswell_render')
    #         renderer.set('frame', 'thirsty.F')
    #         renderer.set('aasamples', 40)
    #         renderer.set('rayhits', 10)
    #         renderer.set('threads', 8)
    #         # image_name = "../products/images/surfswell_scene3_FPS" + str(int(thirsty.FPS)) + ".exr"
    #         image_name = os.path.join(PRODUCTSPATH, "images/{name}_FPS{fps}.exr".format(name=PRODNAME, fps=str(int(thirsty.FPS))))
    #         renderer.set('imagename', image_name)
    #         renderer.verbose = True
    #         renderer.generate_object()
    #         if renderer.render_scene( renderscene, renderscene.get_camera('ocean_camera'), image):
    #             cam.write_image_with_metadata( image)
    #         else:
    #             LogIt(__file__,"Not writing image to disk")
    #
    #         for g in renderscene.geometry:
    #             g.reset_object()
    #
    #         renderscene.clear()
    #
    #
    #         LogIt(__file__, colors.color_yellow + "\n\n\tR E N D E R   F I N I S H E D\n" + colors.color_white)

    endJob()
コード例 #3
0
def sim(input_frange, wave_parms):
    beginJob()

    # thirsty.FPS = 30.0
    thirsty.FPS = 24.0
    timestep = 1.0/float( thirsty.FPS )

    import gilligan.thurston.frange as frange
    frame_range = frange.Frange(input_frange)

    thirsty.F = 1

    simscene = CreateWaterSims('water shape', wave_parms)
    simscene.set('frame', 'thirsty.F' )


    simscene.generate_object()

    # Need to assemble basewave from swell and pm
    merged_ocean = simmerge.WaveMerge('base_ocean')
    merged_ocean.add_wave( simscene.get_sim('swell_waves') )
    merged_ocean.add_wave( simscene.get_sim('small_waves') )
    merged_ocean.generate_object()
    merged_ocean.verbose = True

    sw = simscene.get_sim('swell_waves')
    pw = simscene.get_sim('small_waves')

    #
    #  Update ocean to current time
    #

    frame_list = frame_range.frames

    for f in range(1,frame_range.end+1):
        LogIt(__file__, colors.color_magenta + "\n\n********************************** F R A M E  " + str(f) + " *****************************************\n" + colors.color_white)
        thirsty.F = int(f)
        merged_ocean.update(timestep)
        if f in frame_list:
            sw.write_displacement(os.path.join(PRODUCTSPATH, 'sim/{name}_swell_wave.{f}.exr'.format(name=PRODNAME, f=util.formattedFrame(f))))
            pw.write_displacement(os.path.join(PRODUCTSPATH, 'sim/{name}_small_wave.{f}.exr'.format(name=PRODNAME, f=util.formattedFrame(f))))

    endJob()
コード例 #4
0
ファイル: runGilligan.py プロジェクト: zjingcong/eclipse
        " *****************************************\n" + colors.color_white)
    thirsty.F = int(f)
    LogIt(
        __file__, colors.color_yellow + "\n\n\tS I M U L A T I O N\n" +
        colors.color_white)
    merged_ocean.update(timestep)
    water_thing = RetrieveThingInWater(f)
    ew.set('height_source_geom', water_thing)
    ew.set('compute_height_source', True)
    ew.update(timestep)
    LogIt(
        __file__, colors.color_yellow +
        "\n\n\tS I M U L A T I O N   F I N I S H E D\n" + colors.color_white)
    if f in frame_list:
        if ew.verbose:
            fname = "../products/ewave_sim/" + ew.label + "." + util.formattedFrame(
                f) + ".exr"
            ew.write_displacement(fname)

###############################
#
#  Render phase
#
###############################

        LogIt(__file__,
              colors.color_yellow + "\n\n\tR E N D E R\n" + colors.color_white)
        renderscene = scene.Scene('renderscene')
        renderscene.set('frame', 'thirsty.F')

        #
        #  Camera placement wrt to ocean surface