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

LightOmni Class

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

This class is used to create omni directional light sources. It is possible to modulate the light from omni light sources with a texture.

Example#

The following code illustrates how to create an omni light source and set its parameters.

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

/* .. */

// creating an omni light source and setting its color to white, attenuation distance to 10 units
LightOmniPtr light_omni = LightOmni::create(Math::vec4(1.0f, 1.0f, 1.0f, 1.0f), 10.0f, "");

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

// setting position of the light source
light_omni->setWorldPosition(Math::Vec3(0.0f, 0.0f, 5.0f));

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

// setting light intensity
light_omni->setIntensity(0.1f);

See Also#

  • A set of UnigineScript samples located in the <UnigineSDK>/data/samples/lights/ folder:
    • omni_00
    • omni_01
    • omni_03
    • omni_04
    • omni_06
  • A C++ API sample located in the source/samples/Api/Nodes/Lights folder

LightOmni Class

Members

void setAttenuationDistance ( float distance ) #

Sets a new distance from the light source shape, at which the light source doesn't illuminate anything.

Arguments

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

float getAttenuationDistance() const#

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

Return value

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

Math::vec2 getShadowDepthRange() const#

Returns the current shadow depth range for the light source.

Return value

Current shadow depth range for the light source as a two-component vector (min, max).

void setShapeType ( Light::SHAPE type ) #

Sets a new 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


Light::SHAPE getShapeType() const#

Returns the current 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

Current shape of the light source (one of the SHAPE_* variables).

void setShapeHeight ( float height ) #

Sets a new height of the rectangular light source.

Arguments

  • float height - The height of the light source shape.

float getShapeHeight() const#

Returns the current height of the rectangular light source.

Return value

Current height of the light source shape.

void setShapeLength ( float length ) #

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

Arguments

  • float length - The length of the light source shape.

float getShapeLength() const#

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

Return value

Current length of the light source shape.

void setShapeRadius ( float radius ) #

Sets a new radius of the spherical, capsule-shaped or rectangular light source.
Notice
In case of the rectangular shape, the value is the corner radius.

Arguments

  • float radius - The radius of the light source shape.

float getShapeRadius() const#

Returns the current radius of the spherical, capsule-shaped or rectangular light source.
Notice
In case of the rectangular shape, the value is the corner radius.

Return value

Current radius of the light source shape.

Math::vec3 getSize() const#

Returns the current size of the area illuminated by the light source. depending on the shape type, the size varies:
  • If the light is point-shaped, each component of the vector will be equal to the attenuation distance:
    Source code (C++)
    vec3(attenuation_distance)
  • If the light is spherical, each component of the vector will be equal to the attenuation distance + sphere radius:
    Source code (C++)
    vec3(attenuation_distance + sphere_radius)
  • If the light is capsule-shaped, the 1st component of the vector will be equal to attenuation distance + capsule length:
    Source code (C++)
    vec3(attenuation_distance + capsule_length,attenuation_distance,attenuation_distance)
  • If the light is rectangular, the 2nd component of the vector will be equal to attenuation distance + rectangle height:
    Source code (C++)
    vec3(attenuation_distance,attenuation_distance + rectangle_height,attenuation_distance)

Return value

Current size of the illuminated area.

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

Sets a new light image texture.

Arguments

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

const Ptr<Texture> & getTexture() const#

Returns the current light image texture.

Return value

Current texture smart pointer.

void setTextureFilePath ( const char * path ) #

Sets a new name (path) of the cubemap texture file used with this light source.

Arguments

  • const char * path - The cubemap texture file path.

const char * getTextureFilePath() const#

Returns the current name (path) of the cubemap texture file used with this light source.

Return value

Current cubemap texture file path.

void setShadowNearClippingDistance ( float distance ) #

Sets a new distance from the light source shape, within which the object doesn't cast shadow under this light source.

Arguments

  • float distance - The distance from the light source shape, within which the object doesn't cast shadow under this light source.

float getShadowNearClippingDistance() const#

Returns the current distance from the light source shape, within which the object doesn't cast shadow under this light source.

Return value

Current distance from the light source shape, within which the object doesn't cast shadow under this light source.

void setNearAttenuationGradientLength ( float length ) #

Sets a new length of the gradient area smoothering the attenuation border near the light source.

Arguments

  • float length - The length of the gradient area smoothering the attenuation border near the light source.

float getNearAttenuationGradientLength() const#

Returns the current length of the gradient area smoothering the attenuation border near the light source.

Return value

Current length of the gradient area smoothering the attenuation border near the light source.

void setNearAttenuationDistance ( float distance ) #

Sets a new distance from the light source shape within which the light intensity is equal to 0. If an object is located within this distance from the light source, it won't be illuminated.

Arguments

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

float getNearAttenuationDistance() const#

Returns the current distance from the light source shape within which the light intensity is equal to 0. If an object is located within this distance from the light source, it won't be illuminated.

Return value

Current distance from the light source shape, within which the light source doesn't illuminate anything.

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

Constructor. Creates a new omni light source with the given parameters.

Arguments

  • const Math::vec4 & color - Color of the new light source.
  • float attenuation_distance - Attenuation distance
  • const char * name - Name of the source.

int setTextureImage ( const Ptr<Image> & image, bool 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 - New texture to set.
  • bool 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 ) const#

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 setShadowSideEnabled ( int side, int enable ) #

Enables or disables shadows for the specified side of the omni light source's cube map. By default the light source casts shadows in all directions.

Arguments

  • int side - Number of the side of the omni light source for which shadows are to be enabled or disabled. One of the following values:
    • 0 - positive X
    • 1 - negative X
    • 2 - positive Y
    • 3 - negative Y
    • 4 - positive Z
    • 5 - negative Z
  • int enable - 1 to enable shadows for the specified side of the omni light source, 0 - to disable.

int isShadowSideEnabled ( int side ) const#

Returns a value indicating if shadows are to be cast for the specified side of the omni light source. By default the light source casts shadows in all directions.

Arguments

  • int side - Number of the side of the omni light source for which shadows are to be enabled or disabled. One of the following values:
    • 0 - positive X
    • 1 - negative X
    • 2 - positive Y
    • 3 - negative Y
    • 4 - positive Z
    • 5 - negative Z

Return value

1 if shadows are to be cast for the specified side of the omni light source; otherwise, 0.

static int type ( ) #

Returns the type of the node.

Return value

Light type identifier.
Last update: 2024-12-13
Build: ()