Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (Ayumi), 662 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Rotating a vector around an object #463232
11/23/16 01:38
11/23/16 01:38
Joined: Aug 2014
Posts: 57
Y
Yking Offline OP
Junior Member
Yking  Offline OP
Junior Member
Y

Joined: Aug 2014
Posts: 57
Hello dear forum,

there is something I need help with and my understanding of vectors might be too limited to do so frown .

Basically I have a 3d model with an opening at one end (a cannon) and I want it to shoot projectiles.
Now, I do not want the projectiles to start shooting from the object-base (0/0/0) but rather from the opening.

In neutral position, I could just define a starting-point for my projectiles at the coordinates
Quote:
vector(object.x + 100, object.y, object.z + 20)

This way, when the object (the cannon) just stays as it is, the projectile can be created at my new coordinates, which is at the opening.

This works and is completely fine, but of course, as soon as I rotate my cannon it does not fit anymore.
The coordinates I defined for the starting-position of my projectile will always stay the same, no matter which way the cannon is rotated. This makes sense and I understand why it is like that, but I really want the starting-position to rotate along with the cannon in the correct way, so its always at the cannons opening.

In workshop 24 , all the way at the bottom, is a code for a 3rd person camera perspective, bound to the player-object. I figured that this code might fit my situation but so far I did not have any success with anything.

What is the best way to let my starting-position correctly rotate along with my object?
Thanks for any help in advance smile

Re: Rotating a vector around an object [Re: Yking] #463233
11/23/16 02:12
11/23/16 02:12
Joined: Aug 2014
Posts: 57
Y
Yking Offline OP
Junior Member
Yking  Offline OP
Junior Member
Y

Joined: Aug 2014
Posts: 57
I found my solution, it was
Quote:
vec_for_vertex

Solved all my problems grin !

Re: Rotating a vector around an object [Re: Yking] #463238
11/23/16 10:55
11/23/16 10:55
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
In situation as above, you could define an offset for vector, then rotate it with the object and after all that add to the results the origin position of the model (your 3d model).

It should be something like this:
Code:
vec_set(temp_vec.x, vector(100, 0, 20)); // values taken from your example
vec_rotate(temp_vec.x, my.pan); // my.pan - here is all angles of your 3d model
vec_add(temp_vec.x, my.x); // my.x - is the position of your 3d model


Best regards!


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Rotating a vector around an object [Re: 3run] #463277
11/26/16 02:37
11/26/16 02:37
Joined: Aug 2014
Posts: 57
Y
Yking Offline OP
Junior Member
Yking  Offline OP
Junior Member
Y

Joined: Aug 2014
Posts: 57
Thank you very much, 3run laugh !

I will try your solution out aswell laugh !


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