Visualization Library 2.0.0

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
WrappersGraphics.hpp
Go to the documentation of this file.
1 /**************************************************************************************/
2 /* */
3 /* Visualization Library */
4 /* http://visualizationlibrary.org */
5 /* */
6 /* Copyright (c) 2005-2020, Michele Bosi */
7 /* All rights reserved. */
8 /* */
9 /* Redistribution and use in source and binary forms, with or without modification, */
10 /* are permitted provided that the following conditions are met: */
11 /* */
12 /* - Redistributions of source code must retain the above copyright notice, this */
13 /* list of conditions and the following disclaimer. */
14 /* */
15 /* - Redistributions in binary form must reproduce the above copyright notice, this */
16 /* list of conditions and the following disclaimer in the documentation and/or */
17 /* other materials provided with the distribution. */
18 /* */
19 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND */
20 /* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED */
21 /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
22 /* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR */
23 /* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
24 /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
25 /* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */
26 /* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
27 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
28 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
29 /* */
30 /**************************************************************************************/
31 
32 #ifndef VLXWrapper_Graphics_INCLUDE_ONCE
33 #define VLXWrapper_Graphics_INCLUDE_ONCE
34 
35 #include <vlX/WrappersCore.hpp>
37 #include <vlGraphics/Actor.hpp>
38 #include <vlGraphics/Effect.hpp>
39 #include <vlGraphics/Shader.hpp>
40 #include <vlGraphics/Geometry.hpp>
41 #include <vlGraphics/Light.hpp>
42 #include <vlGraphics/ClipPlane.hpp>
43 #include <vlGraphics/Camera.hpp>
51 #include <vlGraphics/GLSL.hpp>
53 #include <vlCore/DiskFile.hpp>
54 
55 namespace vlX
56 {
59  {
61  {
62  if (!vlx->getValue("Value"))
63  {
64  vl::Log::error( vl::Say("Line %n : error. 'VLXValue' expected in object '%s'. \n") << vlx->lineNumber() << vlx->tag() );
65  return NULL;
66  }
67 
68  const VLXValue& value = *vlx->getValue("Value");
69 
70  vl::ref<vl::ArrayAbstract> arr_abstract;
71 
72  if (vlx->tag() == "<vl::ArrayFloat1>")
73  {
75  const VLXArrayReal* vlx_arr_float = value.getArrayReal();
76  vl::ref<vl::ArrayFloat1> arr_float1 = new vl::ArrayFloat1; arr_abstract = arr_float1;
77  arr_float1->resize( vlx_arr_float->value().size() );
78  vlx_arr_float->copyTo((float*)arr_float1->ptr());
79  }
80  else
81  if (vlx->tag() == "<vl::ArrayFloat2>")
82  {
84  const VLXArrayReal* vlx_arr_float = value.getArrayReal();
85  VLX_IMPORT_CHECK_RETURN_NULL( vlx_arr_float->value().size() % 2 == 0, value)
86  vl::ref<vl::ArrayFloat2> arr_float2 = new vl::ArrayFloat2; arr_abstract = arr_float2;
87  arr_float2->resize( vlx_arr_float->value().size() / 2 );
88  vlx_arr_float->copyTo((float*)arr_float2->ptr());
89  }
90  else
91  if (vlx->tag() == "<vl::ArrayFloat3>")
92  {
94  const VLXArrayReal* vlx_arr_float = value.getArrayReal();
95  VLX_IMPORT_CHECK_RETURN_NULL( vlx_arr_float->value().size() % 3 == 0, value)
96  vl::ref<vl::ArrayFloat3> arr_float3 = new vl::ArrayFloat3; arr_abstract = arr_float3;
97  arr_float3->resize( vlx_arr_float->value().size() / 3 );
98  vlx_arr_float->copyTo((float*)arr_float3->ptr());
99  }
100  else
101  if (vlx->tag() == "<vl::ArrayFloat4>")
102  {
104  const VLXArrayReal* vlx_arr_float = value.getArrayReal();
105  VLX_IMPORT_CHECK_RETURN_NULL( vlx_arr_float->value().size() % 4 == 0, value)
106  vl::ref<vl::ArrayFloat4> arr_float4 = new vl::ArrayFloat4; arr_abstract = arr_float4;
107  arr_float4->resize( vlx_arr_float->value().size() / 4 );
108  vlx_arr_float->copyTo((float*)arr_float4->ptr());
109  }
110  else
111  if (vlx->tag() == "<vl::ArrayDouble1>")
112  {
114  const VLXArrayReal* vlx_arr_floating = value.getArrayReal();
115  vl::ref<vl::ArrayDouble1> arr_floating1 = new vl::ArrayDouble1; arr_abstract = arr_floating1;
116  arr_floating1->resize( vlx_arr_floating->value().size() );
117  vlx_arr_floating->copyTo((double*)arr_floating1->ptr());
118  }
119  else
120  if (vlx->tag() == "<vl::ArrayDouble2>")
121  {
123  const VLXArrayReal* vlx_arr_floating = value.getArrayReal();
124  VLX_IMPORT_CHECK_RETURN_NULL( vlx_arr_floating->value().size() % 2 == 0, value)
125  vl::ref<vl::ArrayDouble2> arr_floating2 = new vl::ArrayDouble2; arr_abstract = arr_floating2;
126  arr_floating2->resize( vlx_arr_floating->value().size() / 2 );
127  vlx_arr_floating->copyTo((double*)arr_floating2->ptr());
128  }
129  else
130  if (vlx->tag() == "<vl::ArrayDouble3>")
131  {
133  const VLXArrayReal* vlx_arr_floating = value.getArrayReal();
134  VLX_IMPORT_CHECK_RETURN_NULL( vlx_arr_floating->value().size() % 3 == 0, value)
135  vl::ref<vl::ArrayDouble3> arr_floating3 = new vl::ArrayDouble3; arr_abstract = arr_floating3;
136  arr_floating3->resize( vlx_arr_floating->value().size() / 3 );
137  vlx_arr_floating->copyTo((double*)arr_floating3->ptr());
138  }
139  else
140  if (vlx->tag() == "<vl::ArrayDouble4>")
141  {
143  const VLXArrayReal* vlx_arr_floating = value.getArrayReal();
144  VLX_IMPORT_CHECK_RETURN_NULL( vlx_arr_floating->value().size() % 4 == 0, value)
145  vl::ref<vl::ArrayDouble4> arr_floating4 = new vl::ArrayDouble4; arr_abstract = arr_floating4;
146  arr_floating4->resize( vlx_arr_floating->value().size() / 4 );
147  vlx_arr_floating->copyTo((double*)arr_floating4->ptr());
148  }
149  else
150  if (vlx->tag() == "<vl::ArrayInt1>")
151  {
153  const VLXArrayInteger* vlx_arr_int = value.getArrayInteger();
154  vl::ref<vl::ArrayInt1> arr_int1 = new vl::ArrayInt1; arr_abstract = arr_int1;
155  arr_int1->resize( vlx_arr_int->value().size() );
156  vlx_arr_int->copyTo((int*)arr_int1->ptr());
157  }
158  else
159  if (vlx->tag() == "<vl::ArrayInt2>")
160  {
162  const VLXArrayInteger* vlx_arr_int = value.getArrayInteger();
163  VLX_IMPORT_CHECK_RETURN_NULL( vlx_arr_int->value().size() % 2 == 0, value)
164  vl::ref<vl::ArrayInt2> arr_int2 = new vl::ArrayInt2; arr_abstract = arr_int2;
165  arr_int2->resize( vlx_arr_int->value().size() / 2 );
166  vlx_arr_int->copyTo((int*)arr_int2->ptr());
167  }
168  else
169  if (vlx->tag() == "<vl::ArrayInt3>")
170  {
172  const VLXArrayInteger* vlx_arr_int = value.getArrayInteger();
173  VLX_IMPORT_CHECK_RETURN_NULL( vlx_arr_int->value().size() % 3 == 0, value)
174  vl::ref<vl::ArrayInt3> arr_int3 = new vl::ArrayInt3; arr_abstract = arr_int3;
175  arr_int3->resize( vlx_arr_int->value().size() / 3 );
176  vlx_arr_int->copyTo((int*)arr_int3->ptr());
177  }
178  else
179  if (vlx->tag() == "<vl::ArrayInt4>")
180  {
182  const VLXArrayInteger* vlx_arr_int = value.getArrayInteger();
183  VLX_IMPORT_CHECK_RETURN_NULL( vlx_arr_int->value().size() % 4 == 0, value)
184  vl::ref<vl::ArrayInt4> arr_int4 = new vl::ArrayInt4; arr_abstract = arr_int4;
185  arr_int4->resize( vlx_arr_int->value().size() / 4 );
186  vlx_arr_int->copyTo((int*)arr_int4->ptr());
187  }
188  else
189  if (vlx->tag() == "<vl::ArrayUInt1>")
190  {
192  const VLXArrayInteger* vlx_arr_int = value.getArrayInteger();
193  vl::ref<vl::ArrayUInt1> arr_int1 = new vl::ArrayUInt1; arr_abstract = arr_int1;
194  arr_int1->resize( vlx_arr_int->value().size() );
195  vlx_arr_int->copyTo((unsigned int*)arr_int1->ptr());
196  }
197  else
198  if (vlx->tag() == "<vl::ArrayUInt2>")
199  {
201  const VLXArrayInteger* vlx_arr_int = value.getArrayInteger();
202  VLX_IMPORT_CHECK_RETURN_NULL( vlx_arr_int->value().size() % 2 == 0, value)
203  vl::ref<vl::ArrayUInt2> arr_int2 = new vl::ArrayUInt2; arr_abstract = arr_int2;
204  arr_int2->resize( vlx_arr_int->value().size() / 2 );
205  vlx_arr_int->copyTo((unsigned int*)arr_int2->ptr());
206  }
207  else
208  if (vlx->tag() == "<vl::ArrayUInt3>")
209  {
211  const VLXArrayInteger* vlx_arr_int = value.getArrayInteger();
212  VLX_IMPORT_CHECK_RETURN_NULL( vlx_arr_int->value().size() % 3 == 0, value)
213  vl::ref<vl::ArrayUInt3> arr_int3 = new vl::ArrayUInt3; arr_abstract = arr_int3;
214  arr_int3->resize( vlx_arr_int->value().size() / 3 );
215  vlx_arr_int->copyTo((unsigned int*)arr_int3->ptr());
216  }
217  else
218  if (vlx->tag() == "<vl::ArrayUInt4>")
219  {
221  const VLXArrayInteger* vlx_arr_int = value.getArrayInteger();
222  VLX_IMPORT_CHECK_RETURN_NULL( vlx_arr_int->value().size() % 4 == 0, value)
223  vl::ref<vl::ArrayUInt4> arr_int4 = new vl::ArrayUInt4; arr_abstract = arr_int4;
224  arr_int4->resize( vlx_arr_int->value().size() / 4 );
225  vlx_arr_int->copyTo((unsigned int*)arr_int4->ptr());
226  }
227  else
228  if (vlx->tag() == "<vl::ArrayShort1>")
229  {
231  const VLXArrayInteger* vlx_arr_int = value.getArrayInteger();
232  vl::ref<vl::ArrayShort1> arr_short1 = new vl::ArrayShort1; arr_abstract = arr_short1;
233  arr_short1->resize( vlx_arr_int->value().size() );
234  vlx_arr_int->copyTo((short*)arr_short1->ptr());
235  }
236  else
237  if (vlx->tag() == "<vl::ArrayShort2>")
238  {
240  const VLXArrayInteger* vlx_arr_int = value.getArrayInteger();
241  VLX_IMPORT_CHECK_RETURN_NULL( vlx_arr_int->value().size() % 2 == 0, value)
242  vl::ref<vl::ArrayShort2> arr_short2 = new vl::ArrayShort2; arr_abstract = arr_short2;
243  arr_short2->resize( vlx_arr_int->value().size() / 2 );
244  vlx_arr_int->copyTo((short*)arr_short2->ptr());
245  }
246  else
247  if (vlx->tag() == "<vl::ArrayShort3>")
248  {
250  const VLXArrayInteger* vlx_arr_int = value.getArrayInteger();
251  VLX_IMPORT_CHECK_RETURN_NULL( vlx_arr_int->value().size() % 3 == 0, value)
252  vl::ref<vl::ArrayShort3> arr_short3 = new vl::ArrayShort3; arr_abstract = arr_short3;
253  arr_short3->resize( vlx_arr_int->value().size() / 3 );
254  vlx_arr_int->copyTo((short*)arr_short3->ptr());
255  }
256  else
257  if (vlx->tag() == "<vl::ArrayShort4>")
258  {
260  const VLXArrayInteger* vlx_arr_int = value.getArrayInteger();
261  VLX_IMPORT_CHECK_RETURN_NULL( vlx_arr_int->value().size() % 4 == 0, value)
262  vl::ref<vl::ArrayShort4> arr_short4 = new vl::ArrayShort4; arr_abstract = arr_short4;
263  arr_short4->resize( vlx_arr_int->value().size() / 4 );
264  vlx_arr_int->copyTo((short*)arr_short4->ptr());
265  }
266  else
267  if (vlx->tag() == "<vl::ArrayUShort1>")
268  {
270  const VLXArrayInteger* vlx_arr_int = value.getArrayInteger();
271  vl::ref<vl::ArrayUShort1> arr_short1 = new vl::ArrayUShort1; arr_abstract = arr_short1;
272  arr_short1->resize( vlx_arr_int->value().size() );
273  vlx_arr_int->copyTo((unsigned short*)arr_short1->ptr());
274  }
275  else
276  if (vlx->tag() == "<vl::ArrayUShort2>")
277  {
279  const VLXArrayInteger* vlx_arr_int = value.getArrayInteger();
280  VLX_IMPORT_CHECK_RETURN_NULL( vlx_arr_int->value().size() % 2 == 0, value)
281  vl::ref<vl::ArrayUShort2> arr_short2 = new vl::ArrayUShort2; arr_abstract = arr_short2;
282  arr_short2->resize( vlx_arr_int->value().size() / 2 );
283  vlx_arr_int->copyTo((unsigned short*)arr_short2->ptr());
284  }
285  else
286  if (vlx->tag() == "<vl::ArrayUShort3>")
287  {
289  const VLXArrayInteger* vlx_arr_int = value.getArrayInteger();
290  VLX_IMPORT_CHECK_RETURN_NULL( vlx_arr_int->value().size() % 3 == 0, value)
291  vl::ref<vl::ArrayUShort3> arr_short3 = new vl::ArrayUShort3; arr_abstract = arr_short3;
292  arr_short3->resize( vlx_arr_int->value().size() / 3 );
293  vlx_arr_int->copyTo((unsigned short*)arr_short3->ptr());
294  }
295  else
296  if (vlx->tag() == "<vl::ArrayUShort4>")
297  {
299  const VLXArrayInteger* vlx_arr_int = value.getArrayInteger();
300  VLX_IMPORT_CHECK_RETURN_NULL( vlx_arr_int->value().size() % 4 == 0, value)
301  vl::ref<vl::ArrayUShort4> arr_short4 = new vl::ArrayUShort4; arr_abstract = arr_short4;
302  arr_short4->resize( vlx_arr_int->value().size() / 4 );
303  vlx_arr_int->copyTo((unsigned short*)arr_short4->ptr());
304  }
305  else
306  if (vlx->tag() == "<vl::ArrayByte1>")
307  {
309  const VLXArrayInteger* vlx_arr_int = value.getArrayInteger();
310  vl::ref<vl::ArrayByte1> arr_byte1 = new vl::ArrayByte1; arr_abstract = arr_byte1;
311  arr_byte1->resize( vlx_arr_int->value().size() );
312  vlx_arr_int->copyTo((char*)arr_byte1->ptr());
313  }
314  else
315  if (vlx->tag() == "<vl::ArrayByte2>")
316  {
318  const VLXArrayInteger* vlx_arr_int = value.getArrayInteger();
319  VLX_IMPORT_CHECK_RETURN_NULL( vlx_arr_int->value().size() % 2 == 0, value)
320  vl::ref<vl::ArrayByte2> arr_byte2 = new vl::ArrayByte2; arr_abstract = arr_byte2;
321  arr_byte2->resize( vlx_arr_int->value().size() / 2 );
322  vlx_arr_int->copyTo((char*)arr_byte2->ptr());
323  }
324  else
325  if (vlx->tag() == "<vl::ArrayByte3>")
326  {
328  const VLXArrayInteger* vlx_arr_int = value.getArrayInteger();
329  VLX_IMPORT_CHECK_RETURN_NULL( vlx_arr_int->value().size() % 3 == 0, value)
330  vl::ref<vl::ArrayByte3> arr_byte3 = new vl::ArrayByte3; arr_abstract = arr_byte3;
331  arr_byte3->resize( vlx_arr_int->value().size() / 3 );
332  vlx_arr_int->copyTo((char*)arr_byte3->ptr());
333  }
334  else
335  if (vlx->tag() == "<vl::ArrayByte4>")
336  {
338  const VLXArrayInteger* vlx_arr_int = value.getArrayInteger();
339  VLX_IMPORT_CHECK_RETURN_NULL( vlx_arr_int->value().size() % 4 == 0, value)
340  vl::ref<vl::ArrayByte4> arr_byte4 = new vl::ArrayByte4; arr_abstract = arr_byte4;
341  arr_byte4->resize( vlx_arr_int->value().size() / 4 );
342  vlx_arr_int->copyTo((char*)arr_byte4->ptr());
343  }
344  else
345  if (vlx->tag() == "<vl::ArrayUByte1>")
346  {
348  const VLXArrayInteger* vlx_arr_int = value.getArrayInteger();
349  vl::ref<vl::ArrayUByte1> arr_byte1 = new vl::ArrayUByte1; arr_abstract = arr_byte1;
350  arr_byte1->resize( vlx_arr_int->value().size() );
351  vlx_arr_int->copyTo((unsigned char*)arr_byte1->ptr());
352  }
353  else
354  if (vlx->tag() == "<vl::ArrayUByte2>")
355  {
357  const VLXArrayInteger* vlx_arr_int = value.getArrayInteger();
358  VLX_IMPORT_CHECK_RETURN_NULL( vlx_arr_int->value().size() % 2 == 0, value)
359  vl::ref<vl::ArrayUByte2> arr_byte2 = new vl::ArrayUByte2; arr_abstract = arr_byte2;
360  arr_byte2->resize( vlx_arr_int->value().size() / 2 );
361  vlx_arr_int->copyTo((unsigned char*)arr_byte2->ptr());
362  }
363  else
364  if (vlx->tag() == "<vl::ArrayUByte3>")
365  {
367  const VLXArrayInteger* vlx_arr_int = value.getArrayInteger();
368  VLX_IMPORT_CHECK_RETURN_NULL( vlx_arr_int->value().size() % 3 == 0, value)
369  vl::ref<vl::ArrayUByte3> arr_byte3 = new vl::ArrayUByte3; arr_abstract = arr_byte3;
370  arr_byte3->resize( vlx_arr_int->value().size() / 3 );
371  vlx_arr_int->copyTo((unsigned char*)arr_byte3->ptr());
372  }
373  else
374  if (vlx->tag() == "<vl::ArrayUByte4>")
375  {
377  const VLXArrayInteger* vlx_arr_int = value.getArrayInteger();
378  VLX_IMPORT_CHECK_RETURN_NULL( vlx_arr_int->value().size() % 4 == 0, value)
379  vl::ref<vl::ArrayUByte4> arr_byte4 = new vl::ArrayUByte4; arr_abstract = arr_byte4;
380  arr_byte4->resize( vlx_arr_int->value().size() / 4 );
381  vlx_arr_int->copyTo((unsigned char*)arr_byte4->ptr());
382  }
383  else
384  {
385  s.signalImportError( vl::Say("Line %n : unknown array '%s'.\n") << vlx->lineNumber() << vlx->tag() );
386  }
387 
388  // register imported structure asap
389  s.registerImportedStructure(vlx, arr_abstract.get());
390  return arr_abstract.get();
391  }
392 
393  template<typename T_Array, typename T_VLXArray>
395  {
396  const T_Array* arr = arr_abstract->as<T_Array>();
397  vl::ref<VLXStructure> st =new VLXStructure(vlx_makeTag(arr_abstract).c_str(), s.generateID("array_"));
398  vl::ref<T_VLXArray> vlx_array = new T_VLXArray;
399  if (arr->size())
400  {
401  vlx_array->value().resize( arr->size() * arr->glSize() );
402  typename T_VLXArray::scalar_type* dst = &vlx_array->value()[0];
403  const typename T_Array::scalar_type* src = (const typename T_Array::scalar_type*)arr->begin();
404  const typename T_Array::scalar_type* end = (const typename T_Array::scalar_type*)arr->end();
405  for(; src<end; ++src, ++dst)
406  *dst = (typename T_VLXArray::scalar_type)*src;
407  }
408  st->value().push_back( VLXStructure::KeyValue("Value", vlx_array.get() ) );
409  return st;
410  }
411 
413  {
415  if(obj->classType() == vl::ArrayUInt1::Type())
416  vlx = export_ArrayT<vl::ArrayUInt1, VLXArrayInteger>(s, obj);
417  else
418  if(obj->classType() == vl::ArrayUInt2::Type())
419  vlx = export_ArrayT<vl::ArrayUInt2, VLXArrayInteger>(s, obj);
420  else
421  if(obj->classType() == vl::ArrayUInt3::Type())
422  vlx = export_ArrayT<vl::ArrayUInt3, VLXArrayInteger>(s, obj);
423  else
424  if(obj->classType() == vl::ArrayUInt4::Type())
425  vlx = export_ArrayT<vl::ArrayUInt4, VLXArrayInteger>(s, obj);
426  else
427 
428  if(obj->classType() == vl::ArrayInt1::Type())
429  vlx = export_ArrayT<vl::ArrayInt1, VLXArrayInteger>(s, obj);
430  else
431  if(obj->classType() == vl::ArrayInt2::Type())
432  vlx = export_ArrayT<vl::ArrayInt2, VLXArrayInteger>(s, obj);
433  else
434  if(obj->classType() == vl::ArrayInt3::Type())
435  vlx = export_ArrayT<vl::ArrayInt3, VLXArrayInteger>(s, obj);
436  else
437  if(obj->classType() == vl::ArrayInt4::Type())
438  vlx = export_ArrayT<vl::ArrayInt4, VLXArrayInteger>(s, obj);
439  else
440 
441  if(obj->classType() == vl::ArrayUShort1::Type())
442  vlx = export_ArrayT<vl::ArrayUShort1, VLXArrayInteger>(s, obj);
443  else
444  if(obj->classType() == vl::ArrayUShort2::Type())
445  vlx = export_ArrayT<vl::ArrayUShort2, VLXArrayInteger>(s, obj);
446  else
447  if(obj->classType() == vl::ArrayUShort3::Type())
448  vlx = export_ArrayT<vl::ArrayUShort3, VLXArrayInteger>(s, obj);
449  else
450  if(obj->classType() == vl::ArrayUShort4::Type())
451  vlx = export_ArrayT<vl::ArrayUShort4, VLXArrayInteger>(s, obj);
452  else
453 
454  if(obj->classType() == vl::ArrayUShort1::Type())
455  vlx = export_ArrayT<vl::ArrayUShort1, VLXArrayInteger>(s, obj);
456  else
457  if(obj->classType() == vl::ArrayUShort2::Type())
458  vlx = export_ArrayT<vl::ArrayUShort2, VLXArrayInteger>(s, obj);
459  else
460  if(obj->classType() == vl::ArrayUShort3::Type())
461  vlx = export_ArrayT<vl::ArrayUShort3, VLXArrayInteger>(s, obj);
462  else
463  if(obj->classType() == vl::ArrayUShort4::Type())
464  vlx = export_ArrayT<vl::ArrayUShort4, VLXArrayInteger>(s, obj);
465  else
466 
467  if(obj->classType() == vl::ArrayShort1::Type())
468  vlx = export_ArrayT<vl::ArrayShort1, VLXArrayInteger>(s, obj);
469  else
470  if(obj->classType() == vl::ArrayShort2::Type())
471  vlx = export_ArrayT<vl::ArrayShort2, VLXArrayInteger>(s, obj);
472  else
473  if(obj->classType() == vl::ArrayShort3::Type())
474  vlx = export_ArrayT<vl::ArrayShort3, VLXArrayInteger>(s, obj);
475  else
476  if(obj->classType() == vl::ArrayShort4::Type())
477  vlx = export_ArrayT<vl::ArrayShort4, VLXArrayInteger>(s, obj);
478  else
479 
480  if(obj->classType() == vl::ArrayUByte1::Type())
481  vlx = export_ArrayT<vl::ArrayUByte1, VLXArrayInteger>(s, obj);
482  else
483  if(obj->classType() == vl::ArrayUByte2::Type())
484  vlx = export_ArrayT<vl::ArrayUByte2, VLXArrayInteger>(s, obj);
485  else
486  if(obj->classType() == vl::ArrayUByte3::Type())
487  vlx = export_ArrayT<vl::ArrayUByte3, VLXArrayInteger>(s, obj);
488  else
489  if(obj->classType() == vl::ArrayUByte4::Type())
490  vlx = export_ArrayT<vl::ArrayUByte4, VLXArrayInteger>(s, obj);
491  else
492 
493  if(obj->classType() == vl::ArrayByte1::Type())
494  vlx = export_ArrayT<vl::ArrayByte1, VLXArrayInteger>(s, obj);
495  else
496  if(obj->classType() == vl::ArrayByte2::Type())
497  vlx = export_ArrayT<vl::ArrayByte2, VLXArrayInteger>(s, obj);
498  else
499  if(obj->classType() == vl::ArrayByte3::Type())
500  vlx = export_ArrayT<vl::ArrayByte3, VLXArrayInteger>(s, obj);
501  else
502  if(obj->classType() == vl::ArrayByte4::Type())
503  vlx = export_ArrayT<vl::ArrayByte4, VLXArrayInteger>(s, obj);
504  else
505 
506  if(obj->classType() == vl::ArrayFloat1::Type())
507  vlx = export_ArrayT<vl::ArrayFloat1, VLXArrayReal>(s, obj);
508  else
509  if(obj->classType() == vl::ArrayFloat2::Type())
510  vlx = export_ArrayT<vl::ArrayFloat2, VLXArrayReal>(s, obj);
511  else
512  if(obj->classType() == vl::ArrayFloat3::Type())
513  vlx = export_ArrayT<vl::ArrayFloat3, VLXArrayReal>(s, obj);
514  else
515  if(obj->classType() == vl::ArrayFloat4::Type())
516  vlx = export_ArrayT<vl::ArrayFloat4, VLXArrayReal>(s, obj);
517  else
518 
519  if(obj->classType() == vl::ArrayDouble1::Type())
520  vlx = export_ArrayT<vl::ArrayDouble1, VLXArrayReal>(s, obj);
521  else
522  if(obj->classType() == vl::ArrayDouble2::Type())
523  vlx = export_ArrayT<vl::ArrayDouble2, VLXArrayReal>(s, obj);
524  else
525  if(obj->classType() == vl::ArrayDouble3::Type())
526  vlx = export_ArrayT<vl::ArrayDouble3, VLXArrayReal>(s, obj);
527  else
528  if(obj->classType() == vl::ArrayDouble4::Type())
529  vlx = export_ArrayT<vl::ArrayDouble4, VLXArrayReal>(s, obj);
530  else
531  {
532  s.signalExportError("Array type not supported for export.\n");
533  }
534 
535  // register exported object asap
536  s.registerExportedObject(obj, vlx.get());
537  return vlx;
538  }
539  };
540 
541  //---------------------------------------------------------------------------
542 
545  {
546  virtual void exportRenderable(const vl::Renderable* obj, VLXStructure* vlx)
547  {
548  if (!obj->objectName().empty() && obj->objectName() != obj->className())
549  *vlx << "ObjectName" << vlx_String(obj->objectName());
550  *vlx << "BufferObjectEnabled" << obj->isBufferObjectEnabled();
551  *vlx << "DisplayListEnabled" << obj->isDisplayListEnabled();
552  if (!obj->boundsDirty())
553  {
554  *vlx << "AABB" << export_AABB(obj->boundingBox());
555  *vlx << "Sphere" << export_Sphere(obj->boundingSphere());
556  }
557  else
558  vl::Log::debug("VLXClassWrapper_Renderable : skipping dirty bounds.\n");
559  }
560 
562  {
563  const VLXValue* name = vlx->getValue("ObjectName");
564  if (name)
565  ren->setObjectName( name->getString() );
566 
567  const std::vector<VLXStructure::KeyValue>& values = vlx->value();
568  for(size_t i=0; i<values.size(); ++i)
569  {
570  const std::string& key = values[i].key();
571  if (key == "BufferObjectEnabled")
572  {
573  ren->setBufferObjectEnabled( values[i].value().getBool() );
574  }
575  else
576  if (key == "DisplayListEnabled")
577  {
578  ren->setDisplayListEnabled( values[i].value().getBool() );
579  }
580  else
581  if (key == "AABB")
582  {
583  ren->setBoundingBox( import_AABB(values[i].value().getStructure()) );
584  }
585  else
586  if (key == "Sphere")
587  {
588  ren->setBoundingSphere( import_Sphere(values[i].value().getStructure()) );
589  }
590  }
591  }
592  };
593 
594  //---------------------------------------------------------------------------
595 
598  {
600  {
602 
603  for(size_t i=0; i<vlx->value().size(); ++i)
604  {
605  const std::string& key = vlx->value()[i].key();
606  const VLXValue& value = vlx->value()[i].value();
607 
608  if (key == "VertexArray")
609  {
611  vl::ArrayAbstract* arr = s.importVLX(value.getStructure())->as<vl::ArrayAbstract>();
612  if (arr)
613  geom->setVertexArray(arr);
614  else
615  s.signalImportError( vl::Say("Line %n : import error.\n") << value.lineNumber() );
616  }
617  else
618  if (key == "NormalArray")
619  {
621  vl::ArrayAbstract* arr = s.importVLX(value.getStructure())->as<vl::ArrayAbstract>();
622  if (arr)
623  geom->setNormalArray(arr);
624  else
625  s.signalImportError( vl::Say("Line %n : import error.\n") << value.lineNumber() );
626  }
627  else
628  if (key == "ColorArray")
629  {
631  vl::ArrayAbstract* arr = s.importVLX(value.getStructure())->as<vl::ArrayAbstract>();
632  if (arr)
633  geom->setColorArray(arr);
634  else
635  s.signalImportError( vl::Say("Line %n : import error.\n") << value.lineNumber() );
636  }
637  else
638  if (key == "SecondaryColorArray")
639  {
641  vl::ArrayAbstract* arr = s.importVLX(value.getStructure())->as<vl::ArrayAbstract>();
642  if (arr)
643  geom->setSecondaryColorArray(arr);
644  else
645  s.signalImportError( vl::Say("Line %n : import error.\n") << value.lineNumber() );
646  }
647  else
648  if (key == "FogCoordArray")
649  {
651  vl::ArrayAbstract* arr = s.importVLX(value.getStructure())->as<vl::ArrayAbstract>();
652  if (arr)
653  geom->setFogCoordArray(arr);
654  else
655  s.signalImportError( vl::Say("Line %n : import error.\n") << value.lineNumber() );
656  }
657  else
658  if (strstr(key.c_str(), "TexCoordArray") == key.c_str())
659  {
660  const char* ch = key.c_str() + 13/*strlen("TexCoordArray")*/;
661  int tex_unit = 0;
662  for(; *ch; ++ch)
663  {
664  if (*ch>='0' && *ch<='9')
665  tex_unit = tex_unit*10 + (*ch - '0');
666  else
667  {
668  vl::Log::error( vl::Say("Line %n : error. ") << value.lineNumber() );
669  vl::Log::error( "TexCoordArray must end with a number!\n" );
670  s.signalImportError( vl::Say("Line %n : import error.\n") << value.lineNumber() );
671  }
672  }
673 
675  vl::ArrayAbstract* arr = s.importVLX(value.getStructure())->as<vl::ArrayAbstract>();
676  if (arr)
677  geom->setTexCoordArray(tex_unit, arr);
678  else
679  s.signalImportError( vl::Say("Line %n : import error.\n") << value.lineNumber() );
680  }
681  else
682  if (strstr(key.c_str(), "VertexAttribArray") == key.c_str())
683  {
684  // MIC FIXME
685  //const char* ch = key.c_str() + 17/*strlen("VertexAttribArray")*/;
686  //int attrib_location = 0;
687  //for(; *ch; ++ch)
688  //{
689  // if (*ch>='0' && *ch<='9')
690  // attrib_location = attrib_location*10 + (*ch - '0');
691  // else
692  // {
693  // vl::Log::error( vl::Say("Line %n : error. ") << value.lineNumber() );
694  // vl::Log::error( "VertexAttribArray must end with a number!\n" );
695  // s.signalImportError( vl::Say("Line %n : import error.\n") << value.lineNumber() );
696  // }
697  //}
698 
699  //VLX_IMPORT_CHECK_RETURN(value.type() == VLXValue::Structure, value)
700  //VertexAttribInfo* info_ptr = s.importVLX(value.getStructure())->as<vl::VertexAttribInfo>();
701  //if (info_ptr)
702  //{
703  // VertexAttribInfo info = *info_ptr;
704  // info.setAttribLocation(attrib_location);
705  // geom->setVertexAttribArray(info);
706  //}
707  //else
708  // s.signalImportError( vl::Say("Line %n : import error.\n") << value.lineNumber() );
709  }
710  else
711  if (key == "DrawCall")
712  {
714  vl::DrawCall* draw_call = s.importVLX(value.getStructure())->as<vl::DrawCall>();
715  if (draw_call)
716  geom->drawCalls().push_back(draw_call);
717  else
718  s.signalImportError( vl::Say("Line %n : import error.\n") << value.lineNumber() );
719  }
720  }
721  }
722 
724  {
726  // registration must be done here to avoid loops
727  s.registerImportedStructure(vlx, geom.get());
728  importGeometry(s, vlx, geom.get());
729  return geom;
730  }
731 
733  {
734  // vl::Renderable
736 
737  // vl::Geometry
738  if (geom->vertexArray())
739  *vlx << "VertexArray" << s.exportVLX(geom->vertexArray());
740 
741  if (geom->normalArray())
742  *vlx << "NormalArray" << s.exportVLX(geom->normalArray());
743 
744  if (geom->colorArray())
745  *vlx << "ColorArray" << s.exportVLX(geom->colorArray());
746 
747  if (geom->secondaryColorArray())
748  *vlx << "SecondaryColorArray" << s.exportVLX(geom->secondaryColorArray());
749 
750  if (geom->fogCoordArray())
751  *vlx << "FogCoordArray" << s.exportVLX(geom->fogCoordArray());
752 
753  for( int i=0; i<vl::VA_MaxTexCoordCount; ++i)
754  {
755  if (geom->texCoordArray(i))
756  {
757  std::string tex_coord_array = vl::String::printf("TexCoordArray%d", i).toStdString();
758  *vlx << tex_coord_array.c_str() << s.exportVLX(geom->texCoordArray(i));
759  }
760  }
761 
762  // MIC FIXME: unify with above
763  //for(size_t i=0; i<VA_MaxAttribCount; ++i)
764  //{
765  // if (geom->vertexAttribArray(i))
766  // {
767  // std::string vertex_attrib_array = vl::String::printf("VertexAttribArray%d", i).toStdString();
768  // *vlx << vertex_attrib_array.c_str() << s.exportVLX(geom->vertexAttribArray(i));
769  // }
770  //}
771 
772  for(int i=0; i<geom->drawCalls().size(); ++i) {
773  *vlx << "DrawCall" << s.exportVLX(geom->drawCalls().at(i));
774  }
775  }
776 
778  {
779  const vl::Geometry* cast_obj = obj->as<vl::Geometry>(); VL_CHECK(cast_obj)
780  vl::ref<VLXStructure> vlx = new VLXStructure(vlx_makeTag(obj).c_str(), s.generateID("geometry_"));
781  // register exported object asap
782  s.registerExportedObject(obj, vlx.get());
783  exportGeometry(s, cast_obj, vlx.get());
784  return vlx;
785  }
786  };
787 
788  //---------------------------------------------------------------------------
789 
792  {
793  void importDrawCall(VLXSerializer& s, const VLXStructure* vlx, vl::DrawCall* draw_call)
794  {
795  if(draw_call->isOfType(vl::DrawElementsBase::Type()))
796  {
797  vl::DrawElementsBase* de= draw_call->as<vl::DrawElementsBase>();
798 
799  const VLXValue* name = vlx->getValue("ObjectName");
800  if (name)
801  de->setObjectName( name->getString() );
802 
803  for(size_t i=0; i<vlx->value().size(); ++i)
804  {
805  const std::string& key = vlx->value()[i].key();
806  const VLXValue& value = vlx->value()[i].value();
807  if( key == "PrimitiveType" )
808  {
810  de->setPrimitiveType( vlx_EPrimitiveType( value, s ) );
812  }
813  else
814  if( key == "Enabled" )
815  {
816  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Bool , value)
817  de->setEnabled( value.getBool() );
818  }
819  else
820  if( key == "Instances" )
821  {
822  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Integer , value)
823  de->setInstances( (int)value.getInteger() );
824  }
825  else
826  if( key == "PrimitiveRestartEnabled" )
827  {
828  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Bool , value)
829  de->setPrimitiveRestartEnabled( value.getBool() );
830  }
831  else
832  if( key == "BaseVertex" )
833  {
834  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Integer , value)
835  de->setBaseVertex( (int)value.getInteger() );
836  }
837  else
838  if( key == "IndexBuffer" )
839  {
841  vl::ArrayAbstract* arr_abstract = s.importVLX(value.getStructure())->as<vl::ArrayAbstract>();
842  if(!arr_abstract)
843  s.signalImportError( vl::Say("Line %n : import error.\n") << value.lineNumber() );
844 
845  if ( de->isOfType(vl::DrawElementsUInt::Type()) )
846  {
847  VLX_IMPORT_CHECK_RETURN(arr_abstract->classType() == vl::ArrayUInt1::Type(), value);
848  de->as<vl::DrawElementsUInt>()->setIndexBuffer( arr_abstract->as<vl::ArrayUInt1>() );
849  }
850  else
851  if ( de->isOfType(vl::DrawElementsUShort::Type()) )
852  {
853  VLX_IMPORT_CHECK_RETURN(arr_abstract->classType() == vl::ArrayUShort1::Type(), value);
854  de->as<vl::DrawElementsUShort>()->setIndexBuffer( arr_abstract->as<vl::ArrayUShort1>() );
855  }
856  else
857  if ( de->isOfType(vl::DrawElementsUByte::Type()) )
858  {
859  VLX_IMPORT_CHECK_RETURN(arr_abstract->classType() == vl::ArrayUByte1::Type(), value);
860  de->as<vl::DrawElementsUByte>()->setIndexBuffer( arr_abstract->as<vl::ArrayUByte1>() );
861  }
862  }
863  }
864  }
865  else
866  if(draw_call->isOfType(vl::MultiDrawElementsBase::Type()))
867  {
869 
870  VL_CHECK(de)
871  VL_CHECK(draw_call)
872 
873  const VLXValue* name = vlx->getValue("ObjectName");
874  if (name)
875  de->setObjectName( name->getString() );
876 
877  for(size_t i=0; i<vlx->value().size(); ++i)
878  {
879  const std::string& key = vlx->value()[i].key();
880  const VLXValue& value = vlx->value()[i].value();
881  if( key == "PrimitiveType" )
882  {
884  de->setPrimitiveType( vlx_EPrimitiveType( value, s ) );
886  }
887  else
888  if( key == "Enabled" )
889  {
890  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Bool , value)
891  de->setEnabled( value.getBool() );
892  }
893  else
894  if( key == "PrimitiveRestartEnabled" )
895  {
896  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Bool , value)
897  de->setPrimitiveRestartEnabled( value.getBool() );
898  }
899  else
900  if( key == "BaseVertices" )
901  {
903  de->baseVertices().resize( value.getArrayInteger()->value().size() );
904  if (de->baseVertices().size())
905  value.getArrayInteger()->copyTo( &de->baseVertices()[0] );
906  // de->setBaseVertices( value.getArrayInt32()->value() );
907  }
908  else
909  if( key == "CountVector" )
910  {
912  de->countVector().resize( value.getArrayInteger()->value().size() );
913  if (de->countVector().size())
914  value.getArrayInteger()->copyTo( &de->countVector()[0] );
915  // de->countVector() = value.getArrayInt32()->value();
916  }
917  else
918  if( key == "IndexBuffer" )
919  {
921  vl::ArrayAbstract* arr_abstract = s.importVLX(value.getStructure())->as<vl::ArrayAbstract>();
922  if( !arr_abstract )
923  s.signalImportError( vl::Say("Line %n : import error.\n") << value.lineNumber() );
924 
925  if ( de->isOfType(vl::MultiDrawElementsUInt::Type()) )
926  {
927  VLX_IMPORT_CHECK_RETURN(arr_abstract->classType() == vl::ArrayUInt1::Type(), value);
928  de->as<vl::MultiDrawElementsUInt>()->setIndexBuffer( arr_abstract->as<vl::ArrayUInt1>() );
929  }
930  else
931  if ( de->isOfType(vl::MultiDrawElementsUShort::Type()) )
932  {
933  VLX_IMPORT_CHECK_RETURN(arr_abstract->classType() == vl::ArrayUShort1::Type(), value);
934  de->as<vl::MultiDrawElementsUShort>()->setIndexBuffer( arr_abstract->as<vl::ArrayUShort1>() );
935  }
936  else
937  if ( de->isOfType(vl::MultiDrawElementsUByte::Type()) )
938  {
939  VLX_IMPORT_CHECK_RETURN(arr_abstract->classType() == vl::ArrayUByte1::Type(), value);
940  de->as<vl::MultiDrawElementsUByte>()->setIndexBuffer( arr_abstract->as<vl::ArrayUByte1>() );
941  }
942  }
943  }
944 
945  // finalize setup
946  de->computePointerVector();
948  if ( de->baseVertices().size() != de->countVector().size() )
949  de->baseVertices().resize( de->countVector().size() );
950  }
951  else
952  if( draw_call->isOfType(vl::DrawArrays::Type()) )
953  {
954  vl::ref<vl::DrawArrays> da = draw_call->as<vl::DrawArrays>();
955 
956  const VLXValue* name = vlx->getValue("ObjectName");
957  if (name)
958  da->setObjectName( name->getString() );
959 
960  for(size_t i=0; i<vlx->value().size(); ++i)
961  {
962  const std::string& key = vlx->value()[i].key();
963  const VLXValue& value = vlx->value()[i].value();
964 
965  if( key == "PrimitiveType" )
966  {
968  da->setPrimitiveType( vlx_EPrimitiveType( value, s ) );
970  }
971  else
972  if( key == "Enabled" )
973  {
974  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Bool , value)
975  da->setEnabled( value.getBool() );
976  }
977  else
978  if( key == "Instances" )
979  {
980  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Integer , value)
981  da->setInstances( (int)value.getInteger() );
982  }
983  else
984  if( key == "Start" )
985  {
986  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Integer , value)
987  da->setStart( (int)value.getInteger() );
988  }
989  else
990  if( key == "Count" )
991  {
992  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Integer , value)
993  da->setCount( (int)value.getInteger() );
994  }
995  }
996  }
997  }
998 
1000  {
1002  if (vlx->tag() == "<vl::DrawElementsUInt>")
1003  dc = new vl::DrawElementsUInt;
1004  else
1005  if (vlx->tag() == "<vl::DrawElementsUShort>")
1006  dc = new vl::DrawElementsUShort;
1007  else
1008  if (vlx->tag() == "<vl::DrawElementsUByte>")
1009  dc = new vl::DrawElementsUByte;
1010  else
1011  if (vlx->tag() == "<vl::MultiDrawElementsUInt>")
1012  dc = new vl::MultiDrawElementsUInt;
1013  else
1014  if (vlx->tag() == "<vl::MultiDrawElementsUShort>")
1015  dc = new vl::MultiDrawElementsUShort;
1016  else
1017  if (vlx->tag() == "<vl::MultiDrawElementsUByte>")
1018  dc = new vl::MultiDrawElementsUByte;
1019  else
1020  if (vlx->tag() == "<vl::DrawArrays>")
1021  dc = new vl::DrawArrays;
1022  else
1023  s.signalImportError( vl::Say("Line %n : error. Unknown draw call.\n") << vlx->lineNumber() );
1024  // register imported structure asap
1025  s.registerImportedStructure(vlx, dc.get());
1026  importDrawCall(s, vlx, dc.get());
1027  return dc;
1028  }
1029 
1031  {
1032  if (!obj->objectName().empty() && obj->objectName() != obj->className())
1033  *vlx << "ObjectName" << vlx_String(obj->objectName());
1034  *vlx << "PrimitiveType" << vlx_Identifier(vlx_EPrimitiveType(obj->primitiveType()));
1035  *vlx << "Enabled" << obj->isEnabled();
1036  if (obj->patchParameter())
1037  *vlx << "PatchParameter" << s.exportVLX(obj->patchParameter());
1038  }
1039 
1041  {
1042  exportDrawCallBase(s, dcall, vlx);
1043 
1044  if (dcall->isOfType(vl::DrawArrays::Type()))
1045  {
1046  const vl::DrawArrays* da = dcall->as<vl::DrawArrays>();
1047  *vlx << "Instances" << (long long)da->instances();
1048  *vlx << "Start" << (long long)da->start();
1049  *vlx << "Count" << (long long)da->count();
1050  }
1051  else
1052  if (dcall->isOfType(vl::DrawElementsUInt::Type()))
1053  {
1054  const vl::DrawElementsUInt* de = dcall->as<vl::DrawElementsUInt>();
1055  *vlx << "Instances" << (long long)de->instances();
1056  *vlx << "PrimitiveRestartEnabled" << de->primitiveRestartEnabled();
1057  *vlx << "BaseVertex" << (long long)de->baseVertex();
1058  *vlx << "IndexBuffer" << s.exportVLX(de->indexBuffer());
1059  }
1060  else
1061  if (dcall->isOfType(vl::DrawElementsUShort::Type()))
1062  {
1063  const vl::DrawElementsUShort* de = dcall->as<vl::DrawElementsUShort>();
1064  *vlx << "Instances" << (long long)de->instances();
1065  *vlx << "PrimitiveRestartEnabled" << de->primitiveRestartEnabled();
1066  *vlx << "BaseVertex" << (long long)de->baseVertex();
1067  *vlx << "IndexBuffer" << s.exportVLX(de->indexBuffer());
1068  }
1069  else
1070  if (dcall->isOfType(vl::DrawElementsUByte::Type()))
1071  {
1072  const vl::DrawElementsUByte* de = dcall->as<vl::DrawElementsUByte>();
1073  *vlx << "Instances" << (long long)de->instances();
1074  *vlx << "PrimitiveRestartEnabled" << de->primitiveRestartEnabled();
1075  *vlx << "BaseVertex" << (long long)de->baseVertex();
1076  *vlx << "IndexBuffer" << s.exportVLX(de->indexBuffer());
1077  }
1078  else
1079  if (dcall->isOfType(vl::MultiDrawElementsUInt::Type()))
1080  {
1082  *vlx << "PrimitiveRestartEnabled" << de->primitiveRestartEnabled();
1083  *vlx << "BaseVertices" << vlx_toValue(de->baseVertices());
1084  *vlx << "CountVector" << vlx_toValue(de->countVector());
1085  *vlx << "IndexBuffer" << s.exportVLX(de->indexBuffer());
1086  }
1087  else
1088  if (dcall->isOfType(vl::MultiDrawElementsUShort::Type()))
1089  {
1091  *vlx << "PrimitiveRestartEnabled" << de->primitiveRestartEnabled();
1092  *vlx << "BaseVertices" << vlx_toValue(de->baseVertices());
1093  *vlx << "CountVector" << vlx_toValue(de->countVector());
1094  *vlx << "IndexBuffer" << s.exportVLX(de->indexBuffer());
1095  }
1096  else
1097  if (dcall->isOfType(vl::MultiDrawElementsUByte::Type()))
1098  {
1100  *vlx << "PrimitiveRestartEnabled" << de->primitiveRestartEnabled();
1101  *vlx << "BaseVertices" << vlx_toValue(de->baseVertices());
1102  *vlx << "CountVector" << vlx_toValue(de->countVector());
1103  *vlx << "IndexBuffer" << s.exportVLX(de->indexBuffer());
1104  }
1105  else
1106  {
1107  vl::Log::error("vl::DrawCall type not supported for export.\n");
1108  }
1109  }
1110 
1112  {
1113  const vl::DrawCall* cast_obj = obj->as<vl::DrawCall>(); VL_CHECK(cast_obj)
1114  vl::ref<VLXStructure> vlx = new VLXStructure(vlx_makeTag(obj).c_str(), s.generateID("drawcall_"));
1115  // register exported object asap
1116  s.registerExportedObject(obj, vlx.get());
1117  exportDrawCall(s, cast_obj, vlx.get());
1118  return vlx;
1119  }
1120  };
1121 
1122  //---------------------------------------------------------------------------
1123 
1126  {
1128  {
1129  std::vector<VLXStructure::KeyValue> values = vlx->value();
1130  for(size_t i=0; i<values.size(); ++i)
1131  {
1132  const std::string& key = values[i].key();
1133  if (key == "PatchVertices")
1134  {
1135  pp->setPatchVertices( (int)values[i].value().getInteger() );
1136  }
1137  else
1138  if (key == "PatchDefaultOuterLevel")
1139  {
1140  pp->setPatchDefaultOuterLevel( (vl::fvec4)vlx_vec4(values[i].value().getArrayReal()) );
1141  }
1142  else
1143  if (key == "PatchDefaultInnerLevel")
1144  {
1145  pp->setPatchDefaultInnerLevel( (vl::fvec2)vlx_vec2(values[i].value().getArrayReal()) );
1146  }
1147  }
1148  }
1149 
1151  {
1153  // register imported structure asap
1154  s.registerImportedStructure(vlx, pp.get());
1155  importPatchParameter(vlx, pp.get());
1156  return pp;
1157  }
1158 
1160  {
1161  *vlx << "PatchVertices" << (long long)pp->patchVertices();
1162  *vlx << "PatchDefaultOuterLevel" << vlx_toValue((vl::vec4)pp->patchDefaultOuterLevel());
1163  *vlx << "PatchDefaultInnerLevel" << vlx_toValue((vl::vec2)pp->patchDefaultInnerLevel());
1164  }
1165 
1167  {
1168  const vl::PatchParameter* cast_obj = obj->as<vl::PatchParameter>(); VL_CHECK(cast_obj)
1169  vl::ref<VLXStructure> vlx = new VLXStructure(vlx_makeTag(obj).c_str(), s.generateID("patchparam_"));
1170  // register exported object asap
1171  s.registerExportedObject(obj, vlx.get());
1172  exportPatchParameter(cast_obj, vlx.get());
1173  return vlx;
1174  }
1175  };
1176 
1177  //---------------------------------------------------------------------------
1178 
1181  {
1183  {
1184  const VLXValue* vlx_obj_name = vlx->getValue("ObjectName");
1185  if (vlx_obj_name)
1186  resdb->setObjectName( vlx_obj_name->getString() );
1187 
1188  const VLXValue* vlx_res = vlx->getValue("Resources");
1189  if (vlx_res)
1190  {
1191  VLX_IMPORT_CHECK_RETURN( vlx_res->type() == VLXValue::List, *vlx_res );
1192  // get the list
1193  const VLXList* list = vlx_res->getList();
1194  for(size_t i=0; i<list->value().size(); ++i)
1195  {
1196  const VLXValue& value = list->value()[i];
1197 
1198  // the member of this list must be all structures.
1199 
1200  if (value.type() != VLXValue::Structure)
1201  {
1202  s.signalImportError( vl::Say("Line %n : structure expected.\n") << value.lineNumber() );
1203  return;
1204  }
1205 
1206  resdb->resources().push_back( s.importVLX(value.getStructure()) );
1207  }
1208  }
1209  }
1210 
1212  {
1214  // register imported structure asap
1215  s.registerImportedStructure(vlx, resdb.get());
1216  importResourceDatabase(s, vlx, resdb.get());
1217  return resdb;
1218  }
1219 
1221  {
1222  if (!obj->objectName().empty() && obj->objectName() != obj->className())
1223  *vlx << "ObjectName" << vlx_String(obj->objectName());
1224  vl::ref<VLXList> list = new VLXList;
1225  *vlx << "Resources" << list.get();
1226 
1227  for(size_t i=0; i<obj->resources().size(); ++i)
1228  {
1229  if ( !s.canExport(obj->resources().at(i).get()) )
1230  {
1231  vl::Log::debug( vl::Say("VLXClassWrapper_ResourceDatabase : skipping '%s'.\n") << obj->resources().at(i).get()->className() );
1232  continue;
1233  }
1234  else
1235  {
1236  *list << s.exportVLX(obj->resources().at(i).get());
1237  }
1238  }
1239  }
1240 
1242  {
1243  const vl::ResourceDatabase* cast_obj = obj->as<vl::ResourceDatabase>(); VL_CHECK(cast_obj)
1244  vl::ref<VLXStructure> vlx = new VLXStructure(vlx_makeTag(obj).c_str(), s.generateID("resdb_"));
1245  // register exported object asap
1246  s.registerExportedObject(obj, vlx.get());
1247  exportResourceDatabase(s, cast_obj, vlx.get());
1248  return vlx;
1249  }
1250  };
1251 
1252  //---------------------------------------------------------------------------
1253 
1256  {
1257  void importUniform(VLXSerializer& s, const VLXStructure* vlx, vl::Uniform* uniform)
1258  {
1259  const VLXValue* val = vlx->getValue("Name");
1260  if (val)
1261  {
1262  VL_CHECK( val->type() == VLXValue::Identifier );
1263  uniform->setName( val->getIdentifier() );
1264  }
1265  else
1266  {
1267  s.signalImportError( vl::Say("Line %d : uniform without 'Name'.\n") << vlx->lineNumber() );
1268  return;
1269  }
1270 
1271  // 'Count' is optional
1272  int count = 1;
1273  val = vlx->getValue("Count");
1274  if (val)
1275  {
1276  VL_CHECK( val->type() == VLXValue::Integer );
1277  count = (int)val->getInteger();
1278  }
1279 
1281  val = vlx->getValue("Type");
1282  if (val)
1283  {
1284  VL_CHECK( val->type() == VLXValue::Identifier );
1285  type = vlx_EUniformType( *val, s );
1286  }
1287  else
1288  {
1289  s.signalImportError( vl::Say("Line %d : uniform without 'Type'.\n") << vlx->lineNumber() );
1290  return;
1291  }
1292 
1293  val = vlx->getValue("Data");
1294  const VLXArrayReal* arr_real = NULL;
1295  const VLXArrayInteger* arr_int = NULL;
1296  if (!val)
1297  {
1298  s.signalImportError( vl::Say("Line %d : uniform without 'Data'.\n") << vlx->lineNumber() );
1299  return;
1300  }
1301  else
1302  {
1303  if (val->type() == VLXValue::ArrayReal)
1304  arr_real = val->getArrayReal();
1305  else
1306  if (val->type() == VLXValue::ArrayInteger)
1307  arr_int = val->getArrayInteger();
1308  }
1309 
1310  std::vector<int> int_vec;
1311  std::vector<unsigned int> uint_vec;
1312  std::vector<float> float_vec;
1313  std::vector<double> double_vec;
1314 
1315  switch(type)
1316  {
1317  case vl::UT_INT:
1318  int_vec.resize(count*1); if (arr_int) arr_int->copyTo(&int_vec[0]); else int_vec[0] = (int)val->getInteger();
1319  uniform->setUniform1i(count, &int_vec[0]);
1320  break;
1321  case vl::UT_INT_VEC2:
1322  int_vec.resize(count*2); arr_int->copyTo(&int_vec[0]); VLX_IMPORT_CHECK_RETURN(int_vec.size() == arr_int->value().size(), *val);
1323  uniform->setUniform2i(count, &int_vec[0]);
1324  break;
1325  case vl::UT_INT_VEC3:
1326  int_vec.resize(count*3); arr_int->copyTo(&int_vec[0]); VLX_IMPORT_CHECK_RETURN(int_vec.size() == arr_int->value().size(), *val);
1327  uniform->setUniform3i(count, &int_vec[0]);
1328  break;
1329  case vl::UT_INT_VEC4:
1330  int_vec.resize(count*4); arr_int->copyTo(&int_vec[0]); VLX_IMPORT_CHECK_RETURN(int_vec.size() == arr_int->value().size(), *val);
1331  uniform->setUniform4i(count, &int_vec[0]);
1332  break;
1333 
1334  case vl::UT_UNSIGNED_INT:
1335  uint_vec.resize(count*1); if (arr_int) arr_int->copyTo(&uint_vec[0]); else uint_vec[0] = (unsigned int)val->getInteger();
1336  uniform->setUniform1ui(count, &uint_vec[0]);
1337  break;
1339  uint_vec.resize(count*2); arr_int->copyTo(&uint_vec[0]); VLX_IMPORT_CHECK_RETURN(uint_vec.size() == arr_int->value().size(), *val);
1340  uniform->setUniform2ui(count, &uint_vec[0]);
1341  break;
1343  uint_vec.resize(count*3); arr_int->copyTo(&uint_vec[0]); VLX_IMPORT_CHECK_RETURN(uint_vec.size() == arr_int->value().size(), *val);
1344  uniform->setUniform3ui(count, &uint_vec[0]);
1345  break;
1347  uint_vec.resize(count*4); arr_int->copyTo(&uint_vec[0]); VLX_IMPORT_CHECK_RETURN(uint_vec.size() == arr_int->value().size(), *val);
1348  uniform->setUniform4ui(count, &uint_vec[0]);
1349  break;
1350 
1351  case vl::UT_FLOAT:
1352  float_vec.resize(count*1); if (arr_real) arr_real->copyTo(&float_vec[0]); else float_vec[0] = (float)val->getReal();
1353  uniform->setUniform1f(count, &float_vec[0]);
1354  break;
1355  case vl::UT_FLOAT_VEC2:
1356  float_vec.resize(count*2); arr_real->copyTo(&float_vec[0]); VLX_IMPORT_CHECK_RETURN(float_vec.size() == arr_real->value().size(), *val);
1357  uniform->setUniform2f(count, &float_vec[0]);
1358  break;
1359  case vl::UT_FLOAT_VEC3:
1360  float_vec.resize(count*3); arr_real->copyTo(&float_vec[0]); VLX_IMPORT_CHECK_RETURN(float_vec.size() == arr_real->value().size(), *val);
1361  uniform->setUniform3f(count, &float_vec[0]);
1362  break;
1363  case vl::UT_FLOAT_VEC4:
1364  float_vec.resize(count*4); arr_real->copyTo(&float_vec[0]); VLX_IMPORT_CHECK_RETURN(float_vec.size() == arr_real->value().size(), *val);
1365  uniform->setUniform4f(count, &float_vec[0]);
1366  break;
1367 
1368  case vl::UT_FLOAT_MAT2:
1369  float_vec.resize(count*2*2); arr_real->copyTo(&float_vec[0]); VLX_IMPORT_CHECK_RETURN(float_vec.size() == arr_real->value().size(), *val);
1370  uniform->setUniformMatrix2f(count, &float_vec[0]);
1371  break;
1372  case vl::UT_FLOAT_MAT3:
1373  float_vec.resize(count*3*3); arr_real->copyTo(&float_vec[0]); VLX_IMPORT_CHECK_RETURN(float_vec.size() == arr_real->value().size(), *val);
1374  uniform->setUniformMatrix3f(count, &float_vec[0]);
1375  break;
1376  case vl::UT_FLOAT_MAT4:
1377  float_vec.resize(count*4*4); arr_real->copyTo(&float_vec[0]); VLX_IMPORT_CHECK_RETURN(float_vec.size() == arr_real->value().size(), *val);
1378  uniform->setUniformMatrix4f(count, &float_vec[0]);
1379  break;
1380 
1381  case vl::UT_FLOAT_MAT2x3:
1382  float_vec.resize(count*2*3); arr_real->copyTo(&float_vec[0]); VLX_IMPORT_CHECK_RETURN(float_vec.size() == arr_real->value().size(), *val);
1383  uniform->setUniformMatrix2x3f(count, &float_vec[0]);
1384  break;
1385  case vl::UT_FLOAT_MAT3x2:
1386  float_vec.resize(count*3*2); arr_real->copyTo(&float_vec[0]); VLX_IMPORT_CHECK_RETURN(float_vec.size() == arr_real->value().size(), *val);
1387  uniform->setUniformMatrix3x2f(count, &float_vec[0]);
1388  break;
1389  case vl::UT_FLOAT_MAT2x4:
1390  float_vec.resize(count*2*4); arr_real->copyTo(&float_vec[0]); VLX_IMPORT_CHECK_RETURN(float_vec.size() == arr_real->value().size(), *val);
1391  uniform->setUniformMatrix2x4f(count, &float_vec[0]);
1392  break;
1393  case vl::UT_FLOAT_MAT4x2:
1394  float_vec.resize(count*4*2); arr_real->copyTo(&float_vec[0]); VLX_IMPORT_CHECK_RETURN(float_vec.size() == arr_real->value().size(), *val);
1395  uniform->setUniformMatrix4x2f(count, &float_vec[0]);
1396  break;
1397  case vl::UT_FLOAT_MAT3x4:
1398  float_vec.resize(count*3*4); arr_real->copyTo(&float_vec[0]); VLX_IMPORT_CHECK_RETURN(float_vec.size() == arr_real->value().size(), *val);
1399  uniform->setUniformMatrix3x4f(count, &float_vec[0]);
1400  break;
1401  case vl::UT_FLOAT_MAT4x3:
1402  float_vec.resize(count*4*3); arr_real->copyTo(&float_vec[0]); VLX_IMPORT_CHECK_RETURN(float_vec.size() == arr_real->value().size(), *val);
1403  uniform->setUniformMatrix4x3f(count, &float_vec[0]);
1404  break;
1405 
1406  case vl::UT_DOUBLE:
1407  double_vec.resize(count*1); if (arr_real) arr_real->copyTo(&double_vec[0]); else double_vec[0] = (double)val->getReal();
1408  uniform->setUniform1d(count, &double_vec[0]);
1409  break;
1410  case vl::UT_DOUBLE_VEC2:
1411  double_vec.resize(count*2); arr_real->copyTo(&double_vec[0]); VLX_IMPORT_CHECK_RETURN(double_vec.size() == arr_real->value().size(), *val);
1412  uniform->setUniform2d(count, &double_vec[0]);
1413  break;
1414  case vl::UT_DOUBLE_VEC3:
1415  double_vec.resize(count*3); arr_real->copyTo(&double_vec[0]); VLX_IMPORT_CHECK_RETURN(double_vec.size() == arr_real->value().size(), *val);
1416  uniform->setUniform3d(count, &double_vec[0]);
1417  break;
1418  case vl::UT_DOUBLE_VEC4:
1419  double_vec.resize(count*4); arr_real->copyTo(&double_vec[0]); VLX_IMPORT_CHECK_RETURN(double_vec.size() == arr_real->value().size(), *val);
1420  uniform->setUniform4d(count, &double_vec[0]);
1421  break;
1422 
1423  case vl::UT_DOUBLE_MAT2:
1424  double_vec.resize(count*2*2); arr_real->copyTo(&double_vec[0]); VLX_IMPORT_CHECK_RETURN(double_vec.size() == arr_real->value().size(), *val);
1425  uniform->setUniformMatrix2d(count, &double_vec[0]);
1426  break;
1427  case vl::UT_DOUBLE_MAT3:
1428  double_vec.resize(count*3*3); arr_real->copyTo(&double_vec[0]); VLX_IMPORT_CHECK_RETURN(double_vec.size() == arr_real->value().size(), *val);
1429  uniform->setUniformMatrix3d(count, &double_vec[0]);
1430  break;
1431  case vl::UT_DOUBLE_MAT4:
1432  double_vec.resize(count*4*4); arr_real->copyTo(&double_vec[0]); VLX_IMPORT_CHECK_RETURN(double_vec.size() == arr_real->value().size(), *val);
1433  uniform->setUniformMatrix4d(count, &double_vec[0]);
1434  break;
1435 
1436  case vl::UT_DOUBLE_MAT2x3:
1437  double_vec.resize(count*2*3); arr_real->copyTo(&double_vec[0]); VLX_IMPORT_CHECK_RETURN(double_vec.size() == arr_real->value().size(), *val);
1438  uniform->setUniformMatrix2x3d(count, &double_vec[0]);
1439  break;
1440  case vl::UT_DOUBLE_MAT3x2:
1441  double_vec.resize(count*3*2); arr_real->copyTo(&double_vec[0]); VLX_IMPORT_CHECK_RETURN(double_vec.size() == arr_real->value().size(), *val);
1442  uniform->setUniformMatrix3x2d(count, &double_vec[0]);
1443  break;
1444  case vl::UT_DOUBLE_MAT2x4:
1445  double_vec.resize(count*2*4); arr_real->copyTo(&double_vec[0]); VLX_IMPORT_CHECK_RETURN(double_vec.size() == arr_real->value().size(), *val);
1446  uniform->setUniformMatrix2x4d(count, &double_vec[0]);
1447  break;
1448  case vl::UT_DOUBLE_MAT4x2:
1449  double_vec.resize(count*4*2); arr_real->copyTo(&double_vec[0]); VLX_IMPORT_CHECK_RETURN(double_vec.size() == arr_real->value().size(), *val);
1450  uniform->setUniformMatrix4x2d(count, &double_vec[0]);
1451  break;
1452  case vl::UT_DOUBLE_MAT3x4:
1453  double_vec.resize(count*3*4); arr_real->copyTo(&double_vec[0]); VLX_IMPORT_CHECK_RETURN(double_vec.size() == arr_real->value().size(), *val);
1454  uniform->setUniformMatrix3x4d(count, &double_vec[0]);
1455  break;
1456  case vl::UT_DOUBLE_MAT4x3:
1457  double_vec.resize(count*4*3); arr_real->copyTo(&double_vec[0]); VLX_IMPORT_CHECK_RETURN(double_vec.size() == arr_real->value().size(), *val);
1458  uniform->setUniformMatrix4x3d(count, &double_vec[0]);
1459  break;
1460 
1461  case vl::UT_NONE:
1462  vl::Log::error( vl::Say("Error importing uniform : uninitialized uniform (%s).\n") << uniform->name() );
1463  break;
1464 
1465  default:
1466  vl::Log::error( vl::Say("Error importing uniform : illegal uniform type (%s).\n") << uniform->name() );
1467  break;
1468  }
1469 
1470  }
1471 
1473  {
1475  // register imported structure asap
1476  s.registerImportedStructure(vlx, obj.get());
1477  importUniform(s, vlx, obj.get());
1478  return obj;
1479  }
1480 
1481  void exportUniform(const vl::Uniform* uniform, VLXStructure* vlx)
1482  {
1483  *vlx << "Name" << vlx_Identifier(uniform->name());
1484  *vlx << "Type" << vlx_Identifier(vlx_EUniformType(uniform->type()));
1485  *vlx << "Count" << (long long)uniform->count();
1486 
1487  const int count = uniform->count();
1489  vl::ref<VLXArrayReal> arr_real = new VLXArrayReal;
1490 
1491  switch(uniform->type())
1492  {
1493  case vl::UT_INT:
1494  {
1495  if (count == 1)
1496  { int val = 0; uniform->getUniform(&val); *vlx << "Data" << (long long)val; break; }
1497  else
1498  { arr_int->value().resize(count*1); arr_int->copyFrom( (int*)uniform->rawData() ); break; }
1499  }
1500  case vl::UT_INT_VEC2: arr_int->value().resize(count*2); arr_int->copyFrom( (int*)uniform->rawData() ); break;
1501  case vl::UT_INT_VEC3: arr_int->value().resize(count*3); arr_int->copyFrom( (int*)uniform->rawData() ); break;
1502  case vl::UT_INT_VEC4: arr_int->value().resize(count*4); arr_int->copyFrom( (int*)uniform->rawData() ); break;
1503 
1504  case vl::UT_UNSIGNED_INT:
1505  {
1506  if (count == 1)
1507  { unsigned int val = 0; uniform->getUniform(&val); *vlx << "Data" << (long long)val; break; }
1508  else
1509  { arr_int->value().resize(count*1); arr_int->copyFrom( (int*)uniform->rawData() ); break; }
1510  }
1511  case vl::UT_UNSIGNED_INT_VEC2: arr_int->value().resize(count*2); arr_int->copyFrom( (int*)uniform->rawData() ); break;
1512  case vl::UT_UNSIGNED_INT_VEC3: arr_int->value().resize(count*3); arr_int->copyFrom( (int*)uniform->rawData() ); break;
1513  case vl::UT_UNSIGNED_INT_VEC4: arr_int->value().resize(count*4); arr_int->copyFrom( (int*)uniform->rawData() ); break;
1514 
1515  case vl::UT_FLOAT:
1516  {
1517  if (count == 1)
1518  { float val = 0; uniform->getUniform(&val); *vlx << "Data" << (double)val; break; }
1519  else
1520  { arr_real->value().resize(count*1); arr_real->copyFrom( (float*)uniform->rawData() ); break; }
1521  }
1522  case vl::UT_FLOAT_VEC2: arr_real->value().resize(count*2); arr_real->copyFrom( (float*)uniform->rawData() ); break;
1523  case vl::UT_FLOAT_VEC3: arr_real->value().resize(count*3); arr_real->copyFrom( (float*)uniform->rawData() ); break;
1524  case vl::UT_FLOAT_VEC4: arr_real->value().resize(count*4); arr_real->copyFrom( (float*)uniform->rawData() ); break;
1525 
1526  case vl::UT_FLOAT_MAT2: arr_real->value().resize(count*2*2); arr_real->copyFrom( (float*)uniform->rawData() ); break;
1527  case vl::UT_FLOAT_MAT3: arr_real->value().resize(count*3*3); arr_real->copyFrom( (float*)uniform->rawData() ); break;
1528  case vl::UT_FLOAT_MAT4: arr_real->value().resize(count*4*4); arr_real->copyFrom( (float*)uniform->rawData() ); break;
1529 
1530  case vl::UT_FLOAT_MAT2x3: arr_real->value().resize(count*2*3); arr_real->copyFrom( (float*)uniform->rawData() ); break;
1531  case vl::UT_FLOAT_MAT3x2: arr_real->value().resize(count*3*2); arr_real->copyFrom( (float*)uniform->rawData() ); break;
1532  case vl::UT_FLOAT_MAT2x4: arr_real->value().resize(count*2*4); arr_real->copyFrom( (float*)uniform->rawData() ); break;
1533  case vl::UT_FLOAT_MAT4x2: arr_real->value().resize(count*4*2); arr_real->copyFrom( (float*)uniform->rawData() ); break;
1534  case vl::UT_FLOAT_MAT3x4: arr_real->value().resize(count*3*4); arr_real->copyFrom( (float*)uniform->rawData() ); break;
1535  case vl::UT_FLOAT_MAT4x3: arr_real->value().resize(count*4*3); arr_real->copyFrom( (float*)uniform->rawData() ); break;
1536 
1537  case vl::UT_DOUBLE:
1538  {
1539  if (count == 1)
1540  { double val = 0; uniform->getUniform(&val); *vlx << "Data" << (double)val; break; }
1541  else
1542  { arr_real->value().resize(count*1); arr_real->copyFrom( (double*)uniform->rawData() ); break; }
1543  }
1544  case vl::UT_DOUBLE_VEC2: arr_real->value().resize(count*2); arr_real->copyFrom( (double*)uniform->rawData() ); break;
1545  case vl::UT_DOUBLE_VEC3: arr_real->value().resize(count*3); arr_real->copyFrom( (double*)uniform->rawData() ); break;
1546  case vl::UT_DOUBLE_VEC4: arr_real->value().resize(count*4); arr_real->copyFrom( (double*)uniform->rawData() ); break;
1547 
1548  case vl::UT_DOUBLE_MAT2: arr_real->value().resize(count*2*2); arr_real->copyFrom( (double*)uniform->rawData() ); break;
1549  case vl::UT_DOUBLE_MAT3: arr_real->value().resize(count*3*3); arr_real->copyFrom( (double*)uniform->rawData() ); break;
1550  case vl::UT_DOUBLE_MAT4: arr_real->value().resize(count*4*4); arr_real->copyFrom( (double*)uniform->rawData() ); break;
1551 
1552  case vl::UT_DOUBLE_MAT2x3: arr_real->value().resize(count*2*3); arr_real->copyFrom( (double*)uniform->rawData() ); break;
1553  case vl::UT_DOUBLE_MAT3x2: arr_real->value().resize(count*3*2); arr_real->copyFrom( (double*)uniform->rawData() ); break;
1554  case vl::UT_DOUBLE_MAT2x4: arr_real->value().resize(count*2*4); arr_real->copyFrom( (double*)uniform->rawData() ); break;
1555  case vl::UT_DOUBLE_MAT4x2: arr_real->value().resize(count*4*2); arr_real->copyFrom( (double*)uniform->rawData() ); break;
1556  case vl::UT_DOUBLE_MAT3x4: arr_real->value().resize(count*3*4); arr_real->copyFrom( (double*)uniform->rawData() ); break;
1557  case vl::UT_DOUBLE_MAT4x3: arr_real->value().resize(count*4*3); arr_real->copyFrom( (double*)uniform->rawData() ); break;
1558 
1559  case vl::UT_NONE:
1560  vl::Log::error( vl::Say("Error exporting uniform : uninitialized uniform (%s).\n") << uniform->name() );
1561  break;
1562 
1563  default:
1564  vl::Log::error( vl::Say("Error exporting uniform : illegal uniform type (%s).\n") << uniform->name() );
1565  break;
1566  }
1567 
1568  if (!arr_int->value().empty())
1569  *vlx << "Data" << arr_int.get();
1570  else
1571  if (!arr_real->value().empty())
1572  *vlx << "Data" << arr_real.get();
1573  }
1574 
1576  {
1577  const vl::Uniform* cast_obj = obj->as<vl::Uniform>(); VL_CHECK(cast_obj)
1578  vl::ref<VLXStructure> vlx = new VLXStructure(vlx_makeTag(obj).c_str(), s.generateID("uniform_"));
1579  // register exported object asap
1580  s.registerExportedObject(obj, vlx.get());
1581  exportUniform(cast_obj, vlx.get());
1582  return vlx;
1583  }
1584  };
1585 
1586  //---------------------------------------------------------------------------
1587 
1590  {
1592  {
1593  const VLXValue* name = vlx->getValue("ObjectName");
1594  if (name)
1595  sh->setObjectName( name->getString() );
1596 
1597  // enables
1598  const VLXValue* enables = vlx->getValue("Enables");
1599  if (enables)
1600  {
1601  VLX_IMPORT_CHECK_RETURN( enables->type() == VLXValue::List, *enables )
1602  const VLXList* list = enables->getList();
1603  for(size_t i=0; i<list->value().size(); ++i)
1604  {
1605  VLX_IMPORT_CHECK_RETURN( list->value()[i].type() == VLXValue::Identifier, list->value()[i] );
1606  vl::EEnable en = vlx_EEnable( list->value()[i], s );
1607  VLX_IMPORT_CHECK_RETURN( en != vl::EN_UnknownEnable, list->value()[i] );
1608  sh->enable(en);
1609  }
1610  }
1611 
1612  // render states
1613  const VLXValue* renderstates = vlx->getValue("RenderStates");
1614  if (renderstates)
1615  {
1616  VLX_IMPORT_CHECK_RETURN( renderstates->type() == VLXValue::List, *renderstates )
1617  const VLXList* list = renderstates->getList();
1618  int index = -1;
1619  for(size_t i=0; i<list->value().size(); ++i)
1620  {
1621  VLX_IMPORT_CHECK_RETURN( list->value()[i].type() == VLXValue::Structure || list->value()[i].type() == VLXValue::Integer, list->value()[i] );
1622  if (list->value()[i].type() == VLXValue::Integer)
1623  {
1624  VLX_IMPORT_CHECK_RETURN( index == -1, list->value()[i] );
1625  index = (int)list->value()[i].getInteger();
1626  }
1627  else
1628  {
1629  vl::RenderState* renderstate = s.importVLX( list->value()[i].getStructure() )->as<vl::RenderState>();
1630  VLX_IMPORT_CHECK_RETURN( renderstate != NULL, list->value()[i] )
1631  VLX_IMPORT_CHECK_RETURN( (index == -1 && !renderstate->isOfType(vl::RenderStateIndexed::Type())) || (index >= 0 && renderstate->isOfType(vl::RenderStateIndexed::Type())), list->value()[i] )
1632  sh->setRenderState(renderstate, index);
1633  // consume index in any case
1634  index = -1;
1635  }
1636  }
1637  }
1638 
1639  // uniforms
1640  const VLXValue* uniforms = vlx->getValue("Uniforms");
1641  if (uniforms)
1642  {
1643  VLX_IMPORT_CHECK_RETURN( uniforms->type() == VLXValue::List, *uniforms )
1644  const VLXList* list = uniforms->getList();
1645  for(size_t i=0; i<list->value().size(); ++i)
1646  {
1647  VLX_IMPORT_CHECK_RETURN( list->value()[i].type() == VLXValue::Structure, list->value()[i] );
1648  vl::Uniform* uniform = s.importVLX( list->value()[i].getStructure() )->as<vl::Uniform>();
1649  VLX_IMPORT_CHECK_RETURN( uniform != NULL, list->value()[i] )
1650  sh->setUniform(uniform);
1651  }
1652  }
1653  }
1654 
1656  {
1657  vl::ref<vl::Shader> obj = new vl::Shader;
1658  // register imported structure asap
1659  s.registerImportedStructure(vlx, obj.get());
1660  importShader(s, vlx, obj.get());
1661  return obj;
1662  }
1663 
1665  {
1666  if (!obj->objectName().empty() && obj->objectName() != obj->className())
1667  *vlx << "ObjectName" << vlx_String(obj->objectName());
1668 
1669  // uniforms
1670  VLXValue uniforms;
1671  uniforms.setList( new VLXList );
1672  if (obj->getUniformSet())
1673  {
1674  for(size_t i=0; i<obj->uniforms().size(); ++i)
1675  *uniforms.getList() << s.exportVLX(obj->uniforms()[i].get());
1676  }
1677  *vlx << "Uniforms" << uniforms;
1678 
1679  // enables
1680  vl::ref<VLXList> enables = new VLXList;
1681  if (obj->getEnableSet() )
1682  {
1683  for(size_t i=0; i<obj->getEnableSet()->enables().size(); ++i)
1684  *enables << vlx_Identifier(vlx_EEnable(obj->getEnableSet()->enables()[i]));
1685  }
1686  *vlx << "Enables" << enables.get();
1687 
1688  // renderstates
1689  VLXValue renderstates;
1690  renderstates.setList( new VLXList );
1691  if (obj->getRenderStateSet())
1692  {
1693  for(size_t i=0; i<obj->getRenderStateSet()->renderStatesCount(); ++i)
1694  {
1695  const vl::RenderState* rs = obj->getRenderStateSet()->renderStates()[i].mRS.get();
1696  if ( !s.canExport(rs) )
1697  {
1698  vl::Log::debug( vl::Say("VLXClassWrapper_Shader : skipping '%s'.\n") << rs->className() );
1699  continue;
1700  }
1701  int index = obj->getRenderStateSet()->renderStates()[i].mIndex;
1702  if (index != -1)
1703  *renderstates.getList() << (long long)index;
1704  *renderstates.getList() << s.exportVLX(rs);
1705  }
1706  }
1707  *vlx << "RenderStates" << renderstates;
1708  }
1709 
1711  {
1712  const vl::Shader* cast_obj = obj->as<vl::Shader>(); VL_CHECK(cast_obj)
1713  vl::ref<VLXStructure> vlx = new VLXStructure(vlx_makeTag(obj).c_str(), s.generateID("shader_"));
1714  // register exported object asap
1715  s.registerExportedObject(obj, vlx.get());
1716  exportShader(s, cast_obj, vlx.get());
1717  return vlx;
1718  }
1719  };
1720 
1721  //---------------------------------------------------------------------------
1722 
1725  {
1727  {
1728  if (obj->isOfType(vl::DistanceLODEvaluator::Type()))
1729  {
1731  const VLXValue* vlx_distances = vlx->getValue("DistanceRageSet");
1732  VLX_IMPORT_CHECK_RETURN( vlx_distances != NULL, *vlx );
1733  VLX_IMPORT_CHECK_RETURN( vlx_distances->type() == VLXValue::ArrayReal, *vlx_distances );
1734  const VLXArrayReal* arr = vlx_distances->getArrayReal();
1735  if (arr->value().size())
1736  {
1737  lod->distanceRangeSet().resize( arr->value().size() );
1738  arr->copyTo( &lod->distanceRangeSet()[0] );
1739  }
1740  }
1741  else
1742  if (obj->isOfType(vl::PixelLODEvaluator::Type()))
1743  {
1745  const VLXValue* vlx_pixels = vlx->getValue("PixelRageSet");
1746  VLX_IMPORT_CHECK_RETURN( vlx_pixels != NULL, *vlx );
1747  VLX_IMPORT_CHECK_RETURN( vlx_pixels->type() == VLXValue::ArrayReal, *vlx_pixels );
1748  const VLXArrayReal* arr = vlx_pixels->getArrayReal();
1749  if (arr->value().size())
1750  {
1751  lod->pixelRangeSet().resize( arr->value().size() );
1752  arr->copyTo( &lod->pixelRangeSet()[0] );
1753  }
1754  }
1755  }
1756 
1758  {
1759  if (vlx->tag() == "<vl::DistanceLODEvaluator>")
1760  {
1762  // register imported structure asap
1763  s.registerImportedStructure(vlx, obj.get());
1764  importLODEvaluator(s, vlx, obj.get());
1765  return obj;
1766  }
1767  else
1768  if (vlx->tag() == "<vl::PixelLODEvaluator>")
1769  {
1771  // register imported structure asap
1772  s.registerImportedStructure(vlx, obj.get());
1773  importLODEvaluator(s, vlx, obj.get());
1774  return obj;
1775  }
1776  else
1777  {
1778  return NULL;
1779  }
1780  }
1781 
1783  {
1784  if (obj->classType() == vl::DistanceLODEvaluator::Type())
1785  {
1787  VLXValue distances( new VLXArrayReal );
1788  distances.getArrayReal()->value().resize( lod->distanceRangeSet().size() );
1789  if (lod->distanceRangeSet().size() != 0)
1790  distances.getArrayReal()->copyFrom( &lod->distanceRangeSet()[0] );
1791  *vlx << "DistanceRageSet" << distances;
1792  }
1793  else
1794  if (obj->classType() == vl::PixelLODEvaluator::Type())
1795  {
1796  const vl::PixelLODEvaluator* lod = obj->as<vl::PixelLODEvaluator>();
1797  VLXValue pixels( new VLXArrayReal );
1798  pixels.getArrayReal()->value().resize( lod->pixelRangeSet().size() );
1799  if (lod->pixelRangeSet().size() != 0)
1800  pixels.getArrayReal()->copyFrom( &lod->pixelRangeSet()[0] );
1801  *vlx << "PixelRageSet" << pixels;
1802  }
1803  else
1804  {
1805  s.signalExportError("vl::LODEvaluator type not supported for export.\n");
1806  }
1807  }
1808 
1810  {
1811  const vl::LODEvaluator* cast_obj = obj->as<vl::LODEvaluator>(); VL_CHECK(cast_obj)
1812  vl::ref<VLXStructure> vlx = new VLXStructure(vlx_makeTag(obj).c_str(), s.generateID("lodeval_"));
1813  // register exported object asap
1814  s.registerExportedObject(obj, vlx.get());
1815  exportLODEvaluator(s, cast_obj, vlx.get());
1816  return vlx;
1817  }
1818  };
1819 
1820  //---------------------------------------------------------------------------
1821 
1824  {
1826  {
1827  const VLXValue* name = vlx->getValue("ObjectName");
1828  if (name)
1829  obj->setObjectName( name->getString() );
1830 
1831  const std::vector<VLXStructure::KeyValue>& values = vlx->value();
1832  for(size_t i=0; i<values.size(); ++i)
1833  {
1834  const std::string& key = values[i].key();
1835  const VLXValue& value = values[i].value();
1836  if (key == "RenderRank")
1837  {
1838  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Integer, value )
1839  obj->setRenderRank( (int)value.getInteger() );
1840  }
1841  else
1842  if (key == "EnableMask")
1843  {
1844  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Integer, value )
1845  obj->setEnableMask( (int)value.getInteger() );
1846  }
1847  else
1848  if (key == "ActiveLod")
1849  {
1850  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Integer, value )
1851  obj->setActiveLod( (int)value.getInteger() );
1852  }
1853  else
1854  if (key == "LODEvaluator")
1855  {
1856  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Structure, value )
1857  vl::LODEvaluator* lod_eval = s.importVLX( value.getStructure() )->as<vl::LODEvaluator>();
1858  VLX_IMPORT_CHECK_RETURN( lod_eval, value )
1859  obj->setLODEvaluator(lod_eval);
1860  }
1861  else
1862  if (key == "Lods")
1863  {
1864  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::List, value )
1865  const VLXList* lod_list = value.getList();
1866  for(size_t ilod=0; ilod< lod_list->value().size(); ++ilod)
1867  {
1868  const VLXValue& lod_shaders = lod_list->value()[ilod];
1869  VLX_IMPORT_CHECK_RETURN( lod_shaders.type() == VLXValue::List, lod_shaders )
1870  obj->lod((int)ilod) = new vl::ShaderPasses;
1871  for( size_t ish=0; ish<lod_shaders.getList()->value().size(); ++ish)
1872  {
1873  const VLXValue& vlx_sh = lod_shaders.getList()->value()[ish];
1874  VLX_IMPORT_CHECK_RETURN( vlx_sh.type() == VLXValue::Structure, vlx_sh )
1875  vl::Shader* shader = s.importVLX( vlx_sh.getStructure() )->as<vl::Shader>();
1876  VLX_IMPORT_CHECK_RETURN( shader, vlx_sh )
1877  obj->lod((int)ilod)->push_back( shader );
1878  }
1879  }
1880  }
1881  }
1882  }
1883 
1885  {
1886  vl::ref<vl::Effect> obj = new vl::Effect;
1887  // register imported structure asap
1888  s.registerImportedStructure(vlx, obj.get());
1889  importEffect(s, vlx, obj.get());
1890  return obj;
1891  }
1892 
1894  {
1895  VLXValue value( new VLXList(vlx_makeTag(sh_seq).c_str()) );
1896  for(int i=0; i<sh_seq->size(); ++i)
1897  *value.getList() << s.exportVLX(sh_seq->at(i));
1898  return value;
1899  }
1900 
1902  {
1903  if (!obj->objectName().empty() && obj->objectName() != obj->className())
1904  *vlx << "ObjectName" << vlx_String(obj->objectName());
1905  *vlx << "RenderRank" << (long long)obj->renderRank();
1906  *vlx << "EnableMask" << (long long)obj->enableMask();
1907  *vlx << "ActiveLod" << (long long)obj->activeLod();
1908 
1909  if (obj->lodEvaluator())
1910  *vlx << "LODEvaluator" << s.exportVLX(obj->lodEvaluator());
1911 
1912  // shaders
1913  vl::ref<VLXList> lod_list = new VLXList;
1914  for(int i=0; obj->lod(i) && i<VL_MAX_EFFECT_LOD; ++i)
1915  *lod_list << export_ShaderPasses(s, obj->lod(i).get());
1916  *vlx << "Lods" << lod_list.get();
1917  }
1918 
1920  {
1921  const vl::Effect* cast_obj = obj->as<vl::Effect>(); VL_CHECK(cast_obj)
1922  vl::ref<VLXStructure> vlx = new VLXStructure(vlx_makeTag(obj).c_str(), s.generateID("effect_"));
1923  // register exported object asap
1924  s.registerExportedObject(obj, vlx.get());
1925  exportEffect(s, cast_obj, vlx.get());
1926  return vlx;
1927  }
1928  };
1929 
1930  //---------------------------------------------------------------------------
1931 
1934  {
1936  {
1937  const VLXValue* name = vlx->getValue("ObjectName");
1938  if (name)
1939  obj->setObjectName( name->getString() );
1940 
1941  const std::vector<VLXStructure::KeyValue>& values = vlx->value();
1942  for(size_t i=0; i<values.size(); ++i)
1943  {
1944  const std::string& key = values[i].key();
1945  const VLXValue& value = values[i].value();
1946  if (key == "RenderRank")
1947  {
1948  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Integer, value )
1949  obj->setRenderRank( (int)value.getInteger() );
1950  }
1951  else
1952  if (key == "RenderBlock")
1953  {
1954  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Integer, value )
1955  obj->setRenderBlock( (int)value.getInteger() );
1956  }
1957  else
1958  if (key == "EnableMask")
1959  {
1960  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Integer, value )
1961  obj->setEnableMask( (int)value.getInteger() );
1962  }
1963  else
1964  if (key == "IsOccludee")
1965  {
1966  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Bool, value )
1967  obj->setOccludee( value.getBool() );
1968  }
1969  else
1970  if (key == "Enabled")
1971  {
1972  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Bool, value )
1973  obj->setEnabled( value.getBool() );
1974  }
1975  else
1976  if (key == "Lods")
1977  {
1978  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::List, value )
1979  const VLXList* list = value.getList();
1980  for(size_t i=0; i<list->value().size(); ++i)
1981  {
1982  const VLXValue& lod = list->value()[i];
1984  vl::Renderable* rend = s.importVLX( lod.getStructure() )->as<vl::Renderable>();
1985  VLX_IMPORT_CHECK_RETURN( rend != NULL, lod )
1986  obj->setLod(i, rend);
1987  }
1988  }
1989  else
1990  if (key == "Effect")
1991  {
1992  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Structure, value )
1993  vl::Effect* fx = s.importVLX(value.getStructure())->as<vl::Effect>();
1994  VLX_IMPORT_CHECK_RETURN( fx != NULL, value )
1995  obj->setEffect(fx);
1996  }
1997  else
1998  if (key == "Transform")
1999  {
2000  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Structure, value )
2001  vl::Transform* tr = s.importVLX(value.getStructure())->as<vl::Transform>();
2002  VLX_IMPORT_CHECK_RETURN( tr != NULL, value )
2003  obj->setTransform(tr);
2004  }
2005  else
2006  if (key == "Uniforms")
2007  {
2008  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::List, value )
2009  const VLXList* list = value.getList();
2010  for(size_t i=0; i<list->value().size(); ++i)
2011  {
2012  VLX_IMPORT_CHECK_RETURN( list->value()[i].type() == VLXValue::Structure, list->value()[i] )
2013  vl::Uniform* uniform = s.importVLX( list->value()[i].getStructure() )->as<vl::Uniform>();
2014  VLX_IMPORT_CHECK_RETURN( uniform != NULL, list->value()[i] )
2015  obj->setUniform(uniform);
2016  }
2017  }
2018  // bounding volumes are not serialized, they are computed based on the geometry's bounds
2019  // else if (key == "AABB") {}
2020  // else if (key == "Sphere") {}
2021  else
2022  if (key == "LODEvaluator")
2023  {
2024  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Structure, value )
2025  if (s.canImport( value.getStructure() ) )
2026  {
2027  vl::LODEvaluator* lod = s.importVLX( value.getStructure() )->as<vl::LODEvaluator>();
2028  VLX_IMPORT_CHECK_RETURN( lod != NULL, value )
2029  obj->setLODEvaluator(lod);
2030  }
2031  }
2032  else
2033  if (key == "ActorEventCallbacks")
2034  {
2035  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::List, value )
2036  const VLXList* list = value.getList();
2037  for(size_t i=0; i<list->value().size(); ++i)
2038  {
2039  const VLXValue& elem = list->value()[i];
2041  if (s.canImport(elem.getStructure()))
2042  {
2043  vl::ActorEventCallback* cb = s.importVLX( elem.getStructure() )->as<vl::ActorEventCallback>();
2044  VLX_IMPORT_CHECK_RETURN( cb != NULL, elem )
2045  obj->actorEventCallbacks()->push_back(cb);
2046  }
2047  }
2048  }
2049  }
2050  }
2051 
2053  {
2054  vl::ref<vl::Actor> obj = new vl::Actor;
2055  // register imported structure asap
2056  s.registerImportedStructure(vlx, obj.get());
2057  importActor(s, vlx, obj.get());
2058  return obj;
2059  }
2060 
2062  {
2063  if (!obj->objectName().empty() && obj->objectName() != obj->className())
2064  *vlx << "ObjectName" << vlx_String(obj->objectName());
2065  *vlx << "EnableMask" << (long long)obj->enableMask();
2066  *vlx << "RenderBlock" << (long long)obj->renderBlock();
2067  *vlx << "RenderRank" << (long long)obj->renderRank();
2068  *vlx << "IsOccludee" << obj->isOccludee();
2069  *vlx << "Enabled" << obj->isEnabled();
2070 
2071  VLXValue renderables;
2072  renderables.setList( new VLXList );
2073  for(size_t i=0; i<VL_MAX_ACTOR_LOD && obj->lod(i); ++i)
2074  *renderables.getList() << s.exportVLX(obj->lod(i));
2075  *vlx << "Lods" << renderables;
2076 
2077  // bounding volumes are not serialized, they are computed based on the geometry's bounds
2078  // *vlx << "AABB" << export_AABB(obj->boundingBox());
2079  // *vlx << "Sphere" << export_Sphere(obj->boundingSphere());
2080 
2081  if (obj->effect())
2082  *vlx << "Effect" << s.exportVLX(obj->effect());
2083  if (obj->transform())
2084  *vlx << "Transform" << s.exportVLX(obj->transform());
2085 
2086  VLXValue uniforms;
2087  uniforms.setList( new VLXList );
2088  for(size_t i=0; obj->getUniformSet() && i<obj->uniforms().size(); ++i)
2089  *uniforms.getList() << s.exportVLX(obj->uniforms()[i].get());
2090  *vlx << "Uniforms" << uniforms;
2091 
2092  if (obj->lodEvaluator())
2093  *vlx << "LODEvaluator" << s.exportVLX(obj->lodEvaluator());
2094 
2095  // mic fixme:
2096  // Scissor: scissors might go away from the vl::Actor
2097 
2098  VLXValue callbacks;
2099  callbacks.setList( new VLXList );
2100  for(int i=0; i<obj->actorEventCallbacks()->size(); ++i)
2101  *callbacks.getList() << s.exportVLX(obj->actorEventCallbacks()->at(i));
2102  *vlx << "ActorEventCallbacks" << callbacks;
2103  }
2104 
2106  {
2107  const vl::Actor* cast_obj = obj->as<vl::Actor>(); VL_CHECK(cast_obj)
2108  vl::ref<VLXStructure> vlx = new VLXStructure(vlx_makeTag(obj).c_str(), s.generateID("actor_"));
2109  // register exported object asap
2110  s.registerExportedObject(obj, vlx.get());
2111  exportActor(s, cast_obj, vlx.get());
2112  return vlx;
2113  }
2114  };
2115 
2116  //---------------------------------------------------------------------------
2117 
2120  {
2122  {
2123  const VLXValue* name = vlx->getValue("ObjectName");
2124  if (name)
2125  obj->setObjectName( name->getString() );
2126 
2127  for(size_t i=0; i<vlx->value().size(); ++i)
2128  {
2129  const std::string& key = vlx->value()[i].key();
2130  const VLXValue& value = vlx->value()[i].value();
2131  if (key == "ViewMatrix")
2132  {
2133  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::List, value);
2134  obj->setViewMatrix( vlx_mat4(value.getList()) );
2135  // VLX_IMPORT_CHECK_RETURN( !obj->viewMatrix().isNull(), value )
2136  }
2137  else
2138  if (key == "ProjectionMatrix")
2139  {
2141  const VLXValue* pmtype = vlx->getValue("ProjectionMatrixType");
2142  if ( pmtype )
2143  {
2144  VLX_IMPORT_CHECK_RETURN( pmtype->type() == VLXValue::Identifier, *pmtype );
2145  ptype = vlx_EProjectionMatrixType( *pmtype, s );
2146  }
2147 
2148  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::List, value);
2149  obj->setProjectionMatrix( vlx_mat4(value.getList()), ptype );
2150  // VLX_IMPORT_CHECK_RETURN( !obj->projectionMatrix().isNull(), value )
2151  }
2152  else
2153  if (key == "Viewport")
2154  {
2156  vl::Viewport* viewp = s.importVLX( value.getStructure() )->as<vl::Viewport>();
2157  VLX_IMPORT_CHECK_RETURN( viewp != NULL, value )
2158  obj->setViewport(viewp);
2159  }
2160  else
2161  if (key == "FOV")
2162  {
2163  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Real, value )
2164  obj->setFOV( (float)value.getReal() );
2165  }
2166  else
2167  if (key == "NearPlane")
2168  {
2169  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Real, value )
2170  obj->setNearPlane( (float)value.getReal() );
2171  }
2172  else
2173  if (key == "FarPlane")
2174  {
2175  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Real, value )
2176  obj->setFarPlane( (float)value.getReal() );
2177  }
2178  else
2179  if (key == "Left")
2180  {
2181  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Real, value )
2182  obj->setLeft( (float)value.getReal() );
2183  }
2184  else
2185  if (key == "Right")
2186  {
2187  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Real, value )
2188  obj->setRight( (float)value.getReal() );
2189  }
2190  else
2191  if (key == "Bottom")
2192  {
2193  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Real, value )
2194  obj->setBottom( (float)value.getReal() );
2195  }
2196  else
2197  if (key == "Top")
2198  {
2199  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Real, value )
2200  obj->setTop( (float)value.getReal() );
2201  }
2202  else
2203  if (key == "BoundTransform")
2204  {
2206  vl::Transform* tr= s.importVLX( value.getStructure() )->as<vl::Transform>();
2207  VLX_IMPORT_CHECK_RETURN( tr != NULL, value )
2208  obj->bindTransform(tr);
2209  }
2210  }
2211  }
2212 
2214  {
2215  vl::ref<vl::Camera> obj = new vl::Camera;
2216  // register imported structure asap
2217  s.registerImportedStructure(vlx, obj.get());
2218  importCamera(s, vlx, obj.get());
2219  return obj;
2220  }
2221 
2223  {
2224  if (!obj->objectName().empty() && obj->objectName() != obj->className())
2225  *vlx << "ObjectName" << vlx_String(obj->objectName());
2226  *vlx << "ViewMatrix" << vlx_toValue(obj->viewMatrix());
2227  *vlx << "ProjectionMatrix" << vlx_toValue(obj->projectionMatrix());
2228  *vlx << "ProjectionMatrixType" << vlx_Identifier(vlx_EProjectionMatrixType(obj->projectionMatrixType()));
2229  *vlx << "Viewport" << s.exportVLX(obj->viewport());
2230  *vlx << "NearPlane" << (double)obj->nearPlane();
2231  *vlx << "FarPlane" << (double)obj->farPlane();
2232  *vlx << "FOV" << (double)obj->fov();
2233  *vlx << "Left" << (double)obj->left();
2234  *vlx << "Right" << (double)obj->right();
2235  *vlx << "Bottom" << (double)obj->bottom();
2236  *vlx << "Top" << (double)obj->top();
2237  if (obj->boundTransform())
2238  *vlx << "BoundTransfrm" << s.exportVLX(obj->boundTransform());
2239  }
2240 
2242  {
2243  const vl::Camera* cast_obj = obj->as<vl::Camera>(); VL_CHECK(cast_obj)
2244  vl::ref<VLXStructure> vlx = new VLXStructure(vlx_makeTag(obj).c_str(), s.generateID("camera_"));
2245  // register exported object asap
2246  s.registerExportedObject(obj, vlx.get());
2247  exportCamera(s, cast_obj, vlx.get());
2248  return vlx;
2249  }
2250  };
2251 
2252 
2253  //---------------------------------------------------------------------------
2254 
2257  {
2259  {
2260  const VLXValue* name = vlx->getValue("ObjectName");
2261  if (name)
2262  obj->setObjectName( name->getString() );
2263 
2264  for(size_t i=0; i<vlx->value().size(); ++i)
2265  {
2266  const std::string& key = vlx->value()[i].key();
2267  const VLXValue& value = vlx->value()[i].value();
2268  if (key == "ClearColor")
2269  {
2270  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::ArrayReal, value );
2271  obj->setClearColor( (vl::fvec4)vlx_vec4( value.getArrayReal() ) );
2272  }
2273  else
2274  if (key == "ClearColorInt")
2275  {
2277  obj->setClearColorInt( vlx_ivec4( value.getArrayInteger() ) );
2278  }
2279  else
2280  if (key == "ClearColorUInt")
2281  {
2283  obj->setClearColorUInt( vlx_uivec4( value.getArrayInteger() ) );
2284  }
2285  else
2286  if (key == "ClearDepth")
2287  {
2288  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Real, value );
2289  obj->setClearDepth( (float)value.getReal() );
2290  }
2291  else
2292  if (key == "ClearStecil")
2293  {
2294  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Integer, value );
2295  obj->setClearStencil( (int)value.getInteger() );
2296  }
2297  else
2298  if (key == "ClearColorMode")
2299  {
2300  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Identifier, value );
2301  obj->setClearColorMode( vlx_EClearColorMode( value, s) );
2302  }
2303  else
2304  if (key == "ClearFlags")
2305  {
2306  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Identifier, value );
2307  obj->setClearFlags( vlx_EClearFlags( value, s ) );
2308  }
2309  else
2310  if (key == "X")
2311  {
2312  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Integer, value );
2313  obj->setX( (int)value.getInteger() );
2314  }
2315  else
2316  if (key == "Y")
2317  {
2318  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Integer, value );
2319  obj->setY( (int)value.getInteger() );
2320  }
2321  else
2322  if (key == "Width")
2323  {
2324  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Integer, value );
2325  obj->setWidth( (int)value.getInteger() );
2326  }
2327  else
2328  if (key == "Height")
2329  {
2330  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Integer, value );
2331  obj->setHeight( (int)value.getInteger() );
2332  }
2333  }
2334  }
2335 
2337  {
2339  // register imported structure asap
2340  s.registerImportedStructure(vlx, obj.get());
2341  importViewport(s, vlx, obj.get());
2342  return obj;
2343  }
2344 
2346  {
2347  if (!obj->objectName().empty() && obj->objectName() != obj->className())
2348  *vlx << "ObjectName" << vlx_String(obj->objectName());
2349  *vlx << "ClearColor" << vlx_toValue((vl::vec4)obj->clearColor());
2350  *vlx << "ClearColorInt" << vlx_toValue(obj->clearColorInt());
2351  *vlx << "ClearColorUInt" << vlx_toValue(obj->clearColorUInt());
2352  *vlx << "ClearDepth" << (double)obj->clearDepth();
2353  *vlx << "ClearStecil" << (long long)obj->clearStencil();
2354  *vlx << "ClearColorMode" << vlx_Identifier(vlx_EClearColorMode(obj->clearColorMode()));
2355  *vlx << "ClearFlags" << vlx_Identifier(vlx_EClearFlags(obj->clearFlags()));
2356  *vlx << "X" << (long long)obj->x();
2357  *vlx << "Y" << (long long)obj->y();
2358  *vlx << "Width" << (long long)obj->width();
2359  *vlx << "Height" << (long long)obj->height();
2360  }
2361 
2363  {
2364  const vl::Viewport* cast_obj = obj->as<vl::Viewport>(); VL_CHECK(cast_obj)
2365  vl::ref<VLXStructure> vlx = new VLXStructure(vlx_makeTag(obj).c_str(), s.generateID("viewport_"));
2366  // register exported object asap
2367  s.registerExportedObject(obj, vlx.get());
2368  exportViewport(cast_obj, vlx.get());
2369  return vlx;
2370  }
2371  };
2372 
2373  //---------------------------------------------------------------------------
2374 
2377  {
2379  {
2380  const VLXValue* name = vlx->getValue("ObjectName");
2381  if (name)
2382  obj->setObjectName( name->getString() );
2383 
2384  for(size_t i=0; i<vlx->value().size(); ++i)
2385  {
2386  const std::string& key = vlx->value()[i].key();
2387  const VLXValue& value = vlx->value()[i].value();
2388  if (key == "LocalMatrix")
2389  {
2390  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::List, value )
2391  obj->setLocalAndWorldMatrix( vlx_mat4( value.getList() ) );
2392  }
2393  else
2394  // let the "Children" property take care of children binding
2395  /*
2396  if (key == "Parent")
2397  {
2398  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Structure, value )
2399  vl::Transform* tr = s.importVLX( value.getStructure() )->as<vl::Transform>();
2400  VLX_IMPORT_CHECK_RETURN( tr != NULL, value )
2401  tr->addChild(obj);
2402  }
2403  else
2404  */
2405  if (key == "Children")
2406  {
2407  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::List, value )
2408  const VLXList* list = value.getList();
2409  for(size_t ich=0; ich<list->value().size(); ++ich)
2410  {
2411  VLX_IMPORT_CHECK_RETURN( list->value()[ich].type() == VLXValue::Structure, list->value()[ich] )
2412  const VLXStructure* vlx_tr = list->value()[ich].getStructure();
2413  vl::Transform* child = s.importVLX( vlx_tr )->as<vl::Transform>();
2414  VLX_IMPORT_CHECK_RETURN( child != NULL, *vlx_tr )
2415  obj->addChild(child);
2416  }
2417  }
2418  }
2419  }
2420 
2422  {
2424  // register imported structure asap
2425  s.registerImportedStructure(vlx, obj.get());
2426  importTransform(s, vlx, obj.get());
2427  return obj;
2428  }
2429 
2431  {
2432  if (!obj->objectName().empty() && obj->objectName() != obj->className())
2433  *vlx << "ObjectName" << vlx_String(obj->objectName());
2434  *vlx << "LocalMatrix" << vlx_toValue(obj->localMatrix());
2435 
2436  // not needed
2437  /*if (obj->parent())
2438  *vlx << "Parent" << s.exportVLX(obj->parent());*/
2439 
2440  VLXValue childs;
2441  childs.setList( new VLXList );
2442  for(size_t i=0; i<obj->childrenCount(); ++i)
2443  childs.getList()->value().push_back( s.exportVLX(obj->children()[i].get()) );
2444  *vlx << "Children" << childs;
2445  }
2446 
2448  {
2449  const vl::Transform* cast_obj = obj->as<vl::Transform>(); VL_CHECK(cast_obj)
2450  vl::ref<VLXStructure> vlx = new VLXStructure(vlx_makeTag(obj).c_str(), s.generateID("transform_"));
2451  // register exported object asap
2452  s.registerExportedObject(obj, vlx.get());
2453  exportTransform(s, cast_obj, vlx.get());
2454  return vlx;
2455  }
2456  };
2457 
2458  //---------------------------------------------------------------------------
2459 
2462  {
2464  {
2465  const VLXValue* name = vlx->getValue("ObjectName");
2466  if (name)
2467  obj->setObjectName( name->getString() );
2468 
2469  for(size_t i=0; i<vlx->value().size(); ++i)
2470  {
2471  const std::string& key = vlx->value()[i].key();
2472  const VLXValue& value = vlx->value()[i].value();
2473  if (key == "Ambient")
2474  {
2475  // note: what if the user specifies ( 1 0 0 0 ) -> becomes a ArrayInteger and an error is issued.
2476  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::ArrayReal, value )
2477  obj->setAmbient( (vl::fvec4)vlx_vec4( value.getArrayReal() ) );
2478  }
2479  else
2480  if (key == "Diffuse")
2481  {
2482  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::ArrayReal, value )
2483  obj->setDiffuse( (vl::fvec4)vlx_vec4( value.getArrayReal() ) );
2484  }
2485  else
2486  if (key == "Specular")
2487  {
2488  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::ArrayReal, value )
2489  obj->setSpecular( (vl::fvec4)vlx_vec4( value.getArrayReal() ) );
2490  }
2491  else
2492  if (key == "Position")
2493  {
2494  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::ArrayReal, value )
2495  obj->setPosition( (vl::fvec4)vlx_vec4( value.getArrayReal() ) );
2496  }
2497  else
2498  if (key == "SpotDirection")
2499  {
2500  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::ArrayReal, value )
2501  obj->setSpotDirection( (vl::fvec3)vlx_vec3( value.getArrayReal() ) );
2502  }
2503  else
2504  if (key == "SpotExponent")
2505  {
2506  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Real, value )
2507  obj->setSpotExponent( (float)value.getReal() );
2508  }
2509  else
2510  if (key == "SpotCutoff")
2511  {
2512  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Real, value )
2513  obj->setSpotCutoff( (float)value.getReal() );
2514  }
2515  else
2516  if (key == "ConstantAttenuation")
2517  {
2518  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Real, value )
2519  obj->setConstantAttenuation( (float)value.getReal() );
2520  }
2521  else
2522  if (key == "LinearAttenuation")
2523  {
2524  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Real, value )
2525  obj->setLinearAttenuation( (float)value.getReal() );
2526  }
2527  else
2528  if (key == "QuadraticAttenuation")
2529  {
2530  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Real, value )
2531  obj->setQuadraticAttenuation( (float)value.getReal() );
2532  }
2533  else
2534  if (key == "BoundTransform")
2535  {
2537  vl::Transform* tr= s.importVLX( value.getStructure() )->as<vl::Transform>();
2538  VLX_IMPORT_CHECK_RETURN( tr != NULL, value )
2539  obj->bindTransform(tr);
2540  }
2541  }
2542  }
2543 
2545  {
2546  vl::ref<vl::Light> obj = new vl::Light;
2547  // register imported structure asap
2548  s.registerImportedStructure(vlx, obj.get());
2549  importLight(s, vlx, obj.get());
2550  return obj;
2551  }
2552 
2554  {
2555  if (!obj->objectName().empty() && obj->objectName() != obj->className())
2556  *vlx << "ObjectName" << vlx_String(obj->objectName());
2557  *vlx << "Ambient" << vlx_toValue((vl::vec4)obj->ambient());
2558  *vlx << "Diffuse" << vlx_toValue((vl::vec4)obj->diffuse());
2559  *vlx << "Specular" << vlx_toValue((vl::vec4)obj->specular());
2560  *vlx << "Position" << vlx_toValue((vl::vec4)obj->position());
2561  *vlx << "SpotDirection" << vlx_toValue((vl::vec3)obj->spotDirection());
2562  *vlx << "SpotExponent" << obj->spotExponent();
2563  *vlx << "SpotCutoff" << obj->spotCutoff();
2564  *vlx << "ConstantAttenuation" << obj->constantAttenuation();
2565  *vlx << "LinearAttenuation" << obj->linearAttenuation();
2566  *vlx << "QuadraticAttenuation" << obj->quadraticAttenuation();
2567  if (obj->boundTransform())
2568  *vlx << "BoundTransform" << s.exportVLX(obj->boundTransform());
2569  }
2570 
2572  {
2573  const vl::Light* cast_obj = obj->as<vl::Light>(); VL_CHECK(cast_obj)
2574  vl::ref<VLXStructure> vlx = new VLXStructure(vlx_makeTag(obj).c_str(), s.generateID("light_"));
2575  // register exported object asap
2576  s.registerExportedObject(obj, vlx.get());
2577  exportLight(s, cast_obj, vlx.get());
2578  return vlx;
2579  }
2580  };
2581 
2582  //---------------------------------------------------------------------------
2583 
2586  {
2588  {
2589  for(size_t i=0; i<vlx->value().size(); ++i)
2590  {
2591  const std::string& key = vlx->value()[i].key();
2592  const VLXValue& value = vlx->value()[i].value();
2593  if (key == "PlaneNormal")
2594  {
2595  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::ArrayReal, value )
2596  obj->plane().setNormal( vlx_vec3( value.getArrayReal() ) );
2597  }
2598  else
2599  if (key == "PlaneOrigin")
2600  {
2601  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Real, value )
2602  obj->plane().setOrigin( (float)value.getReal() );
2603  }
2604  else
2605  if (key == "BoundTransform")
2606  {
2608  vl::Transform* tr= s.importVLX( value.getStructure() )->as<vl::Transform>();
2609  VLX_IMPORT_CHECK_RETURN( tr != NULL, value )
2610  obj->bindTransform(tr);
2611  }
2612  }
2613  }
2614 
2616  {
2618  // register imported structure asap
2619  s.registerImportedStructure(vlx, obj.get());
2620  importClipPlane(s, vlx, obj.get());
2621  return obj;
2622  }
2623 
2625  {
2626  *vlx << "PlaneNormal" << vlx_toValue(clip->plane().normal());
2627  *vlx << "PlaneOrigin" << clip->plane().origin();
2628  if (clip->boundTransform())
2629  *vlx << "BoundTransform" << s.exportVLX(clip->boundTransform());
2630  }
2631 
2633  {
2634  const vl::ClipPlane* cast_obj = obj->as<vl::ClipPlane>(); VL_CHECK(cast_obj)
2635  vl::ref<VLXStructure> vlx = new VLXStructure(vlx_makeTag(obj).c_str(), s.generateID("clipplane_"));
2636  // register exported object asap
2637  s.registerExportedObject(obj, vlx.get());
2638  exportClipPlane(s, cast_obj, vlx.get());
2639  return vlx;
2640  }
2641  };
2642 
2643  //---------------------------------------------------------------------------
2644 
2647  {
2649  {
2650  const VLXValue* name = vlx->getValue("ObjectName");
2651  if (name)
2652  obj->setObjectName( name->getString() );
2653 
2654  for(size_t i=0; i<vlx->value().size(); ++i)
2655  {
2656  const std::string& key = vlx->value()[i].key();
2657  const VLXValue& value = vlx->value()[i].value();
2658  if (key == "AttachShader")
2659  {
2660  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Structure, value )
2661  const VLXStructure* st = value.getStructure();
2662  vl::GLSLShader* glsl_sh = s.importVLX(st)->as<vl::GLSLShader>();
2663  VLX_IMPORT_CHECK_RETURN( glsl_sh != NULL, *st )
2664  obj->attachShader(glsl_sh);
2665  }
2666  else
2667  if (key == "FragDataLocation")
2668  {
2669  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::List, value )
2670  const VLXList* list = value.getList();
2671  VLX_IMPORT_CHECK_RETURN( list->value().size() == 2, *list )
2672  VLX_IMPORT_CHECK_RETURN( list->value()[0].type() == VLXValue::Identifier, *list )
2673  VLX_IMPORT_CHECK_RETURN( list->value()[1].type() == VLXValue::Integer, *list )
2674  const char* name = list->value()[0].getIdentifier().c_str();
2675  int index = (int)list->value()[1].getInteger();
2676  obj->bindFragDataLocation(index, name);
2677  }
2678  // MIC FIXME
2679  //else
2680  //if (key == "AttribLocation")
2681  //{
2682  // VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::List, value )
2683  // const VLXList* list = value.getList();
2684  // VLX_IMPORT_CHECK_RETURN( list->value().size() == 2, *list )
2685  // VLX_IMPORT_CHECK_RETURN( list->value()[0].type() == VLXValue::Identifier, *list )
2686  // VLX_IMPORT_CHECK_RETURN( list->value()[1].type() == VLXValue::Integer, *list )
2687  // const char* name = list->value()[0].getIdentifier().c_str();
2688  // int index = (int)list->value()[1].getInteger();
2689  // obj->addAutoAttribLocation(index, name);
2690  //}
2691  else
2692  if (key == "Uniforms")
2693  {
2694  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::List, value )
2695  const VLXList* list = value.getList();
2696  for(size_t i=0; i<list->value().size(); ++i)
2697  {
2698  VLX_IMPORT_CHECK_RETURN( list->value()[i].type() == VLXValue::Structure, list->value()[i] )
2699  vl::Uniform* uniform = s.importVLX( list->value()[i].getStructure() )->as<vl::Uniform>();
2700  VLX_IMPORT_CHECK_RETURN( uniform != NULL, list->value()[i] )
2701  obj->setUniform(uniform);
2702  }
2703  }
2704  }
2705  }
2706 
2708  {
2710  // register imported structure asap
2711  s.registerImportedStructure(vlx, obj.get());
2712  importGLSLProgram(s, vlx, obj.get());
2713  return obj;
2714  }
2715 
2717  {
2718  if (!obj->objectName().empty() && obj->objectName() != obj->className())
2719  *vlx << "ObjectName" << vlx_String(obj->objectName());
2720 
2721  // export obj shaders
2722  for(int i=0; i<obj->shaderCount(); ++i)
2723  *vlx << "AttachShader" << s.exportVLX(obj->shader(i));
2724 
2725  // export uniforms
2726  VLXValue uniforms;
2727  uniforms.setList( new VLXList );
2728  for(size_t i=0; obj->getUniformSet() && i<obj->getUniformSet()->uniforms().size(); ++i)
2729  *uniforms.getList() << s.exportVLX(obj->getUniformSet()->uniforms()[i].get());
2730  *vlx << "Uniforms" << uniforms;
2731 
2732  // frag data location
2733  for(std::map<std::string, int>::const_iterator it = obj->fragDataLocations().begin(); it != obj->fragDataLocations().end(); ++it)
2734  {
2735  VLXList* location = new VLXList;
2736  *location << vlx_Identifier(it->first); // Name
2737  *location << (long long)it->second; // Location
2738  *vlx << "FragDataLocation" << location;
2739  }
2740 
2742  // MIC FIXME
2743  //for(std::map<std::string, int>::const_iterator it = obj->autoAttribLocations().begin(); it != obj->autoAttribLocations().end(); ++it)
2744  //{
2745  // VLXList* location = new VLXList;
2746  // *location << vlx_Identifier(it->first); // Name
2747  // *location << (long long)it->second; // Location
2748  // *vlx << "AttribLocation" << location;
2749  //}
2750  }
2751 
2753  {
2754  const vl::GLSLProgram* cast_obj = obj->as<vl::GLSLProgram>(); VL_CHECK(cast_obj)
2755  vl::ref<VLXStructure> vlx = new VLXStructure(vlx_makeTag(obj).c_str(), s.generateID("glslprog_"));
2756  // register exported object asap
2757  s.registerExportedObject(obj, vlx.get());
2758  exportGLSLProgram(s, cast_obj, vlx.get());
2759  return vlx;
2760  }
2761  };
2762 
2763  //---------------------------------------------------------------------------
2764 
2767  {
2769  {
2770  const VLXValue* path = vlx->getValue("Path");
2771  const VLXValue* source = vlx->getValue("Source");
2772  VLX_IMPORT_CHECK_RETURN( path != NULL || source != NULL, *vlx )
2773  if (path)
2774  {
2775  VLX_IMPORT_CHECK_RETURN( path->type() == VLXValue::String, *path )
2776  std::string resolved_path = path->getString();
2777  s.resolvePath(resolved_path);
2778  obj->setSource(resolved_path.c_str()); // this automatically loads the source and sets the path
2779  }
2780  else
2781  if (source)
2782  {
2783  VLX_IMPORT_CHECK_RETURN( source->type() == VLXValue::RawtextBlock, *source )
2784  obj->setSource(source->getRawtextBlock()->value().c_str());
2785  }
2786  else
2787  {
2788  vl::Log::warning( vl::Say("Line %n : no source or path specified for glsl shader.\n") << vlx->lineNumber() );
2789  }
2790  }
2791 
2793  {
2795  if (vlx->tag() == "<vl::GLSLVertexShader>")
2796  obj = new vl::GLSLVertexShader;
2797  else
2798  if (vlx->tag() == "<vl::GLSLFragmentShader>")
2799  obj = new vl::GLSLFragmentShader;
2800  else
2801  if (vlx->tag() == "<vl::GLSLGeometryShader>")
2802  obj = new vl::GLSLGeometryShader;
2803  else
2804  if (vlx->tag() == "<vl::GLSLTessControlShader>")
2805  obj = new vl::GLSLTessControlShader;
2806  else
2807  if (vlx->tag() == "<vl::GLSLTessEvaluationShader>")
2808  obj = new vl::GLSLTessEvaluationShader;
2809  else
2810  {
2811  s.signalImportError( vl::Say("Line %n : shader type '%s' not supported.\n") << vlx->tag() );
2812  return NULL;
2813  }
2814 
2815  // register imported structure asap
2816  s.registerImportedStructure(vlx, obj.get());
2817  importGLSLShader(s, vlx, obj.get());
2818  return obj;
2819  }
2820 
2822  {
2823  if (!glslsh->path().empty())
2824  *vlx << "Path" << vlx_String(glslsh->path().toStdString());
2825  else
2826  if (!glslsh->source().empty())
2827  *vlx << "Source" << vlx_Rawtext(glslsh->source());
2828  else
2829  if (glslsh->handle())
2830  *vlx << "Source" << vlx_Rawtext(glslsh->getShaderSource());
2831  else
2832  *vlx << "Source" << vlx_Identifier("NO_SOURCE_FOUND");
2833  }
2834 
2836  {
2837  const vl::GLSLShader* cast_obj = obj->as<vl::GLSLShader>(); VL_CHECK(cast_obj)
2838  vl::ref<VLXStructure> vlx = new VLXStructure(vlx_makeTag(obj).c_str(), s.generateID("glslsh_"));
2839  // register exported object asap
2840  s.registerExportedObject(obj, vlx.get());
2841  exportGLSLShader(cast_obj, vlx.get());
2842  return vlx;
2843  }
2844  };
2845 
2846  //---------------------------------------------------------------------------
2847 
2850  {
2852  {
2853  const VLXValue* name = vlx->getValue("ObjectName");
2854  if (name)
2855  obj->setObjectName( name->getString() );
2856 
2857  const VLXValue* value = vlx->getValue("Value");
2858  VLX_IMPORT_CHECK_RETURN( value->type() == VLXValue::ArrayReal, *value )
2859  obj->setValue( (vl::fvec4)vlx_vec4( value->getArrayReal() ) );
2860  }
2861 
2863  {
2865  // register imported structure asap
2866  s.registerImportedStructure(vlx, obj.get());
2867  importVertexAttrib(s, vlx, obj.get());
2868  return obj;
2869  }
2870 
2872  {
2873  if (!obj->objectName().empty() && obj->objectName() != obj->className())
2874  *vlx << "ObjectName" << vlx_String(obj->objectName());
2875  *vlx << "Value" << vlx_toValue((vl::vec4)obj->value());
2876  }
2877 
2879  {
2880  const vl::VertexAttrib* cast_obj = obj->as<vl::VertexAttrib>(); VL_CHECK(cast_obj)
2881  vl::ref<VLXStructure> vlx = new VLXStructure(vlx_makeTag(obj).c_str(), s.generateID("vertexattrib_"));
2882  // register exported object asap
2883  s.registerExportedObject(obj, vlx.get());
2884  exportVertexAttrib(cast_obj, vlx.get());
2885  return vlx;
2886  }
2887  };
2888 
2889  //---------------------------------------------------------------------------
2890 
2893  {
2895  {
2896  const VLXValue* value = vlx->getValue("Value");
2897  VLX_IMPORT_CHECK_RETURN( value->type() == VLXValue::ArrayReal, *value )
2898  obj->setValue( (vl::fvec4)vlx_vec4( value->getArrayReal() ) );
2899  }
2900 
2902  {
2903  vl::ref<vl::Color> obj = new vl::Color;
2904  // register imported structure asap
2905  s.registerImportedStructure(vlx, obj.get());
2906  importColor(s, vlx, obj.get());
2907  return obj;
2908  }
2909 
2910  void exportColor(const vl::Color* obj, VLXStructure* vlx)
2911  {
2912  *vlx << "Value" << vlx_toValue((vl::vec4)obj->value());
2913  }
2914 
2916  {
2917  const vl::Color* cast_obj = obj->as<vl::Color>(); VL_CHECK(cast_obj)
2918  vl::ref<VLXStructure> vlx = new VLXStructure(vlx_makeTag(obj).c_str(), s.generateID("color_"));
2919  // register exported object asap
2920  s.registerExportedObject(obj, vlx.get());
2921  exportColor(cast_obj, vlx.get());
2922  return vlx;
2923  }
2924  };
2925 
2926  //---------------------------------------------------------------------------
2927 
2930  {
2932  {
2933  const VLXValue* value = vlx->getValue("Value");
2934  VLX_IMPORT_CHECK_RETURN( value->type() == VLXValue::ArrayReal, *value )
2935  obj->setValue( (vl::fvec3)vlx_vec3( value->getArrayReal() ) );
2936  }
2937 
2939  {
2941  // register imported structure asap
2942  s.registerImportedStructure(vlx, obj.get());
2943  importSecondaryColor(s, vlx, obj.get());
2944  return obj;
2945  }
2946 
2948  {
2949  *vlx << "Value" << vlx_toValue((vl::vec3)obj->value());
2950  }
2951 
2953  {
2954  const vl::SecondaryColor* cast_obj = obj->as<vl::SecondaryColor>(); VL_CHECK(cast_obj)
2955  vl::ref<VLXStructure> vlx = new VLXStructure(vlx_makeTag(obj).c_str(), s.generateID("seccolor_"));
2956  // register exported object asap
2957  s.registerExportedObject(obj, vlx.get());
2958  exportSecondaryColor(cast_obj, vlx.get());
2959  return vlx;
2960  }
2961  };
2962 
2963  //---------------------------------------------------------------------------
2964 
2967  {
2969  {
2970  const VLXValue* value = vlx->getValue("Value");
2971  VLX_IMPORT_CHECK_RETURN( value->type() == VLXValue::ArrayReal, *value )
2972  obj->setValue( (vl::fvec3)vlx_vec3( value->getArrayReal() ) );
2973  }
2974 
2976  {
2977  vl::ref<vl::Normal> obj = new vl::Normal;
2978  // register imported structure asap
2979  s.registerImportedStructure(vlx, obj.get());
2980  importNormal(s, vlx, obj.get());
2981  return obj;
2982  }
2983 
2984  void exportNormal(const vl::Normal* obj, VLXStructure* vlx)
2985  {
2986  *vlx << "Value" << vlx_toValue((vl::vec3)obj->value());
2987  }
2988 
2990  {
2991  const vl::Normal* cast_obj = obj->as<vl::Normal>(); VL_CHECK(cast_obj)
2992  vl::ref<VLXStructure> vlx = new VLXStructure(vlx_makeTag(obj).c_str(), s.generateID("normal_"));
2993  // register exported object asap
2994  s.registerExportedObject(obj, vlx.get());
2995  exportNormal(cast_obj, vlx.get());
2996  return vlx;
2997  }
2998  };
2999 
3000  //---------------------------------------------------------------------------
3001 
3004  {
3006  {
3007  const VLXValue* name = vlx->getValue("ObjectName");
3008  if (name)
3009  obj->setObjectName( name->getString() );
3010 
3011  for(size_t i=0; i<vlx->value().size(); ++i)
3012  {
3013  const std::string& key = vlx->value()[i].key();
3014  const VLXValue& value = vlx->value()[i].value();
3015  if (key == "FrontAmbient")
3016  {
3017  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::ArrayReal, value );
3018  obj->setFrontAmbient( (vl::fvec4)vlx_vec4( value.getArrayReal() ) );
3019  }
3020  else
3021  if (key == "FrontDiffuse")
3022  {
3023  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::ArrayReal, value );
3024  obj->setFrontDiffuse( (vl::fvec4)vlx_vec4( value.getArrayReal() ) );
3025  }
3026  else
3027  if (key == "FrontEmission")
3028  {
3029  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::ArrayReal, value );
3030  obj->setFrontEmission( (vl::fvec4)vlx_vec4( value.getArrayReal() ) );
3031  }
3032  else
3033  if (key == "FrontSpecular")
3034  {
3035  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::ArrayReal, value );
3036  obj->setFrontSpecular( (vl::fvec4)vlx_vec4( value.getArrayReal() ) );
3037  }
3038  else
3039  if (key == "FrontShininess")
3040  {
3041  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Real, value );
3042  obj->setFrontShininess( (float)value.getReal() );
3043  }
3044  else
3045  if (key == "BackAmbient")
3046  {
3047  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::ArrayReal, value );
3048  obj->setBackAmbient( (vl::fvec4)vlx_vec4( value.getArrayReal() ) );
3049  }
3050  else
3051  if (key == "BackDiffuse")
3052  {
3053  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::ArrayReal, value );
3054  obj->setBackDiffuse( (vl::fvec4)vlx_vec4( value.getArrayReal() ) );
3055  }
3056  else
3057  if (key == "BackEmission")
3058  {
3059  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::ArrayReal, value );
3060  obj->setBackEmission( (vl::fvec4)vlx_vec4( value.getArrayReal() ) );
3061  }
3062  else
3063  if (key == "BackSpecular")
3064  {
3065  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::ArrayReal, value );
3066  obj->setBackSpecular( (vl::fvec4)vlx_vec4( value.getArrayReal() ) );
3067  }
3068  else
3069  if (key == "BackShininess")
3070  {
3071  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Real, value );
3072  obj->setBackShininess( (float)value.getReal() );
3073  }
3074  else
3075  if (key == "ColorMaterialEnabled")
3076  {
3077  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Bool, value );
3078  obj->setColorMaterialEnabled( value.getBool() );
3079  }
3080  }
3081 
3083  const VLXValue* vlx_col_mat = vlx->getValue("ColorMaterial");
3084  if (vlx_col_mat)
3085  {
3086  VLX_IMPORT_CHECK_RETURN( vlx_col_mat->type() == VLXValue::Identifier, *vlx_col_mat );
3087  col_mat = vlx_EColorMaterial( *vlx_col_mat, s );
3088  }
3089 
3091  const VLXValue* vlx_poly_mat = vlx->getValue("ColorMaterialFace");
3092  if (vlx_poly_mat)
3093  {
3094  VLX_IMPORT_CHECK_RETURN( vlx_poly_mat->type() == VLXValue::Identifier, *vlx_poly_mat );
3095  poly_face = vlx_EPolygonFace( *vlx_poly_mat, s );
3096  }
3097 
3098  obj->setColorMaterial( poly_face, col_mat );
3099  }
3100 
3102  {
3104  // register imported structure asap
3105  s.registerImportedStructure(vlx, obj.get());
3106  importMaterial(s, vlx, obj.get());
3107  return obj;
3108  }
3109 
3111  {
3112  if (!obj->objectName().empty() && obj->objectName() != obj->className())
3113  *vlx << "ObjectName" << vlx_String(obj->objectName());
3114 
3115  *vlx << "FrontAmbient" << vlx_toValue((vl::vec4)obj->frontAmbient());
3116  *vlx << "FrontDiffuse" << vlx_toValue((vl::vec4)obj->frontDiffuse());
3117  *vlx << "FrontEmission" << vlx_toValue((vl::vec4)obj->frontEmission());
3118  *vlx << "FrontSpecular" << vlx_toValue((vl::vec4)obj->frontSpecular());
3119  *vlx << "FrontShininess" << (double)obj->frontShininess();
3120 
3121  *vlx << "BackAmbient" << vlx_toValue((vl::vec4)obj->backAmbient());
3122  *vlx << "BackDiffuse" << vlx_toValue((vl::vec4)obj->backDiffuse());
3123  *vlx << "BackEmission" << vlx_toValue((vl::vec4)obj->backEmission());
3124  *vlx << "BackSpecular" << vlx_toValue((vl::vec4)obj->backSpecular());
3125  *vlx << "BackShininess" << (double)obj->backShininess();
3126 
3127  *vlx << "ColorMaterial" << vlx_Identifier(vlx_EColorMaterial(obj->colorMaterial()));
3128  *vlx << "ColorMaterialFace" << vlx_Identifier(vlx_EPolygonFace(obj->colorMaterialFace()));
3129 
3130  *vlx << "ColorMaterialEnabled" << obj->colorMaterialEnabled();
3131  }
3132 
3134  {
3135  const vl::Material* cast_obj = obj->as<vl::Material>(); VL_CHECK(cast_obj)
3136  vl::ref<VLXStructure> vlx = new VLXStructure(vlx_makeTag(obj).c_str(), s.generateID("material_"));
3137  // register exported object asap
3138  s.registerExportedObject(obj, vlx.get());
3139  exportMaterial(cast_obj, vlx.get());
3140  return vlx;
3141  }
3142  };
3143 
3144  //---------------------------------------------------------------------------
3145 
3148  {
3150  {
3151  if (obj->isOfType(vl::DepthSortCallback::Type()))
3152  {
3153  const VLXValue* vlx_sm = vlx->getValue("SortMode");
3154  VLX_IMPORT_CHECK_RETURN( vlx_sm->type() == VLXValue::Identifier, *vlx_sm )
3155  if (vlx_sm)
3156  {
3158  if ( vlx_sm->getIdentifier() == "SM_SortBackToFront" )
3160  else
3161  if ( vlx_sm->getIdentifier() == "SM_SortFrontToBack" )
3163  else
3164  s.signalImportError( vl::Say("Line %n : unknown sort mode '%s'.\n") << vlx_sm->lineNumber() << vlx_sm->getIdentifier() );
3165  obj->as<vl::DepthSortCallback>()->setSortMode(sm);
3166  }
3167  }
3168  }
3169 
3171  {
3173 
3174  if (vlx->tag() == "<vl::DepthSortCallback>")
3175  obj = new vl::DepthSortCallback;
3176  else
3177  {
3178  s.signalImportError( vl::Say("Line %n : ActorEventCallback type not supported for import.\n") << vlx->lineNumber() );
3179  return NULL;
3180  }
3181 
3182  // register imported structure asap
3183  s.registerImportedStructure(vlx, obj.get());
3184  importActorEventCallback(s, vlx, obj.get());
3185  return obj;
3186  }
3187 
3189  {
3190  if (cb->classType() == vl::DepthSortCallback::Type())
3191  {
3192  const vl::DepthSortCallback* dsc = cb->as<vl::DepthSortCallback>();
3193 
3194  if (dsc->sortMode() == vl::SM_SortBackToFront)
3195  *vlx << "SortMode" << vlx_Identifier("SM_SortBackToFront");
3196  else
3197  *vlx << "SortMode" << vlx_Identifier("SM_SortFrontToBack");
3198  }
3199  else
3200  {
3201  s.signalExportError("ActorEventCallback type not supported for export.\n");
3202  }
3203  }
3204 
3206  {
3207  const vl::ActorEventCallback* cast_obj = obj->as<vl::ActorEventCallback>(); VL_CHECK(cast_obj)
3208  vl::ref<VLXStructure> vlx = new VLXStructure(vlx_makeTag(obj).c_str(), s.generateID("actorcallback_"));
3209  // register exported object asap
3210  s.registerExportedObject(obj, vlx.get());
3211  exportActorEventCallback(s, cast_obj, vlx.get());
3212  return vlx;
3213  }
3214  };
3215 
3216  //---------------------------------------------------------------------------
3217 
3220  {
3222  {
3223  const VLXValue* name = vlx->getValue("ObjectName");
3224  if (name)
3225  obj->setObjectName( name->getString() );
3226 
3228 
3229  for(size_t i=0; i<vlx->value().size(); ++i)
3230  {
3231  const std::string& key = vlx->value()[i].key();
3232  const VLXValue& value = vlx->value()[i].value();
3233 
3234  if (key == "Dimension")
3235  {
3236  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Identifier, value );
3237  obj->setupParams()->setDimension( vlx_ETextureDimension( value, s ) );
3238  }
3239  else
3240  if (key == "TexParameter")
3241  {
3242  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Structure, value );
3243  vl::TexParameter* tex_param = s.importVLX( value.getStructure() )->as<vl::TexParameter>();
3244  VLX_IMPORT_CHECK_RETURN( tex_param != NULL, value );
3245  // copy the content over
3246  *obj->getTexParameter() = *tex_param;
3247  }
3248  else
3249  if (key == "ImagePath")
3250  {
3251  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::String, value );
3252  std::string resolved_path = value.getString();
3253  s.resolvePath( resolved_path );
3254  obj->setupParams()->setImagePath( resolved_path.c_str() );
3255  }
3256  else
3257  if (key == "Format")
3258  {
3259  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Identifier, value );
3260  obj->setupParams()->setFormat( vlx_ETextureFormat( value, s ) );
3261  }
3262  else
3263  if (key == "Width")
3264  {
3265  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Integer, value );
3266  obj->setupParams()->setWidth( (int)value.getInteger() );
3267  }
3268  else
3269  if (key == "Height")
3270  {
3271  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Integer, value );
3272  obj->setupParams()->setHeight( (int)value.getInteger() );
3273  }
3274  else
3275  if (key == "Depth")
3276  {
3277  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Integer, value );
3278  obj->setupParams()->setDepth( (int)value.getInteger() );
3279  }
3280  else
3281  if (key == "GenMipmaps")
3282  {
3283  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Bool, value );
3284  obj->setupParams()->setGenMipmaps( (int)value.getBool() );
3285  }
3286  else
3287  if (key == "BufferObject")
3288  {
3289  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Structure, value );
3290  vl::BufferObject* buf_obj = s.importVLX( value.getStructure() )->as<vl::BufferObject>();
3291  VLX_IMPORT_CHECK_RETURN( buf_obj, value );
3292  obj->setupParams()->setBufferObject( buf_obj );
3293  }
3294  else
3295  if (key == "Samples")
3296  {
3297  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Integer, value );
3298  obj->setupParams()->setSamples( (int)value.getInteger() );
3299  }
3300  else
3301  if (key == "FixedSamplesLocations")
3302  {
3303  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Bool, value );
3304  obj->setupParams()->setFixedSamplesLocations( (int)value.getBool() );
3305  }
3306  }
3307  }
3308 
3310  {
3312  // register imported structure asap
3313  s.registerImportedStructure(vlx, obj.get());
3314  importTexture(s, vlx, obj.get());
3315  return obj;
3316  }
3317 
3319  {
3320  // mic fixme:
3321  // - we should allow patterns such as initializing a texture from an image filled by a shader or procedure.
3322  // - we should allow avoid loading twice the same image or shader source or any externa resource etc. time for a resource manager?
3323 
3324  if (!obj->objectName().empty() && obj->objectName() != obj->className())
3325  *vlx << "ObjectName" << vlx_String(obj->objectName());
3326 
3327  if (obj->getTexParameter())
3328  *vlx << "TexParameter" << s.exportVLX(obj->getTexParameter());
3329 
3330  if (obj->setupParams())
3331  {
3332  const vl::Texture::SetupParams* par = obj->setupParams();
3333 
3334  if (par)
3335  {
3336  *vlx << "Dimension" << vlx_Identifier(vlx_ETextureDimension(par->dimension()));
3337 
3338  *vlx << "Format" << vlx_Identifier(vlx_ETextureFormat(par->format()));
3339 
3340  if (!par->imagePath().empty())
3341  *vlx << "ImagePath" << vlx_String(par->imagePath().toStdString());
3342  else
3343  if (par->image())
3344  *vlx << "ImagePath" << vlx_String(par->image()->filePath().toStdString());
3345 
3346  if (par->width())
3347  *vlx << "Width" << (long long)par->width();
3348 
3349  if (par->height())
3350  *vlx << "Height" << (long long)par->height();
3351 
3352  if (par->depth())
3353  *vlx << "Depth" << (long long)par->depth();
3354 
3355  *vlx << "GenMipmaps" << par->genMipmaps();
3356 
3357  // mic fixme: implement BufferObject importer/exporter
3358 #if 0
3359  if (par->bufferObject())
3360  {
3361  *vlx << "BufferObject" << s.exportVLX(par->bufferObject());
3362  }
3363 #endif
3364 
3365  if(par->samples())
3366  {
3367  *vlx << "Samples" << (long long)par->samples();
3368  *vlx << "FixedSamplesLocations" << par->fixedSamplesLocations();
3369  }
3370  }
3371  }
3372  }
3373 
3375  {
3376  const vl::Texture* cast_obj = obj->as<vl::Texture>(); VL_CHECK(cast_obj)
3377  vl::ref<VLXStructure> vlx = new VLXStructure(vlx_makeTag(obj).c_str(), s.generateID("texture_"));
3378  // register exported object asap
3379  s.registerExportedObject(obj, vlx.get());
3380  exportTexture(s, cast_obj, vlx.get());
3381  return vlx;
3382  }
3383  };
3384 
3385  //---------------------------------------------------------------------------
3386 
3389  {
3391  {
3392  for(size_t i=0; i<vlx->value().size(); ++i)
3393  {
3394  const std::string& key = vlx->value()[i].key();
3395  const VLXValue& value = vlx->value()[i].value();
3396 
3397  if (key == "MinFilter")
3398  {
3399  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Identifier, value );
3400  obj->setMinFilter( vlx_ETexParamFilter( value, s ) );
3401  }
3402  else
3403  if (key == "MagFilter")
3404  {
3405  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Identifier, value );
3406  obj->setMagFilter( vlx_ETexParamFilter( value, s ) );
3407  }
3408  else
3409  if (key == "WrapS")
3410  {
3411  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Identifier, value );
3412  obj->setWrapS( vlx_ETexParamWrap( value, s ) );
3413  }
3414  else
3415  if (key == "WrapT")
3416  {
3417  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Identifier, value );
3418  obj->setWrapT( vlx_ETexParamWrap( value, s ) );
3419  }
3420  else
3421  if (key == "WrapR")
3422  {
3423  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Identifier, value );
3424  obj->setWrapR( vlx_ETexParamWrap( value, s ) );
3425  }
3426  else
3427  if (key == "CompareMode")
3428  {
3429  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Identifier, value );
3430  obj->setCompareMode( vlx_ETexCompareMode( value, s ) );
3431  }
3432  else
3433  if (key == "CompareFunc")
3434  {
3435  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Identifier, value );
3436  obj->setCompareFunc( vlx_ETexCompareFunc( value, s ) );
3437  }
3438  else
3439  if (key == "DepthTextureMode")
3440  {
3441  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Identifier, value );
3442  obj->setDepthTextureMode( vlx_EDepthTextureMode( value, s ) );
3443  }
3444  else
3445  if (key == "BorderColor")
3446  {
3447  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::ArrayReal, value );
3448  obj->setBorderColor( (vl::fvec4)vlx_vec4(value.getArrayReal()) );
3449  }
3450  else
3451  if (key == "Anisotropy")
3452  {
3453  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Real, value );
3454  obj->setAnisotropy( (float)value.getReal() );
3455  }
3456  else
3457  if (key == "GenerateMipmap")
3458  {
3459  VLX_IMPORT_CHECK_RETURN( value.type() == VLXValue::Bool, value );
3460  obj->setGenerateMipmap( value.getBool() );
3461  }
3462  }
3463  }
3464 
3466  {
3468  // register imported structure asap
3469  s.registerImportedStructure(vlx, obj.get());
3470  importTexParameter(s, vlx, obj.get());
3471  return obj;
3472  }
3473 
3475  {
3476  *vlx << "MinFilter" << vlx_Identifier(vlx_ETexParamFilter(texparam->minFilter()));
3477  *vlx << "MagFilter" << vlx_Identifier(vlx_ETexParamFilter(texparam->magFilter()));
3478  *vlx << "WrapS" << vlx_Identifier(vlx_ETexParamWrap(texparam->wrapS()));
3479  *vlx << "WrapT" << vlx_Identifier(vlx_ETexParamWrap(texparam->wrapT()));
3480  *vlx << "WrapR" << vlx_Identifier(vlx_ETexParamWrap(texparam->wrapR()));
3481  *vlx << "CompareMode" << vlx_Identifier(vlx_ETexCompareMode(texparam->compareMode()));
3482  *vlx << "CompareFunc" << vlx_Identifier(vlx_ETexCompareFunc(texparam->compareFunc()));
3483  *vlx << "DepthTextureMode" << vlx_Identifier(vlx_EDepthTextureMode(texparam->depthTextureMode()));
3484  *vlx << "BorderColor" << vlx_toValue((vl::vec4)texparam->borderColor());
3485  *vlx << "Anisotropy" << texparam->anisotropy();
3486  *vlx << "GenerateMipmap" << texparam->generateMipmap();
3487  }
3488 
3490  {
3491  const vl::TexParameter* cast_obj = obj->as<vl::TexParameter>(); VL_CHECK(cast_obj)
3492  vl::ref<VLXStructure> vlx = new VLXStructure(vlx_makeTag(obj).c_str(), s.generateID("texparam_"));
3493  // register exported object asap
3494  s.registerExportedObject(obj, vlx.get());
3495  exportTexParameter(cast_obj, vlx.get());
3496  return vlx;
3497  }
3498  };
3499 
3500  //---------------------------------------------------------------------------
3501 
3504  {
3506  {
3507  const VLXValue* vlx_texture = vlx->getValue("Texture");
3508  if (vlx_texture)
3509  {
3510  VLX_IMPORT_CHECK_RETURN(vlx_texture->type() == VLXValue::Structure, *vlx_texture);
3511  vl::Texture* texture = s.importVLX(vlx_texture->getStructure())->as<vl::Texture>();
3512  VLX_IMPORT_CHECK_RETURN( texture != NULL , *vlx_texture);
3513  obj->setTexture(texture);
3514  }
3515  }
3516 
3518  {
3520  // register imported structure asap
3521  s.registerImportedStructure(vlx, obj.get());
3522  importTextureSampler(s, vlx, obj.get());
3523  return obj;
3524  }
3525 
3527  {
3528  if (tex_sampler->texture())
3529  *vlx << "Texture" << s.exportVLX(tex_sampler->texture());
3530  }
3531 
3533  {
3534  const vl::TextureSampler* cast_obj = obj->as<vl::TextureSampler>(); VL_CHECK(cast_obj)
3535  vl::ref<VLXStructure> vlx = new VLXStructure(vlx_makeTag(obj).c_str(), s.generateID("texsampler_"));
3536  // register exported object asap
3537  s.registerExportedObject(obj, vlx.get());
3538  exportTextureSampler(s, cast_obj, vlx.get());
3539  return vlx;
3540  }
3541  };
3542 }
3543 
3544 #endif
static void debug(const String &message)
Use this function to provide extra information useful to investigate and solve problems.
Definition: Log.cpp:145
void setUniformMatrix3d(int count, const double *value)
Definition: Uniform.hpp:133
EProjectionMatrixType projectionMatrixType() const
The Camera&#39;s projection matrix type.
Definition: Camera.hpp:178
VLX wrapper of vl::Array.
void exportTextureSampler(VLXSerializer &s, const vl::TextureSampler *tex_sampler, VLXStructure *vlx)
void setUniformMatrix4x2d(int count, const double *value)
Definition: Uniform.hpp:139
virtual vl::ref< vl::Object > importVLX(VLXSerializer &s, const VLXStructure *vlx)
The ArrayAbstract class defines an abstract interface to conveniently manipulate data stored in a Buf...
Definition: Array.hpp:58
An array of vl::svec3.
Definition: Array.hpp:468
Associates a Renderable object to an Effect and Transform.
Definition: Actor.hpp:130
See DrawElements.
void setNearPlane(real nearplane)
The near clipping plane.
Definition: Camera.hpp:100
VLX wrapper of vl::Uniform.
void setFrontSpecular(const fvec4 &color)
Definition: Shader.hpp:801
int baseVertex() const
Returns the currently used base vertex.
vl::EPrimitiveType vlx_EPrimitiveType(const VLXValue &value, VLXSerializer &s)
Definition: vlxutils.hpp:1188
An array of vl::uvec2.
Definition: Array.hpp:439
void setBaseVertex(int base_vertex)
If base_vertx is != 0 glDrawElementsBaseVertex/glDrawElementsInstancedBaseVertex will be used instead...
const Renderable * lod(int lod_index) const
Returns the Renderable object representing the LOD level specifed by lod_index.
Definition: Actor.hpp:173
ETextureFormat format() const
Definition: Texture.hpp:182
void exportVertexAttrib(const vl::VertexAttrib *obj, VLXStructure *vlx)
Wraps an OpenGL Shading Language uniform to be associated to a GLSLProgram (see vl::GLSLProgram docum...
Definition: Uniform.hpp:59
void setEffect(Effect *effect)
Binds an Effect to an Actor.
Definition: Actor.hpp:196
const T * at(int i) const
Definition: Collection.hpp:100
int y() const
Definition: Viewport.hpp:67
TexParameter * getTexParameter()
The TexParameter object associated to a Texture.
Definition: Texture.hpp:246
void exportLODEvaluator(VLXSerializer &s, const vl::LODEvaluator *obj, VLXStructure *vlx)
void setTexture(Texture *texture)
The texture sampler by a texture unit.
Definition: Shader.hpp:1765
void setClearStencil(int stencil)
Definition: Viewport.hpp:91
void setEnableMask(unsigned int mask)
The enable mask of an Actor&#39;s Effect defines whether the actor should be rendered or not depending on...
Definition: Effect.hpp:200
virtual vl::ref< vl::Object > importVLX(VLXSerializer &s, const VLXStructure *vlx)
An array of vl::uvec4.
Definition: Array.hpp:443
VLXRawtextBlock * getRawtextBlock()
Definition: Value.hpp:418
void exportViewport(const vl::Viewport *obj, VLXStructure *vlx)
const mat4 & viewMatrix() const
Returns the Camera&#39;s view matrix (inverse of the modeling matrix).
Definition: Camera.hpp:161
void setViewport(Viewport *viewport)
The viewport bound to a camera.
Definition: Camera.hpp:138
void setUniform1i(int count, const int *value)
Definition: Uniform.hpp:99
bool isEnabled() const
Whether an Actor should be considered for rendering, picking, scene bounding box calculation etc...
Definition: Actor.hpp:277
An array of vl::fvec4.
Definition: Array.hpp:416
const std::vector< ref< Uniform > > & uniforms() const
Equivalent to getUniformSet()->uniforms()
Definition: Actor.cpp:121
See MultiDrawElements.
void exportNormal(const vl::Normal *obj, VLXStructure *vlx)
void exportGLSLShader(const vl::GLSLShader *glslsh, VLXStructure *vlx)
virtual vl::ref< VLXStructure > exportVLX(VLXSerializer &s, const vl::Object *obj)
void setPrimitiveType(EPrimitiveType type)
Sets the draw call&#39;s primitive type.
Definition: DrawCall.hpp:107
Transform * transform()
Returns the Transform bound tho an Actor.
Definition: Actor.hpp:190
void setUniform3f(int count, const float *value)
Definition: Uniform.hpp:111
virtual vl::ref< VLXStructure > exportVLX(VLXSerializer &s, const vl::Object *obj)
void exportPatchParameter(const vl::PatchParameter *pp, VLXStructure *vlx)
const Transform * boundTransform() const
Returns the Transform bound to a camera.
Definition: Camera.hpp:150
An array of GLubyte.
Definition: Array.hpp:455
Implements a 4x4 matrix transform used to define the position and orientation of an Actor...
Definition: Transform.hpp:72
void importTexParameter(VLXSerializer &s, const VLXStructure *vlx, vl::TexParameter *obj)
Wrapper for all VLX value types.
Definition: Value.hpp:240
Wraps the OpenGL function glTexParameter(), see also http://www.opengl.org/sdk/docs/man/xhtml/glTexPa...
Definition: Texture.hpp:62
void setUniformMatrix2f(int count, const float *value)
Definition: Uniform.hpp:121
const T * get() const
Definition: Object.hpp:128
ETexCompareFunc compareFunc() const
Definition: Texture.hpp:81
VLX wrapper of vl::Texture.
const fvec4 & value() const
Definition: Shader.hpp:76
virtual vl::ref< VLXStructure > exportVLX(VLXSerializer &s, const vl::Object *obj)
float spotCutoff() const
Valid values are from 0.0f to 90.0f plus the special value 180.0f (default) which disables the spot l...
Definition: Light.hpp:90
size_t renderStatesCount() const
void exportClipPlane(VLXSerializer &s, const vl::ClipPlane *clip, VLXStructure *vlx)
EPolygonFace
void exportTransform(VLXSerializer &s, const vl::Transform *obj, VLXStructure *vlx)
void setBackDiffuse(const fvec4 &color)
Definition: Shader.hpp:812
virtual vl::ref< vl::Object > importVLX(VLXSerializer &s, const VLXStructure *vlx)
void exportActor(VLXSerializer &s, const vl::Actor *obj, VLXStructure *vlx)
vlX::VLXValue * getValue(const char *key)
Definition: Value.hpp:612
vl::vec4 vlx_vec4(const VLXArrayReal *arr)
Definition: vlxutils.hpp:58
const char * vlx_ETextureFormat(vl::ETextureFormat tf)
Definition: vlxutils.hpp:383
VLX wrapper of vl::DistanceLODEvaluator and vl::PixelLODEvaluator.
A simple String formatting class.
Definition: Say.hpp:124
float frontShininess() const
Definition: Shader.hpp:809
const std::vector< GLint > & baseVertices() const
Returns the list of base vertices, one for each primitive.
void setObjectName(const char *name)
The name of the object, by default set to the object&#39;s class name in debug builds.
Definition: Object.hpp:220
std::string vlx_makeTag(const vl::Object *obj)
Definition: vlxutils.hpp:44
static void warning(const String &message)
Use this function to provide information about situations that might lead to errors or loss of data...
Definition: Log.cpp:155
VLX_EXPORT VLXList * setList(VLXList *)
Definition: Value.cpp:144
void setUniformMatrix3x4d(int count, const double *value)
Definition: Uniform.hpp:140
void setSetupParams(SetupParams *setup_params)
See SetupParams.
Definition: Texture.hpp:728
void bindTransform(Transform *transform)
Attach the light to a vl::Transform.
Definition: ClipPlane.hpp:68
vl::ref< VLXStructure > export_ArrayT(VLXSerializer &s, const vl::Object *arr_abstract)
const fvec4 & backDiffuse() const
Definition: Shader.hpp:818
VLX wrapper of vl::Material.
const std::vector< float > & pixelRangeSet() const
An array of vl::usvec4.
Definition: Array.hpp:479
virtual vl::ref< vl::Object > importVLX(VLXSerializer &s, const VLXStructure *vlx)
EColorMaterial colorMaterial() const
Definition: Shader.hpp:827
RenderState wrapping the OpenGL function glNormal(), see also http://www.opengl.org/sdk/docs/man/xhtm...
Definition: Shader.hpp:162
virtual vl::ref< vl::Object > importVLX(VLXSerializer &s, const VLXStructure *vlx)
unsigned int handle() const
The handle of this OpenGL shader object as returned by glCreateShader()
Definition: GLSL.hpp:104
Wraps a GLSL geometry shader to be bound to a GLSLProgram: the shader this shader will run on the pro...
Definition: GLSL.hpp:154
virtual vl::ref< VLXStructure > exportVLX(VLXSerializer &s, const vl::Object *obj)
void exportActorEventCallback(VLXSerializer &s, const vl::ActorEventCallback *cb, VLXStructure *vlx)
Key/value pair used by VLXStructure.
Definition: Value.hpp:582
const std::vector< GLsizei > & countVector() const
The count vector used as &#39;count&#39; parameter of glMultiDrawElements.
void setFrontAmbient(const fvec4 &color)
Definition: Shader.hpp:799
VLXList * getList()
Definition: Value.hpp:410
void importGeometry(VLXSerializer &s, const VLXStructure *vlx, vl::Geometry *geom)
void exportEffect(VLXSerializer &s, const vl::Effect *obj, VLXStructure *vlx)
virtual vl::ref< VLXStructure > exportVLX(VLXSerializer &s, const vl::Object *obj)
const String & imagePath() const
Definition: Texture.hpp:169
virtual vl::ref< VLXStructure > exportVLX(VLXSerializer &s, const vl::Object *obj)
const String & filePath() const
The file from which the image was loaded.
Definition: Image.hpp:371
EnableSet * getEnableSet()
Definition: Shader.hpp:2229
Wraps a GLSL vertex shader to be bound to a GLSLProgram: the shader this shader will run on the progr...
Definition: GLSL.hpp:117
int size() const
Definition: Collection.hpp:82
const ArrayAbstract * vertexArray() const
Conventional vertex array.
Definition: Geometry.hpp:248
VLXStructure * exportVLX(const vl::Object *obj)
Definition: Seriailzer.cpp:87
virtual vl::ref< vl::Object > importVLX(VLXSerializer &s, const VLXStructure *vlx)
void setClearColor(float r, float g, float b, float a)
Definition: Viewport.hpp:79
void importGLSLShader(VLXSerializer &s, const VLXStructure *vlx, vl::GLSLShader *obj)
virtual vl::ref< vl::Object > importVLX(VLXSerializer &s, const VLXStructure *vlx)
void setClearColorInt(int r, int g, int b, int a)
Definition: Viewport.hpp:83
std::string & value()
Definition: Value.hpp:84
const SetupParams * setupParams() const
See SetupParams.
Definition: Texture.hpp:731
std::string generateID(const char *prefix)
Definition: Seriailzer.cpp:196
VLXValue vlx_String(const std::string &str)
Definition: vlxutils.hpp:50
const char * vlx_EPolygonFace(vl::EPolygonFace pf)
Definition: vlxutils.hpp:335
void copyTo(T2 *ptr) const
Definition: Value.hpp:124
Base interface for all MultiDrawElements* sub classes.
void importVertexAttrib(VLXSerializer &s, const VLXStructure *vlx, vl::VertexAttrib *obj)
virtual vl::ref< VLXStructure > exportVLX(VLXSerializer &s, const vl::Object *obj)
See DrawElements.
bool isEnabled() const
True if the draw call is enabled.
Definition: DrawCall.hpp:128
void importDrawCall(VLXSerializer &s, const VLXStructure *vlx, vl::DrawCall *draw_call)
An array of vl::ivec4.
Definition: Array.hpp:434
bool boundsDirty() const
Returns whether the bounding sphere or bounding box are "dirty", that is, meant to be recomputed...
Definition: Renderable.hpp:126
An array of GLuint.
Definition: Array.hpp:437
static void error(const String &message)
Use this function to provide information about run-time errors: file not found, out of memory...
Definition: Log.cpp:165
void exportMaterial(const vl::Material *obj, VLXStructure *vlx)
void setFarPlane(real farplane)
The far clipping plane.
Definition: Camera.hpp:107
void setWrapT(ETexParamWrap texturewrap)
Definition: Texture.hpp:88
void setFrontShininess(float shininess)
Definition: Shader.hpp:803
void setVertexArray(ArrayAbstract *data)
Conventional vertex array.
Definition: Geometry.cpp:155
const char * vlx_EClearColorMode(vl::EClearColorMode ccm)
Definition: vlxutils.hpp:281
An array of 64 bits floating point numbers, can also have a tag.
Definition: Value.hpp:144
void setInstances(int instances)
Sets the number of instances for this set of primitives.
const std::vector< ref< Uniform > > & uniforms() const
Equivalent to gocUniformSet()->uniforms(...)
Definition: Shader.hpp:2205
real origin() const
Definition: Plane.hpp:76
float linearAttenuation() const
Definition: Light.hpp:96
An array of vl::uvec3.
Definition: Array.hpp:441
void setPosition(const fvec4 &position)
The position or direction of a light.
Definition: Light.hpp:77
VLX wrapper of vl::Viewport.
Wraps a GLSL tessellation evaluation shader to be bound to a GLSLProgram: this shader will run on the...
Definition: GLSL.hpp:190
int renderBlock() const
Returns the rendering block of an Actor.
Definition: Actor.hpp:249
double getReal() const
Definition: Value.hpp:506
Wraps a GLSL program to which you can bind vertex, fragment and geometry shaders. ...
Definition: GLSL.hpp:233
VLXValue export_Sphere(const vl::Sphere &sphere)
float constantAttenuation() const
Definition: Light.hpp:108
Base cass for all class wrappers implementing the translation to/from its VLX representation.
VLX wrapper of vl::GLSLProgram.
Wraps an OpenGL texture object representing and managing all the supported texture types...
Definition: Texture.hpp:143
const Collection< ActorEventCallback > * actorEventCallbacks() const
Returns the list of ActorEventCallback bound to an Actor.
Definition: Actor.hpp:370
bool isBufferObjectEnabled() const
Returns true if BufferObject (vertex buffer object) are enabled for a Renderable (enabled by default)...
Definition: Renderable.hpp:201
void setWrapS(ETexParamWrap texturewrap)
Definition: Texture.hpp:87
void setValue(const fvec3 &color)
Definition: Shader.hpp:176
void setSpecular(const fvec4 &specularcolor)
Definition: Light.hpp:68
void setLeft(real v)
Definition: Camera.hpp:114
void resize(size_t dim)
Definition: Array.hpp:233
real left() const
&#39;left&#39; parameter as passed to the last setProjectionFrustum() or setProjectionOrtho*() ...
Definition: Camera.hpp:113
void setBoundingSphere(const Sphere &sphere)
Sets the bounding sphere of a Renderable.
Definition: Renderable.hpp:140
void setNormalArray(ArrayAbstract *data)
Conventional normal array.
Definition: Geometry.cpp:164
void exportGLSLProgram(VLXSerializer &s, const vl::GLSLProgram *obj, VLXStructure *vlx)
vl::vec3 vlx_vec3(const VLXArrayReal *arr)
Definition: vlxutils.hpp:56
See MultiDrawElements.
real nearPlane() const
The near clipping plane.
Definition: Camera.hpp:103
void setSecondaryColorArray(ArrayAbstract *data)
Conventional secondary color array.
Definition: Geometry.cpp:195
const char * vlx_ETexCompareMode(vl::ETexCompareMode tcm)
Definition: vlxutils.hpp:991
void setLinearAttenuation(float linearattenuation)
If the light is positional, rather than directional, its intensity is attenuated by the reciprocal of...
Definition: Light.hpp:95
void setUniformMatrix3f(int count, const float *value)
Definition: Uniform.hpp:122
void setDiffuse(const fvec4 &diffusecolor)
Definition: Light.hpp:65
An array of vl::ubvec2.
Definition: Array.hpp:457
void signalExportError(const vl::String &str)
Definition: Seriailzer.cpp:186
void setColorArray(const fvec4 &color)
Fills the color array with the given color.
Definition: Geometry.hpp:108
const UniformSet * getUniformSet() const
Returns the installed UniformSet.
Definition: Actor.hpp:345
EUniformType type() const
Definition: Uniform.hpp:259
virtual vl::ref< vl::Object > importVLX(VLXSerializer &s, const VLXStructure *vlx)
An array of GLdouble.
Definition: Array.hpp:419
const char * vlx_EProjectionMatrixType(vl::EProjectionMatrixType pt)
Definition: vlxutils.hpp:257
VLXStructure * getStructure()
Definition: Value.hpp:402
const std::string & source() const
Returns the sources for this shader.
Definition: GLSL.hpp:72
const mat4 & localMatrix() const
The matrix representing the transform&#39;s local space.
Definition: Transform.hpp:145
virtual vl::ref< VLXStructure > exportVLX(VLXSerializer &s, const vl::Object *obj)
void setLocalAndWorldMatrix(const mat4 &matrix)
Sets both the local and the world matrices.
Definition: Transform.hpp:176
void setBackSpecular(const fvec4 &color)
Definition: Shader.hpp:813
void importResourceDatabase(VLXSerializer &s, const VLXStructure *vlx, vl::ResourceDatabase *resdb)
void setBackEmission(const fvec4 &color)
Definition: Shader.hpp:814
const std::vector< ref< Uniform > > & uniforms() const
Definition: UniformSet.hpp:68
void setFormat(ETextureFormat format)
Definition: Texture.hpp:181
Texture * texture()
The texture sampler by a texture unit.
Definition: Shader.hpp:1768
void importClipPlane(VLXSerializer &s, const VLXStructure *vlx, vl::ClipPlane *obj)
void setEnableMask(unsigned int mask)
The enable mask of an Actor is usually used to defines whether the actor should be rendered or not de...
Definition: Actor.hpp:265
void exportDrawCallBase(VLXSerializer &s, const vl::DrawCall *obj, VLXStructure *vlx)
bool genMipmaps() const
Definition: Texture.hpp:188
void setSpotCutoff(float spotcutoff)
Valid values are from 0.0f to 90.0f plus the special value 180.0f (default) which disables the spot l...
Definition: Light.hpp:88
void importPatchParameter(const VLXStructure *vlx, vl::PatchParameter *pp)
void setBoundingBox(const AABB &aabb)
Sets the bounding box of a Renderable.
Definition: Renderable.hpp:129
unsigned int enableMask() const
The enable mask of an Actor is usually used to defines whether the actor should be rendered or not de...
Definition: Actor.hpp:270
const fvec4 & backAmbient() const
Definition: Shader.hpp:817
virtual vl::ref< vl::Object > importVLX(VLXSerializer &s, const VLXStructure *vlx)
bool isDisplayListEnabled() const
Returns true if display lists are enabled for a Renderable (disabled by default). ...
Definition: Renderable.hpp:189
void getUniform(double *value) const
Definition: Uniform.hpp:230
void setPatchVertices(int vertices)
Specifies the number of vertices that will be used to make up a single patch primitive.
RenderState wrapping the OpenGL function glColor(), see also http://www.opengl.org/sdk/docs/man/xhtml...
Definition: Shader.hpp:94
const fvec3 & spotDirection() const
Definition: Light.hpp:82
void exportResourceDatabase(VLXSerializer &s, const vl::ResourceDatabase *obj, VLXStructure *vlx)
The Geometry class is a Renderable that implements a polygonal mesh made of polygons, lines and points.
Definition: Geometry.hpp:66
EUniformType
Uniform types, see also vl::UniformInfo, vl::GLSLProgram, vl::Uniform, http://www.opengl.org/sdk/docs/man4/xhtml/glGetActiveUniform.xml.
void importMaterial(VLXSerializer &s, const VLXStructure *vlx, vl::Material *obj)
const ArrayAbstract * colorArray() const
Conventional color array.
Definition: Geometry.hpp:260
int activeLod() const
Returns the lod to be used for rendering.
Definition: Effect.hpp:217
void importGLSLProgram(VLXSerializer &s, const VLXStructure *vlx, vl::GLSLProgram *obj)
void setPatchDefaultInnerLevel(const fvec2 &level)
The two floating-point values corresponding to the tow inner tessellation levels for each subsequent ...
vl::Object * importVLX(const VLXStructure *st)
Definition: Seriailzer.cpp:50
Viewport * viewport()
The viewport bound to a camera.
Definition: Camera.hpp:141
const fvec4 & backSpecular() const
Definition: Shader.hpp:819
std::vector< VLXValue > & value()
Definition: Value.hpp:652
virtual vl::ref< vl::Object > importVLX(VLXSerializer &s, const VLXStructure *vlx)
void setUniform4i(int count, const int *value)
Definition: Uniform.hpp:102
const fvec4 & diffuse() const
Definition: Light.hpp:66
ETexParamFilter minFilter() const
Definition: Texture.hpp:72
void setUniformMatrix2x4f(int count, const float *value)
Definition: Uniform.hpp:127
void setCompareFunc(ETexCompareFunc func)
Definition: Texture.hpp:94
Wraps a GLSL tessellation control shader to be bound to a GLSLProgram: the shader this shader will ru...
Definition: GLSL.hpp:172
void importLight(VLXSerializer &s, const VLXStructure *vlx, vl::Light *obj)
VLX wrapper of vl::SecondaryColor.
virtual vl::ref< VLXStructure > exportVLX(VLXSerializer &s, const vl::Object *obj)
const fvec4 & frontAmbient() const
Definition: Shader.hpp:805
Wraps a GLSL fragment shader to be bound to a GLSLProgram: the shader this shader will run on the pro...
Definition: GLSL.hpp:136
virtual vl::ref< VLXStructure > exportVLX(VLXSerializer &s, const vl::Object *obj)
void setGenerateMipmap(bool generate_mipmap)
Definition: Texture.hpp:92
virtual bool primitiveRestartEnabled() const
Returns whether the primitive-restart functionality is enabled or not.
void setClearColorUInt(unsigned int r, unsigned int g, unsigned int b, unsigned int a)
Definition: Viewport.hpp:87
bool generateMipmap() const
Definition: Texture.hpp:79
const char * vlx_EClearFlags(vl::EClearFlags cf)
Definition: vlxutils.hpp:303
const char * vlx_EEnable(vl::EEnable en)
Definition: vlxutils.hpp:1099
long long getInteger() const
Definition: Value.hpp:495
Base interface for all DrawElements* sub classes.
virtual vl::ref< VLXStructure > exportVLX(VLXSerializer &s, const vl::Object *obj)
DepthSortCallback sorts the primitives of the Geometry bound to the Actor in which the callback is in...
int count() const
Definition: Uniform.hpp:261
const unsigned char * ptr() const
Returns the pointer to the first element of the local buffer. Equivalent to bufferObject()->ptr() ...
Definition: Array.hpp:103
Transform * boundTransform()
Returns the vl::Transform to which the Light is attached.
Definition: ClipPlane.hpp:71
A list of key/VLXValue pairs, can also have a tag.
Definition: Value.hpp:541
virtual void exportRenderable(const vl::Renderable *obj, VLXStructure *vlx)
const char * vlx_ETexParamFilter(vl::ETexParamFilter tpf)
Definition: vlxutils.hpp:1045
void * rawData()
Definition: Uniform.hpp:316
float quadraticAttenuation() const
Definition: Light.hpp:102
const fvec4 & frontDiffuse() const
Definition: Shader.hpp:806
EClearColorMode clearColorMode() const
Definition: Viewport.hpp:102
void exportSecondaryColor(const vl::SecondaryColor *obj, VLXStructure *vlx)
virtual vl::ref< VLXStructure > exportVLX(VLXSerializer &s, const vl::Object *obj)
void setFixedSamplesLocations(bool fixed)
Definition: Texture.hpp:203
Base class for most of the OpenGL render state wrapper classes.
Definition: RenderState.hpp:50
void setMinFilter(ETexParamFilter minfilter)
Definition: Texture.hpp:84
An array of vl::ivec3.
Definition: Array.hpp:432
void setRenderState(RenderStateNonIndexed *renderstate)
Definition: Shader.hpp:2172
PatchParameter * patchParameter()
The PatchParameter attached to a DrawCall to be used when using primitive-type PT_PATCHES.
Definition: DrawCall.hpp:172
int lineNumber() const
Definition: Value.hpp:55
void setUniformMatrix4x3d(int count, const double *value)
Definition: Uniform.hpp:141
void exportColor(const vl::Color *obj, VLXStructure *vlx)
void setDepthTextureMode(EDepthTextureMode mode)
Definition: Texture.hpp:95
EProjectionMatrixType
void setStart(int start)
sets the starting vertex for the rendering.
Definition: DrawArrays.hpp:120
virtual vl::ref< vl::Object > importVLX(VLXSerializer &s, const VLXStructure *vlx)
void exportUniform(const vl::Uniform *uniform, VLXStructure *vlx)
void setImagePath(const String &path)
Definition: Texture.hpp:168
void setCount(int count)
sets the number of vertices to be rendered.
Definition: DrawArrays.hpp:126
VLX wrapper of vl::Light.
void setFrontEmission(const fvec4 &color)
Definition: Shader.hpp:802
vl::Sphere import_Sphere(const VLXStructure *vlx)
bool isOccludee() const
If is_occludee equals true an occlusion test will be performed before the rendering of the Actor (if ...
Definition: Actor.hpp:427
void setBackShininess(float shininess)
Definition: Shader.hpp:815
void exportDrawCall(VLXSerializer &s, const vl::DrawCall *dcall, VLXStructure *vlx)
int height() const
Definition: Viewport.hpp:71
VLX wrapper of vl::Color.
virtual void computePointerVector()=0
Computes the pointer vector to be used when BufferObjects are DISABLED.
real fov() const
The field of view of the camera.
Definition: Camera.hpp:96
Wraps the OpenGL function glClipPlane().
Definition: ClipPlane.hpp:49
int width() const
Definition: Viewport.hpp:69
const char * vlx_EDepthTextureMode(vl::EDepthTextureMode dtm)
Definition: vlxutils.hpp:967
EColorMaterial
const char * vlx_ETexCompareFunc(vl::ETexCompareFunc tcf)
Definition: vlxutils.hpp:1013
void setValue(const fvec3 &color)
Definition: Shader.hpp:142
const std::map< std::string, int > & fragDataLocations() const
Definition: GLSL.hpp:353
real top() const
&#39;top&#39; parameter as passed to the last setProjectionFrustum() or setProjectionOrtho*() ...
Definition: Camera.hpp:125
An array of GLushort.
Definition: Array.hpp:473
For internal use only.
Definition: GLSL.hpp:50
void setSamples(int samples)
Definition: Texture.hpp:200
VLX wrapper of vl::Geometry.
void setConstantAttenuation(float constantattenuation)
If the light is positional, rather than directional, its intensity is attenuated by the reciprocal of...
Definition: Light.hpp:107
const std::vector< ref< Object > > & resources() const
size_t childrenCount() const
Returns the number of child Transform.
Definition: Transform.hpp:243
void importActor(VLXSerializer &s, const VLXStructure *vlx, vl::Actor *obj)
const std::string & name() const
Returns the name of the uniform variable.
Definition: Uniform.hpp:86
RenderState wrapping the OpenGL function glVertexAttrib(), see also http://www.opengl.org/sdk/docs/man3/xhtml/glVertexAttrib.xml for more information.
Definition: Shader.hpp:60
virtual vl::ref< vl::Object > importVLX(VLXSerializer &s, const VLXStructure *vlx)
A simple sequence of VLXValue objects, can also have a tag.
Definition: Value.hpp:634
UniformSet * getUniformSet()
Returns a GLSLProgram&#39;s static UniformSet. Static uniforms are those uniforms whose value is constant...
Definition: GLSL.hpp:470
An array of vl::ubvec3.
Definition: Array.hpp:459
virtual vl::ref< vl::Object > importVLX(VLXSerializer &s, const VLXStructure *vlx)
void exportShader(VLXSerializer &s, const vl::Shader *obj, VLXStructure *vlx)
The base class for all the reference counted objects.
Definition: Object.hpp:158
See DrawElements.
void setRenderRank(int rank)
Modifies the rendering rank of an Actor.
Definition: Actor.hpp:231
void signalImportError(const vl::String &str)
Definition: Seriailzer.cpp:176
An array of vl::dvec2.
Definition: Array.hpp:421
const Plane & plane() const
Returns the actual plane used to perform the clipping.
Definition: ClipPlane.hpp:77
void setBorderColor(fvec4 bordercolor)
Definition: Texture.hpp:90
virtual vl::ref< VLXStructure > exportVLX(VLXSerializer &s, const vl::Object *obj)
void exportGeometry(VLXSerializer &s, const vl::Geometry *geom, VLXStructure *vlx)
vl::uvec4 vlx_uivec4(const VLXArrayInteger *arr)
Definition: vlxutils.hpp:62
void get(std::vector< ref< T > > &resources, bool clear_vector=true)
Returns all the objects of the specified type in the given vector.
const std::string & tag() const
Definition: Value.hpp:63
An abstract class that represents all the objects that can be rendered.
Definition: Renderable.hpp:58
The TextureSampler class associates a Texture object to an OpenGL texture unit.
Definition: Shader.hpp:1747
const uvec4 & clearColorUInt() const
Definition: Viewport.hpp:89
void setSource(const String &source_or_path)
Sets the sources for this shader and schedules a recompilation for it. If the string passed is a file...
Definition: GLSL.cpp:115
virtual vl::ref< VLXStructure > exportVLX(VLXSerializer &s, const vl::Object *obj)
vl::ivec4 vlx_ivec4(const VLXArrayInteger *arr)
Definition: vlxutils.hpp:60
virtual vl::ref< vl::Object > importVLX(VLXSerializer &s, const VLXStructure *vlx)
virtual vl::ref< VLXStructure > exportVLX(VLXSerializer &s, const vl::Object *obj)
ETexParamWrap wrapR() const
Definition: Texture.hpp:76
virtual vl::ref< vl::Object > importVLX(VLXSerializer &s, const VLXStructure *vlx)
void setValue(const fvec4 &value)
Definition: Shader.hpp:74
int count() const
returns the number of vertices to be rendered.
Definition: DrawArrays.hpp:129
bool canExport(const vl::Object *obj) const
Definition: Seriailzer.cpp:124
const std::vector< double > & distanceRangeSet() const
void setUniformMatrix2d(int count, const double *value)
Definition: Uniform.hpp:132
int renderRank() const
Returns the rendering rank of an Actor.
Definition: Actor.hpp:246
VLX wrapper of vl::Actor.
LODEvaluator * lodEvaluator()
Returns the installed LODEvaluator (if any) or NULL.
Definition: Actor.hpp:255
void setUniform3ui(int count, const unsigned int *value)
Definition: Uniform.hpp:106
An array of vl::bvec4.
Definition: Array.hpp:452
virtual void computeBufferObjectPointerVector()=0
Computes the pointer vector to be used when BufferObjects are ENABLED.
Transform * boundTransform()
Definition: Light.cpp:119
bool empty() const
Returns true if length() == 0.
Definition: String.hpp:136
Implements the viewport and clearing settings associated to a Camera.
Definition: Viewport.hpp:51
ETexParamWrap wrapS() const
Definition: Texture.hpp:74
real farPlane() const
The far clipping plane.
Definition: Camera.hpp:110
VLXValue vlx_Identifier(const std::string &str)
Definition: vlxutils.hpp:46
LODEvaluator * lodEvaluator()
Returns the installed LODEvaluator (if any) or NULL.
Definition: Effect.hpp:194
void setTransform(Transform *transform)
Binds a Transform to an Actor.
Definition: Actor.hpp:182
void setClearDepth(real depth)
Definition: Viewport.hpp:94
fvec4 borderColor() const
Definition: Texture.hpp:77
real bottom() const
&#39;bottom&#39; parameter as passed to the last setProjectionFrustum() or setProjectionOrtho*() ...
Definition: Camera.hpp:121
void setUniform(Uniform *uniform)
Utility function using getUniformSet(). Adds a Uniform to this program&#39;s static uniform set...
Definition: GLSL.hpp:476
void setBackAmbient(const fvec4 &color)
Definition: Shader.hpp:811
void exportTexParameter(const vl::TexParameter *texparam, VLXStructure *vlx)
void setRight(real v)
Definition: Camera.hpp:118
int x() const
Definition: Viewport.hpp:65
const BufferObject * bufferObject() const
Definition: Texture.hpp:174
void setRenderRank(int rank)
Modifies the rendering rank of an Actor.
Definition: Effect.hpp:164
void setOccludee(bool is_occludee)
If is_occludee equals true an occlusion test will be performed before the rendering of the Actor (if ...
Definition: Actor.hpp:423
virtual vl::ref< vl::Object > importVLX(VLXSerializer &s, const VLXStructure *vlx)
void setUniformMatrix4x3f(int count, const float *value)
Definition: Uniform.hpp:130
void registerExportedObject(const vl::Object *obj, VLXStructure *st)
Definition: Seriailzer.cpp:146
void setUniformMatrix3x2f(int count, const float *value)
Definition: Uniform.hpp:126
void setTexCoordArray(int tex_unit, ArrayAbstract *data)
Conventional texture coords arrays.
Definition: Geometry.cpp:222
void setProjectionMatrix(const mat4 &mat, EProjectionMatrixType proj_type)
The Camera&#39;s projection matrix.
Definition: Camera.hpp:172
A sequence of Shader objects each of which represent a rendering pass.
Definition: Effect.hpp:51
void setPatchDefaultOuterLevel(const fvec4 &level)
The four floating-point values corresponding to the four outer tessellation levels for each subsequen...
void setQuadraticAttenuation(float quadraticattenuation)
If the light is positional, rather than directional, its intensity is attenuated by the reciprocal of...
Definition: Light.hpp:101
virtual vl::ref< vl::Object > importVLX(VLXSerializer &s, const VLXStructure *vlx)
#define VLX_IMPORT_CHECK_RETURN_NULL(Condition, Obj)
virtual vl::ref< vl::Object > importVLX(VLXSerializer &s, const VLXStructure *vlx)
T * as()
Casts an Object to the specified class.
Definition: Object.hpp:282
void setDimension(ETextureDimension dimension)
Definition: Texture.hpp:178
void setLODEvaluator(LODEvaluator *lod_evaluator)
Installs the LODEvaluator used to compute the current LOD at rendering time.
Definition: Effect.hpp:191
void importShader(VLXSerializer &s, const VLXStructure *vlx, vl::Shader *sh)
std::vector< KeyValue > & value()
Definition: Value.hpp:607
ETextureDimension dimension() const
Definition: Texture.hpp:179
void setUniform2ui(int count, const unsigned int *value)
Definition: Uniform.hpp:105
void setEnabled(bool enabled)
Whether an Actor should be considered for rendering, picking, scene bounding box calculation etc...
Definition: Actor.hpp:274
void setUniformMatrix4f(int count, const float *value)
Definition: Uniform.hpp:123
int patchVertices() const
Returns the number of vertices that will be used to make up a single patch primitive.
VLX wrapper of vl::ClipPlane.
VLX wrapper of vl::Transform.
void setUniform(Uniform *uniform)
Equivalent to getUniformSet()->setUniform(uniform)
Definition: Actor.cpp:119
void setActiveLod(int lod)
Sets the lod to be used for rendering.
Definition: Effect.hpp:209
The ActorEventCallback class defines a callback object to react to Actor-related events.
Definition: Actor.hpp:75
#define NULL
Definition: OpenGLDefs.hpp:81
int renderRank() const
Returns the rendering rank of an Effect.
Definition: Effect.hpp:167
void importNormal(VLXSerializer &s, const VLXStructure *vlx, vl::Normal *obj)
void setViewMatrix(const mat4 &mat)
Sets the Camera&#39;s view matrix (inverse of the modeling matrix).
Definition: Camera.hpp:157
Manages most of the OpenGL rendering states responsible of the final aspect of the rendered objects...
Definition: Shader.hpp:1830
An array of vl::ivec2.
Definition: Array.hpp:430
VLX wrapper of vl::DepthSortCallback.
void setSpotExponent(float spotexponent)
Definition: Light.hpp:84
unsigned int enableMask() const
The enable mask of an Actor&#39;s Effect defines whether the actor should be rendered or not depending on...
Definition: Effect.hpp:203
float anisotropy() const
Definition: Texture.hpp:78
void setPrimitiveRestartEnabled(bool enabled)
Enables the primitive-restart functionality.
real clearDepth() const
Definition: Viewport.hpp:95
VLX wrapper of vl::Camera.
arr_type * indexBuffer()
The BufferObject containing the indices used to render.
const ref< Transform > * children() const
Returns the array containing the child Transforms.
Definition: Transform.hpp:237
void setWidth(int width)
Definition: Viewport.hpp:68
An array of 64 bits integers, can also have a tag.
Definition: Value.hpp:133
void setClearColorMode(EClearColorMode mode)
Definition: Viewport.hpp:101
Abstract class to compute the appropriate LOD of an Actor or Effect.
void setSpotDirection(const fvec3 &spotdirection)
Definition: Light.hpp:81
A LODEvaluator that computes the appropriate LOD based on the distance of an Actor from the Camera...
An array of GLfloat.
Definition: Array.hpp:410
RenderState wrapping the OpenGL function glMaterial() and glColorMaterial(), see also http://www...
Definition: Shader.hpp:774
Defines the sequence of Shader objects used to render an Actor.
Definition: Effect.hpp:91
const fvec4 & frontSpecular() const
Definition: Shader.hpp:807
void importColor(VLXSerializer &s, const VLXStructure *vlx, vl::Color *obj)
See MultiDrawElements.
virtual vl::ref< VLXStructure > exportVLX(VLXSerializer &s, const vl::Object *obj)
void setUniformMatrix2x3f(int count, const float *value)
Definition: Uniform.hpp:125
An array of vl::usvec2.
Definition: Array.hpp:475
#define VLX_IMPORT_CHECK_RETURN(Condition, Obj)
void setDisplayListEnabled(bool enabled)
Enable/disable display lists (disabled by default).
Definition: Renderable.hpp:192
Effect * effect()
Returns the Effect bound to an Actor.
Definition: Actor.hpp:199
std::vector< T > & value()
Definition: Value.hpp:116
void setUniform4ui(int count, const unsigned int *value)
Definition: Uniform.hpp:107
EEnable
Constant that enable/disable a specific OpenGL feature, see also Shader, Shader::enable(), Shader::disable(), Shader::isEnabled()
The BufferObject class is a Buffer that can upload its data on the GPU memory.
const ivec4 & clearColorInt() const
Definition: Viewport.hpp:85
int instances() const
Returns the number of instances for this set of primitives.
VLX wrapper of vl::GLSLVertexShader, vl::GLSLFragmentShader, vl::GLSLGeometryShader, vl::GLSLTessControlShader, vl::GLSLTessEvaluationShader.
ETexParamFilter magFilter() const
Definition: Texture.hpp:73
vl::vec2 vlx_vec2(const VLXArrayReal *arr)
Definition: vlxutils.hpp:54
const vec3 & normal() const
Definition: Plane.hpp:74
const fvec4 & specular() const
Definition: Light.hpp:69
An array of vl::ubvec4.
Definition: Array.hpp:461
const std::string & objectName() const
The name of the object, by default set to the object&#39;s class name.
Definition: Object.hpp:217
virtual vl::ref< VLXStructure > exportVLX(VLXSerializer &s, const vl::Object *obj)
virtual vl::ref< VLXStructure > exportVLX(VLXSerializer &s, const vl::Object *obj)
void setColorMaterial(EPolygonFace face, EColorMaterial color)
Definition: Shader.hpp:825
int clearStencil() const
Definition: Viewport.hpp:92
void exportTexture(VLXSerializer &s, const vl::Texture *obj, VLXStructure *vlx)
VLXValue vlx_Rawtext(const std::string &str)
Definition: vlxutils.hpp:52
void setUniform2f(int count, const float *value)
Definition: Uniform.hpp:110
An array of vl::bvec2.
Definition: Array.hpp:448
The base class of DrawArrays, DrawElements, MultiDrawElements and DrawRangeElements.
Definition: DrawCall.hpp:90
UniformSet * getUniformSet()
Returns the UniformSet installed.
Definition: Shader.hpp:2261
SetupParams wraps all the parameters needed to crate a Texture.
Definition: Texture.hpp:154
An array of vl::dvec3.
Definition: Array.hpp:423
VLX wrapper of vl::VertexAttrib.
virtual vl::ref< vl::Object > importVLX(VLXSerializer &s, const VLXStructure *vlx)
void setFrontDiffuse(const fvec4 &color)
Definition: Shader.hpp:800
Unknown or other projection type.
void setLODEvaluator(LODEvaluator *lod_evaluator)
Installs the LODEvaluator used to compute the current LOD at rendering time.
Definition: Actor.hpp:252
virtual vl::ref< VLXStructure > exportVLX(VLXSerializer &s, const vl::Object *obj)
void setColorMaterialEnabled(bool enabled)
Definition: Shader.hpp:828
Translates an arbitrary set of vl::Object (and subclasses) into VLB and VLT format.
Definition: Serializer.hpp:45
void bindTransform(Transform *transform)
Bind the camera to a Transform.
Definition: Camera.hpp:147
void importTransform(VLXSerializer &s, const VLXStructure *vlx, vl::Transform *obj)
RenderStateSet * getRenderStateSet()
Definition: Shader.hpp:2235
void setName(const char *name)
Sets the name of the uniform variable.
Definition: Uniform.hpp:92
void setUniformMatrix2x4d(int count, const double *value)
Definition: Uniform.hpp:138
virtual vl::ref< VLXStructure > exportVLX(VLXSerializer &s, const vl::Object *obj)
An array of vl::svec2.
Definition: Array.hpp:466
void bindTransform(Transform *transform)
If NULL follows the camera otherwise the given transformation node.
Definition: Light.cpp:114
void importSecondaryColor(VLXSerializer &s, const VLXStructure *vlx, vl::SecondaryColor *obj)
VLX wrapper of vl::ResourceDatabase.
const fvec4 & position() const
The position or direction of a light.
Definition: Light.hpp:79
const fvec4 & clearColor() const
Definition: Viewport.hpp:81
bool getBool() const
Definition: Value.hpp:517
void setValue(const fvec4 &color)
Definition: Shader.hpp:108
void exportCamera(VLXSerializer &s, const vl::Camera *obj, VLXStructure *vlx)
virtual vl::ref< VLXStructure > exportVLX(VLXSerializer &s, const vl::Object *obj)
void setLod(int lod_index, Renderable *renderable)
Sets the Renderable object representing the LOD level specifed by lod_index.
Definition: Actor.hpp:159
virtual bool primitiveRestartEnabled() const
Returns whether the primitive-restart functionality is enabled or not (requires OpenGL 3...
const fvec2 & patchDefaultInnerLevel() const
The two floating-point values corresponding to the tow inner tessellation levels for each subsequent ...
An array of vl::svec4.
Definition: Array.hpp:470
void importCamera(VLXSerializer &s, const VLXStructure *vlx, vl::Camera *obj)
virtual vl::ref< vl::Object > importVLX(VLXSerializer &s, const VLXStructure *vlx)
const String & path() const
The path from which the shader was loaded.
Definition: GLSL.hpp:78
An array of vl::bvec3.
Definition: Array.hpp:450
VLX wrapper of vl::Normal.
VLX wrapper of vl::TexParameter.
void setWrapR(ETexParamWrap texturewrap)
Definition: Texture.hpp:89
void bindFragDataLocation(int color_number, const char *name)
Definition: GLSL.cpp:775
void registerImportedStructure(const VLXStructure *st, Object *obj)
Definition: Seriailzer.cpp:140
void setY(int y)
Definition: Viewport.hpp:66
const fvec4 & value() const
Definition: Shader.hpp:110
virtual vl::ref< VLXStructure > exportVLX(VLXSerializer &s, const vl::Object *obj)
const mat4 & projectionMatrix() const
The Camera&#39;s projection matrix.
Definition: Camera.hpp:175
virtual vl::ref< VLXStructure > exportVLX(VLXSerializer &s, const vl::Object *obj)
Wraps the OpenGL function glLight().
Definition: Light.hpp:51
int lineNumber() const
Definition: Value.hpp:519
const ArrayAbstract * secondaryColorArray() const
Conventional secondary color array.
Definition: Geometry.hpp:266
const char * vlx_EColorMaterial(vl::EColorMaterial cm)
Definition: vlxutils.hpp:357
void setUniform1f(int count, const float *value)
Definition: Uniform.hpp:109
vl::mat4 vlx_mat4(const VLXArrayReal *arr)
Definition: vlxutils.hpp:182
void importRenderable(const VLXStructure *vlx, vl::Renderable *ren)
ETexParamWrap wrapT() const
Definition: Texture.hpp:75
void setEnabled(bool enable)
Enables/disables the draw call.
Definition: DrawCall.hpp:125
void setBottom(real v)
Definition: Camera.hpp:122
const ArrayAbstract * texCoordArray(int tex_unit) const
Conventional texture coords arrays.
Definition: Geometry.hpp:278
ETexCompareMode compareMode() const
Definition: Texture.hpp:80
real right() const
&#39;right&#39; parameter as passed to the last setProjectionFrustum() or setProjectionOrtho*() ...
Definition: Camera.hpp:117
float spotExponent() const
Definition: Light.hpp:85
int start() const
returns the starting vertex for the rendering.
Definition: DrawArrays.hpp:123
void setInstances(int instances)
Sets the number of instances for this set of primitives.
Definition: DrawArrays.hpp:132
std::string getShaderSource() const
Retrieves the shader source using glGetShaderSource()
Definition: GLSL.cpp:67
vl::ETextureDimension vlx_ETextureDimension(const VLXValue &value, VLXSerializer &s)
Definition: vlxutils.hpp:1258
void importTexture(VLXSerializer &s, const VLXStructure *vlx, vl::Texture *obj)
virtual vl::ref< VLXStructure > exportVLX(VLXSerializer &s, const vl::Object *obj)
void setAnisotropy(float anisotropy)
Definition: Texture.hpp:91
An array of vl::fvec3.
Definition: Array.hpp:414
virtual vl::ref< vl::Object > importVLX(VLXSerializer &s, const VLXStructure *vlx)
void setFOV(real fov)
The field of view of the camera.
Definition: Camera.hpp:93
void setFogCoordArray(ArrayAbstract *data)
Conventional fog array.
Definition: Geometry.cpp:212
const char * vlx_EUniformType(vl::EUniformType type)
Definition: vlxutils.hpp:867
VLX wrapper of vl::Renderable.
VLXArrayInteger * getArrayInteger()
Definition: Value.hpp:444
void importViewport(VLXSerializer &s, const VLXStructure *vlx, vl::Viewport *obj)
Represents a virtual camera defining, among other things, the point of view from which scenes can be ...
Definition: Camera.hpp:50
ESortMode sortMode() const
const AABB & boundingBox() const
Returns the bounding box of a Renderable without recomputing the bounds if dirty. ...
Definition: Renderable.hpp:151
static String printf(const char *fmt,...)
Returns a formatted string using the legacy printf syntax. The resulting string can be maximum 1024 +...
Definition: String.cpp:1510
EType type() const
Definition: Value.hpp:396
void importTextureSampler(VLXSerializer &s, const VLXStructure *vlx, vl::TextureSampler *obj)
void setUniform3d(int count, const double *value)
Definition: Uniform.hpp:116
virtual vl::ref< vl::Object > importVLX(VLXSerializer &s, const VLXStructure *vlx)
void importUniform(VLXSerializer &s, const VLXStructure *vlx, vl::Uniform *uniform)
int instances() const
Returns the number of instances for this set of primitives.
Definition: DrawArrays.hpp:135
std::string toStdString() const
Returns a UTF8 encoded std::string.
Definition: String.cpp:1156
const ArrayAbstract * fogCoordArray() const
Conventional fog array.
Definition: Geometry.hpp:272
void setUniform2i(int count, const int *value)
Definition: Uniform.hpp:100
EDepthTextureMode depthTextureMode() const
Definition: Texture.hpp:82
bool attachShader(GLSLShader *shader)
Attaches the GLSLShader to this GLSLProgram.
Definition: GLSL.cpp:354
virtual vl::ref< vl::Object > importVLX(VLXSerializer &s, const VLXStructure *vlx)
virtual vl::ref< vl::Object > importVLX(VLXSerializer &s, const VLXStructure *vlx)
virtual vl::ref< vl::Object > importVLX(VLXSerializer &s, const VLXStructure *vlx)
For internal use only.
EPrimitiveType primitiveType() const
Returns the draw call&#39;s primitive type.
Definition: DrawCall.hpp:110
VLX wrapper of vl::Shader.
VLX wrapper of vl::DrawCall and subclasses.
void setUniformMatrix4x2f(int count, const float *value)
Definition: Uniform.hpp:128
An array of GLint.
Definition: Array.hpp:428
const fvec4 & backEmission() const
Definition: Shader.hpp:820
const Sphere & boundingSphere() const
Returns the bounding sphere of a Renderable without recomputing the bounds if dirty.
Definition: Renderable.hpp:159
void setGenMipmaps(bool on)
Definition: Texture.hpp:187
void setTop(real v)
Definition: Camera.hpp:126
const fvec4 & frontEmission() const
Definition: Shader.hpp:808
const RenderStateSlot * renderStates() const
void setUniform1ui(int count, const unsigned int *value)
Definition: Uniform.hpp:104
Wraps the OpenGL function glDrawArrays().
Definition: DrawArrays.hpp:57
void setUniformMatrix3x4f(int count, const float *value)
Definition: Uniform.hpp:129
void setUniform(Uniform *uniform)
Equivalent to gocUniformSet()->setUniform(...)
Definition: Shader.hpp:2202
void setMagFilter(ETexParamFilter magfilter)
Definition: Shader.cpp:754
const std::string & getString() const
Definition: Value.hpp:460
VLXValue vlx_toValue(const std::vector< int > &vec)
Definition: vlxutils.hpp:64
void setUniform4f(int count, const float *value)
Definition: Uniform.hpp:112
void setUniform4d(int count, const double *value)
Definition: Uniform.hpp:117
An array of vl::fvec2.
Definition: Array.hpp:412
void setBufferObjectEnabled(bool enabled)
Enable/disable BufferObject (vertex buffer object) (enabled by default).
Definition: Renderable.hpp:204
int shaderCount() const
Returns the number of GLSLShader objects bound to this GLSLProgram.
Definition: GLSL.hpp:334
void setBufferObject(BufferObject *bo)
Definition: Texture.hpp:176
bool fixedSamplesLocations() const
Definition: Texture.hpp:202
virtual vl::ref< VLXStructure > exportVLX(VLXSerializer &s, const vl::Object *obj)
#define VL_CHECK(expr)
Definition: checks.hpp:73
const fvec3 & value() const
Definition: Shader.hpp:144
const Image * image() const
Definition: Texture.hpp:172
VLXArrayReal * getArrayReal()
Definition: Value.hpp:447
void importLODEvaluator(VLXSerializer &s, const VLXStructure *vlx, vl::LODEvaluator *obj)
void enable(EEnable capability)
Definition: Shader.hpp:2158
void setRenderBlock(int block)
Modifies the rendering block of an Actor.
Definition: Actor.hpp:243
void setUniformMatrix3x2d(int count, const double *value)
Definition: Uniform.hpp:137
VLX wrapper of vl::TextureSampler.
An array of vl::usvec3.
Definition: Array.hpp:477
const GLSLShader * shader(int i) const
Returns the i-th GLSLShader objects bound to this GLSLProgram.
Definition: GLSL.hpp:337
void setX(int x)
Definition: Viewport.hpp:64
void setHeight(int height)
Definition: Viewport.hpp:70
const char * vlx_ETexParamWrap(vl::ETexParamWrap tpw)
Definition: vlxutils.hpp:1073
void setUniform1d(int count, const double *value)
Definition: Uniform.hpp:114
A LODEvaluator that computes the appropriate LOD based on the approximate 2d area that an Actor cover...
void importActorEventCallback(VLXSerializer &s, const VLXStructure *vlx, vl::ActorEventCallback *obj)
void addChild(Transform *child)
Adds a child transform.
Definition: Transform.hpp:246
void setCompareMode(ETexCompareMode mode)
Definition: Texture.hpp:93
void setNormal(const vec3 &normal)
Definition: Plane.hpp:78
const ArrayAbstract * normalArray() const
Conventional normal array.
Definition: Geometry.hpp:254
virtual vl::ref< VLXStructure > exportVLX(VLXSerializer &s, const vl::Object *obj)
void exportLight(VLXSerializer &s, const vl::Light *obj, VLXStructure *vlx)
ref< RenderState > mRS
bool canImport(const VLXStructure *st) const
Definition: Seriailzer.cpp:132
VLX wrapper of vl::Effect.
float backShininess() const
Definition: Shader.hpp:821
An array of GLbyte.
Definition: Array.hpp:446
const std::string & getIdentifier() const
Definition: Value.hpp:472
void resolvePath(std::string &path)
If the given path starts with "this:" then the "this:" prefix is replaced with the documentURL()...
Definition: Seriailzer.cpp:439
An array of vl::dvec4.
Definition: Array.hpp:425
void setOrigin(real origin)
Definition: Plane.hpp:80
const fvec4 & ambient() const
Definition: Light.hpp:63
The ResourceDatabase class contains and manipulates a set of resources.
void setAmbient(const fvec4 &ambientcolor)
Definition: Light.hpp:62
void setUniform2d(int count, const double *value)
Definition: Uniform.hpp:115
virtual vl::ref< vl::Object > importVLX(VLXSerializer &s, const VLXStructure *vlx)
Collection< DrawCall > & drawCalls()
Returns the list of DrawCall objects bound to a Geometry.
Definition: Geometry.hpp:102
const fvec3 & value() const
Definition: Shader.hpp:178
vl::AABB import_AABB(const VLXStructure *vlx)
const ref< ShaderPasses > & lod(int lod_level) const
Returns the ShaderPasses representing the specified LOD level.
Definition: Effect.hpp:171
void importEffect(VLXSerializer &s, const VLXStructure *vlx, vl::Effect *obj)
bool colorMaterialEnabled() const
Definition: Shader.hpp:829
RenderState wrapping the OpenGL function glSecondaryColor(), see also http://www.opengl.org/sdk/docs/man/xhtml/glSecondaryColor.xml for more information.
Definition: Shader.hpp:128
void setPrimitiveRestartEnabled(bool enabled)
Enables the primitive-restart functionality (requires OpenGL 3.1).
VLX wrapper of vl::PatchParameter.
EClearFlags clearFlags() const
Definition: Viewport.hpp:99
void setClearFlags(EClearFlags clear_flags)
Usually you want to use rather RendererAbstract::setClearFlags()
Definition: Viewport.hpp:98
EPolygonFace colorMaterialFace() const
Definition: Shader.hpp:826
const fvec4 & patchDefaultOuterLevel() const
The four floating-point values corresponding to the four outer tessellation levels for each subsequen...
const std::vector< EEnable > & enables() const
Definition: EnableSet.hpp:89
An array of GLshort.
Definition: Array.hpp:464
Wrapper of glPatchParameter(), specifies the parameters for patch primitives, used by vl::DrawCall::s...
void setUniformMatrix2x3d(int count, const double *value)
Definition: Uniform.hpp:136
VLXValue export_ShaderPasses(VLXSerializer &s, const vl::ShaderPasses *sh_seq)
VLXValue export_AABB(const vl::AABB &aabb)
void setUniform3i(int count, const int *value)
Definition: Uniform.hpp:101
void setUniformMatrix4d(int count, const double *value)
Definition: Uniform.hpp:134