1 registered members (TipmyPip),
18,606
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
[Solved] Rotating an arbitrary oriented entity
[Re: xXxGuitar511]
#173860
12/28/07 17:41
12/28/07 17:41
|
Joined: Jan 2007
Posts: 221
Fenriswolf
OP
Member
|
OP
Member
Joined: Jan 2007
Posts: 221
|
I finally got it working! xXxGuitar, your code was absolutely correct. However, vec_rotate doesn't seem to work as expected in this particular case. As far as I know, the order in which the Euler angles are changed is important. Obviously, rotating the direction vector by each Euler angle seperatly solves the problem: Code:
vec_rotate(vec_to_ent, vector(temp.pan,0,0)); vec_rotate(vec_to_ent, vector(0,temp.tilt,0)); vec_rotate(vec_to_ent, vector(0,0,temp.roll));
Thank you all for your help!
|
|
|
Re: [Solved] Rotating an arbitrary oriented entity
[Re: Fenriswolf]
#173861
12/28/07 21:25
12/28/07 21:25
|
Joined: Mar 2006
Posts: 2,758 Antwerp,Belgium
frazzle
Expert
|
Expert
Joined: Mar 2006
Posts: 2,758
Antwerp,Belgium
|
Great to see you got it working  But could you post the entire code up again, just for convenience  Thanks in progress Frazzle
Antec® Case Intel® X58 Chipset Intel® i7 975 Quad Core 8 GB RAM DDR3 SSD OCZ®-VERTEX2 3.5 x4 ; HD 600 GB NVIDIA® GeForce GTX 295 Memory 1795GB
|
|
|
Re: [Solved] Rotating an arbitrary oriented entity
[Re: frazzle]
#173862
12/28/07 22:37
12/28/07 22:37
|
Joined: Jan 2007
Posts: 221
Fenriswolf
OP
Member
|
OP
Member
Joined: Jan 2007
Posts: 221
|
Of course; here is the working code: Code:
define barrel_handle, skill1;
action ent_turret { my.barrel_handle = handle(ent_create("turret_barrel.mdl", my.x, NULL)); while(my) { you = ptr_for_handle(my.barrel_handle); var vec_to_ent[3]; var ang_to_ent[3];
vec_diff(vec_to_ent, camera.x, my.x); // direction vector // transform the direction vector into local space via rotating it // by the turrets inverted angles vec_rotate(vec_to_ent, vector(-my.pan,0,0)); vec_rotate(vec_to_ent, vector(0,-my.tilt,0)); vec_rotate(vec_to_ent, vector(0,0,-my.roll)); vec_to_angle(ang_to_ent, vec_to_ent); // angle of direction vector
// first rotate the turret's body ang_rotate(my.pan, vector(ang_to_ent.pan,0,0)); // now rotate the barrel vec_set(you.pan, my.pan); ang_rotate(you.pan, vector(0,ang_to_ent.tilt,0)); wait(1); } }
|
|
|
Re: [Solved] Rotating an arbitrary oriented entity
[Re: Fenriswolf]
#173863
12/29/07 09:44
12/29/07 09:44
|
Joined: Mar 2006
Posts: 2,758 Antwerp,Belgium
frazzle
Expert
|
Expert
Joined: Mar 2006
Posts: 2,758
Antwerp,Belgium
|
Oke thanks  Cheers Frazzle
Antec® Case Intel® X58 Chipset Intel® i7 975 Quad Core 8 GB RAM DDR3 SSD OCZ®-VERTEX2 3.5 x4 ; HD 600 GB NVIDIA® GeForce GTX 295 Memory 1795GB
|
|
|
Re: [Solved] Rotating an arbitrary oriented entity
[Re: frazzle]
#173864
01/02/08 14:56
01/02/08 14:56
|
Joined: Mar 2006
Posts: 2,503 SC, United States
xXxGuitar511
Expert
|
Expert
Joined: Mar 2006
Posts: 2,503
SC, United States
|
Wow, I never thought about changing the order. I'm impressed, congratulations...
Cool. tested and confirmed. I have it working with a little Turret as well, but only using bones instead of multi-ents...
Last edited by xXxGuitar511; 01/02/08 20:49.
xXxGuitar511 - Programmer
|
|
|
|