Difference between revisions of "lineIntersectsSurfaces"
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Some wiki formatting) |
m (Replaced <code> with <sqf>) |
||
(60 intermediate revisions by one other user not shown) | |||
Line 15: | Line 15: | ||
|s1= [[lineIntersectsSurfaces]] [begPosASL, endPosASL, ignoreObj1, ignoreObj2, sortMode, maxResults, LOD1, LOD2, returnUnique] | |s1= [[lineIntersectsSurfaces]] [begPosASL, endPosASL, ignoreObj1, ignoreObj2, sortMode, maxResults, LOD1, LOD2, returnUnique] | ||
− | |p1= begPosASL: [[PositionASL]] - virtual line start | + | |p1= begPosASL: [[Array]] format [[Position#PositionASL|PositionASL]] - virtual line start |
− | |p2= endPosASL: [[PositionASL]] - virtual line end | + | |p2= endPosASL: [[Array]] format [[Position#PositionASL|PositionASL]] - virtual line end |
|p3= ignoreObj1: [[Object]] - (Optional, default [[objNull]]) first object to ignore | |p3= ignoreObj1: [[Object]] - (Optional, default [[objNull]]) first object to ignore | ||
Line 27: | Line 27: | ||
|p6= maxResults: [[Number]] - (Optional, default 1) max results to return. -1 to return every result | |p6= maxResults: [[Number]] - (Optional, default 1) max results to return. -1 to return every result | ||
− | |p7= LOD1: [[String]] - (Optional, default "VIEW") primary [[LOD]] to look for intersection | + | |p7= LOD1: [[String]] - (Optional, default "VIEW") primary [[LOD]] to look for intersection. Can be one of: |
− | Can be one of: | ||
* "FIRE" | * "FIRE" | ||
* "VIEW" | * "VIEW" | ||
Line 34: | Line 33: | ||
* "IFIRE" - ("I" stands for Indirect, ''almost'' identical to "FIRE") | * "IFIRE" - ("I" stands for Indirect, ''almost'' identical to "FIRE") | ||
* "NONE" | * "NONE" | ||
− | * "PHYSX" - PhysX geometry LOD {{ | + | * {{GVI|arma3|2.02|size=0.8}} "PHYSX" - PhysX geometry LOD |
+ | * {{GVI|arma3|2.08|size=0.8}} "ROADWAY" - only works from the top | ||
+ | |p7since= arma3 1.52 | ||
− | |p8= LOD2: [[String]] - (Optional, default "FIRE") secondary [[LOD]] to look for intersection | + | |p8= LOD2: [[String]] - (Optional, default "FIRE") secondary [[LOD]] to look for intersection. See ''LOD1'' for possible values |
− | See ''LOD1'' for possible values | + | |p8since= arma3 1.52 |
− | |p9= returnUnique: [[Boolean]] - (Optional, default [[true]]) when [[false]], all intersections in the same object are included | + | |p9= returnUnique: [[Boolean]] - (Optional, default [[true]]) when [[false]], all intersections in the same object are included, otherwise only the first one |
+ | |p9since= arma3 1.70 | ||
|r1= [[Array]] of intersections in format [<nowiki/>[intersectPosASL, surfaceNormal, intersectObj, parentObject], ...] where: | |r1= [[Array]] of intersections in format [<nowiki/>[intersectPosASL, surfaceNormal, intersectObj, parentObject], ...] where: | ||
Line 47: | Line 49: | ||
* parentObject - the object proxy object belongs to (not always the same as intersect object) - [[objNull]] if terrain | * parentObject - the object proxy object belongs to (not always the same as intersect object) - [[objNull]] if terrain | ||
− | |x1= < | + | |x1= <sqf>_intersections = lineIntersectsSurfaces [eyePos player, aimPos chopper, player, chopper, true, -1];</sqf> |
− | |x2= < | + | |x2= <sqf>arrow = "Sign_Arrow_F" createVehicle [0,0,0]; |
− | + | onEachFrame { | |
− | _ins = | + | _ins = lineIntersectsSurfaces [ |
− | + | AGLToASL positionCameraToWorld [0,0,0], | |
− | + | AGLToASL positionCameraToWorld [0,0,1000], | |
− | + | player | |
]; | ]; | ||
− | + | if (count _ins == 0) exitWith { arrow setPosASL [0,0,0] }; | |
− | arrow | + | arrow setPosASL (_ins select 0 select 0); |
− | arrow | + | arrow setVectorUp (_ins select 0 select 1); |
− | + | hintSilent str _ins; | |
− | };</ | + | };</sqf> |
− | |x3= This should detect glass windows and wire fences (since Arma v1.52): < | + | |x3= This should detect glass windows and wire fences (since Arma v1.52): |
− | arrow = "Sign_Arrow_F" | + | <sqf> |
− | + | wirefence = "Land_New_WiredFence_5m_F" createVehicle position player; | |
− | _ins = | + | 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, | 1, | ||
"GEOM", | "GEOM", | ||
"NONE" | "NONE" | ||
]; | ]; | ||
− | + | if (count _ins == 0) exitWith { arrow setPosASL [0,0,0] }; | |
− | arrow | + | arrow setPosASL (_ins select 0 select 0); |
− | arrow | + | arrow setVectorUp (_ins select 0 select 1); |
− | + | hintSilent str _ins; | |
− | };</ | + | }; |
+ | </sqf> | ||
− | |seealso= [[lineIntersectsWith]] | + | |seealso= [[lineIntersectsWith]] [[lineIntersectsObjs]] [[terrainIntersect]] [[terrainIntersectASL]] [[terrainIntersectAtASL]] [[lineIntersects]] [[intersect]] [[cursorObject]] [[cursorTarget]] [[checkVisibility]] |
}} | }} | ||
− | + | {{Note | |
− | + | |user= Killzone_Kid | |
− | + | |timestamp= 20150827124400 | |
− | + | |text= Fast check if the player is in a house: | |
− | + | <sqf>KK_fnc_inHouse = { | |
− | + | lineIntersectsSurfaces [ | |
− | + | getPosWorld _this, | |
− | Fast check if the player is in a house:< | + | getPosWorld _this vectorAdd [0, 0, 50], |
− | + | _this, objNull, true, 1, "GEOM", "NONE" | |
− | + | ] select 0 params ["","","","_house"]; | |
− | + | if (_house isKindOf "House") exitWith { true }; | |
− | _this, | + | false |
− | ] | ||
− | |||
− | |||
}; | }; | ||
− | + | onEachFrame { hintSilent str (player call KK_fnc_inHouse) };</sqf> | |
− | + | }} | |
− | + | {{Note | |
− | + | |user= Pierre MGI | |
− | + | |timestamp= 20160130201000 | |
− | + | |text= This command is useful to place weaponholder (and then spawned weapons) on floor of houses, correcting the spawn position (can_collide) to intersect with floor: | |
− | This command is useful to place weaponholder (and then spawned weapons) on floor of houses, correcting the spawn position (can_collide) to intersect with floor: | + | <sqf>MGI_fnc_setPosAGLS = { |
− | < | + | params ["_obj", "_pos"]; |
− | + | _wh_pos = getPosASL _obj; | |
− | _wh_pos = | ||
− | _pos | + | _pos set [2, (ATLtoASL _pos select 2) - 10]; |
− | _ins = | + | _ins = lineIntersectsSurfaces [_wh_pos, _pos,_obj, objNull, true, 1, "VIEW", "FIRE"]; |
− | _surface_distance = | + | _surface_distance = if (count _ins > 0) then [{ (_ins select 0 select 0) distance _wh_pos }, { 0 }]; |
− | _wh_pos | + | _wh_pos set [2, (getPosASL _obj select 2) - (_surface_distance)]; |
− | _weaponholder | + | _weaponholder setPosASL _wh_pos; |
− | }; | + | };</sqf> |
− | </ | ||
After the position (_pos) obtained in BIS_fnc_buidingPositions array: | After the position (_pos) obtained in BIS_fnc_buidingPositions array: | ||
− | < | + | <sqf>private _weaponHolder = createVehicle ["groundWeaponHolder", _pos, [], 0, "CAN_COLLIDE"]; |
− | [_weaponHolder, _pos] | + | [_weaponHolder, _pos] call MGI_fnc_setPosAGLS;</sqf> |
Then fill your weapon holder. | Then fill your weapon holder. | ||
− | + | }} | |
− | |||
− | |||
− |
Latest revision as of 16:06, 14 May 2022
Description
- Description:
- Returns a list of intersections with surfaces and ground from begPosASL to endPosASL. Doesn't return intersection with sea surface. Works underwater, unlike lineIntersects. Hardcoded max distance: 5000m.
- Groups:
- Math - Geometry
Syntax
- Syntax:
- lineIntersectsSurfaces [begPosASL, endPosASL, ignoreObj1, ignoreObj2, sortMode, maxResults, LOD1, LOD2, returnUnique]
- Parameters:
- begPosASL: Array format PositionASL - virtual line start
- endPosASL: Array format PositionASL - virtual line end
- ignoreObj1: Object - (Optional, default objNull) first object to ignore
- ignoreObj2: Object - (Optional, default objNull) second object to ignore
- sortMode: Boolean - (Optional, default true) true: closest to furthest, false: furthest to closest
- maxResults: Number - (Optional, default 1) max results to return. -1 to return every result
- since
1.52
- LOD1: String - (Optional, default "VIEW") primary LOD to look for intersection. Can be one of:
- since
1.52
- LOD2: String - (Optional, default "FIRE") secondary LOD to look for intersection. See LOD1 for possible values
- since
1.70
- returnUnique: Boolean - (Optional, default true) when false, all intersections in the same object are included, otherwise only the first one
- Return Value:
- Array of intersections in format [[intersectPosASL, surfaceNormal, intersectObj, parentObject], ...] where:
- intersectPosASL - the actual position where line intersects surface
- surfaceNormal - a normal to the intersected surface
- intersectObject - the object the surface belongs to (could be proxy object) - objNull if terrain
- parentObject - the object proxy object belongs to (not always the same as intersect object) - objNull if terrain
Examples
- Example 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.52):
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:
- lineIntersectsWith lineIntersectsObjs terrainIntersect terrainIntersectASL terrainIntersectAtASL lineIntersects intersect 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
- Posted on Aug 27, 2015 - 12:44 (UTC)
- Killzone_Kid
- Fast check if the player 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) };
- Posted on Jan 30, 2016 - 20:10 (UTC)
- Pierre MGI
- This command is useful to place weaponholder (and then spawned weapons) on floor of houses, correcting the spawn position (can_collide) to intersect with floor:
MGI_fnc_setPosAGLS = { params ["_obj", "_pos"]; _wh_pos = getPosASL _obj; _pos set [2, (ATLToASL _pos select 2) - 10]; _ins = lineIntersectsSurfaces [_wh_pos, _pos,_obj, objNull, true, 1, "VIEW", "FIRE"]; _surface_distance = if (count _ins > 0) then [{ (_ins select 0 select 0) distance _wh_pos }, { 0 }]; _wh_pos set [2, (getPosASL _obj select 2) - (_surface_distance)]; _weaponholder setPosASL _wh_pos; };After the position (_pos) obtained in BIS_fnc_buidingPositions array:private _weaponHolder = createVehicle ["groundWeaponHolder", _pos, [], 0, "CAN_COLLIDE"]; [_weaponHolder, _pos] call MGI_fnc_setPosAGLS;Then fill your weapon holder.