lineIntersectsSurfaces: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
(note)
Line 88: Line 88:
<dt class="note">[[User:Killzone Kid|Killzone Kid]]</dt>
<dt class="note">[[User:Killzone Kid|Killzone Kid]]</dt>
<dd class="note">
<dd class="note">
note...
Fast check if object is in a house:<code>KK_fnc_inHouse = {
[[lineIntersectsSurfaces]] [
[[getPosWorld]] _this,
[[getPosWorld]] _this [[vectorAdd]] [0, 0, 50],
_this, [[objNull]], [[true]], 1, "GEOM", "NONE"
] [[select]] 0 [[params]] ["","","","_house"];
[[if]] (_house [[isKindOf]] "House") [[exitWith]] {[[true]]};
[[false]]
};
[[onEachFrame]] {[[hintSilent]] [[str]] ([[player]] [[call]] KK_fnc_inHouse)};</code>
</dd>
</dd>
</dl>
</dl>
<!-- DISCONTINUE Notes -->
<!-- DISCONTINUE Notes -->

Revision as of 14:46, 27 August 2015

Hover & click on the images for description

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.

Since Arma v1.51.131920 it is possible to indicate primary and secondary LOD to look for intersection. Available options are:
  • "FIRE"
  • "VIEW"
  • "GEOM"
  • "IFIRE" - ("I" stands for Indirect, almost the same as FIRE)
  • "NONE"
Default LODs are "VIEW" and "FIRE"
Groups:
Uncategorised

Syntax

Syntax:
lineIntersectsSurfaces [begPosASL, endPosASL, ignoreObj1, ignoreObj2, sortMode, maxResults, LOD1, LOD2]
Parameters:
[begPosASL, endPosASL, ignoreObj1, ignoreObj2, sortMode, maxResults, LOD1, LOD2]: 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
LOD1 (Optional): String (added in v1.51.131920) - Primary LOD to look for intersection. Default: "VIEW"
LOD2 (Optional): String (added in v1.51.131920) - Secondary LOD to look for intersection. Default: "FIRE"
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 [ AGLToASL positionCameraToWorld [0,0,0], AGLToASL 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; };
Example 3:
This should detect glass windows and wire fences (since Arma v1.51.131920): wirefence = "Land_New_WiredFence_5m_F" createVehicle position player; arrow = "Sign_Arrow_F" createVehicle [0,0,0]; onEachFrame { _ins = lineIntersectsSurfaces [ AGLToASL positionCameraToWorld [0,0,0], AGLToASL positionCameraToWorld [0,0,1000], player, objNull, true, 1, "GEOM", "NONE" ]; 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

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

Notes

Bottom Section

Posted on August 27, 2015 - 12:44 (UTC)
Killzone Kid
Fast check if object is in a house:KK_fnc_inHouse = { lineIntersectsSurfaces [ getPosWorld _this, getPosWorld _this vectorAdd [0, 0, 50], _this, objNull, true, 1, "GEOM", "NONE" ] select 0 params ["","","","_house"]; if (_house isKindOf "House") exitWith {true}; false }; onEachFrame {hintSilent str (player call KK_fnc_inHouse)};