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