Panda3D
shaderAttrib.I
1 // Filename: shaderAttrib.I
2 // Created by: sshodhan (10Jul04)
3 // Updated by: weifengh, PandaSE(15Apr10)
4 //
5 ////////////////////////////////////////////////////////////////////
6 //
7 // PANDA 3D SOFTWARE
8 // Copyright (c) Carnegie Mellon University. All rights reserved.
9 //
10 // All use of this software is subject to the terms of the revised BSD
11 // license. You should have received a copy of this license along
12 // with this source code in a file named "LICENSE."
13 //
14 ////////////////////////////////////////////////////////////////////
15 
16 
17 ////////////////////////////////////////////////////////////////////
18 // Function: ShaderAttrib::Constructor
19 // Access: Private
20 // Description:
21 ////////////////////////////////////////////////////////////////////
22 INLINE ShaderAttrib::
23 ShaderAttrib() :
24  _shader(NULL),
25  _shader_priority(0),
26  _auto_shader(false),
27  _has_shader(false),
28  _flags(0),
29  _has_flags(0),
30  _instance_count(0),
31  _auto_normal_on(false),
32  _auto_glow_on(false),
33  _auto_gloss_on(false),
34  _auto_ramp_on(false),
35  _auto_shadow_on(false)
36 {
37 }
38 
39 ////////////////////////////////////////////////////////////////////
40 // Function: ShaderAttrib::Copy Constructor
41 // Access: Private
42 // Description:
43 ////////////////////////////////////////////////////////////////////
44 INLINE ShaderAttrib::
45 ShaderAttrib(const ShaderAttrib &copy) :
46  _shader(copy._shader),
47  _shader_priority(copy._shader_priority),
48  _auto_shader(copy._auto_shader),
49  _has_shader(copy._has_shader),
50  _flags(copy._flags),
51  _has_flags(copy._has_flags),
52  _instance_count(copy._instance_count),
53  _auto_normal_on(copy._auto_normal_on),
54  _auto_glow_on(copy._auto_glow_on),
55  _auto_gloss_on(copy._auto_gloss_on),
56  _auto_ramp_on(copy._auto_ramp_on),
57  _auto_shadow_on(copy._auto_shadow_on),
58  _inputs(copy._inputs)
59 {
60 }
61 
62 ////////////////////////////////////////////////////////////////////
63 // Function: ShaderAttrib::has_shader
64 // Access: Published
65 // Description: If true, the shader field of this attribute overrides
66 // the shader field of the parent attribute.
67 ////////////////////////////////////////////////////////////////////
68 INLINE bool ShaderAttrib::
69 has_shader() const {
70  return _has_shader;
71 }
72 
73 ////////////////////////////////////////////////////////////////////
74 // Function: ShaderAttrib::auto_shader
75 // Access: Published
76 // Description: If true, then this ShaderAttrib does not contain an
77 // explicit shader - instead, it requests the automatic
78 // generation of a shader.
79 ////////////////////////////////////////////////////////////////////
80 INLINE bool ShaderAttrib::
81 auto_shader() const {
82  return _auto_shader;
83 }
84 
85 ////////////////////////////////////////////////////////////////////
86 // Function: ShaderAttrib::get_shader_priority
87 // Access: Published
88 // Description:
89 ////////////////////////////////////////////////////////////////////
90 INLINE int ShaderAttrib::
91 get_shader_priority() const {
92  return _shader_priority;
93 }
94 
95 ////////////////////////////////////////////////////////////////////
96 // Function: ShaderAttrib::get_instance_count
97 // Access: Published
98 // Description: Returns the number of geometry instances. A value
99 // of 0 means not to use instancing at all.
100 ////////////////////////////////////////////////////////////////////
101 INLINE int ShaderAttrib::
103  return _instance_count;
104 }
105 
106 ////////////////////////////////////////////////////////////////////
107 // Function: ShaderAttrib::get_flag
108 // Access: Published
109 // Description:
110 ////////////////////////////////////////////////////////////////////
111 INLINE bool ShaderAttrib::
112 get_flag(int index) const {
113  return (_flags & (1<<index)) ? true:false;
114 }
115 
116 ////////////////////////////////////////////////////////////////////
117 // Function: ShaderAttrib::has_shader_input
118 // Access: Published
119 // Description: Returns true if there is a ShaderInput of the given
120 // name.
121 ////////////////////////////////////////////////////////////////////
122 bool ShaderAttrib::
124  return (_inputs.find(id) != _inputs.end());
125 }
126 
127 ////////////////////////////////////////////////////////////////////
128 // Function: ShaderAttrib::set_shader_input
129 // Access: Published
130 // Description:
131 ////////////////////////////////////////////////////////////////////
132 INLINE CPT(RenderAttrib) ShaderAttrib::
133 set_shader_input(CPT_InternalName id, const PTA_float &v, int priority) const {
134  return set_shader_input(new ShaderInput(MOVE(id), v, priority));
135 }
136 
137 ////////////////////////////////////////////////////////////////////
138 // Function: ShaderAttrib::set_shader_input
139 // Access: Published
140 // Description:
141 ////////////////////////////////////////////////////////////////////
142 INLINE CPT(RenderAttrib) ShaderAttrib::
143 set_shader_input(CPT_InternalName id, const PTA_double &v, int priority) const {
144  return set_shader_input(new ShaderInput(MOVE(id), v, priority));
145 }
146 
147 ////////////////////////////////////////////////////////////////////
148 // Function: ShaderAttrib::set_shader_input
149 // Access: Published
150 // Description:
151 ////////////////////////////////////////////////////////////////////
152 INLINE CPT(RenderAttrib) ShaderAttrib::
153 set_shader_input(CPT_InternalName id, const PTA_LVecBase4 &v, int priority) const {
154  return set_shader_input(new ShaderInput(MOVE(id), v, priority));
155 }
156 
157 ////////////////////////////////////////////////////////////////////
158 // Function: ShaderAttrib::set_shader_input
159 // Access: Published
160 // Description:
161 ////////////////////////////////////////////////////////////////////
162 INLINE CPT(RenderAttrib) ShaderAttrib::
163 set_shader_input(CPT_InternalName id, const PTA_LVecBase3 &v, int priority) const {
164  return set_shader_input(new ShaderInput(MOVE(id), v, priority));
165 }
166 
167 
168 ////////////////////////////////////////////////////////////////////
169 // Function: ShaderAttrib::set_shader_input
170 // Access: Published
171 // Description:
172 ////////////////////////////////////////////////////////////////////
173 INLINE CPT(RenderAttrib) ShaderAttrib::
174 set_shader_input(CPT_InternalName id, const PTA_LVecBase2 &v, int priority) const {
175  return set_shader_input(new ShaderInput(MOVE(id), v, priority));
176 }
177 
178 ////////////////////////////////////////////////////////////////////
179 // Function: ShaderAttrib::set_shader_input
180 // Access: Published
181 // Description:
182 ////////////////////////////////////////////////////////////////////
183 INLINE CPT(RenderAttrib) ShaderAttrib::
184 set_shader_input(CPT_InternalName id, const LVecBase4 &v, int priority) const {
185  return set_shader_input(new ShaderInput(MOVE(id), v, priority));
186 }
187 
188 ////////////////////////////////////////////////////////////////////
189 // Function: ShaderAttrib::set_shader_input
190 // Access: Published
191 // Description:
192 ////////////////////////////////////////////////////////////////////
193 INLINE CPT(RenderAttrib) ShaderAttrib::
194 set_shader_input(CPT_InternalName id, const LVecBase3 &v, int priority) const {
195  return set_shader_input(new ShaderInput(MOVE(id), v, priority));
196 }
197 
198 ////////////////////////////////////////////////////////////////////
199 // Function: ShaderAttrib::set_shader_input
200 // Access: Published
201 // Description:
202 ////////////////////////////////////////////////////////////////////
203 INLINE CPT(RenderAttrib) ShaderAttrib::
204 set_shader_input(CPT_InternalName id, const LVecBase2 &v, int priority) const {
205  return set_shader_input(new ShaderInput(MOVE(id), v, priority));
206 }
207 
208 ////////////////////////////////////////////////////////////////////
209 // Function: ShaderAttrib::set_shader_input
210 // Access: Published
211 // Description:
212 ////////////////////////////////////////////////////////////////////
213 INLINE CPT(RenderAttrib) ShaderAttrib::
214 set_shader_input(CPT_InternalName id, const PTA_LMatrix4 &v, int priority) const {
215  return set_shader_input(new ShaderInput(MOVE(id), v, priority));
216 }
217 
218 ////////////////////////////////////////////////////////////////////
219 // Function: ShaderAttrib::set_shader_input
220 // Access: Published
221 // Description:
222 ////////////////////////////////////////////////////////////////////
223 INLINE CPT(RenderAttrib) ShaderAttrib::
224 set_shader_input(CPT_InternalName id, const PTA_LMatrix3 &v, int priority) const {
225  return set_shader_input(new ShaderInput(MOVE(id), v, priority));
226 }
227 
228 ////////////////////////////////////////////////////////////////////
229 // Function: ShaderAttrib::set_shader_input
230 // Access: Published
231 // Description:
232 ////////////////////////////////////////////////////////////////////
233 INLINE CPT(RenderAttrib) ShaderAttrib::
234 set_shader_input(CPT_InternalName id, const LMatrix4 &v, int priority) const {
235  return set_shader_input(new ShaderInput(MOVE(id), v, priority));
236 }
237 
238 ////////////////////////////////////////////////////////////////////
239 // Function: ShaderAttrib::set_shader_input
240 // Access: Published
241 // Description:
242 ////////////////////////////////////////////////////////////////////
243 INLINE CPT(RenderAttrib) ShaderAttrib::
244 set_shader_input(CPT_InternalName id, const LMatrix3 &v, int priority) const {
245  return set_shader_input(new ShaderInput(MOVE(id), v, priority));
246 }
247 
248 ////////////////////////////////////////////////////////////////////
249 // Function: ShaderAttrib::set_shader_input
250 // Access: Published
251 // Description:
252 ////////////////////////////////////////////////////////////////////
253 INLINE CPT(RenderAttrib) ShaderAttrib::
254 set_shader_input(CPT_InternalName id, Texture *tex, int priority) const {
255  return set_shader_input(new ShaderInput(MOVE(id), tex, priority));
256 }
257 
258 ////////////////////////////////////////////////////////////////////
259 // Function: ShaderAttrib::set_shader_input
260 // Access: Published
261 // Description:
262 ////////////////////////////////////////////////////////////////////
263 INLINE CPT(RenderAttrib) ShaderAttrib::
264 set_shader_input(CPT_InternalName id, const NodePath &np, int priority) const {
265  return set_shader_input(new ShaderInput(MOVE(id), np, priority));
266 }
267 
268 ////////////////////////////////////////////////////////////////////
269 // Function: ShaderAttrib::set_shader_input
270 // Access: Published
271 // Description:
272 ////////////////////////////////////////////////////////////////////
273 INLINE CPT(RenderAttrib) ShaderAttrib::
274 set_shader_input(CPT_InternalName id, double n1, double n2, double n3, double n4, int priority) const {
275  return set_shader_input(new ShaderInput(MOVE(id), LVecBase4(n1, n2, n3, n4), priority));
276 }
277 
278 //weifengh
279 ////////////////////////////////////////////////////////////////////
280 // Function: ShaderAttrib::auto_normal_on
281 // Access: Published
282 // Description:
283 ////////////////////////////////////////////////////////////////////
284 INLINE bool ShaderAttrib::
285 auto_normal_on() const {
286  return _auto_normal_on;
287 }
288 
289 ////////////////////////////////////////////////////////////////////
290 // Function: ShaderAttrib::auto_glow_on
291 // Access: Published
292 // Description:
293 ////////////////////////////////////////////////////////////////////
294 INLINE bool ShaderAttrib::
295 auto_glow_on() const {
296  return _auto_glow_on;
297 }
298 
299 ////////////////////////////////////////////////////////////////////
300 // Function: ShaderAttrib::auto_gloss_on
301 // Access: Published
302 // Description:
303 ////////////////////////////////////////////////////////////////////
304 INLINE bool ShaderAttrib::
305 auto_gloss_on() const {
306  return _auto_gloss_on;
307 }
308 
309 ////////////////////////////////////////////////////////////////////
310 // Function: ShaderAttrib::auto_ramp_on
311 // Access: Published
312 // Description:
313 ////////////////////////////////////////////////////////////////////
314 INLINE bool ShaderAttrib::
315 auto_ramp_on() const {
316  return _auto_ramp_on;
317 }
318 
319 ////////////////////////////////////////////////////////////////////
320 // Function: ShaderAttrib::auto_shadow_on
321 // Access: Published
322 // Description:
323 ////////////////////////////////////////////////////////////////////
324 INLINE bool ShaderAttrib::
325 auto_shadow_on() const {
326  return _auto_shadow_on;
327 }
This is the base class for all three-component vectors and points.
Definition: lvecBase3.h:105
This is a const pointer to an InternalName, and should be used in lieu of a CPT(InternalName) in func...
Definition: internalName.h:197
bool auto_shader() const
If true, then this ShaderAttrib does not contain an explicit shader - instead, it requests the automa...
Definition: shaderAttrib.I:81
This is the base class for a number of render attributes (other than transform) that may be set on sc...
Definition: renderAttrib.h:60
int get_instance_count() const
Returns the number of geometry instances.
Definition: shaderAttrib.I:102
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
Definition: texture.h:75
This is a small container class that can hold any one of the value types that can be passed as input ...
Definition: shaderInput.h:41
bool has_shader_input(CPT_InternalName id) const
Returns true if there is a ShaderInput of the given name.
Definition: shaderAttrib.I:123
This is a 4-by-4 transform matrix.
Definition: lmatrix.h:451
This is the base class for all two-component vectors and points.
Definition: lvecBase2.h:105
bool has_shader() const
If true, the shader field of this attribute overrides the shader field of the parent attribute...
Definition: shaderAttrib.I:69
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:111
This is a 3-by-3 transform matrix.
Definition: lmatrix.h:110
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:165