selectionVectorDirAndUp: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
m (Some wiki formatting)
 
(6 intermediate revisions by 2 users not shown)
Line 2: Line 2:


|game1= arma3
|game1= arma3
|version1= 2.06
|version1= 2.06
|branch= dev


|arg= global
|arg= global


|descr= Searches for selection in the object model in the give LOD level of the object model, and returns the Direction and Up vectors in model space.
|descr= Searches for selection in the object model's LOD level, and returns the Direction and Up vectors in model space.


|gr1= Object Manipulation
|gr1= Object Manipulation
Line 19: Line 16:
|p2= selectionName: [[String]] - selection name (see [[selectionNames]])
|p2= selectionName: [[String]] - selection name (see [[selectionNames]])


|p3= LOD: [[String]] or [[Number]] - the LOD that contains the selection. [[String]] can be one of:
|p3= LOD: [[String]] or [[Number]] - the LOD that contains the selection:
* "Memory"
* [[String]] - can be one of:
* "Geometry"
** "Memory"
* "FireGeometry"
** "Geometry"
* "LandContact"
** "FireGeometry"
* "HitPoints"  
** "LandContact"
* "ViewGeometry" (''since Arma 3 v2.06.147636'')
** "HitPoints"
When [[Number]] is used, command searches for a LOD with the similar [[LOD_resolutions|resolution]] (see [[allLODs]]).
** "ViewGeometry"
* [[Number]] - command searches for a LOD with the similar [[LOD resolutions|resolution]] (see [[allLODs]]).
 
|r1= [[Array]] - in format [<nowiki/>[[vectorDir]], [[vectorUp]]], where the vectors are in model space
 
|x1= <sqf>vehicle player selectionVectorDirAndUp ["drivewheel_axis", "FireGeometry"] params ["_axisVectorDir", "_axisVectorUp"];</sqf>
 
|x2= Get the player's barrel end ({{hl|_p1}} being muzzle end's ASL position):<sqf>
onEachFrame {
private _weapon = currentWeapon player;
if (_weapon == "") exitWith {};
 
// update weapon info upon weapon switch
if (_weapon != player getVariable ["last_weapon", "?"]) then
{
private _cfg = configFile >> "CfgWeapons" >> _weapon;
private _model = getText(_cfg >> "model");
private _simpleObject = createSimpleObject [_model, [0,0,0], true];
private _offset = _simpleObject selectionPosition [getText (_cfg >> "muzzlePos"), "memory"];
_offset = _offset apply { [_x] };
deleteVehicle _simpleObject;
player setVariable ["offset", _offset];
player setVariable ["last_weapon", _weapon];
player setVariable ["proxy",
[
"proxy:\a3\characters_f\proxies\pistol.001",
"proxy:\a3\characters_f\proxies\weapon.001",
"proxy:\a3\characters_f\proxies\launcher.001",
"proxy:\a3\characters_f\proxies\binoculars.001"
] select (([1, 4, 4096] find getNumber (_cfg >> "type")) + 1)
];
};
 
_offset = player getVariable ["offset", []];
private _proxy = player getVariable ["proxy", ""];
// using LOD resolution 1 (and lod index 0) - this is not always reliable
// you should manually check allLODs and find the most suitable LOD (smallest res LOD usually has the best accuracy, but it might be slow too)
player selectionVectorDirAndUp [_proxy, 1] params ["_vy", "_vz"];
private _pos = selectionPosition [player, _proxy, 0];
private _vx = _vy vectorCrossProduct _vz;
 
private _mat = matrixTranspose [_vx, _vy, _vz];
_pos = _pos vectorAdd flatten (_mat matrixMultiply _offset);


|r1= [[Array]] - in format <nowiki>[</nowiki>[[vectorDir]], [[vectorUp]]<nowiki>]</nowiki>, where the vectors are in model space
private _p1 = player modelToWorldVisualWorld _pos;
private _p2 = _p1 vectorAdd (player vectorModelToWorldVisual (_vx vectorMultiply -1000));
drawLine3D [ASLToAGL _p1, ASLToAGL _p2, [1,0,0,1]];
};
</sqf>


|seealso= [[selectionPosition]] [[selectionNames]] [[allLODs]]
|seealso= [[selectionPosition]] [[selectionNames]] [[allLODs]]
}}
}}

Latest revision as of 00:41, 12 February 2024

Hover & click on the images for description

Description

Description:
Searches for selection in the object model's LOD level, and returns the Direction and Up vectors in model space.
Groups:
Object Manipulation

Syntax

Syntax:
object selectionVectorDirAndUp [selectionName, LOD]
Parameters:
object: Object
selectionName: String - selection name (see selectionNames)
LOD: String or Number - the LOD that contains the selection:
  • String - can be one of:
    • "Memory"
    • "Geometry"
    • "FireGeometry"
    • "LandContact"
    • "HitPoints"
    • "ViewGeometry"
  • Number - command searches for a LOD with the similar resolution (see allLODs).
Return Value:
Array - in format [vectorDir, vectorUp], where the vectors are in model space

Examples

Example 1:
vehicle player selectionVectorDirAndUp ["drivewheel_axis", "FireGeometry"] params ["_axisVectorDir", "_axisVectorUp"];
Example 2:
Get the player's barrel end (_p1 being muzzle end's ASL position):
onEachFrame { private _weapon = currentWeapon player; if (_weapon == "") exitWith {}; // update weapon info upon weapon switch if (_weapon != player getVariable ["last_weapon", "?"]) then { private _cfg = configFile >> "CfgWeapons" >> _weapon; private _model = getText(_cfg >> "model"); private _simpleObject = createSimpleObject [_model, [0,0,0], true]; private _offset = _simpleObject selectionPosition [getText (_cfg >> "muzzlePos"), "memory"]; _offset = _offset apply { [_x] }; deleteVehicle _simpleObject; player setVariable ["offset", _offset]; player setVariable ["last_weapon", _weapon]; player setVariable ["proxy", [ "proxy:\a3\characters_f\proxies\pistol.001", "proxy:\a3\characters_f\proxies\weapon.001", "proxy:\a3\characters_f\proxies\launcher.001", "proxy:\a3\characters_f\proxies\binoculars.001" ] select (([1, 4, 4096] find getNumber (_cfg >> "type")) + 1) ]; }; _offset = player getVariable ["offset", []]; private _proxy = player getVariable ["proxy", ""]; // using LOD resolution 1 (and lod index 0) - this is not always reliable // you should manually check allLODs and find the most suitable LOD (smallest res LOD usually has the best accuracy, but it might be slow too) player selectionVectorDirAndUp [_proxy, 1] params ["_vy", "_vz"]; private _pos = selectionPosition [player, _proxy, 0]; private _vx = _vy vectorCrossProduct _vz; private _mat = matrixTranspose [_vx, _vy, _vz]; _pos = _pos vectorAdd flatten (_mat matrixMultiply _offset); private _p1 = player modelToWorldVisualWorld _pos; private _p2 = _p1 vectorAdd (player vectorModelToWorldVisual (_vx vectorMultiply -1000)); drawLine3D [ASLToAGL _p1, ASLToAGL _p2, [1,0,0,1]]; };

Additional Information

See also:
selectionPosition selectionNames allLODs

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