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

Unigine::Plugins::IG::CollisionSegment Class

Header: #include <plugins/Unigine/IG/UnigineIG.h>

This class is used to manage collision segments that are assigned to entities and used for collision detection.

Notice
IG plugin must be loaded.

A collision detection segment is a line segment along which collision testing is performed by the IG. When a collision detection segment intersects a polygon, the IG registers a collision by sending the corresponding notification.

Notice
Collision detection testing is performed by the IG every frame.

The segment is defined by specifying the locations of its endpoints with respect to the associated entity’s body coordinate system. Figure below illustrates five segments defined for an aircraft.

Collision detection volumes are tested segment-to-polygon. An entity will not perform collision detection segment testing against its own geometry.

If an entity is destroyed, all collision detection segments defined for that entity will also be destroyed.

CollisionSegment Class

Members


int getID ( ) const#

Returns the ID of the collision segment.

Return value

Collision segment ID.

Entity * getEntity ( ) const#

Returns the entity to which the collision segment is assigned.

Return value

Entity to which the collision segment is assigned.

bool isEnabled ( ) const#

Returns a value indicating if the collision segment is enabled.

Return value

true if the collision segment is enabled; otherwise, false

void setEnabled ( bool value ) #

Enables or disables the collision segment.

Arguments

  • bool value - true to enable the collision segment; false - to disable it.

void setStartPoint ( const Math::vec3& point ) #

Sets the coordinates of the start point of the collision segment.

Arguments

  • const Math::vec3& point - Coordinates of the start point of the collision segment, in the coordinate system of the entity.

const Math::vec3& getStartPoint ( ) const#

Returns the current coordinates of the start point of the collision segment.

Return value

Coordinates of the start point of the collision segment, in the coordinate system of the entity.

void setEndPoint ( Math::vec3 point ) #

Sets the coordinates of the end point of the collision segment.

Arguments

  • Math::vec3 point - Coordinates of the end point of the collision segment, in the coordinate system of the entity.

Math::vec3 getEndPoint ( ) const#

Returns the current coordinates of the end point of the collision segment.

Return value

Coordinates of the end point of the collision segment, in the coordinate system of the entity.

void setMaterialMask ( int mask ) #

Sets the material mask for the collision segment. This parameter specifies the environmental and cultural features to be included in or excluded from consideration for collision testing.

Arguments

  • int mask - Integer representing a bit mask, each bit of which represents a range of material code values. Setting that bit to 1 will cause the IG to register hits with materials within the corresponding range.

int getMaterialMask ( ) const#

Gets the material mask for the collision segment. This parameter specifies the environmental and cultural features to be included in or excluded from consideration for collision testing.

Return value

Integer representing a bit mask, each bit of which represents a range of material code values. Setting that bit to 1 will cause the IG to register hits with materials within the corresponding range.

void * addOnCollisionDetectedCallback ( Unigine::CallbackBase3< CollisionSegment *, Ptr<Object>, Ptr<WorldIntersection>> * func ) #

Adds a callback function to be called when a collision with the collision segment is detected. This function can be used to define specific actions to be performed when a collision with the segment is detected. The signature of the callback function must be as follows:
Source code (C++)
void(CollisionSegment *segment , ObjectPtr object, WorldIntersectionPtr wi);

You can set a callback function as follows:

Source code (C++)
addOnCollisionDetectedCallback(MakeCallback(collision_callback_function_name));

Example: Setting a collision detected callback for a collision segment of an entity

Source code (C++)
/// callback function to be called when a collision with the collision segment is detected
void my_callback(CollisionSegment *segment , ObjectPtr object, WorldIntersectionPtr wi)
{
	// insert your code handling collision event here
}

// ...
// somewhere in code
void SomeClass::init()
{
	// adding "my_callback" to be called when a collision with the segment is detected
	ig_manager->getEntity(entity_id)->getCollisionSegment(segment_id)->addOnCollisionDetectedCallback(Unigine::MakeCallback( my_callback ));
}

Arguments

Return value

ID of the last added collision detected callback, if the callback was added successfully; otherwise, nullptr. This ID can be used to remove this callback when necessary.

bool removeOnCollisionDetectedCallback ( void * id ) #

Removes the specified callback from the list of collision detected callbacks.

Arguments

  • void * id - Collision detected callback ID obtained when adding it.

Return value

True if the collision detected callback with the given ID was removed successfully; otherwise false.

void clearOnCollisionDetectedCallbacks ( ) #

Clears all added collision detected callbacks.
Last update: 2023-03-15
Build: ()