34 StandardMunger::NumericType numeric_type,
35 StandardMunger::Contents contents) :
37 _num_components(num_components),
38 _numeric_type(numeric_type),
41 _munge_color_scale(false),
43 _shader_skinning(false),
44 _remove_material(false)
47 state->get_attrib_def(shader_attrib);
51 if (shader_attrib->get_flag(ShaderAttrib::F_hardware_skinning)) {
52 _shader_skinning =
true;
56 shader_attrib->get_shader() ==
nullptr) {
61 if (state->get_attrib(color_attrib) &&
67 }
else if (state->get_attrib(color_scale_attrib) &&
69 _color_scale = color_scale_attrib->
get_scale();
72 state->get_attrib(TextureAttrib::get_class_slot());
78 _munge_color_scale =
true;
79 _should_munge_state =
true;
95 state->get_attrib(material_attrib) &&
97 shader_attrib->get_shader() ==
nullptr) {
98 _remove_material =
true;
99 _should_munge_state =
true;
118 new_data = new_data->set_color(_color, _num_components, _numeric_type,
120 }
else if (_munge_color_scale) {
121 new_data = new_data->scale_color(_color_scale, _num_components,
122 _numeric_type, _contents);
126 if (_shader_skinning || (_auto_shader && hardware_animated_vertices &&
130 }
else if (hardware_animated_vertices &&
132 new_data->get_slider_table() ==
nullptr) {
135 if (table !=
nullptr &&
139 if (matrix_palette &&
166 if (new_format == orig_format) {
171 return new_data->convert_to(new_format);
177 void StandardMunger::
183 if (unsupported_bits != 0) {
188 if ((unsupported_bits & Geom::GR_composite_bits) != 0 ||
189 (unsupported_bits & Geom::GR_strip_cut_index) != 0) {
198 geom = geom->decompose();
204 if ((unsupported_bits & Geom::GR_shade_model_bits) != 0) {
207 geom = geom->rotate();
209 if ((unsupported_bits & Geom::GR_indexed_bits) != 0) {
213 new_geom->make_nonindexed(
false);
215 vertex_data = new_geom->get_vertex_data();
223 void StandardMunger::
228 if (unsupported_bits != 0) {
233 if ((unsupported_bits & Geom::GR_composite_bits) != 0 ||
234 (unsupported_bits & Geom::GR_strip_cut_index) != 0) {
243 geom = geom->decompose();
249 if ((unsupported_bits & Geom::GR_shade_model_bits) != 0) {
252 geom = geom->rotate();
254 if ((unsupported_bits & Geom::GR_indexed_bits) != 0) {
258 new_geom->make_nonindexed(
false);
260 vertex_data = new_geom->get_vertex_data();
271 compare_to_impl(
const GeomMunger *other)
const {
274 if (_munge_color != om->_munge_color) {
275 return (
int)_munge_color - (int)om->_munge_color;
277 if (_munge_color_scale != om->_munge_color_scale) {
278 return (
int)_munge_color_scale - (int)om->_munge_color_scale;
281 int compare = _color.compare_to(om->_color);
286 if (_munge_color_scale) {
287 int compare = _color_scale.compare_to(om->_color_scale);
292 if (_shader_skinning != om->_shader_skinning) {
293 return (
int)_shader_skinning - (int)om->_shader_skinning;
295 if (_auto_shader != om->_auto_shader) {
296 return (
int)_auto_shader - (int)om->_auto_shader;
298 if (_remove_material != om->_remove_material) {
299 return (
int)_remove_material - (int)om->_remove_material;
302 return StateMunger::compare_to_impl(other);
312 geom_compare_to_impl(
const GeomMunger *other)
const {
315 if (_munge_color != om->_munge_color) {
316 return (
int)_munge_color - (int)om->_munge_color;
318 if (_munge_color_scale != om->_munge_color_scale) {
319 return (
int)_munge_color_scale - (int)om->_munge_color_scale;
322 int compare = _color.compare_to(om->_color);
327 if (_munge_color_scale) {
328 int compare = _color_scale.compare_to(om->_color_scale);
333 if (_shader_skinning != om->_shader_skinning) {
334 return (
int)_shader_skinning - (int)om->_shader_skinning;
337 return StateMunger::geom_compare_to_impl(other);
348 munged_state = munged_state->remove_attrib(ColorAttrib::get_class_slot());
349 munged_state = munged_state->remove_attrib(ColorScaleAttrib::get_class_slot());
350 }
else if (_munge_color_scale) {
351 munged_state = munged_state->remove_attrib(ColorScaleAttrib::get_class_slot());
354 if (_remove_material) {
355 munged_state = munged_state->remove_attrib(MaterialAttrib::get_class_slot());
get_animation_type
Returns the type of animation represented by this spec.
This is just a simple derivative of GeomMunger that adds the ability to munge states.
bool get_runtime_color_scale() const
Returns true if this particular GSG can implement (or would prefer to implement) set color and/or col...
bool auto_shader() const
If true, then this ShaderAttrib does not contain an explicit shader - instead, it requests the automa...
has_scale
Returns true if the ColorScaleAttrib has a non-identity scale, false otherwise (in which case it migh...
bool has_alpha_scale() const
Returns true if the ColorScaleAttrib has a non-identity scale in the alpha component (ignoring RGB),...
bool get_color_scale_via_lighting() const
Returns true if this particular GSG can implement (or would prefer to implement) set color and/or col...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Indicates which, if any, material should be applied to geometry.
This object describes how the vertex animation, if any, represented in a GeomVertexData is encoded.
StandardMunger(GraphicsStateGuardianBase *gsg, const RenderState *state, int num_components, NumericType numeric_type, Contents contents)
The StandardMunger constructor accepts additional parameters that specify the GSG's preferred color f...
Objects of this class are used to convert vertex data from a Geom into a format suitable for passing ...
GraphicsStateGuardian * get_gsg() const
Returns a pointer to the GSG that created this munger.
Performs some generic munging that is appropriate for all GSG types; for instance,...
void set_hardware(int num_transforms, bool indexed_transforms)
Specifies that vertex animation is to be performed by the graphics hardware (or at least by the graph...
CPT(GeomVertexData) StandardMunger
Given a source GeomVertexData, converts it as necessary for rendering.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool get_alpha_scale_via_texture() const
Returns true if this particular GSG can implement (or would prefer to implement) an alpha scale via a...
Indicates the set of TextureStages and their associated Textures that should be applied to (or remove...
get_max_vertex_transform_indices
Returns the maximum number of transforms there may be in a single TransformTable for this graphics ha...
get_scale
Returns the scale to be applied to colors.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual Geom * make_copy() const
Returns a newly-allocated Geom that is a shallow copy of this one.
get_max_vertex_transforms
Returns the maximum number of transform matrices that may be simultaneously used to transform any one...
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
A container for geometry primitives.
bool has_rgb_scale() const
Returns true if the ColorScaleAttrib has a non-identity scale in the RGB components (ignoring alpha),...
Applies a scale to colors in the scene graph and on vertices.
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
get_material
If the MaterialAttrib is not an 'off' MaterialAttrib, returns the material that is associated.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is a base class for the GraphicsStateGuardian class, which is itself a base class for the variou...
void set_vertex_data(const GeomVertexData *data)
Replaces the Geom's underlying vertex data table with a completely new table.
A thread; that is, a lightweight process.
Indicates what color should be applied to renderable geometry.
get_geom_rendering
Returns the set of GeomRendering bits that represent the rendering properties required to properly re...
virtual int get_supported_geom_rendering() const
Returns the union of Geom::GeomRendering values that this particular GSG can support directly.
TypeHandle is the identifier used to differentiate C++ class types.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
get_color_type
Returns the type of color specified by this ColorAttrib.
bool has_any_on_light() const
Returns true if any light is turned on by the attrib, false otherwise.
Indicates which set of lights should be considered "on" to illuminate geometry at this level and belo...