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
0 registered members (), 16,302 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 1 of 2 1 2
Particles from one vertex to another #83353
07/26/06 13:06
07/26/06 13:06
Joined: Jun 2004
Posts: 2,234
Wisconsin USA
FoxHound Offline OP
Expert
FoxHound  Offline OP
Expert

Joined: Jun 2004
Posts: 2,234
Wisconsin USA
After a user requested this in the scripting forum, I put it together. Tought I might put it here for all to see.

Also check this page http://foxhound-production.com/3dgs/lazersight/lazersight.php
For a simualr particle effect used as a lazer sight.

entity* model_a;
entity* model_b;



function main
{
level_load("test_level.wmb");
wait(3);

model_a = ent_create("guard.mdl",vector(200,0,0), null);
model_b = ent_create("guard.mdl",vector(-200,0,0), null);
var var_1 = 1;
var i;
i = ent_vertices(model_a);

while(1)
{

var_1 %= i;
var_1 += 1;

particle_line(var_1);
model_a.pan += 1;
model_b.pan += 1;
wait(1);
}

}

function remove_flares()
{
my.lifespan = 0; // remove the flare particle
}

bmap beam = <beam2.tga>;
function particle_function()
{
my.bmap = beam;
my.flare = on;
my.bright = on;
my.size = 10;
my.transparent = on;
my.alpha = 50;
my.function = remove_flares;
}

var vector1[3];
var vector2[3];//local vars so this function can be ran several times at once
var dist;

FUNCTION particle_line(var_1)
{

var temp_array[3];

vec_for_vertex(vector1, model_a, var_1);//we get the vectors of the vertexs
vec_for_vertex(vector2, model_b, var_1);//same here

dist = vec_dist(vector1.x,vector2.x);//we get the distance of the vertexs
//return;
while(dist > 0)//until we are finished with this chain, NO WAIT!!!!
{
vec_set(temp,vector2.x);
vec_sub(temp,vector1.x);
vec_to_angle(temp_array,temp); // now TEMP_ARRAY looks at VECTOR2

temp.x = vector1.x + dist * cos (temp_array.pan);
temp.y = vector1.y + dist * sin (temp_array.pan);
temp.z = vector1.z + dist * tan (temp_array.tilt);//CALUCLATES THE ANGLE

effect(particle_function, 1, temp, normal);//CREATES THE PARTICLE

dist -= 1;//the higher this number the lower the quailty the particle line is, 5 is good

}
return;
}

font standard_font = "Arial",1,20; // truetype font
panel debug
{
flags = visible;
digits = 100,10,4,standard_font,1,vector1.x;
digits = 100,25,4,standard_font,1,vector1.y;
digits = 100,40,4,standard_font,1,vector1.z;

digits = 100,70,4,standard_font,1,vector2.x;
digits = 100,85,4,standard_font,1,vector2.y;
digits = 100,100,4,standard_font,1,vector2.z;
digits = 100,140,4,standard_font,1,dist;
}


---------------------
There is no signature here.


QUIT LOOKING FOR ONE!
Re: Particles from one vertex to another [Re: FoxHound] #83354
07/26/06 15:29
07/26/06 15:29
Joined: Sep 2003
Posts: 4,959
US
G
Grimber Offline
Expert
Grimber  Offline
Expert
G

Joined: Sep 2003
Posts: 4,959
US
you can put the my.lifespan in the partical definition itself, eliminating the function

Re: Particles from one vertex to another [Re: Grimber] #83355
07/29/06 03:58
07/29/06 03:58
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B Offline
Expert
mpdeveloper_B  Offline
Expert

Joined: Feb 2006
Posts: 2,185
and i thank you for the code foxhound ^^ nice of you to share it.

but if someone can post how to stretch an image between two vertices it was what i was really looking for


- aka Manslayer101
Re: Particles from one vertex to another [Re: mpdeveloper_B] #83356
07/29/06 05:16
07/29/06 05:16
Joined: Sep 2003
Posts: 4,959
US
G
Grimber Offline
Expert
Grimber  Offline
Expert
G

Joined: Sep 2003
Posts: 4,959
US
get the direction vector from vertex 1 to vertex 2

spawn the particals at one vertex1,
effect (function, var number, VECTOR* pos, VECTOR* speed);
in the VECTOR* speed parameter insert the direction vector you got from above.

set the particals lifespan = 0 ( or 1) mess with this depends on the distance from vert1 and vert 2

and set the particals streak flag on.


try that

Last edited by Grimber; 07/29/06 05:17.
Re: Particles from one vertex to another [Re: mpdeveloper_B] #83357
07/29/06 18:00
07/29/06 18:00
Joined: Jun 2005
Posts: 4,875
broozar Offline
Expert
broozar  Offline
Expert

Joined: Jun 2005
Posts: 4,875
Quote:

but if someone can post how to stretch an image between two vertices it was what i was really looking for




that would be awesome, too.
i need it for my podracer, see, i cannot simulate a lightning with particles that it looks like it should... with glow, many branches etc. without loosing a lot of performance.

0-0 <-- lightning between pods
|.|

Re: Particles from one vertex to another [Re: broozar] #83358
07/29/06 19:35
07/29/06 19:35
Joined: Sep 2003
Posts: 4,959
US
G
Grimber Offline
Expert
Grimber  Offline
Expert
G

Joined: Sep 2003
Posts: 4,959
US
if your using an animated sprite for the electric/lighting between the pod engines, you just need the distance and direction between the 2 vertexs ( of both you can find examples in the manual)

then align the sprite to the direction and scale it based on the distance ( original sprite size/ distance)

Re: Particles from one vertex to another [Re: Grimber] #83359
07/30/06 02:26
07/30/06 02:26
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B Offline
Expert
mpdeveloper_B  Offline
Expert

Joined: Feb 2006
Posts: 2,185
no, not stretching a particle, this is very simple that code is above, it is the contribution, what i mean is what DaBro0zar is agreeing would be good, to have a image, not particle, streched between two verteces, i already tried changing the scale_x, scale_y, and scale_z, these do not work, how can you stretch an image properly. The reason i want this so bad is it would really save on fps and it would be better for collisions, because i'm using spark effects when my saber collides...


- aka Manslayer101
Re: Particles from one vertex to another [Re: mpdeveloper_B] #83360
07/30/06 12:53
07/30/06 12:53
Joined: Sep 2003
Posts: 4,959
US
G
Grimber Offline
Expert
Grimber  Offline
Expert
G

Joined: Sep 2003
Posts: 4,959
US
yes, vertex attach the image ( sprite) to one vertex.
then get the vector direction from vertex 1 to vertex 2, convert that to angles
align the sprite to those angles

then getting the distance from vertex 1 to vertex 2 then scale the image( sprite) ( original hight in pixels /distance)

its no differnt then doing a vertex attachment with a model and aligning the model ( see the script exampls on acknext site) except your just adding in a scale calculation for distance

Re: Particles from one vertex to another [Re: Grimber] #83361
07/31/06 15:45
07/31/06 15:45
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B Offline
Expert
mpdeveloper_B  Offline
Expert

Joined: Feb 2006
Posts: 2,185
so like:
entity* player;
var create_ver;
var tilt_var;
var vertex_1 = 0; //change this to the first vertex num
var vertex_2 = 1; //change this to the second vertex num

action saber
{
vec_for_vertex (tilt_var, player, vertex_2);
my.pan = tilt_var;
my.tilt = tilt_var;
my.roll = tilt_var;
}

action player_act
{
player = me;
vec_for_vertex (create_ver, me, vertex_1);
ent_create ("sprite.tga", create_ver, saber_act);
}


- aka Manslayer101
Re: Particles from one vertex to another [Re: mpdeveloper_B] #83362
07/31/06 18:29
07/31/06 18:29
Joined: Sep 2003
Posts: 4,959
US
G
Grimber Offline
Expert
Grimber  Offline
Expert
G

Joined: Sep 2003
Posts: 4,959
US
not exactly in your saber action
vec_for_vertex gives a Location vector not a direction or angle vector

you subtract the FROM vector to the TO vector to get a direction vector from FROM to TO

then to convert a direction vector to pan/tilt/roll angles is done with vec_to_angle

and then if your using a sprite you will need (if i rexcall right) to add( or subtract) an 90 degree offset to the pan angle.

Page 1 of 2 1 2

Moderated by  adoado, checkbutton, mk_1, Perro 

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