Align trenches to ground

This commit is contained in:
esteldunedain 2016-01-26 11:03:11 -03:00
parent 0358b10298
commit f8a1215264
2 changed files with 17 additions and 11 deletions

View File

@ -26,16 +26,19 @@ params ["_unit"];
params ["_unit"];
private ["_position", "_direction", "_trench"];
_position = getPosASL GVAR(trench);
_direction = getDir GVAR(trench);
GVAR(trenchType) params ["", "", "_dx", "_dy", "_offset"];
private _position = getPosASL GVAR(trench);
private _angle = (GVAR(digDirection) + getDir _unit);
private _minz = (getTerrainHeightASL _position);
_position set [2, _minz + _offset];
private _v3 = [sin _angle, +cos _angle, 0] vectorCrossProduct surfaceNormal _position;
private _v1 = (surfaceNormal _position) vectorCrossProduct _v3;
deleteVehicle GVAR(trench);
_trench = createVehicle [GVAR(trenchType) select 0, [0, 0, 0], [], 0, "NONE"];
private _trench = createVehicle [GVAR(trenchType) select 0, [0, 0, 0], [], 0, "NONE"];
_trench setPosASL _position;
_trench setDir _direction;
_trench setVectorDirAndUp [_v1, surfaceNormal _position];
GVAR(trench) = objNull;
}, [_unit], 1] call EFUNC(common,waitAndExecute);

View File

@ -57,7 +57,7 @@ GVAR(digPFH) = [{
GVAR(trenchType) params ["", "", "_dx", "_dy", "_offset"];
private _minz = (getTerrainHeightASL _basePos);
private ["_ix","_iy"];
for [{_ix = -_dx/2},{_ix <= _dx/2},{_ix = _ix + _dx/3}] do {
/*for [{_ix = -_dx/2},{_ix <= _dx/2},{_ix = _ix + _dx/3}] do {
for [{_iy = -_dy/2},{_iy <= _dy/2},{_iy = _iy + _dy/3}] do {
private _pos = _basePos vectorAdd ([cos _angle, -sin _angle, 0] vectorMultiply _ix)
vectorAdd ([sin _angle, +cos _angle, 0] vectorMultiply _iy);
@ -66,15 +66,18 @@ GVAR(digPFH) = [{
#ifdef DEBUG_MODE_FULL
_pos set [2, getTerrainHeightASL _pos];
_pos2 = +_pos;
_pos2 set [2, getTerrainHeightASL _pos+2];
_pos2 set [2, getTerrainHeightASL _pos + 1];
drawLine3D [ASLtoAGL _pos, ASLtoAGL _pos2, [1,1,0,1]];
#endif
};
};
};*/
_basePos set [2, _minz + _offset];
_trench setPosASL _basePos;
_trench setDir _angle;
private _v3 = [sin _angle, +cos _angle, 0] vectorCrossProduct surfaceNormal _basePos;
private _v1 = (surfaceNormal _basePos) vectorCrossProduct _v3;
_trench setVectorDirAndUp [_v1, surfaceNormal _basePos];
}, 0, [_unit, _trench]] call CBA_fnc_addPerFrameHandler;
// add mouse button action and hint