User Tools

Site Tools


reference_guide:math_expression_language:functions_variables:input_functions:collision_in_mel

Collision

Collision Input Functions

ExpressionME-L allows you to connect multiple nodes and work with the data supplied by these nodes. Handling particle collisions can be easily achieved by using either the UDeflector Node or the FlowData Node. Special functions have been implemented in ME-L to allow for easy handling of collision events. Find below a list of these functions along with their parameters and variables.

Global Variable:

collision_in_idreturns the index of the input you created (starting with 0 excluding Time and On). 

 

collision_in_detect

Detects a collision for a given particle. Works with UDeflector and FlowData

Parameters:

Parameter Description
pid_in The particle ID to check for a collision.
affect_in(Optional) A boolean value that specifies whether to affect the particle position and velocity if a collision is detected. Default is false.

Output:

Return Description
scalar0: failed, 1: success

collision_in_point

Gets the collision point information. Only valid if the collision_in_detect() function returns 1.

Parameters:

Parameter Description
point_dataThe data to retrieve from the collision point. Check out the full list for PointData
scalar_outA scalar value to store the output.
vector_outA vector[3] to store the output.

 

Output:

Return Description
scalar0: failed, 1: success

Important To know

UDefector is able to use/generate the following information:

  • point_pos
  • point_opos
  • point_center
  • point_vel
  • point_norm
  • point_onorm
  • point_gnorm
  • point_ognorm
  • point_fid
  • point_bc
  • point_mtlid
  • point_col
  • point_uvw

           

FlowData only offers collision event and the following point data:             point_norm

 

Sample 1: Get the collision detect info from the FlowData operator and on collide, get the surface normal of the collision point

var normal[3];

if (collision_in_detect(pid))
{
   collision_in_point(point_norm, normal); %%//%% Do anything here with the normal value
} 

Sample 2: UDeflector - get the collision and update the particle position and velocity to the collision values (if you use a group as the first input of the expression, all particles in this group will be evaluated in parallel for the collision detection)

var ppos[3];
var pvel[3];

if (collision_in_detect(pid))
{ %%//%% Get and set the values, with affect_in set to true
collision_in_point(point_pos, ppos, true);
collision_in_point(point_vel, pvel, true);

set_pdata(pid, data_pos, ppos);
 set_pdata(pid, data_vel, pvel);
}

%%//%% The same as the above code collision_in_detect(pid, true);

©2024, cebas Visual Technology Inc.

reference_guide/math_expression_language/functions_variables/input_functions/collision_in_mel.txt · Last modified: 2024/01/24 18:34 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki