Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
4 registered members (fogman, Grant, AndrewAMD, juanex), 989 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Laser targeting #123574
04/12/07 22:26
04/12/07 22:26
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
tompo Offline OP
User
tompo  Offline OP
User

Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
How to create a thin line from a gun to the target? Like gun's light?
I understand that I have to trace from gun to target and I can do it.
But now, how to create a line from gun x,y,z to target x,y,z?


Never say never.
Re: Laser targeting [Re: tompo] #123575
04/12/07 22:35
04/12/07 22:35
Joined: Dec 2005
Posts: 252
MyOwnKingdom
nipx Offline
Member
nipx  Offline
Member

Joined: Dec 2005
Posts: 252
MyOwnKingdom
you could use particles.
or a model and scale it.


nipx

Re: Laser targeting [Re: nipx] #123576
04/12/07 22:53
04/12/07 22:53
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
tompo Offline OP
User
tompo  Offline OP
User

Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
I know that but how?
and if You scaled a model he is scaled to both direction, not only from gun to target.
Particles... you mean 100000000 particles ony by one to create a line?!
It doesn't look like good (fast render) idea


Never say never.
Re: Laser targeting [Re: tompo] #123577
04/12/07 23:08
04/12/07 23:08
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
For particles, it's simply one particle "streaked" between the two points...

For the entity, you can scale only one dimension. ex: my.scale_x = 10;


xXxGuitar511
- Programmer
Re: Laser targeting [Re: xXxGuitar511] #123578
04/12/07 23:26
04/12/07 23:26
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
tompo Offline OP
User
tompo  Offline OP
User

Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
Give me a code to streak between two ponits, please;)
Of'course You can scale only my.scale_x but it's growing to both directions, to and from the emiter (gun). Or maybe I'm wrong.. so give me example script;)


Never say never.
Re: Laser targeting [Re: tompo] #123579
04/12/07 23:28
04/12/07 23:28
Joined: Dec 2005
Posts: 252
MyOwnKingdom
nipx Offline
Member
nipx  Offline
Member

Joined: Dec 2005
Posts: 252
MyOwnKingdom
Quote:

Give me a code to streak between two ponits, please;)



-> my.streak=on; in your particle script.

give me a min for the scale_x...

nipx

1000 posts (! much ! fanfare !) congrat

Re: Laser targeting [Re: nipx] #123580
04/12/07 23:43
04/12/07 23:43
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
tompo Offline OP
User
tompo  Offline OP
User

Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
I know my.streak =on function:)
but how to make streak from vector1 to vector2 ?

I've made something like this, but doesn't look well:

function laser_fun
{
my.lifespan = 0;
}

function laser_fun
{
my.bmap = sparkle_bmp; my.passable = off; my.beam = on;
my.flare = on; my.bright = on; my.streak = on;
my.transparent = on; my.alpha = 70;
vec_add (my.vel_x, gun_pos);
my.function = laser_fun;
}

function laser_fire
{
while(mouse_left == 1)
{
effect(laser_fun,1,gun.pos,normal);
wait(5);
}
}


function gun_fun
{
gun = me;
while(1)
{

vec_diff(gun_pos,target.x,my.pos); //target is the result of trace

wait(1);
}
}
on_mouse_left laser_Fire;


Never say never.
Re: Laser targeting [Re: tompo] #123581
04/13/07 00:10
04/13/07 00:10
Joined: Dec 2005
Posts: 252
MyOwnKingdom
nipx Offline
Member
nipx  Offline
Member

Joined: Dec 2005
Posts: 252
MyOwnKingdom
ok, try this:

1.set correct hull
2.get the original size
3.always look to the target
4.put in the middle (before you get the factor!)
5.get the factor to stretch
6.scale it with this factor


===>>>
Code:
	

var originalSize;
var distToTarget;
var finalLength;

//wait for first BB
wait(1);

//set correct hull
c_setminmax(me);

//get the original size
originalSize=my.max_x*2;

//look to target
vec_set(temp, target.x);
vec_sub(temp, my.x);
vec_to_angle(my.pan, temp);

//calculate distance
distToTarget=vec_dist(my.x, target.x);

//place in the middle
vec_set(temp, my.x);
vec_sub(temp, target.x);
vec_add(my.x, temp);


///**** not sure if this works. if not try this: ****///
//my.x+=target.x-my.x;
//my.y+=target.y-my.y;
//my.z+=target.z-my.z;
//**** ****///


//calculate factor
finalLength=distToTarget/originalSize;

//scale the model
my.scale_x=finalLength;




didnt really test this code, but could work



nipx

Re: Laser targeting [Re: nipx] #123582
04/13/07 06:36
04/13/07 06:36
Joined: Jun 2006
Posts: 2,640
Earth
Germanunkol Offline
Expert
Germanunkol  Offline
Expert

Joined: Jun 2006
Posts: 2,640
Earth
for the particles, I have the code somewhere...

(note: you need at least commercial for the streak effect to work)

Code:


function delete_line()
{
if(my.alpha < my.skill_a && my.skill_c == 0)
{
my.alpha + = 20*time_step;
}
else
{
my.skill_c = 1;
my.alpha - = 2*time_step;
}
}

function line_red()
{
my.bmap = red_line;
my.move = off; //important!
my.streak = on;
my.alpha = 0;
my.bright = on;
my.transparent = on;
my.size = .75;
my.skill_a = 7;
my.function = delete_line;
}


//careful: the vectors you pass to this function have to be global vectors...
function draw_red_line(&vectorfrom,&vectorto)
{
vec_diff(temp,vectorto,vectorfrom);
effect(red_line,1,vectorfrom,temp);
}




Hope it helps...


~"I never let school interfere with my education"~
-Mark Twain
Re: Laser targeting [Re: Germanunkol] #123583
04/13/07 11:03
04/13/07 11:03
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
tompo Offline OP
User
tompo  Offline OP
User

Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
It's look the same what I've made


Never say never.

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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