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