Skip to content
Alessandro Febretti edited this page Nov 19, 2013 · 7 revisions

Last revision: ver. 5.1 - 5 November 2013

[[module cyclops | Python-Reference#module-cyclops]] extends [[SceneNode]] wraps the cyclops::Light

Defines a light for the scene. After creation, lights are automatically attached to the scene root node. Lights need to be explicitly turned on using the setEnabled method. Cyclops supports point, spot and directional lights by default, but custom light functions can be added by the user.

Methods

Method(s) Description
create() static Creates a new light object
setColor(color) Sets the diffuse color for this light
setAmbient(color) Sets the ambient color for this light. Ambient color will be considered only for the main scene light (see SceneManager.setMainLight)
isEnabled(), setEnabled(value) Gets or sets the light enabled value
setAttenuation(consant, linear, quadratic), getAttenuation() Sets or gets the light attenuation values. getAttenuation() returns the attenuation parameters as a Vector3 object.
setLightType(type), getLightType() Sets or gets the light type
setLightFunction(string), getLightFunction() Sets or gets the light function
setLightDirection(value), getLightDirection() Sets or gets the light direction for Spot or Directional light types
setSpotExponent(value), getSpotExponent() Sets or gets the spot exponent for Spot lights
setSpotCutoff(value), getSpotCutoff() Sets or gets the spot cutoff for Spot lights
Shadow Mapping
setShadow([[ShadowMap]] shadow), [[ShadowMap]] getShadowMap()` Sets or gets the shadow map for this light
setShadowRefreshMode(ShadowRefreshMode srm) Sets the shadow refresh mode. Supported values are ShadowRefreshMode.OnFrame, ShadowRefreshMode.OnLightMove

Light Types

The setLightType() method accepts a value from the LightType enumeration. Supported values are:

  • Point: for point lights
  • Directional: for directional lights
  • Spot: for spot lights
  • Custom: for custom lights

Custom lights allow the user to specify a custom, per pixel light function:

	scene = getSceneManager()
	
	// Use the customFragmentFunctions macro to inject code into fragment shaders.
	scene.setShaderMacroToString('customFragmentFunctions', '''
		customLightFunction(SurfaceData sd, LightData ld)
		{
			// Trivial example: return a fixed color regardless of light or surface properties
			return vec4(1, 0, 0, 0);
		}
	'''
	)
	
	light = Light.create()
	light.setType(lightType.Custom)
	light.setLightFunction('customLightFunction')
Clone this wiki locally