14#ifndef SPRITEPARTICLERENDERER_H
15#define SPRITEPARTICLERENDERER_H
44 SpriteWriter(
const SpriteWriter ©):
49 aspect_ratio(copy.aspect_ratio) {
71class SpriteAnim :
public ReferenceCount{
78 void set_source_info(
const std::string &tex) {
79 _source_type = ST_texture;
83 void set_source_info(
const std::string &model,
const std::string &node) {
84 _source_type = ST_from_node;
85 _source_model = model;
89 SourceType get_source_type()
const {
93 std::string get_tex_source()
const {
97 std::string get_model_source()
const {
101 std::string get_node_source()
const {
105 int get_num_frames()
const {
106 return textures.size();
110 SpriteAnim(
Texture* t, LTexCoord ll, LTexCoord ur) {
111 textures.push_back(t);
112 this->ll.push_back(ll);
113 this->ur.push_back(ur);
119 for (
int i = 0; i < t.get_num_textures(); ++i) {
120 textures.push_back(t.get_texture(i));
124 void set_ll(
const int n, LTexCoord c) {
128 void set_ur(
const int n, LTexCoord c) {
132 Texture *get_frame(
const int n)
const {
136 LTexCoord get_ll(
const int n)
const {
140 LTexCoord get_ur(
const int n)
const {
145 pvector< PT(
Texture) > textures;
147 SourceType _source_type;
148 std::string _source_tex,_source_model,_source_node;
161 virtual BaseParticleRenderer *
make_copy();
165 void set_from_node(
const NodePath &node_path,
const std::string &model,
const std::string &node,
bool size_from_texels =
false);
167 void add_from_node(
const NodePath &node_path,
const std::string &model,
const std::string &node,
bool size_from_texels =
false,
bool resize =
false);
170 INLINE
void add_texture(
Texture *tex, PN_stdfloat texels_per_unit = 1.0f,
bool resize =
false);
172 INLINE
void set_ll_uv(
const LTexCoord &ll_uv);
173 INLINE
void set_ll_uv(
const LTexCoord &ll_uv,
const int anim,
const int frame);
174 INLINE
void set_ur_uv(
const LTexCoord &ur_uv);
175 INLINE
void set_ur_uv(
const LTexCoord &ur_uv,
const int anim,
const int frame);
176 INLINE
void set_size(PN_stdfloat width, PN_stdfloat height);
177 INLINE
void set_color(
const LColor &color);
178 INLINE
void set_x_scale_flag(
bool animate_x_ratio);
179 INLINE
void set_y_scale_flag(
bool animate_y_ratio);
180 INLINE
void set_anim_angle_flag(
bool animate_theta);
181 INLINE
void set_initial_x_scale(PN_stdfloat initial_x_scale);
182 INLINE
void set_final_x_scale(PN_stdfloat final_x_scale);
183 INLINE
void set_initial_y_scale(PN_stdfloat initial_y_scale);
184 INLINE
void set_final_y_scale(PN_stdfloat final_y_scale);
185 INLINE
void set_nonanimated_theta(PN_stdfloat theta);
186 INLINE
void set_alpha_blend_method(ParticleRendererBlendMethod bm);
187 INLINE
void set_alpha_disable(
bool ad);
188 INLINE
void set_animate_frames_enable(
bool an);
189 INLINE
void set_animate_frames_rate(PN_stdfloat r);
190 INLINE
void set_animate_frames_index(
int i);
192 INLINE
Texture *get_texture()
const;
193 INLINE
Texture *get_texture(
const int anim,
const int frame)
const;
194 INLINE
int get_num_anims()
const;
195 INLINE
SpriteAnim *get_anim(
const int n)
const;
196 MAKE_SEQ(get_anims, get_num_anims, get_anim);
200 INLINE LTexCoord
get_ll_uv(
const int anim,
const int frame)
const;
202 INLINE LTexCoord
get_ur_uv(
const int anim,
const int frame)
const;
205 INLINE LColor get_color()
const;
206 INLINE
bool get_x_scale_flag()
const;
207 INLINE
bool get_y_scale_flag()
const;
208 INLINE
bool get_anim_angle_flag()
const;
209 INLINE PN_stdfloat get_initial_x_scale()
const;
210 INLINE PN_stdfloat get_final_x_scale()
const;
211 INLINE PN_stdfloat get_initial_y_scale()
const;
212 INLINE PN_stdfloat get_final_y_scale()
const;
213 INLINE PN_stdfloat get_nonanimated_theta()
const;
214 INLINE ParticleRendererBlendMethod get_alpha_blend_method()
const;
215 INLINE
bool get_alpha_disable()
const;
216 INLINE
bool get_animate_frames_enable()
const;
217 INLINE PN_stdfloat get_animate_frames_rate()
const;
218 INLINE
int get_animate_frames_index()
const;
220 virtual void output(std::ostream &out)
const;
221 virtual void write(std::ostream &out,
int indent_level = 0)
const;
224 pvector< pvector< PT(
Geom) > > _sprite_primitive;
225 pvector< pvector< PT(
GeomPoints) > > _sprites;
226 pvector< pvector< SpriteWriter > > _sprite_writer;
235 PN_stdfloat _initial_x_scale;
236 PN_stdfloat _final_x_scale;
237 PN_stdfloat _initial_y_scale;
238 PN_stdfloat _final_y_scale;
240 PN_stdfloat _base_y_scale;
241 PN_stdfloat _aspect_ratio;
242 PN_stdfloat _animate_frames_rate;
243 int _animate_frames_index;
245 bool _animate_x_ratio;
246 bool _animate_y_ratio;
249 bool _animate_frames;
250 bool _animation_removed;
252 ParticleRendererBlendMethod _blend_method;
260 virtual void birth_particle(
int index);
261 virtual void kill_particle(
int index);
262 virtual void init_geoms();
265 virtual void resize_pool(
int new_size);
268 vector_int _anim_size;
269 pvector<int*> _ttl_count;
270 vector_int _birth_list;
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void output(std::ostream &out) const
Write a string representation of this instance to <out>.
virtual void write(std::ostream &out, int indent=0) const
Write a string representation of this instance to <out>.
High level class for color interpolation.
Defines a series of disconnected points.
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
This object provides a high-level interface for quickly writing a sequence of numeric values from a v...
A container for geometry primitives.
This is a set of zero or more NodePaths.
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
A lightweight class that represents a single element that may be timed and/or counted via stats.
A body on which physics will be applied.
Helper class used by SpriteParticleRenderer to keep track of its textures and their respective UVs an...
LTexCoord get_ur_uv() const
Returns the UV coordinate of the lower-left corner; see set_ur_uv().
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...
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.
PN_stdfloat get_height() const
Returns the height of each particle in world units.
void set_size(PN_stdfloat width, PN_stdfloat height)
Sets the size of each particle in world units.
SpriteParticleRenderer(Texture *tex=nullptr)
constructor
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.
PN_stdfloat get_width() const
Returns the width of each particle in world units.
virtual BaseParticleRenderer * make_copy()
child dynamic copy
void add_from_node(const NodePath &node_path, bool size_from_texels=false, bool resize=false)
This will allow the renderer to randomly choose from more than one texture or sequence at particle bi...
void remove_animation(const int n)
Removes an animation texture set from the renderer.
void set_texture(Texture *tex, PN_stdfloat texels_per_unit=1.0f)
Sets the renderer up to render the entire texture image.
LTexCoord get_ll_uv() const
Returns the UV coordinate of the lower-left corner; see set_ll_uv().
void set_from_node(const NodePath &node_path, bool size_from_texels=false)
Sets the properties on this renderer from the geometry referenced by the indicated NodePath.
Manages a list of Texture objects, as returned by TexturePool::find_all_textures().
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.