Collision Sprite3d Alphablending

Advanced game related topics
Fred
Administrator
Administrator
Posts: 18254
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

There is the SpritePixelCollision() which should also work almost correctly if your alpha sprite doesn't have too much shadow around it.
Preludian
User
User
Posts: 17
Joined: Thu Apr 27, 2006 7:01 pm
Location: lovely Bonn

Post by Preludian »

Unfortunately not ;( I have a masked PNG file. And even the nicest mask doesn't help. If you want I can send you the file to see for yourself if you don't believe me?

Edit: I just sent you an email (support@....) because I'll be home later on again and in case you would like to have a look............. :) it's a png and the code
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

You might need to make a second 2-color 2d sprite from the original 2d sprite you used as a texture, which is white where you want it to collide and black everywhere else. If you use that "mask-sprite" for collision testing, it really should work without problems.
BERESHEIT
Preludian
User
User
Posts: 17
Joined: Thu Apr 27, 2006 7:01 pm
Location: lovely Bonn

Post by Preludian »

@netmaestro: I know, but this would mean much more work and memory usage. I'd prefer not having to do it this way. Unfortunately I had to crop the sprites to a minimum for the collision to function, but now I do not have 2^x Sprites and I heard that even some newer ATI cards had problem with this, so if Fred doen't come up with a decent solution I will have to resort to the way you mentioned. Well thinking of it, I doubt that Fred will want to fix this one during the weekend, so :( oh well... but I really would prefer not having to code around bugs, this isn't meant PB specific, few applications are bullett proof, but annoying it is always...
Preludian
User
User
Posts: 17
Joined: Thu Apr 27, 2006 7:01 pm
Location: lovely Bonn

Post by Preludian »

Huray! I have found a way :)

I simply had to save the image as an png WITHOUT transparancy but with a black background.

Then I had to take #PB_Sprite_AlphaBlending out and voilà, it works perfectly.

Code: Select all

LoadSprite(0,#ResPath + "\Eichung.png",  #PB_Sprite_Texture)
Of course it's a workaround, because it uses the default transparancy color I guess, so I must be carefull not to have the same color in the image. Didn't check this out though.

Of couse having a mask would be nicer, so don't take it off the todo list for PB4.01 :wink:
Thalius
Enthusiast
Enthusiast
Posts: 711
Joined: Thu Jul 17, 2003 4:15 pm
Contact:

Post by Thalius »

It's Color "0" from the Palette IIRC which is used as transparency Color.

Cheers,

Thalius
"In 3D there is never enough Time to do Things right,
but there's always enough Time to make them *look* right."
"psssst! i steal signatures... don't tell anyone! ;)"
Preludian
User
User
Posts: 17
Joined: Thu Apr 27, 2006 7:01 pm
Location: lovely Bonn

Post by Preludian »

@Thalius: Sorry, I don't quite understand what you wrote, is it the same thing I wrote but in other words or am I missing something crucial. :?:

To recapitulate, I have a png without mask, but I saved it with transparancy disabled and a black background instead in PS Save as Web.

Then I deleted the alpha part of the LoadSprite command, else the complete Sprite would have been transparent.

I guess I could have chosen any color as long as I set the TransparentSpriteColor accordingly.

What do you mean now???

EDIT: Ohoh, I didn't see the small black pixels around the sprites in 800x600, because of a dark background, but in Full Screen 1600x1200, yeiks, it's there :( Was that what you wre trying to tell me Thalius?
Ok, then it's still a dirty bug. When does 4.01 come out????
Post Reply