This page has been translated automatically.
视频教程
界面
要领
高级
实用建议
基础
专业(SIM)
UnigineEditor
界面概述
资源工作流程
Version Control
设置和首选项
项目开发
调整节点参数
Setting Up Materials
设置属性
照明
Sandworm
使用编辑器工具执行特定任务
如何擴展編輯器功能
嵌入式节点类型
Nodes
Objects
Effects
Decals
光源
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
编程
基本原理
搭建开发环境
使用范例
C++
C#
UnigineScript
统一的Unigine着色器语言 UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
材质和着色器
Rebuilding the Engine Tools
GUI
双精度坐标
应用程序接口
Animations-Related Classes
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
VR-Related Classes
创建内容
内容优化
材质
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

Unigine::LightProj Class

Header: #include <UnigineLights.h>
Inherits from: Light

This class is used to create projected light sources that emit light from a single point and cast a cone of light. It is possible to modulate the light from these light sources with a texture.

Example#

The following code illustrates how to create a projected light source and set its parameters.

Source code (UnigineScript)
#include <UnigineLights.h>
using namespace Unigine;

/* .. */

// creating a projected light source and setting its color to white, attenuation distance to 10 units and FOV angle to 60 degrees
LightProjPtr projector = LightProj::create(Math::vec4(1.0f, 1.0f, 0.5f, 1.0f), 10.0f, 60.0f, "");

// setting position of the light source
projector->setWorldPosition(Math::Vec3(2.5f, 2.5f, 3.0f));

// setting the name of the light source
projector->setName("projector");

// setting rotation of the light source
projector->setNodeRotation(Math::quat(-45.0f, 45.0f, 0.0f));

// setting penumbra factor
projector->setPenumbra(0.425f);

// setting a texture named "mytexture.tga" for light modulation
projector->setTextureFilePath("mytexture.tga");

// setting light intensity
projector->setIntensity(1.0f);

See Also#

  • A set of UnigineScript API samples located in the <UnigineSDK>/data/samples/lights/ folder:
    • proj_00
    • proj_03

LightProj Class

Members


static LightProjPtr create ( const Math::vec4 & color, float attenuation_distance, float fov, const char * name = 0 ) #

Constructor. Creates a new projected light source with texture modulation based on given parameters.

Arguments

  • const Math::vec4 & color - Color of the new light source.
  • float attenuation_distance - Distance from the light source shape, at which the light source doesn't illuminate anything.
  • float fov - Field of view of the new light source.
  • const char * name - Path to a texture of the new light source.

void setAttenuationDistance ( float distance ) #

Updates the distance from the light source shape, at which the light source doesn't illuminate anything.

Arguments

  • float distance - Distance from the light source shape, at which the light source doesn't illuminate anything.

float getAttenuationDistance ( ) #

Returns the distance from the light source shape, at which the light source doesn't illuminate anything.

Return value

Distance from the light source shape, at which the light source doesn't illuminate anything.

void setFov ( float fov ) #

Updates the current field of view of the projected light source. Remember that large fields of view may lead to shadow distortions.

Arguments

  • float fov - New field of view in degrees. This value will be saturated in range [1; 180].

float getFov ( ) #

Returns the current field of view of the projected light source.

Return value

Field of view in degrees.

void setTexture ( const Ptr<Texture> & texture ) #

Sets the light image texture smart pointer.

Arguments

  • const Ptr<Texture> & texture - Texture smart pointer.

Ptr<Texture> getTexture ( ) #

Gets a light image texture smart pointer.

Return value

Returns image texture smart pointer.

int setTextureImage ( const Ptr<Image> & image, int dynamic = 0 ) #

Sets a given Image instance as the light image texture. If you need to set a texture of all the lights in the scene, set dynamic flag to 1.

Arguments

  • const Ptr<Image> & image - Image.
  • int dynamic - Dynamic texture flag.
    • If set to 0, changing a texture of the light instance will also affect all the lights in the scene.
    • If set to 1, an image will be successfully set only for the current light instance.

Return value

Returns 1 if the texture is set successfully; otherwise, 0.

int getTextureImage ( const Ptr<Image> & image ) #

Reads the light image texture into an Image instance.

Arguments

  • const Ptr<Image> & image - Image, into which the texture is read.

Return value

Returns 1 if the texture is read successfully; otherwise, 0.

void setTextureFilePath ( const char * path ) #

Updates the file path for the texture used with this light source.

Arguments

  • const char * path - New texture file path.

const char * getTextureFilePath ( ) #

Returns the file path for the texture used with this light source.

Return value

Texture file path.

void setPenumbra ( float penumbra ) #

Sets light attenuation intensity in the penumbra cast from an object by this light source..

Arguments

  • float penumbra - Intensity of the shadow.

float getPenumbra ( ) #

Returns the current light attenuation intensity in the penumbra cast from an object by this light source.

Return value

Intensity of the shadow.

Math::mat4 getProjection ( ) const#

Returns the projection matrix used with this light source.

Return value

Projection matrix.

void setShapeHeight ( float height ) #

Updates the height of the rectangular light source.

Arguments

  • float height - Height of the light source shape.

float getShapeHeight ( ) #

Returns the height of the rectangular light source.

Return value

Height of the light source shape.

void setShapeLength ( float length ) #

Updates the length of the capsule-shaped or rectangular light source.

Arguments

  • float length - Length of the light source shape.

float getShapeLength ( ) #

Returns a length of the capsule-shaped or rectangular light source.

Return value

Length of the light source shape.

void setShapeRadius ( float radius ) #

Updates the radius of the spherical, capsule-shaped or rectangular light source.
Notice
In case of the rectangular shape, the corner radius is set.

Arguments

  • float radius - Radius of the light source shape.

float getShapeRadius ( ) #

Returns a radius of the spherical, capsule-shaped or rectangular light source.
Notice
In case of the rectangular shape, the corner radius will be returned.

Return value

Radius of the light source shape.

void setShapeType ( int type ) #

Updates the shape of the light source.
Notice
A light source of the rectangular shape produces the light and the speck in a form of a rounded rectangle.

Arguments

  • int type - Shape of the light source (one of the SHAPE_* variables).

int getShapeType ( ) #

Returns the shape of the light source.
Notice
A light source of the rectangular shape produces the light and the speck in a form of a rounded rectangle.

Return value

Shape of the light source (one of the SHAPE_* variables).

void setZNear ( float znear ) #

Updates the distance to the near clipping plane of the projected light source.

Arguments

  • float znear - New distance to the near clipping plane in units. If a negative value is provided, 0 will be used instead. The default value is 0.1.

float getZNear ( ) #

Returns the distance to the near clipping plane of the projected light source. The default value is 0.1.

Return value

Distance to the near clipping plane in units.

static int type ( ) #

Returns the type of the node.

Return value

Light type identifier.

void setIESRelativeToFov ( bool fov ) #

Sets a value indicating if IES texture is scaled to fit within the light source's Field of View. Works only when light's distibution is defined by an IES profile (color texture parameter is set to IES), a lighting industry standard of describing how the light is cast based on real-world measured light fixtures.

Arguments

  • bool fov - true - to enable scaling of IES texture to fit within the light source's Field of View; false - to disable.

bool isIESRelativeToFov ( ) const#

Returns a value indicating if IES texture is scaled to fit within the light source's Field of View. Works only when light's distibution is defined by an IES profile (color texture parameter is set to IES), a lighting industry standard of describing how the light is cast based on real-world measured light fixtures.

Return value

true if IES texture is scaled to fit within the light source's Field of View; otherwise, false.

Math::vec2 getShadowDepthRange ( ) const#

Returns shadow depth range for the light source.

Return value

Shadow depth range for the light source as a two-component vector (min, max).
Last update: 2024-08-16
Build: ()