Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2017
360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.98 KB | None | 0 0
  1. /*
  2. Author: code34 nicolas_boiteux@yahoo.fr
  3. Copyright (C) 2014-2015 Nicolas BOITEUX
  4.  
  5. CLASS OO_CAMERA
  6.  
  7. This program is free software: you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation, either version 3 of the License, or
  10. (at your option) any later version.
  11.  
  12. This program is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20.  
  21. #include "oop.h"
  22.  
  23. CLASS("OO_CAMERA")
  24. PRIVATE VARIABLE("bool","attach");
  25. PRIVATE VARIABLE("object","camera");
  26. PRIVATE VARIABLE("string","name");
  27. PRIVATE VARIABLE("string","ctrlname");
  28. PRIVATE STATIC_VARIABLE("scalar","globalinstanceid");
  29. PRIVATE VARIABLE("scalar","instanceid");
  30.  
  31. PUBLIC FUNCTION("array","constructor") {
  32. private ["_cam", "_instanceid", "_name"];
  33.  
  34. _instanceid = MEMBER("globalinstanceid",nil);
  35. if (isNil "_instanceid") then {_instanceid = 0;};
  36. _instanceid = _instanceid + 1;
  37. MEMBER("globalinstanceid",_instanceid);
  38. MEMBER("instanceid",_instanceid);
  39.  
  40. _name = "rtt"+str(_instanceid);
  41. MEMBER("name", _name);
  42.  
  43. _cam = "camera" camCreate [position player select 0, position player select 1, 50];
  44. _cam cameraEffect ["internal","back", _name];
  45. MEMBER("camera", _cam);
  46.  
  47. _name = "ctrlname" + str(MEMBER("instanceid", nil));
  48. MEMBER("ctrlname", _name);
  49. };
  50.  
  51. PUBLIC FUNCTION("array","setPipEffect") {
  52. MEMBER("name", nil) setPiPEffect _this;
  53. };
  54.  
  55. PUBLIC FUNCTION("object", "backCamera"){
  56. _array = [_this,[0.7,-2,1.5]];
  57. MEMBER("attachTo", _array);
  58. };
  59.  
  60. PUBLIC FUNCTION("object", "topCamera"){
  61. _array = [_this,[0,0,30]];
  62. MEMBER("attachTo", _array);
  63. };
  64.  
  65. PUBLIC FUNCTION("object", "goProCamera"){
  66. _array = [_this,[0,1,0], "neck"];
  67. MEMBER("attachTo", _array);
  68. };
  69.  
  70. PUBLIC FUNCTION("array", "attachTo"){
  71. private ["_object", "_position", "_poscamera", "_vehicle"];
  72.  
  73. _object = _this select 0;
  74. _position = _this select 1;
  75.  
  76. if(count _this > 2) then {
  77. _poscamera = _this select 2;
  78. } else {
  79. _poscamera = "";
  80. };
  81. _vehicle = vehicle _object;
  82.  
  83. MEMBER("camera", nil) attachto [_object,_position, _poscamera];
  84. MEMBER("camera", nil) camSetTarget _object;
  85. MEMBER("camera", nil) camCommit 0;
  86. MEMBER("attach", true);
  87.  
  88. while { MEMBER("attach", nil) } do {
  89. if(_vehicle != vehicle _object) then {
  90. _vehicle = vehicle _object;
  91. MEMBER("camera", nil) attachto [_vehicle,_position, _poscamera];
  92. MEMBER("camera", nil) camSetTarget _vehicle;
  93. MEMBER("camera", nil) camCommit 0;
  94. };
  95. sleep 1;
  96. };
  97. };
  98.  
  99. PUBLIC FUNCTION("array", "detach"){
  100. MEMBER("attach", false);
  101. };
  102.  
  103. PUBLIC FUNCTION("object", "uavCamera", "_targetlock"){
  104. private ["_uav", "_position", "_wp"];
  105. _position = [position _this select 0, position _this select 1, 100];
  106. _uav = createVehicle ["B_UAV_A2_dynamicLoadout_F", _position, [], 0, "FLY"];
  107. createVehicleCrew _uav;
  108. _uav lockCameraTo [_targetlock, [0]];
  109. _uav flyInHeight 200;
  110. MEMBER("camera", nil) attachTo [_uav, [0,0,0], "PiP0_pos"];
  111.  
  112. while { alive _uav} do {
  113. _position = [position _this select 0, position _this select 1, 100];
  114. _wp = (group _uav) addWaypoint [_position, 0];
  115. _wp setWaypointType "LOITER";
  116. _wp setWaypointLoiterType "CIRCLE_L";
  117. _wp setWaypointLoiterRadius 100;
  118. sleep 30;
  119. deletewaypoint _wp;
  120. };
  121.  
  122. addMissionEventHandler ["Draw3D", {
  123. _dir =
  124. (uav selectionPosition "PiP0_pos")
  125. vectorFromTo
  126. (uav selectionPosition "PiP0_dir");
  127. cam setVectorDirAndUp [
  128. _dir,
  129. _dir vectorCrossProduct [-(_dir select 1), _dir select 0, 0]
  130. ];
  131.  
  132. sleep 30;
  133. deletevehicle _uav;
  134. };
  135.  
  136. PUBLIC FUNCTION("array","r2w") {
  137. uiNamespace setvariable [MEMBER("ctrlname", nil), findDisplay 46 ctrlCreate ["RscPicture", -1]];
  138. (uiNamespace getvariable MEMBER("ctrlname", nil)) ctrlSetPosition _this;
  139. (uiNamespace getvariable MEMBER("ctrlname", nil)) ctrlCommit 0;
  140. (uiNamespace getvariable MEMBER("ctrlname", nil)) ctrlSetText "#(argb,512,512,9)r2t("+ MEMBER("name", nil) + ",1.0)";
  141. };
  142.  
  143. PUBLIC FUNCTION("object","r2o") {
  144. private ["_object"];
  145. _object = _this;
  146. _object setObjectTexture [0, "#(argb,512,512,9)r2t("+ MEMBER("name", nil) + ",1.0)"];
  147. };
  148.  
  149. PUBLIC FUNCTION("","deconstructor") {
  150. camDestroy MEMBER("camera", nil);
  151. ctrlDelete (uiNamespace getvariable MEMBER("ctrlname", nil));
  152. DELETE_VARIABLE("attach");
  153. DELETE_VARIABLE("camera");
  154. DELETE_VARIABLE("ctrlname");
  155. DELETE_VARIABLE("instanceid");
  156. DELETE_VARIABLE("name");
  157. };
  158. ENDCLASS;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement