4 registered members (ozgur, Ayumi, VHX, monarch),
1,161
guests, and 4
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Need a laser beam particle effect example
[Re: Ercoles]
#413553
12/15/12 10:59
12/15/12 10:59
|
Joined: May 2009
Posts: 5,370 Caucasus
3run
Senior Expert
|
Senior Expert
Joined: May 2009
Posts: 5,370
Caucasus
|
OMFG... Are you kidding mate? We are talking about particles, right? p.vel_x only will work in the body of the particle function! GO READ FUCKING MANUAL!
function blah_particle(PARTICLE* p){
VECTOR vTemp;
// move in X direction, with speed 15:
vec_set(vTemp, vector(15, 0, 0));
// rotate vector above with camera angles (make movement local):
vec_rotate(vTemp, camera.pan);
// apply to particle:
vec_set(p.vel_x, vTemp);
}
And don't ask such a silly question, or very soon no one will answer them.
|
|
|
Re: Need a laser beam particle effect example
[Re: 3run]
#413565
12/15/12 13:10
12/15/12 13:10
|
Joined: Apr 2011
Posts: 75 Malta
Ercoles
OP
Junior Member
|
OP
Junior Member
Joined: Apr 2011
Posts: 75
Malta
|
You seem not understand me, so I posted the whole routine here:
ENTITY* gun1; ENTITY* gun2;
function p_alphafade(PARTICLE *p) { p.alpha -= p.skill_a*time_step; if (p.alpha <= 0) p.lifespan = 0; }
function p_trace(PARTICLE *p) { VECTOR vTemp; set(p, BRIGHT|TRANSLUCENT|BEAM); p.size = 1; p.skill_a = 10; // fade factor p.event = p_alphafade; p.red =255; p.blue=20; p.green=128; }
action tracer_right() { VECTOR vTemp; vec_set(vTemp, vector(0, 150, 30)); vec_rotate(vTemp, camera.pan); effect(p_trace,1,vector(camera.x+100+(150*cos(camera.pan)),camera.y-(150*sin(camera.pan)),camera.z-30),vTemp); }
action tracer_left() { VECTOR vTemp; vec_set(vTemp, vector(0, -150, 30)); vec_rotate(vTemp, camera.pan); effect(p_trace,1,vector(camera.x+100+(150*cos(camera.pan)),camera.y+(150*sin(camera.pan)),camera.z-30),vTemp); }
function main() { video_screen = 1; video_mode = 12; vec_set(sky_color,vector(0,0,0)); level_load(NULL); video_window(NULL,NULL,0,"Laser demo"); camera.x=0; camera.y=0; camera.z=0; camera.pan=0; camera.tilt=0; while (1){ //camera.pan -= mouse_force.x*2; //camera.tilt += mouse_force.y*2; if (mouse_left == 1){ if(proc_status(tracer_right) < 5) { gun1=ent_create(NULL,NULL,tracer_right); } if(proc_status(tracer_left) < 5) { gun2=ent_create(NULL,NULL,tracer_left); } } wait(1); } }
The routine as it is will show 2 lasers firing to a fixed point in the middle. What I need is that when I uncomment the 2 lines which allow panning and tilting of the camera the 2 lasers remain firing in the middle and not go to different directions.
|
|
|
Re: Need a laser beam particle effect example
[Re: Ercoles]
#413607
12/15/12 19:57
12/15/12 19:57
|
Joined: Apr 2011
Posts: 75 Malta
Ercoles
OP
Junior Member
|
OP
Junior Member
Joined: Apr 2011
Posts: 75
Malta
|
At last I did it and the solution was really the vec_for_screen command, for the benefit of other people here is the code:
function p_alphafade(PARTICLE *p) { p.alpha -= p.skill_a*time_step; if (p.alpha <= 0) p.lifespan = 0; }
function p_trace(PARTICLE *p) { VECTOR vTemp; set(p, BRIGHT|TRANSLUCENT|BEAM); p.size = 1; p.skill_a = 10; // fade factor p.event = p_alphafade; p.red =255; p.blue=20; p.green=128; }
action tracer_right() { VECTOR v1; v1.x = mouse_pos.x; v1.y = mouse_pos.y; v1.z = 15; vec_for_screen(v1,camera); VECTOR v2; vec_set(v2, vector(0, 50, -30)); vec_rotate(v2, camera.pan); effect(p_trace,1,v1,v2); ent_remove(me); }
action tracer_left() { VECTOR v1; v1.x = mouse_pos.x; v1.y = mouse_pos.y; v1.z = 15; vec_for_screen(v1,camera); VECTOR v2; vec_set(v2, vector(0, -50, -30)); vec_rotate(v2, camera.pan); effect(p_trace,1,v1,v2); ent_remove(me); }
function main() { video_screen = 1; video_mode = 12; mouse_mode = 4; vec_set(sky_color,vector(0,0,0)); level_load(NULL); video_window(NULL,NULL,0,"Laser demo"); camera.x=0; camera.y=0; camera.z=0; camera.pan=0; camera.tilt=0; while (1){ //camera.pan -= mouse_force.x*2; //camera.tilt += mouse_force.y*2; if (mouse_left == 1){ if(proc_status(tracer_right) < 1) { ent_create(NULL,NULL,tracer_right); } if(proc_status(tracer_left) < 1) { ent_create(NULL,NULL,tracer_left); } } wait(1); } }
|
|
|
Re: Need a laser beam particle effect example
[Re: Ercoles]
#413617
12/15/12 22:21
12/15/12 22:21
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
I read those tutorials but they do not say much about vectors. My recommendation was not limited to vectors but to general stuff. Your code and your answers show that you're missing important basic knowledge. There are many vector commands in the manual which could be helpful for this task but tutorials about them are rare. Vector tutorials do not make much sense because they are a tools to achieve things, like bricks for a bricklayer. Now, a tutorial about bricks wouldn't help a brickalyer much, would it? He has to learn about bricks while learning how to lay bricks. I think that vec_for_screen or vec_to_screen could be usefull for this task. You're right about this. And PLEASE: indent your code and use code tags as Kartoffel already told you.
Always learn from history, to be sure you make the same mistakes again...
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|