[osg-users] Change particle color !

Carlos Sanches 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);



smokeParticle->setColorRange(osgParticle::rangev4(initial_color,final_color
) );
            psa->setDefaultParticleTemplate(*smokeParticle);








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>
> wrote:
> > > 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
> to
> 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
> Particle
> and there are no setter functions, I can not change these values directly.
> I
> can only change the ranges, using set*Range.
>
> If the particles have limited lifetime, I can setColorRange or
> setAlphaRange
> 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
> their
> 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
> its
> color or alpha at all, because immortal particles retrieve their current
> values from the interpolators only once, at their first rendering pass
> ever.
> So changing the ranges has no effect on them.
>
> Did I miss something?
>
> Thanks for your help
>        bastian
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>



-- 
Carlos Sanches
Analista de Sistemas e computação gráfica
Tel: 55 11 3816 2888
Cel: 55 11 9650 7137

Somar Meteorologia
www.somarmeteorologia.com.br
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20080916/387ae2e6/attachment-0002.htm>


More information about the osg-users mailing list