[osg-users] Change particle color !
carlos at met.com.br
Tue Sep 16 09:03:33 PDT 2008
hey man I did it .
look the example particle
cor is the float that is variable of alpha to me , but can be r g or b
and using the code in the principal loop:
initial_color = osg::Vec4(R, G, B, cor);
final_color = osg::Vec4(fR, fG, fB, 0.0);
On Tue, Sep 16, 2008 at 1:31 PM, b boltze <con at bspot.de> wrote:
> Hi Mattias,
> On Monday 18 August 2008 22:42:04 Mattias Helsing wrote:
> > On Mon, Aug 18, 2008 at 8:44 PM, Carlos Sanches <cesmsp at gmail.com>
> > > to do this I need to change the color of particles after your creation
> > > only when I press the key.
> > yes it is possible. You need an EventHandler and a osg::Timer.
> > Set the color in EventHandler::handle(osgGA::FRAME).
> > There is probably 10 other ways to do this also.
> I have a similar problem and I fear I don't understand how this is supposed
> work. Creating an EventHandler and a Timer is easy of course, but actually
> changing the particles' colors seems problematical to me:
> Since the _current_* (alpha, color, etc.) attributes are protected in
> and there are no setter functions, I can not change these values directly.
> can only change the ranges, using set*Range.
> If the particles have limited lifetime, I can setColorRange or
> on them, so they will fade out. But since they have already lived a portion
> of their lifetime, they won't start at the beginning of the given interval,
> but jump right into it, to the value corresponding to the percentage of
> lifetime they have already spent.
> For example: A particle has already lived 9 seconds out of 10. Alpha range
> before the change was 1 to 1, so the particles alpha was 1. Then I set the
> alpha to range from 1 to 0, and the particle will immediately take an alpha
> value of 1+(0-1)*(9/10) = 0.1, assuming linear interpolation.
> If, on the other hand, the particle has infinite lifetime, I can't change
> color or alpha at all, because immortal particles retrieve their current
> values from the interpolators only once, at their first rendering pass
> So changing the ranges has no effect on them.
> Did I miss something?
> Thanks for your help
> osg-users mailing list
> osg-users at lists.openscenegraph.org
Analista de Sistemas e computação gráfica
Tel: 55 11 3816 2888
Cel: 55 11 9650 7137
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the osg-users