Difference between revisions of "lineIntersectsSurfaces"
Das Attorney (talk | contribs) |
Das Attorney (talk | contribs) m |
||
Line 68: | Line 68: | ||
arrow setPosASL (_ins select 0 select 0); | arrow setPosASL (_ins select 0 select 0); | ||
arrow setVectorUp (_ins select 0 select 1); | arrow setVectorUp (_ins select 0 select 1); | ||
+ | _intDist = (_ins select 0 select 0) distance (ATLToASL positionCameraToWorld [0,0,0]); | ||
_sel = ""; | _sel = ""; | ||
_dist = 10000; | _dist = 10000; | ||
Line 73: | Line 74: | ||
_ins2 = [_ins select 0 select 3,_x] intersect [ | _ins2 = [_ins select 0 select 3,_x] intersect [ | ||
positionCameraToWorld [0,0,0], | positionCameraToWorld [0,0,0], | ||
− | positionCameraToWorld [0,0, | + | positionCameraToWorld [0,0,_intDist + 0.1] |
]; | ]; | ||
Line 83: | Line 84: | ||
} forEach _ins2; | } forEach _ins2; | ||
if (_sel != "") exitWith {}; | if (_sel != "") exitWith {}; | ||
− | } forEach [" | + | } forEach ["GEOM","IFIRE","FIRE","VIEW"]; |
− | hintsilent format [" | + | hintsilent format ["GEOM: %1",_sel]; |
}; | }; | ||
["sample_id","onEachFrame","testFunc"] call BIS_fnc_addStackedEventHandler; | ["sample_id","onEachFrame","testFunc"] call BIS_fnc_addStackedEventHandler; |
Revision as of 00:01, 13 August 2015
Description
- Description:
- Returns list of intersections with surfaces from begPosASL to endPosASL. If there is ground intersection, it is also included. Works on units. Works underwater. Doesn't return intersection with sea surface. Hardcoded max distance: 5000m.
Syntax
- Syntax:
- lineIntersectsSurfaces [begPosASL, endPosASL, ignoreObj1, ignoreObj2, sortMode, maxResults]
- Parameters:
- [begPosASL, endPosASL, ignoreObj1, ignoreObj2, sortMode, maxResults]: Array
- begPosASL: PositionASL - virtual line start
- endPosASL: PositionASL - virtual line end
- ignoreObj1 (Optional): Object - first object to ignore or objNull: Default: objNull
- ignoreObj2 (Optional): Object - second object to ignore or objNull: Default: objNull
- sortMode (Optional): Boolean - true: closest to furthest, false: furthest to closest. Default: true
- maxResults (Optional): Number - Max results to return. -1 to return every result. Default: 1
- Return Value:
- Array of intersections in format [[intersectPosASL, surfaceNormal, intersectObj, parentObject],...] where:
- intersectPosASL - the actual position where line intersects 1st surface
- surfaceNormal - a normal to the intersected surface
- intersectObject - the object the surface belongs to (could be proxy object)
- parentObject - the object proxy object belongs to (not always the same as intersect object)
Examples
- Example 1:
-
_intersections = lineIntersectsSurfaces [eyePos player, aimPos chopper, player, chopper, true, -1];
- Example 2:
-
arrow = "Sign_Arrow_F" createVehicle [0,0,0]; onEachFrame { _ins = lineIntersectsSurfaces [ ATLToASL positionCameraToWorld [0,0,0], ATLToASL positionCameraToWorld [0,0,1000], player ]; if (count _ins == 0) exitWith {arrow setPosASL [0,0,0]}; arrow setPosASL (_ins select 0 select 0); arrow setVectorUp (_ins select 0 select 1); hintSilent str _ins; };
Additional Information
- See also:
- lineIntersectsWithlineIntersectsObjsterrainIntersectterrainIntersectASLlineIntersectsintersect
- Groups:
- Uncategorised
Notes
Notes
Bottom Section
You can combine with intersect command to find selection names on intersected objects (in this example priority is geom >> ifire >> fire >> view):
<nowiki>arrow = "Sign_Arrow_F" createVehicle [0,0,0];
testFunc = { _ins = lineIntersectsSurfaces [ ATLToASL positionCameraToWorld [0,0,0], ATLToASL positionCameraToWorld [0,0,1000], player ]; if (count _ins == 0) exitWith { arrow setPosASL [0,0,0] }; arrow setPosASL (_ins select 0 select 0); arrow setVectorUp (_ins select 0 select 1); _intDist = (_ins select 0 select 0) distance (ATLToASL positionCameraToWorld [0,0,0]); _sel = ""; _dist = 10000; { _ins2 = [_ins select 0 select 3,_x] intersect [ positionCameraToWorld [0,0,0], positionCameraToWorld [0,0,_intDist + 0.1] ];
{ if (_x select 1 < _dist) then { _dist = _x select 1; _sel = _x select 0 }; } forEach _ins2; if (_sel != "") exitWith {}; } forEach ["GEOM","IFIRE","FIRE","VIEW"];
hintsilent format ["GEOM: %1",_sel]; }; ["sample_id","onEachFrame","testFunc"] call BIS_fnc_addStackedEventHandler;
- Pages using duplicate arguments in template calls
- Introduced with Arma 3 Development Branch
- Scripting Commands
- Arma 3: Scripting Commands
- Arma 3: New Scripting Commands
- Command Group: Uncategorised
- Introduced with Arma 3 Development Branch version 1.49
- Commands utilizing global arguments
- Scripting Commands Arma 3