Panda3D
Public Member Functions | Public Attributes | List of all members
SpriteParticleRenderer Class Reference

Renders a particle system with high-speed nasty trick sprites. More...

#include "spriteParticleRenderer.h"

Inheritance diagram for SpriteParticleRenderer:
BaseParticleRenderer ReferenceCount MemoryBase

Public Member Functions

 SpriteParticleRenderer (Texture *tex=nullptr)
 constructor More...
 
 SpriteParticleRenderer (const SpriteParticleRenderer &copy)
 copy constructor More...
 
virtual ~SpriteParticleRenderer ()
 destructor More...
 
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 birth. More...
 
void add_from_node (const NodePath &node_path, const std::string &model, const std::string &node, 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 birth. More...
 
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 particle birth. More...
 
ParticleRendererBlendMethod get_alpha_blend_method () const
 
bool get_alpha_disable () const
 
SpriteAnimget_anim (const int n) const
 
bool get_anim_angle_flag () const
 
bool get_animate_frames_enable () const
 
int get_animate_frames_index () const
 
PN_stdfloat get_animate_frames_rate () const
 
LColor get_color () const
 
ColorInterpolationManagerget_color_interpolation_manager () const
 
PN_stdfloat get_final_x_scale () const
 
PN_stdfloat get_final_y_scale () const
 
PN_stdfloat get_height () const
 Returns the height of each particle in world units. More...
 
PN_stdfloat get_initial_x_scale () const
 
PN_stdfloat get_initial_y_scale () const
 
SpriteAnimget_last_anim () const
 
LTexCoord get_ll_uv () const
 Returns the UV coordinate of the lower-left corner; see set_ll_uv(). More...
 
LTexCoord get_ll_uv (const int anim, const int frame) const
 Returns the UV coordinate of the lower-left corner; see set_ll_uv(). More...
 
PN_stdfloat get_nonanimated_theta () const
 
int get_num_anims () const
 
Textureget_texture () const
 
Textureget_texture (const int anim, const int frame) const
 
LTexCoord get_ur_uv () const
 Returns the UV coordinate of the lower-left corner; see set_ur_uv(). More...
 
LTexCoord get_ur_uv (const int anim, const int frame) const
 Returns the UV coordinate of the upper-right corner; see set_ur_uv(). More...
 
PN_stdfloat get_width () const
 Returns the width of each particle in world units. More...
 
bool get_x_scale_flag () const
 
bool get_y_scale_flag () const
 
virtual BaseParticleRenderermake_copy ()
 child dynamic copy More...
 
virtual void output (std::ostream &out) const
 Write a string representation of this instance to <out>. More...
 
void remove_animation (const int n)
 Removes an animation texture set from the renderer. More...
 
void set_alpha_blend_method (ParticleRendererBlendMethod bm)
 
void set_alpha_disable (bool ad)
 
void set_anim_angle_flag (bool animate_theta)
 
void set_animate_frames_enable (bool an)
 
void set_animate_frames_index (int i)
 
void set_animate_frames_rate (PN_stdfloat r)
 
void set_color (const LColor &color)
 
void set_final_x_scale (PN_stdfloat final_x_scale)
 
void set_final_y_scale (PN_stdfloat final_y_scale)
 
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. More...
 
void set_from_node (const NodePath &node_path, const std::string &model, const std::string &node, bool size_from_texels=false)
 If the source type is important, use this one. More...
 
void set_initial_x_scale (PN_stdfloat initial_x_scale)
 
void set_initial_y_scale (PN_stdfloat initial_y_scale)
 
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. More...
 
void set_ll_uv (const LTexCoord &ll_uv, const int anim, const int frame)
 Sets the UV coordinate of the lower-left corner of all the sprites generated by this renderer. More...
 
void set_nonanimated_theta (PN_stdfloat theta)
 
void set_size (PN_stdfloat width, PN_stdfloat height)
 Sets the size of each particle in world units. More...
 
void set_texture (Texture *tex, PN_stdfloat texels_per_unit=1.0f)
 Sets the renderer up to render the entire texture image. More...
 
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. More...
 
void set_ur_uv (const LTexCoord &ur_uv, const int anim, const int frame)
 Sets the UV coordinate of the upper-right corner of all the sprites generated by this renderer. More...
 
void set_x_scale_flag (bool animate_x_ratio)
 
void set_y_scale_flag (bool animate_y_ratio)
 
virtual void write (std::ostream &out, int indent_level=0) const
 Write a string representation of this instance to <out>. More...
 
- Public Member Functions inherited from BaseParticleRenderer
virtual ~BaseParticleRenderer ()
 Destructor. More...
 
ParticleRendererAlphaMode get_alpha_mode () const
 
bool get_ignore_scale () const
 Returns the "ignore scale" flag. More...
 
GeomNodeget_render_node () const
 Query the geomnode pointer. More...
 
NodePath get_render_node_path () const
 Query the geomnode pointer. More...
 
PN_stdfloat get_user_alpha () const
 gets alpha for "user" alpha mode More...
 
void set_alpha_mode (ParticleRendererAlphaMode am)
 
void set_color_blend_mode (ColorBlendAttrib::Mode bm, ColorBlendAttrib::Operand oa=ColorBlendAttrib::O_zero, ColorBlendAttrib::Operand ob=ColorBlendAttrib::O_zero)
 sets the ColorBlendAttrib on the _render_node More...
 
void set_ignore_scale (bool ignore_scale)
 Sets the "ignore scale" flag. More...
 
void set_user_alpha (PN_stdfloat ua)
 sets alpha for "user" alpha mode More...
 
- Public Member Functions inherited from ReferenceCount
int get_ref_count () const
 
WeakReferenceListget_weak_list () const
 Returns the WeakReferenceList associated with this ReferenceCount object. More...
 
bool has_weak_list () const
 Returns true if this particular ReferenceCount object has a WeakReferenceList created, false otherwise. More...
 
void local_object ()
 This function should be called, once, immediately after creating a new instance of some ReferenceCount-derived object on the stack. More...
 
void ref () const
 Explicitly increments the reference count. More...
 
bool ref_if_nonzero () const
 Atomically increases the reference count of this object if it is not zero. More...
 
bool test_ref_count_integrity () const
 Does some easy checks to make sure that the reference count isn't completely bogus. More...
 
bool test_ref_count_nonzero () const
 Does some easy checks to make sure that the reference count isn't zero, or completely bogus. More...
 
virtual bool unref () const
 Explicitly decrements the reference count. More...
 
WeakReferenceListweak_ref ()
 Adds the indicated PointerToVoid as a weak reference to this object. More...
 
void weak_unref ()
 Removes the indicated PointerToVoid as a weak reference to this object. More...
 

Public Attributes

 get_anim
 
 get_num_anims
 
- Public Attributes inherited from ReferenceCount
 get_ref_count
 Returns the current reference count. More...
 

Additional Inherited Members

- Public Types inherited from BaseParticleRenderer
enum  ParticleRendererAlphaMode {
  PR_ALPHA_NONE, PR_ALPHA_OUT, PR_ALPHA_IN, PR_ALPHA_IN_OUT,
  PR_ALPHA_USER, PR_NOT_INITIALIZED_YET
}
 
enum  ParticleRendererBlendMethod { PP_NO_BLEND, PP_BLEND_LINEAR, PP_BLEND_CUBIC }
 
- Static Public Member Functions inherited from ReferenceCount
static TypeHandle get_class_type ()
 
static void init_type ()
 

Detailed Description

Renders a particle system with high-speed nasty trick sprites.

Definition at line 154 of file spriteParticleRenderer.h.

Constructor & Destructor Documentation

◆ SpriteParticleRenderer() [1/2]

SpriteParticleRenderer::SpriteParticleRenderer ( Texture tex = nullptr)
explicit

constructor

Definition at line 42 of file spriteParticleRenderer.cxx.

References set_texture().

Referenced by make_copy().

◆ SpriteParticleRenderer() [2/2]

SpriteParticleRenderer::SpriteParticleRenderer ( const SpriteParticleRenderer copy)

copy constructor

Definition at line 73 of file spriteParticleRenderer.cxx.

◆ ~SpriteParticleRenderer()

SpriteParticleRenderer::~SpriteParticleRenderer ( )
virtual

Member Function Documentation

◆ add_from_node() [1/2]

void SpriteParticleRenderer::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 birth.

If resize is true, or if there are no textures currently on the renderer, it will force the renderer to use the size information from this node from now on. (Default is false)

Definition at line 266 of file spriteParticleRenderer.cxx.

Referenced by add_from_node(), and set_from_node().

◆ add_from_node() [2/2]

void SpriteParticleRenderer::add_from_node ( const NodePath node_path,
const std::string &  model,
const std::string &  node,
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 birth.

If the source type is important, use this one.

model and node should lead to node_path like this: node_path = loader.loadModel(model).find(node)

If resize is true, or if there are no textures currently on the renderer, it will force the renderer to use the size information from this node from now on. (Default is false)

Definition at line 247 of file spriteParticleRenderer.cxx.

References add_from_node().

◆ add_texture()

void SpriteParticleRenderer::add_texture ( Texture tex,
PN_stdfloat  texels_per_unit = 1.0f,
bool  resize = false 
)
inline

Adds texture to image pool, effectively creating a single frame animation that can be selected at particle birth.

This should only be called after a previous call to set_texture().

Definition at line 45 of file spriteParticleRenderer.I.

References set_texture().

◆ get_height()

PN_stdfloat SpriteParticleRenderer::get_height ( ) const
inline

Returns the height of each particle in world units.

Definition at line 347 of file spriteParticleRenderer.I.

◆ get_ll_uv() [1/2]

LTexCoord SpriteParticleRenderer::get_ll_uv ( ) const
inline

Returns the UV coordinate of the lower-left corner; see set_ll_uv().

Definition at line 303 of file spriteParticleRenderer.I.

◆ get_ll_uv() [2/2]

LTexCoord SpriteParticleRenderer::get_ll_uv ( const int  anim,
const int  frame 
) const
inline

Returns the UV coordinate of the lower-left corner; see set_ll_uv().

Definition at line 311 of file spriteParticleRenderer.I.

◆ get_ur_uv() [1/2]

LTexCoord SpriteParticleRenderer::get_ur_uv ( ) const
inline

Returns the UV coordinate of the lower-left corner; see set_ur_uv().

Definition at line 321 of file spriteParticleRenderer.I.

◆ get_ur_uv() [2/2]

LTexCoord SpriteParticleRenderer::get_ur_uv ( const int  anim,
const int  frame 
) const
inline

Returns the UV coordinate of the upper-right corner; see set_ur_uv().

Definition at line 329 of file spriteParticleRenderer.I.

◆ get_width()

PN_stdfloat SpriteParticleRenderer::get_width ( ) const
inline

Returns the width of each particle in world units.

Definition at line 339 of file spriteParticleRenderer.I.

◆ make_copy()

BaseParticleRenderer * SpriteParticleRenderer::make_copy ( )
virtual

child dynamic copy

Implements BaseParticleRenderer.

Definition at line 113 of file spriteParticleRenderer.cxx.

References SpriteParticleRenderer().

◆ output()

void SpriteParticleRenderer::output ( std::ostream &  out) const
virtual

Write a string representation of this instance to <out>.

Reimplemented from BaseParticleRenderer.

Definition at line 750 of file spriteParticleRenderer.cxx.

◆ remove_animation()

void SpriteParticleRenderer::remove_animation ( const int  n)
inline

Removes an animation texture set from the renderer.

Definition at line 68 of file spriteParticleRenderer.I.

◆ set_from_node() [1/2]

void SpriteParticleRenderer::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.

This should be a reference to a GeomNode or a SequenceNode; it extracts out the texture and UV range from the node.

This will remove all previously added textures and animations. It will also resize the renderer to match this new geometry.

If node_path refers to a GeomNode(or has one beneath it) the texture, its size, and UV data will be extracted from that.

If node_path references a SequenceNode(or has one beneath it) with multiple GeomNodes beneath it, the size data will correspond only to the first GeomNode found with a valid texture, while the texture and UV information will be stored for each individual node.

If size_from_texels is true, the particle size is based on the number of texels in the source image; otherwise, it is based on the size of the first polygon found in the node.

model and node are the two items used to construct node_path. If the source type is important, use set_from_node(NodePath,string,string,bool) instead.

Definition at line 226 of file spriteParticleRenderer.cxx.

◆ set_from_node() [2/2]

void SpriteParticleRenderer::set_from_node ( const NodePath node_path,
const std::string &  model,
const std::string &  node,
bool  size_from_texels = false 
)

If the source type is important, use this one.

model and node should lead to node_path like this: node_path = loader.loadModel(model).find(node)

This will remove all previously add textures and resize the renderer to match the new geometry.

Definition at line 195 of file spriteParticleRenderer.cxx.

References add_from_node().

◆ set_ll_uv() [1/2]

void SpriteParticleRenderer::set_ll_uv ( const LTexCoord &  ll_uv)
inline

Sets the UV coordinate of the lower-left corner of all the sprites generated by this renderer.

Normally this is (0, 0), but it might be set to something else to use only a portion of the texture.

Definition at line 89 of file spriteParticleRenderer.I.

◆ set_ll_uv() [2/2]

void SpriteParticleRenderer::set_ll_uv ( const LTexCoord &  ll_uv,
const int  anim,
const int  frame 
)
inline

Sets the UV coordinate of the lower-left corner of all the sprites generated by this renderer.

Normally this is (0, 0), but it might be set to something else to use only a portion of the texture.

Definition at line 99 of file spriteParticleRenderer.I.

◆ set_size()

void SpriteParticleRenderer::set_size ( PN_stdfloat  width,
PN_stdfloat  height 
)
inline

Sets the size of each particle in world units.

Definition at line 131 of file spriteParticleRenderer.I.

◆ set_texture()

void SpriteParticleRenderer::set_texture ( Texture tex,
PN_stdfloat  texels_per_unit = 1.0f 
)
inline

Sets the renderer up to render the entire texture image.

The scale of each particle is based on the size of the texture in each dimension, modified by texels_per_unit.

Used to set the size of the particles. Will clear all previously loaded textures and animations.

Definition at line 23 of file spriteParticleRenderer.I.

Referenced by add_texture(), and SpriteParticleRenderer().

◆ set_ur_uv() [1/2]

void SpriteParticleRenderer::set_ur_uv ( const LTexCoord &  ur_uv)
inline

Sets the UV coordinate of the upper-right corner of all the sprites generated by this renderer.

Normally this is (1, 1), but it might be set to something else to use only a portion of the texture.

Definition at line 111 of file spriteParticleRenderer.I.

◆ set_ur_uv() [2/2]

void SpriteParticleRenderer::set_ur_uv ( const LTexCoord &  ur_uv,
const int  anim,
const int  frame 
)
inline

Sets the UV coordinate of the upper-right corner of all the sprites generated by this renderer.

Normally this is (1, 1), but it might be set to something else to use only a portion of the texture.

Definition at line 121 of file spriteParticleRenderer.I.

◆ write()

void SpriteParticleRenderer::write ( std::ostream &  out,
int  indent_level = 0 
) const
virtual

Write a string representation of this instance to <out>.

Reimplemented from BaseParticleRenderer.

Definition at line 760 of file spriteParticleRenderer.cxx.

References indent(), and BaseParticleRenderer::write().


The documentation for this class was generated from the following files: