Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 14:22
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
4 registered members (AndrewAMD, Quad, soulman3, Ayumi), 675 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 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 | chip programmers | 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