Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rotate scripted optic according to weapon bank #1162

Merged
merged 4 commits into from
Jun 15, 2019
Merged

Conversation

commy2
Copy link
Contributor

@commy2 commy2 commented Jun 14, 2019

When merged this pull request will:

  • title

https://i.imgur.com/WPMvUrP.png
https://i.imgur.com/wLqQxI8.png

@commy2 commy2 added this to the 3.12 milestone Jun 14, 2019
@PabstMirror
Copy link
Contributor

PabstMirror commented Jun 14, 2019

seems to be a little variance with left and right depending on terrain slope and view direction,
but I'm not sure if it's wrong or that's how it actually is
e.g. left = -31.7463, right = 29.1498
also it seems to handle "bipod deployed" tilt correctly (world tilts, not the gun)

@commy2
Copy link
Contributor Author

commy2 commented Jun 14, 2019

Some dev code to mess around with:

["cba_debug", "onEachFrame", { 
    params ["_unit", "_weapon", "_pos"]; 
    private _aim = _unit modelToWorldVisualWorld (_unit selectionPosition "Pelvis"); 
    private _cam = _unit modelToWorldVisualWorld (_unit selectionPosition "camera"); 
    private _up = _aim vectorFromTo _cam; 
 
    private _wDir = _unit weaponDirection _weapon; 
    private _wLat = vectorNormalized (_wDir vectorCrossProduct _up); 
    private _wUp = _wLat vectorCrossProduct _wDir; 
 
    private _origin = _unit modelToWorldVisualWorld (_unit selectionPosition "proxy:\a3\characters_f\proxies\weapon.001") vectorAdd 
        (_wDir vectorMultiply _pos#0) vectorAdd 
        (_wLat vectorMultiply _pos#1) vectorAdd 
        (_wUp  vectorMultiply _pos#2); 

    private _0 = AGLToASL positionCameraToWorld [0,0,0]; 
    private _x = AGLToASL positionCameraToWorld [1,0,0]; 
    private _y = AGLToASL positionCameraToWorld [0,1,0]; 
 
    private _up = _0 vectorFromTo _y; 
    private _right = _0 vectorFromTo _x; 
 
    drawLine3D [ASLToAGL _origin, ASLToAGL (_origin vectorAdd _up), [1,0,0,1]]; 
    drawLine3D [ASLToAGL _origin, ASLToAGL (_origin vectorAdd _right), [0,1,0,1]]; 
    drawLine3D [ASLToAGL _origin, ASLToAGL (_origin vectorAdd _wUp), [0,0,1,1]]; 
 
    systemChat str round (90 - acos (_right vectorCos _wUp)); 
}, [player, currentWeapon player, [2,0,0]]] call BIS_fnc_addStackedEventHandler; 

seems to be a litter variance with left and right depending on terrain slope and view direction,

Yeah, Pelvis is not the perfect memory point for this, but the best I have. There also is aimPoint, but that has worse results, especially in the side stances.

@commy2
Copy link
Contributor Author

commy2 commented Jun 14, 2019

Deployed on hills sideways.

https://i.imgur.com/Xfemy7D.png
https://i.imgur.com/tGyQf1M.png

@commy2 commy2 merged commit cd8a239 into master Jun 15, 2019
@commy2 commy2 deleted the scripted-optics-bank branch June 15, 2019 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants