|
|
stretching sprite from point a to point b
#268481
05/29/09 14:27
05/29/09 14:27
|
Joined: Jun 2006
Posts: 2,640 Earth
Germanunkol
OP
Expert
|
OP
Expert
Joined: Jun 2006
Posts: 2,640
Earth
|
Hi! I want to create a lightning effect and I've created the sprites. I have three problems: -A sprite's size seems to depend on the image size (correct me if I'm wrong) so if I use vec_normalize(sprite.scale_x,vec_dist(pointA,pointB)); I get something that's way too big, cause sprite.scale_x == 1 does not mean its one quant in length. -Orientation issues... vec_diff(temp,pointA,pointB); vec_to_angle(sprite.pan,temp); won't work, because in 3d, a sprite's x axis isn't along the image's 2d x axis, instead it's perpendicular to the images x and y axis. -origin of a sprite is its middle, so I need to move it so that the end of the sprite is at either point a or point b.
I don't want to use a model instead.
Does someone have a script that streches a sprite from any given point a to point b? I've searched, but couldn't find anything... Thanks...
~"I never let school interfere with my education"~ -Mark Twain
|
|
|
Re: stretching sprite from point a to point b
[Re: Germanunkol]
#268708
05/30/09 19:19
05/30/09 19:19
|
Joined: Jun 2006
Posts: 2,640 Earth
Germanunkol
OP
Expert
|
OP
Expert
Joined: Jun 2006
Posts: 2,640
Earth
|
there must be somewhere here who's used sprites for lightning effects? Any AUM that does it? does anyone know?
~"I never let school interfere with my education"~ -Mark Twain
|
|
|
Re: stretching sprite from point a to point b
[Re: Germanunkol]
#268740
05/30/09 21:52
05/30/09 21:52
|
Joined: Dec 2008
Posts: 271
Saturnus
Member
|
Member
Joined: Dec 2008
Posts: 271
|
Hello! The following code should work for you, I think. You need to know the unscaled height of your sprite in quants to make use of it. Just substract your sprite's "min_y" property from its "max_y" property to get the height.
VECTOR vec_to;
ANGLE ang_to;
vec_diff(vec_to, pointB, pointA);
vec_to_angle(ang_to, vec_to);
// H = unscaled height of yourSprite in quants
yourSprite->scale_y = vec_length(vec_to) / H;
vec_lerp(vec_to, pointA, pointB, 0.5);
vec_set(yourSprite->x, vec_to);
yourSprite->pan = ang_to.pan;
yourSprite->tilt = ang_to.tilt + 90;
yourSprite->roll = 0;
|
|
|
Re: stretching sprite from point a to point b
[Re: Saturnus]
#268871
05/31/09 15:21
05/31/09 15:21
|
Joined: Jun 2006
Posts: 2,640 Earth
Germanunkol
OP
Expert
|
OP
Expert
Joined: Jun 2006
Posts: 2,640
Earth
|
thank you very much! you.pan = ang_to.pan; you.tilt = ang_to.tilt+90; you.roll = 90; worked better for me. But the rest of your code was just what I needed! 
~"I never let school interfere with my education"~ -Mark Twain
|
|
|
|