DI-Guy SDK Documentation  13.1
diguyGraphicsMaterial.h
Go to the documentation of this file.
1 
2 /*********************************************************************
3  ** Copyright (c) 1992-2015 VT MAK
4  ** All rights reserved.
5  *********************************************************************/
6 
7 /*********************************************************************/
14 #ifndef __diguyGraphicsMaterial_H
15 #define __diguyGraphicsMaterial_H
16 
17 #ifdef SWIG
19 #else
20 #define CPLUSPLUS_ONLY
21 #endif
22 
23 #ifdef CPLUSPLUS_ONLY
24 #include <diguy_constants.h>
25 #include <declspec_diguy.h>
26 
27 class bdiGeometryMtl;
29 
30 /****************************************************************************/
31 
32 #endif
33 
34 /****************************************************************************/
35 class BDI_DECLSPEC_diguy diguyGraphicsMaterial
36 {
37 
38 public:
39 
40 /*****************************************************************************/
49  /*l
50  *b Description:
51  **
52  ** Returns the name of the texture. This pointer will
53  ** never be NULL.
54  **
55  *b Returns:
56  **
57  ** name of the texture
58  **
59  *b Callable From:
60  **
61  *- - C++
62  *- - Script
63  */
64  const char* get_name();
65 
66 #ifdef CPLUSPLUS_ONLY
67 
68  /*l
69  *b Description:
70  **
71  ** This function returns the red, green, blue, and alpha
72  ** components of the material's ambient setting. All returned
73  ** values will be between 0 (least intensity) and 1 (highest
74  ** intensity).
75  **
76  *b Arguments:
77  **
78  *a rgba - pointer to an array of four floats into which results
79  *a should be copied
80  **
81  *b Callable From:
82  **
83  *- - C++
84  */
85  void get_ambient(float* rgba);
86 
87  /*l
88  *b Description:
89  **
90  ** This function returns the red, green, blue, and alpha
91  ** components of the material's diffuse setting. All returned
92  ** values will be between 0 (least intensity) and 1 (highest
93  ** intensity).
94  **
95  *b Arguments:
96  **
97  *a rgba - pointer to an array of four floats into which results
98  *a should be copied
99  **
100  *b Callable From:
101  **
102  *- - C++
103  */
104  void get_diffuse(float* rgba);
105 
106  /*l
107  *b Description:
108  **
109  ** This function returns the red, green, blue, and alpha
110  ** components of the material's specular setting. All returned
111  ** values will be between 0 (least intensity) and 1 (highest
112  ** intensity).
113  **
114  *b Arguments:
115  **
116  *a rgba - pointer to an array of four floats into which results
117  *a should be copied
118  **
119  *b Callable From:
120  **
121  *- - C++
122  */
123  void get_specular(float* rgba);
124 
125  /*l
126  *b Description:
127  **
128  ** This function returns the red, green, blue, and alpha
129  ** components of the material's emission setting. All returned
130  ** values will be between 0 (least intensity) and 1 (highest
131  ** intensity).
132  **
133  *b Arguments:
134  **
135  *a rgba - pointer to an array of four floats into which results
136  *a should be copied
137  **
138  *b Callable From:
139  **
140  *- - C++
141  */
142  void get_emission(float* rgba);
143 
144  /*l
145  *b Description:
146  **
147  ** This function returns the material's shininess setting.
148  **
149  *b Arguments:
150  **
151  *a s - pointer to float into which result should be copied
152  **
153  *b Callable From:
154  **
155  *- - C++
156  */
157  void get_shininess(float* s);
158 
159 
160  /*l
161  *b Description:
162  **
163  ** This function frees most memory allocated by the DI-Guy geometry
164  ** loader for this object.
165  **
166  ** This function should only be called during or after the object's
167  ** build() function has been called. After it has been called, calls
168  ** to many accessor functions will fail.
169  **
170  *b Callable From:
171  **
172  *- - C++
173  */
174  void free_loader_memory();
175 
176 #endif
177 
178  /*l
179  *b Description:
180  **
181  ** This function returns whether the material contains an alpha
182  ** component. Materials that have an alpha component can make
183  ** objects semi-transparent, which can affect when said objects
184  ** should be drawn.
185  **
186  *b Returns:
187  **
188  ** 1 if texture contains an alpha component, 0 if not; -1 on failure
189  **
190  *b Callable From:
191  **
192  *- - C++
193  *- - Script
194  */
195  int get_contains_alpha_component();
196 
197  /*l
198  *b Description:
199  **
200  ** This function returns the last material that was bound.
201  **
202  ** In bind_now() the current material can be checked against the last
203  ** bound material; if the values are the same the bind_now() function
204  ** can most often immediately return. This is desirable because
205  ** rendering state changes can have significant performance overhead.
206  **
207  *b Callable From:
208  **
209  *- - C++
210  *- - Script
211  */
212  static diguyGraphicsMaterial* get_last_bound_material();
213 
214  /*l
215  *b Description:
216  **
217  ** This function clears out the last bound material pointer.
218  **
219  ** diguyScenario::draw() calls it automatically, but it's recommended
220  ** that this function also be called when the drawing of a new
221  ** character is beginning. This can be done in
222  ** diguyGraphicsLink::begin_character_draw().
223  **
224  *b Callable From:
225  **
226  *- - C++
227  *- - Script
228  */
229  static void clear_last_bound_material();
230 
231 
232 
233 /*****************************************************************************/
245 #ifdef CPLUSPLUS_ONLY
246 
247  /*l
248  *b Description:
249  **
250  ** This function will be called by DI-Guy when it is time for a
251  ** renderer-specific material object to be created. At that point
252  ** all material information has been read and is available via the
253  ** Accessor Functions above.
254  **
255  *i Immediate Mode:
256  **
257  ** Immediate mode renderers may override this function, to
258  ** create an object that may be invoked by bind_now() to set
259  ** material attributes.
260  **
261  *i Scene Graph:
262  **
263  ** Scene graph renderers usually do override this function, to
264  ** create a material object that will be associated with
265  ** diguyGraphicsMesh objects.
266  **
267  *b Callable From:
268  **
269  *- - N/A (automatically called by DI-Guy Graphics API during
270  *- the Build Stage)
271  */
272  virtual void build();
273 
274  /*l
275  *b Description:
276  **
277  ** This function will be called by DI-Guy when it is time for a
278  ** renderer-specific material object to be destroyed.
279  **
280  *i Immediate Mode:
281  **
282  ** Immediate mode renderers may override this function, to
283  ** destroy any object that may have been created by build().
284  **
285  *i Scene Graph:
286  **
287  ** Scene graph renderers usually do override this function, to
288  ** destroy any object that may have been created by build().
289  **
290  *b Callable From:
291  **
292  *- - N/A (automatically called by DI-Guy Graphics API during
293  *- the Unbuild Stage)
294  */
295  virtual void unbuild();
296 
297  /*l
298  *b Description:
299  **
300  ** This function will be called by DI-Guy when the material should
301  ** be made active, or bound.
302  **
303  ** Note that this material should be checked against the material
304  ** returned by get_last_bound_material(). If they're the same this
305  ** function should return early.
306  **
307  *i Immediate Mode:
308  **
309  ** Immediate mode renderers usually do override this function, to
310  ** invoke the object created by build(), or make calls to the
311  ** renderer to set appropriate material state.
312  **
313  *i Scene Graph:
314  **
315  ** Scene graph renderers usually do not override this function.
316  **
317  *b Callable From:
318  **
319  *- - N/A (automatically called by DI-Guy Graphics API during
320  *- Draw Stage)
321  */
322  virtual void bind_now();
324 #endif
325 
326 
327 /****************************************************************************/
328 /****************************************************************************/
329 
334 #ifdef CPLUSPLUS_ONLY
335 
336  bdiGeometryMtl* get_scripted_object() {return m_scripted_object;}
337 
338 protected:
339 
340  /*l
341  ** A protected constructor. Constructors are called automatically
342  ** by DI-Guy.
343  */
344  diguyGraphicsMaterial(void* internal_data);
345 
346  /*l
347  ** A protected destructor. Destructors are called automatically
348  ** by DI-Guy.
349  */
350  virtual ~diguyGraphicsMaterial();
351 
352 private:
353 
354  /*l
355  ** A pointer to internal data.
356  */
357  bdiGeometryMtl* m_scripted_object;
358 
359  friend class bdiGeometryMtl;
360  friend class bdiGeometryFactory;
361 
362 #endif
363 };
364 
365 
366 #endif /* __diguyGraphicsMaterial_H */
A class that represents a shared material.
Definition: diguyGraphicsMaterial.h:34