Panda3D
 All Classes Functions Variables Enumerations
baseParticleRenderer.I
1 // Filename: baseParticleRenderer.I
2 // Created by: charles (20Jun00)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 ////////////////////////////////////////////////////////////////////
16 // Function : BaseParticleRender::get_render_node
17 // Class : Published
18 // Description : Query the geomnode pointer
19 ////////////////////////////////////////////////////////////////////
21 get_render_node() const {
22  return _render_node;
23 }
24 
25 ////////////////////////////////////////////////////////////////////
26 // Function : BaseParticleRender::get_render_node_path
27 // Class : Published
28 // Description : Query the geomnode pointer
29 ////////////////////////////////////////////////////////////////////
32  return _render_node_path;
33 }
34 
35 ////////////////////////////////////////////////////////////////////
36 // Function : BaseParticleRender::set_alpha_mode
37 // Access : Published
38 ////////////////////////////////////////////////////////////////////
39 INLINE void BaseParticleRenderer::
40 set_alpha_mode(BaseParticleRenderer::ParticleRendererAlphaMode am) {
41  update_alpha_mode(am);
42  init_geoms();
43 }
44 
45 ////////////////////////////////////////////////////////////////////
46 // Function : BaseParticleRender::get_alpha_mode
47 // Access : Published
48 ////////////////////////////////////////////////////////////////////
49 INLINE BaseParticleRenderer::ParticleRendererAlphaMode BaseParticleRenderer::
50 get_alpha_mode() const {
51  return _alpha_mode;
52 }
53 
54 ////////////////////////////////////////////////////////////////////
55 // Function : BaseParticleRender::set_user_alpha
56 // Access : Published
57 // Description : sets alpha for "user" alpha mode
58 ////////////////////////////////////////////////////////////////////
59 INLINE void BaseParticleRenderer::
60 set_user_alpha(PN_stdfloat ua) {
61  _user_alpha = ua;
62 }
63 
64 ////////////////////////////////////////////////////////////////////
65 // Function : BaseParticleRender::get_user_alpha
66 // Access : Published
67 // Description : gets alpha for "user" alpha mode
68 ////////////////////////////////////////////////////////////////////
69 INLINE PN_stdfloat BaseParticleRenderer::
70 get_user_alpha() const {
71  return _user_alpha;
72 }
73 
74 ////////////////////////////////////////////////////////////////////
75 // Function : BaseParticleRender::set_color_blend_mode
76 // Access : Published
77 // Description : sets the ColorBlendAttrib on the _render_node
78 ////////////////////////////////////////////////////////////////////
79 INLINE void BaseParticleRenderer::
80 set_color_blend_mode(ColorBlendAttrib::Mode bm, ColorBlendAttrib::Operand oa, ColorBlendAttrib::Operand ob) {
81  CPT(RenderAttrib) ra;
82  if(bm == ColorBlendAttrib::M_add || bm == ColorBlendAttrib::M_subtract || bm == ColorBlendAttrib::M_inv_subtract) {
83  ra = ColorBlendAttrib::make(bm,oa,ob);
84  } else {
85  ra = ColorBlendAttrib::make(bm);
86  }
87 
88  _render_node->set_attrib(ra);
89  return;
90 }
91 
92 ////////////////////////////////////////////////////////////////////
93 // Function : BaseParticleRender::get_ignore_scale
94 // Access : Published
95 // Description : Returns the "ignore scale" flag. See
96 // set_ignore_scale().
97 ////////////////////////////////////////////////////////////////////
98 INLINE bool BaseParticleRenderer::
100  return _ignore_scale;
101 }
102 
103 ////////////////////////////////////////////////////////////////////
104 // Function : BaseParticleRender::get_cur_alpha
105 // Access : Published
106 // Description : gets current alpha for a particle
107 ////////////////////////////////////////////////////////////////////
108 INLINE PN_stdfloat BaseParticleRenderer::
109 get_cur_alpha(BaseParticle* bp) {
110  switch(_alpha_mode) {
111  case PR_ALPHA_OUT:
112  return 1.0f - bp->get_parameterized_age();
113 
114  case PR_ALPHA_IN:
115  return bp->get_parameterized_age();
116 
117  case PR_ALPHA_IN_OUT:
118  return 2.0 * min(bp->get_parameterized_age(),
119  1.0f - bp->get_parameterized_age());
120 
121  case PR_ALPHA_USER:
122  return _user_alpha;
123 
124  default:
125  return 1.0; // should not get here
126  }
127 }
This is the base class for a number of render attributes (other than transform) that may be set on sc...
Definition: renderAttrib.h:60
PN_stdfloat get_user_alpha() const
gets alpha for "user" alpha mode
GeomNode * get_render_node() const
Query the geomnode pointer.
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
void set_user_alpha(PN_stdfloat ua)
sets alpha for "user" alpha mode
bool get_ignore_scale() const
Returns the "ignore scale" flag.
NodePath get_render_node_path() const
Query the geomnode pointer.
An individual, physically-modelable particle abstract base class.
Definition: baseParticle.h:26
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:165
A node that holds Geom objects, renderable pieces of geometry.
Definition: geomNode.h:37