29 _anims.push_back(
new SpriteAnim(tex,LTexCoord(0.0f, 0.0f),LTexCoord(1.0f, 1.0f)));
46 if (_anims.size() == 0) {
51 _anims.push_back(
new SpriteAnim(tex,LTexCoord(0.0f, 0.0f),LTexCoord(1.0f, 1.0f)));
69 nassertv(n < (
int)_anims.size());
72 for (i = 0; i < (int)_anims.size(); ++i) {
73 for (j = 0; j < (int)_anim_size[i]; ++j) {
74 _sprites[i][j]->clear_vertices();
78 _anims.erase(_anims.begin()+n);
79 _animation_removed =
true;
99 set_ll_uv(
const LTexCoord &ll_uv,
const int anim,
const int frame) {
100 if(anim < (
int)_anims.size() && frame < (int)_anims[anim]->get_num_frames()) {
101 _anims[anim]->set_ll(frame,ll_uv);
121 set_ur_uv(
const LTexCoord &ur_uv,
const int anim,
const int frame) {
122 if(anim < (
int)_anims.size() && frame < (int)_anims[anim]->get_num_frames()) {
123 _anims[anim]->set_ur(frame,ur_uv);
140 INLINE
void SpriteParticleRenderer::
141 set_color(
const LColor &color) {
143 _color_interpolation_manager->set_default_color(_color);
149 INLINE
void SpriteParticleRenderer::
150 set_x_scale_flag(
bool animate_x_ratio) {
151 _animate_x_ratio = animate_x_ratio;
158 INLINE
void SpriteParticleRenderer::
159 set_y_scale_flag(
bool animate_y_ratio) {
160 _animate_y_ratio = animate_y_ratio;
167 INLINE
void SpriteParticleRenderer::
168 set_anim_angle_flag(
bool animate_theta) {
169 _animate_theta = animate_theta;
176 INLINE
void SpriteParticleRenderer::
177 set_initial_x_scale(PN_stdfloat initial_x_scale) {
178 _initial_x_scale = initial_x_scale;
185 INLINE
void SpriteParticleRenderer::
186 set_final_x_scale(PN_stdfloat final_x_scale) {
187 _final_x_scale = final_x_scale;
193 INLINE
void SpriteParticleRenderer::
194 set_initial_y_scale(PN_stdfloat initial_y_scale) {
195 _initial_y_scale = initial_y_scale;
202 INLINE
void SpriteParticleRenderer::
203 set_final_y_scale(PN_stdfloat final_y_scale) {
204 _final_y_scale = final_y_scale;
210 INLINE
void SpriteParticleRenderer::
211 set_nonanimated_theta(PN_stdfloat theta) {
219 INLINE
void SpriteParticleRenderer::
220 set_alpha_blend_method(ParticleRendererBlendMethod bm) {
227 INLINE
void SpriteParticleRenderer::
228 set_alpha_disable(
bool ad) {
235 INLINE
void SpriteParticleRenderer::
236 set_animate_frames_enable(
bool an) {
237 _animate_frames = an;
243 INLINE
void SpriteParticleRenderer::
244 set_animate_frames_rate(PN_stdfloat r) {
246 _animate_frames_rate = r;
252 INLINE
void SpriteParticleRenderer::
253 set_animate_frames_index(
int i) {
254 nassertv(i < (
int)_anims[0]->get_num_frames());
255 _animate_frames_index = i;
261 INLINE
Texture *SpriteParticleRenderer::
262 get_texture()
const {
263 return get_texture(0,0);
269 INLINE
Texture *SpriteParticleRenderer::
270 get_texture(
const int anim,
const int frame)
const {
271 if(_anims.size() == 0) {
274 nassertr(anim < (
int)_anims.size() && anim >= 0,
nullptr);
275 nassertr(frame < (
int)_anims[anim]->get_num_frames() && frame >= 0,_anims[anim]->get_frame(0));
276 return _anims[anim]->get_frame(frame);
279 INLINE
int SpriteParticleRenderer::
280 get_num_anims()
const {
281 return _anims.size();
285 get_anim(
const int n)
const {
286 nassertr(n < (
int)_anims.size(),
nullptr);
291 get_last_anim()
const {
293 return *(_anims.end()-1);
312 int a = anim < (int)_anims.size()?anim:0;
313 int f = frame < (int)_anims[a]->get_num_frames()?frame:0;
314 return _anims[a]->get_ll(f);
330 int a = anim < (int)_anims.size()?anim:0;
331 int f = frame < (int)_anims[a]->get_num_frames()?frame:0;
332 return _anims[a]->get_ur(f);
354 INLINE LColor SpriteParticleRenderer::
362 INLINE
bool SpriteParticleRenderer::
363 get_x_scale_flag()
const {
364 return _animate_x_ratio;
370 INLINE
bool SpriteParticleRenderer::
371 get_y_scale_flag()
const {
372 return _animate_y_ratio;
378 INLINE
bool SpriteParticleRenderer::
379 get_anim_angle_flag()
const {
380 return _animate_theta;
386 INLINE PN_stdfloat SpriteParticleRenderer::
387 get_initial_x_scale()
const {
388 return _initial_x_scale;
394 INLINE PN_stdfloat SpriteParticleRenderer::
395 get_final_x_scale()
const {
396 return _final_x_scale;
402 INLINE PN_stdfloat SpriteParticleRenderer::
403 get_initial_y_scale()
const {
404 return _initial_y_scale;
410 INLINE PN_stdfloat SpriteParticleRenderer::
411 get_final_y_scale()
const {
412 return _final_y_scale;
418 INLINE PN_stdfloat SpriteParticleRenderer::
419 get_nonanimated_theta()
const {
426 INLINE BaseParticleRenderer::ParticleRendererBlendMethod SpriteParticleRenderer::
427 get_alpha_blend_method()
const {
428 return _blend_method;
434 INLINE
bool SpriteParticleRenderer::
435 get_alpha_disable()
const {
436 return _alpha_disable;
442 INLINE
bool SpriteParticleRenderer::
443 get_animate_frames_enable()
const {
444 return _animate_frames;
450 INLINE PN_stdfloat SpriteParticleRenderer::
451 get_animate_frames_rate()
const {
452 return _animate_frames_rate;
458 INLINE
int SpriteParticleRenderer::
459 get_animate_frames_index()
const {
460 return _animate_frames_index;
467 get_color_interpolation_manager()
const {
468 return _color_interpolation_manager;
void remove_animation(const int n)
Removes an animation texture set from the renderer.
get_y_size
Returns the height of the texture image in texels.
get_filename
Returns the filename that has been set.
Helper class used by SpriteParticleRenderer to keep track of its textures and their respective UVs an...
PN_stdfloat get_width() const
Returns the width of each particle in world units.
void set_ll_uv(const LTexCoord &ll_uv)
Sets the UV coordinate of the lower-left corner of all the sprites generated by this renderer.
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
void set_ur_uv(const LTexCoord &ur_uv)
Sets the UV coordinate of the upper-right corner of all the sprites generated by this renderer.
void add_texture(Texture *tex, PN_stdfloat texels_per_unit=1.0f, bool resize=false)
Adds texture to image pool, effectively creating a single frame animation that can be selected at par...
LTexCoord get_ur_uv() const
Returns the UV coordinate of the lower-left corner; see set_ur_uv().
High level class for color interpolation.
PN_stdfloat get_height() const
Returns the height of each particle in world units.
LTexCoord get_ll_uv() const
Returns the UV coordinate of the lower-left corner; see set_ll_uv().
void set_texture(Texture *tex, PN_stdfloat texels_per_unit=1.0f)
Sets the renderer up to render the entire texture image.
void set_size(PN_stdfloat width, PN_stdfloat height)
Sets the size of each particle in world units.
get_x_size
Returns the width of the texture image in texels.