Advertisement
Guest User

Untitled

a guest
Aug 3rd, 2015
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.40 KB | None | 0 0
  1. GetObjectBox = {
  2. //Use: _Box = [Object,Height_Int] call GetObjectBox;
  3. //Variables to be passed: [Object,Height];
  4.  
  5. //TO UNDERSTAND SIN AND COS SEE: https://www.mathsisfun.com/sine-cosine-tangent.html
  6. //THIS IS TO FIND THE LOCATION
  7.  
  8. _obj=_this select 0;
  9. _height = _this select 1;
  10. //Calculate Object Size
  11. //_front = BoundingBox ......
  12. //_back = BoundingBox .....
  13. //_left = BoundingBox .....
  14. //_right = BoundingBox .....
  15. //_top = BoundingBox .....
  16. //_bottom = BoundingBox .....
  17. //Calculate Front/Back sin
  18. // _FBSin = sin dir _obj .....
  19. //Calculate Front Location
  20. // _FLocation = _FBSin * _front .... //Needs to be in a worldPos [x,y,z]
  21. //Calculate Back Location
  22. // _BLocation = _FBSin * _back .... //Needs to be in a worldPos [x,y,z]
  23. //Calculate Left/Right sin
  24. // _LRSin = sin dir _obj .....
  25. //Calculate Left Location
  26. // _LLocation = _LRSin * _left .... //Needs to be in a worldPos [x,y,z]
  27. //Calculate Right Location
  28. // _RLocation = _LRSin * _right .... //Needs to be in a worldPos [x,y,z]
  29. //Calculate Top location
  30. //_topLocation = ((getPosWorld _obj) select 2) + _top;
  31. //Calculate Bottom Location
  32. //_bottomLocation = ((getPosWorld _obj) select 2) + _bottom; //Needs to be in a worldPos [x,y,z]
  33. //Add Height to Top Location
  34. //_topLocation = _topLocation + _height; //Needs to be in a worldPos [x,y,z]
  35. _return = [_FLocation,_BLocation,_RLocation,_LLocation,_topLocation,_bottomLocation];
  36. _return
  37. };
  38.  
  39. FindObjInBox = {
  40. //Use: [_FLocation,_BLocation,_RLocation,_LLocation,_topLocation,_bottomLocation,Object] call FindObjInBox;
  41. _FLocation = _this select 0;
  42. _BLocation = _this select 1;
  43. _RLocation = _this select 2;
  44. _LLocation = _this select 3;
  45. _topLocation = _this select 4;
  46. _bottomLocation = _this select 5;
  47. _Object = _this select 6;
  48. //_ObjectSize = BoundingBoxReal _Object .... //Get object size
  49. //Get List of objects within BoundingBoxSize;
  50. /*
  51. _size = BoundingBoxReal _obj ... //Calculate size of box here
  52. _goodObjects = [];
  53. //Below finds objects nearby.
  54. {
  55. if (_x distance _Object < _size) then {
  56. _goodObjects = _goodObjects + [_x];
  57. };
  58. } forEach nearObjects _Object;
  59. */
  60.  
  61. //Check if nearby objects are within Box
  62. /*
  63. {
  64. _xDist = _x distance _Object;
  65. if (_xDist distance _FLocation < _ObjectSize) then {
  66. _checkArray = [true];
  67. } else {
  68. _checkArray = [false];
  69. };
  70.  
  71. if (_xDist distance _RLocation < _ObjectSize) then {
  72. _checkArray = _checkArray + [true];
  73. } else {
  74. _checkArray = _checkArray + [false];
  75. };
  76.  
  77. if (_xDist distance _LLocation < _ObjectSize) then {
  78. _checkArray = _checkArray + [true];
  79. } else {
  80. _checkArray = _checkArray + [false];
  81. };
  82.  
  83. if (_xDist distance _RLocation < _ObjectSize) then {
  84. _checkArray = _checkArray + [true];
  85. } else {
  86. _checkArray = _checkArray + [false];
  87. };
  88.  
  89. if (_xDist distance _topLocation < _ObjectSize) then {
  90. _checkArray = _checkArray + [true];
  91. } else {
  92. _checkArray = _checkArray + [false];
  93. };
  94.  
  95. if (_xDist distance _bottomLocation < _ObjectSize) then {
  96. _checkArray = _checkArray + [true];
  97. } else {
  98. _checkArray = _checkArray + [false];
  99. };
  100. if (false in _checkArray) then {
  101. _return = _return + [_x];
  102. };
  103. } forEach _goodObjects;
  104. _return
  105. */
  106. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement