irrlicht/include/SMaterial.h

585 lines
19 KiB
C
Raw Normal View History

// Copyright (C) 2002-2009 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __S_MATERIAL_H_INCLUDED__
#define __S_MATERIAL_H_INCLUDED__
#include "SColor.h"
#include "matrix4.h"
#include "irrArray.h"
#include "EMaterialTypes.h"
#include "EMaterialFlags.h"
#include "SMaterialLayer.h"
namespace irr
{
namespace video
{
class ITexture;
//! Flag for EMT_ONETEXTURE_BLEND, ( BlendFactor ) BlendFunc = source * sourceFactor + dest * destFactor
enum E_BLEND_FACTOR
{
EBF_ZERO = 0, //!< src & dest (0, 0, 0, 0)
EBF_ONE, //!< src & dest (1, 1, 1, 1)
EBF_DST_COLOR, //!< src (destR, destG, destB, destA)
EBF_ONE_MINUS_DST_COLOR, //!< src (1-destR, 1-destG, 1-destB, 1-destA)
EBF_SRC_COLOR, //!< dest (srcR, srcG, srcB, srcA)
EBF_ONE_MINUS_SRC_COLOR, //!< dest (1-srcR, 1-srcG, 1-srcB, 1-srcA)
EBF_SRC_ALPHA, //!< src & dest (srcA, srcA, srcA, srcA)
EBF_ONE_MINUS_SRC_ALPHA, //!< src & dest (1-srcA, 1-srcA, 1-srcA, 1-srcA)
EBF_DST_ALPHA, //!< src & dest (destA, destA, destA, destA)
EBF_ONE_MINUS_DST_ALPHA, //!< src & dest (1-destA, 1-destA, 1-destA, 1-destA)
EBF_SRC_ALPHA_SATURATE //!< src (min(srcA, 1-destA), idem, ...)
};
//! MaterialTypeParam: e.g. DirectX: D3DTOP_MODULATE, D3DTOP_MODULATE2X, D3DTOP_MODULATE4X
enum E_MODULATE_FUNC
{
EMFN_MODULATE_1X = 1,
EMFN_MODULATE_2X = 2,
EMFN_MODULATE_4X = 4
};
//! Comparison function, e.g. for depth buffer test
enum E_COMPARISON_FUNC
{
//! Test never succeeds, this equals disable
ECFN_NEVER=0,
//! <= test, default for e.g. depth test
ECFN_LESSEQUAL=1,
//! Exact equality
ECFN_EQUAL=2,
//! exclusive less comparison, i.e. <
ECFN_LESS,
//! Succeeds almost always, except for exact equality
ECFN_NOTEQUAL,
//! >= test
ECFN_GREATEREQUAL,
//! inverse of <=
ECFN_GREATER,
//! test succeeds always
ECFN_ALWAYS
};
//! Enum values for enabling/disabling color planes for rendering
enum E_COLOR_PLANE
{
//! No color enabled
ECP_NONE=0,
//! Alpha enabled
ECP_ALPHA=1,
//! Red enabled
ECP_RED=2,
//! Green enabled
ECP_GREEN=4,
//! Blue enabled
ECP_BLUE=8,
//! All colors, no alpha
ECP_RGB=14,
//! All planes enabled
ECP_ALL=15
};
//! EMT_ONETEXTURE_BLEND: pack srcFact & dstFact and Modulo to MaterialTypeParam
inline f32 pack_texureBlendFunc ( const E_BLEND_FACTOR srcFact, const E_BLEND_FACTOR dstFact, const E_MODULATE_FUNC modulate=EMFN_MODULATE_1X )
{
return (f32)(modulate << 16 | srcFact << 8 | dstFact);
}
//! EMT_ONETEXTURE_BLEND: unpack srcFact & dstFact and Modulo to MaterialTypeParam
inline void unpack_texureBlendFunc ( E_BLEND_FACTOR &srcFact, E_BLEND_FACTOR &dstFact,
E_MODULATE_FUNC &modulo, const f32 param )
{
const u32 state = (u32)param;
modulo = E_MODULATE_FUNC( ( state & 0x00FF0000 ) >> 16 );
srcFact = E_BLEND_FACTOR ( ( state & 0x0000FF00 ) >> 8 );
dstFact = E_BLEND_FACTOR ( ( state & 0x000000FF ) );
}
Changes in 1.6 TA - fixed createMeshWith2TCoords normals were missing during copy. - addded //! Creates a copy of the mesh, which will only consist of S3DVertex vertices. IMesh* CMeshManipulator::createMeshWith1TCoords(IMesh* mesh) const - added io::IFileSystem* CSceneManager::getFileSystem() for preparing to remove the (mostly) unnecessary double member variables in many loaders - added virtual const c8* ISceneManager::getAnimatorTypeName(ESCENE_NODE_ANIMATOR_TYPE type); to the SceneManger Interface. just like getTypeName is public - added CSceneNodeAnimatorFlyCircle::radiusEllipsoid. if radiusEllipsoid == 0 the default circle animation is done else radiusEllipsoid forms the b-axe of the ellipsoid. -> gummiball bouncing - added ISceneManager::createFlyStraightAnimator variable bool ping-pong used in loop mode to device if start from beginning ( default ) or make ping-pong -> straight bouncing - changed IFileSystem::registerFileArchive remove the index of the hiarchy and added a new interface method //! move the hirarchy of the filesystem. moves sourceIndex relative up or down virtual bool moveFileArchive( u32 sourceIndex, s32 relative ) = 0; - bugfix and changes in SViewFrustum::SViewFrustum wrong size of Matrices copy. This bug must be ages old... (typo) detected during resizing the Matrices. removed obsolute Matrices renamed E_TRANSFORMATION_STATE_2 to E_TRANSFORMATION_STATE_FRUSTUM therefore also changed SViewFrustum::setTransformState to not tap in the pitfall again of wrong memory... and renamed it to getTransform, like in the driver and Matrices private - OpenGL: Specular - moved //! EMT_ONETEXTURE_BLEND: has BlendFactor Alphablending inline bool textureBlendFunc_hasAlpha ( E_BLEND_FACTOR factor ) const from the material renderes ( 3x declared ) to SMaterial.h - updated managed light example to use standard driver selection - BurningsVideo - LightModel reworked. Point Light & Direction Light works for Diffuse Color as aspected Specular and Fog still have problems ( needs new pixel shader ) pushed burningsvideo to 0.42 for this major step - removed obsolete matrix transformations renamed E_TRANSFORMATION_STATE_2 to E_TRANSFORMATION_STATE_BURNING - cleaned line3d.h vector3d.h template behavior. many mixed f32/f64 implementations are here. i'm not sure if this should be the default behavior to use f64 for example for 1.0/x value, because they benefit from more precisions, but in my point of view the user is responsible of choosing a vector3d<f32> or vector3d<f64>. - added core::squareroot to irrmath.h -> for having candidates for faster math in the same file - added AllowZWriteOnTransparent from SceneManager to burningsvideo Following SceneManger guideline -added hasAlpha() to ITexture This info can be used for e.q to downgrade a transparent alpha channel blit to add if the texture has no alpha channel. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2199 dfc29bdd-3216-0410-991c-e03cc46cb475
2009-02-05 07:33:55 -08:00
//! EMT_ONETEXTURE_BLEND: has BlendFactor Alphablending
inline bool textureBlendFunc_hasAlpha ( const E_BLEND_FACTOR factor )
{
switch ( factor )
{
case EBF_SRC_ALPHA:
case EBF_ONE_MINUS_SRC_ALPHA:
case EBF_DST_ALPHA:
case EBF_ONE_MINUS_DST_ALPHA:
case EBF_SRC_ALPHA_SATURATE:
return true;
default:
return false;
Changes in 1.6 TA - fixed createMeshWith2TCoords normals were missing during copy. - addded //! Creates a copy of the mesh, which will only consist of S3DVertex vertices. IMesh* CMeshManipulator::createMeshWith1TCoords(IMesh* mesh) const - added io::IFileSystem* CSceneManager::getFileSystem() for preparing to remove the (mostly) unnecessary double member variables in many loaders - added virtual const c8* ISceneManager::getAnimatorTypeName(ESCENE_NODE_ANIMATOR_TYPE type); to the SceneManger Interface. just like getTypeName is public - added CSceneNodeAnimatorFlyCircle::radiusEllipsoid. if radiusEllipsoid == 0 the default circle animation is done else radiusEllipsoid forms the b-axe of the ellipsoid. -> gummiball bouncing - added ISceneManager::createFlyStraightAnimator variable bool ping-pong used in loop mode to device if start from beginning ( default ) or make ping-pong -> straight bouncing - changed IFileSystem::registerFileArchive remove the index of the hiarchy and added a new interface method //! move the hirarchy of the filesystem. moves sourceIndex relative up or down virtual bool moveFileArchive( u32 sourceIndex, s32 relative ) = 0; - bugfix and changes in SViewFrustum::SViewFrustum wrong size of Matrices copy. This bug must be ages old... (typo) detected during resizing the Matrices. removed obsolute Matrices renamed E_TRANSFORMATION_STATE_2 to E_TRANSFORMATION_STATE_FRUSTUM therefore also changed SViewFrustum::setTransformState to not tap in the pitfall again of wrong memory... and renamed it to getTransform, like in the driver and Matrices private - OpenGL: Specular - moved //! EMT_ONETEXTURE_BLEND: has BlendFactor Alphablending inline bool textureBlendFunc_hasAlpha ( E_BLEND_FACTOR factor ) const from the material renderes ( 3x declared ) to SMaterial.h - updated managed light example to use standard driver selection - BurningsVideo - LightModel reworked. Point Light & Direction Light works for Diffuse Color as aspected Specular and Fog still have problems ( needs new pixel shader ) pushed burningsvideo to 0.42 for this major step - removed obsolete matrix transformations renamed E_TRANSFORMATION_STATE_2 to E_TRANSFORMATION_STATE_BURNING - cleaned line3d.h vector3d.h template behavior. many mixed f32/f64 implementations are here. i'm not sure if this should be the default behavior to use f64 for example for 1.0/x value, because they benefit from more precisions, but in my point of view the user is responsible of choosing a vector3d<f32> or vector3d<f64>. - added core::squareroot to irrmath.h -> for having candidates for faster math in the same file - added AllowZWriteOnTransparent from SceneManager to burningsvideo Following SceneManger guideline -added hasAlpha() to ITexture This info can be used for e.q to downgrade a transparent alpha channel blit to add if the texture has no alpha channel. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2199 dfc29bdd-3216-0410-991c-e03cc46cb475
2009-02-05 07:33:55 -08:00
}
}
//! These flags are used to specify the anti-aliasing and smoothing modes
/** Techniques supported are multisampling, geometry smoothing, and alpha
to coverage.
Some drivers don't support a per-material setting of the anti-aliasing
modes. In those cases, FSAA/multisampling is defined by the device mode
chosen upon creation via irr::SIrrCreationParameters.
*/
enum E_ANTI_ALIASING_MODE
{
//! Use to turn off anti-aliasing for this material
EAAM_OFF=0,
//! Default anti-aliasing mode
EAAM_SIMPLE=1,
//! High-quality anti-aliasing, not always supported, automatically enables SIMPLE mode
EAAM_QUALITY=3,
//! Line smoothing
EAAM_LINE_SMOOTH=4,
//! point smoothing, often in software and slow, only with OpenGL
EAAM_POINT_SMOOTH=8,
//! All typical anti-alias and smooth modes
EAAM_FULL_BASIC=15,
//! Enhanced anti-aliasing for transparent materials
/** Usually used with EMT_TRANSPARENT_ALPHA_REF and multisampling. */
EAAM_ALPHA_TO_COVERAGE=16
};
//! These flags allow to define the interpretation of vertex color when lighting is enabled
/** Without lighting being enabled the vertex color is the only value defining the fragment color.
Once lighting is enabled, the four values for diffuse, ambient, emissive, and specular take over.
With these flags it is possible to define which lighting factor shall be defined by the vertex color
instead of the lighting factor which is the same for all faces of that material.
The default is to use vertex color for the diffuse value, another pretty common value is to use
vertex color for both diffuse and ambient factor. */
enum E_COLOR_MATERIAL
{
//! Don't use vertex color for lighting
ECM_NONE=0,
//! Use vertex color for diffuse light, this is default
ECM_DIFFUSE,
//! Use vertex color for ambient light
ECM_AMBIENT,
//! Use vertex color for emissive light
ECM_EMISSIVE,
//! Use vertex color for specular light
ECM_SPECULAR,
//! Use vertex color for both diffuse and ambient light
ECM_DIFFUSE_AND_AMBIENT
};
//! Maximum number of texture an SMaterial can have.
const u32 MATERIAL_MAX_TEXTURES = _IRR_MATERIAL_MAX_TEXTURES_;
//! Struct for holding parameters for a material renderer
class SMaterial
{
public:
//! Default constructor. Creates a solid, lit material with white colors
SMaterial()
: MaterialType(EMT_SOLID), AmbientColor(255,255,255,255), DiffuseColor(255,255,255,255),
EmissiveColor(0,0,0,0), SpecularColor(255,255,255,255),
Shininess(0.0f), MaterialTypeParam(0.0f), MaterialTypeParam2(0.0f), Thickness(1.0f),
ZBuffer(ECFN_LESSEQUAL), AntiAliasing(EAAM_SIMPLE|EAAM_LINE_SMOOTH), ColorMask(ECP_ALL),
ColorMaterial(ECM_DIFFUSE),
Wireframe(false), PointCloud(false), GouraudShading(true), Lighting(true), ZWriteEnable(true),
BackfaceCulling(true), FrontfaceCulling(false), FogEnable(false), NormalizeNormals(false)
{ }
//! Copy constructor
/** \param other Material to copy from. */
SMaterial(const SMaterial& other)
{
// These pointers are checked during assignment
for (u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i)
TextureLayer[i].TextureMatrix = 0;
*this = other;
}
//! Assignment operator
/** \param other Material to copy from. */
SMaterial& operator=(const SMaterial& other)
{
// Check for self-assignment!
if (this == &other)
return *this;
MaterialType = other.MaterialType;
AmbientColor = other.AmbientColor;
DiffuseColor = other.DiffuseColor;
EmissiveColor = other.EmissiveColor;
SpecularColor = other.SpecularColor;
Shininess = other.Shininess;
MaterialTypeParam = other.MaterialTypeParam;
MaterialTypeParam2 = other.MaterialTypeParam2;
Thickness = other.Thickness;
for (u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i)
{
TextureLayer[i] = other.TextureLayer[i];
}
Wireframe = other.Wireframe;
PointCloud = other.PointCloud;
GouraudShading = other.GouraudShading;
Lighting = other.Lighting;
ZWriteEnable = other.ZWriteEnable;
BackfaceCulling = other.BackfaceCulling;
FrontfaceCulling = other.FrontfaceCulling;
FogEnable = other.FogEnable;
NormalizeNormals = other.NormalizeNormals;
ZBuffer = other.ZBuffer;
AntiAliasing = other.AntiAliasing;
ColorMask = other.ColorMask;
ColorMaterial = other.ColorMaterial;
return *this;
}
//! Texture layer array.
SMaterialLayer TextureLayer[MATERIAL_MAX_TEXTURES];
//! Type of the material. Specifies how everything is blended together
E_MATERIAL_TYPE MaterialType;
//! How much ambient light (a global light) is reflected by this material.
/** The default is full white, meaning objects are completely
globally illuminated. Reduce this if you want to see diffuse
or specular light effects. */
SColor AmbientColor;
//! How much diffuse light coming from a light source is reflected by this material.
/** The default is full white. */
SColor DiffuseColor;
//! Light emitted by this material. Default is to emit no light.
SColor EmissiveColor;
//! How much specular light (highlights from a light) is reflected.
/** The default is to reflect white specular light. See
SMaterial::Shininess on how to enable specular lights. */
SColor SpecularColor;
//! Value affecting the size of specular highlights.
/** A value of 20 is common. If set to 0, no specular
highlights are being used. To activate, simply set the
shininess of a material to a value in the range [0.5;128]:
\code
sceneNode->getMaterial(0).Shininess = 20.0f;
\endcode
You can change the color of the highlights using
\code
sceneNode->getMaterial(0).SpecularColor.set(255,255,255,255);
\endcode
The specular color of the dynamic lights
(SLight::SpecularColor) will influence the the highlight color
too, but they are set to a useful value by default when
creating the light scene node. Here is a simple example on how
to use specular highlights:
\code
// load and display mesh
scene::IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode(
smgr->getMesh("data/faerie.md2"));
node->setMaterialTexture(0, driver->getTexture("data/Faerie2.pcx")); // set diffuse texture
node->setMaterialFlag(video::EMF_LIGHTING, true); // enable dynamic lighting
node->getMaterial(0).Shininess = 20.0f; // set size of specular highlights
// add white light
scene::ILightSceneNode* light = smgr->addLightSceneNode(0,
core::vector3df(5,5,5), video::SColorf(1.0f, 1.0f, 1.0f));
\endcode */
f32 Shininess;
//! Free parameter, dependent on the material type.
/** Mostly ignored, used for example in EMT_PARALLAX_MAP_SOLID
and EMT_TRANSPARENT_ALPHA_CHANNEL. */
f32 MaterialTypeParam;
//! Second free parameter, dependent on the material type.
/** Mostly ignored. */
f32 MaterialTypeParam2;
//! Thickness of non-3dimensional elements such as lines and points.
f32 Thickness;
//! Is the ZBuffer enabled? Default: ECFN_LESSEQUAL
/** Values are from E_COMPARISON_FUNC. */
u8 ZBuffer;
//! Sets the antialiasing mode
/** Values are chosen from E_ANTI_ALIASING_MODE. Default is
EAAM_SIMPLE|EAAM_LINE_SMOOTH, i.e. simple multi-sample
anti-aliasing and lime smoothing is enabled. */
u8 AntiAliasing;
//! Defines the enabled color planes
/** Values are defined as or'ed values of the E_COLOR_PLANE enum.
Only enabled color planes will be rendered to the current render
target. Typical use is to disable all colors when rendering only to
depth or stencil buffer, or using Red and Green for Stereo rendering. */
u8 ColorMask:4;
//! Defines the interpretation of vertex color in the lighting equation
/** Values should be chosen from E_COLOR_MATERIAL.
When lighting is enabled, vertex color can be used instead of the
material values for light modulation. This allows to easily change e.g. the
diffuse light behavior of each face. The default, ECM_DIFFUSE, will result in
a very similar rendering as with lighting turned off, just with light shading. */
u8 ColorMaterial:3;
//! Draw as wireframe or filled triangles? Default: false
/** The user can access a material flag using
\code material.Wireframe=true \endcode
or \code material.setFlag(EMF_WIREFRAME, true); \endcode */
bool Wireframe:1;
//! Draw as point cloud or filled triangles? Default: false
bool PointCloud:1;
//! Flat or Gouraud shading? Default: true
bool GouraudShading:1;
//! Will this material be lighted? Default: true
bool Lighting:1;
//! Is the zbuffer writeable or is it read-only. Default: true.
/** This flag is forced to false if the MaterialType is a
transparent type and the scene parameter
ALLOW_ZWRITE_ON_TRANSPARENT is not set. */
bool ZWriteEnable:1;
//! Is backface culling enabled? Default: true
bool BackfaceCulling:1;
//! Is frontface culling enabled? Default: false
bool FrontfaceCulling:1;
//! Is fog enabled? Default: false
bool FogEnable:1;
//! Should normals be normalized?
/** Always use this if the mesh lit and scaled. Default: false */
bool NormalizeNormals:1;
//! Gets the texture transformation matrix for level i
/** \param i The desired level. Must not be larger than MATERIAL_MAX_TEXTURES.
\return Texture matrix for texture level i. */
core::matrix4& getTextureMatrix(u32 i)
{
return TextureLayer[i].getTextureMatrix();
}
//! Gets the immutable texture transformation matrix for level i
/** \param i The desired level.
\return Texture matrix for texture level i, or identity matrix for levels larger than MATERIAL_MAX_TEXTURES. */
const core::matrix4& getTextureMatrix(u32 i) const
{
if (i<MATERIAL_MAX_TEXTURES)
return TextureLayer[i].getTextureMatrix();
else
return core::IdentityMatrix;
}
//! Sets the i-th texture transformation matrix
/** \param i The desired level.
\param mat Texture matrix for texture level i. */
void setTextureMatrix(u32 i, const core::matrix4& mat)
{
if (i>=MATERIAL_MAX_TEXTURES)
return;
TextureLayer[i].setTextureMatrix(mat);
}
//! Gets the i-th texture
/** \param i The desired level.
\return Texture for texture level i, if defined, else 0. */
ITexture* getTexture(u32 i) const
{
return i < MATERIAL_MAX_TEXTURES ? TextureLayer[i].Texture : 0;
}
//! Sets the i-th texture
/** If i>=MATERIAL_MAX_TEXTURES this setting will be ignored.
\param i The desired level.
\param tex Texture for texture level i. */
void setTexture(u32 i, ITexture* tex)
{
if (i>=MATERIAL_MAX_TEXTURES)
return;
TextureLayer[i].Texture = tex;
}
//! Sets the Material flag to the given value
/** \param flag The flag to be set.
\param value The new value for the flag. */
void setFlag(E_MATERIAL_FLAG flag, bool value)
{
switch (flag)
{
case EMF_WIREFRAME:
Wireframe = value; break;
case EMF_POINTCLOUD:
PointCloud = value; break;
case EMF_GOURAUD_SHADING:
GouraudShading = value; break;
case EMF_LIGHTING:
Lighting = value; break;
case EMF_ZBUFFER:
ZBuffer = value; break;
case EMF_ZWRITE_ENABLE:
ZWriteEnable = value; break;
case EMF_BACK_FACE_CULLING:
BackfaceCulling = value; break;
case EMF_FRONT_FACE_CULLING:
FrontfaceCulling = value; break;
case EMF_BILINEAR_FILTER:
{
for (u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i)
TextureLayer[i].BilinearFilter = value;
}
break;
case EMF_TRILINEAR_FILTER:
{
for (u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i)
TextureLayer[i].TrilinearFilter = value;
}
break;
case EMF_ANISOTROPIC_FILTER:
{
if (value)
for (u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i)
TextureLayer[i].AnisotropicFilter = 0xFF;
else
for (u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i)
TextureLayer[i].AnisotropicFilter = 0;
}
break;
case EMF_FOG_ENABLE:
FogEnable = value; break;
case EMF_NORMALIZE_NORMALS:
NormalizeNormals = value; break;
case EMF_TEXTURE_WRAP:
{
for (u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i)
TextureLayer[i].TextureWrap = (E_TEXTURE_CLAMP)value;
}
break;
case EMF_ANTI_ALIASING:
AntiAliasing = value?EAAM_SIMPLE:EAAM_OFF;
break;
case EMF_COLOR_MASK:
ColorMask = value?ECP_ALL:ECP_NONE;
break;
case EMF_COLOR_MATERIAL:
ColorMaterial = value?ECM_DIFFUSE:ECM_NONE;
break;
default:
break;
}
}
//! Gets the Material flag
/** \param flag The flag to query.
\return The current value of the flag. */
bool getFlag(E_MATERIAL_FLAG flag) const
{
switch (flag)
{
case EMF_WIREFRAME:
return Wireframe;
case EMF_POINTCLOUD:
return PointCloud;
case EMF_GOURAUD_SHADING:
return GouraudShading;
case EMF_LIGHTING:
return Lighting;
case EMF_ZBUFFER:
return ZBuffer!=ECFN_NEVER;
case EMF_ZWRITE_ENABLE:
return ZWriteEnable;
case EMF_BACK_FACE_CULLING:
return BackfaceCulling;
case EMF_FRONT_FACE_CULLING:
return FrontfaceCulling;
case EMF_BILINEAR_FILTER:
return TextureLayer[0].BilinearFilter;
case EMF_TRILINEAR_FILTER:
return TextureLayer[0].TrilinearFilter;
case EMF_ANISOTROPIC_FILTER:
return TextureLayer[0].AnisotropicFilter!=0;
case EMF_FOG_ENABLE:
return FogEnable;
case EMF_NORMALIZE_NORMALS:
return NormalizeNormals;
case EMF_TEXTURE_WRAP:
return !(TextureLayer[0].TextureWrap ||
TextureLayer[1].TextureWrap ||
TextureLayer[2].TextureWrap ||
TextureLayer[3].TextureWrap);
case EMF_ANTI_ALIASING:
return (AntiAliasing==1);
case EMF_COLOR_MASK:
return (ColorMask!=ECP_NONE);
case EMF_COLOR_MATERIAL:
return (ColorMaterial != ECM_NONE);
}
return false;
}
//! Inequality operator
/** \param b Material to compare to.
\return True if the materials differ, else false. */
inline bool operator!=(const SMaterial& b) const
{
bool different =
MaterialType != b.MaterialType ||
AmbientColor != b.AmbientColor ||
DiffuseColor != b.DiffuseColor ||
EmissiveColor != b.EmissiveColor ||
SpecularColor != b.SpecularColor ||
Shininess != b.Shininess ||
MaterialTypeParam != b.MaterialTypeParam ||
MaterialTypeParam2 != b.MaterialTypeParam2 ||
Thickness != b.Thickness ||
Wireframe != b.Wireframe ||
PointCloud != b.PointCloud ||
GouraudShading != b.GouraudShading ||
Lighting != b.Lighting ||
ZBuffer != b.ZBuffer ||
ZWriteEnable != b.ZWriteEnable ||
BackfaceCulling != b.BackfaceCulling ||
FrontfaceCulling != b.FrontfaceCulling ||
FogEnable != b.FogEnable ||
NormalizeNormals != b.NormalizeNormals ||
AntiAliasing != b.AntiAliasing ||
ColorMask != b.ColorMask ||
ColorMaterial != b.ColorMaterial;
for (u32 i=0; (i<MATERIAL_MAX_TEXTURES) && !different; ++i)
{
different |= (TextureLayer[i] != b.TextureLayer[i]);
}
return different;
}
//! Equality operator
/** \param b Material to compare to.
\return True if the materials are equal, else false. */
inline bool operator==(const SMaterial& b) const
{ return !(b!=*this); }
bool isTransparent() const
{
return MaterialType==EMT_TRANSPARENT_ADD_COLOR ||
MaterialType==EMT_TRANSPARENT_ALPHA_CHANNEL ||
MaterialType==EMT_TRANSPARENT_VERTEX_ALPHA ||
MaterialType==EMT_TRANSPARENT_REFLECTION_2_LAYER;
}
};
Changes in version 1.6, TA - FileSystem 2.0 SUPER MASTER MAJOR API CHANGE !!! The FileSystem is know build internally like for e.q the texture-, and the meshloaders. There exists a known list of ArchiveLoader, which know how to produce a Archive. The Loaders and the Archive can be attached/detached on runtime. The FileNames are now stored as core::string<c16>. where c16 is toggled between char/wchar with the #define flag _IRR_WCHAR_FILESYSTEM, to supported unicode backends (default:off) I replaced all (const c8* filename) to string references. Basically the FileSystem is divided into two regions. Native and Virtual. Native means using the backend OS. Virtual means only use currently attach IArchives. Browsing each FileSystem has it's own workdirectory and it's own methods to - create a FileTree - add/remove files & directory ( to be done ) Hint: store a savegame in a zip archive... basic browsing for all archives is implemented. Example 21. Quake3Explorer shows this TODO: - a file filter should be implemented. - The IArchive should have a function to create a filetree for now CFileList is used. Class Hiarchy: IArchiveLoader: is able to produce a IFileArchive - ZipLoader - PakLoader - MountPointReader ( formaly known as CUnzipReader ) IFileArchive: -ZipArchive -PakArchive -MountPoint (known as FolderFile) IFileSystem - addArchiveLoader - changed implementation of isALoadableFileExtension in all loaders to have consistent behavior - added a parameter to IFileList * createFileList setFileListSystem allows to query files in any of the game archives standard behavior listtype = SYSTEM ( default) - CLimitReadFile added multiple file random-access support. solved problems with mixed compressed & uncompressed files in a zip TODO: - Big Big Testing!! - Linux Version ( minor ) - remove all double loader interfaces where only the filename differs (IReadFile/const char *filename). This blows up the the interface - many loaders use their own private filesearching we should rework this - there are a lot of helper function ( getAbsolutePath, getFileDir ) which should be adapted to the virtual filesystem - IrrlichtDevice added: virtual bool setGammaRamp( f32 red, f32 green, f32 blue, f32 brightness, f32 contrast ) = 0; virtual bool getGammaRamp( f32 &red, f32 &green, f32 &blue ) = 0; and calculating methods to DeviceStub. implemented in Win32, TODO: other Devices - irrlicht.h changed exported irrlicht.dll routines createDevice, createDeviceEx, IdentityMatrix to extern "C" name mangling. for easier dynamically loading the irrlicht library and different versions - ParticleSystem removed the private (old?,wrong?) interface from the ParticleEffectors to match the parent class irr::io::IAttributeExchangingObject::deserializeAttributes TODO: please test if the serialization works! - Generic - vector3d<T>& normalize() #if 0 f32 length = (f32)(X*X + Y*Y + Z*Z); if (core::equals(length, 0.f)) return *this; length = core::reciprocal_squareroot ( (f32)length ); #else const T length = core::reciprocal_squareroot ( (X*X + Y*Y + Z*Z) ); #endif Weak checking on zero?!?! just to avoid a sqrt?. mhm, maybe not;-) added reciprocal_squareroot for f64 - dimension2d added operator dimension2d<T>& operator=(const dimension2d<U>& other) to cast between different types - vector2d bugfix: vector2d<T>& operator+=(const dimension2d<T>& other) { X += other.Width; Y += other.Width; return *this; } to vector2d<T>& operator+=(const dimension2d<T>& other) { X += other.Width; Y += other.Height; return *this; } - C3DMeshLoader renamed chunks const u16 to a enum removing "variable declared but never used warning" - added a global const identity Material changed all references *((video::SMaterial*)0) to point to IdentityMaterial removed warning: "a NULL reference is not allowed" - modified IRRLICHT_MATH to not support reciprocal stuff but to use faster float-to-int conversion. gcc troubles may they are. i'm using intel-compiler..;-) - core::matrix4 USE_MATRIX_TEST i tried to optimize the identity-check ( in means of performance) i didn't succeed so well, so i made a define for the matrix isIdentity -check for now it's sometimes faster to always calculate versus identity-check but if there are a lot of scenenodes/ particles one can profit from the fast_inverse matrix, when no scaling is used. further approvement could be done on inverse for just tranlastion! ( many static scenenodes are not rotated, they are just placed somewhere in the world) one thing to take in account is that sizeof(matrix) is 64 byte and with the additional bool/u32 makes it 66 byte which is not really cache-friendly.. - added buildRotateFromTo Builds a matrix that rotates from one vector to another - irr::array. changed allocating routine in push_back okt, 2008. it's only allowed to alloc one element, if default constructor has to be called. removes existing crashes. ( MD3 Mesh ) and possible others ones. A new list template should be made. one with constructor/destructor calls ( safe_array ) and one without. like the array since the beginning of irrlicht. currently the array/string is extremly slow.. also a hint for the user has to be done, so that a struct T of array<T> must have a copy constructor of type T ( const T&other ). i needed hours to track that down... added a new method setAllocStrategy, safe ( used + 1 ), double ( used * 2 + 1) better default strategies will be implemented - removed binary_search_const i added it quite a long time ago, but it doesnt make real sense a call to a sort method should happen always. i just wanted to safe a few cycles.. - added binary_search_multi searches for a multi-set ( more than 1 entry in the sorted array) returns start and end-index - changed some identity matrix settings to use core::IdentityMatrix - added deletePathFromFilename to generic string functions in coreutil.h and removed from CZipReader and CPakReader - s32 deserializeAttributes used instead of virtual void deserializeAttributes in ParticleSystem ( wrong virtual was used) - strings & Locale - started to add locale support - added verify to string - added some helper functions - XBOX i have access to a XBOX development machine now. I started to compile for the XBOX. Question: Who did the previous implementation?. There is no XBOX-Device inhere. maybe it's forbidden because of using the offical Microsoft XDK. I will implement a native or sdl device based on opendk. irrlicht compiles without errors on the xbox but can't be used. TODO: - native XBOX Device - Windows Mobile reworked a little. added the mobile example to the windows solution for cross development. added maximal 128x128 texture size for windows mobile ( memory issues ) - Collision Speed Up The Collision Speed Up greatly improves with many small static child-nodes - added COctTreeTriangleSelector::getTriangles for 3dline from user Piraaate - modified createOctTreeTriangleSelector and createTriangleSelector to allow node == 0, to be added to a meta selector - CSceneNodeAnimatorCollisionResponse has the same problem as CSceneNodeAnimatorFPS on first update: Problem. you start setting the map. (setWorld). First update cames 4000 ms later. The Animator applies the missing force... big problem... changed to react on first update like camera. - add Variable FirstUpdate. if set to true ( on all changes ) then position, lasttime, and falling are initialized -added #define OCTTREE_USE_HARDWARE in Octree.h if defined octtree uses internally a derived scene::MeshBuffer which has the possibility to use the Hardware Vertex Buffer for static vertices and dirty indices;-) if defined OCTTREE_USE_HARDWARE octree uses internally a derived scene::CMeshBuffer so it's not just a replacement inside the octree. It also in the OctTreeSceneNode. #if defined (OCTTREE_USE_HARDWARE) driver->drawMeshBuffer ( &LightMapMeshes[i] ); #else driver->drawIndexedTriangleList( &LightMapMeshes[i].Vertices[0], LightMapMeshes[i].Vertices.size(), d[i].Indices, d[i].CurrentSize / 3); #endif #define OCTTREE_PARENTTEST is also used. It's skip testing on fully outside and takes everything on fully inside - virtual void ISceneNode::updateAbsolutePosition() - changed inline CMatrix4<T> CMatrix4<T>::operator*(const CMatrix4<T>& m2) const all two matrices have to be checked by isIdentity() to let the isIdentity work always -changed inline bool CMatrix4<T>::isIdentity() const on full identityCheck-> to look first on Translation, because this is the most challenging element which will likely not to be identity.. - virtual core::matrix4 getRelativeTransformation() const Hiarchy on Identity-Check 1) ->getRelativeTransform -> 9 floating point checks to be passed as Identity 2) ->isIdentity () -> 16 floating point checks to be passed as Identity - inline void CMatrix4<T>::transformBoxEx(core::aabbox3d<f32>& box) const added isIdentity() check - changed CSceneNodeAnimatorCollisionResponse - added CSceneNodeAnimatorCollisionResponse::setGravity needed to set the differents Forces for the Animator. for eq. water.. - added CSceneNodeAnimatorCollisionResponse::setAnimateTarget - added CSceneNodeAnimatorCollisionResponse::getAnimateTarget - changed CSceneNodeAnimatorCollisionResponse::animateNode to react on FirstUpdate - changad Gravity to - TODO: set Gravity to Physically frame independent values.. current response uses an frame depdended acceleration vector. ~9.81 m/s^2 was achieved at around 50 fps with a setting of -0.03 may effect existing application.. - SceneNodes - CSkyDomeSceneNode moved radius ( default 1000 ) to constructor added Normals added DebugInfo added Material.ZBuffer, added SceneMaanager - CVolumeLightSceneNode: changed default blending OneTextureBlendgl_src_color gl_src_alpha to EMT_TRANSPARENT_ADD_COLOR ( gl_src_color gl_one ) which gives the same effect on non-transparent-materials. Following the unspoken guide-line, lowest effect as default - added LensFlareSceneNode (from forum user gammaray, modified to work ) showing in example special fx - changed SceneNode Skydome f64 to f32, - AnimatedMesh -Debug Data: mesh normals didn't rotate with the scenenode fixed ( matrix-multiplication order) - Camera SceneNode setPosition Camera now finally allow to change position and target and updates all effected animators.. a call to OnAnimate ( ) lastime < time or OnAnimate ( 0 ) will reset the camera and fr. the collision animator to a new position - Device: added the current mousebutton state to the Mouse Event so i need to get the current mouse state from the OS -a dded to CIrrDeviceWin32 TODO: - Linux and SDL Device - GUI - CGUIFont: - added virtual void setInvisibleCharacters( const wchar_t *s ) = 0; define which characters should not be drawn ( send to driver) by the font. for example " " would not draw any space which is usually blank in most fonts and saves rendering of ususally full blank alpha-sprites. This saves a lot of rendering... default: setInvisibleCharacters ( L" " ); - added MultiLine rendering should avoid to us CStaticText breaking text in future - CGUIListBox - changed Scrollbar LargeStepSize to ItemHeight which easy enables to scroll line by line - CGUIScrollBar bug: Create a Window and inside a listbox with a scrollbar or a windowed irrlicht application Click & hold Scrollbar Slider. move outside it's region. Release Mouse. Go Back to Scrollbar.. it's moving always... it's generally missing the event PRESSED_MOVED, which leads to problem when an element is dragging, has a focus, or position loose and gets focus back again. ( think of a drunken mouse sliding left&right during tracking ) so added the mouse Input Buttonstates on every mouse event IrrDeviceWin32: added event.MouseInput.ButtonStates = wParam & ( MK_LBUTTON | MK_RBUTTON | MK_MBUTTON ); TODO: Linux & SDL so now i can do this case irr::EMIE_MOUSE_MOVED: if ( !event.MouseInput.isLeftPressed () ) { Dragging = false; } - bug: Scrollbar notifyListBox notify when the scrollbar is clicked. - changed timed event in draw to OnPostRender Why the hell is a gui element firing a timed event in a draw routine!!!!!. This should be corrected for all gui-elements. - added GUI Image List from Reinhard Ostermeier, modified to work added GUI Tree View from Reinhard Ostermeier, modified to work shown in the Quake3MapShader Example TODO: Spritebanks - FileOpenDialog changed the static text for the filename to an edit box. - changed the interface for addEditBox to match with addStaticText - changed the interface for addSpinBox to match with addEditBox - added MouseWheel to Spinbox - changed CGUITable CLICK_AREA from 3 to 12 to enable clicking on the visible marker - CGUISpritebank removed some crashes with empty Sprite banks - IGUIScrollBar added SetMin before min was always 0 changed ScrollWheel Direction on horizontal to move right on wheel up, left on wheel down - IComboBox -added ItemData - removed IsVisbile check in IGUIElement::draw - Image Loaders - added TGA file type 2 ( grayscale uncompressed ) - added TGA file type (1) 8 Bit indexed color uncompressed ColorConverter: - added convert_B8G8R8toA8R8G8B8 - added convert_B8G8R8A8toA8R8G8B8 - Media Files - added missing shaders and textures to map-20kdm2. Taken from free implementation - ball.wav. adjusted DC-Offset, amplified to -4dB, trim cross-zero - impact.wav clip-restoration, trim cross-zero - added gun.md2, gun.pcx to media-files copyright issues!. i don't know from where this file came from... i hope this is not from original quake2.. - added new irrlicht logo irrlicht3.png i've taken the new layout. i should ask niko to use it. - added Skydome picture to media files (skydome2.jpg) half/sphere - OctTree -added #define OCTTREE_PARENTTEST ( default: disabled ) used to leave-out children test if the parent passed a complete frustum. plus: leaves out children test minus: all edges have to be checked - added MesBuffer Hardware Hint Vertex to octtree - CQuake3ShaderSceneNode: - removed function releaseMesh Shader doesn't copy the original mesh anymore ( saving memory ) so therefore this (for others often misleading ) function was removed - changed constructor to take a (shared) destination meshbuffer for rendering reducing vertex-memory to a half - don't copy the original vertices anymore - added deformvertexes autosprite - added deformvertexes move - added support for RTCW and Raven BSPs ( qmap2 ) - added polygonoffset (TODO: not perfect) - added added nomipmaps - added rgbgen const - added alphagen - added MesBuffer Hardware Hint Vertex/Index to Quake3: static geometry, dynamic indices - added Quake3Explorer examples - added wave noise - added tcmod transform - added whiteimage - added collision to Quake3Explorer - renamed SMD3QuaterionTag* to SMD3QuaternionTag* ( typo ) - updated quake3:blendfunc - added crouch to Quake3Explorer (modifying the ellipsiodRadius of the camera animator ) added crouch to CSceneNodeAnimatorCameraFPS still problems with stand up and collision - Quake3MapLoader modified memory allocation for faster loading - Quake3LoadParam added Parameter to the Mesh-Loader - added The still existing missing caulking of curved surfaces. using round in the coordinates doesn't solve the problem. but for the demo bsp mesh it solves the problem... (luck) so for now it's switchable. TJUNCTION_SOLVER_ROUND default:off - BurningVideo - pushed BurningsVideo to 0.40 - added blendfunc gl_one_minus_dst_alpha gl_one - added blendfunc gl_dst_color gl_zero - added blendfunc gl_dst_color src_alpha - modified AlphaChannel_Ref renderer to support alpha test lessequal - addded 32 Bit Index Buffer - added sourceRect/destRect check to 2D-Blitter ( slower, but resolves crash ) - added setTextureCreationFlag video::ETCF_ALLOW_NON_POWER_2 Burning checks this flag and when set, it bypasses the power2 size check, which is necessary on 3D but can be avoided on 2D. used on fonts automatically. - added Support for Destination Alpha - OpenGL - Fixed a bug in COpenGLExtensenionHandler where a glint was downcasted to u8!!!!!! MaxTextureSize=static_cast<u32>(num); - TODO: COpenGLMaterialRenderer_ONETEXTURE_BLEND to work as expected - Direct3D8 - compile and links again - added 32 Bit Index Buffer - D3DSAMP_MIPMAPLODBIAS doesnt compile!. it is d3d9 i think. - compile for XBOX - Direc3D9 - fixed crash on RTT Textures DepthBuffer freed twice. added deleteAllTextures to destuctor - NullDriver - removeallTextures. added setMaterial ( SMaterial() ) to clean pointers for freed textures git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2147 dfc29bdd-3216-0410-991c-e03cc46cb475
2009-01-27 07:53:53 -08:00
//! global const identity Material
IRRLICHT_API extern SMaterial IdentityMaterial;
} // end namespace video
} // end namespace irr
#endif