Page 1 of 1

Sprite3D Color changing - Can't find it

Posted: Sun Aug 19, 2007 7:51 pm
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

Posted: Sun Aug 19, 2007 8:15 pm
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

Posted: Sun Aug 19, 2007 8:29 pm
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

Posted: Mon Aug 20, 2007 1:29 am
by citystate
why not fade a white spite from transparent to opaque in front of your multi-coloured sprite?

Posted: Mon Aug 20, 2007 1:39 am
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.

Posted: Mon Aug 20, 2007 1:48 am
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

Posted: Mon Aug 20, 2007 7:26 am
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.

Posted: Mon Aug 20, 2007 4:57 pm
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.

Posted: Mon Aug 20, 2007 5:02 pm
by DeXtr0
Actually you are 100% right.
netmaestro gave the same tip.

Sorry netmaestro.

Thanks demivec for mentionning it to me.