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;
55 if (!
get_gsg()->get_runtime_color_scale() && !_auto_shader &&
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);
127 (_auto_shader && hardware_animated_vertices &&
131 }
else if (hardware_animated_vertices &&
133 new_data->get_slider_table() ==
nullptr) {
136 if (table !=
nullptr &&
139 get_gsg()->get_max_vertex_transforms()) {
140 if (matrix_palette &&
156 get_gsg()->get_max_vertex_transforms()) {
167 if (new_format == orig_format) {
172 return new_data->convert_to(new_format);
178 void StandardMunger::
184 if (unsupported_bits != 0) {
189 if ((unsupported_bits & Geom::GR_composite_bits) != 0 ||
190 (unsupported_bits & Geom::GR_strip_cut_index) != 0) {
199 geom = geom->decompose();
205 if ((unsupported_bits & Geom::GR_shade_model_bits) != 0) {
208 geom = geom->rotate();
210 if ((unsupported_bits & Geom::GR_indexed_bits) != 0) {
214 new_geom->make_nonindexed(
false);
216 vertex_data = new_geom->get_vertex_data();
224 void StandardMunger::
229 if (unsupported_bits != 0) {
234 if ((unsupported_bits & Geom::GR_composite_bits) != 0 ||
235 (unsupported_bits & Geom::GR_strip_cut_index) != 0) {
244 geom = geom->decompose();
250 if ((unsupported_bits & Geom::GR_shade_model_bits) != 0) {
253 geom = geom->rotate();
255 if ((unsupported_bits & Geom::GR_indexed_bits) != 0) {
259 new_geom->make_nonindexed(
false);
261 vertex_data = new_geom->get_vertex_data();
272 compare_to_impl(
const GeomMunger *other)
const {
275 if (_munge_color != om->_munge_color) {
276 return (
int)_munge_color - (int)om->_munge_color;
278 if (_munge_color_scale != om->_munge_color_scale) {
279 return (
int)_munge_color_scale - (int)om->_munge_color_scale;
282 int compare = _color.compare_to(om->_color);
287 if (_munge_color_scale) {
288 int compare = _color_scale.compare_to(om->_color_scale);
293 if (_shader_skinning != om->_shader_skinning) {
294 return (
int)_shader_skinning - (int)om->_shader_skinning;
296 if (_auto_shader != om->_auto_shader) {
297 return (
int)_auto_shader - (int)om->_auto_shader;
299 if (_remove_material != om->_remove_material) {
300 return (
int)_remove_material - (int)om->_remove_material;
303 return StateMunger::compare_to_impl(other);
313 geom_compare_to_impl(
const GeomMunger *other)
const {
316 if (_munge_color != om->_munge_color) {
317 return (
int)_munge_color - (int)om->_munge_color;
319 if (_munge_color_scale != om->_munge_color_scale) {
320 return (
int)_munge_color_scale - (int)om->_munge_color_scale;
323 int compare = _color.compare_to(om->_color);
328 if (_munge_color_scale) {
329 int compare = _color_scale.compare_to(om->_color_scale);
334 if (_shader_skinning != om->_shader_skinning) {
335 return (
int)_shader_skinning - (int)om->_shader_skinning;
338 return StateMunger::geom_compare_to_impl(other);
349 munged_state = munged_state->remove_attrib(ColorAttrib::get_class_slot());
350 munged_state = munged_state->remove_attrib(ColorScaleAttrib::get_class_slot());
351 }
else if (_munge_color_scale) {
352 munged_state = munged_state->remove_attrib(ColorScaleAttrib::get_class_slot());
355 if (_remove_material) {
356 munged_state = munged_state->remove_attrib(MaterialAttrib::get_class_slot());
Indicates what color should be applied to renderable geometry.
get_color_type
Returns the type of color specified by this ColorAttrib.
Applies a scale to colors in the scene graph and on vertices.
bool has_alpha_scale() const
Returns true if the ColorScaleAttrib has a non-identity scale in the alpha component (ignoring RGB),...
has_scale
Returns true if the ColorScaleAttrib has a non-identity scale, false otherwise (in which case it migh...
bool has_rgb_scale() const
Returns true if the ColorScaleAttrib has a non-identity scale in the RGB components (ignoring alpha),...
get_scale
Returns the scale to be applied to colors.
Objects of this class are used to convert vertex data from a Geom into a format suitable for passing ...
This object describes how the vertex animation, if any, represented in a GeomVertexData is encoded.
get_animation_type
Returns the type of animation represented by this spec.
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...
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
A container for geometry primitives.
virtual Geom * make_copy() const
Returns a newly-allocated Geom that is a shallow copy of this one.
void set_vertex_data(const GeomVertexData *data)
Replaces the Geom's underlying vertex data table with a completely new table.
get_geom_rendering
Returns the set of GeomRendering bits that represent the rendering properties required to properly re...
This is a base class for the GraphicsStateGuardian class, which is itself a base class for the variou...
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...
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...
virtual int get_supported_geom_rendering() const
Returns the union of Geom::GeomRendering values that this particular GSG can support directly.
Indicates which set of lights should be considered "on" to illuminate geometry at this level and belo...
bool has_any_on_light() const
Returns true if any light is turned on by the attrib, false otherwise.
Indicates which, if any, material should be applied to geometry.
get_material
If the MaterialAttrib is not an 'off' MaterialAttrib, returns the material that is associated.
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
bool auto_shader() const
If true, then this ShaderAttrib does not contain an explicit shader - instead, it requests the automa...
Performs some generic munging that is appropriate for all GSG types; for instance,...
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...
GraphicsStateGuardian * get_gsg() const
Returns a pointer to the GSG that created this munger.
This is just a simple derivative of GeomMunger that adds the ability to munge states.
Indicates the set of TextureStages and their associated Textures that should be applied to (or remove...
A thread; that is, a lightweight process.
TypeHandle is the identifier used to differentiate C++ class types.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
CPT(GeomVertexData) StandardMunger
Given a source GeomVertexData, converts it as necessary for rendering.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.