Irrlicht 3D Engine
IQ3Shader.h
Go to the documentation of this file.
1 // Copyright (C) 2006-2012 Nikolaus Gebhardt / Thomas Alten
2 // This file is part of the "Irrlicht Engine".
3 // For conditions of distribution and use, see copyright notice in irrlicht.h
4 
5 #ifndef __I_Q3_LEVEL_SHADER_H_INCLUDED__
6 #define __I_Q3_LEVEL_SHADER_H_INCLUDED__
7 
8 #include "irrArray.h"
9 #include "fast_atof.h"
10 #include "IFileSystem.h"
11 #include "IVideoDriver.h"
12 #include "coreutil.h"
13 
14 namespace irr
15 {
16 namespace scene
17 {
18 namespace quake3
19 {
20 
21  static core::stringc irrEmptyStringc("");
22 
25  {
32  };
33 
38  {
43  patchTesselation ( 8 ),
44  verbose ( 0 ),
45  startTime ( 0 ), endTime ( 0 ),
46  mergeShaderBuffer ( 1 ),
48  loadAllShaders ( 0 ),
49  loadSkyShader ( 0 ),
50  alpharef ( 1 ),
51  swapLump ( 0 ),
52  #ifdef __BIG_ENDIAN__
53  swapHeader ( 1 )
54  #else
55  swapHeader ( 0 )
56  #endif
57  {
58  memcpy ( scriptDir, "scripts\x0", 8 );
59  }
60 
75  c8 scriptDir [ 64 ];
76  };
77 
78  // some useful typedefs
81 
82  // string helper.. TODO: move to generic files
83  inline s16 isEqual ( const core::stringc &string, u32 &pos, const c8 * const list[], u16 listSize )
84  {
85  const char * in = string.c_str () + pos;
86 
87  for ( u16 i = 0; i != listSize; ++i )
88  {
89  if (string.size() < pos)
90  return -2;
91  u32 len = (u32) strlen ( list[i] );
92  if (string.size() < pos+len)
93  continue;
94  if ( in [len] != 0 && in [len] != ' ' )
95  continue;
96  if ( strncmp ( in, list[i], len ) )
97  continue;
98 
99  pos += len + 1;
100  return (s16) i;
101  }
102  return -2;
103  }
104 
105  inline f32 getAsFloat ( const core::stringc &string, u32 &pos )
106  {
107  const char * in = string.c_str () + pos;
108 
109  f32 value = 0.f;
110  pos += (u32) ( core::fast_atof_move ( in, value ) - in ) + 1;
111  return value;
112  }
113 
115  inline core::vector3df getAsVector3df ( const core::stringc &string, u32 &pos )
116  {
117  core::vector3df v;
118 
119  v.X = getAsFloat ( string, pos );
120  v.Z = getAsFloat ( string, pos );
121  v.Y = getAsFloat ( string, pos );
122 
123  return v;
124  }
125 
126 
127  /*
128  extract substrings
129  */
130  inline void getAsStringList ( tStringList &list, s32 max, const core::stringc &string, u32 &startPos )
131  {
132  list.clear ();
133 
134  s32 finish = 0;
135  s32 endPos;
136  do
137  {
138  endPos = string.findNext ( ' ', startPos );
139  if ( endPos == -1 )
140  {
141  finish = 1;
142  endPos = string.size();
143  }
144 
145  list.push_back ( string.subString ( startPos, endPos - startPos ) );
146  startPos = endPos + 1;
147 
148  if ( list.size() >= (u32) max )
149  finish = 1;
150 
151  } while ( !finish );
152 
153  }
154 
156  struct SBlendFunc
157  {
159  : type ( video::EMT_SOLID ), modulate ( mod ),
160  param0( 0.f ),
161  isTransparent ( 0 ) {}
162 
165 
168  };
169 
170  // parses the content of Variable cull
171  inline bool getCullingFunction ( const core::stringc &cull )
172  {
173  if ( cull.size() == 0 )
174  return true;
175 
176  bool ret = true;
177  static const c8 * funclist[] = { "none", "disable", "twosided" };
178 
179  u32 pos = 0;
180  switch ( isEqual ( cull, pos, funclist, 3 ) )
181  {
182  case 0:
183  case 1:
184  case 2:
185  ret = false;
186  break;
187  }
188  return ret;
189  }
190 
191  // parses the content of Variable depthfunc
192  // return a z-test
193  inline u8 getDepthFunction ( const core::stringc &string )
194  {
196 
197  if ( string.size() == 0 )
198  return ret;
199 
200  static const c8 * funclist[] = { "lequal","equal" };
201 
202  u32 pos = 0;
203  switch ( isEqual ( string, pos, funclist, 2 ) )
204  {
205  case 0:
206  ret = video::ECFN_LESSEQUAL;
207  break;
208  case 1:
209  ret = video::ECFN_EQUAL;
210  break;
211  }
212  return ret;
213  }
214 
215 
227  inline static void getBlendFunc ( const core::stringc &string, SBlendFunc &blendfunc )
228  {
229  if ( string.size() == 0 )
230  return;
231 
232  // maps to E_BLEND_FACTOR
233  static const c8 * funclist[] =
234  {
235  "gl_zero",
236  "gl_one",
237  "gl_dst_color",
238  "gl_one_minus_dst_color",
239  "gl_src_color",
240  "gl_one_minus_src_color",
241  "gl_src_alpha",
242  "gl_one_minus_src_alpha",
243  "gl_dst_alpha",
244  "gl_one_minus_dst_alpha",
245  "gl_src_alpha_sat",
246 
247  "add",
248  "filter",
249  "blend",
250 
251  "ge128",
252  "gt0",
253  };
254 
255 
256  u32 pos = 0;
257  s32 srcFact = isEqual ( string, pos, funclist, 16 );
258 
259  if ( srcFact < 0 )
260  return;
261 
262  u32 resolved = 0;
263  s32 dstFact = isEqual ( string, pos, funclist, 16 );
264 
265  switch ( srcFact )
266  {
267  case video::EBF_ZERO:
268  switch ( dstFact )
269  {
270  // gl_zero gl_src_color == gl_dst_color gl_zero
272  blendfunc.type = video::EMT_ONETEXTURE_BLEND;
273  blendfunc.param0 = video::pack_textureBlendFunc ( video::EBF_DST_COLOR, video::EBF_ZERO, blendfunc.modulate );
274  blendfunc.isTransparent = 1;
275  resolved = 1;
276  break;
277  } break;
278 
279  case video::EBF_ONE:
280  switch ( dstFact )
281  {
282  // gl_one gl_zero
283  case video::EBF_ZERO:
284  blendfunc.type = video::EMT_SOLID;
285  blendfunc.isTransparent = 0;
286  resolved = 1;
287  break;
288 
289  // gl_one gl_one
290  case video::EBF_ONE:
291  blendfunc.type = video::EMT_TRANSPARENT_ADD_COLOR;
292  blendfunc.isTransparent = 1;
293  resolved = 1;
294  break;
295  } break;
296 
298  switch ( dstFact )
299  {
300  // gl_src_alpha gl_one_minus_src_alpha
302  blendfunc.type = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
303  blendfunc.param0 = 1.f/255.f;
304  blendfunc.isTransparent = 1;
305  resolved = 1;
306  break;
307  } break;
308 
309  case 11:
310  // add
311  blendfunc.type = video::EMT_TRANSPARENT_ADD_COLOR;
312  blendfunc.isTransparent = 1;
313  resolved = 1;
314  break;
315  case 12:
316  // filter = gl_dst_color gl_zero or gl_zero gl_src_color
317  blendfunc.type = video::EMT_ONETEXTURE_BLEND;
318  blendfunc.param0 = video::pack_textureBlendFunc ( video::EBF_DST_COLOR, video::EBF_ZERO, blendfunc.modulate );
319  blendfunc.isTransparent = 1;
320  resolved = 1;
321  break;
322  case 13:
323  // blend = gl_src_alpha gl_one_minus_src_alpha
324  blendfunc.type = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
325  blendfunc.param0 = 1.f/255.f;
326  blendfunc.isTransparent = 1;
327  resolved = 1;
328  break;
329  case 14:
330  // alphafunc ge128
331  blendfunc.type = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
332  blendfunc.param0 = 0.5f;
333  blendfunc.isTransparent = 1;
334  resolved = 1;
335  break;
336  case 15:
337  // alphafunc gt0
338  blendfunc.type = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
339  blendfunc.param0 = 1.f / 255.f;
340  blendfunc.isTransparent = 1;
341  resolved = 1;
342  break;
343 
344  }
345 
346  // use the generic blender
347  if ( 0 == resolved )
348  {
349  blendfunc.type = video::EMT_ONETEXTURE_BLEND;
350  blendfunc.param0 = video::pack_textureBlendFunc (
351  (video::E_BLEND_FACTOR) srcFact,
352  (video::E_BLEND_FACTOR) dstFact,
353  blendfunc.modulate);
354 
355  blendfunc.isTransparent = 1;
356  }
357  }
358 
359  // random noise [-1;1]
360  struct Noiser
361  {
362  static f32 get ()
363  {
364  static u32 RandomSeed = 0x69666966;
365  RandomSeed = (RandomSeed * 3631 + 1);
366 
367  f32 value = ( (f32) (RandomSeed & 0x7FFF ) * (1.0f / (f32)(0x7FFF >> 1) ) ) - 1.f;
368  return value;
369  }
370  };
371 
373  {
374  TCMOD = 0,
376  RGBGEN = 2,
377  TCGEN = 3,
378  MAP = 4,
379  ALPHAGEN = 5,
380 
381  FUNCTION2 = 0x10,
388 
395  BULGE = FUNCTION2 + 13,
402  MOVE = FUNCTION2 + 20,
405 
414 
415  UNKNOWN = -2
416  };
417 
419  {
423  base ( 0 ), amp ( 1 ), phase ( 0 ), frequency ( 1 ),
424  wave ( 1 ),
425  x ( 0 ), y ( 0 ), z( 0 ), count( 0 ) {}
426 
427  // "tcmod","deformvertexes","rgbgen", "tcgen"
429  // depends
431  // depends
433 
437 
438  union
439  {
442  };
443 
444  union
445  {
448  };
449 
451 
452  union
453  {
456  };
457 
458  union
459  {
462  };
463 
468 
469  f32 evaluate ( f32 dt ) const
470  {
471  // phase in 0 and 1..
472  f32 x = core::fract( (dt + phase ) * frequency );
473  f32 y = 0.f;
474 
475  switch ( func )
476  {
477  case SINUS:
478  y = sinf ( x * core::PI * 2.f );
479  break;
480  case COSINUS:
481  y = cosf ( x * core::PI * 2.f );
482  break;
483  case SQUARE:
484  y = x < 0.5f ? 1.f : -1.f;
485  break;
486  case TRIANGLE:
487  y = x < 0.5f ? ( 4.f * x ) - 1.f : ( -4.f * x ) + 3.f;
488  break;
489  case SAWTOOTH:
490  y = x;
491  break;
492  case SAWTOOTH_INVERSE:
493  y = 1.f - x;
494  break;
495  case NOISE:
496  y = Noiser::get();
497  break;
498  default:
499  break;
500  }
501 
502  return base + ( y * amp );
503  }
504 
505 
506  };
507 
509  {
510  const f32 lng = i * 2.0f * core::PI / 255.0f;
511  const f32 lat = j * 2.0f * core::PI / 255.0f;
512  return core::vector3df(cosf ( lat ) * sinf ( lng ),
513  sinf ( lat ) * sinf ( lng ),
514  cosf ( lng ));
515  }
516 
517  //
518  inline void getModifierFunc ( SModifierFunction& fill, const core::stringc &string, u32 &pos )
519  {
520  if ( string.size() == 0 )
521  return;
522 
523  static const c8 * funclist[] =
524  {
525  "sin","cos","square",
526  "triangle", "sawtooth","inversesawtooth", "noise"
527  };
528 
529  fill.func = (eQ3ModifierFunction) isEqual ( string,pos, funclist,7 );
530  fill.func = fill.func == UNKNOWN ? SINUS : (eQ3ModifierFunction) ((u32) fill.func + WAVE_MODIFIER_FUNCTION + 1);
531 
532  fill.base = getAsFloat ( string, pos );
533  fill.amp = getAsFloat ( string, pos );
534  fill.phase = getAsFloat ( string, pos );
535  fill.frequency = getAsFloat ( string, pos );
536  }
537 
538 
539  // name = "a b c .."
540  struct SVariable
541  {
544 
545  SVariable ( const c8 * n, const c8 *c = 0 ) : name ( n ), content (c) {}
546  virtual ~SVariable () {}
547 
548  void clear ()
549  {
550  name = "";
551  content = "";
552  }
553 
554  s32 isValid () const
555  {
556  return name.size();
557  }
558 
559  bool operator == ( const SVariable &other ) const
560  {
561  return 0 == strcmp ( name.c_str(), other.name.c_str () );
562  }
563 
564  bool operator < ( const SVariable &other ) const
565  {
566  return 0 > strcmp ( name.c_str(), other.name.c_str () );
567  }
568 
569  };
570 
571 
572  // string database. "a" = "Hello", "b" = "1234.6"
573  struct SVarGroup
574  {
575  SVarGroup () { Variable.setAllocStrategy ( core::ALLOC_STRATEGY_SAFE ); }
576  virtual ~SVarGroup () {}
577 
578  u32 isDefined ( const c8 * name, const c8 * content = 0 ) const
579  {
580  for ( u32 i = 0; i != Variable.size (); ++i )
581  {
582  if ( 0 == strcmp ( Variable[i].name.c_str(), name ) &&
583  ( 0 == content || strstr ( Variable[i].content.c_str(), content ) )
584  )
585  {
586  return i + 1;
587  }
588  }
589  return 0;
590  }
591 
592  // searches for Variable name and returns is content
593  // if Variable is not found a reference to an Empty String is returned
594  const core::stringc &get( const c8 * name ) const
595  {
596  SVariable search ( name );
597  s32 index = Variable.linear_search ( search );
598  if ( index < 0 )
599  return irrEmptyStringc;
600 
601  return Variable [ index ].content;
602  }
603 
604  // set the Variable name
605  void set ( const c8 * name, const c8 * content = 0 )
606  {
607  u32 index = isDefined ( name, 0 );
608  if ( 0 == index )
609  {
610  Variable.push_back ( SVariable ( name, content ) );
611  }
612  else
613  {
614  Variable [ index ].content = content;
615  }
616  }
617 
618 
620  };
621 
624  {
626  {
627  VariableGroup.setAllocStrategy ( core::ALLOC_STRATEGY_SAFE );
628  }
629  virtual ~SVarGroupList () {}
630 
632  };
633 
634 
636  struct IShader
637  {
639  : ID ( 0 ), VarGroup ( 0 ) {}
640  virtual ~IShader () {}
641 
642  void operator = (const IShader &other )
643  {
644  ID = other.ID;
645  VarGroup = other.VarGroup;
646  name = other.name;
647  }
648 
649  bool operator == (const IShader &other ) const
650  {
651  return 0 == strcmp ( name.c_str(), other.name.c_str () );
652  //return name == other.name;
653  }
654 
655  bool operator < (const IShader &other ) const
656  {
657  return strcmp ( name.c_str(), other.name.c_str () ) < 0;
658  //return name < other.name;
659  }
660 
661  u32 getGroupSize () const
662  {
663  if ( 0 == VarGroup )
664  return 0;
665  return VarGroup->VariableGroup.size ();
666  }
667 
668  const SVarGroup * getGroup ( u32 stage ) const
669  {
670  if ( 0 == VarGroup || stage >= VarGroup->VariableGroup.size () )
671  return 0;
672 
673  return &VarGroup->VariableGroup [ stage ];
674  }
675 
676  // id
678  SVarGroupList *VarGroup; // reference
679 
680  // Shader: shader name ( also first variable in first Vargroup )
681  // Entity: classname ( variable in Group(1) )
683  };
684 
685  typedef IShader IEntity;
686 
688 
689  /*
690  dump shader like original layout, regardless of internal data holding
691  no recursive folding..
692  */
693  inline void dumpVarGroup ( core::stringc &dest, const SVarGroup * group, s32 stack )
694  {
695  core::stringc buf;
696  s32 i;
697 
698 
699  if ( stack > 0 )
700  {
701  buf = "";
702  for ( i = 0; i < stack - 1; ++i )
703  buf += '\t';
704 
705  buf += "{\n";
706  dest.append ( buf );
707  }
708 
709  for ( u32 g = 0; g != group->Variable.size(); ++g )
710  {
711  buf = "";
712  for ( i = 0; i < stack; ++i )
713  buf += '\t';
714 
715  buf += group->Variable[g].name;
716  buf += " ";
717  buf += group->Variable[g].content;
718  buf += "\n";
719  dest.append ( buf );
720  }
721 
722  if ( stack > 1 )
723  {
724  buf = "";
725  for ( i = 0; i < stack - 1; ++i )
726  buf += '\t';
727 
728  buf += "}\n";
729  dest.append ( buf );
730  }
731 
732  }
733 
737  inline core::stringc & dumpShader ( core::stringc &dest, const IShader * shader, bool entity = false )
738  {
739  if ( 0 == shader )
740  return dest;
741 
742  const SVarGroup * group;
743 
744  const u32 size = shader->VarGroup->VariableGroup.size ();
745  for ( u32 i = 0; i != size; ++i )
746  {
747  group = &shader->VarGroup->VariableGroup[ i ];
748  dumpVarGroup ( dest, group, core::clamp( (int)i, 0, 2 ) );
749  }
750 
751  if ( !entity )
752  {
753  if ( size <= 1 )
754  {
755  dest.append ( "{\n" );
756  }
757  dest.append ( "}\n" );
758  }
759  return dest;
760  }
761 
762 
763  /*
764  quake3 doesn't care much about tga & jpg
765  load one or multiple files stored in name started at startPos to the texture array textures
766  if texture is not loaded 0 will be added ( to find missing textures easier)
767  */
768  inline void getTextures(tTexArray &textures,
769  const core::stringc &name, u32 &startPos,
770  io::IFileSystem *fileSystem,
771  video::IVideoDriver* driver)
772  {
773  static const char * const extension[] =
774  {
775  ".jpg",
776  ".jpeg",
777  ".png",
778  ".dds",
779  ".tga",
780  ".bmp",
781  ".pcx"
782  };
783 
784  tStringList stringList;
785  getAsStringList(stringList, -1, name, startPos);
786 
787  textures.clear();
788 
789  io::path loadFile;
790  for ( u32 i = 0; i!= stringList.size (); ++i )
791  {
792  video::ITexture* texture = 0;
793  for (u32 g = 0; g != 7; ++g)
794  {
795  core::cutFilenameExtension ( loadFile, stringList[i] );
796 
797  if ( loadFile == "$whiteimage" )
798  {
799  texture = driver->getTexture( "$whiteimage" );
800  if ( 0 == texture )
801  {
802  core::dimension2du s ( 2, 2 );
803  u32 image[4] = { 0xFFFFFFFF, 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF };
804  video::IImage* w = driver->createImageFromData ( video::ECF_A8R8G8B8, s,&image );
805  texture = driver->addTexture( "$whiteimage", w );
806  w->drop ();
807  }
808 
809  }
810  else
811  if ( loadFile == "$redimage" )
812  {
813  texture = driver->getTexture( "$redimage" );
814  if ( 0 == texture )
815  {
816  core::dimension2du s ( 2, 2 );
817  u32 image[4] = { 0xFFFF0000, 0xFFFF0000,0xFFFF0000,0xFFFF0000 };
818  video::IImage* w = driver->createImageFromData ( video::ECF_A8R8G8B8, s,&image );
819  texture = driver->addTexture( "$redimage", w );
820  w->drop ();
821  }
822  }
823  else
824  if ( loadFile == "$blueimage" )
825  {
826  texture = driver->getTexture( "$blueimage" );
827  if ( 0 == texture )
828  {
829  core::dimension2du s ( 2, 2 );
830  u32 image[4] = { 0xFF0000FF, 0xFF0000FF,0xFF0000FF,0xFF0000FF };
831  video::IImage* w = driver->createImageFromData ( video::ECF_A8R8G8B8, s,&image );
832  texture = driver->addTexture( "$blueimage", w );
833  w->drop ();
834  }
835  }
836  else
837  if ( loadFile == "$checkerimage" )
838  {
839  texture = driver->getTexture( "$checkerimage" );
840  if ( 0 == texture )
841  {
842  core::dimension2du s ( 2, 2 );
843  u32 image[4] = { 0xFFFFFFFF, 0xFF000000,0xFF000000,0xFFFFFFFF };
844  video::IImage* w = driver->createImageFromData ( video::ECF_A8R8G8B8, s,&image );
845  texture = driver->addTexture( "$checkerimage", w );
846  w->drop ();
847  }
848  }
849  else
850  if ( loadFile == "$lightmap" )
851  {
852  texture = 0;
853  }
854  else
855  {
856  loadFile.append ( extension[g] );
857  }
858 
859  texture = driver->findTexture( loadFile );
860  if ( texture )
861  break;
862 
863  if ( fileSystem->existFile ( loadFile ) )
864  {
865  texture = driver->getTexture( loadFile );
866  if ( texture )
867  break;
868  texture = 0;
869  }
870  }
871  // take 0 Texture
872  textures.push_back(texture);
873  }
874  }
875 
876 
879  {
880  };
881 
882 } // end namespace quake3
883 } // end namespace scene
884 } // end namespace irr
885 
886 #endif
887 
const core::stringc & get(const c8 *name) const
Definition: IQ3Shader.h:594
The FileSystem manages files and archives and provides access to them.
Definition: IFileSystem.h:32
void getModifierFunc(SModifierFunction &fill, const core::stringc &string, u32 &pos)
Definition: IQ3Shader.h:518
bool drop() const
Drops the object. Decrements the reference counter by one.
signed short s16
16 bit signed variable.
Definition: irrTypes.h:52
core::stringc & dumpShader(core::stringc &dest, const IShader *shader, bool entity=false)
Definition: IQ3Shader.h:737
const f32 PI
Constant for PI.
Definition: irrMath.h:57
T Y
Y coordinate of the vector.
Definition: vector3d.h:413
E_BLEND_FACTOR
Flag for EMT_ONETEXTURE_BLEND, ( BlendFactor ) BlendFunc = source * sourceFactor + dest * destFactor.
Definition: SMaterial.h:23
core::vector3df getAsVector3df(const core::stringc &string, u32 &pos)
get a quake3 vector translated to irrlicht position (x,-z,y )
Definition: IQ3Shader.h:115
Manages various Quake3 Shader Styles.
Definition: IQ3Shader.h:878
u32 size() const
Returns length of the string's content.
Definition: irrString.h:502
E_MATERIAL_TYPE
Abstracted and easy to use fixed function/programmable pipeline material modes.
const char * fast_atof_move(const char *in, f32 &result)
Provides a fast function for converting a string into a float.
Definition: fast_atof.h:310
dest (srcR, srcG, srcB, srcA)
Definition: SMaterial.h:29
video::E_MODULATE_FUNC modulate
Definition: IQ3Shader.h:164
eQ3MeshIndex
Hold the different Mesh Types used for getMesh.
Definition: IQ3Shader.h:24
float f32
32 bit floating point variable.
Definition: irrTypes.h:108
holding a group a variable
Definition: IQ3Shader.h:623
f32 getAsFloat(const core::stringc &string, u32 &pos)
Definition: IQ3Shader.h:105
string< T, TAlloc > & append(T character)
Appends a character to this string.
Definition: irrString.h:634
void getTextures(tTexArray &textures, const core::stringc &name, u32 &startPos, io::IFileSystem *fileSystem, video::IVideoDriver *driver)
Definition: IQ3Shader.h:768
src & dest (0, 0, 0, 0)
Definition: SMaterial.h:25
virtual IImage * createImageFromData(ECOLOR_FORMAT format, const core::dimension2d< u32 > &size, void *data, bool ownForeignMemory=false, bool deleteMemory=true)=0
Creates a software image from a byte array.
bool operator==(const SVariable &other) const
Definition: IQ3Shader.h:559
Material type with standard lightmap technique.
char c8
8 bit character variable.
Definition: irrTypes.h:35
f32 fract(f32 x)
Definition: irrMath.h:755
video::E_MATERIAL_TYPE defaultLightMapMaterial
Definition: IQ3Shader.h:61
T X
X coordinate of the vector.
Definition: vector3d.h:410
f32 pack_textureBlendFunc(const E_BLEND_FACTOR srcFact, const E_BLEND_FACTOR dstFact, const E_MODULATE_FUNC modulate=EMFN_MODULATE_1X, const u32 alphaSource=EAS_TEXTURE)
Pack srcFact, dstFact, Modulate and alpha source to MaterialTypeParam or BlendFactor.
Definition: SMaterial.h:118
SVarGroupList * VarGroup
Definition: IQ3Shader.h:678
core::array< video::ITexture * > tTexArray
Definition: IQ3Shader.h:80
Everything in the Irrlicht Engine can be found in this namespace.
Definition: aabbox3d.h:12
bool operator<(const IShader &other) const
Definition: IQ3Shader.h:655
void operator=(const IShader &other)
Definition: IQ3Shader.h:642
src & dest (1, 1, 1, 1)
Definition: SMaterial.h:26
Interface for software image data.
Definition: IImage.h:25
Very simple string class with some useful features.
Definition: irrString.h:37
s16 isEqual(const core::stringc &string, u32 &pos, const c8 *const list[], u16 listSize)
Definition: IQ3Shader.h:83
void push_back(const T &element)
Adds an element at back of array.
Definition: irrArray.h:111
unsigned char u8
8 bit unsigned variable.
Definition: irrTypes.h:22
vector3d< f32 > vector3df
Typedef for a f32 3d vector.
Definition: vector3d.h:447
bool operator<(const SVariable &other) const
Definition: IQ3Shader.h:564
File containing useful basic utility functions.
src & dest (srcA, srcA, srcA, srcA)
Definition: SMaterial.h:31
core::array< SVariable > Variable
Definition: IQ3Shader.h:619
SVariable(const c8 *n, const c8 *c=0)
Definition: IQ3Shader.h:545
u8 getDepthFunction(const core::stringc &string)
Definition: IQ3Shader.h:193
SBlendFunc(video::E_MODULATE_FUNC mod)
Definition: IQ3Shader.h:158
Is bilinear filtering enabled? Default: true.
unsigned short u16
16 bit unsigned variable.
Definition: irrTypes.h:44
u32 isDefined(const c8 *name, const c8 *content=0) const
Definition: IQ3Shader.h:578
video::E_MATERIAL_TYPE type
Definition: IQ3Shader.h:163
signed int s32
32 bit signed variable.
Definition: irrTypes.h:70
E_MODULATE_FUNC
MaterialTypeParam: e.g. DirectX: D3DTOP_MODULATE, D3DTOP_MODULATE2X, D3DTOP_MODULATE4X.
Definition: SMaterial.h:54
const T * c_str() const
Returns character string.
Definition: irrString.h:526
unsigned int u32
32 bit unsigned variable.
Definition: irrTypes.h:62
Exact equality.
Definition: SMaterial.h:69
u32 size() const
Get number of occupied elements of the array.
Definition: irrArray.h:364
src & dest (1-srcA, 1-srcA, 1-srcA, 1-srcA)
Definition: SMaterial.h:32
Interface to driver which is able to perform 2d and 3d graphics functions.
Definition: IVideoDriver.h:151
void getAsStringList(tStringList &list, s32 max, const core::stringc &string, u32 &startPos)
Definition: IQ3Shader.h:130
Standard solid material.
virtual ITexture * addTexture(const core::dimension2d< u32 > &size, const io::path &name, ECOLOR_FORMAT format=ECF_A8R8G8B8)=0
Creates an empty texture of specified size.
<= test, default for e.g. depth test
Definition: SMaterial.h:67
Self reallocating template array (like stl vector) with additional features.
Definition: irrArray.h:22
A Parsed Shader Holding Variables ordered in Groups.
Definition: IQ3Shader.h:636
E_MATERIAL_FLAG
Material flags.
virtual ITexture * getTexture(const io::path &filename)=0
Get access to a named texture.
core::array< SVarGroup > VariableGroup
Definition: IQ3Shader.h:631
const SVarGroup * getGroup(u32 stage) const
Definition: IQ3Shader.h:668
T Z
Z coordinate of the vector.
Definition: vector3d.h:416
bool operator==(const IShader &other) const
Definition: IQ3Shader.h:649
A blend function for a q3 shader.
Definition: IQ3Shader.h:156
Interface of a Video Driver dependent Texture.
Definition: ITexture.h:153
Base class of most objects of the Irrlicht Engine.
Makes the material transparent based on the texture alpha channel.
void dumpVarGroup(core::stringc &dest, const SVarGroup *group, s32 stack)
Definition: IQ3Shader.h:693
src (destR, destG, destB, destA)
Definition: SMaterial.h:27
virtual video::ITexture * findTexture(const io::path &filename)=0
Check if the image is already loaded.
void clear()
Clears the array and deletes all allocated memory.
Definition: irrArray.h:199
core::vector3df getMD3Normal(u32 i, u32 j)
Definition: IQ3Shader.h:508
BlendFunc = source * sourceFactor + dest * destFactor ( E_BLEND_FUNC )
video::E_MODULATE_FUNC defaultModulate
Definition: IQ3Shader.h:62
virtual bool existFile(const path &filename) const =0
Determines if a file exists and could be opened.
core::array< core::stringc > tStringList
Definition: IQ3Shader.h:79
bool getCullingFunction(const core::stringc &cull)
Definition: IQ3Shader.h:171
void set(const c8 *name, const c8 *content=0)
Definition: IQ3Shader.h:605
video::E_MATERIAL_FLAG defaultFilter
Definition: IQ3Shader.h:63
const T clamp(const T &value, const T &low, const T &high)
clamps a value between low and high
Definition: irrMath.h:167
io::path & cutFilenameExtension(io::path &dest, const io::path &source)
cut the filename extension from a source file path and store it in a dest file path
Definition: coreutil.h:48
core::array< IEntity > tQ3EntityList
Definition: IQ3Shader.h:687