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 &&
58 const ColorAttrib *color_attrib;
59 const ColorScaleAttrib *color_scale_attrib;
61 if (state->get_attrib(color_attrib) &&
62 color_attrib->get_color_type() != ColorAttrib::T_vertex) {
67 }
else if (state->get_attrib(color_scale_attrib) &&
68 color_scale_attrib->has_scale()) {
69 _color_scale = color_scale_attrib->get_scale();
71 const TextureAttrib *tex_attrib = (const TextureAttrib *)
72 state->get_attrib(TextureAttrib::get_class_slot());
76 if ((color_scale_attrib->has_rgb_scale() && !get_gsg()->get_color_scale_via_lighting()) ||
77 (color_scale_attrib->has_alpha_scale() && !get_gsg()->get_alpha_scale_via_texture(tex_attrib))) {
78 _munge_color_scale = true;
79 _should_munge_state = true;
93 if (get_gsg()->get_color_scale_via_lighting() &&
95 state->get_attrib(material_attrib) &&
97 shader_attrib->get_shader() ==
nullptr) {
98 _remove_material = true;
99 _should_munge_state = true;
115 CPT(GeomVertexData) new_data = data;
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);
125 GeomVertexAnimationSpec animation = new_data->get_format()->get_animation();
127 (_auto_shader && hardware_animated_vertices &&
131 }
else if (hardware_animated_vertices &&
133 new_data->get_slider_table() ==
nullptr) {
135 const TransformBlendTable *table = new_data->get_transform_blend_table();
136 if (table !=
nullptr &&
139 get_gsg()->get_max_vertex_transforms()) {
140 if (matrix_palette &&
156 get_gsg()->get_max_vertex_transforms()) {
164 CPT(GeomVertexFormat) orig_format = new_data->get_format();
165 CPT(GeomVertexFormat) new_format = munge_format(orig_format, animation);
167 if (new_format == orig_format) {
172 return new_data->convert_to(new_format);
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();
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();
272compare_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);
313geom_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);
346 CPT(RenderState) munged_state = state;
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());
Objects of this class are used to convert vertex data from a Geom into a format suitable for passing ...
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...
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...
get_shader
Returns the shader object associated with the node.
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.
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.