Panda3D
eggRenderState.cxx
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file eggRenderState.cxx
10  * @author drose
11  * @date 2005-03-12
12  */
13 
14 #include "eggRenderState.h"
15 #include "eggRenderMode.h"
16 #include "eggLine.h"
17 #include "eggPoint.h"
18 #include "textureAttrib.h"
19 #include "renderAttrib.h"
20 #include "eggTexture.h"
21 #include "texGenAttrib.h"
22 #include "internalName.h"
23 #include "eggCurve.h"
24 #include "eggSurface.h"
25 #include "cullBinAttrib.h"
26 #include "cullFaceAttrib.h"
27 #include "shadeModelAttrib.h"
28 #include "transparencyAttrib.h"
29 #include "depthWriteAttrib.h"
30 #include "depthTestAttrib.h"
31 #include "depthOffsetAttrib.h"
32 #include "texMatrixAttrib.h"
33 #include "renderModeAttrib.h"
34 #include "material.h"
35 #include "materialAttrib.h"
36 #include "materialPool.h"
37 #include "config_gobj.h"
38 #include "config_egg2pg.h"
39 
40 
41 /**
42  * Sets up the state as appropriate for the indicated primitive.
43  */
46  // The various EggRenderMode properties can be defined directly at the
47  // primitive, at a group above the primitive, or an a texture applied to the
48  // primitive. The EggNode::determine_*() functions can find the right
49  // pointer to the level at which this is actually defined for a given
50  // primitive.
51  EggRenderMode::AlphaMode am = EggRenderMode::AM_unspecified;
52  EggRenderMode::DepthWriteMode dwm = EggRenderMode::DWM_unspecified;
53  EggRenderMode::DepthTestMode dtm = EggRenderMode::DTM_unspecified;
54  EggRenderMode::VisibilityMode vm = EggRenderMode::VM_unspecified;
55  bool implicit_alpha = false;
56  bool binary_alpha_only = true; // true if all alpha sources are binary alpha.
57  bool has_draw_order = false;
58  int draw_order = 0;
59  bool has_depth_offset = false;
60  int depth_offset = 0;
61  bool has_bin = false;
62  std::string bin;
63 
64  EggRenderMode *render_mode;
65  render_mode = egg_prim->determine_alpha_mode();
66  if (render_mode != nullptr) {
67  am = render_mode->get_alpha_mode();
68  }
69  render_mode = egg_prim->determine_depth_write_mode();
70  if (render_mode != nullptr) {
71  dwm = render_mode->get_depth_write_mode();
72  }
73  render_mode = egg_prim->determine_depth_test_mode();
74  if (render_mode != nullptr) {
75  dtm = render_mode->get_depth_test_mode();
76  }
77  render_mode = egg_prim->determine_visibility_mode();
78  if (render_mode != nullptr) {
79  vm = render_mode->get_visibility_mode();
80  }
81  render_mode = egg_prim->determine_draw_order();
82  if (render_mode != nullptr) {
83  has_draw_order = true;
84  draw_order = render_mode->get_draw_order();
85  }
86  render_mode = egg_prim->determine_depth_offset();
87  if (render_mode != nullptr) {
88  has_depth_offset = true;
89  depth_offset = render_mode->get_depth_offset();
90  }
91  render_mode = egg_prim->determine_bin();
92  if (render_mode != nullptr) {
93  has_bin = true;
94  bin = render_mode->get_bin();
95  }
96 
97  // add_attrib(TextureAttrib::make_off());
98  int num_textures = egg_prim->get_num_textures();
99  CPT(RenderAttrib) texture_attrib = nullptr;
100  CPT(RenderAttrib) tex_gen_attrib = nullptr;
101  CPT(RenderAttrib) tex_mat_attrib = nullptr;
102  TexMats tex_mats;
103 
104  for (int i = 0; i < num_textures; i++) {
105  PT_EggTexture egg_tex = egg_prim->get_texture(i);
106 
107  const TextureDef &def = _loader._textures[egg_tex];
108  if (def._texture != nullptr) {
109  if (texture_attrib == nullptr) {
110  texture_attrib = def._texture;
111  } else {
112  texture_attrib = texture_attrib->compose(def._texture);
113  }
114 
115  if (egg_tex->affects_polygon_alpha()) {
116  const TextureAttrib *tex_attrib = DCAST(TextureAttrib, def._texture);
117  Texture *tex = tex_attrib->get_texture();
118  nassertv(tex != nullptr);
119 
120  Texture::Format format = tex->get_format();
121  if (Texture::has_alpha(format) && !Texture::has_binary_alpha(format)) {
122  // This texture specifies a gradient alpha format.
123  binary_alpha_only = false;
124  }
125 
126  if (am == EggRenderMode::AM_unspecified) {
127  // If neither the primitive nor the texture specified an alpha mode,
128  // assume it should be alpha'ed if the texture has an alpha channel
129  // (unless the texture environment type is one that doesn't apply
130  // its alpha to the result).
131  int num_components = tex->get_num_components();
132  if (egg_tex->has_alpha_channel(num_components)) {
133  implicit_alpha = true;
134  }
135  }
136  }
137 
138  // Check for a texgen attrib.
139  bool has_tex_gen = false;
140  if (egg_tex->get_tex_gen() != EggTexture::TG_unspecified) {
141  has_tex_gen = true;
142  if (tex_gen_attrib == nullptr) {
143  tex_gen_attrib = TexGenAttrib::make();
144  }
145  tex_gen_attrib = DCAST(TexGenAttrib, tex_gen_attrib)->
146  add_stage(def._stage, get_tex_gen(egg_tex));
147  }
148 
149  // Record the texture's associated texture matrix, so we can see if we
150  // can safely bake it into the UV's. (We need to get the complete list
151  // of textures that share this same set of UV's per each unique texture
152  // matrix. Whew!)
153  CPT(InternalName) uv_name;
154  if (egg_tex->has_uv_name() && egg_tex->get_uv_name() != std::string("default")) {
155  uv_name = InternalName::get_texcoord_name(egg_tex->get_uv_name());
156  } else {
157  uv_name = InternalName::get_texcoord();
158  }
159 
160  if (has_tex_gen) {
161  // If the texture has a texgen mode, we will always apply its texture
162  // transform, never bake it in. In fact, we don't even care about its
163  // UV's in this case, since we won't be using them.
164  tex_mat_attrib = apply_tex_mat(tex_mat_attrib, def._stage, egg_tex);
165 
166  } else {
167 /*
168  * Otherwise, we need to record that there is at least one texture on this
169  * particular UV name and with this particular texture matrix. If there are
170  * no other textures, or if all of the other textures use the same texture
171  * matrix, then tex_mats[uv_name].size() will remain 1 (which tells us we can
172  * bake in the texture matrix to the UV's). On the other hand, if there is
173  * another texture on the same uv name but with a different transform, it will
174  * increase tex_mats[uv_name].size() to at least 2, indicating we can't bake
175  * in the texture matrix.
176  */
177  tex_mats[uv_name][egg_tex->get_transform3d()].push_back(&def);
178  }
179  }
180  }
181 
182  // These parametric primitive types can't have their UV's baked in, so if we
183  // have one of these we always need to apply the texture matrix as a
184  // separate attribute, regardless of how many textures share the particular
185  // UV set.
186  bool needs_tex_mat = (egg_prim->is_of_type(EggCurve::get_class_type()) ||
187  egg_prim->is_of_type(EggSurface::get_class_type()));
188 
189  // Now that we've visited all of the textures in the above loop, we can go
190  // back and see how many of them share the same UV name and texture matrix.
191  TexMats::const_iterator tmi;
192  for (tmi = tex_mats.begin(); tmi != tex_mats.end(); ++tmi) {
193  const InternalName *uv_name = (*tmi).first;
194  const TexMatTransforms &tmt = (*tmi).second;
195 
196  if (tmt.size() == 1 && !needs_tex_mat) {
197  // Only one unique transform sharing this set of UV's. We can bake in
198  // the transform!
199  const TexMatTextures &tmtex = (*tmt.begin()).second;
200 
201  // The first EggTexture on the list is sufficient, since we know they
202  // all have the same transform.
203  nassertv(!tmtex.empty());
204  TexMatTextures::const_iterator tmtexi = tmtex.begin();
205  const EggTexture *egg_tex = (*tmtexi)->_egg_tex;
206  if (egg_tex->has_transform()) {
207  // If there's no transform, it's an identity matrix; don't bother
208  // recording it. Of course, it would do no harm to record it if we
209  // felt like it.
210  _bake_in_uvs[uv_name] = egg_tex;
211  }
212 
213  } else {
214  // Multiple transforms on this UV set, or a geometry type that doesn't
215  // support baking in UV's. We have to apply the texture matrix to each
216  // stage.
217  TexMatTransforms::const_iterator tmti;
218  for (tmti = tmt.begin(); tmti != tmt.end(); ++tmti) {
219  const TexMatTextures &tmtex = (*tmti).second;
220  TexMatTextures::const_iterator tmtexi;
221  for (tmtexi = tmtex.begin(); tmtexi != tmtex.end(); ++tmtexi) {
222  const EggTexture *egg_tex = (*tmtexi)->_egg_tex;
223  TextureStage *stage = (*tmtexi)->_stage;
224 
225  tex_mat_attrib = apply_tex_mat(tex_mat_attrib, stage, egg_tex);
226  }
227  }
228  }
229  }
230 
231  if (texture_attrib != nullptr) {
232  add_attrib(texture_attrib);
233  }
234 
235  if (tex_gen_attrib != nullptr) {
236  add_attrib(tex_gen_attrib);
237  }
238 
239  if (tex_mat_attrib != nullptr) {
240  add_attrib(tex_mat_attrib);
241  }
242 
243  if (egg_prim->has_material()) {
244  PT(EggMaterial) material = egg_prim->get_material();
245  CPT(RenderAttrib) mt =
246  get_material_attrib(material, egg_prim->get_bface_flag());
247  add_attrib(mt);
248 
249  if (material->has_diff() && material->get_diff()[3] != 1.0) {
250  implicit_alpha = true;
251  binary_alpha_only = false;
252  }
253  }
254 
255 
256  // Also check the color of the primitive to see if we should assume alpha
257  // based on the alpha values specified in the egg file.
258  if (am == EggRenderMode::AM_unspecified) {
259  if (egg_prim->has_color()) {
260  if (egg_prim->get_color()[3] != 1.0) {
261  implicit_alpha = true;
262  binary_alpha_only = false;
263  }
264  }
265  EggPrimitive::const_iterator vi;
266  for (vi = egg_prim->begin();
267  !implicit_alpha && vi != egg_prim->end();
268  ++vi) {
269  if ((*vi)->has_color()) {
270  if ((*vi)->get_color()[3] != 1.0) {
271  implicit_alpha = true;
272  binary_alpha_only = false;
273  }
274  }
275  }
276 
277  if (implicit_alpha) {
278  am = EggRenderMode::AM_on;
279  }
280  }
281 
282  switch (am) {
283  case EggRenderMode::AM_on:
284  // Alpha type "on" means to get the default transparency type.
285  if (binary_alpha_only) {
286  am = EggRenderMode::AM_binary;
287  } else if (egg_alpha_mode != EggRenderMode::AM_unspecified) {
288  am = egg_alpha_mode;
289  }
290  break;
291 
292  case EggRenderMode::AM_blend:
293  case EggRenderMode::AM_ms:
294  case EggRenderMode::AM_ms_mask:
295  case EggRenderMode::AM_dual:
296  if (egg_implicit_alpha_binary) {
297  // Any of these modes gets implicitly downgraded to AM_binary, if all of
298  // the alpha sources only contribute a binary value to alpha.
299  if (binary_alpha_only) {
300  am = EggRenderMode::AM_binary;
301  }
302  }
303  break;
304 
305  default:
306  break;
307  }
308 
309  switch (am) {
310  case EggRenderMode::AM_on:
311  case EggRenderMode::AM_blend:
312  add_attrib(TransparencyAttrib::make(TransparencyAttrib::M_alpha));
313  break;
314 
315  case EggRenderMode::AM_blend_no_occlude:
316  add_attrib(TransparencyAttrib::make(TransparencyAttrib::M_alpha));
317  add_attrib(DepthWriteAttrib::make(DepthWriteAttrib::M_off));
318  break;
319 
320  case EggRenderMode::AM_ms:
321  add_attrib(TransparencyAttrib::make(TransparencyAttrib::M_multisample));
322  break;
323 
324  case EggRenderMode::AM_ms_mask:
325  add_attrib(TransparencyAttrib::make(TransparencyAttrib::M_multisample_mask));
326  break;
327 
328  case EggRenderMode::AM_binary:
329  add_attrib(TransparencyAttrib::make(TransparencyAttrib::M_binary));
330  break;
331 
332  case EggRenderMode::AM_dual:
333  add_attrib(TransparencyAttrib::make(TransparencyAttrib::M_dual));
334  break;
335 
336  case EggRenderMode::AM_premultiplied:
337  add_attrib(TransparencyAttrib::make(TransparencyAttrib::M_premultiplied_alpha));
338  break;
339 
340  default:
341  break;
342  }
343 
344  switch (dwm) {
345  case EggRenderMode::DWM_on:
346  add_attrib(DepthWriteAttrib::make(DepthWriteAttrib::M_on));
347  break;
348 
349  case EggRenderMode::DWM_off:
350  add_attrib(DepthWriteAttrib::make(DepthWriteAttrib::M_off));
351  break;
352 
353  default:
354  break;
355  }
356 
357  switch (dtm) {
358  case EggRenderMode::DTM_on:
359  add_attrib(DepthTestAttrib::make(DepthTestAttrib::M_less));
360  break;
361 
362  case EggRenderMode::DTM_off:
363  add_attrib(DepthTestAttrib::make(DepthTestAttrib::M_none));
364  break;
365 
366  default:
367  break;
368  }
369 
370  switch (vm) {
371  case EggRenderMode::VM_hidden:
372  _hidden = true;
373  break;
374 
375  case EggRenderMode::VM_normal:
376  default:
377  break;
378  }
379 
380  _flat_shaded =
381  (egg_flat_shading &&
382  egg_prim->get_connected_shading() == EggPrimitive::S_per_face);
383 
384  if (_flat_shaded) {
385  add_attrib(ShadeModelAttrib::make(ShadeModelAttrib::M_flat));
386  }
387 
388  if (egg_prim->is_of_type(EggLine::get_class_type())) {
389  _primitive_type = Geom::PT_lines;
390  EggLine *egg_line = DCAST(EggLine, egg_prim);
391  if (egg_line->get_thick() != 1.0) {
392  add_attrib(RenderModeAttrib::make(RenderModeAttrib::M_unchanged,
393  egg_line->get_thick()));
394  }
395  } else if (egg_prim->is_of_type(EggPoint::get_class_type())) {
396  _primitive_type = Geom::PT_points;
397  EggPoint *egg_point = DCAST(EggPoint, egg_prim);
398  if (egg_point->get_thick() != 1.0 || egg_point->get_perspective()) {
399  add_attrib(RenderModeAttrib::make(RenderModeAttrib::M_unchanged,
400  egg_point->get_thick(),
401  egg_point->get_perspective()));
402  }
403  } else {
404  _primitive_type = Geom::PT_polygons;
405  }
406 
407  if (has_bin) {
408  add_attrib(CullBinAttrib::make(bin, draw_order));
409 
410  } else if (has_draw_order) {
411  add_attrib(CullBinAttrib::make("fixed", draw_order));
412  }
413  if (has_depth_offset) {
414  add_attrib(DepthOffsetAttrib::make(depth_offset));
415  }
416 
417 
418  if (egg_prim->get_bface_flag()) {
419  // The primitive is marked with backface culling disabled--we want to see
420  // both sides.
421  add_attrib(CullFaceAttrib::make(CullFaceAttrib::M_cull_none));
422  }
423 }
424 
425 /**
426  * Provides a unique ordering for different EggRenderState objects, so that
427  * primitives of similar state can be grouped together by the EggBinner.
428  */
430 compare_to(const EggRenderState &other) const {
431  if (_state != other._state) {
432  int c = _state->compare_to(*other._state);
433  if (c != 0) {
434  return c;
435  }
436  }
437  if (_hidden != other._hidden) {
438  return (int)_hidden - (int)other._hidden;
439  }
440  if (_flat_shaded != other._flat_shaded) {
441  return (int)_flat_shaded - (int)other._flat_shaded;
442  }
443  if (_primitive_type != other._primitive_type) {
444  return (int)_primitive_type - (int)other._primitive_type;
445  }
446 
447  if (_bake_in_uvs.size() != other._bake_in_uvs.size()) {
448  return (int)_bake_in_uvs.size() - (int)other._bake_in_uvs.size();
449  }
450 
451  BakeInUVs::const_iterator ai, bi;
452  ai = _bake_in_uvs.begin();
453  bi = other._bake_in_uvs.begin();
454  while (ai != _bake_in_uvs.end()) {
455  nassertr(bi != other._bake_in_uvs.end(), false);
456  if ((*ai).first != (*bi).first) {
457  return (*ai).first < (*bi).first ? -1 : 1;
458  }
459  if ((*ai).second != (*bi).second) {
460  return (*ai).second < (*bi).second ? -1 : 1;
461  }
462  ++ai;
463  ++bi;
464  }
465  nassertr(bi == other._bake_in_uvs.end(), false);
466 
467  return 0;
468 }
469 
470 /**
471  * Returns a RenderAttrib suitable for enabling the material indicated by the
472  * given EggMaterial, and with the indicated backface flag.
473  */
474 CPT(RenderAttrib) EggRenderState::
475 get_material_attrib(const EggMaterial *egg_mat, bool bface) {
476  Materials &materials =
477  bface ? _loader._materials_bface : _loader._materials;
478 
479  // First, check whether we've seen this material before.
480  Materials::const_iterator mi;
481  mi = materials.find(egg_mat);
482  if (mi != materials.end()) {
483  return (*mi).second;
484  }
485 
486  // Ok, this is the first time we've seen this particular EggMaterial.
487  // Create a new Material that matches it.
488  PT(Material) mat = new Material(egg_mat->get_name());
489  if (egg_mat->has_base()) {
490  mat->set_base_color(egg_mat->get_base());
491  }
492  if (egg_mat->has_diff()) {
493  mat->set_diffuse(egg_mat->get_diff());
494  // By default, ambient is the same as diffuse, if diffuse is specified but
495  // ambient is not.
496  mat->set_ambient(egg_mat->get_diff());
497  }
498  if (egg_mat->has_amb()) {
499  mat->set_ambient(egg_mat->get_amb());
500  }
501  if (egg_mat->has_emit()) {
502  mat->set_emission(egg_mat->get_emit());
503  }
504  if (egg_mat->has_spec()) {
505  mat->set_specular(egg_mat->get_spec());
506  }
507  if (egg_mat->has_shininess()) {
508  mat->set_shininess(egg_mat->get_shininess());
509  }
510  if (egg_mat->has_roughness()) {
511  mat->set_roughness(egg_mat->get_roughness());
512  }
513  if (egg_mat->has_metallic()) {
514  mat->set_metallic(egg_mat->get_metallic());
515  }
516  if (egg_mat->has_ior()) {
517  mat->set_refractive_index(egg_mat->get_ior());
518  }
519  if (egg_mat->has_local()) {
520  mat->set_local(egg_mat->get_local());
521  }
522 
523  mat->set_twoside(bface);
524 
525  // Now get a global Material pointer, shared with other models.
526  Material *shared_mat = MaterialPool::get_material(mat);
527 
528  // And create a MaterialAttrib for this Material.
529  CPT(RenderAttrib) mt = MaterialAttrib::make(shared_mat);
530  materials.insert(Materials::value_type(egg_mat, mt));
531 
532  return mt;
533 }
534 
535 /**
536  * Extracts the tex_gen from the given egg texture, and returns its
537  * corresponding TexGenAttrib mode.
538  */
539 TexGenAttrib::Mode EggRenderState::
540 get_tex_gen(const EggTexture *egg_tex) {
541  switch (egg_tex->get_tex_gen()) {
542  case EggTexture::TG_unspecified:
543  return TexGenAttrib::M_off;
544 
545  case EggTexture::TG_eye_sphere_map:
546  return TexGenAttrib::M_eye_sphere_map;
547 
548  case EggTexture::TG_world_cube_map:
549  return TexGenAttrib::M_world_cube_map;
550 
551  case EggTexture::TG_eye_cube_map:
552  return TexGenAttrib::M_eye_cube_map;
553 
554  case EggTexture::TG_world_normal:
555  return TexGenAttrib::M_world_normal;
556 
557  case EggTexture::TG_eye_normal:
558  return TexGenAttrib::M_eye_normal;
559 
560  case EggTexture::TG_world_position:
561  return TexGenAttrib::M_world_position;
562 
563  case EggTexture::TG_eye_position:
564  return TexGenAttrib::M_eye_position;
565 
566  case EggTexture::TG_point_sprite:
567  return TexGenAttrib::M_point_sprite;
568  };
569 
570  return TexGenAttrib::M_off;
571 }
572 
573 /**
574  * Applies the texture matrix from the indicated egg texture to the given
575  * TexMatrixAttrib, and returns the new attrib.
576  */
577 CPT(RenderAttrib) EggRenderState::
578 apply_tex_mat(CPT(RenderAttrib) tex_mat_attrib,
579  TextureStage *stage, const EggTexture *egg_tex) {
580  if (egg_tex->has_transform()) {
581  CPT(TransformState) transform = _loader.make_transform(egg_tex);
582 
583  if (tex_mat_attrib == nullptr) {
584  tex_mat_attrib = TexMatrixAttrib::make();
585  }
586  tex_mat_attrib = DCAST(TexMatrixAttrib, tex_mat_attrib)->
587  add_stage(stage, transform);
588  }
589 
590  return tex_mat_attrib;
591 }
A base class for any of a number of kinds of geometry primitives: polygons, point lights,...
Definition: eggPrimitive.h:47
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
get_material
Returns a pointer to the applied material, or NULL if there is no material applied.
Definition: eggPrimitive.h:115
AlphaMode get_alpha_mode() const
Returns the alpha mode that was set, or AM_unspecified if nothing was set.
Definition: eggRenderMode.I:98
VisibilityMode get_visibility_mode() const
Returns the visibility mode that was set, or VM_unspecified if nothing was set.
Definition: eggRenderMode.I:75
static Material * get_material(Material *temp)
Returns a Material pointer that represents the same material described by temp, except that it is a s...
Definition: materialPool.I:31
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is our own Panda specialization on the default STL map.
Definition: pmap.h:49
Indicates a coordinate-system transform on vertices.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual EggRenderMode * determine_bin()
Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or some such object at this leve...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A line segment, or a series of connected line segments, defined by a <Line> entry.
Definition: eggLine.h:25
This is the base class for a number of render attributes (other than transform) that may be set on sc...
Definition: renderAttrib.h:51
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
std::string get_bin() const
Returns the bin name that has been set for this particular object, if any.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
int get_draw_order() const
Returns the "draw-order" flag as set for this particular object.
Defines a texture map that may be applied to geometry.
Definition: eggTexture.h:30
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
Definition: texture.h:71
double get_thick() const
Returns the thickness set on this particular point.
Definition: eggPoint.I:60
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual EggRenderMode * determine_alpha_mode()
Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or some such object at this leve...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
LColor get_color() const
Returns the color set on this particular attribute.
Definition: eggAttributes.I:91
A single point, or a collection of points as defined by a single <PointLight> entry.
Definition: eggPoint.h:25
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
DepthWriteMode get_depth_write_mode() const
Returns the depth_write mode that was set, or DWM_unspecified if nothing was set.
Definition: eggRenderMode.I:36
void fill_state(EggPrimitive *egg_prim)
Sets up the state as appropriate for the indicated primitive.
Indicates the set of TextureStages and their associated Textures that should be applied to (or remove...
Definition: textureAttrib.h:31
get_connected_shading
Determines what sort of shading properties this primitive's connected neighbors have.
Definition: eggPrimitive.h:112
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is our own Panda specialization on the default STL vector.
Definition: pvector.h:42
This class is used within this package only to record the render state that should be assigned to eac...
get_format
Returns the format of the texture, which represents both the semantic meaning of the texels and,...
Definition: texture.h:362
This class stores miscellaneous rendering properties that is associated with geometry,...
Definition: eggRenderMode.h:31
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual EggRenderMode * determine_depth_test_mode()
Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or some such object at this leve...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
CPT(RenderAttrib) EggRenderState
Returns a RenderAttrib suitable for enabling the material indicated by the given EggMaterial,...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
static bool has_alpha(Format format)
Returns true if the indicated format includes alpha, false otherwise.
Definition: texture.cxx:2573
void add_attrib(const RenderAttrib *attrib)
A convenience function to add the indicated render attribute to the aggregate state.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool get_perspective() const
Returns the perspective flag set on this particular point.
Definition: eggPoint.I:95
get_num_components
Returns the number of color components for each texel of the texture image.
Definition: texture.h:355
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Texture * get_texture() const
If the TextureAttrib is not an 'off' TextureAttrib, returns the base-level texture that is associated...
Definition: textureAttrib.I:61
virtual EggRenderMode * determine_depth_offset()
Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or some such object at this leve...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
get_spec
It is legal to call this even if has_spec() returns false.
Definition: eggMaterial.h:96
Defines the way an object appears in the presence of lighting.
Definition: material.h:43
Encodes a string name in a hash table, mapping it to a pointer.
Definition: internalName.h:38
get_num_textures
Returns the number of textures applied to the primitive.
Definition: eggPrimitive.h:100
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual EggRenderMode * determine_draw_order()
Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or some such object at this leve...
Applies a transform matrix to UV's before they are rendered.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
get_emit
It is legal to call this even if has_emit() returns false.
Definition: eggMaterial.h:95
get_texture
Returns the first texture on the primitive, if any, or NULL if there are no textures on the primitive...
Definition: eggPrimitive.h:100
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
double get_thick() const
Returns the thickness set on this particular line.
Definition: eggLine.I:59
bool is_of_type(TypeHandle handle) const
Returns true if the current object is or derives from the indicated type.
Definition: typedObject.I:28
virtual EggRenderMode * determine_visibility_mode()
Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or some such object at this leve...
get_bface_flag
Retrieves the backfacing flag of the polygon.
Definition: eggPrimitive.h:116
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
get_base
It is legal to call this even if has_base() returns false.
Definition: eggMaterial.h:92
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Defines the properties of a named stage of the multitexture pipeline.
Definition: textureStage.h:35
static bool has_binary_alpha(Format format)
Returns true if the indicated format includes a binary alpha only, false otherwise.
Definition: texture.cxx:2602
Computes texture coordinates for geometry automatically based on vertex position and/or normal.
Definition: texGenAttrib.h:32
int get_depth_offset() const
Returns the "depth-offset" flag as set for this particular object.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
get_diff
It is legal to call this even if has_diff() returns false.
Definition: eggMaterial.h:93
DepthTestMode get_depth_test_mode() const
Returns the depth_test mode that was set, or DTM_unspecified if nothing was set.
Definition: eggRenderMode.I:55
virtual EggRenderMode * determine_depth_write_mode()
Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or some such object at this leve...
get_amb
It is legal to call this even if has_amb() returns false.
Definition: eggMaterial.h:94
has_material
Returns true if the primitive is materiald (and get_material() will return a real pointer),...
Definition: eggPrimitive.h:115
int compare_to(const EggRenderState &other) const
Provides a unique ordering for different EggRenderState objects, so that primitives of similar state ...
bool has_transform() const
Returns true if the transform is nonempty, false if it is empty (no transform components have been ad...
Definition: eggTransform.I:143