Panda3D
 All Classes Functions Variables Enumerations
renderModeAttrib.I
1 // Filename: renderModeAttrib.I
2 // Created by: drose (14Mar02)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: RenderModeAttrib::Constructor
18 // Access: Private
19 // Description: Use RenderModeAttrib::make() to construct a new
20 // RenderModeAttrib object.
21 ////////////////////////////////////////////////////////////////////
22 INLINE RenderModeAttrib::
23 RenderModeAttrib(RenderModeAttrib::Mode mode, PN_stdfloat thickness,
24  bool perspective, const LColor &wireframe_color) :
25  _mode(mode),
26  _thickness(thickness),
27  _perspective(perspective),
28  _wireframe_color(wireframe_color)
29 {
30 }
31 
32 ////////////////////////////////////////////////////////////////////
33 // Function: RenderModeAttrib::get_mode
34 // Access: Published
35 // Description: Returns the render mode.
36 ////////////////////////////////////////////////////////////////////
37 INLINE RenderModeAttrib::Mode RenderModeAttrib::
38 get_mode() const {
39  return _mode;
40 }
41 
42 ////////////////////////////////////////////////////////////////////
43 // Function: RenderModeAttrib::get_thickness
44 // Access: Published
45 // Description: Returns the line width or point thickness. This is
46 // only relevant when rendering points or lines, such as
47 // when the mode is M_wireframe or M_point (or when
48 // rendering actual points or lines primitives in
49 // M_polygon mode).
50 ////////////////////////////////////////////////////////////////////
51 INLINE PN_stdfloat RenderModeAttrib::
52 get_thickness() const {
53  return _thickness;
54 }
55 
56 ////////////////////////////////////////////////////////////////////
57 // Function: RenderModeAttrib::get_perspective
58 // Access: Published
59 // Description: Returns the perspective flag. When this is true, the
60 // point thickness represented by get_thickness() is
61 // actually a width in 3-d units, and the points should
62 // scale according to perspective. When it is false,
63 // the default, the point thickness is actually a width
64 // in pixels, and points are a uniform size regardless
65 // of distance from the camera.
66 ////////////////////////////////////////////////////////////////////
67 INLINE bool RenderModeAttrib::
68 get_perspective() const {
69  return _perspective;
70 }
71 
72 ////////////////////////////////////////////////////////////////////
73 // Function: RenderModeAttrib::get_wireframe_color
74 // Access: Published
75 // Description: Returns the color that is used in M_filled_wireframe
76 // mode to distinguish the wireframe from the rest of
77 // the geometry.
78 ////////////////////////////////////////////////////////////////////
79 INLINE const LColor &RenderModeAttrib::
81  return _wireframe_color;
82 }
83 
84 ////////////////////////////////////////////////////////////////////
85 // Function: RenderModeAttrib::get_geom_rendering
86 // Access: Published
87 // Description: Returns the union of the Geom::GeomRendering bits
88 // that will be required once this RenderModeAttrib is
89 // applied to a geom which includes the indicated
90 // geom_rendering bits.
91 ////////////////////////////////////////////////////////////////////
92 INLINE int RenderModeAttrib::
93 get_geom_rendering(int geom_rendering) const {
94  if (_mode == M_point) {
95  geom_rendering |= Geom::GR_point;
96  }
97  if ((geom_rendering & Geom::GR_point) != 0) {
98  if (_perspective) {
99  geom_rendering |= (Geom::GR_point_perspective | Geom::GR_point_uniform_size);
100  } else if (_thickness != 1.0f) {
101  geom_rendering |= Geom::GR_point_uniform_size;
102  }
103  }
104 
105  return geom_rendering;
106 }
int get_geom_rendering(int geom_rendering) const
Returns the union of the Geom::GeomRendering bits that will be required once this RenderModeAttrib is...
bool get_perspective() const
Returns the perspective flag.
const LColor & get_wireframe_color() const
Returns the color that is used in M_filled_wireframe mode to distinguish the wireframe from the rest ...
Mode get_mode() const
Returns the render mode.
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:111
PN_stdfloat get_thickness() const
Returns the line width or point thickness.