Panda3D
colorBlendAttrib.I
1 // Filename: colorBlendAttrib.I
2 // Created by: drose (29Mar02)
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: ColorBlendAttrib::Constructor
18 // Access: Private
19 // Description: Use ColorBlendAttrib::make() to construct a new
20 // ColorBlendAttrib object.
21 ////////////////////////////////////////////////////////////////////
22 INLINE ColorBlendAttrib::
23 ColorBlendAttrib() :
24  _mode(M_none),
25  _a(O_one),
26  _b(O_one),
27  _color(LColor::zero()),
28  _involves_constant_color(false),
29  _involves_color_scale(false)
30 {
31 }
32 
33 ////////////////////////////////////////////////////////////////////
34 // Function: ColorBlendAttrib::Constructor
35 // Access: Private
36 // Description: Use ColorBlendAttrib::make() to construct a new
37 // ColorBlendAttrib object.
38 ////////////////////////////////////////////////////////////////////
39 INLINE ColorBlendAttrib::
40 ColorBlendAttrib(ColorBlendAttrib::Mode mode,
41  ColorBlendAttrib::Operand a, ColorBlendAttrib::Operand b,
42  const LColor &color) :
43  _mode(mode),
44  _a(a),
45  _b(b),
46  _color(color),
47  _involves_constant_color(involves_constant_color(a) || involves_constant_color(b)),
48  _involves_color_scale(involves_color_scale(a) || involves_color_scale(b))
49 {
50 }
51 
52 ////////////////////////////////////////////////////////////////////
53 // Function: ColorBlendAttrib::get_mode
54 // Access: Published
55 // Description: Returns the colorBlend mode.
56 ////////////////////////////////////////////////////////////////////
57 INLINE ColorBlendAttrib::Mode ColorBlendAttrib::
58 get_mode() const {
59  return _mode;
60 }
61 
62 ////////////////////////////////////////////////////////////////////
63 // Function: ColorBlendAttrib::get_operand_a
64 // Access: Published
65 // Description: Returns the multiplier for the first component.
66 ////////////////////////////////////////////////////////////////////
67 INLINE ColorBlendAttrib::Operand ColorBlendAttrib::
68 get_operand_a() const {
69  return _a;
70 }
71 
72 ////////////////////////////////////////////////////////////////////
73 // Function: ColorBlendAttrib::get_operand_b
74 // Access: Published
75 // Description: Returns the multiplier for the second component.
76 ////////////////////////////////////////////////////////////////////
77 INLINE ColorBlendAttrib::Operand ColorBlendAttrib::
78 get_operand_b() const {
79  return _b;
80 }
81 
82 ////////////////////////////////////////////////////////////////////
83 // Function: ColorBlendAttrib::get_color
84 // Access: Published
85 // Description: Returns the constant color associated with the attrib.
86 ////////////////////////////////////////////////////////////////////
88 get_color() const {
89  return _color;
90 }
91 
92 ////////////////////////////////////////////////////////////////////
93 // Function: ColorBlendAttrib::involves_constant_color
94 // Access: Published
95 // Description: Returns true if the this attrib uses the
96 // constant color, false otherwise.
97 ////////////////////////////////////////////////////////////////////
98 INLINE bool ColorBlendAttrib::
100  return _involves_constant_color;
101 }
102 
103 ////////////////////////////////////////////////////////////////////
104 // Function: ColorBlendAttrib::involves_color_scale
105 // Access: Published
106 // Description: Returns true if the this attrib uses the
107 // color scale attrib, false otherwise.
108 ////////////////////////////////////////////////////////////////////
109 INLINE bool ColorBlendAttrib::
111  return _involves_color_scale;
112 }
113 
114 ////////////////////////////////////////////////////////////////////
115 // Function: ColorBlendAttrib::involves_constant_color
116 // Access: Published, Static
117 // Description: Returns true if the indicated operand uses the
118 // constant color, false otherwise.
119 ////////////////////////////////////////////////////////////////////
120 INLINE bool ColorBlendAttrib::
121 involves_constant_color(ColorBlendAttrib::Operand operand) {
122  switch (operand) {
123  case O_constant_color:
124  case O_one_minus_constant_color:
125  case O_constant_alpha:
126  case O_one_minus_constant_alpha:
127  return true;
128 
129  default:
130  return false;
131  }
132 }
133 
134 ////////////////////////////////////////////////////////////////////
135 // Function: ColorBlendAttrib::involves_color_scale
136 // Access: Published, Static
137 // Description: Returns true if the indicated operand uses the
138 // color scale attrib, false otherwise.
139 ////////////////////////////////////////////////////////////////////
140 INLINE bool ColorBlendAttrib::
141 involves_color_scale(ColorBlendAttrib::Operand operand) {
142  switch (operand) {
143  case O_color_scale:
144  case O_one_minus_color_scale:
145  case O_alpha_scale:
146  case O_one_minus_alpha_scale:
147  return true;
148 
149  default:
150  return false;
151  }
152 }
Mode get_mode() const
Returns the colorBlend mode.
bool involves_color_scale() const
Returns true if the this attrib uses the color scale attrib, false otherwise.
Operand get_operand_a() const
Returns the multiplier for the first component.
LColor get_color() const
Returns the constant color associated with the attrib.
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:111
Operand get_operand_b() const
Returns the multiplier for the second component.
bool involves_constant_color() const
Returns true if the this attrib uses the constant color, false otherwise.