Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
1 registered members (TipmyPip), 18,619 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
[Solved] Rotating an arbitrary oriented entity [Re: xXxGuitar511] #173860
12/28/07 17:41
12/28/07 17:41
Joined: Jan 2007
Posts: 221
F
Fenriswolf Offline OP
Member
Fenriswolf  Offline OP
Member
F

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 Offline
Expert
frazzle  Offline
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
F
Fenriswolf Offline OP
Member
Fenriswolf  Offline OP
Member
F

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 Offline
Expert
frazzle  Offline
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 Offline
Expert
xXxGuitar511  Offline
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
Page 2 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1