intersect: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "|= Game version" to "|Game version=")
m (Text replacement - "<sqf>([^↵][^\/]*↵[^\/]*)<\/sqf>" to "<sqf> $1 </sqf>")
 
(96 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Command|= Comments
{{RV|type=command
____________________________________________________________________________________________


| arma |Game name=
|game1= arma1
|1.00|Game version=
|version1= 1.00
|arg= global|Multiplayer Arguments=
____________________________________________________________________________________________


| Finds named selections in object which are in specified LOD, intersected by given section of a line. Return value is in the form of [selection, distance]. Multiple returned arrays are nested within a single array. No intersection returns []. ''lodName'' could be one of the following:  
|game2= arma2
|version2= 1.00
 
|game3= arma2oa
|version3= 1.50
 
|game4= tkoh
|version4= 1.00
 
|game5= arma3
|version5= 0.50
 
|arg= global
 
|gr1= Math - Geometry
 
|descr= Finds named selections in object which are in specified LOD, intersected by given section of a line. Return value is in the form of [selection, distance]. Multiple returned arrays are nested within a single array. No intersection returns []. ''lodName'' could be one of the following:  
* "FIRE"
* "FIRE"
* "VIEW"
* "VIEW"
* "GEOM"
* "GEOM"
* "IFIRE" - ("I" stands for Indirect, almost the same as FIRE)|DESCRIPTION=
* "IFIRE" - ("I" stands for Indirect, almost the same as FIRE)
____________________________________________________________________________________________
* {{GVI|arma3|2.02|size= 0.75}} "PHYSX" - PhysX geometry LOD
 
|s1= [object, lodName] [[intersect]] [begPos, endPos]


| [object, lodName] '''intersect''' [begPos, endPos] |SYNTAX=
|p1= object: [[Object]]


|p1= [object, lodName]: [[Array]] |PARAMETER1=
|p2= lodName: [[String]]
|p2= object: [[Object]] |PARAMETER2=
|p3= lodName: [[String]] |PARAMETER3=
|p4= [begPos, endPos] : [[Array]] |PARAMETER4=
|p5= begPos: [[Array]] - format [[PositionAGL]] |PARAMETER5=
|p6= endPos: [[Array]] - format [[PositionAGL]] |PARAMETER6=


| [[Array]] - array of intersections in format: <nowiki>[</nowiki>[selection, distance],...], where
|p3= begPos: [[Array]] format [[Position#PositionAGL|PositionAGL]]
 
|p4= endPos: [[Array]] format [[Position#PositionAGL|PositionAGL]]
 
|r1= [[Array]] - array of intersections in format: [<nowiki/>[selection, distance],...], where
* selection - name of intersected selection
* selection - name of intersected selection
* distance - distance from begPos
* distance - distance from begPos
The results are also sorted, closest selection first |RETURNVALUE=
The results are also sorted, closest selection first
____________________________________________________________________________________________
 
 
|x1= <sqf>[_tank, "VIEW"] intersect [[1500, 1500, 2], [1550, 1500, 2]];</sqf>
|x1= <code>[_tank, "VIEW"] [[intersect]] [[1500, 1500, 2], [1550, 1500, 2]];</code> |EXAMPLE1=


|x2= <code>sphere = "Sign_Sphere10cm_F" [[createVehicle]] [0,0,0];
|x2= <sqf>
[[onEachFrame]] {
sphere = "Sign_Sphere10cm_F" createVehicle [0,0,0];
_begPos = [[positionCameraToWorld]] [0,0,0];
onEachFrame {
_begPosASL = [[AGLToASL]] _begPos;
_begPos = positionCameraToWorld [0,0,0];
_endPos = [[positionCameraToWorld]] [0,0,1000];
_begPosASL = AGLToASL _begPos;
_endPosASL = [[AGLToASL]] _endPos;
_endPos = positionCameraToWorld [0,0,1000];
_ins = [[lineIntersectsSurfaces]] [_begPosASL, _endPosASL, [[player]], [[objNull]], [[true]], 1, "FIRE", "NONE"];
_endPosASL = AGLToASL _endPos;
[[if]] (_ins [[isEqualTo]] []) [[exitWith]] {sphere [[setPosASL]] [0,0,0]};
_ins = lineIntersectsSurfaces [_begPosASL, _endPosASL, player, objNull, true, 1, "FIRE", "NONE"];
_ins [[select]] 0 [[params]] ["_pos", "_norm", "_obj", "_parent"];
if (_ins isEqualTo []) exitWith {sphere setPosASL [0,0,0]};
[[if]] !([[getModelInfo]] _parent [[select]] 2) [[exitWith]] {sphere [[setPosASL]] [0,0,0]};
_ins select 0 params ["_pos", "_norm", "_obj", "_parent"];
_ins2 = [_parent, "FIRE"] [[intersect]] [_begPos, _endPos];
if !(getModelInfo _parent select 2) exitWith {sphere setPosASL [0,0,0]};
[[if]] (_ins2 [[isEqualTo]] []) [[exitWith]] {sphere [[setPosASL]] [0,0,0]};
_ins2 = [_parent, "FIRE"] intersect [_begPos, _endPos];
_ins2 [[select]] 0 [[params]] ["_name", "_dist"];
if (_ins2 isEqualTo []) exitWith {sphere setPosASL [0,0,0]};
_posASL = _begPosASL [[vectorAdd]] ((_begPosASL [[vectorFromTo]] _endPosASL) [[vectorMultiply]] _dist);
_ins2 select 0 params ["_name", "_dist"];
[[drawIcon3D]] ["", [1,1,1,1], [[ASLToAGL]] _posASL, 0, 0, 0, _name, 1, 0.03, "PuristaMedium"];
_posASL = _begPosASL vectorAdd ((_begPosASL vectorFromTo _endPosASL) vectorMultiply _dist);
sphere [[setPosASL]] _posASL;
drawIcon3D ["", [1,1,1,1], ASLToAGL _posASL, 0, 0, 0, _name, 1, 0.03, "PuristaMedium"];
};</code> |EXAMPLE2=
sphere setPosASL _posASL;
____________________________________________________________________________________________
};
</sqf>


| [[lineIntersectsSurfaces]], [[terrainIntersect]], [[terrainIntersectASL]], [[terrainIntersectAtASL]], [[lineIntersects]], [[lineIntersectsWith]], [[lineIntersectsObjs]], [[cursorObject]], [[cursorTarget]], [[checkVisibility]] |SEEALSO=
|seealso= [[lineIntersectsSurfaces]] [[terrainIntersect]] [[terrainIntersectASL]] [[terrainIntersectAtASL]] [[lineIntersects]] [[lineIntersectsWith]] [[lineIntersectsObjs]] [[cursorObject]] [[cursorTarget]] [[checkVisibility]]
}}


{{Note
|user= ManDay
|timestamp= 20070725083700
|text= The most common [[LOD]] is "''FIRE''", which identifies the most detailled hitbox used for ammunition.
}}
}}


<h3 style="display:none">Notes</h3>
{{Note
<dl class="command_description">
|user= ffur2007slx2_5
<!-- Note Section BEGIN -->
|timestamp= 20140327145200
<dd class="notedate">Posted on Jul 25, 2007 - 08:37
|text= Example (In {{arma3}} ver 1.14) display returned arrays on cursor entities:
<dt class="note">'''[[User:ManDay|ManDay]]'''<dd class="note">
<sqf>
The most common [[LOD]] is "''FIRE''", which identifies the most detailled hitbox used for ammunition.
<dd class="notedate">Posted on Mar 27, 2014 - 14:52
<dt class="note">'''[[User:ffur2007slx2_5|ffur2007slx2_5]]'''<dd class="note">
Example (In ArmA3 ver 1.14) display returned arrays on cursor entities:<br>
<code>
Sto = [];
Sto = [];
Fn = {
Fn = {
  {
{
    Sto set [_foreachindex,[cursortarget,_x] intersect [(asltoagl (eyepos player)),(screentoworld [0.5,0.5])]];
Sto set [_foreachindex,[cursorTarget, _x] intersect [ASLToAGL eyePos player, screenToWorld [0.5,0.5]]];
  } foreach ["FIRE","VIEW","GEOM","IFIRE"];
} foreach ["FIRE", "VIEW", "GEOM", "IFIRE"];
  hintsilent format ["FIRE: %1, VIEW: %2, GEOM: %3, IFIRE: %4",Sto select 0,Sto select 1,Sto select 2,Sto select 3];
hintSilent format ["FIRE: %1, VIEW: %2, GEOM: %3, IFIRE: %4", Sto select 0, Sto select 1, Sto select 2, Sto select 3];
};
};
["sample_id","onEachFrame","Fn"] call BIS_fnc_addStackedEventHandler;
["sample_id", "onEachFrame", "Fn"] call BIS_fnc_addStackedEventHandler;
</code>
</sqf>
Return FIRE: [something], VIEW: [something], GEOM: [something], IFIRE: [something].
Return FIRE: [something], VIEW: [something], GEOM: [something], IFIRE: [something].
<!-- Note Section END -->
}}
</dl>


<h3 style="display:none">Bottom Section</h3>
{{Note
[[Category:Scripting Commands|INTERSECT]]
|user= Killzone_Kid
[[Category:Scripting Commands OFP Elite |INTERSECT]]
|timestamp= 20150820183400
[[Category:Scripting Commands ArmA|INTERSECT]]
|text= [[intersect]] will spam .rpt if passed to it object has no skeleton. Use [[getModelInfo]] to filter out those objects.
[[Category:Scripting Commands ArmA2|{{uc:{{PAGENAME}}}}]]
}}
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting_Commands_Take_On_Helicopters|{{uc:{{PAGENAME}}}}]]
 
<!-- CONTINUE Notes -->
<dl class="command_description">
<dd class="notedate">Posted on August 20, 2015 - 18:34 (UTC)</dd>
<dt class="note">[[User:Killzone Kid|Killzone Kid]]</dt>
<dd class="note">
[[intersect]] will spam .rpt if passed to it object has no skeleton. Use [[getModelInfo]] to filter out those objects.
</dd>
</dl>
<!-- DISCONTINUE Notes -->

Latest revision as of 11:34, 3 September 2024

Hover & click on the images for description

Description

Description:
Finds named selections in object which are in specified LOD, intersected by given section of a line. Return value is in the form of [selection, distance]. Multiple returned arrays are nested within a single array. No intersection returns []. lodName could be one of the following:
  • "FIRE"
  • "VIEW"
  • "GEOM"
  • "IFIRE" - ("I" stands for Indirect, almost the same as FIRE)
  • Arma 3 logo black.png2.02 "PHYSX" - PhysX geometry LOD
Groups:
Math - Geometry

Syntax

Syntax:
[object, lodName] intersect [begPos, endPos]
Parameters:
object: Object
lodName: String
begPos: Array format PositionAGL
endPos: Array format PositionAGL
Return Value:
Array - array of intersections in format: [[selection, distance],...], where
  • selection - name of intersected selection
  • distance - distance from begPos
The results are also sorted, closest selection first

Examples

Example 1:
[_tank, "VIEW"] intersect [[1500, 1500, 2], [1550, 1500, 2]];
Example 2:
sphere = "Sign_Sphere10cm_F" createVehicle [0,0,0]; onEachFrame { _begPos = positionCameraToWorld [0,0,0]; _begPosASL = AGLToASL _begPos; _endPos = positionCameraToWorld [0,0,1000]; _endPosASL = AGLToASL _endPos; _ins = lineIntersectsSurfaces [_begPosASL, _endPosASL, player, objNull, true, 1, "FIRE", "NONE"]; if (_ins isEqualTo []) exitWith {sphere setPosASL [0,0,0]}; _ins select 0 params ["_pos", "_norm", "_obj", "_parent"]; if !(getModelInfo _parent select 2) exitWith {sphere setPosASL [0,0,0]}; _ins2 = [_parent, "FIRE"] intersect [_begPos, _endPos]; if (_ins2 isEqualTo []) exitWith {sphere setPosASL [0,0,0]}; _ins2 select 0 params ["_name", "_dist"]; _posASL = _begPosASL vectorAdd ((_begPosASL vectorFromTo _endPosASL) vectorMultiply _dist); drawIcon3D ["", [1,1,1,1], ASLToAGL _posASL, 0, 0, 0, _name, 1, 0.03, "PuristaMedium"]; sphere setPosASL _posASL; };

Additional Information

See also:
lineIntersectsSurfaces terrainIntersect terrainIntersectASL terrainIntersectAtASL lineIntersects lineIntersectsWith lineIntersectsObjs cursorObject cursorTarget checkVisibility

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note
ManDay - c
Posted on Jul 25, 2007 - 08:37 (UTC)
The most common LOD is "FIRE", which identifies the most detailled hitbox used for ammunition.
ffur2007slx2_5 - c
Posted on Mar 27, 2014 - 14:52 (UTC)
Example (In Arma 3 ver 1.14) display returned arrays on cursor entities:
Sto = []; Fn = { { Sto set [_foreachindex,[cursorTarget, _x] intersect [ASLToAGL eyePos player, screenToWorld [0.5,0.5]]]; } foreach ["FIRE", "VIEW", "GEOM", "IFIRE"]; hintSilent format ["FIRE: %1, VIEW: %2, GEOM: %3, IFIRE: %4", Sto select 0, Sto select 1, Sto select 2, Sto select 3]; }; ["sample_id", "onEachFrame", "Fn"] call BIS_fnc_addStackedEventHandler;
Return FIRE: [something], VIEW: [something], GEOM: [something], IFIRE: [something].
Killzone_Kid - c
Posted on Aug 20, 2015 - 18:34 (UTC)
intersect will spam .rpt if passed to it object has no skeleton. Use getModelInfo to filter out those objects.