Effect problem

Posted By: tompo

Effect problem - 04/20/07 12:12

First a little introduction

I have a spaceship with laser and 3rd person camera.
Ship is rotating by:
c_rotate (me, vector(mose_hor *time_step,mouse_vert *time_step, 0), USE_AXISR);

moving by:
c_move(me,vector(my.speed *time_step *10,0,0),nullvector,GLIDE);

and targeting from player to ahead by:
temp.x = MOUSE_POS.x; temp.y = MOUSE_POS.y; temp.z = 1000;
vec_for_screen(temp,CAMERA); vec_set(my.x, temp); then trace.

Everything work very well and I have full freedom by moving ship in whole sphere with the mouse.

The problems are...
1. how to create effect (laser effect) with bmap using streak function and/or vel_x/y/z from player.pos to target.pos where this bmap is moving along this vector?!
I've tried with: vec_diff (along_vec,player.x,target.x) vec_add(my.vel_x,along_vec) but it doesn't work.

2. how to create good looking trail from player.x. I've tried create little sparkle.pcx in player.pos every while loop and then decrease the alpha, but the sparkles was separately. So i need streak in this case too, I think.

HELP!
Posted By: Germanunkol

Re: Effect problem - 04/20/07 12:50

for the laser/shot: (note: you need com or pro version for this to work)

Code:


function delete_line()
{
my.alpha - = 2*time_step;
if(my.alpha < = 0)
{
my.lifespan = 0;
}
}

function draw_line_red()
{
my.bmap = red_line;
my.move = off;
my.streak = on;
my.alpha = 80;
my.bright = on;
my.transparent = on;
my.size = .75;
my.function = delete_line;
}

function draw_line_3d(&vec_from,&vec_to)
{
vec_diff(temp,vec_to,vec_from);
effect(draw_line_red,1vec_from,temp);
}




how to use:
draw_line_3d(my.x,target.x);

for the trail:
what i do is creating a particle every frame, with a random bitmap (either red or yellow). red ones are larger than yellow ones.
they all have a random, very slow velocity, so that the trail is not perfectly straight, but looks like fire burning or something along those lines.


Code:


function vec_randomize(&vec, Speed)
{
vec[0] = random(speed)- speed /2;
vec[1] = random(speed)- speed /2;
vec[2] = random(speed)- speed /2;
}




function thruster_fade()
{
my.alpha - = 20 *time_step;
my.size - = 1 *time_step;
if(my.alpha <= 0 || my.size <= 0)
{
my.lifespan = 0;
}
}


function thruster_particles()
{
my.lifespan = 100;
my.alpha = 50;
if(int(random(1)) == 1)
{
my.bmap = RedPart2;
my.size = 20 ;
}
else
{
my.bmap = yellow_part;
my.size = 10 ;
}
my.bright = on;
my.move = on;
my.transparent = on;
my.function = thruster_fade;
}



// in the ship's action, inside a while 1 loop:
vec_randomize(temp, 3 ;)
effect(thruster_particles,1,my.x,temp);




you can change all red values, I don't know how large your ship is/how long the trail should be... so fiddle around with some numbers.
please tell me if this works...
hope it does

Micha
Posted By: xXxGuitar511

Re: Effect problem - 04/20/07 12:52

Why not use a model stretched from point A to B...?
Posted By: tompo

Re: Effect problem - 04/20/07 13:12

I allready have a model from a to b by using this:
web page
but with bmaps and streak, vel_x it will looks much better I think like muzzle or something.

About trail... this is nice but this is like truster_engine and I'm intereesting in smooth looking and thin trails (two) created on wings edges. Like in almost all space games
Posted By: Germanunkol

Re: Effect problem - 04/20/07 13:24

no problem.
make the "3" a smaller number, instead of creating the effect at "my.x", create it at a vertex position, make my.size half as big, or even smaller (the 20 and the 10), and change:
my.alpha - = 20 *time_step;
my.size - = 1 *time_step;
into:
my.alpha - = 5 *time_step;
my.size - = .5 *time_step;
or something like that.

for creating the effect at 2 vertecies, change:
vec_randomize(temp, 3
effect(thruster_particles,1,my.x,temp);
to:
var temp_pos[3];
vec_randomize(temp, .2
vec_for_vertex(temp_pos,10)
effect(thruster_particles,1,temp_pos,temp);
vec_randomize(temp, .2
vec_for_vertex(temp_pos,20)
effect(thruster_particles,1,temp_pos,temp);

the 10 and 20 need to be the numbers of the vertecies you want the effect to be at: find those numbers in MED, by clicking selecting a vertex and looking at the bottom of the window, where it should give you the number.

does that work for you`?
Posted By: tompo

Re: Effect problem - 04/20/07 13:26

laser fire something like this:
laser
and I supposed that this bmap is moving along this vector

trails... look at this ships and his trails
trails
look at this ship in deph field (the turning one) and those beutifull smooth trails behind this ship towads to player position:D

thruster and trails
next one
Posted By: tompo

Re: Effect problem - 04/20/07 14:39

And.... hard nut to crack?!
I don't really use models becouse:
1. its impossible (I think) to make such trails with models
2. f.e. 20 (only 20) ships in battle with 3 trails models (1 for thruster and
2 on wings) and with 3 laser models = (3+3)*20 +20 = 140 models to calculate in one loop! Not to render ofcourse but number of running functions will kill frame_rate I'm affraid
Posted By: Germanunkol

Re: Effect problem - 04/20/07 15:37

I'll try and create a demo with these 3 effects later on. I won't promise anything, these thrusters are pro effects, but I think I can get something along those lines. Stay tuned... I'll just finish watching Les Miserables, and then I'll get to work, these effects look great, and you got me interested in this

Micha
Posted By: tompo

Re: Effect problem - 04/20/07 15:52

These effects (thrusters and trials) are from old Microsofts game "Freelancer"
I've made something like this (laser and thruster) with flare.tga decresing alpha and size by time_step but I have a problem with streak and vel_x along vec_diff(player.pos,target.pos).
But I have no idea how to create these trials with bmp and streak or vel_x along player move vector becouse I have full freedom to rotate around 360 degree
Posted By: tompo

Re: Effect problem - 04/21/07 00:13

I've made something like this:

in player loop
Code:
 
a = cos(player.pan); b= sin(player.pan); c= sin(player.tilt);
effect(dummy_funkcja,1,my.pos,vector(a,b,c)); //the same direction as player



dummy_funkcja

Code:
 
my.bmap = wstega; //image above
my.passable = on; my.transparent = on; my.overlay = on;
my.alpha = random(30); my.flare = on;
my.size = random(1); my.bright = on;
my.move = on; my.streak = on; my.beam = on;
vec_add(my.vel_x,vector(a *2, b *2, c *2)); //to increase speed or with -2 to change dierection
my.function = dummy_f;



dummy_f
Code:

my.size = clamp(my.size,0,1);
my.size -= 0.1 * time_step;
my.alpha -= 0.1* time_step;
if(my.alpha <=0){my.lifespan = 0;}



Everything looks fine until ship is not moving. When I increase speed by c_move function spaces between bmps just split/spread/separate (my english)

If ship is not moving...
- increase speed, set +n in vel_x, increase lifespan and we'll have good lookin laser.
- decrease size, set -n in vel_x, set size and alpha to not random and we'll have nice trails towards to player.

Any sugestions?
Posted By: tompo

Re: Effect problem - 04/22/07 10:12

resluts...

When entity is not moving (i've made bigger to see effect)

nice trail towards player

But when ent is moving

every bmap is separate
Posted By: Germanunkol

Re: Effect problem - 04/22/07 12:54

how many particles is that? It looks very cool!..
do you give the particles any initial velocity? if yes, how about slowing that down?
Posted By: tompo

Re: Effect problem - 04/22/07 13:51

code for this is on the first site
but it doesn't work well
When ship is moving those maps are separated (see screen 2) and I have no idea how to create somethig like on screens from Freelancer by Microsoft.
About slowing down... second digits are fps so 90 is a good becouse I've set fps_max to 100 Screen resolutions is 1024x768x32bit
(Sempron 1.8GHz, 1GB Ram DDR1, GForce 6600GT AGP)
Posted By: Germanunkol

Re: Effect problem - 04/23/07 19:23

One thing I'd do is changing the sprite. I don't have much time right now, but i'll see if I can find something. one that blends better...
One thing you can try and do: add half of the ship's velocity to the particle's velocity...

define a vector at the beginning of your script:

var ship_movement[3];

and every time you c_move, set the ship_movement to the vector by which you move the ship. for instance, if you're doing:

c_move(my, temp, nullvector, ....);
then do
vec_set(ship_movement, temp);
vec_scale(ship_movement, .5);
right in front of that

then, when you call the effect, add the ship_movement to the velocity like this:
vec_add(temp, ship_movement);
effect(thruster_particles,1,my.x,temp);

does this change things at all?

you might want to try using fire2_blue.tga from easy particle 3...
Posted By: xXxGuitar511

Re: Effect problem - 04/24/07 03:01

Create a function that gets the distance between the new & old position of the ship, and then create a particle every X quants between those two positions.

This will give you a constant trail.
Posted By: vlau

Re: Effect problem - 04/24/07 07:50

Read my old missile trail code may be you'll get some idea from there.
Posted By: tompo

Re: Effect problem - 04/24/07 16:57

After a few modifications works great
THX a lot & 5 stars for this code
© 2023 lite-C Forums