This page has been translated automatically.
视频教程
界面
要领
高级
实用建议
UnigineEditor
界面概述
资产工作流程
设置和首选项
项目开发
调整节点参数
Setting Up Materials
Setting Up Properties
照明
Landscape Tool
Sandworm
使用编辑器工具执行特定任务
Extending Editor Functionality
嵌入式节点类型
Nodes
Objects
Effects
Decals
光源
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
编程
基本原理
搭建开发环境
Usage Examples
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
Rebuilding the Engine Tools
GUI
双精度坐标
应用程序接口
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
创建内容
Content Optimization
Materials
Art Samples
Tutorials

Unigine::Plugins::IG::Region Class

Warning
The functionality described in this article is not available in the Community SDK edition.
You should upgrade to Sim SDK edition to use it.
Header: #include <plugins/UnigineIG.h>

This class is used to manage weather regions for the IG. Each region contains one or multiple layers each comprising a vertical profile. The main layer always exists in the region and cannot be deleted. It is a base layer used to define weather parameters for the region, such as visibility range, temperature, humidity, etc.

Notice
IG plugin must be loaded.

There are three types of weather regions available:

  • Global - representing atmospheric layers, which have no distinct horizontal boundaries. Atmospheric effects are observed anywhere within the vertical range.
  • Local Rectangle - they have the same set of parameters (visibility, coverage, wind) as Global ones but atmospheric effects for them are restricted to a certain area defined by a rectangle.
  • Local Polygon - they have the same set of parameters (visibility, coverage, wind) as Global ones but atmospheric effects for them are restricted to a certain area defined by a polygon.

Global meteo conditions are managed via the Meteo class.

Region Class

Enums

ShapeType#

NameDescription
ShapeType_GLOBAL = 0Global region type (atmospheric layers, which have no distinct horizontal boundaries).
ShapeType_RECTANGLE = 1Local rectangle region type: regional weather with atmospheric effects restricted to a certain area defined by a rectangle.
ShapeType_POLYGON = 2Local polygon region type: regional weather with atmospheric effects restricted to a certain area defined by a polygon.

Members


void setEnabled ( bool v ) #

Enables or disables the weather region.

Arguments

  • bool v - true to enable the weather region; false - to disable it.

bool isEnabled ( ) const#

Returns a value indicating if the weather region is currently enabled.

Return value

true if the weather region is currently enabled; otherwise, false.

int64_t getID ( ) const#

Returns the ID of the region.

Return value

Region ID.

WeatherLayer * createLayer ( int64_t layer_id, WeatherLayerType type ) #

Creates a new weather layer for the region. In case a layer with the specified ID exists and has a different type, it will be replaced with the new one.

Arguments

  • int64_t layer_id - ID of the layer to be created.
  • WeatherLayerType type - Type of the layer to be created, one of the following values:
    • Plugins::IG::WeatherLayerType::LAYER_BASE - base layer.
    • Plugins::IG::WeatherLayerType::LAYER_CLOUD - cloud layer.
    • Plugins::IG::WeatherLayerType::LAYER_PRECIPITATION - precipitation layer.

Return value

New weather layer if it is created successfully; otherwise, nullptr.

WeatherLayer * getLayer ( int64_t layer_id ) #

Returns a weather layer by its ID.

Arguments

  • int64_t layer_id - Weather layer ID.

Return value

Weather layer with the specified ID if it exists, otherwise nullptr.

bool removeLayer ( int64_t layer_id ) #

Removes a weather layer with the specified ID.

Arguments

  • int64_t layer_id - Weather layer ID.

Return value

true if the weather layer is created successfully; otherwise, false.

WeatherLayer * getMainLayer ( ) #

Returns the main weather layer of the region. It is a base layer, that is used to define weather parameters, such as visibility range, temperature, humidity, etc. The main layer always exists in the region and cannot be deleted.

Return value

Main weather layer of the region.

void getLayers ( Vector<WeatherLayer*>& vec ) const#

Returns the list of all layers (base, clouds, precipitation) contained in the weather region.

Arguments

  • Vector<WeatherLayer*>& vec - The list of all layers in the weather region.

void findWeatherLayers ( const Vec3& geo_pos, Vector<MeteoPositionParam>& vector ) const#

Returns the list of all layers (base, clouds, precipitation) of the weather region containing the specified position (and thus affecting it) along with their corresponding impact factors (as MeteoPositionParam structure).

Arguments

  • const Vec3& geo_pos - Geocoordinates of the point for which all affecting layers are to be found.
  • Vector<MeteoPositionParam>& vector - The list of all layers in the weather region containing the specified position (and thus affecting it) along with their corresponding impact factors (as MeteoPositionParam structure).

bool setShapeAsRectangle ( const Vec2& size, double corner_radius ) #

Sets the shape of a rectangle weather region using the specified width, height, and corner radius.

Arguments

  • const Vec2& size - Vector combining width and height of the rectangle, in units (W, H).
  • double corner_radius - Corner radius of the rectangle, in units. This parameter enables you to create a rounded rectangle.
    Notice
    This value cannot be greater than half size.

Return value

true if the shape of the region is set successfully; otherwise, false.

bool setShapeAsPolygon ( const Vector<vec2>& points, const Vector<unsigned short>& indices ) #

Sets the shape of a polygon weather region using the specified sets of vertex coordinates and their indices.

Arguments

  • const Vector<vec2>& points - Array of polygon vertex coordinates.
  • const Vector<unsigned short>& indices - Array of vertex indices defining a polygon.

Return value

true if the shape of the region is set successfully; otherwise, false.

bool setShapeAsPolygon ( const Vector<Vec2>& geo_points ) #

Sets the shape of a polygon weather region as a set of geocoordinates of points.

Arguments

  • const Vector<Vec2>& geo_points - Array of geocoordinates of points forming a polygon.

Return value

true if the shape of the region is set successfully; otherwise, false.

Region::ShapeType getShapeType ( ) const#

Sets the type of the weather region's shape.

Return value

Weather region type, one of the following:
  • GLOBAL - global (atmospheric layers, which have no distinct horizontal boundaries)
  • RECTANGLE - local (regional weather with atmospheric effects restricted to a certain area defined by a rectangle)
  • POLYGON - local (regional weather with atmospheric effects restricted to a certain area defined by a polygon)

const Vec2 & getShapeSize ( ) const#

Returns the size of the rectangle that defines or encloses the shape of the weather region as a two-component vector.

Return value

Two-component vector (W, L) containing width and length of the rectangle (in meters) that defines or encloses the shape of the weather region depending on its type:
  • Global - (inf, inf)
  • Rectangle - (rectangle_width, rectangle_length)
  • Polygon - (boundbox_width, boundbox_length)

Vec2 getShapeSizeOuter ( ) const#

Returns the size of the outer rectangle (shape_size + 2 * transition_size) that includes transition areas of the weather region as a two-component vector.

Return value

Two-component vector (W, L) containing width and length of the outer rectangle (in meters) that includes transition areas of the weather region depending on its type:
  • Global - (inf, inf)
  • Rectangle - (rectangle_width + 2 * transition_size, rectangle_length + 2 * transition_size)
  • Polygon - (boundbox_width + 2 * transition_size, boundbox_length + 2 * transition_size)

double getShapeRectangleRadius ( ) const#

Returns the current corner radius of the rectangle. This parameter defines the shape of a rounded rectangle.

Return value

Current corner radius of the rectangle, in units.

void setTransitionSize ( double width ) #

Sets the width of the transition area around the borders of the weather region. The effects of the region fade out gradually within this area.

Arguments

  • double width - New width of the transition area around the borders of the weather region to be set, in meters.

double getTransitionSize ( ) const#

Returns the current width of the transition area around the borders of the weather region. The effects of the region fade out gradually within this area.

Return value

Current width of the transition area around the borders of the weather region, in meters.

void setWorldPosition ( const Vec2& world_pos ) #

Sets new world coordinates for the weather region's position.

Arguments

  • const Vec2& world_pos - New Cartesian coordinates to be set for the weather region's position (X, Y).

const Vec2 & getWorldPosition ( ) const#

Returns the current world coordinates of the weather region's position.

Return value

Current Cartesian coordinates of the weather region's position (X, Y).

void setGeoPosition ( const Vec2& geo_pos ) #

Sets new geocoordinates for the weather region's position.

Arguments

  • const Vec2& geo_pos - Geocoordinates of the weather region's position (Lat, Lon).

void setRotation ( float angle_deg ) #

Rotates the weather region around the Z axis by the specified angle.

Arguments

  • float angle_deg - Rotation angle to be set, in degrees within the [-360; 360] range.

float getRotation ( ) const#

Returns the current angle of rotation of the weather region around the Z axis.

Return value

Current rotation angle, in degrees within the [-360; 360] range.

float getImpact ( const Vec2& world_pos ) const#

Returns a value indicating the degree of impact of the region at the specified point depending on whether it is completely inside, outside, or somewhere within the transition area.

Arguments

  • const Vec2& world_pos - World coordinates (Cartesian) of the point to be ckecked.

Return value

Value indicating the degree of impact of the region at the specified point:
  • 0 - completely outside the region (and transition area)
  • 1 - inside the region
  • (0 < x < 1) - within the transition area

void * addOnChangedCallback ( CallbackBase * callback ) #

Adds a callback on changing region parameters.
Source code (C++)
/// callback function to be called when region parameters change
void SomeClass::my_region_callback()
{
	// actions to be performed on changing region parameters
}

// ...
// somewhere in code
void SomeClass::init()
{
	// adding "my_region_callback" to be called on changing weather conditions
	ig_manager->getMeteo()->getRegion(1)->addOnChangedCallback(this, Unigine::MakeCallback(this, &SomeClass::my_region_callback );
}

Arguments

Return value

Callback subscriber ID. This ID can be used to remove this callback when necessary.

bool removeOnChangedCallback ( void * id ) #

Removes a callback on changing region parameters for the specified subscriber.

Arguments

  • void * id - Callback subscriber ID specified when adding it.

Return value

true if the callback for the specified subscriber is removed successfully; otherwise, false.
Last update: 2021-09-29
Build: ()