Sprite3D Color changing - Can't find it

Just starting out? Need help? Post your questions and find answers here.
DeXtr0
User
User
Posts: 58
Joined: Tue Mar 06, 2007 12:49 pm
Location: Belgium
Contact:

Sprite3D Color changing - Can't find it

Post by DeXtr0 »

Hey everybody,

I searched the forum a couple of times for a solution but until now, I did not found the right answer to the issue i'm stuck with:

I want to display a sprite3D.
Fade that sprite3D to white
After a while fade back (from the white color) to the original colors of the Sprite.

Is something like this possible ?

I looked for drawing buffer, color palettes, I even thought of using DisplayAlphaSprite but the sprite has more than 256 colors.

All tips are welcome.

Regards,
DeXtr0
Proud member of dAWN (www.dawncreations.com)
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 »

Fading to the background is easy enough using the transparency parameter of DisplaySprite3D(), but nothing comes to mind about fading to white. Here's a hack that might work for you if you don't find a better way of doing it (which probably does exist):

Code: Select all

InitSprite():InitSprite3D()
OpenWindow(0,0,0,320,240,"",$CA0001)
OpenWindowedScreen(WindowID(0),0,0,320,240,0,0,0)
CreateSprite(0,64,64,#PB_Sprite_Texture)
StartDrawing(SpriteOutput(0))
  Circle(32,32,32,#Red)
StopDrawing()
CreateSprite(1,64,64,#PB_Sprite_Texture)
StartDrawing(SpriteOutput(1))
  Circle(32,32,32,#White)
StopDrawing()
CreateSprite3D(0,0)
CreateSprite3D(1,1)

up=1:whitelevel=0

Repeat
  If up
    whitelevel+1:If whitelevel>254:up=0:EndIf
  Else
    whitelevel-1:If whitelevel<1:up=1:EndIf
  EndIf
  ev=WindowEvent()
  ClearScreen(#Black)
  Start3D()
    DisplaySprite3D(1,20,20)
    DisplaySprite3D(0,20,20,255-whitelevel)
  Stop3D()
  FlipBuffers()
  Delay(1)
Until ev=#WM_CLOSE
BERESHEIT
DeXtr0
User
User
Posts: 58
Joined: Tue Mar 06, 2007 12:49 pm
Location: Belgium
Contact:

Post by DeXtr0 »

Hey netmaestro,

You hack is quite good but not really what I was looking for.
The sprite is a full color png file and I want to fade that to white.
If you play with the transparancy parameter it just fades to the real color :o

However the idea was good and I hope to get some more tips.
Maybe others have already changed the colors of a sprite3D ?

Anyway thanks a lot for trying to help me out.

Appreciated,
DeXtr0
Proud member of dAWN (www.dawncreations.com)
citystate
Enthusiast
Enthusiast
Posts: 638
Joined: Sun Feb 12, 2006 10:06 pm

Post by citystate »

why not fade a white spite from transparent to opaque in front of your multi-coloured sprite?
there is no sig, only zuul (and the following disclaimer)

WARNING: may be talking out of his hat
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

not a bad idea...
but if the base-sprite isn't filled squarish, that is also no solution.
when it has transparent areas itself, it won't work.

the only solution I can think of at the moment is to create the fading in multiple 2Dsprites,
and create several sprite3D out of them, to display the fading framewise.
this can be done on the fly for sure.

do you really need Sprite3D for it?
does it need to be an absolute independant rotateable and transformable picture?

if it's only for resizing, try to load it as image, resize it, and draw it on the sprite.
oh... and have a nice day.
citystate
Enthusiast
Enthusiast
Posts: 638
Joined: Sun Feb 12, 2006 10:06 pm

Post by citystate »

Kaeru Gaman wrote:but if the base-sprite isn't filled squarish, that is also no solution.
when it has transparent areas itself, it won't work
perhaps a white solid sprite overlaid on a grab of the backgound (performed on the fly to allow for moving sprites) might work
there is no sig, only zuul (and the following disclaimer)

WARNING: may be talking out of his hat
DeXtr0
User
User
Posts: 58
Joined: Tue Mar 06, 2007 12:49 pm
Location: Belgium
Contact:

Post by DeXtr0 »

Hey guys,

Well it does not "has" to be a sprite3D but it could be very handy.
Nevertheless that is not a "must".

I'm already very happy if it could work with a normal Sprite.

I think, the tip of citystate is a very good one.
I have not tought of that :)

I'll try it as soon as I got some time and I'll let you know if I solved it.

Thanks everybody for the great help.
Proud member of dAWN (www.dawncreations.com)
User avatar
Demivec
Addict
Addict
Posts: 4260
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Post by Demivec »

citystate wrote:why not fade a white spite from transparent to opaque in front of your multi-coloured sprite?
DeXtr0 wrote:I think, the tip of citystate is a very good one.
I have not tought of that Smile
Didn't netmaestro's snippet already do this? He drew a red circle sprite with a white circle sprite with transparency in front of it. All that is missing is a method of converting any sprite to a white sprite.
DeXtr0
User
User
Posts: 58
Joined: Tue Mar 06, 2007 12:49 pm
Location: Belgium
Contact:

Post by DeXtr0 »

Actually you are 100% right.
netmaestro gave the same tip.

Sorry netmaestro.

Thanks demivec for mentionning it to me.
Proud member of dAWN (www.dawncreations.com)
Post Reply