14#ifndef COLORINTERPOLATIONMANAGER_H
15#define COLORINTERPOLATIONMANAGER_H
35 virtual LColor interpolate(
const PN_stdfloat t = 0)
const = 0;
42 static void init_type() {
43 TypedReferenceCount::init_type();
45 TypedReferenceCount::get_class_type());
49 return get_class_type();
51 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
71 virtual LColor interpolate(
const PN_stdfloat t = 0)
const;
81 static void init_type() {
82 ColorInterpolationFunction::init_type();
83 register_type(_type_handle,
"ColorInterpolationFunctionConstant",
84 ColorInterpolationFunction::get_class_type());
88 return get_class_type();
90 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
110 LColor interpolate(
const PN_stdfloat t = 0)
const;
120 static void init_type() {
121 ColorInterpolationFunctionConstant::init_type();
122 register_type(_type_handle,
"ColorInterpolationFunctionLinear",
123 ColorInterpolationFunctionConstant::get_class_type());
127 return get_class_type();
129 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
154 LColor interpolate(
const PN_stdfloat t = 0)
const;
165 static void init_type() {
166 ColorInterpolationFunctionLinear::init_type();
167 register_type(_type_handle,
"ColorInterpolationFunctionStepwave",
168 ColorInterpolationFunctionLinear::get_class_type());
172 return get_class_type();
174 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
197 LColor interpolate(
const PN_stdfloat t = 0)
const;
207 static void init_type() {
208 ColorInterpolationFunctionLinear::init_type();
209 register_type(_type_handle,
"ColorInterpolationFunctionSinusoid",
210 ColorInterpolationFunctionLinear::get_class_type());
214 return get_class_type();
216 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
241 INLINE
int get_id()
const;
255 PN_stdfloat _t_begin;
257 PN_stdfloat _t_total;
276 int add_constant(
const PN_stdfloat time_begin = 0.0f,
const PN_stdfloat time_end = 1.0f,
const LColor &color = LColor(1.0f,1.0f,1.0f,1.0f),
const bool is_modulated =
true);
277 int add_linear(
const PN_stdfloat time_begin = 0.0f,
const PN_stdfloat time_end = 1.0f,
const LColor &color_a = LColor(1.0f,0.0f,0.0f,1.0f),
const LColor &color_b = LColor(0.0f,1.0f,0.0f,1.0f),
const bool is_modulated =
true);
278 int add_stepwave(
const PN_stdfloat time_begin = 0.0f,
const PN_stdfloat time_end = 1.0f,
const LColor &color_a = LColor(1.0f,0.0f,0.0f,1.0f),
const LColor &color_b = LColor(0.0f,1.0f,0.0f,1.0f),
const PN_stdfloat width_a = 0.5f,
const PN_stdfloat width_b = 0.5f,
const bool is_modulated =
true);
279 int add_sinusoid(
const PN_stdfloat time_begin = 0.0f,
const PN_stdfloat time_end = 1.0f,
const LColor &color_a = LColor(1.0f,0.0f,0.0f,1.0f),
const LColor &color_b = LColor(0.0f,1.0f,0.0f,1.0f),
const PN_stdfloat period = 1.0f,
const bool is_modulated =
true);
291 LColor _default_color;
ColorInterpolationFunctionConstant()
default constructor
void set_color_a(const LColor &c)
Sets the primary color of the function.
LColor get_color_a() const
Returns the primary color of the function.
void set_color_b(const LColor &c)
Sets the secondary color of the function.
LColor get_color_b() const
Returns the secondary color of the function.
ColorInterpolationFunctionLinear()
default constructor
ColorInterpolationFunctionSinusoid()
default constructor
PN_stdfloat get_period() const
Returns the time to transition from A to B then back to A again.
void set_period(const PN_stdfloat p)
Sets the time to transition from A to B then back to A again.
PN_stdfloat get_width_a() const
Returns the primary width of the function.
void set_width_a(const PN_stdfloat w)
Sets the primary width of the function.
PN_stdfloat get_width_b() const
Returns the secondary width of the function.
void set_width_b(const PN_stdfloat w)
Sets the secondary width of the function.
ColorInterpolationFunctionStepwave()
default constructor
Abstract class from which all other functions should inherit.
ColorInterpolationFunction()
constructor
ColorInterpolationSegment * get_segment(const int seg_id)
Returns the segment that corresponds to 'seg_id'.
ColorInterpolationManager()
default constructor
void set_default_color(const LColor &c)
Sets the color to used if no segments are present.
int add_constant(const PN_stdfloat time_begin=0.0f, const PN_stdfloat time_end=1.0f, const LColor &color=LColor(1.0f, 1.0f, 1.0f, 1.0f), const bool is_modulated=true)
Adds a constant segment of the specified color to the manager and returns the segment's id as known b...
void clear_to_initial()
Removes all segments from the manager.
int add_stepwave(const PN_stdfloat time_begin=0.0f, const PN_stdfloat time_end=1.0f, const LColor &color_a=LColor(1.0f, 0.0f, 0.0f, 1.0f), const LColor &color_b=LColor(0.0f, 1.0f, 0.0f, 1.0f), const PN_stdfloat width_a=0.5f, const PN_stdfloat width_b=0.5f, const bool is_modulated=true)
Adds a stepwave segment of two colors to the manager and returns the segment's id as known by the man...
LColor generateColor(const PN_stdfloat interpolated_time)
For time 'interpolated_time', this returns the additive composite color of all segments that influenc...
std::string get_segment_id_list()
Returns a space delimited list of all of the ids in the manager at the time.
int add_linear(const PN_stdfloat time_begin=0.0f, const PN_stdfloat time_end=1.0f, const LColor &color_a=LColor(1.0f, 0.0f, 0.0f, 1.0f), const LColor &color_b=LColor(0.0f, 1.0f, 0.0f, 1.0f), const bool is_modulated=true)
Adds a linear segment between two colors to the manager and returns the segment's id as known by the ...
int add_sinusoid(const PN_stdfloat time_begin=0.0f, const PN_stdfloat time_end=1.0f, const LColor &color_a=LColor(1.0f, 0.0f, 0.0f, 1.0f), const LColor &color_b=LColor(0.0f, 1.0f, 0.0f, 1.0f), const PN_stdfloat period=1.0f, const bool is_modulated=true)
Adds a stepwave segment of two colors and a specified period to the manager and returns the segment's...
void clear_segment(const int seg_id)
Removes the segment of 'id' from the manager.
A single unit of interpolation.
bool is_modulated() const
Returns whether the function is additive or modulated.
void set_time_end(const PN_stdfloat time)
Sets the point in the particle's lifetime at which this segment's effect ends.
void set_function(ColorInterpolationFunction *function)
Sets the function that the segment will use for its interpolation calculations.
ColorInterpolationSegment(ColorInterpolationFunction *function, const PN_stdfloat &time_begin, const PN_stdfloat &time_end, const bool is_modulated, const int id)
constructor
PN_stdfloat get_time_begin() const
Returns the point in the particle's lifetime at which this segment begins its effect.
void set_time_begin(const PN_stdfloat time)
Sets the point in the particle's lifetime at which this segment begins its effect.
void set_enabled(const bool enabled)
Sets whether the segments effects should be applied.
TypedReferenceCount * get_function() const
Returns a reference to the function object corresponding to this segment.
int get_id() const
Returns the id assigned to this segment by the manager that created it.
LColor interpolateColor(const PN_stdfloat t) const
Returns the interpolated color according to the segment's function and start and end times.
void set_is_modulated(const bool flag)
Sets how the function is applied to the final color.
PN_stdfloat get_time_end() const
Returns the point in the particle's lifetime at which this segment's effect stops.
bool is_enabled() const
Returns whether the segments effects are being applied.
TypeHandle is the identifier used to differentiate C++ class types.
A base class for things which need to inherit from both TypedObject and from ReferenceCount.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.