blueprints.light module#
Lights can be used to illuminate your models. They have a position and an orientation which can be set via
the standard orientation attributes of blueprints.thing.moveable.MoveableThing. Mujoco uses the
Light.dir attribute internally, so blueprint synchronizes all changes in euler, alpha, beta,
gamma with dir internally.
Similarly to blueprints.camera.Camera Lights can either be fixed in orientation locally/globally or
tracking another Body by setting the Light.mode and optionally Light.target. For a detailed
description see Light.mode.
>>> body = blue.Body(lights=blue.Light(mode='fixed'))
>>> body = blue.Body(lights=blue.Light(mode='track'))
>>> one = blue.Body(name='one', lights=blue.Light(mode='targetbody'))
>>> two = blue.Body(name='two')
>>> root = blue.Body(name='root', bodies=[one, two])
>>> # Version one:
>>> root.bodies['one'].lights.target = root.bodies['two']
>>> # Version two:
>>> root.bodies['two'].targeting_lights = root.bodies['one'].lights
<body name="root">
<body name="one">
<light mode="targetbody" name="unnamed_light" cutoff="90.0" target="two" />
</body>
<body name="two" />
</body>
- class blueprints.light.Light[source]#
Bases:
LightType,CyclicalThing,MoveableThingThis class is available through the shortcut
blueprints.Light.Most attribute descriptions are partially taken from Mujoco.
- __init__(pos=[0.0, 0.0, 0.0], dir=[0.0, 0.0, -1.0], attenuation=[1.0, 0.0, 0.0], ambient=[0.0, 0.0, 0.0], diffuse=[0.7, 0.7, 0.7], specular=[0.3, 0.3, 0.3], mode='fixed', directional=False, castshadow=True, active=True, cutoff=6.283185307179586, exponent=10.0, name=None, x=None, y=None, z=None, **kwargs)[source]#
- Parameters:
pos (
np.ndarray | list[int | float], optional) – Represents the position of the Light. Changing this attribute also changes the propertiesx,yandz.dir (
np.ndarray | list[int | float], optional) – Direction of the Light.attenuation (
np.ndarray | list[int | float], optional) – These are the constant, linear and quadratic attenuation coefficients in OpenGL. The default corresponds to no attenuation. See the OpenGL documentation for more information on this and all other OpenGL-related properties.ambient (
np.ndarray | list[int | float], optional) – The ambient color of the Light.diffuse (
np.ndarray | list[int | float], optional) – The diffuse color of the Light.specular (
np.ndarray | list[int | float], optional) – The specular color of the Light.mode (
str, optional) – The mode defines who the position and orientation is changed over time. Seemodefor a detailed description.directional (
bool, optional) – The light is directional if this attribute is True, otherwise it is a spotlight.castshadow (
bool, optional) – If this attribute is True the Light will cast shadows. More precisely, the geoms illuminated by the light will cast shadows, however this is a property of Lights rather than geoms. Since each shadow-casting light causes one extra rendering pass through all geoms, this attribute should be used with caution.active (
bool, optional) – The Light is active if this attribute is True. This can be used at runtime to turn Lights on and off.cutoff (
float, optional) – Cutoff angle for spotlights in radians.exponent (
float, optional) – Exponent for spotlights. This setting controls the softness of the spotlight cutoff.name (
str | None, optional) – The user specified name of the Camera. It might change in the case of a naming conflict.x (
int | float |np.int32 | np.int64 | np.float32 | np.float64 | None, optional) – If pos is not specified, this argument sets the X position coordinate.y (
int | float |np.int32 | np.int64 | np.float32 | np.float64 | None, optional) – If pos is not specified, this argument sets the Y position coordinate.z (
int | float |np.int32 | np.int64 | np.float32 | np.float64 | None, optional) – If pos is not specified, this argument sets the Z position coordinate.**kwargs – Keyword arguments are passed to
super().__init__.
- property target: BodyType | None#
The target attribute specifies a Body that is tracked by the camera. Compatible
modevalues are (‘targetbody’, ‘targetbodycom’).- Return type:
blue.BodyType | None
- property mode: str#
This argument works identically to
blueprints.camera.Camera.mode. Possible values are:'fixed': Position and orientation will change w.r.t. the parents frame of reference.'track': Position is at a constant offset from the parent in world coordinates, while the camera orientation is constant in world coordinates.'trackcom': is similar to'track'but the constant spatial offset is defined relative to the center of mass of the kinematic subtree starting at the parent Body. This can be used to keep an entire mechanism in view. Note that the subtree center of mass for the World is the center of mass of the entire model.'targetbody': the Camera position is fixed in the parent Body, while the Camera orientation is adjusted so that it always points towards the targeted Body (which is specified with the target attribute)'targetbodycom': is the same as'targetbody'but the Camera is oriented towards the center of mass of the subtree starting at the target Cody.
- Returns:
When setting this value manually, it must be one of those specified above, otherwise an error is raised.
- Return type:
str
- property dir: ndarray#
Direction of the light.
- Return type:
np.ndarray
- property attenuation: ndarray#
These are the constant, linear and quadratic attenuation coefficients in OpenGL. The default corresponds to no attenuation. See the OpenGL documentation for more information on this and all other OpenGL-related properties.
- Return type:
np.ndarray
- property ambient: ndarray#
The ambient color of the light (RGB).
- Return type:
np.ndarray
- property diffuse: ndarray#
The diffuse color of the light (RGB).
- Return type:
np.ndarray
- property specular: ndarray#
The specular color of the light (RGB).
- Return type:
np.ndarray
- property directional: bool#
The light is directional if this attribute is “true”, otherwise it is a spotlight.
- Return type:
bool
- property castshadow: bool#
If this attribute is True the Light will cast shadows. More precisely, the geoms illuminated by the light will cast shadows, however this is a property of Lights rather than geoms. Since each shadow-casting light causes one extra rendering pass through all geoms, this attribute should be used with caution.
- Return type:
bool
- property active: bool#
The light is active if this attribute is “true”. This can be used at runtime to turn lights on and off.
- Return type:
bool
- property cutoff: float#
Cutoff angle for spotlights in radians.
- Return type:
float
- property exponent: float#
Exponent for spotlights. This setting controls the softness of the spotlight cutoff.
- Return type:
float