3 registered members (TedMar, Ayumi, kzhao),
1,359
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Spreading the effect between two vertex
#290979
09/22/09 18:20
09/22/09 18:20
|
Joined: Oct 2006
Posts: 470 Balkan
Ganderoleg
OP
Senior Member
|
OP
Senior Member
Joined: Oct 2006
Posts: 470
Balkan
|
Hello, I was wondering if someone could help me with spreading the effect between two vertex in a straight line ?
I tried to use vec_for_vertex with vec_diff and vec_normalize but didn't get it right. All I achieved is to place(not to spread) effect between two vertex in a triangle-sort-of-way. Thanx.
Btw: I am using C-Script.
Last edited by Ganderoleg; 09/22/09 18:22.
|
|
|
Re: Spreading the effect between two vertex
[Re: Scorpion]
#291010
09/22/09 21:38
09/22/09 21:38
|
Joined: Aug 2007
Posts: 1,922 Schweiz
Widi
Serious User
|
Serious User
Joined: Aug 2007
Posts: 1,922
Schweiz
|
If you mean particle:
VECTOR Temp_vec1;
VECTOR Temp_vec2;
VECTOR Temp_vec2;
void WAFFEN_FX_FEUER(vertex_1,vertex_2)
{
while (my)
{
if (!is_e(my,CLIPPED))
{
vec_for_vertex (Temp_vec1,my,vertex_1);
vec_for_vertex (Temp_vec2,my,vertex_2);
for (i = 0;i < 5;i ++)
{
vec_lerp (Temp_vec3,Temp_vec1,Temp_vec2,random(1));
effect (WAFFE_ROT_PAR,4 * time,Temp_vec3,normal);
effect (WAFFE_FEUER_PAR,4 * time,Temp_vec3,normal);
}
}
wait(1);
}
}
So the effect shows up at a random position between the 2 vertices
Last edited by Widi; 09/22/09 21:41.
|
|
|
Re: Spreading the effect between two vertex
[Re: Widi]
#291018
09/22/09 23:10
09/22/09 23:10
|
Joined: Oct 2006
Posts: 470 Balkan
Ganderoleg
OP
Senior Member
|
OP
Senior Member
Joined: Oct 2006
Posts: 470
Balkan
|
Particles I need X number of particles to populate a distance from vertex1 to vertex2 on mdl object. The embarrassing part is that I'm already using that effect through script written by programmer signed as John (FlyingSword.wdl). It's just that I couldn't clone it fast and it should be just a few lines of code. So I thought I ask. This is the function that I think is responsible for light-effect on sword: FUNCTION LightSword(){ //"Magic, glowy, sparkly, ooh" effect vec_for_vertex(PointVec,my,vektor_1); //Sword Point, if you use a different model be sure to change the vertex Vec_for_vertex(tempvec,my,vektor_2); //Sword Hilt, if you use a different model be sure to change the vertex BladeLength = vec_dist(PointVec.x,tempvec.x); //My game uses varying sword lengths so I check the length each Time OrbitPlayerMin=MAX(BladeLength*2,70); //Set the orbitplayer distances based on the sword length OrbitPlayerMax=MIN(BladeLength*3,80);
vec_diff(tempangle,PointVec.x,tempvec.x); //Set tempangle to point from the hilt to the point effectcounter = BladeLength/2; //Calculate the number of effects we need to light the sword vec_normalize(tempangle,2); //normalize(reduce) the distance of tempangle to 2, we add //tempangle to the last effect position to calculate the //next effect position
WHILE((effectCounter>0)&&(partix==1)) { effect(SwordPlasma_effect,2,tempvec,tempvec); //generate a plasma effect along the sword blade vec_add(tempvec.x,tempangle.x); //calculate the position to generate the next effect effectcounter -=1; //decrement the effect counter } }
@WidiI will try the code but I believe it's in Lite-C. Will it work if I change it to C-Script(void to function etc.)?
|
|
|
Re: Spreading the effect between two vertex
[Re: Ganderoleg]
#291080
09/23/09 11:28
09/23/09 11:28
|
Joined: Aug 2007
Posts: 1,922 Schweiz
Widi
Serious User
|
Serious User
Joined: Aug 2007
Posts: 1,922
Schweiz
|
You can change "void" to "function", but i dont know moore about c-script.
Have a look at the line vec_lerp (Temp_vec3,Temp_vec1,Temp_vec2,random(1));
from my Code. vec_lerp gives you a random Point (Temp_vec3) between the two Points (Temp_vec1 and Temp_vec2).
I use this code also to show up a sword particleeffect.
Last edited by Widi; 09/23/09 11:28.
|
|
|
Re: Spreading the effect between two vertex
[Re: Widi]
#291094
09/23/09 12:28
09/23/09 12:28
|
Joined: Oct 2006
Posts: 470 Balkan
Ganderoleg
OP
Senior Member
|
OP
Senior Member
Joined: Oct 2006
Posts: 470
Balkan
|
This code works great! All I needed to do is lose for (works only in Lite-C) I placed it in my sword function: while (1) { vec_for_vertex(ringmvert_a, my, 6); vec_for_vertex(ringmvert_b, my, 9);
vec_lerp (ringmost_a,ringmvert_a,ringmvert_b,random(1)); effect(mana_cspezial,max(1,mana_cAnzahlPartikel*time),ringmost_a,normal); vec_lerp (ringmost_a,ringmvert_a,ringmvert_b,random(1)); effect(mana_cspezial,max(1,mana_cAnzahlPartikel*time),ringmost_a,normal); vec_lerp (ringmost_a,ringmvert_a,ringmvert_b,random(1)); effect(mana_cspezial,max(1,mana_cAnzahlPartikel*time),ringmost_a,normal); wait(1); }
Btw- I forgotten the way on how to make random more randomized so I placed vec_lerp after each effect. Without it they all go in a same rhythm and in the same move-path(even in a same direction). Thanx for code Widi.You really helped me out.
|
|
|
|