Jump to content
thedubl

Top 4 corners of bouding box

Recommended Posts

Hello, I have seen a lot sling load scripts at they use the mounting points to attach ropes, however if there are objects (tanks, Hemitt, etc) that do not have mounting points it will default to a single rope and look kind of silly. So, I was going to improve this by making a array/file of vehicles and mounting points to use if it does not have any. OK... finally! Now the question is what is the best way to find the top corners of a bounding box real? Something like this (not a geometry person)?

 

configfile >> "CfgVehicles" >> typeof _obj >> "slingLoadCargoMemoryPoints"

 

https://community.bistudio.com/wiki/boundingBoxReal

_veh = _this select 0;

//from bwiki
_bbr = boundingBoxReal _veh; 						//finds the coordinates of the bounding box
_p1 = _bbr select 0;         						//pos 1
_p2 = _bbr select 1;         						//pos 2

_maxWidth = abs ((_p2 select 0) - (_p1 select 0));  //width
_maxLength = abs ((_p2 select 1) - (_p1 select 1)); //length
_maxHeight = abs ((_p2 select 2) - (_p1 select 2)); //height


_H = _maxHeight;        
_L = _maxLength;
_W = _maxWidth ;

//get the corner point of the vehicle
_c1 =[_p2];
_c2 =[(_p1 select 0), (_p1 select 1)+_H,(_p1 select 2)];                  //x only
_c3 =[(_p1 select 0), (_p1 select 1)+_H,(_p1 select 2)+_W];               //y and z 
_c4=[(_p2 select 0), (_p2 select 1),(_p1 select 2)+_W];                   //z only

Thanks for any help,

dub

Share this post


Link to post
Share on other sites

I would use this:

_bbr = boundingBoxReal _veh;
_p1 = _bbr select 0;
_p2 = _bbr select 1;

_x1 = _p1 select 0;
_y1 = _p1 select 1;
_z1 = _p1 select 2;
_x2 = _p2 select 0;
_y2 = _p2 select 1;
_z2 = _p2 select 2;

_dx = _x2 - _x1;
_dy = _y2 - _y1;


_m1 = [_x1 + _dx * 0.25, y1 + _dy * 0.25, _z2];
_m2 = [_x1 + _dx * 0.25, y1 + _dy * 0.75, _z2];
_m3 = [_x1 + _dx * 0.75, y1 + _dy * 0.25, _z2];
_m4 = [_x1 + _dx * 0.75, y1 + _dy * 0.75, _z2];

 

That way your hardpoints are half-way between the middle and the corners, reducing the risk of having them somewhere in mid-air.

  • Like 2

Share this post


Link to post
Share on other sites

Hey tajin! Cool, thanks! Once I get this all working I will update the post so that it may help others!

 

Thanks again!

dubl

Share this post


Link to post
Share on other sites

I would use this:

_bbr = boundingBoxReal _veh;
_p1 = _bbr select 0;
_p2 = _bbr select 1;

_x1 = _p1 select 0;
_y1 = _p1 select 1;
_z1 = _p1 select 2;
_x2 = _p2 select 0;
_y2 = _p2 select 1;
_z2 = _p2 select 2;

_dx = _x2 - _x1;
_dy = _y2 - _y1;


_m1 = [_x1 + _dx * 0.25, y1 + _dy * 0.25, _z2];
_m2 = [_x1 + _dx * 0.25, y1 + _dy * 0.75, _z2];
_m3 = [_x1 + _dx * 0.75, y1 + _dy * 0.25, _z2];
_m4 = [_x1 + _dx * 0.75, y1 + _dy * 0.75, _z2];

That way your hardpoints are half-way between the middle and the corners, reducing the risk of having them somewhere in mid-air.

Why not go further and have:

_dz = _z2 - _z1;

_m1 = [_x1 + _dx * 0.25, y1 + _dy * 0.25, _z1 + _dz * 0.75];
_m2 = [_x1 + _dx * 0.25, y1 + _dy * 0.75, _z1 + _dz * 0.75];
_m3 = [_x1 + _dx * 0.75, y1 + _dy * 0.25, _z1 + _dz * 0.75];
_m4 = [_x1 + _dx * 0.75, y1 + _dy * 0.75, _z1 + _dz * 0.75];

It wouldn't hurt if rope ends were merged into box by 1/4 on z. Even more reduced risk of having rope ends mid-air.

Though they aren't top points anymore.

Share this post


Link to post
Share on other sites

It's also possible that you may have to just define custom model points for each vehicle in some kind of config class that will be added to description.ext, if the effect doesn't turn out well. Note that I'm very lazy so I wouldn't suggest something like this unless I thought it was absolutely necessary.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×