Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (ozgur, TipmyPip, AndrewAMD), 1,209 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 3 of 3 1 2 3
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 Offline
Senior Expert
3run  Offline
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!
Code:
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.


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
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
E
Ercoles Offline OP
Junior Member
Ercoles  Offline OP
Junior Member
E

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] #413586
12/15/12 16:35
12/15/12 16:35
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
http://tutorial.3dgamestudio.net/

Seriously.

The resource leak still exists btw.


Always learn from history, to be sure you make the same mistakes again...
Re: Need a laser beam particle effect example [Re: Uhrwerk] #413600
12/15/12 18:32
12/15/12 18:32
Joined: Apr 2011
Posts: 75
Malta
E
Ercoles Offline OP
Junior Member
Ercoles  Offline OP
Junior Member
E

Joined: Apr 2011
Posts: 75
Malta
I read those tutorials but they do not say much about vectors. There are many vector commands in the manual which could be helpful for this task but tutorials about them are rare. I think that vec_for_screen or vec_to_screen could be usefull for this task.

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
E
Ercoles Offline OP
Junior Member
Ercoles  Offline OP
Junior Member
E

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 Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Originally Posted By: Ercoles
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.
Originally Posted By: Ercoles
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.
Originally Posted By: Erocles
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...
Page 3 of 3 1 2 3

Gamestudio download | chip programmers | 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