Skip to content

Commit

Permalink
Merge pull request #1 from gruppe-adler/salbei
Browse files Browse the repository at this point in the history
rework
  • Loading branch information
AdlerSalbei authored Dec 8, 2020
2 parents 62b758f + f92b66c commit ae503de
Show file tree
Hide file tree
Showing 20 changed files with 341 additions and 230 deletions.
34 changes: 6 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,9 @@
this is WIP @salbei and no warranties are given

# grad-introCam
# grad-introCam - Anleitung im [WIKI](https://github.com/gruppe-adler/grad-introCam/wiki)
=======

aliascartoons intro script inspired me to a complete refactoring/rewriting.
## Features
- Quickcreation of shots
- Simple usage of Camera system

planning to implement further features (text effects etc) too


# How To
1. Put grad-introCam in your mission root.

2. Include cfgFunctions in your description.ext like this
```
class cfgFunctions {
#include "grad-introCam\cfgFunctions.hpp"
};
```

3. Add cam shot definitions to grad-introCam\functions\server\fn_shotDefinitions.sqf

You can add as many as you like. There are currently three different camera types:
"FREE" - moves between two points
"ATTACHED" - moves along with a vehicle/unit
"ROTATE" - rotates around a point/unit/vehicle

You can define start/end position, camTarget, duration of camera shot, start/end fov (smaller is more zoom) and camera offset. Rotation takes some different parameters, just check the example.

["FREE", pos1, pos2, target, duration, fov1, fov2, offset (optional)],
["ATTACHED", pos1, pos2, target, duration, fov1, fov2, offset (optional)],
["ROTATE", angleStart, angleEnd, target, duration, fov1, fov2, radius (int), cclockwise (bool)]
Demo: https://github.com/gruppe-adler/CO_introCamTest.Altis
29 changes: 15 additions & 14 deletions cfgFunctions.hpp
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
class GRAD_introCam {
#ifndef MODULES_DIRECTORY
#define MODULES_DIRECTORY modules
#endif

class GRAD_introCam {
class client {
file = grad-introCam\functions\client;

class camAttached;
class camCommands;
class camFree;
class camRotate;
class play;
file = MODULES_DIRECTORY\grad-introCam\functions\client;
class blackOnLoad { postInit = 1; };
class blend;
class camAttached;
class camMove;
class camRotate;
class createCam;
class handleNextShot;
class play;
};

class server {
file = grad-introCam\functions\server;

class addShot;
class init;
class shotDefinitions { postInit = 1; };
file = MODULES_DIRECTORY\grad-introCam\functions\server;
class init { postInit = 1; };
};

};
12 changes: 12 additions & 0 deletions functions/client/fn_blackOnLoad.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
if !(hasInterface) exitWith {};

[] call compile preprocessFileLineNumbers "USER\userIntro.sqf";
(GRAD_introCam_shotDefinitions select 0) params ["_type", "", "", "", "", "", ["_blackFade", false]];

if (
GRAD_introCam_playOnStart &&
{_type isEqualTo "CAMERA"} &&
{_blackFade}
) then {
cutText ["", "BLACK FADED", 999];
};
58 changes: 58 additions & 0 deletions functions/client/fn_blend.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
params ["", "_duration", ["_titleText", []], ["_blendOut", -1], ["_blendIn", -1]];

if (_blendOut >= 0) then {
cutText ["", "BLACK OUT", _blendOut];
} else {
_blendOut = 0;
};

[{
params ["_titleText", "_blendIn", "_blendOut", "_duration"];
_titleText params ["_titleTextType"];

switch (_titleTextType) do {
case "PLAIN": {
_titleText params ["", "_text"];
_text call BIS_fnc_titleText;
};
case "DYNAMIC": {
_titleText params ["", "_text", ["_x", -1], ["_y", -1], ["_duration", 4], ["_fadeInTime", 1], ["_deltaY", 0], ["_rscLayer", -1]];

if (_rscLayer > 0) then {
[_text, _x, _y, _duration, _fadeInTime, _deltaY, _rscLayer] spawn BIS_fnc_dynamicText;
} else {
[_text, _x, _y, _duration, _fadeInTime, _deltaY] spawn BIS_fnc_dynamicText;
};

};
case "TYPETEXT": {
_titleText params ["", "_text"];

[_text] spawn BIS_fnc_typeText;
};
case "TYPETEXT2": {
_titleText params ["", "_text"];

[_text] spawn BIS_fnc_typeText2;
};
case "INFOTEXT": {
_titleText params ["", "_text"];
[_text ] spawn BIS_fnc_infoText;
};
default {hint "Wrong string supplied to grad-introCam";};
};

if (_blendIn >= 0) then {
[
{
params ["_blendIn"];

cutText ["", "BLACK IN", _blendIn];
},
[_blendIn],
(_duration - _blendIn - _blendOut)
] call CBA_fnc_waitAndExecute;

};

}, [_titleText, _blendIn, _blendOut, _duration], _blendOut] call CBA_fnc_waitAndExecute;
30 changes: 15 additions & 15 deletions functions/client/fn_camAttached.sqf
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
params ["_campos1", "_campos2", "_target", "_duration", "_zoom1", "_zoom2", "_offset"];
_offset params ["_offsetX", "_offsetY", "_offsetZ"];
//#include "script_component.hpp"

if (typeName _campos1 isEqualTo "OBJECT") then {
_campos1 = getPos _campos1;
};
params ["_camera", "_args"];
_args params ["", "_duration", "_object", "_target",["_zoom", 0.75], ["_offset",[0,0,0]]];

_camera = "camera" camCreate _campos1;
_camera camSetFov _zoom1;
showCinemaBorder true;
_camera attachTo [_campos2, [_offsetX,_offsetY,_offsetZ]];
_camera cameraEffect ["internal", "BACK"];
_camera camCommand "inertia on";
_camera camPrepareTarget _target;
_camera camPrepareFOV _zoom2;
_camera camCommitPrepared _duration;
sleep _duration;
_camera attachTo [_object, _offset];
_camera camSetTarget _target;
_camera camSetFOV _zoom;
_camera camCommit 0;

[
{
detach _this;
},
_camera,
_duration
] call CBA_fnc_waitAndExecute;
47 changes: 0 additions & 47 deletions functions/client/fn_camCommands.sqf

This file was deleted.

36 changes: 0 additions & 36 deletions functions/client/fn_camFree.sqf

This file was deleted.

27 changes: 27 additions & 0 deletions functions/client/fn_camMove.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//#include "script_component.hpp"

params ["_camera", "_args"];
_args params [
"",
"_duration",
"_camPos",
"_target",
["_zoom", 0.75],
["_offset", [0,0,0]],
["_commitTime", -1]
];

if !(_camPos isEqualType []) then {
_camPos = getPos _camPos;
};

_camPos = _camPos vectorAdd _offset;
if (_commitTime < 0) then {
_commitTime = _duration;
};

// pos 2 - where camera is moving next - target2
_camera camSetPos _camPos;
_camera camSetTarget _target;
_camera camSetFov _zoom;
_camera camCommit _commitTime;
99 changes: 63 additions & 36 deletions functions/client/fn_camRotate.sqf
Original file line number Diff line number Diff line change
@@ -1,36 +1,63 @@
params ["_angleStart", "_angleEnd", "_target", "_duration", "_zoom1", "_zoom2", "_angle", "_radius", "_cclockwise"];

private _timeBegin = time;

private _targetPos = if (_target isEqualType []) then {_target} else {getPos _target};
private _coords = _targetPos getPos [_radius,_angle];

private _angleDelta = _angleEnd - _angleStart;
private _angleDistance = _duration / _angleDelta * 360 * 0.1;

// diag_log ["rotation: %1 + %2 + %3 + %4 + %5 + %6", _angleStart, _angleEnd, _angle, _radius, _angleDelta, _angleDistance];
// ["rotation: %1 + %2 + %3 + %4",150,100,89,scalar NaN]


private _camera = "camera" camCreate _coords;
showCinemaBorder true;
_camera cameraEffect ["internal", "BACK"];
_camera camCommand "inertia off";
_camera camPrepareTarget _target;
_camera camPrepareFOV _zoom1;
_camera camCommitPrepared 0;

while {(time - _timeBegin) < _duration} do {
private _targetPos = if (_target isEqualType []) then {_target} else {getPos _target};

private _coords = _targetPos getPos [_radius,_angle];

_camera camPreparePos _coords;
_camera camCommitPrepared 0.1;

waitUntil {camCommitted _camera};

_angle = if (_cclockwise) then {_angle - _angleDistance} else {_angle + _angleDistance};

systemChat format ["angle: %1", _angle];
};
//#include "script_component.hpp"

params ["_camera", "_args"];
_args params ["", "_duration", "_target", ["_height", 5], ["_radius", 10], ["_startingAngle", 0], ["_endAngle", 180], ["_clockwise", true], ["_rise", 0]];

GRAD_introCam_camRotateFinish = false;

private _angleDistance = _endAngle - _startingAngle;
if (_clockwise) then {
if (_endAngle < _startingAngle) then {
_angleDistance = 360 - _startingAngle + _endAngle;
};
}else{
if (_endAngle > _startingAngle) then {
_angleDistance = (360 - _endAngle) + _startingAngle;
};
};

private _steps = (_angleDistance / _duration) * 0.01;
private _riseSteps = if (_rise != 0) then {
((_rise / _duration) * 0.01)
}else{
0
};

_duration = _duration* 0.01;

GRAD_introCam_camAngle = _startingAngle;
private _pos = (_target getPos [_radius, _startingAngle]) vectorAdd [0,0, _height];
private _camAttachObj = "HeliHEmpty" createVehicleLocal _pos;
_camAttachObj setPos _pos;
_camera attachTo [_camAttachObj, [0, 0, 0]];
_camera camSetTarget _target;
_camera camCommit 0;

[
{
params ["_args", "_handle"];
_args params ["_camAttachObj", "_cam", "_target", "_steps", "_endAngle", "_endTime", "_riseSteps", "_radius"];
if (GRAD_introCam_camAngle == _endAngle || {time > _endTime}) exitWith {
[_handle] call CBA_fnc_removePerFrameHandler;
detach _cam;
deleteVehicle _camAttachObj;
GRAD_introCam_camRotateFinish = true;
GRAD_introCam_camAngle = nil;
[{GRAD_introCam_camRotateFinish = nil;},[],1] call CBA_fnc_waitAndExecute;
};

GRAD_introCam_camAngle = GRAD_introCam_camAngle + _steps;

private _newPos = _target getPos [_radius, GRAD_introCam_camAngle];
private _height = (getPosASL _camAttachObj) select 2;
if (_riseSteps != 0) then {
_height = _height + (_riseSteps);
};

_newPos set [2, _height];
_camAttachObj setPosASL _newPos;

},
0.01,
[_camAttachObj, _camera, _target, _steps, _endAngle, (time + (_duration * 100) + 0.1), _riseSteps, _radius]
]call CBA_fnc_addPerFrameHandler;
Loading

0 comments on commit ae503de

Please sign in to comment.