mr.Flea 0 Posted May 26, 2007 Set 3-dimensional object's  vector [_OBJECT,[_Ox,_Oy,_Oz]]call compile preprocessfile "setdir3d.sqf" <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">#define OX 0 #define OY 1 #define OZ 2 private["_x","_y","_z","_a","_t_sin","_t_cos","_dir","_up"]; _a = _this select 1; _t_sin = sin -(_a select OX); _t_cos = cos -(_a select OX); _x = [ [_t_cos,_t_sin,0], [-_t_sin,_t_cos,0], [0,0,1] ]; _t_sin = sin (_a select OY); _t_cos = cos (_a select OY); _y = [ [1,0,0], [0,_t_cos,_t_sin], [0,-_t_sin,_t_cos] ]; _t_sin = sin (_a select OZ); _t_cos = cos (_a select OZ); _z = [ [_t_cos,0,-_t_sin], [0,1,0], [_t_sin,0,_t_cos] ]; #define M1(X,Y) ((_x select X) select Y) #define M2(X,Y) ((_y select X) select Y) #define ROL [\ [\ M2(0,0) * M1(0,0)+ M2(0,1)* M1(1,0)+ M2(0,2)* M1(2,0),\ M2(0,0) * M1(0,1)+ M2(0,1)* M1(1,1)+ M2(0,2)* M1(2,1),\ M2(0,0) * M1(0,2)+ M2(0,1)* M1(1,2)+ M2(0,2)* M1(2,2)\ ],\ [\ M2(1,0)* M1(0,0)+ M2(1,1)* M1(1,0)+ M2(1,2)* M1(2,0),\ M2(1,0)* M1(0,1)+ M2(1,1)* M1(1,1)+ M2(1,2)* M1(2,1),\ M2(1,0)* M1(0,2)+ M2(1,1)* M1(1,2)+ M2(1,2)* M1(2,2)\ ],\ [\ M2(2,0)* M1(0,0)+ M2(2,1)* M1(1,0)+ M2(2,2)* M1(2,0),\ M2(2,0)* M1(0,1)+ M2(2,1)* M1(1,1)+ M2(2,2)* M1(2,1),\ M2(2,0)* M1(0,2)+ M2(2,1)* M1(1,2)+ M2(2,2)* M1(2,2)\ ]\ ] _a = ROL; #undef M1 #undef M2 #define M1(X,Y) ((_a select X) select Y) #define M2(X,Y) ((_z select X) select Y) _a = ROL; #undef ROL #define ROL [\ M1(1,0) * VY + M1(2,0) * VZ,\ M1(1,1) * VY + M1(2,1) * VZ,\ M1(1,2) * VY + M1(2,2) * VZ\ ] #define VY 1 #define VZ 0 _dir = ROL; #undef VY #undef VZ #define VY 0 #define VZ 1 _up = ROL; (_this select 0) SetVectorDir _dir; (_this select 0) SetVectorUp _up; [_up,_dir] Set 2-dimensional object's  vector [_object[_Ox,_Oz]] call compile preprocessfile "setdir2d.sqf" <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> private["_a","_b","_dir","_up"]; _a = _this select 1 select 0; _b = _this select 1 select 0; _dir = [ sin _a * cos _b, cos _a * cos _b, sin _b ]; _b = _b + 90; _up = [ sin _a * cos _b, cos _a * cos _b, sin _b ]; (_this select 0) SetVectorDir _dir; (_this select 0) SetVectorUp _up; [_up,_dir] PS The function will work correctly only if given object do not collide with other objects (groound,water, buildings etc) Share this post Link to post Share on other sites
mr.Flea 0 Posted May 28, 2007 Quote[/b] ]private["_a","_b","_dir","_up"];_a = _this select 1 select 0; _b = _this select 1 select 1; _dir = [ sin _a * cos _b, cos _a * cos _b, sin _b ]; _b = _b + 90; _up = [ sin _a * cos _b, cos _a * cos _b, sin _b ]; (_this select 0) SetVectorDir _dir; (_this select 0) SetVectorUp _up; [_up,_dir] Share this post Link to post Share on other sites
mandoble 1 Posted May 28, 2007 Set 2-dimensional object's vector[_object[_Ox,_Oz]] call compile preprocessfile "setdir2d.sqf" [_object, [_Ox,_Oz]] call compile preprocessfile "setdir2d.sqf" Great implementation of the transformation matrix Share this post Link to post Share on other sites
mr.Flea 0 Posted May 28, 2007 Flying projection <a href="ftp://www.armedassault.info/_hosted/rau/flea/ play.rar" target="_blank">Top Gun (42 kb)</a> Â Share this post Link to post Share on other sites
mr.Flea 0 Posted May 28, 2007 Top Gun(not dead link) Share this post Link to post Share on other sites
chris330 0 Posted September 23, 2007 Looks amazing! How the hell does it work? I assume all that M stuff is matrix multiplication? Could you explain it a little more if you can please? Sorry to ask but it really does look the business and I'd like to know more about it Share this post Link to post Share on other sites