Panda3D
Loading...
Searching...
No Matches
renderModeAttrib.I
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 renderModeAttrib.I
10 * @author drose
11 * @date 2002-03-14
12 */
13
14/**
15 * Use RenderModeAttrib::make() to construct a new RenderModeAttrib object.
16 */
17INLINE RenderModeAttrib::
18RenderModeAttrib(RenderModeAttrib::Mode mode, PN_stdfloat thickness,
19 bool perspective, const LColor &wireframe_color) :
20 _mode(mode),
21 _thickness(thickness),
22 _perspective(perspective),
23 _wireframe_color(wireframe_color)
24{
25}
26
27/**
28 * Returns the render mode.
29 */
30INLINE RenderModeAttrib::Mode RenderModeAttrib::
31get_mode() const {
32 return _mode;
33}
34
35/**
36 * Returns the line width or point thickness. This is only relevant when
37 * rendering points or lines, such as when the mode is M_wireframe or M_point
38 * (or when rendering actual points or lines primitives in M_polygon mode).
39 */
40INLINE PN_stdfloat RenderModeAttrib::
41get_thickness() const {
42 return _thickness;
43}
44
45/**
46 * Returns the perspective flag. When this is true, the point thickness
47 * represented by get_thickness() is actually a width in 3-d units, and the
48 * points should scale according to perspective. When it is false, the
49 * default, the point thickness is actually a width in pixels, and points are
50 * a uniform size regardless of distance from the camera.
51 */
52INLINE bool RenderModeAttrib::
53get_perspective() const {
54 return _perspective;
55}
56
57/**
58 * Returns the color that is used in M_filled_wireframe mode to distinguish
59 * the wireframe from the rest of the geometry.
60 */
61INLINE const LColor &RenderModeAttrib::
62get_wireframe_color() const {
63 return _wireframe_color;
64}
65
66/**
67 * Returns the union of the Geom::GeomRendering bits that will be required
68 * once this RenderModeAttrib is applied to a geom which includes the
69 * indicated geom_rendering bits.
70 */
72get_geom_rendering(int geom_rendering) const {
73 if (_mode == M_point) {
74 geom_rendering |= Geom::GR_point | Geom::GR_render_mode_point;
75
76 } else if (_mode == M_wireframe) {
77 geom_rendering |= Geom::GR_render_mode_wireframe;
78 }
79
80 if ((geom_rendering & Geom::GR_point) != 0) {
81 if (_perspective) {
82 geom_rendering |= (Geom::GR_point_perspective | Geom::GR_point_uniform_size);
83 } else if (_thickness != 1.0f) {
84 geom_rendering |= Geom::GR_point_uniform_size;
85 }
86 }
87
88 return geom_rendering;
89}
get_perspective
Returns the perspective flag.
get_thickness
Returns the line width or point thickness.
int get_geom_rendering(int geom_rendering) const
Returns the union of the Geom::GeomRendering bits that will be required once this RenderModeAttrib is...
get_wireframe_color
Returns the color that is used in M_filled_wireframe mode to distinguish the wireframe from the rest ...
get_mode
Returns the render mode.