C++ SDK Reference  12.5
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
diguyGraphicsMaterial.h
Go to the documentation of this file.
1 
2 /*
3  * Copyright (C) 1992-2013 Boston Dynamics
4  * ALL RIGHTS RESERVED.
5  *
6  * These coded instructions, statements, and computer programs
7  * contain unpublished proprietary information of Boston Dynamics
8  * and are protected by Copyright Laws of the United States.
9  * They may not be used, duplicated, or disclosed in any form, in
10  * whole or in part, without the prior written consent from Boston
11  * Dynamics.
12  *
13  * RESTRICTED RIGHTS LEGEND
14  * Use, duplication, or disclosure by the government is subject
15  * to restrictions as set forth in FAR 52.227.19(c)(2) or
16  * subparagraph (c)(1)(ii) of the Rights in Technical Data and
17  * Computer Software clause at DFARS 252.227-7013 and/or in
18  * similar or successor clauses in the FAR, or the DOD or NASA
19  * FAR Supplement, or to subparagraphs (c)(1) and (c)(2) of the
20  * Commercial Computer Software--Restricted Rights at 48 CFR
21  * 52.227-19, as applicable. Unpublished-rights reserved under
22  * the Copyright Laws of the United States.
23  * Contractor/Manufacturer is:
24  * Boston Dynamics/78 Fourth Avenue/Waltham MA 02451.
25  */
26 
27 /*********************************************************************/
34 #ifndef __diguyGraphicsMaterial_H
35 #define __diguyGraphicsMaterial_H
36 
37 #ifdef SWIG
39 #else
40 #define CPLUSPLUS_ONLY
41 #endif
42 
43 #ifdef CPLUSPLUS_ONLY
44 #include <diguy_constants.h>
45 #include <declspec_diguy.h>
46 
47 class bdiGeometryMtl;
49 
50 /****************************************************************************/
51 
52 #endif
53 
54 /****************************************************************************/
55 class BDI_DECLSPEC_diguy diguyGraphicsMaterial
56 {
57 
58 public:
59 
60 /*****************************************************************************/
69  /*l
70  *b Description:
71  **
72  ** Returns the name of the texture. This pointer will
73  ** never be NULL.
74  **
75  *b Returns:
76  **
77  ** name of the texture
78  **
79  *b Callable From:
80  **
81  *- - C++
82  *- - Script
83  */
84  const char* get_name();
85 
86 #ifdef CPLUSPLUS_ONLY
87 
88  /*l
89  *b Description:
90  **
91  ** This function returns the red, green, blue, and alpha
92  ** components of the material's ambient setting. All returned
93  ** values will be between 0 (least intensity) and 1 (highest
94  ** intensity).
95  **
96  *b Arguments:
97  **
98  *a rgba - pointer to an array of four floats into which results
99  *a should be copied
100  **
101  *b Callable From:
102  **
103  *- - C++
104  */
105  void get_ambient(float* rgba);
106 
107  /*l
108  *b Description:
109  **
110  ** This function returns the red, green, blue, and alpha
111  ** components of the material's diffuse setting. All returned
112  ** values will be between 0 (least intensity) and 1 (highest
113  ** intensity).
114  **
115  *b Arguments:
116  **
117  *a rgba - pointer to an array of four floats into which results
118  *a should be copied
119  **
120  *b Callable From:
121  **
122  *- - C++
123  */
124  void get_diffuse(float* rgba);
125 
126  /*l
127  *b Description:
128  **
129  ** This function returns the red, green, blue, and alpha
130  ** components of the material's specular setting. All returned
131  ** values will be between 0 (least intensity) and 1 (highest
132  ** intensity).
133  **
134  *b Arguments:
135  **
136  *a rgba - pointer to an array of four floats into which results
137  *a should be copied
138  **
139  *b Callable From:
140  **
141  *- - C++
142  */
143  void get_specular(float* rgba);
144 
145  /*l
146  *b Description:
147  **
148  ** This function returns the red, green, blue, and alpha
149  ** components of the material's emission setting. All returned
150  ** values will be between 0 (least intensity) and 1 (highest
151  ** intensity).
152  **
153  *b Arguments:
154  **
155  *a rgba - pointer to an array of four floats into which results
156  *a should be copied
157  **
158  *b Callable From:
159  **
160  *- - C++
161  */
162  void get_emission(float* rgba);
163 
164  /*l
165  *b Description:
166  **
167  ** This function returns the material's shininess setting.
168  **
169  *b Arguments:
170  **
171  *a s - pointer to float into which result should be copied
172  **
173  *b Callable From:
174  **
175  *- - C++
176  */
177  void get_shininess(float* s);
178 
179  /*l
180  *b Description:
181  **
182  ** This function returns whether the material contains an alpha
183  ** component. Materials that have an alpha component can make
184  ** objects semi-transparent, which can affect when said objects
185  ** should be drawn.
186  **
187  *b Returns:
188  **
189  ** 1 if texture contains an alpha component, 0 if not; -1 on failure
190  **
191  *b Callable From:
192  **
193  *- - C++
194  */
195  int get_contains_alpha_component();
196 
197  /*l
198  *b Description:
199  **
200  ** This function frees most memory allocated by the DI-Guy geometry
201  ** loader for this object.
202  **
203  ** This function should only be called during or after the object's
204  ** build() function has been called. After it has been called, calls
205  ** to many accessor functions will fail.
206  **
207  *b Callable From:
208  **
209  *- - C++
210  */
211  void free_loader_memory();
212 
213  /*l
214  *b Description:
215  **
216  ** This function returns the last material that was bound.
217  **
218  ** In bind_now() the current material can be checked against the last
219  ** bound material; if the values are the same the bind_now() function
220  ** can most often immediately return. This is desirable because
221  ** rendering state changes can have significant performance overhead.
222  **
223  *b Callable From:
224  **
225  *- - C++
226  */
227  static diguyGraphicsMaterial* get_last_bound_material();
228 
229  /*l
230  *b Description:
231  **
232  ** This function clears out the last bound material pointer.
233  **
234  ** diguyScenario::draw() calls it automatically, but it's recommended
235  ** that this function also be called when the drawing of a new
236  ** character is beginning. This can be done in
237  ** diguyGraphicsLink::begin_character_draw().
238  **
239  *b Callable From:
240  **
241  *- - C++
242  */
243  static void clear_last_bound_material();
244 
245 #endif
246 
247 
248 /*****************************************************************************/
260 #ifdef CPLUSPLUS_ONLY
261 
262  /*l
263  *b Description:
264  **
265  ** This function will be called by DI-Guy when it is time for a
266  ** renderer-specific material object to be created. At that point
267  ** all material information has been read and is available via the
268  ** Accessor Functions above.
269  **
270  *i Immediate Mode:
271  **
272  ** Immediate mode renderers may override this function, to
273  ** create an object that may be invoked by bind_now() to set
274  ** material attributes.
275  **
276  *i Scene Graph:
277  **
278  ** Scene graph renderers usually do override this function, to
279  ** create a material object that will be associated with
280  ** diguyGraphicsMesh objects.
281  **
282  *b Callable From:
283  **
284  *- - N/A (automatically called by DI-Guy Graphics API during
285  *- the Build Stage)
286  */
287  virtual void build();
288 
289  /*l
290  *b Description:
291  **
292  ** This function will be called by DI-Guy when it is time for a
293  ** renderer-specific material object to be destroyed.
294  **
295  *i Immediate Mode:
296  **
297  ** Immediate mode renderers may override this function, to
298  ** destroy any object that may have been created by build().
299  **
300  *i Scene Graph:
301  **
302  ** Scene graph renderers usually do override this function, to
303  ** destroy any object that may have been created by build().
304  **
305  *b Callable From:
306  **
307  *- - N/A (automatically called by DI-Guy Graphics API during
308  *- the Unbuild Stage)
309  */
310  virtual void unbuild();
311 
312  /*l
313  *b Description:
314  **
315  ** This function will be called by DI-Guy when the material should
316  ** be made active, or bound.
317  **
318  ** Note that this material should be checked against the material
319  ** returned by get_last_bound_material(). If they're the same this
320  ** function should return early.
321  **
322  *i Immediate Mode:
323  **
324  ** Immediate mode renderers usually do override this function, to
325  ** invoke the object created by build(), or make calls to the
326  ** renderer to set appropriate material state.
327  **
328  *i Scene Graph:
329  **
330  ** Scene graph renderers usually do not override this function.
331  **
332  *b Callable From:
333  **
334  *- - N/A (automatically called by DI-Guy Graphics API during
335  *- Draw Stage)
336  */
337  virtual void bind_now();
338 
339 #endif
341 
342 /****************************************************************************/
343 /****************************************************************************/
344 
349 #ifdef CPLUSPLUS_ONLY
350 
351  bdiGeometryMtl* get_scripted_object() {return m_scripted_object;}
352 
353 protected:
354 
355  /*l
356  ** A protected constructor. Constructors are called automatically
357  ** by DI-Guy.
358  */
359  diguyGraphicsMaterial(void* internal_data);
360 
361  /*l
362  ** A protected destructor. Destructors are called automatically
363  ** by DI-Guy.
364  */
365  virtual ~diguyGraphicsMaterial();
366 
367 private:
368 
369  /*l
370  ** A pointer to internal data.
371  */
372  bdiGeometryMtl* m_scripted_object;
373 
374  friend class bdiGeometryMtl;
375  friend class bdiGeometryFactory;
376 
377 #endif
378 };
379 
380 
381 #endif /* __diguyGraphicsMaterial_H */