|
@@ -20,10 +20,11 @@
|
|
|
|
|
|
|
|
#include "baseParticleRenderer.h"
|
|
#include "baseParticleRenderer.h"
|
|
|
#include "transparencyAttrib.h"
|
|
#include "transparencyAttrib.h"
|
|
|
|
|
+#include "compassEffect.h"
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
-// Function : BaseParticleRenderer
|
|
|
|
|
-// Access : Public
|
|
|
|
|
|
|
+// Function : BaseParticleRender::BaseParticleRenderer
|
|
|
|
|
+// Access : Published
|
|
|
// Description : Default Constructor
|
|
// Description : Default Constructor
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
BaseParticleRenderer::
|
|
BaseParticleRenderer::
|
|
@@ -32,13 +33,14 @@ BaseParticleRenderer(ParticleRendererAlphaMode alpha_mode) :
|
|
|
_render_node = new GeomNode("BaseParticleRenderer render node");
|
|
_render_node = new GeomNode("BaseParticleRenderer render node");
|
|
|
|
|
|
|
|
_user_alpha = 1.0f;
|
|
_user_alpha = 1.0f;
|
|
|
|
|
+ _ignore_scale = false;
|
|
|
|
|
|
|
|
update_alpha_mode(alpha_mode);
|
|
update_alpha_mode(alpha_mode);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
-// Function : BaseParticleRenderer
|
|
|
|
|
-// Access : Public
|
|
|
|
|
|
|
+// Function : BaseParticleRender::BaseParticleRenderer
|
|
|
|
|
+// Access : Published
|
|
|
// Description : Copy Constructor
|
|
// Description : Copy Constructor
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
BaseParticleRenderer::
|
|
BaseParticleRenderer::
|
|
@@ -47,13 +49,14 @@ BaseParticleRenderer(const BaseParticleRenderer& copy) :
|
|
|
_render_node = new GeomNode("BaseParticleRenderer render node");
|
|
_render_node = new GeomNode("BaseParticleRenderer render node");
|
|
|
|
|
|
|
|
_user_alpha = copy._user_alpha;
|
|
_user_alpha = copy._user_alpha;
|
|
|
|
|
+ set_ignore_scale(copy._ignore_scale);
|
|
|
|
|
|
|
|
update_alpha_mode(copy._alpha_mode);
|
|
update_alpha_mode(copy._alpha_mode);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
-// Function : ~BaseParticleRenderer
|
|
|
|
|
-// Access : Public
|
|
|
|
|
|
|
+// Function : BaseParticleRender::~BaseParticleRenderer
|
|
|
|
|
+// Access : Published
|
|
|
// Description : Destructor
|
|
// Description : Destructor
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
BaseParticleRenderer::
|
|
BaseParticleRenderer::
|
|
@@ -61,28 +64,60 @@ BaseParticleRenderer::
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
-// Function : enable_alpha
|
|
|
|
|
-// Access : Private
|
|
|
|
|
-// Description : Builds an intermediate node and transition that
|
|
|
|
|
-// enables alpha channeling.
|
|
|
|
|
|
|
+// Function : BaseParticleRender::set_ignore_scale
|
|
|
|
|
+// Access : Published
|
|
|
|
|
+// Description : Sets the "ignore scale" flag. When this is true,
|
|
|
|
|
+// particles will be drawn as if they had no scale,
|
|
|
|
|
+// regardless of whatever scale might be inherited from
|
|
|
|
|
+// above the render node in the scene graph.
|
|
|
|
|
+//
|
|
|
|
|
+// This flag is mainly useful to support legacy code
|
|
|
|
|
+// that was written for a very early version of Panda,
|
|
|
|
|
+// whose sprite particle renderer had a bug that
|
|
|
|
|
+// incorrectly ignored the inherited scale.
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
void BaseParticleRenderer::
|
|
void BaseParticleRenderer::
|
|
|
-enable_alpha() {
|
|
|
|
|
- _render_state = RenderState::make(TransparencyAttrib::make(TransparencyAttrib::M_alpha));
|
|
|
|
|
|
|
+set_ignore_scale(bool ignore_scale) {
|
|
|
|
|
+ _ignore_scale = ignore_scale;
|
|
|
|
|
+
|
|
|
|
|
+ if (_ignore_scale) {
|
|
|
|
|
+ _render_node->set_effect(CompassEffect::make(NodePath(), CompassEffect::P_scale));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ _render_node->clear_effect(CompassEffect::get_class_type());
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
-// Function : disable_alpha
|
|
|
|
|
-// Access : Private
|
|
|
|
|
-// Description : kills the intermediate alpha node/arc
|
|
|
|
|
|
|
+// Function : BaseParticleRender::output
|
|
|
|
|
+// Access : Published
|
|
|
|
|
+// Description : Write a string representation of this instance to
|
|
|
|
|
+// <out>.
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
void BaseParticleRenderer::
|
|
void BaseParticleRenderer::
|
|
|
-disable_alpha() {
|
|
|
|
|
- _render_state = RenderState::make(TransparencyAttrib::make(TransparencyAttrib::M_none));
|
|
|
|
|
|
|
+output(ostream &out) const {
|
|
|
|
|
+ #ifndef NDEBUG //[
|
|
|
|
|
+ out<<"BaseParticleRenderer";
|
|
|
|
|
+ #endif //] NDEBUG
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
|
|
+// Function : BaseParticleRender::write
|
|
|
|
|
+// Access : Published
|
|
|
|
|
+// Description : Write a string representation of this instance to
|
|
|
|
|
+// <out>.
|
|
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
|
|
+void BaseParticleRenderer::
|
|
|
|
|
+write(ostream &out, int indent) const {
|
|
|
|
|
+ #ifndef NDEBUG //[
|
|
|
|
|
+ out.width(indent); out<<""; out<<"BaseParticleRenderer:\n";
|
|
|
|
|
+ out.width(indent+2); out<<""; out<<"_render_node "<<_render_node<<"\n";
|
|
|
|
|
+ out.width(indent+2); out<<""; out<<"_user_alpha "<<_user_alpha<<"\n";
|
|
|
|
|
+ //ReferenceCount::write(out, indent+2);
|
|
|
|
|
+ #endif //] NDEBUG
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
-// Function : update_alpha_state
|
|
|
|
|
|
|
+// Function : BaseParticleRender::update_alpha_state
|
|
|
// Access : Private
|
|
// Access : Private
|
|
|
// Description : handles the base class part of alpha updating.
|
|
// Description : handles the base class part of alpha updating.
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
@@ -100,30 +135,22 @@ update_alpha_mode(ParticleRendererAlphaMode am) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
-// Function : output
|
|
|
|
|
-// Access : Public
|
|
|
|
|
-// Description : Write a string representation of this instance to
|
|
|
|
|
-// <out>.
|
|
|
|
|
|
|
+// Function : BaseParticleRender::enable_alpha
|
|
|
|
|
+// Access : Private
|
|
|
|
|
+// Description : Builds an intermediate node and transition that
|
|
|
|
|
+// enables alpha channeling.
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
void BaseParticleRenderer::
|
|
void BaseParticleRenderer::
|
|
|
-output(ostream &out) const {
|
|
|
|
|
- #ifndef NDEBUG //[
|
|
|
|
|
- out<<"BaseParticleRenderer";
|
|
|
|
|
- #endif //] NDEBUG
|
|
|
|
|
|
|
+enable_alpha() {
|
|
|
|
|
+ _render_state = RenderState::make(TransparencyAttrib::make(TransparencyAttrib::M_alpha));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
-// Function : write
|
|
|
|
|
-// Access : Public
|
|
|
|
|
-// Description : Write a string representation of this instance to
|
|
|
|
|
-// <out>.
|
|
|
|
|
|
|
+// Function : BaseParticleRender::disable_alpha
|
|
|
|
|
+// Access : Private
|
|
|
|
|
+// Description : kills the intermediate alpha node/arc
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
void BaseParticleRenderer::
|
|
void BaseParticleRenderer::
|
|
|
-write(ostream &out, int indent) const {
|
|
|
|
|
- #ifndef NDEBUG //[
|
|
|
|
|
- out.width(indent); out<<""; out<<"BaseParticleRenderer:\n";
|
|
|
|
|
- out.width(indent+2); out<<""; out<<"_render_node "<<_render_node<<"\n";
|
|
|
|
|
- out.width(indent+2); out<<""; out<<"_user_alpha "<<_user_alpha<<"\n";
|
|
|
|
|
- //ReferenceCount::write(out, indent+2);
|
|
|
|
|
- #endif //] NDEBUG
|
|
|
|
|
|
|
+disable_alpha() {
|
|
|
|
|
+ _render_state = RenderState::make(TransparencyAttrib::make(TransparencyAttrib::M_none));
|
|
|
}
|
|
}
|