https://docs.omniverse.nvidia.com/kit/docs/kit-manual/latest/api/pxr.html?highlight=lux#usdlux-module
Where is the documentation for UsdLux? I’d like to add a sphere light and set it’s location, but can’t figure out how to do so from the docs.
All I can do is scraped from examples, like:
distantLight = UsdLux.DomeLight.Define(stage, Sdf.Path("/DomeLight"))
distantLight.CreateIntensityAttr(500)
Hi,
I’ve implemented it as follow:
class Light:
def __init__(self, prim_path, simulationWorld, lightType, name, intensity, color, position, orientation):
self.prim_path = prim_path
self.lightType = lightType
self.simulationWorld = simulationWorld
self.name = name
self.intensity = intensity
self.color = color
self.position = position
self.orientation = orientation
def initialize(self):
#selection between different light types
if self.lightType == "Dome":
light = UsdLux.DomeLight.Define(self.simulationWorld.stage, Sdf.Path(self.prim_path))
light.CreateIntensityAttr(self.intensity)
light.CreateColorTemperatureAttr(self.color)
light.AddTranslateOp()
elif self.lightType == "Sphere":
light = UsdLux.SphereLight.Define(self.simulationWorld.stage, Sdf.Path(self.prim_path))
light.CreateIntensityAttr(self.intensity)
light.CreateColorTemperatureAttr(self.color)
light.AddTranslateOp()
elif self.lightType == "Disk":
light = UsdLux.DiskLight.Define(self.simulationWorld.stage, Sdf.Path(self.prim_path))
light.CreateIntensityAttr(self.intensity)
light.CreateColorTemperatureAttr(self.color)
light.AddTranslateOp()
elif self.lightType == "Distant":
light = UsdLux.DistantLight.Define(self.simulationWorld.stage, Sdf.Path(self.prim_path))
light.CreateIntensityAttr(self.intensity)
light.CreateColorTemperatureAttr(self.color)
light.AddTranslateOp()
else:
print("unsupported type of light is selected")
lightPrim = XFormPrim(self.prim_path, name=self.name, position=self.position, orientation=self.orientation)
return lightPrim
The class is then used in the following function:
def LoadingLight(simulationWorld, parameters, lightName):
primPathLight = "/World/Lights/" + lightName
LightObject = Light(prim_path=primPathLight,
simulationWorld=simulationWorld,
lightType=parameters["type"],
name=lightName,
intensity=parameters["intensity"],
color=parameters["temperature"],
position=np.array(parameters["position"]),
orientation=np.array(parameters["rotation"]))
lightPrim = LightObject.initialize()
simulationWorld.scene.add(lightPrim)
return simulationWorld
system
Closed
4
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.