Gamestudio Links
Zorro Links
Newest Posts
Zorro version 3.0 prerelease!
by Grant. 02/24/26 22:21
WFO Training with parallel cores Zorro64
by Martin_HH. 02/24/26 19:51
ZorroGPT
by TipmyPip. 02/23/26 21:52
Camera always moves upwards?
by clonman. 02/21/26 09:29
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 02/19/26 13:22
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
5 registered members (TipmyPip, clint000, Grant, chsmac85, Martin_HH), 5,858 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
alx, ApprenticeInMuc, PatrickH90, USER0328, Sfrdragon
19199 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
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 Offline OP
Expert
Germanunkol  Offline 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 Offline OP
Expert
Germanunkol  Offline 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 Offline
Member
Saturnus  Offline
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.

Code:
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 Offline OP
Expert
Germanunkol  Offline 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! smile


~"I never let school interfere with my education"~
-Mark Twain

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

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