mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 02:42:49 -04:00
add set_ignore_scale
This commit is contained in:
parent
3cf1d513f2
commit
cd10f4fcbc
@ -17,8 +17,8 @@
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function : get_render_node
|
||||
// Class : Public
|
||||
// Function : BaseParticleRender::get_render_node
|
||||
// Class : Published
|
||||
// Description : Query the geomnode pointer
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE GeomNode *BaseParticleRenderer::
|
||||
@ -27,8 +27,8 @@ get_render_node() const {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function : set_alpha_mode
|
||||
// Access : public
|
||||
// Function : BaseParticleRender::set_alpha_mode
|
||||
// Access : Published
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void BaseParticleRenderer::
|
||||
set_alpha_mode(BaseParticleRenderer::ParticleRendererAlphaMode am) {
|
||||
@ -37,8 +37,8 @@ set_alpha_mode(BaseParticleRenderer::ParticleRendererAlphaMode am) {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function : get_alpha_mode
|
||||
// Access : public
|
||||
// Function : BaseParticleRender::get_alpha_mode
|
||||
// Access : Published
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE BaseParticleRenderer::ParticleRendererAlphaMode BaseParticleRenderer::
|
||||
get_alpha_mode() const {
|
||||
@ -46,8 +46,8 @@ get_alpha_mode() const {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function : set_user_alpha
|
||||
// Access : public
|
||||
// Function : BaseParticleRender::set_user_alpha
|
||||
// Access : Published
|
||||
// Description : sets alpha for "user" alpha mode
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void BaseParticleRenderer::
|
||||
@ -56,8 +56,8 @@ set_user_alpha(float ua) {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function : get_user_alpha
|
||||
// Access : public
|
||||
// Function : BaseParticleRender::get_user_alpha
|
||||
// Access : Published
|
||||
// Description : gets alpha for "user" alpha mode
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE float BaseParticleRenderer::
|
||||
@ -66,8 +66,8 @@ get_user_alpha() const {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function : set_color_blend_mode
|
||||
// Access : public
|
||||
// Function : BaseParticleRender::set_color_blend_mode
|
||||
// Access : Published
|
||||
// Description : sets the ColorBlendAttrib on the _render_node
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void BaseParticleRenderer::
|
||||
@ -81,11 +81,22 @@ set_color_blend_mode(ColorBlendAttrib::Mode bm, ColorBlendAttrib::Operand oa, Co
|
||||
|
||||
_render_node->set_attrib(ra);
|
||||
return;
|
||||
};
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function : get_cur_alpha
|
||||
// Access : public
|
||||
// Function : BaseParticleRender::get_ignore_scale
|
||||
// Access : Published
|
||||
// Description : Returns the "ignore scale" flag. See
|
||||
// set_ignore_scale().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool BaseParticleRenderer::
|
||||
get_ignore_scale() const {
|
||||
return _ignore_scale;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function : BaseParticleRender::get_cur_alpha
|
||||
// Access : Published
|
||||
// Description : gets current alpha for a particle
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE float BaseParticleRenderer::
|
||||
|
@ -20,10 +20,11 @@
|
||||
|
||||
#include "baseParticleRenderer.h"
|
||||
#include "transparencyAttrib.h"
|
||||
#include "compassEffect.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function : BaseParticleRenderer
|
||||
// Access : Public
|
||||
// Function : BaseParticleRender::BaseParticleRenderer
|
||||
// Access : Published
|
||||
// Description : Default Constructor
|
||||
////////////////////////////////////////////////////////////////////
|
||||
BaseParticleRenderer::
|
||||
@ -32,13 +33,14 @@ BaseParticleRenderer(ParticleRendererAlphaMode alpha_mode) :
|
||||
_render_node = new GeomNode("BaseParticleRenderer render node");
|
||||
|
||||
_user_alpha = 1.0f;
|
||||
_ignore_scale = false;
|
||||
|
||||
update_alpha_mode(alpha_mode);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function : BaseParticleRenderer
|
||||
// Access : Public
|
||||
// Function : BaseParticleRender::BaseParticleRenderer
|
||||
// Access : Published
|
||||
// Description : Copy Constructor
|
||||
////////////////////////////////////////////////////////////////////
|
||||
BaseParticleRenderer::
|
||||
@ -47,13 +49,14 @@ BaseParticleRenderer(const BaseParticleRenderer& copy) :
|
||||
_render_node = new GeomNode("BaseParticleRenderer render node");
|
||||
|
||||
_user_alpha = copy._user_alpha;
|
||||
set_ignore_scale(copy._ignore_scale);
|
||||
|
||||
update_alpha_mode(copy._alpha_mode);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function : ~BaseParticleRenderer
|
||||
// Access : Public
|
||||
// Function : BaseParticleRender::~BaseParticleRenderer
|
||||
// Access : Published
|
||||
// Description : Destructor
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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::
|
||||
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::
|
||||
disable_alpha() {
|
||||
_render_state = RenderState::make(TransparencyAttrib::make(TransparencyAttrib::M_none));
|
||||
output(ostream &out) const {
|
||||
#ifndef NDEBUG //[
|
||||
out<<"BaseParticleRenderer";
|
||||
#endif //] NDEBUG
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function : update_alpha_state
|
||||
// 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 : BaseParticleRender::update_alpha_state
|
||||
// Access : Private
|
||||
// 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::
|
||||
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::
|
||||
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));
|
||||
}
|
||||
|
@ -64,6 +64,9 @@ PUBLISHED:
|
||||
|
||||
INLINE void set_color_blend_mode(ColorBlendAttrib::Mode bm, ColorBlendAttrib::Operand oa = ColorBlendAttrib::O_zero, ColorBlendAttrib::Operand ob = ColorBlendAttrib::O_zero);
|
||||
|
||||
void set_ignore_scale(bool ignore_scale);
|
||||
INLINE bool get_ignore_scale() const;
|
||||
|
||||
virtual void output(ostream &out) const;
|
||||
virtual void write(ostream &out, int indent=0) const;
|
||||
|
||||
@ -91,6 +94,7 @@ private:
|
||||
PT(GeomNode) _render_node;
|
||||
|
||||
float _user_alpha;
|
||||
bool _ignore_scale;
|
||||
|
||||
// birth and kill particle are for renderers that might do maintenance
|
||||
// faster if it was notified on a per-event basis. An example:
|
||||
|
Loading…
x
Reference in New Issue
Block a user