5#ifndef __I_Q3_LEVEL_SHADER_H_INCLUDED__
6#define __I_Q3_LEVEL_SHADER_H_INCLUDED__
85 const char * in =
string.c_str () + pos;
87 for (
u16 i = 0; i != listSize; ++i )
89 if (
string.size() < pos)
91 u32 len = (
u32) strlen ( list[i] );
92 if (
string.size() < pos+len)
94 if ( in [len] != 0 && in [len] !=
' ' )
96 if ( strncmp ( in, list[i], len ) )
107 const char * in =
string.c_str () + pos;
138 endPos =
string.findNext (
' ', startPos );
142 endPos =
string.size();
145 list.push_back (
string.subString ( startPos, endPos - startPos ) );
146 startPos = endPos + 1;
148 if ( list.size() >= (
u32) max )
173 if ( cull.size() == 0 )
177 static const c8 * funclist[] = {
"none",
"disable",
"twosided" };
180 switch (
isEqual ( cull, pos, funclist, 3 ) )
197 if (
string.size() == 0 )
200 static const c8 * funclist[] = {
"lequal",
"equal" };
203 switch (
isEqual (
string, pos, funclist, 2 ) )
227 inline static void getBlendFunc (
const core::stringc &
string, SBlendFunc &blendfunc )
229 if (
string.size() == 0 )
233 static const c8 * funclist[] =
238 "gl_one_minus_dst_color",
240 "gl_one_minus_src_color",
242 "gl_one_minus_src_alpha",
244 "gl_one_minus_dst_alpha",
257 s32 srcFact =
isEqual (
string, pos, funclist, 16 );
263 s32 dstFact =
isEqual (
string, pos, funclist, 16 );
274 blendfunc.isTransparent = 1;
285 blendfunc.isTransparent = 0;
292 blendfunc.isTransparent = 1;
303 blendfunc.param0 = 1.f/255.f;
304 blendfunc.isTransparent = 1;
312 blendfunc.isTransparent = 1;
319 blendfunc.isTransparent = 1;
325 blendfunc.param0 = 1.f/255.f;
326 blendfunc.isTransparent = 1;
332 blendfunc.param0 = 0.5f;
333 blendfunc.isTransparent = 1;
339 blendfunc.param0 = 1.f / 255.f;
340 blendfunc.isTransparent = 1;
355 blendfunc.isTransparent = 1;
364 static u32 RandomSeed = 0x69666966;
365 RandomSeed = (RandomSeed * 3631 + 1);
367 f32 value = ( (
f32) (RandomSeed & 0x7FFF ) * (1.0f / (
f32)(0x7FFF >> 1) ) ) - 1.f;
427 x ( 0 ),
y ( 0 ),
z( 0 ),
count( 0 ) {}
486 y =
x < 0.5f ? 1.f : -1.f;
489 y =
x < 0.5f ? ( 4.f *
x ) - 1.f : ( -4.f *
x ) + 3.f;
515 sinf ( lat ) * sinf ( lng ),
522 if (
string.size() == 0 )
525 static const c8 * funclist[] =
527 "sin",
"cos",
"square",
528 "triangle",
"sawtooth",
"inversesawtooth",
"noise"
563 return 0 == strcmp (
name.c_str(), other.
name.c_str () );
568 return 0 > strcmp (
name.c_str(), other.
name.c_str () );
584 if ( 0 == strcmp (
Variable[i].name.c_str(), name ) &&
585 ( 0 == content || strstr (
Variable[i].content.c_str(), content ) )
601 return irrEmptyStringc;
607 void set (
const c8 * name,
const c8 * content = 0 )
616 Variable [ index ].content = content;
653 return 0 == strcmp (
name.c_str(), other.
name.c_str () );
659 return strcmp (
name.c_str(), other.
name.c_str () ) < 0;
704 for ( i = 0; i < stack - 1; ++i )
711 for (
u32 g = 0; g != group->
Variable.size(); ++g )
714 for ( i = 0; i < stack; ++i )
727 for ( i = 0; i < stack - 1; ++i )
747 for (
u32 i = 0; i != size; ++i )
757 dest.append (
"{\n" );
759 dest.append (
"}\n" );
775 static const char* extension[] =
792 for (
u32 i = 0; i!= stringList.size (); ++i )
795 for (
u32 g = 0; g != 7 ; ++g)
799 if ( loadFile ==
"$whiteimage" )
801 texture = driver->
getTexture(
"$whiteimage" );
805 u32 image[4] = { 0xFFFFFFFF, 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF };
807 texture = driver->
addTexture(
"$whiteimage", w );
813 if ( loadFile ==
"$redimage" )
819 u32 image[4] = { 0xFFFF0000, 0xFFFF0000,0xFFFF0000,0xFFFF0000 };
821 texture = driver->
addTexture(
"$redimage", w );
826 if ( loadFile ==
"$blueimage" )
832 u32 image[4] = { 0xFF0000FF, 0xFF0000FF,0xFF0000FF,0xFF0000FF };
834 texture = driver->
addTexture(
"$blueimage", w );
839 if ( loadFile ==
"$checkerimage" )
841 texture = driver->
getTexture(
"$checkerimage" );
845 u32 image[4] = { 0xFFFFFFFF, 0xFF000000,0xFF000000,0xFFFFFFFF };
847 texture = driver->
addTexture(
"$checkerimage", w );
852 if ( loadFile ==
"$lightmap" )
858 loadFile.
append ( extension[g] );
861 if ( fileSystem->
existFile ( loadFile ) )
870 textures.push_back(texture);
Base class of most objects of the Irrlicht Engine.
bool drop() const
Drops the object. Decrements the reference counter by one.
Axis aligned bounding box in 3d dimensional space.
string< T, TAlloc > & append(T character)
Appends a character to this string.
T X
X coordinate of the vector.
T Z
Z coordinate of the vector.
T Y
Y coordinate of the vector.
The FileSystem manages files and archives and provides access to them.
virtual bool existFile(const path &filename) const =0
Determines if a file exists and could be opened.
Manages various Quake3 Shader Styles.
Interface for software image data.
Interface of a Video Driver dependent Texture.
Interface to driver which is able to perform 2d and 3d graphics functions.
virtual ITexture * getTexture(const io::path &filename)=0
Get access to a named texture.
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.
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.
File containing useful basic utility functions.
vector3d< f32 > vector3df
Typedef for a f32 3d vector.
const char * fast_atof_move(const char *in, f32 &result)
Provides a fast function for converting a string into a float.
const f32 PI
Constant for PI.
const T clamp(const T &value, const T &low, const T &high)
clamps a value between low and high
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
u8 getDepthFunction(const core::stringc &string)
core::vector3df getMD3Normal(u32 i, u32 j)
core::array< IEntity > tQ3EntityList
core::stringc & dumpShader(core::stringc &dest, const IShader *shader, bool entity=false)
s16 isEqual(const core::stringc &string, u32 &pos, const c8 *list[], u16 listSize)
eQ3MeshIndex
Hold the different Mesh Types used for getMesh.
bool getCullingFunction(const core::stringc &cull)
core::vector3df getAsVector3df(const core::stringc &string, u32 &pos)
get a quake3 vector translated to irrlicht position (x,-z,y )
void getTextures(tTexArray &textures, const core::stringc &name, u32 &startPos, io::IFileSystem *fileSystem, video::IVideoDriver *driver)
void getAsStringList(tStringList &list, s32 max, const core::stringc &string, u32 &startPos)
void dumpVarGroup(core::stringc &dest, const SVarGroup *group, s32 stack)
core::array< video::ITexture * > tTexArray
void getModifierFunc(SModifierFunction &fill, const core::stringc &string, u32 &pos)
f32 getAsFloat(const core::stringc &string, u32 &pos)
core::array< core::stringc > tStringList
E_MODULATE_FUNC
MaterialTypeParam: e.g. DirectX: D3DTOP_MODULATE, D3DTOP_MODULATE2X, D3DTOP_MODULATE4X.
@ ECF_A8R8G8B8
Default 32 bit color format. 8 bits are used for every component: red, green, blue and alpha.
E_MATERIAL_FLAG
Material flags.
E_MATERIAL_TYPE
Abstracted and easy to use fixed function/programmable pipeline material modes.
@ EMT_ONETEXTURE_BLEND
BlendFunc = source * sourceFactor + dest * destFactor ( E_BLEND_FUNC )
@ EMT_TRANSPARENT_ADD_COLOR
A transparent material.
@ EMT_SOLID
Standard solid material.
@ EMT_TRANSPARENT_ALPHA_CHANNEL
Makes the material transparent based on the texture alpha channel.
E_BLEND_FACTOR
Flag for EMT_ONETEXTURE_BLEND, ( BlendFactor ) BlendFunc = source * sourceFactor + dest * destFactor.
@ EBF_SRC_ALPHA
src & dest (srcA, srcA, srcA, srcA)
@ EBF_ONE
src & dest (1, 1, 1, 1)
@ EBF_SRC_COLOR
dest (srcR, srcG, srcB, srcA)
@ EBF_ZERO
src & dest (0, 0, 0, 0)
@ EBF_ONE_MINUS_SRC_ALPHA
src & dest (1-srcA, 1-srcA, 1-srcA, 1-srcA)
@ EBF_DST_COLOR
src (destR, destG, destB, destA)
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)
EMT_ONETEXTURE_BLEND: pack srcFact, dstFact, Modulate and alpha source to MaterialTypeParam.
@ ECFN_LESSEQUAL
<= test, default for e.g. depth test
@ ECFN_EQUAL
Exact equality.
Everything in the Irrlicht Engine can be found in this namespace.
float f32
32 bit floating point variable.
unsigned int u32
32 bit unsigned variable.
signed short s16
16 bit signed variable.
unsigned char u8
8 bit unsigned variable.
char c8
8 bit character variable.
signed int s32
32 bit signed variable.
unsigned short u16
16 bit unsigned variable.
A Parsed Shader Holding Variables ordered in Groups.
bool operator==(const IShader &other) const
bool operator<(const IShader &other) const
const SVarGroup * getGroup(u32 stage) const
void operator=(const IShader &other)
video::E_MODULATE_FUNC defaultModulate
s32 cleanUnResolvedMeshes
video::E_MATERIAL_FLAG defaultFilter
video::E_MATERIAL_TYPE defaultLightMapMaterial
A blend function for a q3 shader.
video::E_MODULATE_FUNC modulate
video::E_MATERIAL_TYPE type
SBlendFunc(video::E_MODULATE_FUNC mod)
eQ3ModifierFunction masterfunc1
eQ3ModifierFunction masterfunc0
eQ3ModifierFunction tcgen
eQ3ModifierFunction alphagen
f32 evaluate(f32 dt) const
eQ3ModifierFunction rgbgen
u32 isDefined(const c8 *name, const c8 *content=0) const
const core::stringc & get(const c8 *name) const
void set(const c8 *name, const c8 *content=0)
core::array< SVariable > Variable
holding a group a variable
core::array< SVarGroup > VariableGroup
SVariable(const c8 *n, const c8 *c=0)
bool operator==(const SVariable &other) const
bool operator<(const SVariable &other) const