|
7 registered members (fairtrader, Quad, miwok, Martin_HH, AndrewAMD, alibaba, dpn),
581
guests, and 0
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
giving c_trace a direction?
#287338
08/31/09 13:37
08/31/09 13:37
|
Joined: Mar 2008
Posts: 2,247 Baden Württemberg, Germany
Espér
OP
Expert
|
OP
Expert
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
|
ok.. you know that you´re able to trace below the object with
c_trace(my.x, vector(my.x, my.y, my.z-100), ...);
But when i rotate the model, i want to trace to his new-below automatical now. Example (yellow = object, red = trace ):  Question: Can someone give me a script to do that??? (me=noob at trigonometrics )
Last edited by Espér; 08/31/09 13:38.
|
|
|
Re: giving c_trace a direction?
[Re: Espér]
#287343
08/31/09 14:00
08/31/09 14:00
|
Joined: Sep 2003
Posts: 5,900 Bielefeld, Germany
Pappenheimer
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
|
If you want to learn the 3DGS related trigonometry, look out for the Kinji Vector Tutorials, they are unbelievable easy.
You need this:
VECTOR temp;//in case you didn't already define it
vec_set(temp, my.pan); temp.tilt -= 90;//turn the angle to look below the entity vec_for_angle(temp, temp);//transform the angle to a direction vec_scale(temp, 4000);// vec_add(temp, my.x);//add the new values to the position of the Entity
c_trace(my.x, temp, ...);
It is not tested, I tend miss or mix up things. For testing, set the scaling to a value like the hight of your entity, and create an entity at that position, something like:
if(key_p)ent_create("star.tga", temp, NULL);
|
|
|
Re: giving c_trace a direction?
[Re: Pappenheimer]
#287359
08/31/09 15:46
08/31/09 15:46
|
Joined: Mar 2008
Posts: 2,247 Baden Württemberg, Germany
Espér
OP
Expert
|
OP
Expert
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
|
hmm.. both are not working correct.. Pappenheimer.. deins bringt mir immer nen crash in der Objektaktion Rei, in your code, my crosshair ( wich is ymbol of the new target ) stays only at the side of the object: (the yellow spot is the point, where the crosshair should stay ) 
|
|
|
Re: giving c_trace a direction?
[Re: Pappenheimer]
#287373
08/31/09 17:14
08/31/09 17:14
|
Joined: Feb 2009
Posts: 3,207 Germany, Magdeburg
Rei_Ayanami
Expert
|
Expert
Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
|
Du kannst mit mir auch deutsch reden  Hmm, eigentlich müsste es gehen... Edit: Ich habe was vegessen  Also nochmal
croshair.x = my.x + cos(das_teil_was_sich_dreht.pan)*die_länge_wie_weit_entfernt_sein_soll_in_quants;
croshair.y = my.y + sin(das_teil_was_sich_dreht.pan)*die_länge_wie_weit_entfernt_sein_soll_in_quants;
croshair.z = my.z + cos(das_teil_was_sich_dreht.tilt)*die_länge_wie_weit_entfernt_sein_soll_in_quants;
Muss funktinieren  !
|
|
|
Re: giving c_trace a direction?
[Re: Rei_Ayanami]
#287375
08/31/09 17:21
08/31/09 17:21
|
Joined: Jul 2002
Posts: 3,208 Germany
Error014
Expert
|
Expert
Joined: Jul 2002
Posts: 3,208
Germany
|
Rei - bei dir muss in die x- und y-koordinate noch ein sin(bla.tilt). Schaut man direkt nach vorne (tilt=0) so darf ja, wenn ich das Ausgangsproblem recht verstehe, nichts bei der x und y koordinate addiert werden. Ein sin wie oben angegeben würde das korrigieren (siehe übrigens auch: Kugelkoordinaten - das hat sehr, sehr ähnliche sin/cos-geschichten ;))
keine ahnung, ob das in lite-c auch so ist, aber früher, als ich noch jung war, da gab es den befehl vec_rotate. damit wäre das ein
vec_set(temp,vector(0,0,-100)); //100 quants nach unten vec_rotate(temp,my.pan); //oder wessen pan auch immer vec_add(temp,my.x); //temp hat nun die gewünschte position
... mag alles falsch sein. himmel, ist das lange her
Perhaps this post will get me points for originality at least.
Check out Dungeon Deities! It's amazing and will make you happy, successful and almost certainly more attractive! It might be true!
|
|
|
|