コード例 #1
0
ファイル: prim_light.py プロジェクト: Tugcga/S-USD
def emit_sycles_light(app, light_name, usd_tfm, visibility, usd_prim, light_type, xsi_parent, up_key, ignore_tfm):
    xsi_light = None
    usd_light = None
    # cylinder light is not suported by cycles lighst
    if light_type == "RectLight":
        xsi_light = app.GetPrim("cyclesArea", light_name, xsi_parent)
        usd_light = UsdLux.RectLight(usd_prim)
        # set width and height
        set_import_parameter(app, xsi_light, "sizeU", usd_light.GetWidthAttr())
        set_import_parameter(app, xsi_light, "sizeV", usd_light.GetHeightAttr())
    elif light_type == "DiskLight":
        xsi_light = app.GetPrim("cyclesArea", light_name, xsi_parent)
        usd_light = UsdLux.DiskLight(usd_prim)
        xsi_light.Parameters("shape").Value = 1
        set_import_parameter(app, xsi_light, "sizeU", usd_light.GetRadiusAttr())
        set_import_parameter(app, xsi_light, "sizeV", usd_light.GetRadiusAttr())
    elif light_type == "LightPortal":
        xsi_light = app.GetPrim("cyclesArea", light_name, xsi_parent)
        usd_light = UsdLux.LightPortal(usd_prim)
        xsi_light.Parameters("is_portal").Value = True
    elif light_type == "SphereLight":
        xsi_light = app.GetPrim("cyclesPoint", light_name, xsi_parent)
        usd_light = UsdLux.SphereLight(usd_prim)
        set_import_parameter(app, xsi_light, "size", usd_light.GetRadiusAttr())
    elif light_type == "DistantLight":
        xsi_light = app.GetPrim("cyclesSun", light_name, xsi_parent)
        usd_light = UsdLux.DistantLight(usd_prim)
        set_import_parameter(app, xsi_light, "angle", usd_light.GetAngleAttr())
    elif light_type == "DomeLight":
        xsi_light = app.GetPrim("cyclesBackground", light_name, xsi_parent)
        usd_light = UsdLux.DomeLight(usd_prim)
    if xsi_light is not None:
        # set transform
        utils.set_xsi_transform(app, xsi_light, usd_tfm, up_key=up_key, add_tfm=usd_light.GetLocalTransformation())
        utils.set_xsi_visibility(xsi_light, visibility)

        # for all lights (except dome light and portal) we can set diffuse, specular, intensity
        if usd_light is not None and light_type != "DomeLight" and light_type != "LightPortal":
            set_import_parameter(app, xsi_light, "use_diffuse", usd_light.GetDiffuseAttr())
            set_import_parameter(app, xsi_light, "use_glossy", usd_light.GetSpecularAttr())
            set_import_parameter(app, xsi_light, "power", usd_light.CreateIntensityAttr())

    return xsi_light
コード例 #2
0
ファイル: testUsdExportRfMLight.py プロジェクト: yjang/USD
    def _ValidateDiskLightXformAnimation(self):
        lightPrimPath = '/RfMLightsTest/Lights/DiskLight'
        lightPrim = self._stage.GetPrimAtPath(lightPrimPath)
        self.assertTrue(lightPrim)

        diskLight = UsdLux.DiskLight(lightPrim)
        self.assertTrue(diskLight)

        xformOps = diskLight.GetOrderedXformOps()
        self.assertEqual(len(xformOps), 1)

        translateOp = xformOps[0]

        self.assertEqual(translateOp.GetOpName(), 'xformOp:translate')
        self.assertEqual(translateOp.GetOpType(), UsdGeom.XformOp.TypeTranslate)

        for frame in xrange(int(self.START_TIMECODE), int(self.END_TIMECODE + 1.0)):
            expectedTranslation = Gf.Vec3d(1.0, float(frame), 1.0)
            self.assertTrue(
                Gf.IsClose(translateOp.Get(frame), expectedTranslation, 1e-6))
コード例 #3
0
ファイル: prim_light.py プロジェクト: Tugcga/S-USD
def emit_default_light(app, light_name, usd_tfm, visibility, usd_prim, light_type, xsi_parent, up_key, ignore_tfm):
    xsi_light = None
    if light_type == "DistantLight":
        xsi_light = app.GetPrimLight("Infinite.Preset", light_name, xsi_parent)
        usd_light = UsdLux.DistantLight(usd_prim)
        # for distance we set transform
        utils.set_xsi_transform(app, xsi_light, usd_tfm, up_key=up_key, add_tfm=usd_light.GetLocalTransformation())
        utils.set_xsi_visibility(xsi_light, visibility)
        # and diffuse and specular params
        set_import_diffuse_param(app, xsi_light, usd_light)
        set_import_specular_param(app, xsi_light, usd_light)
    else:  # all other lights are point lights
        if light_type in ["SphereLight", "RectLight", "DiskLight", "CylinderLight"]:  # portal and dome lights are not supported by default lights
            xsi_light = app.GetPrimLight("Point.Preset", light_name, xsi_parent)
            # cast ptim to light
            usd_light = UsdLux.SphereLight(usd_prim) if light_type == "SphereLight" else (UsdLux.RectLight(usd_prim) if light_type == "RectLight" else (UsdLux.DiskLight(usd_prim) if light_type == "DiskLight" else UsdLux.CylinderLight(usd_prim)))
            # set transform
            utils.set_xsi_transform(app, xsi_light, usd_tfm, up_key=up_key, add_tfm=usd_light.GetLocalTransformation())
            utils.set_xsi_visibility(xsi_light, visibility)
            # set diffuse and specular
            set_import_diffuse_param(app, xsi_light, usd_light)
            set_import_specular_param(app, xsi_light, usd_light)
            # enable area light
            xsi_light.Parameters("LightArea").Value = True
            set_import_light_geometry(app, xsi_light, usd_light, light_type)
    return xsi_light