I’m trying to fade away text in C++. In python, I would do that using a function interval with setAlphaScale as function. Does anybody have a clue how to do something similar in C++, or would I need to set the new alpha scale every frame manually?
You can create intervals in C++ too. You just need to get a pointer to the global IntervalManager to register your intervals. You also need to call intervalManager->step() every frame.
Thanks for your quick response.
Well, I already know how to setup intervals in C++, and am using plenty of 'em, but, the problem is I don’t know how a FunctionInterval would work in C++, and if that even exists, or there is a different way to get an AlphaScaleInterval.
Oh, yeah, don’t do it that way. You probably shouldn’t use a FunctionInterval in Python either unless there’s no other alternative; and in the case of alpha scale, there is an alternative: the ColorScaleInterval, which can scale alpha as well as color.
If, however, the existing intervals aren’t sufficient to meet your needs, you should define a new interval class by subclassing CInterval. Then override at least priv_step() to do what you want it to do.
Ah. Though, it seems that ColorScaleInterval is python, not C++ (I can’t find any c++ files that look like it).
I’ll look into subclassing CInterval, thanks for the help.
This is the entirety of the LerpColorScaleInterval definition in Python:
class LerpColorScaleInterval(LerpNodePathInterval):
def __init__(self, nodePath, duration, colorScale, startColorScale = None,
other = None, blendType = 'noBlend',
bakeInStart = 1, name = None):
LerpNodePathInterval.__init__(self, name, duration, blendType,
bakeInStart, 0, nodePath, other)
self.setEndColorScale(colorScale)
if startColorScale != None:
self.setStartColorScale(startColorScale)
So you can see, it is just a LerpNodePathInterval with a special constructor. LerpNodePathInterval in turn is a CLerpNodePathInterval with a special constructor.