bmap_to_alpha and particles

Posted By: Futurulus

bmap_to_alpha and particles - 01/12/08 06:19

Hi everyone,

I'm trying to make a laser effect for my game, and the manual says that bmap_to_alpha has replaced "flare", which I used extensively in A6. Here is my Code:
BMAP* BeamBmap = "laserpart.pcx";

function BeamPart(PARTICLE* this)
{
this.bmap = BeamBmap;
this.size = 2;
this.flags |= BEAM | TRANSLUCENT;
this.lifespan = .001; // lasts one frame: a new beam is created each frame
this.event = NULL;
}

function InitFX()
{
bmap_to_alpha(BeamBmap, 100);
return 1;
}


The results, however, aren't what I expected. The way it is, with the percent factor set at 100, the beam disappears:

Same for 30% (which the manual recommended) and 0%.

With the factor set to -100, the particles are opaque, black squares:

But without the bmap_to alpha, the particles have ugly black halos:


What am I doing wrong? I don't think this is a bug in Gamestudio; this project has had many problems, and all but one have been my fault. It's usually something simple, too. Can other pairs of eyes catch what mine have missed?

Sorry if the pictures don't show up; Google's been having issues lately...
Posted By: Frederick_Lim

Re: bmap_to_alpha and particles - 01/13/08 14:57

Same here, the result of bmap_to_alpha() is not looks like "flare" flag in C-script.
Posted By: Scorpion

Re: bmap_to_alpha and particles - 01/18/08 22:59

then just open gimp. copy the image, put it into the alphachanel as greyscale image and save the whole stuff as *.tga
Posted By: Futurulus

Re: bmap_to_alpha and particles - 01/18/08 23:13

Yeah, I ended up doing that with Paint Shop Pro -- but the 60-day trial version doesn't last forever! It's easier in script, too. I'm not used to sophisticated image programs, layers and all that
Posted By: Scorpion

Re: bmap_to_alpha and particles - 01/19/08 10:33

here I wrote a little function, that should do the job, too:

Code:
void create_flare(BMAP* picture)
{
VECTOR picture_size;
VECTOR paintPos;
int i;
int format;
float pixel;
picture_size.x = bmap_width(picture);
picture_size.y = bmap_height(picture);
format = bmap_lock(picture,0);
for(i=0;i<picture_size.x*picture_size.y;i++)
{
paintPos.x = i%picture_size.x;
paintPos.y = (picture_size.y-1)-integer(i/picture_size.x);
pixel=pixel_for_bmap(picture,paintPos.x,paintPos.y);
pixel_to_vec(temp,NULL,format,pixel);
pixel = pixel_for_vec(temp,(temp.x+temp.y+temp.z)/3/2.55,format);
pixel_to_bmap(picture,paintPos.x,paintPos.y,pixel);
}
bmap_unlock(picture);
}


Posted By: tompo

Re: bmap_to_alpha and particles - 01/19/08 11:18

look at my old contribution... laser from .tga maybe will help
LINK
Posted By: Futurulus

Re: bmap_to_alpha and particles - 01/19/08 21:18

@Scorpion: I'm getting black boxes with your function, too. I see how it should work...what type of value does pixel_for_vec return? And if my image isn't already in an alpha format, does your function support it? If I make a PNG image with a few black pixels entirely transparent so I know it has an alpha channel, the particles disappear altogether.

@tompo: That is the kind of effect I'm looking for, but that's written in C-Script. Lite-C is the core of the problem: flare doesn't exist anymore, and the suggested replacement doesn't seem to do what it's supposed to.

EDIT: here is a link to my Gamestudio Picasa album, so you can see the pictures: http://picasaweb.google.com/Futurulus/Gamestudio
Posted By: Scorpion

Re: bmap_to_alpha and particles - 01/20/08 11:43

pixel_for_bmap gets the pixel-color/alpha of the bmap in a single float variable.
pixel_to_vec converts it to a color-vector, which is temp here.
pixel_for_vec again returns such a float variable
pixel_to_bmap writes it to the position again

the only thing i could think of, that you convert that bmap to another format(with alpha), but i don't know a function that does that. So try to save them already as 32-bit tgas. Then it should work.
© 2024 lite-C Forums