SpotLight
A spot light illuminating the scene.The light has a location and a illumination cone restricting the directionstaken by the rays of light (can cast shadows).
Target: Sofa.GL.Component.Shader
namespace: sofa::gl::component::shader
parents:
- PositionalLight
Data
Name | Description | Default value |
---|---|---|
name | object name | unnamed |
printLog | if true, emits extra messages at runtime. | 0 |
tags | list of the subsets the object belongs to | |
bbox | this object bounding box | |
componentState | The state of the component among (Dirty, Valid, Undefined, Loading, Invalid). | Undefined |
listening | if true, handle the events, otherwise ignore the events | 0 |
enable | Display the object or not | 1 |
color | Set the color of the light. (default=[1.0,1.0,1.0,1.0]) | 1 1 1 1 |
shadowTextureSize | [Shadowing] Set size for shadow texture | 0 |
zNear | [Shadowing] Light's ZNear | |
zFar | [Shadowing] Light's ZFar | |
shadowsEnabled | [Shadowing] Enable Shadow from this light | 1 |
softShadows | [Shadowing] Turn on Soft Shadow from this light | 0 |
shadowFactor | [Shadowing] Shadow Factor (decrease/increase darkness) | 1 |
VSMLightBleeding | [Shadowing] (VSM only) Light bleeding parameter | 0.05 |
VSMMinVariance | [Shadowing] (VSM only) Minimum variance parameter | 0.001 |
textureUnit | [Shadowing] Texture unit for the generated shadow texture | 1 |
modelViewMatrix | [Shadowing] ModelView Matrix | |
projectionMatrix | [Shadowing] Projection Matrix | |
fixed | Fix light position from the camera | 0 |
position | Set the position of the light | -0.7 0.3 0 |
attenuation | Set the attenuation of the light | 0 |
direction | Set the direction of the light | 0 0 -1 |
cutoff | Set the angle (cutoff) of the spot | 30 |
exponent | Set the exponent of the spot | 1 |
lookat | If true, direction specify the point at which the spotlight should be pointed to | 0 |
Visualization | ||
drawSource | Draw Light Source | 0 |
Links
Name | Description | Destination type name |
---|---|---|
context | Graph Node containing this object (or BaseContext::getDefault() if no graph is used) | BaseContext |
slaves | Sub-objects used internally by this object | BaseObject |
master | nullptr for regular objects, or master object for which this object is one sub-objects | BaseObject |
Examples
SpotLight.scn
<Node name="root" dt="0.01" gravity="0 0 -10" showBoundingTree="0">
<RequiredPlugin name="Sofa.Component.Collision.Detection.Algorithm"/> <!-- Needed to use components [BVHNarrowPhase BruteForceBroadPhase CollisionPipeline] -->
<RequiredPlugin name="Sofa.Component.Collision.Detection.Intersection"/> <!-- Needed to use components [MinProximityIntersection] -->
<RequiredPlugin name="Sofa.Component.Collision.Geometry"/> <!-- Needed to use components [LineCollisionModel PointCollisionModel TriangleCollisionModel] -->
<RequiredPlugin name="Sofa.Component.Collision.Response.Contact"/> <!-- Needed to use components [CollisionResponse] -->
<RequiredPlugin name="Sofa.Component.IO.Mesh"/> <!-- Needed to use components [MeshOBJLoader] -->
<RequiredPlugin name="Sofa.Component.LinearSolver.Iterative"/> <!-- Needed to use components [CGLinearSolver] -->
<RequiredPlugin name="Sofa.Component.Mapping.NonLinear"/> <!-- Needed to use components [RigidMapping] -->
<RequiredPlugin name="Sofa.Component.Mass"/> <!-- Needed to use components [UniformMass] -->
<RequiredPlugin name="Sofa.Component.ODESolver.Backward"/> <!-- Needed to use components [EulerImplicitSolver] -->
<RequiredPlugin name="Sofa.Component.StateContainer"/> <!-- Needed to use components [MechanicalObject] -->
<RequiredPlugin name="Sofa.Component.Topology.Container.Constant"/> <!-- Needed to use components [MeshTopology] -->
<RequiredPlugin name="Sofa.GL.Component.Rendering3D"/> <!-- Needed to use components [OglModel] -->
<RequiredPlugin name="Sofa.GL.Component.Shader"/> <!-- Needed to use components [LightManager SpotLight] -->
<DefaultAnimationLoop/>
<CollisionPipeline verbose="0" />
<BruteForceBroadPhase/>
<BVHNarrowPhase/>
<CollisionResponse response="PenalityContactForceField" />
<MinProximityIntersection name="Proximity" alarmDistance="0.02" contactDistance="0.02" />
<LightManager />
<SpotLight name="light1" color="1 0 0" position="0.5 0.7 2" cutoff="25" exponent="1" drawSource="false" />
<SpotLight name="light2" color="0 1 0" position="0.5 -0.7 2" cutoff="25" exponent="1" drawSource="false"/>
<SpotLight name="light3" color="0 0 1" position="-0.8 0 2" cutoff="25" exponent="1" drawSource="false"/>
<SpotLight name="light4" color="1 1 1" position="0 0 2" cutoff="10" exponent="1000" drawSource="false" />
<include href="Objects/SaladBowl.xml" />
<include href="Objects/TorusRigid.xml" scale="0.05" rx="30" ry="15" dz="1" />
</Node>
def createScene(root_node):
root = root_node.addChild('root', dt="0.01", gravity="0 0 -10", showBoundingTree="0")
root.addObject('RequiredPlugin', name="Sofa.Component.Collision.Detection.Algorithm")
root.addObject('RequiredPlugin', name="Sofa.Component.Collision.Detection.Intersection")
root.addObject('RequiredPlugin', name="Sofa.Component.Collision.Geometry")
root.addObject('RequiredPlugin', name="Sofa.Component.Collision.Response.Contact")
root.addObject('RequiredPlugin', name="Sofa.Component.IO.Mesh")
root.addObject('RequiredPlugin', name="Sofa.Component.LinearSolver.Iterative")
root.addObject('RequiredPlugin', name="Sofa.Component.Mapping.NonLinear")
root.addObject('RequiredPlugin', name="Sofa.Component.Mass")
root.addObject('RequiredPlugin', name="Sofa.Component.ODESolver.Backward")
root.addObject('RequiredPlugin', name="Sofa.Component.StateContainer")
root.addObject('RequiredPlugin', name="Sofa.Component.Topology.Container.Constant")
root.addObject('RequiredPlugin', name="Sofa.GL.Component.Rendering3D")
root.addObject('RequiredPlugin', name="Sofa.GL.Component.Shader")
root.addObject('DefaultAnimationLoop', )
root.addObject('CollisionPipeline', verbose="0")
root.addObject('BruteForceBroadPhase', )
root.addObject('BVHNarrowPhase', )
root.addObject('CollisionResponse', response="PenalityContactForceField")
root.addObject('MinProximityIntersection', name="Proximity", alarmDistance="0.02", contactDistance="0.02")
root.addObject('LightManager', )
root.addObject('SpotLight', name="light1", color="1 0 0", position="0.5 0.7 2", cutoff="25", exponent="1", drawSource="false")
root.addObject('SpotLight', name="light2", color="0 1 0", position="0.5 -0.7 2", cutoff="25", exponent="1", drawSource="false")
root.addObject('SpotLight', name="light3", color="0 0 1", position="-0.8 0 2", cutoff="25", exponent="1", drawSource="false")
root.addObject('SpotLight', name="light4", color="1 1 1", position="0 0 2", cutoff="10", exponent="1000", drawSource="false")
root.addObject('include', href="Objects/SaladBowl.xml")
root.addObject('include', href="Objects/TorusRigid.xml", scale="0.05", rx="30", ry="15", dz="1")