* irrlicht upgrade PART 2: upped irr 1.4

* someone please fix sln/vcproj for vc80
This commit is contained in:
false_genesis 2008-04-03 18:20:11 +00:00
parent ed316ab946
commit 025e084b09
911 changed files with 319052 additions and 27 deletions

View File

@ -21,22 +21,22 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shared", "src\shared.vcproj
{262199E8-EEDF-4700-A1D1-E9CC901CF480} = {262199E8-EEDF-4700-A1D1-E9CC901CF480}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Irrlicht", "src\dep\src\irrlicht\Irrlicht7.1.vcproj", "{E08E042A-6C45-411B-92BE-3CC31331019F}"
ProjectSection(ProjectDependencies) = postProject
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} = {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StuffExtract", "src\tools\stuffextract.vcproj", "{EFFE60F4-DA39-41E8-9E53-E462000A2D91}"
ProjectSection(ProjectDependencies) = postProject
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} = {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}
{F548FC51-24A4-45FF-A381-BEBC39F18270} = {F548FC51-24A4-45FF-A381-BEBC39F18270}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Irrlicht", "src\dep\src\irrlicht\Irrlicht7.1.vcproj", "{E08E042A-6C45-411B-92BE-3CC31331019F}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Debug = Debug
Relase - Fast FPU = Relase - Fast FPU
Release = Release
Release - Fast FPU = Release - Fast FPU
Release - Fast FPU DebugInfo = Release - Fast FPU DebugInfo
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
@ -46,6 +46,8 @@ Global
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Relase - Fast FPU.Build.0 = Release|Win32
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release.ActiveCfg = Release|Win32
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release.Build.0 = Release|Win32
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release - Fast FPU.ActiveCfg = Release|Win32
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release - Fast FPU.Build.0 = Release|Win32
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release - Fast FPU DebugInfo.ActiveCfg = Release|Win32
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release - Fast FPU DebugInfo.Build.0 = Release|Win32
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Debug.ActiveCfg = Debug|Win32
@ -54,6 +56,8 @@ Global
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Relase - Fast FPU.Build.0 = Release|Win32
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release.ActiveCfg = Release|Win32
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release.Build.0 = Release|Win32
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release - Fast FPU.ActiveCfg = Release|Win32
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release - Fast FPU.Build.0 = Release|Win32
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release - Fast FPU DebugInfo.ActiveCfg = Release|Win32
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release - Fast FPU DebugInfo.Build.0 = Release|Win32
{262199E8-EEDF-4700-A1D1-E9CC901CF480}.Debug.ActiveCfg = Debug|Win32
@ -62,6 +66,8 @@ Global
{262199E8-EEDF-4700-A1D1-E9CC901CF480}.Relase - Fast FPU.Build.0 = Release|Win32
{262199E8-EEDF-4700-A1D1-E9CC901CF480}.Release.ActiveCfg = Release|Win32
{262199E8-EEDF-4700-A1D1-E9CC901CF480}.Release.Build.0 = Release|Win32
{262199E8-EEDF-4700-A1D1-E9CC901CF480}.Release - Fast FPU.ActiveCfg = Release|Win32
{262199E8-EEDF-4700-A1D1-E9CC901CF480}.Release - Fast FPU.Build.0 = Release|Win32
{262199E8-EEDF-4700-A1D1-E9CC901CF480}.Release - Fast FPU DebugInfo.ActiveCfg = Release|Win32
{262199E8-EEDF-4700-A1D1-E9CC901CF480}.Release - Fast FPU DebugInfo.Build.0 = Release|Win32
{F548FC51-24A4-45FF-A381-BEBC39F18270}.Debug.ActiveCfg = Debug|Win32
@ -70,24 +76,30 @@ Global
{F548FC51-24A4-45FF-A381-BEBC39F18270}.Relase - Fast FPU.Build.0 = Release|Win32
{F548FC51-24A4-45FF-A381-BEBC39F18270}.Release.ActiveCfg = Release|Win32
{F548FC51-24A4-45FF-A381-BEBC39F18270}.Release.Build.0 = Release|Win32
{F548FC51-24A4-45FF-A381-BEBC39F18270}.Release - Fast FPU.ActiveCfg = Release|Win32
{F548FC51-24A4-45FF-A381-BEBC39F18270}.Release - Fast FPU.Build.0 = Release|Win32
{F548FC51-24A4-45FF-A381-BEBC39F18270}.Release - Fast FPU DebugInfo.ActiveCfg = Release|Win32
{F548FC51-24A4-45FF-A381-BEBC39F18270}.Release - Fast FPU DebugInfo.Build.0 = Release|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Debug.ActiveCfg = Debug|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Debug.Build.0 = Debug|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Relase - Fast FPU.ActiveCfg = Relase - Fast FPU|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Relase - Fast FPU.Build.0 = Relase - Fast FPU|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release.ActiveCfg = Release|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release.Build.0 = Release|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release - Fast FPU DebugInfo.ActiveCfg = Release - Fast FPU DebugInfo|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release - Fast FPU DebugInfo.Build.0 = Release - Fast FPU DebugInfo|Win32
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Debug.ActiveCfg = Debug|Win32
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Debug.Build.0 = Debug|Win32
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Relase - Fast FPU.ActiveCfg = Release|Win32
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Relase - Fast FPU.Build.0 = Release|Win32
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release.ActiveCfg = Release|Win32
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release.Build.0 = Release|Win32
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release - Fast FPU.ActiveCfg = Release|Win32
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release - Fast FPU.Build.0 = Release|Win32
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release - Fast FPU DebugInfo.ActiveCfg = Release|Win32
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release - Fast FPU DebugInfo.Build.0 = Release|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Debug.ActiveCfg = Debug|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Debug.Build.0 = Debug|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Relase - Fast FPU.ActiveCfg = Release - Fast FPU|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Relase - Fast FPU.Build.0 = Release - Fast FPU|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release.ActiveCfg = Release|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release.Build.0 = Release|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release - Fast FPU.ActiveCfg = Release - Fast FPU|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release - Fast FPU.Build.0 = Release - Fast FPU|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release - Fast FPU DebugInfo.ActiveCfg = Release - Fast FPU|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release - Fast FPU DebugInfo.Build.0 = Release - Fast FPU|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection

View File

@ -29,7 +29,7 @@
ImproveFloatingPointConsistency="FALSE"
FavorSizeOrSpeed="1"
AdditionalIncludeDirectories="shared;Client;Client/World;Client/Realm;dep/include"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_IRR_STATIC_LIB_"
StringPooling="TRUE"
RuntimeLibrary="0"
BufferSecurityCheck="FALSE"
@ -98,7 +98,7 @@
ImproveFloatingPointConsistency="FALSE"
OptimizeForProcessor="0"
AdditionalIncludeDirectories="shared;Client;Client/World;Client/Realm;dep/include"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_IRR_STATIC_LIB_"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
PrecompiledHeaderFile=""
@ -489,18 +489,42 @@
<File
RelativePath=".\dep\include\irrlicht\aabbox3d.h">
</File>
<File
RelativePath=".\dep\include\irrlicht\CMeshBuffer.h">
</File>
<File
RelativePath=".\dep\include\irrlicht\coreutil.h">
</File>
<File
RelativePath=".\dep\include\irrlicht\dimension2d.h">
</File>
<File
RelativePath=".\dep\include\irrlicht\ECullingTypes.h">
</File>
<File
RelativePath=".\dep\include\irrlicht\EDebugSceneTypes.h">
</File>
<File
RelativePath=".\dep\include\irrlicht\EDriverFeatures.h">
</File>
<File
RelativePath=".\dep\include\irrlicht\EDriverTypes.h">
</File>
<File
RelativePath=".\dep\include\irrlicht\EGUIElementTypes.h">
</File>
<File
RelativePath=".\dep\include\irrlicht\EMaterialFlags.h">
</File>
<File
RelativePath=".\dep\include\irrlicht\EMaterialTypes.h">
</File>
<File
RelativePath=".\dep\include\irrlicht\EMeshWriterEnums.h">
</File>
<File
RelativePath=".\dep\include\irrlicht\EMessageBoxFlags.h">
</File>
<File
RelativePath=".\dep\include\irrlicht\ESceneNodeAnimatorTypes.h">
</File>
@ -519,24 +543,15 @@
<File
RelativePath=".\dep\include\irrlicht\IAnimatedMesh.h">
</File>
<File
RelativePath=".\dep\include\irrlicht\IAnimatedMeshB3d.h">
</File>
<File
RelativePath=".\dep\include\irrlicht\IAnimatedMeshMD2.h">
</File>
<File
RelativePath=".\dep\include\irrlicht\IAnimatedMeshMD3.h">
</File>
<File
RelativePath=".\dep\include\irrlicht\IAnimatedMeshMS3D.h">
</File>
<File
RelativePath=".\dep\include\irrlicht\IAnimatedMeshSceneNode.h">
</File>
<File
RelativePath=".\dep\include\irrlicht\IAnimatedMeshX.h">
</File>
<File
RelativePath=".\dep\include\irrlicht\IAttributeExchangingObject.h">
</File>
@ -546,6 +561,9 @@
<File
RelativePath=".\dep\include\irrlicht\IBillboardSceneNode.h">
</File>
<File
RelativePath=".\dep\include\irrlicht\IBoneSceneNode.h">
</File>
<File
RelativePath=".\dep\include\irrlicht\ICameraSceneNode.h">
</File>
@ -621,6 +639,9 @@
<File
RelativePath=".\dep\include\irrlicht\IGUISkin.h">
</File>
<File
RelativePath=".\dep\include\irrlicht\IGUISpinBox.h">
</File>
<File
RelativePath=".\dep\include\irrlicht\IGUISpriteBank.h">
</File>
@ -675,6 +696,9 @@
<File
RelativePath=".\dep\include\irrlicht\IMeshSceneNode.h">
</File>
<File
RelativePath=".\dep\include\irrlicht\IMeshWriter.h">
</File>
<File
RelativePath=".\dep\include\irrlicht\IMetaTriangleSelector.h">
</File>
@ -684,9 +708,39 @@
<File
RelativePath=".\dep\include\irrlicht\IParticleAffector.h">
</File>
<File
RelativePath=".\dep\include\irrlicht\IParticleAnimatedMeshSceneNodeEmitter.h">
</File>
<File
RelativePath=".\dep\include\irrlicht\IParticleAttractionAffector.h">
</File>
<File
RelativePath=".\dep\include\irrlicht\IParticleBoxEmitter.h">
</File>
<File
RelativePath=".\dep\include\irrlicht\IParticleCylinderEmitter.h">
</File>
<File
RelativePath=".\dep\include\irrlicht\IParticleEmitter.h">
</File>
<File
RelativePath=".\dep\include\irrlicht\IParticleFadeOutAffector.h">
</File>
<File
RelativePath=".\dep\include\irrlicht\IParticleGravityAffector.h">
</File>
<File
RelativePath=".\dep\include\irrlicht\IParticleMeshEmitter.h">
</File>
<File
RelativePath=".\dep\include\irrlicht\IParticleRingEmitter.h">
</File>
<File
RelativePath=".\dep\include\irrlicht\IParticleRotationAffector.h">
</File>
<File
RelativePath=".\dep\include\irrlicht\IParticleSphereEmitter.h">
</File>
<File
RelativePath=".\dep\include\irrlicht\IParticleSystemSceneNode.h">
</File>
@ -699,6 +753,9 @@
<File
RelativePath=".\dep\include\irrlicht\IReadFile.h">
</File>
<File
RelativePath=".\dep\include\irrlicht\IReferenceCounted.h">
</File>
<File
RelativePath=".\dep\include\irrlicht\irrAllocator.h">
</File>
@ -762,6 +819,9 @@
<File
RelativePath=".\dep\include\irrlicht\IShadowVolumeSceneNode.h">
</File>
<File
RelativePath=".\dep\include\irrlicht\ISkinnedMesh.h">
</File>
<File
RelativePath=".\dep\include\irrlicht\ITerrainSceneNode.h">
</File>
@ -777,9 +837,6 @@
<File
RelativePath=".\dep\include\irrlicht\ITriangleSelector.h">
</File>
<File
RelativePath=".\dep\include\irrlicht\IUnknown.h">
</File>
<File
RelativePath=".\dep\include\irrlicht\IVideoDriver.h">
</File>
@ -846,6 +903,9 @@
<File
RelativePath=".\dep\include\irrlicht\SMaterial.h">
</File>
<File
RelativePath=".\dep\include\irrlicht\SMaterialLayer.h">
</File>
<File
RelativePath=".\dep\include\irrlicht\SMesh.h">
</File>
@ -861,6 +921,12 @@
<File
RelativePath=".\dep\include\irrlicht\SParticle.h">
</File>
<File
RelativePath=".\dep\include\irrlicht\SSharedMeshBuffer.h">
</File>
<File
RelativePath=".\dep\include\irrlicht\SSkinMeshBuffer.h">
</File>
<File
RelativePath=".\dep\include\irrlicht\SViewFrustum.h">
</File>

View File

@ -0,0 +1,166 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __T_MESH_BUFFER_H_INCLUDED__
#define __T_MESH_BUFFER_H_INCLUDED__
#include "irrArray.h"
#include "IMeshBuffer.h"
namespace irr
{
namespace scene
{
//! Template implementation of the IMeshBuffer interface
template <class T>
class CMeshBuffer : public IMeshBuffer
{
public:
//! constructor
CMeshBuffer() // everything's default constructed
{
#ifdef _DEBUG
setDebugName("SMeshBuffer");
#endif
}
//! returns the material of this meshbuffer
virtual const video::SMaterial& getMaterial() const
{
return Material;
}
//! returns the material of this meshbuffer
virtual video::SMaterial& getMaterial()
{
return Material;
}
//! returns pointer to vertices
virtual const void* getVertices() const
{
return Vertices.const_pointer();
}
//! returns pointer to vertices
virtual void* getVertices()
{
return Vertices.pointer();
}
//! returns amount of vertices
virtual u32 getVertexCount() const
{
return Vertices.size();
}
//! returns pointer to Indices
virtual const u16* getIndices() const
{
return Indices.const_pointer();
}
//! returns pointer to Indices
virtual u16* getIndices()
{
return Indices.pointer();
}
//! returns amount of indices
virtual u32 getIndexCount() const
{
return Indices.size();
}
//! returns an axis aligned bounding box
virtual const core::aabbox3d<f32>& getBoundingBox() const
{
return BoundingBox;
}
//! set user axis aligned bounding box
virtual void setBoundingBox(const core::aabbox3df& box)
{
BoundingBox = box;
}
//! recalculates the bounding box. should be called if the mesh changed.
virtual void recalculateBoundingBox()
{
if (Vertices.empty())
BoundingBox.reset(0,0,0);
else
{
BoundingBox.reset(Vertices[0].Pos);
for (u32 i=1; i<Vertices.size(); ++i)
BoundingBox.addInternalPoint(Vertices[i].Pos);
}
}
//! returns which type of vertex data is stored.
virtual video::E_VERTEX_TYPE getVertexType() const
{
return T().getType();
}
//! append the vertices and indices to the current buffer
virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices)
{
const u32 vertexCount = getVertexCount();
u32 i;
Vertices.reallocate(vertexCount+numVertices);
for (i=0; i<numVertices; ++i)
{
Vertices.push_back(reinterpret_cast<const T*>(vertices)[i]);
BoundingBox.addInternalPoint(reinterpret_cast<const T*>(vertices)[i].Pos);
}
Indices.reallocate(getIndexCount()+numIndices);
for (i=0; i<numIndices; ++i)
{
Indices.push_back(indices[i]+vertexCount);
}
}
//! append the meshbuffer to the current buffer
virtual void append(const IMeshBuffer* const other)
{
const u32 vertexCount = getVertexCount();
u32 i;
Vertices.reallocate(vertexCount+other->getVertexCount());
for (i=0; i<other->getVertexCount(); ++i)
{
Vertices.push_back(reinterpret_cast<const T*>(other->getVertices())[i]);
}
Indices.reallocate(getIndexCount()+other->getIndexCount());
for (i=0; i<other->getIndexCount(); ++i)
{
Indices.push_back(other->getIndices()[i]+vertexCount);
}
BoundingBox.addInternalBox(other->getBoundingBox());
}
//! Material for this meshbuffer.
video::SMaterial Material;
//! Vertices of this buffer
core::array<T> Vertices;
//! Indices into the vertices of this buffer.
core::array<u16> Indices;
//! Bounding box of this meshbuffer.
core::aabbox3d<f32> BoundingBox;
};
typedef CMeshBuffer<video::S3DVertex> SMeshBuffer;
typedef CMeshBuffer<video::S3DVertex2TCoords> SMeshBufferLightMap;
typedef CMeshBuffer<video::S3DVertexTangents> SMeshBufferTangents;
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,39 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __E_CULLING_TYPES_H_INCLUDED__
#define __E_CULLING_TYPES_H_INCLUDED__
#include "irrTypes.h"
namespace irr
{
namespace scene
{
//! An enumeration for all types of automatic culling for built-in scene nodes
enum E_CULLING_TYPE
{
EAC_OFF = 0,
EAC_BOX = 1,
EAC_FRUSTUM_BOX = 2,
EAC_FRUSTUM_SPHERE = 4
};
//! Names for culling type
const c8* const AutomaticCullingNames[] =
{
"false",
"box", // camera box against node box
"frustum_box", // camera frustum against node box
"frustum_sphere", // camera frustum against node sphere
0
};
} // end namespace scene
} // end namespace irr
#endif // __E_CULLING_TYPES_H_INCLUDED__

View File

@ -0,0 +1,47 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __E_DEBUG_SCENE_TYPES_H_INCLUDED__
#define __E_DEBUG_SCENE_TYPES_H_INCLUDED__
namespace irr
{
namespace scene
{
//! An enumeration for all types of debug data for built-in scene nodes (flags)
enum E_DEBUG_SCENE_TYPE
{
//! No Debug Data ( Default )
EDS_OFF = 0,
//! Show Bounding Boxes of SceneNode
EDS_BBOX = 1,
//! Show Vertex Normals
EDS_NORMALS = 2,
//! Shows Skeleton/Tags
EDS_SKELETON = 4,
//! Overlays Mesh Wireframe
EDS_MESH_WIRE_OVERLAY = 8,
//! Temporary use transparency Material Type
EDS_HALF_TRANSPARENCY = 16,
//! Show Bounding Boxes of all MeshBuffers
EDS_BBOX_BUFFERS = 32,
//! Show all debug infos
EDS_FULL = 0xffffffff
};
} // end namespace scene
} // end namespace irr
#endif // __E_DEBUG_SCENE_TYPES_H_INCLUDED__

View File

@ -0,0 +1,88 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __E_DRIVER_FEATURES_H_INCLUDED__
#define __E_DRIVER_FEATURES_H_INCLUDED__
namespace irr
{
namespace video
{
//! enumeration for querying features of the video driver.
enum E_VIDEO_DRIVER_FEATURE
{
//! Is driver able to render to a surface?
EVDF_RENDER_TO_TARGET = 0,
//! Is hardeware transform and lighting supported?
EVDF_HARDWARE_TL,
//! Are multiple textures per material possible?
EVDF_MULTITEXTURE,
//! Is driver able to render with a bilinear filter applied?
EVDF_BILINEAR_FILTER,
//! Can the driver handle mip maps?
EVDF_MIP_MAP,
//! Can the driver update mip maps automatically?
EVDF_MIP_MAP_AUTO_UPDATE,
//! Are stencilbuffers switched on and does the device support stencil buffers?
EVDF_STENCIL_BUFFER,
//! Is Vertex Shader 1.1 supported?
EVDF_VERTEX_SHADER_1_1,
//! Is Vertex Shader 2.0 supported?
EVDF_VERTEX_SHADER_2_0,
//! Is Vertex Shader 3.0 supported?
EVDF_VERTEX_SHADER_3_0,
//! Is Pixel Shader 1.1 supported?
EVDF_PIXEL_SHADER_1_1,
//! Is Pixel Shader 1.2 supported?
EVDF_PIXEL_SHADER_1_2,
//! Is Pixel Shader 1.3 supported?
EVDF_PIXEL_SHADER_1_3,
//! Is Pixel Shader 1.4 supported?
EVDF_PIXEL_SHADER_1_4,
//! Is Pixel Shader 2.0 supported?
EVDF_PIXEL_SHADER_2_0,
//! Is Pixel Shader 3.0 supported?
EVDF_PIXEL_SHADER_3_0,
//! Are ARB vertex programs v1.0 supported?
EVDF_ARB_VERTEX_PROGRAM_1,
//! Are ARB fragment programs v1.0 supported?
EVDF_ARB_FRAGMENT_PROGRAM_1,
//! Is GLSL supported?
EVDF_ARB_GLSL,
//! Is HLSL supported?
EVDF_HLSL,
//! Are non-power-of-two textures supported?
EVDF_TEXTURE_NPOT,
//! Are framebuffer objects supported?
EVDF_FRAMEBUFFER_OBJECT
};
} // end namespace video
} // end namespace irr
#endif

View File

@ -0,0 +1,56 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __E_DRIVER_TYPES_H_INCLUDED__
#define __E_DRIVER_TYPES_H_INCLUDED__
namespace irr
{
namespace video
{
//! An enum for all types of drivers the Irrlicht Engine supports.
enum E_DRIVER_TYPE
{
//! Null device, useful for applications to run the engine without visualisation.
//! The null device is able to load textures, but does not render and display
//! any graphics.
EDT_NULL,
//! The Irrlicht Engine Software renderer, runs on all platforms,
//! with every hardware. It should only be used for 2d graphics,
//! but it can also perform some primitive 3d functions. These 3d drawing
//! functions are quite fast, but very inaccurate, and don't even support
//! clipping in 3D mode.
EDT_SOFTWARE,
//! The Burning's Software Renderer, an alternative software renderer for Irrlicht.
//! Basically it can be described as the Irrlicht Software renderer on steroids. It rasterizes
//! 3D geometry perfectly: It is able to perform correct 3d clipping, perspective
//! correct texture mapping, perspective correct color mapping, and renders
//! sub pixel correct, sub texel correct primitives. In addition, it does
//! bilinear texel filtering and supports more materials than the EDT_SOFTWARE driver.
//! This renderer has been written entirely by Thomas Alten, thanks a lot for this huge
//! contribution.
EDT_BURNINGSVIDEO,
//! Direct3D 8 device, only available on Win32 platforms.
//! Performs hardware accelerated rendering of 3D and 2D primitives.
EDT_DIRECT3D8,
//! Direct3D 9 device, only available on Win32 platforms.
//! Performs hardware accelerated rendering of 3D and 2D primitives.
EDT_DIRECT3D9,
//! OpenGL device, available on most platforms.
//! Performs hardware accelerated rendering of 3D and 2D primitives.
EDT_OPENGL
};
} // end namespace video
} // end namespace irr
#endif

View File

@ -0,0 +1,123 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __E_GUI_ELEMENT_TYPES_H_INCLUDED__
#define __E_GUI_ELEMENT_TYPES_H_INCLUDED__
namespace irr
{
namespace gui
{
//! List of all basic Irrlicht GUI elements.
/** An IGUIElement returns this when calling IGUIElement::getType(); */
enum EGUI_ELEMENT_TYPE
{
//! A button (IGUIButton)
EGUIET_BUTTON = 0,
//! A check box (IGUICheckBox)
EGUIET_CHECK_BOX,
//! A combo box (IGUIComboBox)
EGUIET_COMBO_BOX,
//! A context menu (IGUIContextMenu)
EGUIET_CONTEXT_MENU,
//! A menu (IGUIMenu)
EGUIET_MENU,
//! An edit box (IGUIEditBox)
EGUIET_EDIT_BOX,
//! A file open dialog (IGUIFileOpenDialog)
EGUIET_FILE_OPEN_DIALOG,
//! A color select open dialog (IGUIColorSelectDialog)
EGUIET_COLOR_SELECT_DIALOG,
//! A in/out fader (IGUIInOutFader)
EGUIET_IN_OUT_FADER,
//! An image (IGUIImage)
EGUIET_IMAGE,
//! A list box (IGUIListBox)
EGUIET_LIST_BOX,
//! A mesh viewer (IGUIMeshViewer)
EGUIET_MESH_VIEWER,
//! A message box (IGUIWindow)
EGUIET_MESSAGE_BOX,
//! A modal screen
EGUIET_MODAL_SCREEN,
//! A scroll bar (IGUIScrollBar)
EGUIET_SCROLL_BAR,
//! A static text (IGUIStaticText)
EGUIET_STATIC_TEXT,
//! A tab (IGUITab)
EGUIET_TAB,
//! A tab control
EGUIET_TAB_CONTROL,
//! A tool bar (IGUIToolBar)
EGUIET_TOOL_BAR,
//! A window
EGUIET_WINDOW,
//! A spin box (IGUISpinBox)
EGUIET_SPIN_BOX,
//! Not an element, amount of elements in there
EGUIET_COUNT,
//! Unknown type.
EGUIET_ELEMENT,
//! This enum is never used, it only forces the compiler to
//! compile these enumeration values to 32 bit.
EGUIET_FORCE_32_BIT = 0x7fffffff
};
//! Names for built-in element types
const c8* const GUIElementTypeNames[] =
{
"button",
"checkBox",
"comboBox",
"contextMenu",
"menu",
"editBox",
"fileOpenDialog",
"colorSelectDialog",
"inOutFader",
"image",
"listBox",
"meshViewer",
"messageBox",
"modalScreen",
"scrollBar",
"staticText",
"tab",
"tabControl",
"toolBar",
"window",
"spinBox",
0
};
} // end namespace gui
} // end namespace irr
#endif

View File

@ -0,0 +1,74 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __E_MATERIAL_FLAGS_H_INCLUDED__
#define __E_MATERIAL_FLAGS_H_INCLUDED__
namespace irr
{
namespace video
{
//! Material flags
enum E_MATERIAL_FLAG
{
//! Draw as wireframe or filled triangles? Default: false
EMF_WIREFRAME = 0,
//! Draw as point cloud or filled triangles? Default: false
EMF_POINTCLOUD,
//! Flat or Gouraud shading? Default: true
EMF_GOURAUD_SHADING,
//! Will this material be lighted? Default: true
EMF_LIGHTING,
//! Is the ZBuffer enabled? Default: true
EMF_ZBUFFER,
//! May be written to the zbuffer or is it readonly. Default: true
//! This flag is ignored, if the material type is a transparent type.
EMF_ZWRITE_ENABLE,
//! Is backfaceculling enabled? Default: true
EMF_BACK_FACE_CULLING,
//! Is bilinear filtering enabled? Default: true
EMF_BILINEAR_FILTER,
//! Is trilinear filtering enabled? Default: false
//! If the trilinear filter flag is enabled,
//! the bilinear filtering flag is ignored.
EMF_TRILINEAR_FILTER,
//! Is anisotropic filtering? Default: false
//! In Irrlicht you can use anisotropic texture filtering in
//! conjunction with bilinear or trilinear texture filtering
//! to improve rendering results. Primitives will look less
//! blurry with this flag switched on.
EMF_ANISOTROPIC_FILTER,
//! Is fog enabled? Default: false
EMF_FOG_ENABLE,
//! Normalizes normals.You can enable this if you need
//! to scale a dynamic lighted model. Usually, its normals will get scaled
//! too then and it will get darker. If you enable the EMF_NORMALIZE_NORMALS flag,
//! the normals will be normalized again, and the model will look as bright as it should.
EMF_NORMALIZE_NORMALS,
//! Access to all layers texture wrap settings. Overwrites separate layer settings.
EMF_TEXTURE_WRAP,
//! This is not a flag, but a value indicating how much flags there are.
EMF_MATERIAL_FLAG_COUNT
};
} // end namespace video
} // end namespace irr
#endif // __E_MATERIAL_FLAGS_H_INCLUDED__

View File

@ -0,0 +1,223 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __E_MATERIAL_TYPES_H_INCLUDED__
#define __E_MATERIAL_TYPES_H_INCLUDED__
namespace irr
{
namespace video
{
//! Abstracted and easy to use fixed function/programmable pipeline material modes.
enum E_MATERIAL_TYPE
{
//! Standard solid material. Only first texture is used, which is
//! supposed to be the diffuse material.
EMT_SOLID = 0,
//! Solid material with 2 texture layers. The second is blended onto the
//! first using the alpha value of the vertex colors.
//! This material is currently not implemented in OpenGL, but it
//! works with DirectX.
EMT_SOLID_2_LAYER,
//! Material type with standard lightmap technique:
//! There should be 2 textures: The first texture layer is a diffuse map,
//! the second is a light map. Vertex light is ignored.
EMT_LIGHTMAP,
//! Material type with lightmap technique like EMT_LIGHTMAP, but
//! lightmap and diffuse texture are not modulated, but added instead.
EMT_LIGHTMAP_ADD,
//! Material type with standard lightmap technique:
//! There should be 2 textures: The first texture layer is a diffuse map,
//! the second is a light map. Vertex light is ignored.
//! The texture colors are effectively multiplyied by 2 for brightening.
//! like known in DirectX as D3DTOP_MODULATE2X.
EMT_LIGHTMAP_M2,
//! Material type with standard lightmap technique:
//! There should be 2 textures: The first texture layer is a diffuse map,
//! the second is a light map. Vertex light is ignored.
//! The texture colors are effectively multiplyied by 4 for brightening.
//! like known in DirectX as D3DTOP_MODULATE4X.
EMT_LIGHTMAP_M4,
//! Like EMT_LIGHTMAP, but also supports dynamic lighting.
EMT_LIGHTMAP_LIGHTING,
//! Like EMT_LIGHTMAP_M2, but also supports dynamic lighting.
EMT_LIGHTMAP_LIGHTING_M2,
//! Like EMT_LIGHTMAP_4, but also supports dynamic lighting.
EMT_LIGHTMAP_LIGHTING_M4,
//! Detail mapped material. The first texture is diffuse color map, the
//! second is added to this and usually displayed with a bigger scale value
//! so that it adds more detail. The detail map is added to the diffuse map using
//! ADD_SIGNED, so that it is possible to add and substract color from the diffuse
//! map. For example a value of (127,127,127) will not change the appearance of
//! the diffuse map at all.
//! Often used for terrain rendering.
EMT_DETAIL_MAP,
//! Makes the material look like it was reflection the environment
//! around it. To make this possible, a texture called 'sphere map'
//! is used, which must be set as Textures[0].
EMT_SPHERE_MAP,
//! A reflecting material with an
//! optional additional non reflecting texture layer. The reflection
//! map should be set as Texture 1.
EMT_REFLECTION_2_LAYER,
//! A transparent material. Only the first texture is used.
//! The new color is calculated by simply adding the source color and
//! the dest color. This means if for example a billboard using a texture with
//! black background and a red circle on it is drawn with this material, the
//! result is that only the red circle will be drawn a little bit transparent,
//! and everything which was black is 100% transparent and not visible.
//! This material type is useful for e.g. particle effects.
EMT_TRANSPARENT_ADD_COLOR,
//! Makes the material transparent based on the texture alpha channel.
//! The final color is blended together from the destination color and the
//! texture color, using the alpha channel value as blend factor.
//! Only first texture is used. If you are using this material with small
//! textures, it is a good idea to load the texture in 32 bit
//! mode (video::IVideoDriver::setTextureCreationFlag()).
//! Also, an alpha ref is used, which can be manipulated using SMaterial::MaterialTypeParam.
//! If set to 0, the alpha ref gets its default value which is 0.5f and which means
//! that pixels with an alpha value >127 will be written, others not. In other, simple
//! words: this value controls how sharp the edges become when going from a
//! transparent to a solid spot on the texture.
EMT_TRANSPARENT_ALPHA_CHANNEL,
//! Makes the material transparent based on the texture alpha channel.
//! If the alpha channel value is greater than 127, a pixel is written to the
//! target, otherwise not. This material does not use alpha blending
//! and is a lot faster than EMT_TRANSPARENT_ALPHA_CHANNEL. It
//! is ideal for drawing stuff like leafes of plants, because the borders
//! are not blurry but sharp.
//! Only first texture is used. If you are using this material with small
//! textures and 3d object, it is a good idea to load the texture in 32 bit
//! mode (video::IVideoDriver::setTextureCreationFlag()).
EMT_TRANSPARENT_ALPHA_CHANNEL_REF,
//! Makes the material transparent based on the vertex alpha value.
EMT_TRANSPARENT_VERTEX_ALPHA,
//! A transparent reflecting material with an
//! optional additional non reflecting texture layer. The reflection
//! map should be set as Texture 1. The transparency depends on the
//! alpha value in the vertex colors. A texture which will not reflect
//! can be set als Texture 2.
//! Please note that this material type is currently not 100% implemented
//! in OpenGL. It works in Direct3D.
EMT_TRANSPARENT_REFLECTION_2_LAYER,
//! A solid normal map renderer. First texture is the color map, the
//! second should be the normal map. Note that you should use this material
//! only when drawing geometry consisting of vertices of type S3DVertexTangents
//! (EVT_TANGENTS). You can convert any mesh into this format using
//! IMeshManipulator::createMeshWithTangents() (See SpecialFX2 Tutorial).
//! This shader runs on vertex shader 1.1 and pixel shader 1.1 capable hardware and
//! falls back on a fixed function lighted material if this hardware is not available.
//! Only two lights are supported by this shader, if there are more, the nearest two
//! are chosen. Currently, this shader is only implemented for the D3D8 and D3D9 renderers.
EMT_NORMAL_MAP_SOLID,
//! A transparent normal map renderer. First texture is the color map, the
//! second should be the normal map. Note that you should use this material
//! only when drawing geometry consisting of vertices of type S3DVertexTangents
//! (EVT_TANGENTS). You can convert any mesh into this format using
//! IMeshManipulator::createMeshWithTangents() (See SpecialFX2 Tutorial).
//! This shader runs on vertex shader 1.1 and pixel shader 1.1 capable hardware and
//! falls back on a fixed function lighted material if this hardware is not available.
//! Only two lights are supported by this shader, if there are more, the nearest two
//! are chosen. Currently, this shader is only implemented for the D3D8 and D3D9 renderers.
EMT_NORMAL_MAP_TRANSPARENT_ADD_COLOR,
//! A transparent (based on the vertex alpha value) normal map renderer.
//! First texture is the color map, the
//! second should be the normal map. Note that you should use this material
//! only when drawing geometry consisting of vertices of type S3DVertexTangents
//! (EVT_TANGENTS). You can convert any mesh into this format using
//! IMeshManipulator::createMeshWithTangents() (See SpecialFX2 Tutorial).
//! This shader runs on vertex shader 1.1 and pixel shader 1.1 capable hardware and
//! falls back on a fixed function lighted material if this hardware is not available.
//! Only two lights are supported by this shader, if there are more, the nearest two
//! are chosen. Currently, this shader is only implemented for the D3D8 and D3D9 renderers.
EMT_NORMAL_MAP_TRANSPARENT_VERTEX_ALPHA,
//! Just like EMT_NORMAL_MAP_SOLID, but uses parallax mapping too, which
//! looks a lot more realistic. This only works when the hardware supports at
//! least vertex shader 1.1 and pixel shader 1.4.
//! First texture is the color map, the second should be the normal map.
//! The normal map texture should contain the height value in the
//! alpha component. The IVideoDriver::makeNormalMapTexture() method writes
//! this value automaticly when creating normal maps from a heightmap when using a 32 bit
//! texture.
//! The height scale of the material (affecting the bumpiness) is being controlled
//! by the SMaterial::MaterialTypeParam member.
//! If set to zero, the default value (0.02f) will be applied. Otherwise
//! the value set in SMaterial::MaterialTypeParam is taken. This value depends on with which
//! scale the texture is mapped on the material. Too high or low values of MaterialTypeParam
//! can result in strange artifacts.
EMT_PARALLAX_MAP_SOLID,
//! A material just like EMT_PARALLAX_MAP_SOLID, but it is transparent, using
//! EMT_TRANSPARENT_ADD_COLOR as base material.
EMT_PARALLAX_MAP_TRANSPARENT_ADD_COLOR,
//! A material just like EMT_PARALLAX_MAP_SOLID, but it is transparent, using
//! EMT_TRANSPARENT_VERTEX_ALPHA as base material.
EMT_PARALLAX_MAP_TRANSPARENT_VERTEX_ALPHA,
//! BlendFunc = source * sourceFactor + dest * destFactor ( E_BLEND_FUNC )
//! Using only Textures[0]. generic Blender
EMT_ONETEXTURE_BLEND,
//! This value is not used. It only forces this enumeration to compile in 32 bit.
EMT_FORCE_32BIT = 0x7fffffff
};
//! Array holding the built in material type names
const char* const sBuiltInMaterialTypeNames[] =
{
"solid",
"solid_2layer",
"lightmap",
"lightmap_add",
"lightmap_m2",
"lightmap_m4",
"lightmap_light",
"lightmap_light_m2",
"lightmap_light_m4",
"detail_map",
"sphere_map",
"reflection_2layer",
"trans_add",
"trans_alphach",
"trans_alphach_ref",
"trans_vertex_alpha",
"trans_reflection_2layer",
"normalmap_solid",
"normalmap_trans_add",
"normalmap_trans_vertexalpha",
"parallaxmap_solid",
"parallaxmap_trans_add",
"parallaxmap_trans_vertexalpha",
"onetexture_blend",
0
};
} // end namespace video
} // end namespace irr
#endif // __E_MATERIAL_TYPES_H_INCLUDED__

View File

@ -0,0 +1,48 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __E_MESH_WRITER_ENUMS_H_INCLUDED__
#define __E_MESH_WRITER_ENUMS_H_INCLUDED__
namespace irr
{
namespace scene
{
//! An enumeration for all supported types of built-in mesh writers
/** A scene mesh writers is represented by a four character code
such as 'irrm' or 'coll' instead of simple numbers, to avoid
name clashes with external mesh writers.*/
enum EMESH_WRITER_TYPE
{
//! Irrlicht Native mesh writer, for static .irrmesh files.
EMWT_IRR_MESH = MAKE_IRR_ID('i','r','r','m'),
//! COLLADA mesh writer for .dae and .xml files
EMWT_COLLADA = MAKE_IRR_ID('c','o','l','l'),
//! STL mesh writer for .stl files
EMWT_STL = MAKE_IRR_ID('s','t','l',0)
};
//! flags configuring mesh writing
enum E_MESH_WRITER_FLAGS
{
//! no writer flags
EMWF_NONE = 0,
//! write lightmap textures out if possible
EMWF_WRITE_LIGHTMAPS = 0x1,
//! write in a way that does consume less disk space
EMWF_WRITE_COMPRESSED = 0x2
};
} // end namespace scene
} // end namespace irr
#endif // __E_MESH_WRITER_ENUMS_H_INCLUDED__

View File

@ -0,0 +1,35 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __E_MESSAGE_BOX_FLAGS_H_INCLUDED__
#define __E_MESSAGE_BOX_FLAGS_H_INCLUDED__
namespace irr
{
namespace gui
{
//! enumeration for message box layout flags
enum EMESSAGE_BOX_FLAG
{
//! Flag for the ok button
EMBF_OK = 0x1,
//! Flag for the cancel button
EMBF_CANCEL = 0x2,
//! Flag for the yes button
EMBF_YES = 0x4,
//! Flag for the no button
EMBF_NO = 0x8,
//! This value is not used. It only forces this enumeration to compile in 32 bit.
EMBF_FORCE_32BIT = 0x7fffffff
};
} // namespace gui
} // namespace irr
#endif

View File

@ -0,0 +1,53 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __E_SCENE_NODE_ANIMATOR_TYPES_H_INCLUDED__
#define __E_SCENE_NODE_ANIMATOR_TYPES_H_INCLUDED__
namespace irr
{
namespace scene
{
//! An enumeration for all types of built-in scene node animators
enum ESCENE_NODE_ANIMATOR_TYPE
{
//! Fly circle scene node animator
ESNAT_FLY_CIRCLE = 0,
//! Fly straight scene node animator
ESNAT_FLY_STRAIGHT,
//! Follow spline scene node animator
ESNAT_FOLLOW_SPLINE,
//! Rotation scene node animator
ESNAT_ROTATION,
//! Texture scene node animator
ESNAT_TEXTURE,
//! Deletion scene node animator
ESNAT_DELETION,
//! Collision respose scene node animator
ESNAT_COLLISION_RESPONSE,
//! Amount of built-in scene node animators
ESNAT_COUNT,
//! Unknown scene node animator
ESNAT_UNKNOWN,
//! This enum is never used, it only forces the compiler to
//! compile these enumeration values to 32 bit.
ESNAT_FORCE_32_BIT = 0x7fffffff
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,89 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __E_SCENE_NODE_TYPES_H_INCLUDED__
#define __E_SCENE_NODE_TYPES_H_INCLUDED__
#include "irrTypes.h"
namespace irr
{
namespace scene
{
//! An enumeration for all types of built-in scene nodes
/** A scene node type is represented by a four character code
such as 'cube' or 'mesh' instead of simple numbers, to avoid
name clashes with external scene nodes.*/
enum ESCENE_NODE_TYPE
{
//! simple cube scene node
ESNT_CUBE = MAKE_IRR_ID('c','u','b','e'),
//! Sphere scene node
ESNT_SPHERE = MAKE_IRR_ID('s','p','h','r'),
//! Text Scene Node
ESNT_TEXT = MAKE_IRR_ID('t','e','x','t'),
//! Water Surface Scene Node
ESNT_WATER_SURFACE = MAKE_IRR_ID('w','a','t','r'),
//! Terrain Scene Node
ESNT_TERRAIN = MAKE_IRR_ID('t','e','r','r'),
//! Sky Box Scene Node
ESNT_SKY_BOX = MAKE_IRR_ID('s','k','y','_'),
//! Shadow Volume Scene Node
ESNT_SHADOW_VOLUME = MAKE_IRR_ID('s','h','d','w'),
//! OctTree Scene Node
ESNT_OCT_TREE = MAKE_IRR_ID('o','c','t','t'),
//! Mesh Scene Node
ESNT_MESH = MAKE_IRR_ID('m','e','s','h'),
//! Light Scene Node
ESNT_LIGHT = MAKE_IRR_ID('l','g','h','t'),
//! Empty Scene Node
ESNT_EMPTY = MAKE_IRR_ID('e','m','t','y'),
//! Dummy Transformation Scene Node
ESNT_DUMMY_TRANSFORMATION = MAKE_IRR_ID('d','m','m','y'),
//! Camera Scene Node
ESNT_CAMERA = MAKE_IRR_ID('c','a','m','_'),
//! Maya Camera Scene Node
ESNT_CAMERA_MAYA = MAKE_IRR_ID('c','a','m','M'),
//! First Person Shooter style Camera
ESNT_CAMERA_FPS = MAKE_IRR_ID('c','a','m','F'),
//! Billboard Scene Node
ESNT_BILLBOARD = MAKE_IRR_ID('b','i','l','l'),
//! Animated Mesh Scene Node
ESNT_ANIMATED_MESH = MAKE_IRR_ID('a','m','s','h'),
//! Particle System Scene Node
ESNT_PARTICLE_SYSTEM = MAKE_IRR_ID('p','t','c','l'),
//! Quake3 Model Scene Node ( has tag to link to )
ESNT_MD3_SCENE_NODE = MAKE_IRR_ID('m','d','3','_'),
//! Unknown scene node
ESNT_UNKNOWN = MAKE_IRR_ID('u','n','k','n')
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,36 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __E_TERRAIN_ELEMENTS_H__
#define __E_TERRAIN_ELEMENTS_H__
namespace irr
{
namespace scene
{
//! enumeration for patch sizes specifying the size of patches in the TerrainSceneNode
enum E_TERRAIN_PATCH_SIZE
{
//! patch size of 9, at most, use 4 levels of detail with this patch size.
ETPS_9 = 9,
//! patch size of 17, at most, use 5 levels of detail with this patch size.
ETPS_17 = 17,
//! patch size of 33, at most, use 6 levels of detail with this patch size.
ETPS_33 = 33,
//! patch size of 65, at most, use 7 levels of detail with this patch size.
ETPS_65 = 65,
//! patch size of 129, at most, use 8 levels of detail with this patch size.
ETPS_129 = 129
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,103 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_ANIMATED_MESH_H_INCLUDED__
#define __I_ANIMATED_MESH_H_INCLUDED__
#include "aabbox3d.h"
#include "IMesh.h"
namespace irr
{
namespace scene
{
enum E_ANIMATED_MESH_TYPE
{
//! Unknown animated mesh type.
EAMT_UNKNOWN = 0,
//! Quake 2 MD2 model file
EAMT_MD2,
//! Quake 3 MD3 model file
EAMT_MD3,
//! Maya .obj static model
EAMT_OBJ,
//! Quake 3 .bsp static Map
EAMT_BSP,
//! 3D Studio .3ds file
EAMT_3DS,
//! My3D Mesh, the file format by Zhuck Dimitry
EAMT_MY3D,
//! Pulsar LMTools .lmts file. This Irrlicht loader was
//! written by Jonas Petersen
EAMT_LMTS,
//! Cartography Shop .csm file. This loader was created by Saurav Mohapatra.
EAMT_CSM,
//! .oct file for Paul Nette's FSRad or from Murphy McCauley's
//! Blender .oct exporter. The oct file format contains 3D
//! geometry and lightmaps and can be loaded directly by Irrlicht
EAMT_OCT,
//! generic skinned mesh
EAMT_SKINNED
};
//! Interface for an animated mesh.
/** There are already simple implementations of this interface available so
you don't have to implement this interface on your own if you need to:
You might want to use irr::scene::SAnimatedMesh, irr::scene::SMesh,
irr::scene::SMeshBuffer etc. */
class IAnimatedMesh : public IMesh
{
public:
//! destructor
virtual ~IAnimatedMesh() { }
//! Gets the frame count of the animated mesh.
/** \return Returns the amount of frames. If the amount is 1,
it is a static, non animated mesh. */
virtual u32 getFrameCount() const = 0;
//! Returns the IMesh interface for a frame.
/** \param frame: Frame number as zero based index. The maximum
frame number is getFrameCount() - 1;
\param detailLevel: Level of detail. 0 is the lowest, 255 the
highest level of detail. Most meshes will ignore the detail level.
\param startFrameLoop: Because some animated meshes (.MD2) are
blended between 2 static frames, and maybe animated in a loop,
the startFrameLoop and the endFrameLoop have to be defined, to
prevent the animation to be blended between frames which are
outside of this loop.
If startFrameLoop and endFrameLoop are both -1, they are ignored.
\param endFrameLoop: see startFrameLoop.
\return Returns the animated mesh based on a detail level. */
virtual IMesh* getMesh(s32 frame, s32 detailLevel=255, s32 startFrameLoop=-1, s32 endFrameLoop=-1) = 0;
//! Returns the type of the animated mesh.
/** In most cases it is not neccessary to use this method.
This is useful for making a safe downcast. For example,
if getMeshType() returns EAMT_MD2 it's safe to cast the
IAnimatedMesh to IAnimatedMeshMD2.
\returns Type of the mesh. */
virtual E_ANIMATED_MESH_TYPE getMeshType() const
{
return EAMT_UNKNOWN;
}
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,79 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_ANIMATED_MESH_MD2_H_INCLUDED__
#define __I_ANIMATED_MESH_MD2_H_INCLUDED__
#include "IAnimatedMesh.h"
namespace irr
{
namespace scene
{
//! Types of standard md2 animations
enum EMD2_ANIMATION_TYPE
{
EMAT_STAND = 0,
EMAT_RUN,
EMAT_ATTACK,
EMAT_PAIN_A,
EMAT_PAIN_B,
EMAT_PAIN_C,
EMAT_JUMP,
EMAT_FLIP,
EMAT_SALUTE,
EMAT_FALLBACK,
EMAT_WAVE,
EMAT_POINT,
EMAT_CROUCH_STAND,
EMAT_CROUCH_WALK,
EMAT_CROUCH_ATTACK,
EMAT_CROUCH_PAIN,
EMAT_CROUCH_DEATH,
EMAT_DEATH_FALLBACK,
EMAT_DEATH_FALLFORWARD,
EMAT_DEATH_FALLBACKSLOW,
EMAT_BOOM,
//! Not an animation, but amount of animation types.
EMAT_COUNT
};
//! Interface for using some special functions of MD2 meshes
class IAnimatedMeshMD2 : public IAnimatedMesh
{
public:
// Get frame loop data for a default MD2 animation type.
//! \param l: The EMD2_ANIMATION_TYPE to get the frames for.
//! \param outBegin: The returned beginning frame for animation type specified.
//! \param outEnd: The returned ending frame for the animation type specified.
//! \param outFPS: The number of frames per second, this animation should be played at.
//! \return Returns the beginframe, endframe and frames per second for a default MD2 animation type.
virtual void getFrameLoop(EMD2_ANIMATION_TYPE l, s32& outBegin,
s32& outEnd, s32& outFPS) const = 0;
// Get frame loop data for a special MD2 animation type, identified by name.
//! \param name: Name of the animation.
//! \param outBegin: The returned beginning frame for animation type specified.
//! \param outEnd: The returned ending frame for the animation type specified.
//! \param outFPS: The number of frames per second, this animation should be played at.
//! \return Returns the beginframe, endframe and frames per second for a special MD2 animation type.
virtual bool getFrameLoop(const c8* name,
s32& outBegin, s32& outEnd, s32& outFPS) const = 0;
//! Returns amount of md2 animations in this file.
virtual s32 getAnimationCount() const = 0;
//! Returns name of md2 animation.
//! \param nr: Zero based index of animation.
virtual const c8* getAnimationName(s32 nr) const = 0;
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,258 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_ANIMATED_MESH_MD3_H_INCLUDED__
#define __I_ANIMATED_MESH_MD3_H_INCLUDED__
#include "IAnimatedMesh.h"
#include "IQ3Shader.h"
#include "quaternion.h"
namespace irr
{
namespace scene
{
enum eMD3Models
{
EMD3_HEAD = 0,
EMD3_UPPER,
EMD3_LOWER,
EMD3_WEAPON,
EMD3_NUMMODELS
};
// Animation list
enum EMD3_ANIMATION_TYPE
{
// Animations for both lower and upper parts of the player
EMD3_BOTH_DEATH_1 = 0,
EMD3_BOTH_DEAD_1,
EMD3_BOTH_DEATH_2,
EMD3_BOTH_DEAD_2,
EMD3_BOTH_DEATH_3,
EMD3_BOTH_DEAD_3,
// Animations for the upper part
EMD3_TORSO_GESTURE,
EMD3_TORSO_ATTACK_1,
EMD3_TORSO_ATTACK_2,
EMD3_TORSO_DROP,
EMD3_TORSO_RAISE,
EMD3_TORSO_STAND_1,
EMD3_TORSO_STAND_2,
// Animations for the lower part
EMD3_LEGS_WALK_CROUCH,
EMD3_LEGS_WALK,
EMD3_LEGS_RUN,
EMD3_LEGS_BACK,
EMD3_LEGS_SWIM,
EMD3_LEGS_JUMP_1,
EMD3_LEGS_LAND_1,
EMD3_LEGS_JUMP_2,
EMD3_LEGS_LAND_2,
EMD3_LEGS_IDLE,
EMD3_LEGS_IDLE_CROUCH,
EMD3_LEGS_TURN,
//! Not an animation, but amount of animation types.
EMD3_ANIMATION_COUNT
};
struct SMD3AnimationInfo
{
s32 first; // First frame
s32 num; // Last frame
s32 looping; // Looping frames
s32 fps; // Frames per second
};
// byte-align structures
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
# pragma pack( push, packing )
# pragma pack( 1 )
# define PACK_STRUCT
#elif defined( __GNUC__ )
# define PACK_STRUCT __attribute__((packed))
#else
# error compiler not supported
#endif
// this holds the header info of the MD3 file
struct SMD3Header
{
c8 headerID[4]; //id of file, always "IDP3"
s32 Version; //this is a version number, always 15
s8 fileName[68]; //sometimes left Blank... 65 chars, 32bit aligned == 68 chars
s32 numFrames; //number of KeyFrames
s32 numTags; //number of 'tags' per frame
s32 numMeshes; //number of meshes/skins
s32 numMaxSkins; //maximum number of unique skins used in md3 file
s32 headerSize; //always equal to the length of this header
s32 tagStart; //starting position of tag-structures
s32 tagEnd; //ending position of tag-structures/starting position of mesh-structures
s32 fileSize;
};
struct SMD3MeshHeader
{
c8 meshID[4]; //id, must be IDP3
c8 meshName[68]; //name of mesh 65 chars, 32 bit aligned == 68 chars
s32 numFrames; //number of meshframes in mesh
s32 numShader; //number of skins in mesh
s32 numVertices; //number of vertices
s32 numTriangles; //number of Triangles
s32 offset_triangles; //starting position of Triangle data, relative to start of Mesh_Header
s32 offset_shaders; //size of header
s32 offset_st; //starting position of texvector data, relative to start of Mesh_Header
s32 vertexStart; //starting position of vertex data,relative to start of Mesh_Header
s32 offset_end;
};
//! Compressed Vertex Data
struct SMD3Vertex
{
s16 position[3];
u8 normal[2];
};
//! Texure Coordinate
struct SMD3TexCoord
{
f32 u;
f32 v;
};
//! Triangle Index
struct SMD3Face
{
s32 Index[3];
};
// Default alignment
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
# pragma pack( pop, packing )
#endif
#undef PACK_STRUCT
//! Holding Frame Data for a Mesh
struct SMD3MeshBuffer : public IReferenceCounted
{
SMD3MeshHeader MeshHeader;
core::array < core::stringc > Shader;
core::array < s32 > Indices;
core::array < SMD3Vertex > Vertices;
core::array < SMD3TexCoord > Tex;
};
//! hold a tag info for connecting meshes
//! basically its an alternate way to describe a transformation
struct SMD3QuaterionTag
{
SMD3QuaterionTag() {}
SMD3QuaterionTag( const core::stringc& name )
: Name ( name ) {}
// construct from a matrix
SMD3QuaterionTag ( const core::stringc& name, const core::matrix4 &m )
{
Name = name;
position = m.getTranslation ();
rotation = m;
}
// set to matrix
void setto ( core::matrix4 &m )
{
rotation.getMatrix ( m );
m.setTranslation ( position );
}
// construct from a position and euler angles in degrees
SMD3QuaterionTag ( const core::vector3df &pos, const core::vector3df &angle )
{
position = pos;
rotation.set ( angle * core::DEGTORAD );
}
bool operator == ( const SMD3QuaterionTag &other ) const
{
return Name == other.Name;
}
core::stringc Name;
core::vector3df position;
core::quaternion rotation;
};
// holds a assoziative list of named quaternions
struct SMD3QuaterionTagList : public virtual IReferenceCounted
{
SMD3QuaterionTag* get ( const core::stringc& name )
{
SMD3QuaterionTag search ( name );
s32 index = Container.linear_search ( search );
if ( index >= 0 )
return &Container[index];
return 0;
}
u32 size () const
{
return Container.size();
}
SMD3QuaterionTag& operator[] (u32 index )
{
return Container[index];
}
core::array < SMD3QuaterionTag > Container;
};
//! Holding Frames Buffers and Tag Infos
struct SMD3Mesh: public IReferenceCounted
{
~SMD3Mesh()
{
for (u32 i=0; i<Buffer.size(); ++i)
Buffer[i]->drop();
};
SMD3Header MD3Header;
core::stringc Name;
core::array < SMD3MeshBuffer * > Buffer;
SMD3QuaterionTagList TagList;
};
//! Interface for using some special functions of MD3 meshes
class IAnimatedMeshMD3 : public IAnimatedMesh
{
public:
//! tune how many frames you want to render inbetween
virtual void setInterpolationShift ( u32 shift, u32 loopMode ) = 0;
virtual SMD3QuaterionTagList *getTagList(s32 frame, s32 detailLevel, s32 startFrameLoop, s32 endFrameLoop) = 0;
virtual SMD3Mesh * getOriginalMesh () = 0;
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,213 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_ANIMATED_MESH_SCENE_NODE_H_INCLUDED__
#define __I_ANIMATED_MESH_SCENE_NODE_H_INCLUDED__
#include "ISceneNode.h"
#include "IBoneSceneNode.h"
#include "IAnimatedMeshMD2.h"
#include "IAnimatedMeshMD3.h"
#include "IShadowVolumeSceneNode.h"
namespace irr
{
namespace scene
{
enum E_JOINT_UPDATE_ON_RENDER
{
// do nothing
EJUOR_NONE = 0,
// get joints positions from the mesh (for attached nodes, etc)
EJUOR_READ,
// control joint positions in the mesh (eg. ragdolls, or set the animation from animateJoints() )
EJUOR_CONTROL,
//! count of all available interpolation modes
EJUOR_COUNT
};
class IAnimatedMeshSceneNode;
//! Callback interface for catching events of ended animations.
/** Implement this interface and use
IAnimatedMeshSceneNode::setAnimationEndCallback to be able to
be notified if an animation playback has ended.
**/
class IAnimationEndCallBack : public virtual IReferenceCounted
{
public:
//! Will be called when the animation playback has ended.
//! See IAnimatedMeshSceneNode::setAnimationEndCallback for
//! more informations.
//! \param node: Node of which the animation has ended.
virtual void OnAnimationEnd(IAnimatedMeshSceneNode* node) = 0;
};
//! Scene node capable of displaying an animated mesh and its shadow.
/** The shadow is optional: If a shadow should be displayed too, just invoke
the IAnimatedMeshSceneNode::createShadowVolumeSceneNode().*/
class IAnimatedMeshSceneNode : public ISceneNode
{
public:
//! Constructor
IAnimatedMeshSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id,
const core::vector3df& position = core::vector3df(0,0,0),
const core::vector3df& rotation = core::vector3df(0,0,0),
const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f))
: ISceneNode(parent, mgr, id, position, rotation, scale) {}
//! Destructor
virtual ~IAnimatedMeshSceneNode() {}
//! Sets the current frame number.
//! From now on the animation is played from this frame.
//! \param frame: Number of the frame to let the animation be started from.
//! The frame number must be a valid frame number of the IMesh used by this
//! scene node. Set IAnimatedMesh::getMesh() for details.
virtual void setCurrentFrame(f32 frame) = 0;
//! Sets the frame numbers between the animation is looped.
//! The default is 0 - MaximalFrameCount of the mesh.
//! \param begin: Start frame number of the loop.
//! \param end: End frame number of the loop.
//! \return Returns true if successful, false if not.
virtual bool setFrameLoop(s32 begin, s32 end) = 0;
//! Sets the speed with witch the animation is played.
//! \param framesPerSecond: Frames per second played.
virtual void setAnimationSpeed(f32 framesPerSecond) = 0;
//! Creates shadow volume scene node as child of this node
//! and returns a pointer to it. The shadow can be rendered using the ZPass
//! or the zfail method. ZPass is a little bit faster because the shadow volume
//! creation is easier, but with this method there occur ugly looking artifacs
//! when the camera is inside the shadow volume. These error do not occur
//! with the ZFail method.
//! \param id: Id of the shadow scene node. This id can be used to identify
//! the node later.
//! \param zfailmethod: If set to true, the shadow will use the zfail method,
//! if not, zpass is used.
//! \param infinity: Value used by the shadow volume algorithm to scale the
//! shadow volume.
//! \return Returns pointer to the created shadow scene node.
//! This pointer should not be dropped. See IReferenceCounted::drop() for more information.
virtual IShadowVolumeSceneNode* addShadowVolumeSceneNode(s32 id=-1,
bool zfailmethod=true, f32 infinity=10000.0f) = 0;
//! Returns a pointer to a joint in the mesh (if the mesh is a bone based mesh)
//! With this method it is possible to attach scene nodes to joints
//! for example possible to attach a weapon to the left hand of an
//! animated model. This example shows how:
//! \code
//! ISceneNode* hand =
//! yourAnimatedMeshSceneNode->getJointNode("LeftHand");
//! hand->addChild(weaponSceneNode);
//! \endcode
//! Please note that the joint returned by this method may not exist
//! before this call and the joints in the node were created by it.
//! \param jointName: Name of the joint.
//! \return Returns a pointer to the scene node which represents the joint
//! with the specified name. Returns 0 if the contained mesh is not an
//! skinned mesh or the name of the joint could not be found.
virtual IBoneSceneNode* getJointNode(const c8* jointName)=0;
//! same as getJointNode(const c8* jointName), but based on id
virtual IBoneSceneNode* getJointNode(u32 jointID) = 0;
//! Redundant command, please use getJointNode (only for backwards compatibility)
virtual ISceneNode* getMS3DJointNode(const c8* jointName) = 0;
//! Redundant command, please use getJointNode (only for backwards compatibility)
virtual ISceneNode* getXJointNode(const c8* jointName) = 0;
//! Starts a default MD2 animation.
//! With this method it is easily possible to start a Run, Attack,
//! Die or whatever animation, if the mesh contained in this scene
//! node is an md2 mesh. Otherwise, nothing happens.
//! \param anim: An MD2 animation type, which should be played, for
//! example EMAT_STAND for the standing animation.
//! \return Returns true if successful, and false if not, for example
//! if the mesh in the scene node is not a md2 mesh.
virtual bool setMD2Animation(EMD2_ANIMATION_TYPE anim) = 0;
//! Starts a special MD2 animation.
//! With this method it is easily possible to start a Run, Attack,
//! Die or whatever animation, if the mesh contained in this scene
//! node is an md2 mesh. Otherwise, nothing happens. This method uses
//! a character string to identify the animation. If the animation is a
//! standard md2 animation, you might want to start this animation
//! with the EMD2_ANIMATION_TYPE enumeration instead.
//! \param animationName: Name of the animation which should be played.
//! \return Returns true if successful, and false if not, for example
//! if the mesh in the scene node is not an md2 mesh, or no animation
//! with this name could be found.
virtual bool setMD2Animation(const c8* animationName) = 0;
//! Returns the current displayed frame number.
virtual f32 getFrameNr() const = 0;
//! Returns the current start frame number.
virtual s32 getStartFrame() const = 0;
//! Returns the current end frame number.
virtual s32 getEndFrame() const = 0;
//! Sets looping mode which is on by default. If set to false,
//! animations will not be played looped.
virtual void setLoopMode(bool playAnimationLooped) = 0;
//! Sets a callback interface which will be called if an animation
//! playback has ended. Set this to 0 to disable the callback again.
//! Please note that this will only be called when in non looped mode,
//! see IAnimatedMeshSceneNode::setLoopMode().
virtual void setAnimationEndCallback(IAnimationEndCallBack* callback=0) = 0;
//! Sets if the scene node should not copy the materials of the mesh but use them in a read only style.
/* In this way it is possible to change the materials a mesh causing all mesh scene nodes
referencing this mesh to change too. */
virtual void setReadOnlyMaterials(bool readonly) = 0;
//! Returns if the scene node should not copy the materials of the mesh but use them in a read only style
virtual bool isReadOnlyMaterials() const = 0;
//! Sets a new mesh
virtual void setMesh(IAnimatedMesh* mesh) = 0;
//! Returns the current mesh
virtual IAnimatedMesh* getMesh(void) = 0;
//! returns the absolute transformation for a special MD3 Tag if the mesh is a md3 mesh,
//! or the absolutetransformation if it's a normal scenenode
virtual const SMD3QuaterionTag& getMD3TagTransformation( const core::stringc & tagname) = 0;
//! Set how the joints should be updated on render
//! 0-do nothing
//! 1-get joints positions from the mesh (for attached nodes, etc)
//! 2-control joint positions in the mesh (eg. ragdolls, or set the animation from animateJoints() )
virtual void setJointMode(E_JOINT_UPDATE_ON_RENDER mode)=0;
//! Sets the transition time in seconds (note: This needs to enable joints, and setJointmode maybe set to 2)
//! you must call animateJoints(), or the mesh will not ani\mate
virtual void setTransitionTime(f32 Time) =0;
//! animates the joints in the mesh based on the current frame (also takes in to account transitions)
virtual void animateJoints(bool CalculateAbsolutePositions=true) = 0;
//! render mesh ignoring it's transformation. Used with ragdolls. (culling is unaffected)
virtual void setRenderFromIdentity( bool On )=0;
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,71 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_ATTRIBUTE_EXCHANGING_OBJECT_H_INCLUDED__
#define __I_ATTRIBUTE_EXCHANGING_OBJECT_H_INCLUDED__
#include "IReferenceCounted.h"
namespace irr
{
namespace io
{
class IAttributes;
//! Enumation flags passed through SAttributeReadWriteOptions to the IAttributeExchangingObject object
enum E_ATTRIBUTE_READ_WRITE_FLAGS
{
//! Serialization/Deserializion is done for an xml file
EARWF_FOR_FILE = 0x00000001,
//! Serialization/Deserializion is done for an editor property box
EARWF_FOR_EDITOR = 0x00000002,
//! When writing filenames, relative paths should be used
EARWF_USE_RELATIVE_PATHS = 0x00000004
};
//! struct holding data describing options
struct SAttributeReadWriteOptions
{
//! constructor
SAttributeReadWriteOptions()
: Flags(0), Filename(0)
{
}
//! Combination of E_ATTRIBUTE_READ_WRITE_FLAGS or other, custom ones
s32 Flags;
//! optional filename
const c8* Filename;
};
//! An object which is able to serialize and deserialize its attributes into an attributes object
class IAttributeExchangingObject : public virtual IReferenceCounted
{
public:
//! Writes attributes of the object.
//! Implement this to expose the attributes of your scene node animator for
//! scripting languages, editors, debuggers or xml serialization purposes.
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const {}
//! Reads attributes of the object.
//! Implement this to set the attributes of your scene node animator for
//! scripting languages, editors, debuggers or xml deserialization purposes.
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) {}
};
} // end namespace io
} // end namespace irr
#endif

View File

@ -0,0 +1,753 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_ATTRIBUTES_H_INCLUDED__
#define __I_ATTRIBUTES_H_INCLUDED__
#include "IReferenceCounted.h"
#include "SColor.h"
#include "vector3d.h"
#include "vector2d.h"
#include "line2d.h"
#include "line3d.h"
#include "triangle3d.h"
#include "position2d.h"
#include "rect.h"
#include "matrix4.h"
#include "quaternion.h"
#include "plane3d.h"
#include "triangle3d.h"
#include "line2d.h"
#include "line3d.h"
#include "irrString.h"
#include "irrArray.h"
#include "IXMLReader.h"
namespace irr
{
namespace video
{
class ITexture;
} // end namespace video
namespace io
{
class IXMLWriter;
//! Types of attributes available for IAttributes
enum E_ATTRIBUTE_TYPE
{
// integer attribute
EAT_INT = 0,
// float attribute
EAT_FLOAT,
// string attribute
EAT_STRING,
// boolean attribute
EAT_BOOL,
// enumeration attribute
EAT_ENUM,
// color attribute
EAT_COLOR,
// floating point color attribute
EAT_COLORF,
// 3d vector attribute
EAT_VECTOR3D,
// 2d position attribute
EAT_POSITION2D,
// vector 2d
EAT_VECTOR2D,
// rectangle attribute
EAT_RECT,
// matrix attribute
EAT_MATRIX,
// quaternion attribute
EAT_QUATERNION,
// 3d bounding box
EAT_BBOX,
// plane
EAT_PLANE,
// 3d triangle
EAT_TRIANGLE3D,
// line 2d
EAT_LINE2D,
// line 3d
EAT_LINE3D,
// array of stringws attribute
EAT_STRINGWARRAY,
// array of float
EAT_FLOATARRAY,
// array of int
EAT_INTARRAY,
// binary data attribute
EAT_BINARY,
// texture reference attribute
EAT_TEXTURE,
// user pointer void*
EAT_USER_POINTER,
// known attribute type count
EAT_COUNT,
// unknown attribute
EAT_UNKNOWN
};
//! Provides a generic interface for attributes and their values and the possiblity to serialize them
class IAttributes : public virtual IReferenceCounted
{
public:
//! Returns amount of attributes in this collection of attributes.
virtual u32 getAttributeCount() const = 0;
//! Returns attribute name by index.
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
virtual const c8* getAttributeName(s32 index) = 0;
//! Returns the type of an attribute
//! \param attributeName: Name for the attribute
virtual E_ATTRIBUTE_TYPE getAttributeType(const c8* attributeName) = 0;
//! Returns attribute type by index.
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
virtual E_ATTRIBUTE_TYPE getAttributeType(s32 index) = 0;
//! Returns the type string of the attribute
//! \param attributeName: String for the attribute type
virtual const wchar_t* getAttributeTypeString(const c8* attributeName) = 0;
//! Returns the type string of the attribute by index.
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
virtual const wchar_t* getAttributeTypeString(s32 index) = 0;
//! Returns if an attribute with a name exists
virtual bool existsAttribute(const c8* attributeName) = 0;
//! Returns attribute index from name, -1 if not found
virtual s32 findAttribute(const c8* attributeName) = 0;
//! Removes all attributes
virtual void clear() = 0;
//! Reads attributes from a xml file.
//! \param readCurrentElementOnly: If set to true, reading only works if current element has the name 'attributes' or
//! the name specified using elementName.
//! \param elementName: The surrounding element name. If it is null, the default one, "attributes" will be taken.
//! If set to false, the first appearing list of attributes are read.
virtual bool read(io::IXMLReader* reader, bool readCurrentElementOnly=false, const wchar_t* elementName=0) = 0;
//! Write these attributes into a xml file
//! \param writer: The XML writer to write to
//! \param writeXMLHeader: Writes a header to the XML file, required if at the beginning of the file
//! \param elementName: The surrounding element name. If it is null, the default one, "attributes" will be taken.
virtual bool write(io::IXMLWriter* writer, bool writeXMLHeader=false, const wchar_t* elementName=0) = 0;
/*
Integer Attribute
*/
//! Adds an attribute as integer
virtual void addInt(const c8* attributeName, s32 value) = 0;
//! Sets an attribute as integer value
virtual void setAttribute(const c8* attributeName, s32 value) = 0;
//! Gets an attribute as integer value
//! \param attributeName: Name of the attribute to get.
//! \return Returns value of the attribute previously set by setAttribute()
virtual s32 getAttributeAsInt(const c8* attributeName) = 0;
//! Gets an attribute as integer value
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
virtual s32 getAttributeAsInt(s32 index) = 0;
//! Sets an attribute as integer value
virtual void setAttribute(s32 index, s32 value) = 0;
/*
Float Attribute
*/
//! Adds an attribute as float
virtual void addFloat(const c8* attributeName, f32 value) = 0;
//! Sets a attribute as float value
virtual void setAttribute(const c8* attributeName, f32 value) = 0;
//! Gets an attribute as float value
//! \param attributeName: Name of the attribute to get.
//! \return Returns value of the attribute previously set by setAttribute()
virtual f32 getAttributeAsFloat(const c8* attributeName) = 0;
//! Gets an attribute as float value
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
virtual f32 getAttributeAsFloat(s32 index) = 0;
//! Sets an attribute as float value
virtual void setAttribute(s32 index, f32 value) = 0;
/*
String Attribute
*/
//! Adds an attribute as string
virtual void addString(const c8* attributeName, const c8* value) = 0;
//! Sets an attribute value as string.
//! \param attributeName: Name for the attribute
//! \param value: Value for the attribute. Set this to 0 to delete the attribute
virtual void setAttribute(const c8* attributeName, const c8* value) = 0;
//! Gets an attribute as string.
//! \param attributeName: Name of the attribute to get.
//! \return Returns value of the attribute previously set by setAttribute()
//! or 0 if attribute is not set.
virtual core::stringc getAttributeAsString(const c8* attributeName) = 0;
//! Gets an attribute as string.
//! \param attributeName: Name of the attribute to get.
//! \param target: Buffer where the string is copied to.
virtual void getAttributeAsString(const c8* attributeName, c8* target) = 0;
//! Returns attribute value as string by index.
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
virtual core::stringc getAttributeAsString(s32 index) = 0;
//! Sets an attribute value as string.
//! \param attributeName: Name for the attribute
virtual void setAttribute(s32 index, const c8* value) = 0;
// wide strings
//! Adds an attribute as string
virtual void addString(const c8* attributeName, const wchar_t* value) = 0;
//! Sets an attribute value as string.
//! \param attributeName: Name for the attribute
//! \param value: Value for the attribute. Set this to 0 to delete the attribute
virtual void setAttribute(const c8* attributeName, const wchar_t* value) = 0;
//! Gets an attribute as string.
//! \param attributeName: Name of the attribute to get.
//! \return Returns value of the attribute previously set by setAttribute()
//! or 0 if attribute is not set.
virtual core::stringw getAttributeAsStringW(const c8* attributeName) = 0;
//! Gets an attribute as string.
//! \param attributeName: Name of the attribute to get.
//! \param target: Buffer where the string is copied to.
virtual void getAttributeAsStringW(const c8* attributeName, wchar_t* target) = 0;
//! Returns attribute value as string by index.
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
virtual core::stringw getAttributeAsStringW(s32 index) = 0;
//! Sets an attribute value as string.
//! \param attributeName: Name for the attribute
virtual void setAttribute(s32 index, const wchar_t* value) = 0;
/*
Binary Data Attribute
*/
//! Adds an attribute as binary data
virtual void addBinary(const c8* attributeName, void* data, s32 dataSizeInBytes) = 0;
//! Sets an attribute as binary data
virtual void setAttribute(const c8* attributeName, void* data, s32 dataSizeInBytes ) = 0;
//! Gets an attribute as binary data
//! \param attributeName: Name of the attribute to get.
virtual void getAttributeAsBinaryData(const c8* attributeName, void* outData, s32 maxSizeInBytes) = 0;
//! Gets an attribute as binary data
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
virtual void getAttributeAsBinaryData(s32 index, void* outData, s32 maxSizeInBytes) = 0;
//! Sets an attribute as binary data
virtual void setAttribute(s32 index, void* data, s32 dataSizeInBytes ) = 0;
/*
Array Attribute
*/
//! Adds an attribute as wide string array
virtual void addArray(const c8* attributeName, core::array<core::stringw> value) = 0;
//! Sets an attribute value as a wide string array.
//! \param attributeName: Name for the attribute
//! \param value: Value for the attribute. Set this to 0 to delete the attribute
virtual void setAttribute(const c8* attributeName, const core::array<core::stringw> value) = 0;
//! Gets an attribute as an array of wide strings.
//! \param attributeName: Name of the attribute to get.
//! \return Returns value of the attribute previously set by setAttribute()
//! or 0 if attribute is not set.
virtual core::array<core::stringw> getAttributeAsArray(const c8* attributeName) = 0;
//! Returns attribute value as an array of wide strings by index.
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
virtual core::array<core::stringw> getAttributeAsArray(s32 index) = 0;
//! Sets an attribute as an array of wide strings
virtual void setAttribute(s32 index, core::array<core::stringw> value) = 0;
/*
Bool Attribute
*/
//! Adds an attribute as bool
virtual void addBool(const c8* attributeName, bool value) = 0;
//! Sets an attribute as boolean value
virtual void setAttribute(const c8* attributeName, bool value) = 0;
//! Gets an attribute as boolean value
//! \param attributeName: Name of the attribute to get.
//! \return Returns value of the attribute previously set by setAttribute()
virtual bool getAttributeAsBool(const c8* attributeName) = 0;
//! Gets an attribute as boolean value
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
virtual bool getAttributeAsBool(s32 index) = 0;
//! Sets an attribute as boolean value
virtual void setAttribute(s32 index, bool value) = 0;
/*
Enumeration Attribute
*/
//! Adds an attribute as enum
virtual void addEnum(const c8* attributeName, const c8* enumValue, const c8* const* enumerationLiterals) = 0;
//! Adds an attribute as enum
virtual void addEnum(const c8* attributeName, s32 enumValue, const c8* const* enumerationLiterals) = 0;
//! Sets an attribute as enumeration
virtual void setAttribute(const c8* attributeName, const c8* enumValue, const c8* const* enumerationLiterals) = 0;
//! Gets an attribute as enumeration
//! \param attributeName: Name of the attribute to get.
//! \return Returns value of the attribute previously set by setAttribute()
virtual const c8* getAttributeAsEnumeration(const c8* attributeName) = 0;
//! Gets an attribute as enumeration
//! \param attributeName: Name of the attribute to get.
//! \param enumerationLiteralsToUse: Use these enumeration literals to get the index value instead of the set ones.
//! This is useful when the attribute list maybe was read from an xml file, and only contains the enumeration string, but
//! no information about its index.
//! \return Returns value of the attribute previously set by setAttribute()
virtual s32 getAttributeAsEnumeration(const c8* attributeName, const c8* const* enumerationLiteralsToUse) = 0;
//! Gets an attribute as enumeration
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
virtual s32 getAttributeAsEnumeration(s32 index, const c8* const* enumerationLiteralsToUse) = 0;
//! Gets an attribute as enumeration
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
virtual const c8* getAttributeAsEnumeration(s32 index) = 0;
//! Gets the list of enumeration literals of an enumeration attribute
//! \param attributeName: Name of the attribute to get.
virtual void getAttributeEnumerationLiteralsOfEnumeration(const c8* attributeName, core::array<core::stringc>& outLiterals) = 0;
//! Gets the list of enumeration literals of an enumeration attribute
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
virtual void getAttributeEnumerationLiteralsOfEnumeration(s32 index, core::array<core::stringc>& outLiterals) = 0;
//! Sets an attribute as enumeration
virtual void setAttribute(s32 index, const c8* enumValue, const c8* const* enumerationLiterals) = 0;
/*
SColor Attribute
*/
//! Adds an attribute as color
virtual void addColor(const c8* attributeName, video::SColor value) = 0;
//! Sets a attribute as color
virtual void setAttribute(const c8* attributeName, video::SColor color) = 0;
//! Gets an attribute as color
//! \param attributeName: Name of the attribute to get.
//! \return Returns value of the attribute previously set by setAttribute()
virtual video::SColor getAttributeAsColor(const c8* attributeName) = 0;
//! Gets an attribute as color
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
virtual video::SColor getAttributeAsColor(s32 index) = 0;
//! Sets an attribute as color
virtual void setAttribute(s32 index, video::SColor color) = 0;
/*
SColorf Attribute
*/
//! Adds an attribute as floating point color
virtual void addColorf(const c8* attributeName, video::SColorf value) = 0;
//! Sets a attribute as floating point color
virtual void setAttribute(const c8* attributeName, video::SColorf color) = 0;
//! Gets an attribute as floating point color
//! \param attributeName: Name of the attribute to get.
//! \return Returns value of the attribute previously set by setAttribute()
virtual video::SColorf getAttributeAsColorf(const c8* attributeName) = 0;
//! Gets an attribute as floating point color
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
virtual video::SColorf getAttributeAsColorf(s32 index) = 0;
//! Sets an attribute as floating point color
virtual void setAttribute(s32 index, video::SColorf color) = 0;
/*
Vector3d Attribute
*/
//! Adds an attribute as 3d vector
virtual void addVector3d(const c8* attributeName, core::vector3df value) = 0;
//! Sets a attribute as 3d vector
virtual void setAttribute(const c8* attributeName, core::vector3df v) = 0;
//! Gets an attribute as 3d vector
//! \param attributeName: Name of the attribute to get.
//! \return Returns value of the attribute previously set by setAttribute()
virtual core::vector3df getAttributeAsVector3d(const c8* attributeName) = 0;
//! Gets an attribute as 3d vector
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
virtual core::vector3df getAttributeAsVector3d(s32 index) = 0;
//! Sets an attribute as vector
virtual void setAttribute(s32 index, core::vector3df v) = 0;
/*
Position2d Attribute
*/
//! Adds an attribute as 2d position
virtual void addPosition2d(const c8* attributeName, core::position2di value) = 0;
//! Sets a attribute as 2d position
virtual void setAttribute(const c8* attributeName, core::position2di v) = 0;
//! Gets an attribute as position
//! \param attributeName: Name of the attribute to get.
//! \return Returns value of the attribute previously set by setAttribute()
virtual core::position2di getAttributeAsPosition2d(const c8* attributeName) = 0;
//! Gets an attribute as position
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
virtual core::position2di getAttributeAsPosition2d(s32 index) = 0;
//! Sets an attribute as 2d position
virtual void setAttribute(s32 index, core::position2di v) = 0;
/*
Rectangle Attribute
*/
//! Adds an attribute as rectangle
virtual void addRect(const c8* attributeName, core::rect<s32> value) = 0;
//! Sets an attribute as rectangle
virtual void setAttribute(const c8* attributeName, core::rect<s32> v) = 0;
//! Gets an attribute as rectangle
//! \param attributeName: Name of the attribute to get.
//! \return Returns value of the attribute previously set by setAttribute()
virtual core::rect<s32> getAttributeAsRect(const c8* attributeName) = 0;
//! Gets an attribute as rectangle
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
virtual core::rect<s32> getAttributeAsRect(s32 index) = 0;
//! Sets an attribute as rectangle
virtual void setAttribute(s32 index, core::rect<s32> v) = 0;
/*
matrix attribute
*/
//! Adds an attribute as matrix
virtual void addMatrix(const c8* attributeName, const core::matrix4& v) = 0;
//! Sets an attribute as matrix
virtual void setAttribute(const c8* attributeName, const core::matrix4& v) = 0;
//! Gets an attribute as a matrix4
//! \param attributeName: Name of the attribute to get.
//! \return Returns value of the attribute previously set by setAttribute()
virtual core::matrix4 getAttributeAsMatrix(const c8* attributeName) = 0;
//! Gets an attribute as matrix
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
virtual core::matrix4 getAttributeAsMatrix(s32 index) = 0;
//! Sets an attribute as matrix
virtual void setAttribute(s32 index, const core::matrix4& v) = 0;
/*
quaternion attribute
*/
//! Adds an attribute as quaternion
virtual void addQuaternion(const c8* attributeName, core::quaternion v) = 0;
//! Sets an attribute as quaternion
virtual void setAttribute(const c8* attributeName, core::quaternion v) = 0;
//! Gets an attribute as a quaternion
//! \param attributeName: Name of the attribute to get.
//! \return Returns value of the attribute previously set by setAttribute()
virtual core::quaternion getAttributeAsQuaternion(const c8* attributeName) = 0;
//! Gets an attribute as quaternion
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
virtual core::quaternion getAttributeAsQuaternion(s32 index) = 0;
//! Sets an attribute as quaternion
virtual void setAttribute(s32 index, core::quaternion v) = 0;
/*
3d bounding box
*/
//! Adds an attribute as axis aligned bounding box
virtual void addBox3d(const c8* attributeName, core::aabbox3df v) = 0;
//! Sets an attribute as axis aligned bounding box
virtual void setAttribute(const c8* attributeName, core::aabbox3df v) = 0;
//! Gets an attribute as a axis aligned bounding box
//! \param attributeName: Name of the attribute to get.
//! \return Returns value of the attribute previously set by setAttribute()
virtual core::aabbox3df getAttributeAsBox3d(const c8* attributeName) = 0;
//! Gets an attribute as axis aligned bounding box
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
virtual core::aabbox3df getAttributeAsBox3d(s32 index) = 0;
//! Sets an attribute as axis aligned bounding box
virtual void setAttribute(s32 index, core::aabbox3df v) = 0;
/*
plane
*/
//! Adds an attribute as 3d plane
virtual void addPlane3d(const c8* attributeName, core::plane3df v) = 0;
//! Sets an attribute as 3d plane
virtual void setAttribute(const c8* attributeName, core::plane3df v) = 0;
//! Gets an attribute as a 3d plane
//! \param attributeName: Name of the attribute to get.
//! \return Returns value of the attribute previously set by setAttribute()
virtual core::plane3df getAttributeAsPlane3d(const c8* attributeName) = 0;
//! Gets an attribute as 3d plane
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
virtual core::plane3df getAttributeAsPlane3d(s32 index) = 0;
//! Sets an attribute as 3d plane
virtual void setAttribute(s32 index, core::plane3df v) = 0;
/*
3d triangle
*/
//! Adds an attribute as 3d triangle
virtual void addTriangle3d(const c8* attributeName, core::triangle3df v) = 0;
//! Sets an attribute as 3d trianle
virtual void setAttribute(const c8* attributeName, core::triangle3df v) = 0;
//! Gets an attribute as a 3d triangle
//! \param attributeName: Name of the attribute to get.
//! \return Returns value of the attribute previously set by setAttribute()
virtual core::triangle3df getAttributeAsTriangle3d(const c8* attributeName) = 0;
//! Gets an attribute as 3d triangle
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
virtual core::triangle3df getAttributeAsTriangle3d(s32 index) = 0;
//! Sets an attribute as 3d triangle
virtual void setAttribute(s32 index, core::triangle3df v) = 0;
/*
line 2d
*/
//! Adds an attribute as a 2d line
virtual void addLine2d(const c8* attributeName, core::line2df v) = 0;
//! Sets an attribute as a 2d line
virtual void setAttribute(const c8* attributeName, core::line2df v) = 0;
//! Gets an attribute as a 2d line
//! \param attributeName: Name of the attribute to get.
//! \return Returns value of the attribute previously set by setAttribute()
virtual core::line2df getAttributeAsLine2d(const c8* attributeName) = 0;
//! Gets an attribute as a 2d line
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
virtual core::line2df getAttributeAsLine2d(s32 index) = 0;
//! Sets an attribute as a 2d line
virtual void setAttribute(s32 index, core::line2df v) = 0;
/*
line 3d
*/
//! Adds an attribute as a 3d line
virtual void addLine3d(const c8* attributeName, core::line3df v) = 0;
//! Sets an attribute as a 3d line
virtual void setAttribute(const c8* attributeName, core::line3df v) = 0;
//! Gets an attribute as a 3d line
//! \param attributeName: Name of the attribute to get.
//! \return Returns value of the attribute previously set by setAttribute()
virtual core::line3df getAttributeAsLine3d(const c8* attributeName) = 0;
//! Gets an attribute as a 3d line
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
virtual core::line3df getAttributeAsLine3d(s32 index) = 0;
//! Sets an attribute as a 3d line
virtual void setAttribute(s32 index, core::line3df v) = 0;
/*
Texture Attribute
*/
//! Adds an attribute as texture reference
virtual void addTexture(const c8* attributeName, video::ITexture* texture) = 0;
//! Sets an attribute as texture reference
virtual void setAttribute(const c8* attributeName, video::ITexture* texture ) = 0;
//! Gets an attribute as texture reference
//! \param attributeName: Name of the attribute to get.
virtual video::ITexture* getAttributeAsTexture(const c8* attributeName) = 0;
//! Gets an attribute as texture reference
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
virtual video::ITexture* getAttributeAsTexture(s32 index) = 0;
//! Sets an attribute as texture reference
virtual void setAttribute(s32 index, video::ITexture* texture) = 0;
/*
User Pointer Attribute
*/
//! Adds an attribute as user pointner
virtual void addUserPointer(const c8* attributeName, void* userPointer) = 0;
//! Sets an attribute as user pointer
virtual void setAttribute(const c8* attributeName, void* userPointer) = 0;
//! Gets an attribute as user pointer
//! \param attributeName: Name of the attribute to get.
virtual void* getAttributeAsUserPointer(const c8* attributeName) = 0;
//! Gets an attribute as user pointer
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
virtual void* getAttributeAsUserPointer(s32 index) = 0;
//! Sets an attribute as user pointer
virtual void setAttribute(s32 index, void* userPointer) = 0;
};
} // end namespace io
} // end namespace irr
#endif

View File

@ -0,0 +1,56 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_BILLBOARD_SCENE_NODE_H_INCLUDED__
#define __I_BILLBOARD_SCENE_NODE_H_INCLUDED__
#include "ISceneNode.h"
namespace irr
{
namespace scene
{
//! A billboard scene node.
/** A billboard is like a 3d sprite: A 2d element,
which always looks to the camera. It is usually used for explosions, fire,
lensflares, particles and things like that.
*/
class IBillboardSceneNode : public ISceneNode
{
public:
//! constructor
IBillboardSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id,
const core::vector3df& position = core::vector3df(0,0,0))
: ISceneNode(parent, mgr, id, position) {}
//! Sets the size of the billboard.
virtual void setSize(const core::dimension2d<f32>& size) = 0;
//! Returns the size of the billboard.
virtual const core::dimension2d<f32>& getSize() const = 0;
//! Set the color of all vertices of the billboard
//! \param overallColor: the color to set
virtual void setColor(const video::SColor & overallColor) = 0;
//! Set the color of the top and bottom vertices of the billboard
//! \param topColor: the color to set the top vertices
//! \param bottomColor: the color to set the bottom vertices
virtual void setColor(const video::SColor & topColor, const video::SColor & bottomColor) = 0;
//! Gets the color of the top and bottom vertices of the billboard
//! \param topColor: stores the color of the top vertices
//! \param bottomColor: stores the color of the bottom vertices
virtual void getColor(video::SColor & topColor, video::SColor & bottomColor) const = 0;
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,103 @@
#ifndef __I_BONE_SCENE_NODE_H_INCLUDED__
#define __I_BONE_SCENE_NODE_H_INCLUDED__
// Used with ISkinnedMesh and IAnimatedMeshSceneNode, for boned meshes
#include "ISceneNode.h"
namespace irr
{
namespace scene
{
//! Enumeration for different bone animation modes
enum E_BONE_ANIMATION_MODE
{
//! The bone is usually animated, unless it's parent is not animated
EBAM_AUTOMATIC=0,
//! The bone is animated by the skin, if it's parent is not animated
//! then animation will resume from this bone onward
EBAM_ANIMATED,
//! The bone is not animated by the skin
EBAM_UNANIMATED,
//! Not an animation mode, just here to count the available modes
EBAM_COUNT
};
enum E_BONE_SKINNING_SPACE
{
//! local skinning, standard
EBSS_LOCAL=0,
//! global skinning
EBSS_GLOBAL,
EBSS_COUNT
};
//! Names for bone animation modes
const c8* const BoneAnimationModeNames[] =
{
"automatic",
"animated",
"unanimated",
0,
};
class IBoneSceneNode : public ISceneNode
{
public:
IBoneSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id=-1) :
ISceneNode(parent, mgr, id),positionHint(-1),scaleHint(-1),rotationHint(-1) { }
//! Returns the name of the bone
virtual const c8* getBoneName() const = 0;
//! Returns the index of the bone
virtual u32 getBoneIndex() const = 0;
//! Sets the animation mode of the bone. Returns true if successful. (Unused)
virtual bool setAnimationMode(E_BONE_ANIMATION_MODE mode) = 0;
//! Gets the current animation mode of the bone
virtual E_BONE_ANIMATION_MODE getAnimationMode() const = 0;
//! returns the axis aligned bounding box of this node
virtual const core::aabbox3d<f32>& getBoundingBox() const = 0;
//! Returns the relative transformation of the scene node.
//virtual core::matrix4 getRelativeTransformation() const = 0;
virtual void OnAnimate(u32 timeMs) =0;
//! Does nothing as bones are not visible
virtual void render() { }
//! How the relative transformation of the bone is used
virtual void setSkinningSpace( E_BONE_SKINNING_SPACE space ) =0;
//! How the relative transformation of the bone is used
virtual E_BONE_SKINNING_SPACE getSkinningSpace() =0;
//! updates the absolute position based on the relative and the parents position
virtual void updateAbsolutePositionOfAllChildren()=0;
s32 positionHint;
s32 scaleHint;
s32 rotationHint;
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,148 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_CAMERA_SCENE_NODE_H_INCLUDED__
#define __I_CAMERA_SCENE_NODE_H_INCLUDED__
#include "ISceneNode.h"
#include "IEventReceiver.h"
namespace irr
{
namespace scene
{
struct SViewFrustum;
//! Scene Node which is a (controlable) camera.
/** The whole scene will be
rendered from the cameras point of view. Because the ICameraScenNode
is a SceneNode, it can be attached to any other scene node, and will
follow its parents movement, rotation and so on.
*/
class ICameraSceneNode : public ISceneNode, public IEventReceiver
{
public:
//! Constructor
ICameraSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id,
const core::vector3df& position = core::vector3df(0,0,0),
const core::vector3df& rotation = core::vector3df(0,0,0),
const core::vector3df& scale = core::vector3df(1.0f,1.0f,1.0f))
: ISceneNode(parent, mgr, id, position, rotation, scale), IsOrthogonal(false) {}
//! Destructor
virtual ~ICameraSceneNode() {}
//! Sets the projection matrix of the camera.
/** The core::matrix4 class has some methods
to build a projection matrix. e.g: core::matrix4::buildProjectionMatrixPerspectiveFovLH.
Note that the matrix will only stay as set by this method until one of
the following Methods are called: setNearValue, setFarValue, setAspectRatio, setFOV.
\param projection: The new projection matrix of the camera. */
virtual void setProjectionMatrix(const core::matrix4& projection) = 0;
//! Gets the current projection matrix of the camera.
/** \return Returns the current projection matrix of the camera. */
virtual const core::matrix4& getProjectionMatrix() const = 0;
//! Gets the current view matrix of the camera.
/** \return Returns the current view matrix of the camera. */
virtual const core::matrix4& getViewMatrix() const = 0;
//! It is possible to send mouse and key events to the camera.
/** Most cameras
may ignore this input, but camera scene nodes which are created for
example with ISceneManager::addMayaCameraSceneNode or
ISceneManager::addMeshViewerCameraSceneNode, may want to get this input
for changing their position, look at target or whatever. */
virtual bool OnEvent(const SEvent& event) = 0;
//! Sets the look at target of the camera
/** \param pos: Look at target of the camera. */
virtual void setTarget(const core::vector3df& pos) = 0;
//! Gets the current look at target of the camera
/** \return Returns the current look at target of the camera */
virtual core::vector3df getTarget() const = 0;
//! Sets the up vector of the camera.
/** \param pos: New upvector of the camera. */
virtual void setUpVector(const core::vector3df& pos) = 0;
//! Gets the up vector of the camera.
/** \return Returns the up vector of the camera. */
virtual core::vector3df getUpVector() const = 0;
//! Gets the value of the near plane of the camera.
/** \return Returns the value of the near plane of the camera. */
virtual f32 getNearValue() const = 0;
//! Gets the value of the far plane of the camera.
/** \return Returns the value of the far plane of the camera. */
virtual f32 getFarValue() const = 0;
//! Gets the aspect ratio of the camera.
/** \return Returns the aspect ratio of the camera. */
virtual f32 getAspectRatio() const = 0;
//! Gets the field of view of the camera.
/** \return Returns the field of view of the camera in radiants. */
virtual f32 getFOV() const = 0;
//! Sets the value of the near clipping plane. (default: 1.0f)
/** \param zn: New z near value. */
virtual void setNearValue(f32 zn) = 0;
//! Sets the value of the far clipping plane (default: 2000.0f)
/** \param zf: New z far value. */
virtual void setFarValue(f32 zf) = 0;
//! Sets the aspect ratio (default: 4.0f / 3.0f)
/** \param aspect: New aspect ratio. */
virtual void setAspectRatio(f32 aspect) = 0;
//! Sets the field of view (Default: PI / 2.5f)
/** \param fovy: New field of view in radiants. */
virtual void setFOV(f32 fovy) = 0;
//! Returns the view frustum.
/** Needed sometimes by bspTree or LOD render nodes.
\return Returns the current view frustum. */
virtual const SViewFrustum* getViewFrustum() const = 0;
//! Disables or enables the camera to get key or mouse inputs.
/** If this is set to true, the camera will respond to key inputs
otherwise not. */
virtual void setInputReceiverEnabled(bool enabled) = 0;
//! Returns if the input receiver of the camera is currently enabled.
virtual bool isInputReceiverEnabled() const = 0;
//! Returns if a camera is orthogonal.
/** This setting does not change anything of the view or projection matrix. However
it influences how collision detection and picking is done with this camera. */
virtual bool isOrthogonal() const
{
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
return IsOrthogonal;
}
//! Sets if this camera should return if it is orthogonal.
/** This setting does not change anything of the view or projection matrix. However
it influences how collision detection and picking is done with this camera. */
void setIsOrthogonal( bool orthogonal )
{
IsOrthogonal = orthogonal;
}
private:
bool IsOrthogonal;
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,81 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_CURSOR_CONTROL_H_INCLUDED__
#define __I_CURSOR_CONTROL_H_INCLUDED__
#include "IReferenceCounted.h"
#include "position2d.h"
#include "rect.h"
namespace irr
{
namespace gui
{
//! Interface to manipulate the mouse cursor.
class ICursorControl : public virtual IReferenceCounted
{
public:
//! Changes the visible state of the mouse cursor.
/** \param visible: The new visible state. If true, the cursor will be visible,
if false, it will be invisible. */
virtual void setVisible(bool visible) = 0;
//! Returns if the cursor is currently visible.
/** \return Returns true if the cursor is visible, false if not. */
virtual bool isVisible() const = 0;
/** Sets the new position of the cursor. The position must be
between (0.0f, 0.0f) and (1.0f, 1.0f), where (0.0f, 0.0f) is
the top left corner and (1.0f, 1.0f) is the bottom right corner of the
render window. */
//! \param pos: New position of the cursor.
virtual void setPosition(const core::position2d<f32> &pos) = 0;
/** Sets the new position of the cursor. The position must be
between (0.0f, 0.0f) and (1.0f, 1.0f), where (0.0f, 0.0f) is
the top left corner and (1.0f, 1.0f) is the bottom right corner of the
render window. */
//! \param x: New x-coord of the cursor.
//! \param y: New x-coord of the cursor.
virtual void setPosition(f32 x, f32 y) = 0;
//! Sets the new position of the cursor.
/** \param pos: New position of the cursor. The coordinates are pixel units. */
virtual void setPosition(const core::position2d<s32> &pos) = 0;
//! Sets the new position of the cursor.
/** \param x: New x-coord of the cursor. The coordinates are pixel units. */
/** \param y: New y-coord of the cursor. The coordinates are pixel units. */
virtual void setPosition(s32 x, s32 y) = 0;
//! Returns the current position of the mouse cursor.
/** \return Returns the current position of the cursor. The returned position
is the position of the mouse cursor in pixel units. */
virtual core::position2d<s32> getPosition() = 0;
//! Returns the current position of the mouse cursor.
/** \return Returns the current position of the cursor. The returned position
is a value between (0.0f, 0.0f) and (1.0f, 1.0f), where (0.0f, 0.0f) is
the top left corner and (1.0f, 1.0f) is the bottom right corner of the
render window. */
virtual core::position2d<f32> getRelativePosition() = 0;
//! Sets an absolute reference rect for setting and retrieving the cursor position.
/** If this rect is set, the cursor position is not being calculated relative to
the rendering window but to this rect. You can set the rect pointer to 0 to disable
this feature again. This feature is useful when rendering into parts of foreign windows
for example in an editor.
\param rect: A pointer to an reference rectangle or 0 to disable the reference rectangle.*/
virtual void setReferenceRect(core::rect<s32>* rect=0) = 0;
};
} // end namespace gui
} // end namespace irr
#endif

View File

@ -0,0 +1,42 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_DUMMY_TRANSFORMATION_SCENE_NODE_H_INCLUDED__
#define __I_DUMMY_TRANSFORMATION_SCENE_NODE_H_INCLUDED__
#include "ISceneNode.h"
namespace irr
{
namespace scene
{
//! Dummy scene node for adding additional transformations to the scene graph.
/** This scene node does not render itself, and does not respond to set/getPosition,
set/getRotation and set/getScale. Its just a simple scene node that takes a
matrix as relative transformation, making it possible to insert any transformation
anywhere into the scene graph.
This scene node is for example used by the IAnimatedMeshSceneNode for emulating
joint scene nodes when playing skeletal animations.
*/
class IDummyTransformationSceneNode : public ISceneNode
{
public:
//! constructor
IDummyTransformationSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id)
: ISceneNode(parent, mgr, id) {}
//! Returns a reference to the current relative transformation matrix.
//! This is the matrix, this scene node uses instead of scale, translation
//! and rotation.
virtual core::matrix4& getRelativeTransformationMatrix() = 0;
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,263 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_EVENT_RECEIVER_H_INCLUDED__
#define __I_EVENT_RECEIVER_H_INCLUDED__
#include "ILogger.h"
#include "position2d.h"
#include "Keycodes.h"
namespace irr
{
//! Enumeration for all event types there are.
enum EEVENT_TYPE
{
//! An event of the graphical user interface.
/** GUI events are created by the GUI environment or the GUI elements in response
to mouse or keyboard events. When a GUI element receives an event it will either
process it and return true, or pass the event to its parent. If an event is not absorbed
before it reaches the root element then it will then be passed to the user receiver. */
EET_GUI_EVENT = 0,
//! A mouse input event.
/** Mouse events are created by the device and passed to IrrlichtDevice::postEventFromUser
in response to mouse input received from the operating system.
Mouse events are first passed to the user receiver, then to the GUI environment (and possibly
many GUI elements), then finally the input receiving scene manager (and possibly the active
camera) */
EET_MOUSE_INPUT_EVENT,
//! A key input evant.
/** Keyboard events are also created by the device and passed to IrrlichtDevice::postEventFromUser.
They take the same path as mouse events. */
EET_KEY_INPUT_EVENT,
//! A log event
/** Log events are only passed to the user receiver if there is one. If they are absorbed by the
user receiver then no text will be sent to the console. */
EET_LOG_TEXT_EVENT,
//! A user event with user data. This is not used by Irrlicht and can be used
//! to send user specific data though the system.
EET_USER_EVENT
};
//! Enumeration for all mouse input events
enum EMOUSE_INPUT_EVENT
{
//! Left mouse button was pressed down.
EMIE_LMOUSE_PRESSED_DOWN = 0,
//! Right mouse button was pressed down.
EMIE_RMOUSE_PRESSED_DOWN,
//! Middle mouse button was pressed down.
EMIE_MMOUSE_PRESSED_DOWN,
//! Left mouse button was left up.
EMIE_LMOUSE_LEFT_UP,
//! Right mouse button was left up.
EMIE_RMOUSE_LEFT_UP,
//! Middle mouse button was left up.
EMIE_MMOUSE_LEFT_UP,
//! The mouse cursor changed its position.
EMIE_MOUSE_MOVED,
//! The mouse wheel was moved. Use Wheel value in event data to find out
//! in what direction and how fast.
EMIE_MOUSE_WHEEL,
//! No real event. Just for convenience to get number of events
EMIE_COUNT
};
namespace gui
{
class IGUIElement;
//! Enumeration for all events which are sendable by the gui system
enum EGUI_EVENT_TYPE
{
//! A gui element has lost its focus.
//! GUIEvent.Caller is losing the focus to GUIEvent.Element.
//! If the event is absorbed then the focus will not be changed.
EGET_ELEMENT_FOCUS_LOST = 0,
//! A gui element has got the focus.
//! If the event is absorbed then the focus will not be changed.
EGET_ELEMENT_FOCUSED,
//! The mouse cursor hovered over a gui element.
EGET_ELEMENT_HOVERED,
//! The mouse cursor left the hovered element.
EGET_ELEMENT_LEFT,
//! An element would like to close.
//! Windows and context menus use this event when they would like to close,
//! this can be cancelled by absorbing the event.
EGET_ELEMENT_CLOSED,
//! A button was clicked.
EGET_BUTTON_CLICKED,
//! A scrollbar has changed its position.
EGET_SCROLL_BAR_CHANGED,
//! A checkbox has changed its check state.
EGET_CHECKBOX_CHANGED,
//! A new item in a listbox was seleted.
EGET_LISTBOX_CHANGED,
//! An item in the listbox was selected, which was already selected.
EGET_LISTBOX_SELECTED_AGAIN,
//! A file has been selected in the file dialog
EGET_FILE_SELECTED,
//! A file open dialog has been closed without choosing a file
EGET_FILE_CHOOSE_DIALOG_CANCELLED,
//! 'Yes' was clicked on a messagebox
EGET_MESSAGEBOX_YES,
//! 'No' was clicked on a messagebox
EGET_MESSAGEBOX_NO,
//! 'OK' was clicked on a messagebox
EGET_MESSAGEBOX_OK,
//! 'Cancel' was clicked on a messagebox
EGET_MESSAGEBOX_CANCEL,
//! In an editbox was pressed 'ENTER'
EGET_EDITBOX_ENTER,
//! The tab was changed in an tab control
EGET_TAB_CHANGED,
//! A menu item was selected in a (context) menu
EGET_MENU_ITEM_SELECTED,
//! The selection in a combo box has been changed
EGET_COMBO_BOX_CHANGED,
//! The value of a spin box has changed
EGET_SPINBOX_CHANGED
};
} // end namespace gui
//! SEvents hold information about an event. See irr::IEventReceiver for details on event handling.
struct SEvent
{
struct SGUIEvent
{
//! IGUIElement who called the event
gui::IGUIElement* Caller;
//! If the event has something to do with another element, it will be held here.
gui::IGUIElement* Element;
//! Type of GUI Event
gui::EGUI_EVENT_TYPE EventType;
};
struct SMouseInput
{
//! X position of mouse cursor
s32 X;
//! Y position of mouse cursor
s32 Y;
//! mouse wheel delta, usually 1.0 or -1.0.
/** Only valid if event was EMIE_MOUSE_WHEEL */
f32 Wheel;
//! type of mouse event
EMOUSE_INPUT_EVENT Event;
};
struct SKeyInput
{
//! Character corresponding to the key (0, if not a character)
wchar_t Char;
//! Key which has been pressed or released
EKEY_CODE Key;
//! if not pressed, then the key was left up
bool PressedDown;
//! true if shift was also pressed
bool Shift;
//! true if ctrl was also pressed
bool Control;
};
struct SLogEvent
{
//! pointer to text which has been logged
const c8* Text;
//! log level in which the text has been logged
ELOG_LEVEL Level;
};
struct SUserEvent
{
//! Some user specified data as int
s32 UserData1;
//! Another user specified data as int
s32 UserData2;
//! Some user specified data as float
f32 UserData3;
};
EEVENT_TYPE EventType;
union
{
struct SGUIEvent GUIEvent;
struct SMouseInput MouseInput;
struct SKeyInput KeyInput;
struct SLogEvent LogEvent;
struct SUserEvent UserEvent;
};
};
//! Interface of an object which can receive events.
/** Many of the engine's classes inherit IEventReceiver so they are able to process events.
Events usually start at a postEventFromUser function and are passed down through a chain of
event receivers until OnEvent returns true.
See irr::EEVENT_TYPE for a description of where each type of event starts, and the path it takes
through the system. */
class IEventReceiver
{
public:
virtual ~IEventReceiver() {}
//! called if an event happened.
//! \return Returns true if the event was processed
virtual bool OnEvent(const SEvent& event) = 0;
};
} // end namespace irr
#endif

View File

@ -0,0 +1,58 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_FILE_LIST_H_INCLUDED__
#define __I_FILE_LIST_H_INCLUDED__
#include "IReferenceCounted.h"
namespace irr
{
namespace io
{
//! The Filelist lists all files in a directory.
class IFileList : public virtual IReferenceCounted
{
public:
//! destructor
virtual ~IFileList() {}
//! Returns the amount of files in the filelist.
//! \return
//! Returns the amount of files and directories in the file list.
virtual u32 getFileCount() const = 0;
//! Gets the name of a file in the list, based on an index.
//! The path is not included in this name. Use getFullFileName for this.
//! \param index is the zero based index of the file which name should
//! be returned. The index has to be smaller than the amount getFileCount() returns.
//! \return
//! Returns the file name of the file. Returns 0, if an error occured.
virtual const c8* getFileName(u32 index) const = 0;
//! Gets the full name of a file in the list, path included, based on an index.
//! \param index is the zero based index of the file which name should
//! be returned. The index has to be smaller than the amount getFileCount() returns.
//! \return
//! Returns the file name of the file. Returns 0, if an error occured.
virtual const c8* getFullFileName(u32 index) = 0;
//! Returns of the file is a directory
//! \param
//! index is the zero based index of the file which name should
//! be returned. The index has to be smaller than the amount getFileCount() returns.
//! \return
//! Returns true, if the file is a directory, and false, if it is not.
//! If an error occurs, the result is undefined.
virtual bool isDirectory(u32 index) const = 0;
};
} // end namespace irr
} // end namespace io
#endif

View File

@ -0,0 +1,197 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_FILE_SYSTEM_H_INCLUDED__
#define __I_FILE_SYSTEM_H_INCLUDED__
#include "IReferenceCounted.h"
#include "IXMLReader.h"
#include "irrString.h"
namespace irr
{
namespace video
{
class IVideoDriver;
} // end namespace video
namespace io
{
class IReadFile;
class IWriteFile;
class IFileList;
class IXMLWriter;
class IAttributes;
//! The FileSystem manages files and archives and provides access to them.
/**
It manages where files are, so that modules which
use the the IO do not need to know where every file is located. A file
could be in a .zip-Archive or as file on disk, using the IFileSystem
makes no difference to this.
*/
class IFileSystem : public virtual IReferenceCounted
{
public:
//! destructor
virtual ~IFileSystem() {}
//! Opens a file for read access.
/** \param filename: Name of file to open.
\return Returns a pointer to the created file interface.
The returned pointer should be dropped when no longer needed.
See IReferenceCounted::drop() for more information. */
virtual IReadFile* createAndOpenFile(const c8* filename) = 0;
//! Creates an IReadFile interface for accessing memory like a file.
/** This allows you to use a pointer to memory where an IReadFile is requested.
\param memory: A pointer to the start of the file in memory
\param len: The length of the memory in bytes
\param fileName: The name given to this file
\param deleteMemoryWhenDropped: True if the memory should be deleted
along with the IReadFile when it is dropped.
\return Returns a pointer to the created file interface.
The returned pointer should be dropped when no longer needed.
See IReferenceCounted::drop() for more information.
*/
virtual IReadFile* createMemoryReadFile(void* memory, s32 len, const c8* fileName, bool deleteMemoryWhenDropped=false) = 0;
//! Opens a file for write access.
/** \param filename: Name of file to open.
\param append: If the file already exist, all write operations are
appended to the file.
\return Returns a pointer to the created file interface. 0 is returned, if the
file could not created or opened for writing.
The returned pointer should be dropped when no longer needed.
See IReferenceCounted::drop() for more information. */
virtual IWriteFile* createAndWriteFile(const c8* filename, bool append=false) = 0;
//! Adds an zip archive to the file system.
/** After calling this, the Irrlicht Engine will search and open files directly from this archive too.
This is useful for hiding data from the end user, speeding up file access and making it possible to
access for example Quake3 .pk3 files, which are nothing different than .zip files.
\param filename: Filename of the zip archive to add to the file system.
\param ignoreCase: If set to true, files in the archive can be accessed without
writing all letters in the right case.
\param ignorePaths: If set to true, files in the added archive can be accessed
without its complete path.
\return Returns true if the archive was added successful, false if not. */
virtual bool addZipFileArchive(const c8* filename, bool ignoreCase = true, bool ignorePaths = true) = 0;
//! Adds an unzipped archive ( or basedirectory with subdirectories..) to the file system.
/** Useful for handling data which will be in a zip file
\param filename: Filename of the unzipped zip archive base directory to add to the file system.
\param ignoreCase: If set to true, files in the archive can be accessed without
writing all letters in the right case.
\param ignorePaths: If set to true, files in the added archive can be accessed
without its complete path.
\return Returns true if the archive was added successful, false if not. */
virtual bool addFolderFileArchive(const c8* filename, bool ignoreCase = true, bool ignorePaths = true) = 0;
//! Adds an pak archive to the file system.
/** After calling this, the Irrlicht Engine will search and open files directly from this archive too.
This is useful for hiding data from the end user, speeding up file access and making it possible to
access for example Quake2/KingPin/Hexen2 .pak files
\param filename: Filename of the pak archive to add to the file system.
\param ignoreCase: If set to true, files in the archive can be accessed without
writing all letters in the right case.
\param ignorePaths: If set to true, files in the added archive can be accessed
without its complete path.(should not use with Quake2 paks
\return Returns true if the archive was added successful, false if not. */
virtual bool addPakFileArchive(const c8* filename, bool ignoreCase = true, bool ignorePaths = true) = 0;
//! Returns the string of the current working directory.
virtual const c8* getWorkingDirectory() = 0;
//! Changes the current Working Directory.
/** \param newDirectory: A string specifying the new working directory.
The string is operating system dependent. Under Windows it has
the form "<drive>:\<directory>\<sudirectory>\<..>". An example would be: "C:\Windows\"
\return Returns true if successful, otherwise false. */
virtual bool changeWorkingDirectoryTo(const c8* newDirectory) = 0;
//! Converts a relative path to an absolute (unique) path, resolving symbolic links if required
virtual core::stringc getAbsolutePath(const core::stringc& filename) const = 0;
//! Returns the directory a file is located in.
/** \param filename: The file to get the directory from */
virtual core::stringc getFileDir(const core::stringc& filename) const = 0;
//! Creates a list of files and directories in the current working directory and returns it.
/** \return a Pointer to the created IFileList is returned. After the list has been used
it has to be deleted using its IFileList::drop() method.
See IReferenceCounted::drop() for more information. */
virtual IFileList* createFileList() const = 0;
//! Determines if a file exists and could be opened.
/** \param filename is the string identifying the file which should be tested for existence.
\return Returns true if file exists, and false if it does not exist or an error occured. */
virtual bool existFile(const c8* filename) const = 0;
//! Creates a XML Reader from a file which returns all parsed strings as wide characters (wchar_t*).
/** Use createXMLReaderUTF8() if you prefer char* instead of wchar_t*. See IIrrXMLReader for
more information on how to use the parser.
\return 0, if file could not be opened, otherwise a pointer to the created
IXMLReader is returned. After use, the reader
has to be deleted using its IXMLReader::drop() method.
See IReferenceCounted::drop() for more information. */
virtual IXMLReader* createXMLReader(const c8* filename) = 0;
//! Creates a XML Reader from a file which returns all parsed strings as wide characters (wchar_t*).
/** Use createXMLReaderUTF8() if you prefer char* instead of wchar_t*. See IIrrXMLReader for
more information on how to use the parser.
\return 0, if file could not be opened, otherwise a pointer to the created
IXMLReader is returned. After use, the reader
has to be deleted using its IXMLReader::drop() method.
See IReferenceCounted::drop() for more information. */
virtual IXMLReader* createXMLReader(IReadFile* file) = 0;
//! Creates a XML Reader from a file which returns all parsed strings as ASCII/UTF-8 characters (char*).
/** Use createXMLReader() if you prefer wchar_t* instead of char*. See IIrrXMLReader for
more information on how to use the parser.
\return 0, if file could not be opened, otherwise a pointer to the created
IXMLReader is returned. After use, the reader
has to be deleted using its IXMLReaderUTF8::drop() method.
See IReferenceCounted::drop() for more information. */
virtual IXMLReaderUTF8* createXMLReaderUTF8(const c8* filename) = 0;
//! Creates a XML Reader from a file which returns all parsed strings as ASCII/UTF-8 characters (char*).
/** Use createXMLReader() if you prefer wchar_t* instead of char*. See IIrrXMLReader for
more information on how to use the parser.
\return 0, if file could not be opened, otherwise a pointer to the created
IXMLReader is returned. After use, the reader
has to be deleted using its IXMLReaderUTF8::drop() method.
See IReferenceCounted::drop() for more information. */
virtual IXMLReaderUTF8* createXMLReaderUTF8(IReadFile* file) = 0;
//! Creates a XML Writer from a file.
/** \return 0, if file could not be opened, otherwise a pointer to the created
IXMLWriter is returned. After use, the reader
has to be deleted using its IXMLWriter::drop() method.
See IReferenceCounted::drop() for more information. */
virtual IXMLWriter* createXMLWriter(const c8* filename) = 0;
//! Creates a XML Writer from a file.
/** \return 0, if file could not be opened, otherwise a pointer to the created
IXMLWriter is returned. After use, the reader
has to be deleted using its IXMLWriter::drop() method.
See IReferenceCounted::drop() for more information. */
virtual IXMLWriter* createXMLWriter(IWriteFile* file) = 0;
//! Creates a new empty collection of attributes, usable for serialization and more.
/** \param driver: Video driver to be used to load textures when specified as attribute values.
Can be null to prevent automatic texture loading by attributes.
\return Returns a pointer to the created object.
If you no longer need the object, you should call IAttributes::drop().
See IReferenceCounted::drop() for more information. */
virtual IAttributes* createEmptyAttributes(video::IVideoDriver* driver=0) = 0;
};
} // end namespace io
} // end namespace irr
#endif

View File

@ -0,0 +1,274 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_GPU_PROGRAMMING_SERVICES_H_INCLUDED__
#define __I_GPU_PROGRAMMING_SERVICES_H_INCLUDED__
#include "IReferenceCounted.h"
#include "SMaterial.h"
namespace irr
{
namespace io
{
class IReadFile;
} // end namespace io
namespace video
{
class IVideoDriver;
class IShaderConstantSetCallBack;
//! Compile target enumeration for the addHighLevelShaderMaterial() method.
enum E_VERTEX_SHADER_TYPE
{
EVST_VS_1_1 = 0,
EVST_VS_2_0,
EVST_VS_2_a,
EVST_VS_3_0,
//! This is not a type, but a value indicating how much types there are.
EVST_COUNT
};
//! Names for all vertex shader types, each entry corresponds to a E_VERTEX_SHADER_TYPE entry.
const c8* const VERTEX_SHADER_TYPE_NAMES[] = {
"vs_1_1",
"vs_2_0",
"vs_2_a",
"vs_3_0",
0 };
//! Compile target enumeration for the addHighLevelShaderMaterial() method.
enum E_PIXEL_SHADER_TYPE
{
EPST_PS_1_1 = 0,
EPST_PS_1_2,
EPST_PS_1_3,
EPST_PS_1_4,
EPST_PS_2_0,
EPST_PS_2_a,
EPST_PS_2_b,
EPST_PS_3_0,
//! This is not a type, but a value indicating how much types there are.
EPST_COUNT
};
//! Names for all pixel shader types, each entry corresponds to a E_PIXEL_SHADER_TYPE entry.
const c8* const PIXEL_SHADER_TYPE_NAMES[] = {
"ps_1_1",
"ps_1_2",
"ps_1_3",
"ps_1_4",
"ps_2_0",
"ps_2_a",
"ps_2_b",
"ps_3_0",
0 };
//! Interface making it possible to create and use programs running on the GPU.
class IGPUProgrammingServices
{
public:
//! destructor
virtual ~IGPUProgrammingServices() {}
//! Adds a new material renderer to the VideoDriver, based on a high level shading
//! language. Currently only HLSL/D3D9 and GLSL/OpenGL is supported.
//! \param vertexShaderProgram: String containing the source of the vertex shader program.
//! This can be 0 if no vertex program shall be used.
//! \param vertexShaderEntryPointName: Name of the entry function of the vertexShaderProgram
//! \param vsCompileTarget: Vertex shader version where the high level shader shall be compiled to.
//! \param pixelShaderProgram: String containing the source of the pixel shader program.
//! This can be 0 if no pixel shader shall be used.
//! \param pixelShaderEntryPointName: Entry name of the function of the pixelShaderEntryPointName
//! \param psCompileTarget: Pixel shader version where the high level shader shall be compiled to.
//! \param callback: Pointer to an implementation of IShaderConstantSetCallBack in which you
//! can set the needed vertex and pixel shader program constants. Set this to 0 if you don't need this.
//! \param baseMaterial: Base material which renderstates will be used to shade the
//! material.
//! \param userData: a user data int. This int can be set to any value and will be set as parameter
//! in the callback method when calling OnSetConstants(). In this way it is easily possible to
//! use the same callback method for multiple materials and distinguish between them during the call.
//! \return Returns the number of the
//! material type which can be set in SMaterial::MaterialType to use the renderer.
//! -1 is returned if an error occured, e.g. if a vertex or pixel shader
//! program could not be compiled or a compile target is not reachable.
//! The error strings are then printed to the error log and
//! can be catched with a custom event receiver.
virtual s32 addHighLevelShaderMaterial(
const c8* vertexShaderProgram,
const c8* vertexShaderEntryPointName = "main",
E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1,
const c8* pixelShaderProgram = 0,
const c8* pixelShaderEntryPointName = "main",
E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1,
IShaderConstantSetCallBack* callback = 0,
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
s32 userData = 0 ) = 0;
//! Like IGPUProgrammingServices::addShaderMaterial(),
//! but tries to load the programs from files.
//! \param vertexShaderProgram: Text file containing the source of the vertex shader program.
//! Set to 0 if no shader shall be created.
//! \param vertexShaderEntryPointName: Name of the entry function of the vertexShaderProgram
//! \param vsCompileTarget: Vertex shader version where the high level shader shall be compiled to.
//! \param pixelShaderProgram: Text file containing the source of the pixel shader program. Set to
//! 0 if no shader shall be created.
//! \param vertexShaderEntryPointName: Name of the entry function of the vertexShaderProgram
//! \param vsCompileTarget: Vertex shader version where the high level shader shall be compiled to.
//! \param pixelShaderProgram: String containing the source of the pixel shader program.
//! This can be 0 if no pixel shader shall be used.
//! \param pixelShaderEntryPointName: Entry name of the function of the pixelShaderEntryPointName
//! \param psCompileTarget: Pixel shader version where the high level shader shall be compiled to.
//! \param callback: Pointer to an implementation of IShaderConstantSetCallBack in which you
//! can set the needed vertex and pixel shader program constants. Set this to 0 if you don't need this.
//! \param baseMaterial: Base material which renderstates will be used to shade the
//! material.
//! \param userData: a user data int. This int can be set to any value and will be set as parameter
//! in the callback method when calling OnSetConstants(). In this way it is easily possible to
//! use the same callback method for multiple materials and distinguish between them during the call.
//! \return Returns the number of the
//! material type which can be set in SMaterial::MaterialType to use the renderer.
//! -1 is returned if an error occured, e.g. if a vertex or pixel shader
//! program could not be compiled or a compile target is not reachable.
//! The error strings are then printed to the error log and
//! can be catched with a custom event receiver.
virtual s32 addHighLevelShaderMaterialFromFiles(
const c8* vertexShaderProgram,
const c8* vertexShaderEntryPointName = "main",
E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1,
const c8* pixelShaderProgram = 0,
const c8* pixelShaderEntryPointName = "main",
E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1,
IShaderConstantSetCallBack* callback = 0,
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
s32 userData = 0) = 0;
//! Like IGPUProgrammingServices::addShaderMaterial(),
//! but tries to load the programs from files.
//! \param vertexShaderProgram: Text file handle containing the source of the vertex shader program.
//! Set to 0 if no shader shall be created.
//! \param vertexShaderEntryPointName: Name of the entry function of the vertexShaderProgram
//! \param vsCompileTarget: Vertex shader version where the high level shader shall be compiled to.
//! \param pixelShaderProgram: Text file containing the source of the pixel shader program. Set to
//! \param pixelShaderProgram: Text file handle containing the source of the pixel shader program. Set to
//! 0 if no shader shall be created.
//! \param pixelShaderEntryPointName: Entry name of the function of the pixelShaderEntryPointName
//! \param psCompileTarget: Pixel shader version where the high level shader shall be compiled to.
//! \param callback: Pointer to an implementation of IShaderConstantSetCallBack in which you
//! can set the needed vertex and pixel shader program constants. Set this to 0 if you don't need this.
//! \param baseMaterial: Base material which renderstates will be used to shade the
//! material.
//! \param userData: a user data int. This int can be set to any value and will be set as parameter
//! in the callback method when calling OnSetConstants(). In this way it is easily possible to
//! use the same callback method for multiple materials and distinguish between them during the call.
//! \return Returns the number of the
//! material type which can be set in SMaterial::MaterialType to use the renderer.
//! -1 is returned if an error occured, e.g. if a vertex or pixel shader
//! program could not be compiled or a compile target is not reachable.
//! The error strings are then printed to the error log and
//! can be catched with a custom event receiver.
virtual s32 addHighLevelShaderMaterialFromFiles(
io::IReadFile* vertexShaderProgram,
const c8* vertexShaderEntryPointName = "main",
E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1,
io::IReadFile* pixelShaderProgram = 0,
const c8* pixelShaderEntryPointName = "main",
E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1,
IShaderConstantSetCallBack* callback = 0,
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
s32 userData = 0) = 0;
//! Adds a new material renderer to the VideoDriver, using pixel and/or
//! vertex shaders to render geometry.
//! Note that it is a good idea to call IVideoDriver::queryFeature() before to check
//! if the IVideoDriver supports the vertex and/or pixel shader version your are using.
//! The material is added to the VideoDriver like with IVideoDriver::addMaterialRenderer()
//! and can be used like it had been added with that method.
//! \param vertexShaderProgram: String containing the source of the vertex shader program. This can be
//! 0 if no vertex program shall be used.
//! For DX8 programs, the will always input registers look like this:
//! v0: position, v1: normal,
//! v2: color, v3: texture cooridnates, v4: texture coordinates 2 if available.
//! For DX9 programs, you can manually set the registers using the dcl_ statements.
//! \param pixelShaderProgram: String containing the source of the pixel shader program.
//! This can be 0 if you don't want to use a pixel shader.
//! \param callback: Pointer to an implementation of IShaderConstantSetCallBack in which you
//! can set the needed vertex and pixel shader program constants. Set this to 0 if you don't need this.
//! \param baseMaterial: Base material which renderstates will be used to shade the
//! material.
//! \param userData: a user data int. This int can be set to any value and will be set as parameter
//! in the callback method when calling OnSetConstants(). In this way it is easily possible to
//! use the same callback method for multiple materials and distinguish between them during the call.
//! \return Returns the number of the
//! material type which can be set in SMaterial::MaterialType to use the renderer.
//! -1 is returned if an error occured. -1 is returned for example if a vertex or pixel shader
//! program could not be compiled, the error strings are then printed out into the error log, and
//! can be catched with a custom event receiver.
virtual s32 addShaderMaterial(const c8* vertexShaderProgram = 0,
const c8* pixelShaderProgram = 0,
IShaderConstantSetCallBack* callback = 0,
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
s32 userData = 0) = 0;
//! Like IGPUProgrammingServices::addShaderMaterial(), but tries to load the
//! programs from files.
//! \param vertexShaderProgram: Text file containing the source of the vertex shader program.
//! Set to 0 if no shader shall be created.
//! \param pixelShaderProgram: Text file containing the source of the pixel shader program. Set to
//! 0 if no shader shall be created.
//! \param callback: Pointer to an IShaderConstantSetCallback object to which the
//! OnSetConstants function is called.
//! \param baseMaterial: baseMaterial
//! \param userData: a user data int. This int can be set to any value and will be set as parameter
//! in the callback method when calling OnSetConstants(). In this way it is easily possible to
//! use the same callback method for multiple materials and distinguish between them during the call.
//! \return Returns the number of the
//! material type which can be set in SMaterial::MaterialType to use the renderer.
//! -1 is returned if an error occured. -1 is returned for example if a vertex or pixel shader
//! program could not be compiled, the error strings are then printed out into the error log, and
//! can be catched with a custom event receiver.
virtual s32 addShaderMaterialFromFiles(io::IReadFile* vertexShaderProgram,
io::IReadFile* pixelShaderProgram,
IShaderConstantSetCallBack* callback = 0,
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
s32 userData = 0) = 0;
//! Like IGPUProgrammingServices::addShaderMaterial(), but tries to load the
//! programs from files.
//! \param vertexShaderProgramFileName: Text file name containing the source of the
//! vertex shader program.
//! Set to 0 if no shader shall be created.
//! \param pixelShaderProgramFileName: Text file name containing the source of the
//! pixel shader program. Set to 0 if no shader shall be created.
//! \param callback: Pointer to an IShaderConstantSetCallback object on which the
//! OnSetConstants function is called.
//! \param baseMaterial: baseMaterial
//! \param userData: a user data int. This int can be set to any value and will be set as parameter
//! in the callback method when calling OnSetConstants(). In this way it is easily possible to
//! use the same callback method for multiple materials and distinguish between them during the call.
//! \return Returns the number of the
//! material type which can be set in SMaterial::MaterialType to use the renderer.
//! -1 is returned if an error occured. -1 is returned for example if a vertex or pixel shader
//! program could not be compiled, the error strings are then printed out into the error log, and
//! can be catched with a custom event receiver.
virtual s32 addShaderMaterialFromFiles(const c8* vertexShaderProgramFileName,
const c8* pixelShaderProgramFileName,
IShaderConstantSetCallBack* callback = 0,
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
s32 userData = 0) = 0;
};
} // end namespace video
} // end namespace irr
#endif

View File

@ -0,0 +1,136 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_GUI_BUTTON_H_INCLUDED__
#define __I_GUI_BUTTON_H_INCLUDED__
#include "IGUIElement.h"
namespace irr
{
namespace video
{
class ITexture;
} // end namespace video
namespace gui
{
class IGUIFont;
class IGUISpriteBank;
enum EGUI_BUTTON_STATE
{
//! The button is not pressed
EGBS_BUTTON_UP=0,
//! The button is currently pressed down
EGBS_BUTTON_DOWN,
//! The mouse cursor is over the button
EGBS_BUTTON_MOUSE_OVER,
//! The mouse cursor is not over the button
EGBS_BUTTON_MOUSE_OFF,
//! The button has the focus
EGBS_BUTTON_FOCUSED,
//! The button doesn't have the focus
EGBS_BUTTON_NOT_FOCUSED,
//! not used, counts the number of enumerated items
EGBS_COUNT
};
//! Names for gui button state icons
const c8* const GUIButtonStateNames[] =
{
"buttonUp",
"buttonDown",
"buttonMouseOver",
"buttonMouseOff",
"buttonFocused",
"buttonNotFocused",
0,
0,
};
//! GUI Button interface.
class IGUIButton : public IGUIElement
{
public:
//! constructor
IGUIButton(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
: IGUIElement(EGUIET_BUTTON, environment, parent, id, rectangle) {}
//! destructor
virtual ~IGUIButton() {}
//! Sets another skin independent font.
/** If this is set to zero, the button uses the font of the skin.
\param font: New font to set. */
virtual void setOverrideFont(IGUIFont* font=0) = 0;
//! Sets an image which should be displayed on the button when it is in normal state.
/** \param image: Image to be displayed */
virtual void setImage(video::ITexture* image) = 0;
//! Sets a background image for the button when it is in normal state.
/** \param image: Texture containing the image to be displayed
\param pos: Position in the texture, where the image is located */
virtual void setImage(video::ITexture* image, const core::rect<s32>& pos) = 0;
//! Sets a background image for the button when it is in pressed state.
/** If no images is specified for the pressed state via
setPressedImage(), this image is also drawn in pressed state.
\param image: Image to be displayed */
virtual void setPressedImage(video::ITexture* image) = 0;
//! Sets an image which should be displayed on the button when it is in pressed state.
/** \param image: Texture containing the image to be displayed
\param pos: Position in the texture, where the image is located */
virtual void setPressedImage(video::ITexture* image, const core::rect<s32>& pos) = 0;
//! Sets the sprite bank used by the button
virtual void setSpriteBank(IGUISpriteBank* bank) = 0;
//! Sets the animated sprite for a specific button state
/** \param index: Number of the sprite within the sprite bank, use -1 for no sprite
\param state: State of the button to set the sprite for
\param index: The sprite number from the current sprite bank
\param color: The color of the sprite
\param loop: True if the animation should loop, false if not
*/
virtual void setSprite(EGUI_BUTTON_STATE state, s32 index,
video::SColor color=video::SColor(255,255,255,255), bool loop=false) = 0;
//! Sets if the button should behave like a push button.
/** Which means it can be in two states: Normal or Pressed. With a click on the button,
the user can change the state of the button. */
virtual void setIsPushButton(bool isPushButton) = 0;
//! Sets the pressed state of the button if this is a pushbutton
virtual void setPressed(bool pressed) = 0;
//! Returns if the button is currently pressed
virtual bool isPressed() const = 0;
//! Sets if the alpha channel should be used for drawing background images on the button (default is false)
virtual void setUseAlphaChannel(bool useAlphaChannel) = 0;
//! Returns if the alpha channel should be used for drawing background images on the button
virtual bool isAlphaChannelUsed() const = 0;
//! Returns whether the button is a push button
virtual bool isPushButton() const = 0;
//! Sets if the button should use the skin to draw its border and button face (default is true)
virtual void setDrawBorder(bool border) = 0;
//! Returns if the border and button face are being drawn using the skin
virtual bool isDrawingBorder() const = 0;
};
} // end namespace gui
} // end namespace irr
#endif

View File

@ -0,0 +1,38 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_GUI_CHECKBOX_H_INCLUDED__
#define __I_GUI_CHECKBOX_H_INCLUDED__
#include "IGUIElement.h"
namespace irr
{
namespace gui
{
//! GUI Check box interface.
class IGUICheckBox : public IGUIElement
{
public:
//! constructor
IGUICheckBox(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
: IGUIElement(EGUIET_CHECK_BOX, environment, parent, id, rectangle) {}
//! destructor
virtual ~IGUICheckBox() {}
//! Set if box is checked.
virtual void setChecked(bool checked) = 0;
//! Returns true if box is checked.
virtual bool isChecked() const = 0;
};
} // end namespace gui
} // end namespace irr
#endif

View File

@ -0,0 +1,33 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_GUI_COLOR_SELECT_DIALOG_H_INCLUDED__
#define __I_GUI_COLOR_SELECT_DIALOG_H_INCLUDED__
#include "IGUIElement.h"
namespace irr
{
namespace gui
{
//! Standard file chooser dialog.
class IGUIColorSelectDialog : public IGUIElement
{
public:
//! constructor
IGUIColorSelectDialog(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
: IGUIElement(EGUIET_COLOR_SELECT_DIALOG, environment, parent, id, rectangle) {}
//! destructor
virtual ~IGUIColorSelectDialog() {}
};
} // end namespace gui
} // end namespace irr
#endif

View File

@ -0,0 +1,54 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_GUI_COMBO_BOX_H_INCLUDED__
#define __I_GUI_COMBO_BOX_H_INCLUDED__
#include "IGUIElement.h"
namespace irr
{
namespace gui
{
//! Combobox widget
class IGUIComboBox : public IGUIElement
{
public:
//! constructor
IGUIComboBox(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
: IGUIElement(EGUIET_COMBO_BOX, environment, parent, id, rectangle) {}
//! destructor
virtual ~IGUIComboBox() {}
//! Returns amount of items in box
virtual u32 getItemCount() const = 0;
//! Returns string of an item. the idx may be a value from 0 to itemCount-1
virtual const wchar_t* getItem(u32 idx) const = 0;
//! Adds an item and returns the index of it
virtual u32 addItem(const wchar_t* text) = 0;
//! Removes an item from the combo box.
/** Warning. This will change the IDs of all following items */
virtual void removeItem(u32 id) = 0;
//! Deletes all items in the combo box
virtual void clear() = 0;
//! Returns id of selected item. returns -1 if no item is selected.
virtual s32 getSelected() const = 0;
//! Sets the selected item. Set this to -1 if no item should be selected
virtual void setSelected(s32 id) = 0;
};
} // end namespace gui
} // end namespace irr
#endif

View File

@ -0,0 +1,108 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_GUI_CONTEXT_MENU_H_INCLUDED__
#define __I_GUI_CONTEXT_MENU_H_INCLUDED__
#include "IGUIElement.h"
namespace irr
{
namespace gui
{
//! GUI Context menu interface.
class IGUIContextMenu : public IGUIElement
{
public:
//! constructor
IGUIContextMenu(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
: IGUIElement(EGUIET_CONTEXT_MENU, environment, parent, id, rectangle) {}
//! destructor
virtual ~IGUIContextMenu() {};
//! Get amount of menu items
virtual u32 getItemCount() const = 0;
//! Adds a menu item.
/** \param text: Text of menu item. Set this to 0 to create
an separator instead of a real item, which is the same like
calling addSeparator();
\param commandId: Command id of menu item, a simple id you may
set to whatever you want.
\param enabled: Specifies if the menu item should be enabled.
\param hasSubMenu: Set this to true if there should be a submenu
at this item. You can acess this submenu via getSubMenu().
\param checked: Specifies if the menu item should be initially checked.
\return Returns the index of the new item */
virtual u32 addItem(const wchar_t* text, s32 commandId=-1, bool enabled=true,
bool hasSubMenu=false,
bool checked=false
) = 0;
//! Adds a separator item to the menu
virtual void addSeparator() = 0;
//! Get text of the menu item.
/** \param idx: Zero based index of the menu item */
virtual const wchar_t* getItemText(u32 idx) const = 0;
//! Sets text of the menu item.
/** \param idx: Zero based index of the menu item
\param text: New text of the item. */
virtual void setItemText(u32 idx, const wchar_t* text) = 0;
//! Check if a menu item is enabled
/** \param idx: Zero based index of the menu item */
virtual bool isItemEnabled(u32 idx) const = 0;
//! Sets if the menu item should be enabled.
/** \param idx: Zero based index of the menu item
\param enabled: True if it is enabled, otherwise false. */
virtual void setItemEnabled(u32 idx, bool enabled) = 0;
//! Sets if the menu item should be checked.
/** \param idx: Zero based index of the menu item
\param enabled: True if it is enabled, otherwise false. */
virtual void setItemChecked(u32 idx, bool enabled) = 0;
//! Check if a menu item is checked
/** \param idx: Zero based index of the menu item */
virtual bool isItemChecked(u32 idx) const = 0;
//! Removes a menu item
/** \param idx: Zero based index of the menu item */
virtual void removeItem(u32 idx) = 0;
//! Removes all menu items
virtual void removeAllItems() = 0;
//! Get the selected item in the menu
/** \return Index of the selected item, -1 if none selected. */
virtual s32 getSelectedItem() const = 0;
//! Get the command id of a menu item
/** \param idx: Zero based index of the menu item */
virtual s32 getItemCommandId(u32 idx) const = 0;
//! Sets the command id of a menu item
/** \param idx: Zero based index of the menu item
\param id: Command id of menu item, a simple id you may
set to whatever you want. */
virtual void setItemCommandId(u32 idx, s32 id) = 0;
//! Get a pointer to the submenu of an item.
/** 0 is returned if there is no submenu
\param idx: Zero based index of the menu item
\return Returns a pointer to the submenu of an item. */
virtual IGUIContextMenu* getSubMenu(u32 idx) const = 0;
};
} // end namespace gui
} // end namespace irr
#endif

View File

@ -0,0 +1,114 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_GUI_EDIT_BOX_H_INCLUDED__
#define __I_GUI_EDIT_BOX_H_INCLUDED__
#include "IGUIElement.h"
#include "SColor.h"
namespace irr
{
namespace gui
{
class IGUIFont;
//! Single line edit box for editing simple text.
class IGUIEditBox : public IGUIElement
{
public:
//! constructor
IGUIEditBox(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
: IGUIElement(EGUIET_EDIT_BOX, environment, parent, id, rectangle) {}
//! destructor
virtual ~IGUIEditBox() {};
//! Sets another skin independent font.
/** If this is set to zero, the button uses the font of the skin.
\param font: New font to set. */
virtual void setOverrideFont(IGUIFont* font=0) = 0;
//! Sets another color for the text.
/** If set, the edit box does not use the EGDC_BUTTON_TEXT color defined
in the skin, but the set color instead. You don't need to call
IGUIEditBox::enableOverrrideColor(true) after this, this is done
by this function.
If you set a color, and you want the text displayed with the color
of the skin again, call IGUIEditBox::enableOverrideColor(false);
\param color: New color of the text. */
virtual void setOverrideColor(video::SColor color) = 0;
//! Sets if the text should use the overide color or the color in the gui skin.
/** \param enable: If set to true, the override color, which can be set
with IGUIEditBox::setOverrideColor is used, otherwise the
EGDC_BUTTON_TEXT color of the skin. */
virtual void enableOverrideColor(bool enable) = 0;
//! Turns the border on or off
/** \param border: true if you want the border to be drawn, false if not */
virtual void setDrawBorder(bool border) = 0;
//! Sets text justification mode
/** \param horizontal: EGUIA_UPPERLEFT for left justified (default),
EGUIA_LOWEERRIGHT for right justified, or EGUIA_CENTER for centered text.
\param vertical: EGUIA_UPPERLEFT to align with top edge,
EGUIA_LOWEERRIGHT for bottom edge, or EGUIA_CENTER for centered text (default). */
virtual void setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical) = 0;
//! Enables or disables word wrap.
/** \param enable: If set to true, words going over one line are
broken to the next line. */
virtual void setWordWrap(bool enable) = 0;
//! Checks if word wrap is enabled
//! \return true if word wrap is enabled, false otherwise
virtual bool isWordWrapEnabled() const = 0;
//! Enables or disables newlines.
/** \param enable: If set to true, the EGET_EDITBOX_ENTER event will not be fired,
instead a newline character will be inserted. */
virtual void setMultiLine(bool enable) = 0;
//! Checks if multi line editing is enabled
//! \return true if mult-line is enabled, false otherwise
virtual bool isMultiLineEnabled() const = 0;
//! Enables or disables automatic scrolling with cursor position
//! \param enable: If set to true, the text will move around with the cursor position
virtual void setAutoScroll(bool enable) = 0;
//! Checks to see if automatic scrolling is enabled
//! \return true if automatic scrolling is enabled, false if not
virtual bool isAutoScrollEnabled() const = 0;
//! Sets whether the edit box is a password box. Setting this to true will
/** disable MultiLine, WordWrap and the ability to copy with ctrl+c or ctrl+x
\param passwordBox: true to enable password, false to disable
\param passwordChar: the character that is displayed instead of letters */
virtual void setPasswordBox(bool passwordBox, wchar_t passwordChar = L'*') = 0;
//! Returns true if the edit box is currently a password box.
virtual bool isPasswordBox() const = 0;
//! Gets the size area of the text in the edit box
//! \return Returns the size in pixels of the text
virtual core::dimension2di getTextDimension() = 0;
//! Sets the maximum amount of characters which may be entered in the box.
/** \param max: Maximum amount of characters. If 0, the character amount is
infinity. */
virtual void setMax(u32 max) = 0;
//! Returns maximum amount of characters, previously set by setMax();
virtual u32 getMax() const = 0;
};
} // end namespace gui
} // end namespace irr
#endif

View File

@ -0,0 +1,943 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_GUI_ELEMENT_H_INCLUDED__
#define __I_GUI_ELEMENT_H_INCLUDED__
#include "IAttributeExchangingObject.h"
#include "irrList.h"
#include "rect.h"
#include "irrString.h"
#include "IEventReceiver.h"
#include "EGUIElementTypes.h"
#include "IAttributes.h"
namespace irr
{
namespace gui
{
class IGUIEnvironment;
enum EGUI_ALIGNMENT
{
//! Aligned to parent's top or left side (default)
EGUIA_UPPERLEFT=0,
//! Aligned to parent's bottom or right side
EGUIA_LOWERRIGHT,
//! Aligned to the center of parent
EGUIA_CENTER,
//! Scaled within its parent
EGUIA_SCALE
};
//! Names for alignments
const c8* const GUIAlignmentNames[] =
{
"upperLeft",
"lowerRight",
"center",
"scale",
0
};
//! Base class of all GUI elements.
class IGUIElement : public virtual io::IAttributeExchangingObject, public IEventReceiver
{
public:
//! Constructor
IGUIElement(EGUI_ELEMENT_TYPE type, IGUIEnvironment* environment, IGUIElement* parent,
s32 id, core::rect<s32> rectangle)
: Parent(0), RelativeRect(rectangle), AbsoluteRect(rectangle),
AbsoluteClippingRect(rectangle), DesiredRect(rectangle),
MaxSize(0,0), MinSize(1,1), IsVisible(true), IsEnabled(true),
IsSubElement(false), NoClip(false), ID(id), IsTabStop(false), TabOrder(-1), IsTabGroup(false),
AlignLeft(EGUIA_UPPERLEFT), AlignRight(EGUIA_UPPERLEFT), AlignTop(EGUIA_UPPERLEFT), AlignBottom(EGUIA_UPPERLEFT),
Environment(environment), Type(type)
{
#ifdef _DEBUG
setDebugName("IGUIElement");
#endif
// if we were given a parent to attach to
if (parent)
parent->addChild(this);
// if we succeeded in becoming a child
if (Parent)
{
LastParentRect = Parent->getAbsolutePosition();
AbsoluteRect += LastParentRect.UpperLeftCorner;
AbsoluteClippingRect = AbsoluteRect;
AbsoluteClippingRect.clipAgainst(Parent->AbsoluteClippingRect);
}
}
//! Destructor
virtual ~IGUIElement()
{
// delete all children
core::list<IGUIElement*>::Iterator it = Children.begin();
for (; it != Children.end(); ++it)
{
(*it)->Parent = 0;
(*it)->drop();
}
}
//! Returns parent of this element.
IGUIElement* getParent() const
{
return Parent;
}
//! Returns the relative rectangle of this element.
core::rect<s32> getRelativePosition() const
{
return RelativeRect;
}
//! Sets the relative rectangle of this element.
void setRelativePosition(const core::rect<s32>& r)
{
if (Parent)
{
const core::rect<s32>& r2 = Parent->getAbsolutePosition();
core::dimension2df d((f32)(r2.getSize().Width), (f32)(r2.getSize().Height));
if (AlignLeft == EGUIA_SCALE)
ScaleRect.UpperLeftCorner.X = (f32)r.UpperLeftCorner.X / d.Width;
if (AlignRight == EGUIA_SCALE)
ScaleRect.LowerRightCorner.X = (f32)r.LowerRightCorner.X / d.Width;
if (AlignTop == EGUIA_SCALE)
ScaleRect.UpperLeftCorner.Y = (f32)r.UpperLeftCorner.Y / d.Height;
if (AlignBottom == EGUIA_SCALE)
ScaleRect.LowerRightCorner.Y = (f32)r.LowerRightCorner.Y / d.Height;
}
DesiredRect = r;
updateAbsolutePosition();
}
//! Sets the relative rectangle of this element.
void setRelativePosition(const core::rect<f32>& r)
{
if (!Parent)
return;
const core::dimension2di& d = Parent->getAbsolutePosition().getSize();
DesiredRect = core::rect<s32>(
core::floor32((f32)d.Width * r.UpperLeftCorner.X),
core::floor32((f32)d.Height * r.UpperLeftCorner.Y),
core::floor32((f32)d.Width * r.LowerRightCorner.X),
core::floor32((f32)d.Height * r.LowerRightCorner.Y));
ScaleRect = r;
updateAbsolutePosition();
}
//! Returns the absolute rectangle of element.
core::rect<s32> getAbsolutePosition() const
{
return AbsoluteRect;
}
//! Returns the visible area of the element.
core::rect<s32> getAbsoluteClippingRect() const
{
return AbsoluteClippingRect;
}
//! Sets whether the element will ignore its parent's clipping rectangle
void setNotClipped(bool noClip)
{
NoClip = noClip;
}
//! Gets whether the element will ignore its parent's clipping rectangle
bool isNotClipped() const
{
return NoClip;
}
//! Sets the maximum size allowed for this element
/** If set to 0,0, there is no maximum size */
void setMaxSize(core::dimension2di size)
{
MaxSize = size;
updateAbsolutePosition();
}
//! Sets the minimum size allowed for this element
void setMinSize(core::dimension2di size)
{
MinSize = size;
if (MinSize.Width < 1)
MinSize.Width = 1;
if (MinSize.Height < 1)
MinSize.Height = 1;
updateAbsolutePosition();
}
void setAlignment(EGUI_ALIGNMENT left, EGUI_ALIGNMENT right, EGUI_ALIGNMENT top, EGUI_ALIGNMENT bottom)
{
AlignLeft = left;
AlignRight = right;
AlignTop = top;
AlignBottom = bottom;
if (Parent)
{
core::rect<s32> r(Parent->getAbsolutePosition());
core::dimension2df d((f32)r.getSize().Width, (f32)r.getSize().Height);
if (AlignLeft == EGUIA_SCALE)
ScaleRect.UpperLeftCorner.X = (f32)DesiredRect.UpperLeftCorner.X / d.Width;
if (AlignRight == EGUIA_SCALE)
ScaleRect.LowerRightCorner.X = (f32)DesiredRect.LowerRightCorner.X / d.Width;
if (AlignTop == EGUIA_SCALE)
ScaleRect.UpperLeftCorner.Y = (f32)DesiredRect.UpperLeftCorner.Y / d.Height;
if (AlignBottom == EGUIA_SCALE)
ScaleRect.LowerRightCorner.Y = (f32)DesiredRect.LowerRightCorner.Y / d.Height;
}
}
//! Updates the absolute position.
virtual void updateAbsolutePosition()
{
core::rect<s32> parentAbsolute(0,0,0,0);
core::rect<s32> parentAbsoluteClip;
s32 diffx, diffy;
f32 fw=0.f, fh=0.f;
if (Parent)
{
parentAbsolute = Parent->AbsoluteRect;
if (NoClip)
{
IGUIElement* p=this;
while (p && p->NoClip && p->Parent)
p = p->Parent;
if (p->Parent)
parentAbsoluteClip = p->Parent->AbsoluteClippingRect;
else
parentAbsoluteClip = p->AbsoluteClippingRect;
}
else
parentAbsoluteClip = Parent->AbsoluteClippingRect;
}
diffx = parentAbsolute.getWidth() - LastParentRect.getWidth();
diffy = parentAbsolute.getHeight() - LastParentRect.getHeight();
if (AlignLeft == EGUIA_SCALE || AlignRight == EGUIA_SCALE)
fw = (f32)parentAbsolute.getWidth();
if (AlignTop == EGUIA_SCALE || AlignBottom == EGUIA_SCALE)
fh = (f32)parentAbsolute.getHeight();
switch (AlignLeft)
{
case EGUIA_UPPERLEFT:
break;
case EGUIA_LOWERRIGHT:
DesiredRect.UpperLeftCorner.X += diffx;
break;
case EGUIA_CENTER:
DesiredRect.UpperLeftCorner.X += diffx/2;
break;
case EGUIA_SCALE:
DesiredRect.UpperLeftCorner.X = (s32)(ScaleRect.UpperLeftCorner.X * fw);
break;
}
switch (AlignRight)
{
case EGUIA_UPPERLEFT:
break;
case EGUIA_LOWERRIGHT:
DesiredRect.LowerRightCorner.X += diffx;
break;
case EGUIA_CENTER:
DesiredRect.LowerRightCorner.X += diffx/2;
break;
case EGUIA_SCALE:
DesiredRect.LowerRightCorner.X = (s32)(ScaleRect.LowerRightCorner.X * fw);
break;
}
switch (AlignTop)
{
case EGUIA_UPPERLEFT:
break;
case EGUIA_LOWERRIGHT:
DesiredRect.UpperLeftCorner.Y += diffy;
break;
case EGUIA_CENTER:
DesiredRect.UpperLeftCorner.Y += diffy/2;
break;
case EGUIA_SCALE:
DesiredRect.UpperLeftCorner.Y = (s32)(ScaleRect.UpperLeftCorner.Y * fh);
break;
}
switch (AlignBottom)
{
case EGUIA_UPPERLEFT:
break;
case EGUIA_LOWERRIGHT:
DesiredRect.LowerRightCorner.Y += diffy;
break;
case EGUIA_CENTER:
DesiredRect.LowerRightCorner.Y += diffy/2;
break;
case EGUIA_SCALE:
DesiredRect.LowerRightCorner.Y = (s32)(ScaleRect.LowerRightCorner.Y * fh);
break;
}
RelativeRect = DesiredRect;
s32 w = RelativeRect.getWidth();
s32 h = RelativeRect.getHeight();
// make sure the desired rectangle is allowed
if (w < MinSize.Width)
RelativeRect.LowerRightCorner.X = RelativeRect.UpperLeftCorner.X + MinSize.Width;
if (h < MinSize.Height)
RelativeRect.LowerRightCorner.Y = RelativeRect.UpperLeftCorner.Y + MinSize.Height;
if (MaxSize.Width && w > MaxSize.Width)
RelativeRect.LowerRightCorner.X = RelativeRect.UpperLeftCorner.X + MaxSize.Width;
if (MaxSize.Height && h > MaxSize.Height)
RelativeRect.LowerRightCorner.Y = RelativeRect.UpperLeftCorner.Y + MaxSize.Height;
RelativeRect.repair();
AbsoluteRect = RelativeRect + parentAbsolute.UpperLeftCorner;
if (!Parent)
parentAbsoluteClip = AbsoluteRect;
AbsoluteClippingRect = AbsoluteRect;
AbsoluteClippingRect.clipAgainst(parentAbsoluteClip);
LastParentRect = parentAbsolute;
// update all children
core::list<IGUIElement*>::Iterator it = Children.begin();
for (; it != Children.end(); ++it)
{
(*it)->updateAbsolutePosition();
}
}
//! Returns the child element, which is at the position of the point.
IGUIElement* getElementFromPoint(const core::position2d<s32>& point)
{
IGUIElement* target = 0;
// we have to search from back to front, because later children
// might be drawn over the top of earlier ones.
core::list<IGUIElement*>::Iterator it = Children.getLast();
if (IsVisible)
while(it != Children.end())
{
target = (*it)->getElementFromPoint(point);
if (target)
return target;
--it;
}
if (IsVisible && isPointInside(point))
target = this;
return target;
}
//! Returns true if a point is within this element.
//! Elements with a shape other than a rectangle will override this method
virtual bool isPointInside(const core::position2d<s32>& point) const
{
return AbsoluteClippingRect.isPointInside(point);
}
//! Adds a GUI element as new child of this element.
virtual void addChild(IGUIElement* child)
{
if (child)
{
child->grab();
child->remove(); // remove from old parent
child->LastParentRect = getAbsolutePosition();
child->Parent = this;
Children.push_back(child);
}
}
//! Removes a child.
virtual void removeChild(IGUIElement* child)
{
core::list<IGUIElement*>::Iterator it = Children.begin();
for (; it != Children.end(); ++it)
if ((*it) == child)
{
(*it)->Parent = 0;
(*it)->drop();
Children.erase(it);
return;
}
}
//! Removes this element from its parent.
virtual void remove()
{
if (Parent)
Parent->removeChild(this);
}
//! Draws the element and its children.
virtual void draw()
{
if (!IsVisible)
return;
core::list<IGUIElement*>::Iterator it = Children.begin();
for (; it != Children.end(); ++it)
(*it)->draw();
}
//! animate the element and its children.
virtual void OnPostRender(u32 timeMs)
{
if (!IsVisible)
return;
core::list<IGUIElement*>::Iterator it = Children.begin();
for (; it != Children.end(); ++it)
(*it)->OnPostRender( timeMs );
}
//! Moves this element.
virtual void move(core::position2d<s32> absoluteMovement)
{
setRelativePosition(DesiredRect + absoluteMovement);
}
//! Returns true if element is visible.
virtual bool isVisible() const
{
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
return IsVisible;
}
//! Sets the visible state of this element.
virtual void setVisible(bool visible)
{
IsVisible = visible;
}
//! Returns true if this element was created as part of its parent control
virtual bool isSubElement() const
{
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
return IsSubElement;
}
//! Sets whether this control was created as part of its parent,
//! for example when a scrollbar is part of a listbox.
//! SubElements are not saved to disk when calling guiEnvironment->saveGUI()
virtual void setSubElement(bool subElement)
{
IsSubElement = subElement;
}
//! If set to true, the focus will visit this element when using
//! the tab key to cycle through elements.
//! If this element is a tab group (see isTabGroup/setTabGroup) then
//! ctrl+tab will be used instead.
void setTabStop(bool enable)
{
IsTabStop = enable;
}
//! Returns true if this element can be focused by navigating with the tab key
bool isTabStop() const
{
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
return IsTabStop;
}
//! Sets the priority of focus when using the tab key to navigate between a group
//! of elements. See setTabGroup, isTabGroup and getTabGroup for information on tab groups.
//! Elements with a lower number are focused first
void setTabOrder(s32 index)
{
// negative = autonumber
if (index < 0)
{
TabOrder = 0;
IGUIElement *el = getTabGroup();
while (IsTabGroup && el && el->Parent)
el = el->Parent;
IGUIElement *first=0, *closest=0;
if (el)
{
// find the highest element number
el->getNextElement(-1, true, IsTabGroup, first, closest, true);
if (first)
{
TabOrder = first->getTabOrder() + 1;
}
}
}
else
TabOrder = index;
}
//! Returns the number in the tab order sequence
s32 getTabOrder() const
{
return TabOrder;
}
//! Sets whether this element is a container for a group of elements which
//! can be navigated using the tab key. For example, windows are tab groups.
//! Groups can be navigated using ctrl+tab, providing isTabStop is true.
void setTabGroup(bool isGroup)
{
IsTabGroup = isGroup;
}
//! Returns true if this element is a tab group.
bool isTabGroup() const
{
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
return IsTabGroup;
}
//! Returns the container element which holds all elements in this element's
//! tab group.
IGUIElement* getTabGroup()
{
IGUIElement *ret=this;
while (ret && !ret->isTabGroup())
ret = ret->getParent();
return ret;
}
//! Returns true if element is enabled.
virtual bool isEnabled() const
{
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
return IsEnabled;
}
//! Sets the enabled state of this element.
virtual void setEnabled(bool enabled)
{
IsEnabled = enabled;
}
//! Sets the new caption of this element.
virtual void setText(const wchar_t* text)
{
Text = text;
}
//! Returns caption of this element.
virtual const wchar_t* getText() const
{
return Text.c_str();
}
//! Sets the new caption of this element.
virtual void setToolTipText(const wchar_t* text)
{
ToolTipText = text;
}
//! Returns caption of this element.
virtual const core::stringw& getToolTipText() const
{
return ToolTipText;
}
//! Returns id. Can be used to identify the element.
virtual s32 getID() const
{
return ID;
}
//! Sets the id of this element
virtual void setID(s32 id)
{
ID = id;
}
//! Called if an event happened.
virtual bool OnEvent(const SEvent& event)
{
return Parent ? Parent->OnEvent(event) : false;
}
//! Brings a child to front
/** \return Returns true if successful, false if not. */
virtual bool bringToFront(IGUIElement* element)
{
core::list<IGUIElement*>::Iterator it = Children.begin();
for (; it != Children.end(); ++it)
{
if (element == (*it))
{
Children.erase(it);
Children.push_back(element);
return true;
}
}
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
return false;
}
//! Returns list with children of this element
virtual const core::list<IGUIElement*>& getChildren() const
{
return Children;
}
//! Finds the first element with the given id.
/** \param id: Id to search for.
\param searchchildren: Set this to true, if also children of this
element may contain the element with the searched id and they
should be searched too.
\return Returns the first element with the given id. If no element
with this id was found, 0 is returned. */
virtual IGUIElement* getElementFromId(s32 id, bool searchchildren=false) const
{
IGUIElement* e = 0;
core::list<IGUIElement*>::ConstIterator it = Children.begin();
for (; it != Children.end(); ++it)
{
if ((*it)->getID() == id)
return (*it);
if (searchchildren)
e = (*it)->getElementFromId(id, true);
if (e)
return e;
}
return e;
}
//! returns true if the given element is a child of this one.
//! \param child: The child element to check
bool isMyChild(IGUIElement* child) const
{
if (!child)
return false;
do
{
if (child->Parent)
child = child->Parent;
} while (child->Parent && child != this);
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
return child == this;
}
//! searches elements to find the closest next element to tab to
//! \param startOrder: The TabOrder of the current element, -1 if none
//! \param reverse: true if searching for a lower number
//! \param group: true if searching for a higher one
//! \param first: element with the highest/lowest known tab order depending on search direction
//! \param closest: the closest match, depending on tab order and direction
//! \param includeInvisible: includes invisible elements in the search (default=false)
//! \return true if successfully found an element, false to continue searching/fail
bool getNextElement(s32 startOrder, bool reverse, bool group,
IGUIElement*& first, IGUIElement*& closest, bool includeInvisible=false) const
{
// we'll stop searching if we find this number
s32 wanted = startOrder + ( reverse ? -1 : 1 );
if (wanted==-2)
wanted = 1073741824; // maximum s32
core::list<IGUIElement*>::ConstIterator it = Children.begin();
s32 closestOrder, currentOrder;
while(it != Children.end())
{
// ignore invisible elements and their children
if ( ( (*it)->isVisible() || includeInvisible ) &&
(group == true || (*it)->isTabGroup() == false) )
{
// only check tab stops and those with the same group status
if ((*it)->isTabStop() && ((*it)->isTabGroup() == group))
{
currentOrder = (*it)->getTabOrder();
// is this what we're looking for?
if (currentOrder == wanted)
{
closest = *it;
return true;
}
// is it closer than the current closest?
if (closest)
{
closestOrder = closest->getTabOrder();
if ( ( reverse && currentOrder > closestOrder && currentOrder < startOrder)
||(!reverse && currentOrder < closestOrder && currentOrder > startOrder))
{
closest = *it;
}
}
else
if ( (reverse && currentOrder < startOrder) || (!reverse && currentOrder > startOrder) )
{
closest = *it;
}
// is it before the current first?
if (first)
{
closestOrder = first->getTabOrder();
if ( (reverse && closestOrder < currentOrder) || (!reverse && closestOrder > currentOrder) )
{
first = *it;
}
}
else
{
first = *it;
}
}
// search within children
if ((*it)->getNextElement(startOrder, reverse, group, first, closest))
{
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
return true;
}
}
++it;
}
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
return false;
}
//! Returns the type of the gui element.
/** This is needed for the .NET wrapper but will be used
later for serializing and deserializing.
If you wrote your own GUIElements, you need to set the type for your element as first parameter
in the constructor of IGUIElement. For own (=unknown) elements, simply use EGUIET_ELEMENT as type */
EGUI_ELEMENT_TYPE getType() const
{
return Type;
}
//! Returns the type name of the gui element.
/** This is needed serializing elements. For serializing your own elements, override this function
and return your own type name which is created by your IGUIElementFactory */
virtual const c8* getTypeName() const
{
return GUIElementTypeNames[Type];
}
//! Writes attributes of the scene node.
//! Implement this to expose the attributes of your scene node for
//! scripting languages, editors, debuggers or xml serialization purposes.
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const
{
out->addInt("Id", ID );
out->addString("Caption", getText());
out->addRect("Rect", DesiredRect);
out->addPosition2d("MinSize", core::position2di(MinSize.Width, MinSize.Height));
out->addPosition2d("MaxSize", core::position2di(MaxSize.Width, MaxSize.Height));
out->addBool("NoClip", NoClip);
out->addEnum("LeftAlign", AlignLeft, GUIAlignmentNames);
out->addEnum("RightAlign", AlignRight, GUIAlignmentNames);
out->addEnum("TopAlign", AlignTop, GUIAlignmentNames);
out->addEnum("BottomAlign", AlignBottom, GUIAlignmentNames);
out->addBool("Visible", IsVisible);
out->addBool("Enabled", IsEnabled);
out->addBool("TabStop", IsTabStop);
out->addBool("TabGroup", IsTabGroup);
out->addInt("TabOrder", TabOrder);
}
//! Reads attributes of the scene node.
//! Implement this to set the attributes of your scene node for
//! scripting languages, editors, debuggers or xml deserialization purposes.
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0)
{
setID(in->getAttributeAsInt("Id"));
setText(in->getAttributeAsStringW("Caption").c_str());
setVisible(in->getAttributeAsBool("Visible"));
setEnabled(in->getAttributeAsBool("Enabled"));
IsTabStop = in->getAttributeAsBool("TabStop");
IsTabGroup = in->getAttributeAsBool("TabGroup");
TabOrder = in->getAttributeAsInt("TabOrder");
core::position2di p = in->getAttributeAsPosition2d("MaxSize");
setMaxSize(core::dimension2di(p.X,p.Y));
p = in->getAttributeAsPosition2d("MinSize");
setMinSize(core::dimension2di(p.X,p.Y));
setNotClipped(in->getAttributeAsBool("NoClip"));
setAlignment((EGUI_ALIGNMENT) in->getAttributeAsEnumeration("LeftAlign", GUIAlignmentNames),
(EGUI_ALIGNMENT)in->getAttributeAsEnumeration("RightAlign", GUIAlignmentNames),
(EGUI_ALIGNMENT)in->getAttributeAsEnumeration("TopAlign", GUIAlignmentNames),
(EGUI_ALIGNMENT)in->getAttributeAsEnumeration("BottomAlign", GUIAlignmentNames));
setRelativePosition(in->getAttributeAsRect("Rect"));
}
protected:
//! List of all children of this element
core::list<IGUIElement*> Children;
//! Pointer to the parent
IGUIElement* Parent;
//! relative rect of element
core::rect<s32> RelativeRect;
//! absolute rect of element
core::rect<s32> AbsoluteRect;
//! absolute clipping rect of element
core::rect<s32> AbsoluteClippingRect;
//! the rectangle the element would prefer to be,
//! if it was not constrained by parent or max/min size
core::rect<s32> DesiredRect;
//! for calculating the difference when resizing parent
core::rect<s32> LastParentRect;
//! relative scale of the element inside its parent
core::rect<f32> ScaleRect;
//! maximum and minimum size of the element
core::dimension2di MaxSize, MinSize;
//! is visible?
bool IsVisible;
//! is enabled?
bool IsEnabled;
//! is a part of a larger whole and should not be serialized?
bool IsSubElement;
//! does this element ignore its parent's clipping rectangle?
bool NoClip;
//! caption
core::stringw Text;
//! tooltip
core::stringw ToolTipText;
//! id
s32 ID;
//! tab stop like in windows
bool IsTabStop;
//! tab order
s32 TabOrder;
//! tab groups are containers like windows, use ctrl+tab to navigate
bool IsTabGroup;
//! tells the element how to act when its parent is resized
EGUI_ALIGNMENT AlignLeft, AlignRight, AlignTop, AlignBottom;
//! GUI Environment
IGUIEnvironment* Environment;
//! type of element
EGUI_ELEMENT_TYPE Type;
};
} // end namespace gui
} // end namespace irr
#endif

View File

@ -0,0 +1,70 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_GUI_ELEMENT_FACTORY_H_INCLUDED__
#define __I_GUI_ELEMENT_FACTORY_H_INCLUDED__
#include "IReferenceCounted.h"
#include "EGUIElementTypes.h"
namespace irr
{
namespace gui
{
class IGUIElement;
//! Interface making it possible to dynamicly create GUI elements
/** To be able to add custom elements to Irrlicht and to make it possible for the
scene manager to save and load them, simply implement this interface and register it
in your gui environment via IGUIEnvironment::registerGUIElementFactory.
Note: When implementing your own element factory, don't call IGUIEnvironment::grab() to
increase the reference counter of the environment. This is not necessary because the
it will grab() the factory anyway, and otherwise cyclic references will be created.
*/
class IGUIElementFactory : public virtual IReferenceCounted
{
public:
// destructor
virtual ~IGUIElementFactory() {}
//! adds an element to the gui environment based on its type id
/** \param type: Type of the element to add.
\param parent: Parent scene node of the new element, can be null to add to the root.
\return Returns pointer to the new element or null if not successful. */
virtual IGUIElement* addGUIElement(EGUI_ELEMENT_TYPE type, IGUIElement* parent=0) = 0;
//! adds a GUI element to the GUI Environment based on its type name
/** \param typeName: Type name of the element to add.
\param parent: Parent scene node of the new element, can be null to add it to the root.
\return Returns pointer to the new element or null if not successful. */
virtual IGUIElement* addGUIElement(const c8* typeName, IGUIElement* parent=0) = 0;
//! returns amount of GUI element types this factory is able to create
virtual s32 getCreatableGUIElementTypeCount() const = 0;
//! returns type of a createable element type
/** \param idx: Index of the element type in this factory. Must be a value between 0 and
getCreatableGUIElementTypeCount() */
virtual EGUI_ELEMENT_TYPE getCreateableGUIElementType(s32 idx) const = 0;
//! returns type name of a createable GUI element type by index
/** \param idx: Index of the type in this factory. Must be a value between 0 and
getCreatableGUIElementTypeCount() */
virtual const c8* getCreateableGUIElementTypeName(s32 idx) const = 0;
//! returns type name of a createable GUI element
/** \param type: Type of GUI element.
\return: Returns name of the type if this factory can create the type, otherwise 0. */
virtual const c8* getCreateableGUIElementTypeName(EGUI_ELEMENT_TYPE type) const = 0;
};
} // end namespace gui
} // end namespace irr
#endif // __I_GUI_ELEMENT_FACTORY_H_INCLUDED__

View File

@ -0,0 +1,428 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_GUI_ENVIRONMENT_H_INCLUDED__
#define __I_GUI_ENVIRONMENT_H_INCLUDED__
#include "IReferenceCounted.h"
#include "IGUISkin.h"
#include "rect.h"
#include "EMessageBoxFlags.h"
#include "IEventReceiver.h"
#include "IXMLReader.h"
namespace irr
{
class IOSOperator;
class IEventReceiver;
namespace io
{
class IXMLWriter;
class IReadFile;
class IWriteFile;
class IFileSystem;
} // end namespace io
namespace video
{
class IVideoDriver;
class ITexture;
} // end namespace video
namespace gui
{
class IGUIElement;
class IGUIFont;
class IGUISpriteBank;
class IGUIScrollBar;
class IGUIImage;
class IGUIMeshViewer;
class IGUICheckBox;
class IGUIListBox;
class IGUIFileOpenDialog;
class IGUIColorSelectDialog;
class IGUIInOutFader;
class IGUIStaticText;
class IGUIEditBox;
class IGUISpinBox;
class IGUITabControl;
class IGUITab;
class IGUIContextMenu;
class IGUIComboBox;
class IGUIToolBar;
class IGUIButton;
class IGUIWindow;
class IGUIElementFactory;
//! GUI Environment. Used as factory and manager of all other GUI elements.
class IGUIEnvironment : public virtual IReferenceCounted
{
public:
//! destructor
virtual ~IGUIEnvironment() {};
//! Draws all gui elements.
virtual void drawAll() = 0;
//! Sets the focus to an element.
/** Causes a EGET_ELEMENT_FOCUS_LOST event followed by a EGET_ELEMENT_FOCUSED event.
If someone absorbed either of the events, then the focus will not be changed.
\return Returns true on success, false on failure */
virtual bool setFocus(IGUIElement* element) = 0;
//! Returns the element with the focus
virtual IGUIElement* getFocus() const = 0;
//! Removes the focus from an element.
/** Causes a EGET_ELEMENT_FOCUS_LOST event. If the event is absorbed then the focus
will not be changed.
\return Returns true on success, false on failure */
virtual bool removeFocus(IGUIElement* element) = 0;
//! Returns if the element has focus
virtual bool hasFocus(IGUIElement* element) const = 0;
//! Returns the current video driver.
virtual video::IVideoDriver* getVideoDriver() const = 0;
//! Returns the file system.
virtual io::IFileSystem* getFileSystem() const = 0;
//! returns a pointer to the OS operator
virtual IOSOperator* getOSOperator() const = 0;
//! removes all elements from the environment.
virtual void clear() = 0;
//! Posts an input event to the environment.
/** Usually you do not have to
use this method, it is used by the internal engine. */
virtual bool postEventFromUser(const SEvent& event) = 0;
//! This sets a new event receiver for gui events.
/** Usually you do not have to
use this method, it is used by the internal engine. */
virtual void setUserEventReceiver(IEventReceiver* evr) = 0;
//! Returns pointer to the current gui skin.
virtual IGUISkin* getSkin() const = 0;
//! Sets a new GUI Skin
/** You can use this to change the appearance of the whole GUI Environment. You
can set one of the built-in skins or implement your own class derived from
IGUISkin and enable it using this method.
To set for example the built-in Windows classic skin, use the following code:
\code
gui::IGUISkin* newskin = environment->createSkin(gui::EGST_WINDOWS_CLASSIC);
environment->setSkin(newskin);
newskin->drop();
\endcode
*/
virtual void setSkin(IGUISkin* skin) = 0;
//! Creates a new GUI Skin based on a template.
/** Use setSkin() to set the created skin.
\return Returns a pointer to the created skin.
If you no longer need it, you should call IGUISkin::drop().
See IReferenceCounted::drop() for more information. */
virtual IGUISkin* createSkin(EGUI_SKIN_TYPE type) = 0;
//! Returns pointer to the font with the specified file name.
/** Loads the font if it was not loaded before. Returns 0 if the font could not be loaded.
\return
returns a pointer to the font.
This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
virtual IGUIFont* getFont(const c8* filename) = 0;
//! Returns the default built-in font.
virtual IGUIFont* getBuiltInFont() const = 0;
//! Returns pointer to the sprite bank with the specified file name.
/** Loads the bank if it was not loaded before. Returns 0 if it could not be loaded.
\return
returns a pointer to the sprite bank.
This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
virtual IGUISpriteBank* getSpriteBank(const c8* filename) = 0;
//! adds an empty sprite bank to the manager
virtual IGUISpriteBank* addEmptySpriteBank(const c8 *name) = 0;
//! Returns the root gui element.
/** This is the first gui element, parent of all other
gui elements. You'll never need to use this method, unless you are not creating
your own gui elements, trying to add them to the gui elements without a parent.
The returned pointer should not be dropped. See IReferenceCounted::drop() for more information. */
virtual IGUIElement* getRootGUIElement() = 0;
//! Adds an button element.
/** \return
Returns a pointer to the created button. Returns 0 if an error occured.
This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
virtual IGUIButton* addButton(const core::rect<s32>& rectangle,
IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0, const wchar_t* tooltiptext = 0) = 0;
//! Adds an empty window element.
/** \param modal: Defines if the dialog is modal. This means, that all other
gui elements which were created before the message box cannot be used
until this messagebox is removed.
\return
Returns a pointer to the created window. Returns 0 if an error occured.
This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
virtual IGUIWindow* addWindow(const core::rect<s32>& rectangle, bool modal = false,
const wchar_t* text=0, IGUIElement* parent=0, s32 id=-1) = 0;
//! Adds a modal screen. This control stops its parent's members from being
//! able to recieve input until its last child is removed, it then deletes its self.
/** \return
Returns a pointer to the created window. Returns 0 if an error occured.
This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
virtual IGUIElement* addModalScreen(IGUIElement* parent) = 0;
//! Adds a message box.
/** \param caption: Text to be displayed the title of the message box.
\param text: Text to be displayed in the body of the message box.
\param modal: Defines if the dialog is modal. This means, that all other
gui elements which were created before the message box cannot be used
until this messagebox is removed.
\param flags: Flags specifying the layout of the message box. For example
to create a message box with an OK and a CANCEL button on it, set this
to (EMBF_OK | EMBF_CANCEL).
\param parent: Parent gui element of the message box.
\param id: Id with which the gui element can be identified.
\return
Returns a pointer to the created message box. Returns 0 if an error occured.
This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
virtual IGUIWindow* addMessageBox(const wchar_t* caption, const wchar_t* text=0,
bool modal = true, s32 flags = EMBF_OK, IGUIElement* parent=0, s32 id=-1) = 0;
//! Adds a scrollbar.
/** \return
Returns a pointer to the created scrollbar. Returns 0 if an error occured.
This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
virtual IGUIScrollBar* addScrollBar(bool horizontal, const core::rect<s32>& rectangle,
IGUIElement* parent=0, s32 id=-1) = 0;
//! Adds an image element.
/** \param image: Image to be displayed.
\param pos: Position of the image. The width and height of the image is taken
from the image.
\param useAlphaChannel: Sets if the image should use the alpha channel of the texture
to draw itself.
\return
Returns a pointer to the created image element. Returns 0 if an error occured.
This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
virtual IGUIImage* addImage(video::ITexture* image, core::position2d<s32> pos,
bool useAlphaChannel=true, IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0) = 0;
//! Adds an image element.
/** Use IGUIImage::setImage later to set the image to be displayed.
\return
Returns a pointer to the created image element. Returns 0 if an error occured.
This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
virtual IGUIImage* addImage(const core::rect<s32>& rectangle,
IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0) = 0;
//! Adds a checkbox element.
/** \return
Returns a pointer to the created check box. Returns 0 if an error occured.
This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
virtual IGUICheckBox* addCheckBox(bool checked, const core::rect<s32>& rectangle,
IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0) = 0;
//! Adds a list box element.
/** \return
Returns a pointer to the created list box. Returns 0 if an error occured.
This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
virtual IGUIListBox* addListBox(const core::rect<s32>& rectangle,
IGUIElement* parent=0, s32 id=-1, bool drawBackground=false) = 0;
//! Adds an mesh viewer. Not 100% implemented yet.
/** \return
Returns a pointer to the created mesh viewer. Returns 0 if an error occured.
This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
virtual IGUIMeshViewer* addMeshViewer(const core::rect<s32>& rectangle, IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0) = 0;
//! Adds a file open dialog.
/** \param modal: Defines if the dialog is modal. This means, that all other
gui elements which were created before the message box cannot be used
until this messagebox is removed.
\return
Returns a pointer to the created file open dialog. Returns 0 if an error occured.
This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
virtual IGUIFileOpenDialog* addFileOpenDialog(const wchar_t* title = 0,
bool modal=true, IGUIElement* parent=0, s32 id=-1) = 0;
//! Adds a color select dialog.
/** \param modal: Defines if the dialog is modal. This means, that all other
gui elements which were created before the message box cannot be used
until this messagebox is removed.
\return
Returns a pointer to the created file open dialog. Returns 0 if an error occured.
This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
virtual IGUIColorSelectDialog* addColorSelectDialog(const wchar_t* title = 0,
bool modal=true, IGUIElement* parent=0, s32 id=-1) = 0;
//! Adds a static text.
/** The returned pointer must not be dropped.
\param text is the text to be displayed. Can be altered after creation with SetText().
\param rectangle is the position of the static text.
\param border has to be set to true if the static text should have a 3d border.
\param wordWrap specifies, if the text should be wrapped into multiple lines.
\param parent is the parent item of the element. E.g. a window. Set it to 0 to place the fader directly in the environment.
\param id is a s32 to identify the static text element.
\param fillBackground specifies if the background will be filled. Default: false.
\return
Returns a pointer to the created static text. Returns 0 if an error occured.
This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
virtual IGUIStaticText* addStaticText(const wchar_t* text, const core::rect<s32>& rectangle,
bool border=false, bool wordWrap=true, IGUIElement* parent=0, s32 id=-1,
bool fillBackground = false) = 0;
//! Adds an edit box.
/** Supports unicode input from every keyboard around the world,
scrolling, copying and pasting (exchanging data with the clipboard directly), maximum
character amount, marking and all shortcuts like ctrl+X, ctrl+V, ctrg+C,
shift+Left, shift+Right, Home, End, and so on.
\param text is the text to be displayed. Can be altered after creation with setText().
\param rectangle is the position of the edit box.
\param border has to be set to true if the edit box should have a 3d border.
\param parent is the parent item of the element. E.g. a window. Set it to 0 to place the edit box directly in the environment.
\param id is a s32 to identify the edit box.
\return
Returns a pointer to the created edit box. Returns 0 if an error occured.
This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
virtual IGUIEditBox* addEditBox(const wchar_t* text, const core::rect<s32>& rectangle,
bool border=true, IGUIElement* parent=0, s32 id=-1) = 0;
//! Adds a spin box.
/** An edit box with up and down buttons
\param text is the text to be displayed. Can be altered after creation with setText().
\param rectangle is the position of the spin box.
\param parent is the parent item of the element. E.g. a window. Set it to 0 to place the spin box directly in the environment.
\param id is a s32 to identify the spin box.
\return
Returns a pointer to the created spin box. Returns 0 if an error occured.
This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
virtual IGUISpinBox* addSpinBox(const wchar_t* text, const core::rect<s32>& rectangle,
IGUIElement* parent=0, s32 id=-1) = 0;
//! Adds an element for fading in or out.
/* \param rectangle: Pointer to rectangle specifing the borders of the element.
If the pointer is NULL, the whole screen is used.
\param parent: Parent item of the element. E.g. a window. Set it to 0 to place the static text directly in the environment.
\param id: A s32 to identify the text.
\return
Returns a pointer to the created in-out-fader. Returns 0 if an error occured.
This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
virtual IGUIInOutFader* addInOutFader(const core::rect<s32>* rectangle=0, IGUIElement* parent=0, s32 id=-1) = 0;
//! Adds a tab control to the environment.
/** \param rectangle is the position of the tab control.
\param parent is the parent item of the element. E.g. a window. Set it to 0 to place the tab control directly in the environment.
\param fillbackground specifies if the background of the tab control should be drawn to.
\param border specifiys if a flat 3d border should be drawn.
This is usually not necesarry unless you don't place the control directly into the environment without a window as parent.
\param id is a s32 to identify the tab control.
\return
Returns a pointer to the created tab control element. Returns 0 if an error occured.
This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
virtual IGUITabControl* addTabControl(const core::rect<s32>& rectangle,
IGUIElement* parent=0, bool fillbackground=false,
bool border=true, s32 id=-1) = 0;
//! Adds tab to the environment.
/** You can use this element to group other elements. This is not used for creating tabs on tab controls,
please use IGUITabControl::addTab() for this instead.
\param rectangle is the position of the tab.
\param parent is the parent item of the element. E.g. a window. Set it to 0 to place the tab directly in the environment.
\param id is a s32 to identify the tab. */
virtual IGUITab* addTab(const core::rect<s32>& rectangle,
IGUIElement* parent=0, s32 id=-1) = 0;
//! Adds a context menu to the environment.
/** \param rectangle is the position of the menu. Note that the menu is
resizing itself based on what items you add.
\param parent is the parent item of the element. E.g. a window. Set it to 0 to place the menu directly in the environment.
\param id is a s32 to identify the menu. */
virtual IGUIContextMenu* addContextMenu(const core::rect<s32>& rectangle,
IGUIElement* parent=0, s32 id=-1) = 0;
//! Adds a menu to the environment.
/* This is like the menu you can find on top of most windows in modern graphical user interfaces.
\param parent is the parent item of the element. E.g. a window. Set it to 0 to place the menu directly in the environment.
\param id is a s32 to identify the menu. */
virtual IGUIContextMenu* addMenu(IGUIElement* parent=0, s32 id=-1) = 0;
//! Adds a toolbar to the environment.
/** It is like a menu is always placed on top
in its parent, and contains buttons.
\param parent is the parent item of the element. E.g. a window. Set it to 0 to place the tool bar directly in the environment.
\param id is a s32 to identify the tool bar. */
virtual IGUIToolBar* addToolBar(IGUIElement* parent=0, s32 id=-1) = 0;
//! Adds a combo box to the environment.
/** \param parent is the parent item of the element. E.g. a window. Set it to 0 to place the combo box directly in the environment.
\param id is a s32 to identify the combo box. */
virtual IGUIComboBox* addComboBox(const core::rect<s32>& rectangle,
IGUIElement* parent=0, s32 id=-1) = 0;
//! Returns the default element factory which can create all built in elements
virtual IGUIElementFactory* getDefaultGUIElementFactory() const = 0;
//! Adds an element factory to the gui environment.
/** Use this to extend the gui environment with new element types which it should be
able to create automaticly, for example when loading data from xml files. */
virtual void registerGUIElementFactory(IGUIElementFactory* factoryToAdd) = 0;
//! Returns amount of registered gui element factories.
virtual u32 getRegisteredGUIElementFactoryCount() const = 0;
//! Returns a gui element factory by index
virtual IGUIElementFactory* getGUIElementFactory(u32 index) const = 0;
//! Adds a GUI Element by its name
virtual IGUIElement* addGUIElement(const c8* elementName, IGUIElement* parent=0) = 0;
//! Saves the current gui into a file.
//! \param filename: Name of the file.
//! \param start: The GUIElement to start with. Root if 0.
virtual bool saveGUI(const c8* filename, IGUIElement* start=0) = 0;
//! Saves the current gui into a file.
//! \param file: The file to write to.
//! \param start: The GUIElement to start with. Root if 0.
virtual bool saveGUI(io::IWriteFile* file, IGUIElement* start=0) = 0;
//! Loads the gui. Note that the current gui is not cleared before.
//! \param filename: Name of the file .
//! \param parent: Parent for the loaded GUI, root if 0.
virtual bool loadGUI(const c8* filename, IGUIElement* parent=0) = 0;
//! Loads the gui. Note that the current gui is not cleared before.
//! \param file: The file to load from.
//! \param parent: Parent for the loaded GUI, root if 0.
virtual bool loadGUI(io::IReadFile* file, IGUIElement* parent=0) = 0;
//! Writes attributes of the gui environment
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const =0;
//! Reads attributes of the gui environment
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0)=0;
//! writes an element
virtual void writeGUIElement(io::IXMLWriter* writer, IGUIElement* node) =0;
//! reads an element
virtual void readGUIElement(io::IXMLReader* reader, IGUIElement* parent) =0;
};
} // end namespace gui
} // end namespace irr
#endif

View File

@ -0,0 +1,36 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_GUI_FILE_OPEN_DIALOG_H_INCLUDED__
#define __I_GUI_FILE_OPEN_DIALOG_H_INCLUDED__
#include "IGUIElement.h"
namespace irr
{
namespace gui
{
//! Standard file chooser dialog.
class IGUIFileOpenDialog : public IGUIElement
{
public:
//! constructor
IGUIFileOpenDialog(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
: IGUIElement(EGUIET_FILE_OPEN_DIALOG, environment, parent, id, rectangle) {}
//! destructor
virtual ~IGUIFileOpenDialog() {}
//! Returns the filename of the selected file. Returns NULL, if no file was selected.
virtual const wchar_t* getFileName() const = 0;
};
} // end namespace gui
} // end namespace irr
#endif

View File

@ -0,0 +1,95 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_GUI_FONT_H_INCLUDED__
#define __I_GUI_FONT_H_INCLUDED__
#include "IReferenceCounted.h"
#include "SColor.h"
#include "rect.h"
namespace irr
{
namespace gui
{
//! An enum for the different types of GUI font.
enum EGUI_FONT_TYPE
{
//! Bitmap fonts loaded from an XML file or a texture.
EGFT_BITMAP = 0,
//! Scalable vector fonts loaded from an XML file.
//! These fonts reside in system memory and use no video memory
//! until they are displayed. These are slower than bitmap fonts
//! but can be easily scaled and rotated.
EGFT_VECTOR,
//! A font which uses a the native API provided by the operating system.
//! Currently not used.
EGFT_OS,
//! An external font type provided by the user.
EGFT_CUSTOM
};
//! Font interface.
class IGUIFont : public virtual IReferenceCounted
{
public:
//! Destructor
virtual ~IGUIFont() {}
//! Draws an text and clips it to the specified rectangle if wanted.
/** \param text: Text to draw
\param position: Rectangle specifying position where to draw the text.
\param color: Color of the text
\param hcenter: Specifiies if the text should be centered horizontally into the rectangle.
\param vcenter: Specifiies if the text should be centered vertically into the rectangle.
\param clip: Optional pointer to a rectangle against which the text will be clipped.
If the pointer is null, no clipping will be done. */
virtual void draw(const wchar_t* text, const core::rect<s32>& position,
video::SColor color, bool hcenter=false, bool vcenter=false,
const core::rect<s32>* clip=0) = 0;
//! Calculates the dimension of a text.
/** \return Returns width and height of the area covered by the text if it would be
drawn. */
virtual core::dimension2d<s32> getDimension(const wchar_t* text) const = 0;
//! Calculates the index of the character in the text which is on a specific position.
/** \param text: Text string.
\param pixel_x: X pixel position of which the index of the character will be returned.
\return Returns zero based index of the character in the text, and -1 if no no character
is on this position. (=the text is too short). */
virtual s32 getCharacterFromPos(const wchar_t* text, s32 pixel_x) const = 0;
//! Returns the type of this font
virtual EGUI_FONT_TYPE getType() const { return EGFT_CUSTOM; }
//! Sets global kerning for the font.
virtual void setKerningWidth (s32 kerning) = 0;
virtual void setKerningHeight (s32 kerning) = 0;
//! Gets kerning values (distance between letters) for the font. If no parameters are provided,
/** the global kerning distance is returned.
\param thisLetter: If this parameter is provided, the left side kerning for this letter is added
to the global kerning value. For example, a space might only be one pixel wide, but it may
be displayed as several pixels.
\param previousLetter: If provided, kerning is calculated for both letters and added to the global
kerning value. For example, in a font which supports kerning pairs a string such as 'Wo' may have
the 'o' tucked neatly under the 'W'.
*/
virtual s32 getKerningWidth(const wchar_t* thisLetter=0, const wchar_t* previousLetter=0) const = 0;
//! Returns the distance between letters
virtual s32 getKerningHeight() const = 0;
};
} // end namespace gui
} // end namespace irr
#endif

View File

@ -0,0 +1,49 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_GUI_FONT_BITMAP_H_INCLUDED__
#define __I_GUI_FONT_BITMAP_H_INCLUDED__
#include "IGUIFont.h"
namespace irr
{
namespace gui
{
class IGUISpriteBank;
//! Font interface.
class IGUIFontBitmap : public IGUIFont
{
public:
//! Destructor
virtual ~IGUIFontBitmap() {}
//! Returns the type of this font
virtual EGUI_FONT_TYPE getType() const { return EGFT_BITMAP; }
//! returns the parsed Symbol Information
virtual IGUISpriteBank* getSpriteBank() const = 0;
//! returns the sprite number from a given character
virtual u32 getSpriteNoFromChar(const wchar_t *c) const = 0;
//! Gets kerning values (distance between letters) for the font. If no parameters are provided,
/** the global kerning distance is returned.
\param thisLetter: If this parameter is provided, the left side kerning for this letter is added
to the global kerning value. For example, a space might only be one pixel wide, but it may
be displayed as several pixels.
\param previousLetter: If provided, kerning is calculated for both letters and added to the global
kerning value. For example, EGFT_BITMAP will add the right kerning value of previousLetter to the
left side kerning value of thisLetter, then add the global value.
*/
virtual s32 getKerningWidth(const wchar_t* thisLetter=0, const wchar_t* previousLetter=0) const = 0;
};
} // end namespace gui
} // end namespace irr
#endif

View File

@ -0,0 +1,55 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_GUI_IMAGE_H_INCLUDED__
#define __I_GUI_IMAGE_H_INCLUDED__
#include "IGUIElement.h"
namespace irr
{
namespace video
{
class ITexture;
}
namespace gui
{
//! GUI element displaying an image.
class IGUIImage : public IGUIElement
{
public:
//! constructor
IGUIImage(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
: IGUIElement(EGUIET_IMAGE, environment, parent, id, rectangle) {}
//! destructor
virtual ~IGUIImage() {}
//! Sets an image
virtual void setImage(video::ITexture* image) = 0;
//! Sets the colour of the image
virtual void setColor(video::SColor color) = 0;
//! Sets if the image should scale to fit the element
virtual void setScaleImage(bool scale) = 0;
//! Sets if the image should use its alpha channel to draw itself
virtual void setUseAlphaChannel(bool use) = 0;
//! Returns true if the image is scaled to fit, false if not
virtual bool isImageScaled() const = 0;
//! Returns true if the image is using the alpha channel, false if not
virtual bool isAlphaChannelUsed() const = 0;
};
} // end namespace gui
} // end namespace irr
#endif

View File

@ -0,0 +1,69 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_GUI_IN_OUT_FADER_H_INCLUDED__
#define __I_GUI_IN_OUT_FADER_H_INCLUDED__
#include "IGUIElement.h"
#include "SColor.h"
namespace irr
{
namespace gui
{
//! Element for fading out or in
/** Here is a small example on how the class is used. In this example we fade
in from a total red screen in the beginning. As you can see, the fader is not
only useful for dramatic in and out fading, but also to show that the player
is hit in a first person shooter game for example.
\code
gui::IGUIInOutFader* fader = device->getGUIEnvironment()->addInOutFader();
fader->setColor(video::SColor(0,255,0,0));
fader->fadeIn(4000);
\endcode
*/
class IGUIInOutFader : public IGUIElement
{
public:
//! constructor
IGUIInOutFader(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
: IGUIElement(EGUIET_IN_OUT_FADER, environment, parent, id, rectangle) {}
//! destructor
virtual ~IGUIInOutFader() {}
//! Gets the color to fade out to or to fade in from.
virtual video::SColor getColor() const = 0;
//! Sets the color to fade out to or to fade in from.
//! \param color: Color to where it is faded out od from it is faded in.
virtual void setColor(video::SColor color) = 0;
virtual void setColor(video::SColor source, video::SColor dest) = 0;
//! Starts the fade in process. In the beginning the whole rect is drawn by
//! the set color (black by default) and at the end of the overgiven
//! time the color has faded out.
//! \param time: Time specifing how long it should need to fade in,
//! in milliseconds.
virtual void fadeIn(u32 time) = 0;
//! Starts the fade out process. In the beginning everything is visible,
//! and at the end of the time only the set color (black by the fault)
//! will be drawn.
//! \param time: Time specifing how long it should need to fade out,
//! in milliseconds.
virtual void fadeOut(u32 time) = 0;
//! Returns if the fade in or out process is done.
virtual bool isReady() const = 0;
};
} // end namespace gui
} // end namespace irr
#endif

View File

@ -0,0 +1,126 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_GUI_LIST_BOX_H_INCLUDED__
#define __I_GUI_LIST_BOX_H_INCLUDED__
#include "IGUIElement.h"
#include "SColor.h"
namespace irr
{
namespace gui
{
class IGUIFont;
class IGUISpriteBank;
//! Enumeration for listbox colors
enum EGUI_LISTBOX_COLOR
{
//! Color of text
EGUI_LBC_TEXT=0,
//! Color of selected text
EGUI_LBC_TEXT_HIGHLIGHT,
//! Color of icon
EGUI_LBC_ICON,
//! Color of selected icon
EGUI_LBC_ICON_HIGHLIGHT,
//! Not used, just counts the number of available colors
EGUI_LBC_COUNT
};
//! Default list box GUI element.
class IGUIListBox : public IGUIElement
{
public:
//! constructor
IGUIListBox(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
: IGUIElement(EGUIET_LIST_BOX, environment, parent, id, rectangle) {}
//! destructor
virtual ~IGUIListBox() {}
//! returns amount of list items
virtual u32 getItemCount() const = 0;
//! returns string of a list item. the may id be a value from 0 to itemCount-1
virtual const wchar_t* getListItem(u32 id) const = 0;
//! adds an list item, returns id of item
virtual u32 addItem(const wchar_t* text) = 0;
//! adds an list item with an icon
//! \param text Text of list entry
//! \param icon Sprite index of the Icon within the current sprite bank. Set it to -1 if you want no icon
//! \return
//! returns the id of the new created item
virtual u32 addItem(const wchar_t* text, s32 icon) = 0;
//! Removes an item from the list
virtual void removeItem(u32 index) = 0;
//! Returns the icon of an item
virtual s32 getIcon(u32 index) const = 0;
//! Sets the sprite bank which should be used to draw list icons. This font is set to the sprite bank of
//! the built-in-font by default. A sprite can be displayed in front of every list item.
//! An icon is an index within the icon sprite bank. Several default icons are available in the
//! skin through getIcon
virtual void setSpriteBank(IGUISpriteBank* bank) = 0;
//! clears the list, deletes all items in the listbox
virtual void clear() = 0;
//! returns id of selected item. returns -1 if no item is selected.
virtual s32 getSelected() const = 0;
//! sets the selected item. Set this to -1 if no item should be selected
virtual void setSelected(s32 index) = 0;
//! set whether the listbox should scroll to show a newly selected item
//! or a new item as it is added to the list.
virtual void setAutoScrollEnabled(bool scroll) = 0;
//! returns true if automatic scrolling is enabled, false if not.
virtual bool isAutoScrollEnabled() const = 0;
//! set all item colors at given index to color
virtual void setItemOverrideColor(u32 index, const video::SColor &color) = 0;
//! set all item colors of specified type at given index to color
virtual void setItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType, const video::SColor &color) = 0;
//! clear all item colors at index
virtual void clearItemOverrideColor(u32 index) = 0;
//! clear item color at index for given colortype
virtual void clearItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType) = 0;
//! has the item at index it's color overwritten?
virtual bool hasItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType) const = 0;
//! return the overwrite color at given item index.
virtual video::SColor getItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType) const = 0;
//! return the default color which is used for the given colorType
virtual video::SColor getItemDefaultColor(EGUI_LISTBOX_COLOR colorType) const = 0;
//! set the item at the given index
virtual void setItem(u32 index, const wchar_t* text, s32 icon) = 0;
//! Insert the item at the given index
//! Return the index on success or -1 on failure.
virtual s32 insertItem(u32 index, const wchar_t* text, s32 icon) = 0;
//! Swap the items at the given indices
virtual void swapItems(u32 index1, u32 index2) = 0;
};
} // end namespace gui
} // end namespace irr
#endif

View File

@ -0,0 +1,56 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_GUI_MESH_VIEWER_H_INCLUDED__
#define __I_GUI_MESH_VIEWER_H_INCLUDED__
#include "IGUIElement.h"
namespace irr
{
namespace video
{
class SMaterial;
} // end namespace video
namespace scene
{
class IAnimatedMesh;
} // end namespace scene
namespace gui
{
//! 3d mesh viewing GUI element.
class IGUIMeshViewer : public IGUIElement
{
public:
//! constructor
IGUIMeshViewer(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
: IGUIElement(EGUIET_MESH_VIEWER, environment, parent, id, rectangle) {}
//! destructor
virtual ~IGUIMeshViewer() {}
//! Sets the mesh to be shown
virtual void setMesh(scene::IAnimatedMesh* mesh) = 0;
//! Gets the displayed mesh
virtual scene::IAnimatedMesh* getMesh() const = 0;
//! Sets the material
virtual void setMaterial(const video::SMaterial& material) = 0;
//! Gets the material
virtual const video::SMaterial& getMaterial() const = 0;
};
} // end namespace gui
} // end namespace irr
#endif

View File

@ -0,0 +1,59 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_GUI_SCROLL_BAR_H_INCLUDED__
#define __I_GUI_SCROLL_BAR_H_INCLUDED__
#include "IGUIElement.h"
namespace irr
{
namespace gui
{
//! Default scroll bar GUI element.
class IGUIScrollBar : public IGUIElement
{
public:
//! constructor
IGUIScrollBar(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
: IGUIElement(EGUIET_SCROLL_BAR, environment, parent, id, rectangle) {}
//! destructor
~IGUIScrollBar() {};
//! gets the maximum value of the scrollbar.
virtual s32 getMax() const = 0;
//! sets the maximum value of the scrollbar.
virtual void setMax(s32 max) = 0;
//! gets the small step value
virtual s32 getSmallStep() const = 0;
//! Sets the small step, the amount that the value changes by when clicking
//! on the buttons or using the cursor keys.
virtual void setSmallStep(s32 step) = 0;
//! gets the large step value
virtual s32 getLargeStep() const = 0;
//! Sets the large step, the amount that the value changes by when clicking
//! in the tray, or using the page up and page down keys.
virtual void setLargeStep(s32 step) = 0;
//! gets the current position of the scrollbar
virtual s32 getPos() const = 0;
//! sets the current position of the scrollbar
virtual void setPos(s32 pos) = 0;
};
} // end namespace gui
} // end namespace irr
#endif

View File

@ -0,0 +1,515 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_GUI_SKIN_H_INCLUDED__
#define __I_GUI_SKIN_H_INCLUDED__
#include "IAttributeExchangingObject.h"
#include "SColor.h"
#include "rect.h"
namespace irr
{
namespace gui
{
class IGUIFont;
class IGUISpriteBank;
class IGUIElement;
//! Enumeration of available default skins.
/** To set one of the skins, use the following code, for example to set
the Windows classic skin:
\code
gui::IGUISkin* newskin = environment->createSkin(gui::EGST_WINDOWS_CLASSIC);
environment->setSkin(newskin);
newskin->drop();
\endcode
*/
enum EGUI_SKIN_TYPE
{
//! Default windows look and feel
EGST_WINDOWS_CLASSIC=0,
//! Like EGST_WINDOWS_CLASSIC, but with metallic shaded windows and buttons
EGST_WINDOWS_METALLIC,
//! Burning's skin
EGST_BURNING_SKIN,
//! An unknown skin, not serializable at present
EGST_UNKNOWN
};
//! Names for gui element types
const c8* const GUISkinTypeNames[] =
{
"windowsClassic",
"windowsMetallic",
"burning",
"unknown",
0,
};
//! Enumeration for skin colors
enum EGUI_DEFAULT_COLOR
{
//! Dark shadow for three-dimensional display elements.
EGDC_3D_DARK_SHADOW = 0,
//! Shadow color for three-dimensional display elements (for edges facing away from the light source).
EGDC_3D_SHADOW,
//! Face color for three-dimensional display elements and for dialog box backgrounds.
EGDC_3D_FACE,
//! Highlight color for three-dimensional display elements (for edges facing the light source.)
EGDC_3D_HIGH_LIGHT,
//! Light color for three-dimensional display elements (for edges facing the light source.)
EGDC_3D_LIGHT,
//! Active window border.
EGDC_ACTIVE_BORDER,
//! Active window title bar text.
EGDC_ACTIVE_CAPTION,
//! Background color of multiple document interface (MDI) applications.
EGDC_APP_WORKSPACE,
//! Text on a button
EGDC_BUTTON_TEXT,
//! Grayed (disabled) text.
EGDC_GRAY_TEXT,
//! Item(s) selected in a control.
EGDC_HIGH_LIGHT,
//! Text of item(s) selected in a control.
EGDC_HIGH_LIGHT_TEXT,
//! Inactive window border.
EGDC_INACTIVE_BORDER,
//! Inactive window caption.
EGDC_INACTIVE_CAPTION,
//! Tool tip text color
EGDC_TOOLTIP,
//! Tool tip background color
EGDC_TOOLTIP_BACKGROUND,
//! Scrollbar gray area
EGDC_SCROLLBAR,
//! Window background
EGDC_WINDOW,
//! Window symbols like on close buttons, scroll bars and check boxes
EGDC_WINDOW_SYMBOL,
//! Icons in a list or tree
EGDC_ICON,
//! Selected icons in a list or tree
EGDC_ICON_HIGH_LIGHT,
//! this value is not used, it only specifies the amount of default colors
//! available.
EGDC_COUNT
};
//! Names for default skin colors
const c8* const GUISkinColorNames[] =
{
"3DDarkShadow",
"3DShadow",
"3DFace",
"3DHighlight",
"3DLight",
"ActiveBorder",
"ActiveCaption",
"AppWorkspace",
"ButtonText",
"GrayText",
"Highlight",
"HighlightText",
"InactiveBorder",
"InactiveCaption",
"ToolTip",
"ToolTipBackground",
"ScrollBar",
"Window",
"WindowSymbol",
"Icon",
"IconHighlight",
0,
};
//! Enumeration for default sizes.
enum EGUI_DEFAULT_SIZE
{
//! default with / height of scrollbar
EGDS_SCROLLBAR_SIZE = 0,
//! height of menu
EGDS_MENU_HEIGHT,
//! width of a window button
EGDS_WINDOW_BUTTON_WIDTH,
//! width of a checkbox check
EGDS_CHECK_BOX_WIDTH,
//! width of a messagebox
EGDS_MESSAGE_BOX_WIDTH,
//! height of a messagebox
EGDS_MESSAGE_BOX_HEIGHT,
//! width of a default button
EGDS_BUTTON_WIDTH,
//! height of a default button
EGDS_BUTTON_HEIGHT,
//! distance for text from background
EGDS_TEXT_DISTANCE_X,
//! distance for text from background
EGDS_TEXT_DISTANCE_Y,
//! this value is not used, it only specifies the amount of default sizes
//! available.
EGDS_COUNT
};
//! Names for default skin sizes
const c8* const GUISkinSizeNames[] =
{
"ScrollBarSize",
"MenuHeight",
"WindowButtonWidth",
"CheckBoxWidth",
"MessageBoxWidth",
"MessageBoxHeight",
"ButtonWidth",
"ButtonHeight",
"TextDistanceX",
"TextDistanceY",
0,
};
enum EGUI_DEFAULT_TEXT
{
//! Text for the OK button on a message box
EGDT_MSG_BOX_OK = 0,
//! Text for the Cancel button on a message box
EGDT_MSG_BOX_CANCEL,
//! Text for the Yes button on a message box
EGDT_MSG_BOX_YES,
//! Text for the No button on a message box
EGDT_MSG_BOX_NO,
//! Tooltip text for window close button
EGDT_WINDOW_CLOSE,
//! Tooltip text for window maximize button
EGDT_WINDOW_MAXIMIZE,
//! Tooltip text for window minimize button
EGDT_WINDOW_MINIMIZE,
//! Tooltip text for window restore button
EGDT_WINDOW_RESTORE,
//! this value is not used, it only specifies the number of default texts
EGDT_COUNT
};
//! Names for default skin sizes
const c8* const GUISkinTextNames[] =
{
"MessageBoxOkay",
"MessageBoxCancel",
"MessageBoxYes",
"MessageBoxNo",
"WindowButtonClose",
"WindowButtonMaximize",
"WindowButtonMinimize",
"WindowButtonRestore",
0,
};
//! Customizable symbols for GUI
enum EGUI_DEFAULT_ICON
{
//! maximize window button
EGDI_WINDOW_MAXIMIZE = 0,
//! restore window button
EGDI_WINDOW_RESTORE,
//! close window button
EGDI_WINDOW_CLOSE,
//! minimize window button
EGDI_WINDOW_MINIMIZE,
//! resize icon for bottom right corner of a window
EGDI_WINDOW_RESIZE,
//! scroll bar up button
EGDI_CURSOR_UP,
//! scroll bar down button
EGDI_CURSOR_DOWN,
//! scroll bar left button
EGDI_CURSOR_LEFT,
//! scroll bar right button
EGDI_CURSOR_RIGHT,
//! icon for menu children
EGDI_MENU_MORE,
//! tick for checkbox
EGDI_CHECK_BOX_CHECKED,
//! down arrow for dropdown menus
EGDI_DROP_DOWN,
//! smaller up arrow
EGDI_SMALL_CURSOR_UP,
//! smaller down arrow
EGDI_SMALL_CURSOR_DOWN,
//! selection dot in a radio button
EGDI_RADIO_BUTTON_CHECKED,
//! << icon indicating there is more content to the left
EGDI_MORE_LEFT,
//! >> icon indicating that there is more content to the right
EGDI_MORE_RIGHT,
//! icon indicating that there is more content above
EGDI_MORE_UP,
//! icon indicating that there is more content below
EGDI_MORE_DOWN,
//! plus icon for trees
EGDI_EXPAND,
//! minus icon for trees
EGDI_COLLAPSE,
//! file icon for file selection
EGDI_FILE,
//! folder icon for file selection
EGDI_DIRECTORY,
//! value not used, it only specifies the number of icons
EGDI_COUNT
};
const c8* const GUISkinIconNames[] =
{
"windowMaximize",
"windowRestore",
"windowClose",
"windowMinimize",
"windowResize",
"cursorUp",
"cursorDown",
"cursorLeft",
"cursorRight",
"menuMore",
"checkBoxChecked",
"dropDown",
"smallCursorUp",
"smallCursorDown",
"radioButtonChecked",
"moreLeft",
"moreRight",
"moreUp",
"moreDown",
"expand",
"collapse",
"file",
"directory",
0
};
// Customizable fonts
enum EGUI_DEFAULT_FONT
{
//! For static text, edit boxes, lists and most other places
EGDF_DEFAULT=0,
//! Font for buttons
EGDF_BUTTON,
//! Font for window title bars
EGDF_WINDOW,
//! Font for menu items
EGDF_MENU,
//! Font for tooltips
EGDF_TOOLTIP,
//! this value is not used, it only specifies the amount of default fonts
//! available.
EGDF_COUNT
};
const c8* const GUISkinFontNames[] =
{
"defaultFont",
"buttonFont",
"windowFont",
"menuFont",
"tooltipFont",
0
};
//! A skin modifies the look of the GUI elements.
class IGUISkin : public virtual io::IAttributeExchangingObject
{
public:
//! destructor
virtual ~IGUISkin() {};
//! returns default color
virtual video::SColor getColor(EGUI_DEFAULT_COLOR color) const = 0;
//! sets a default color
virtual void setColor(EGUI_DEFAULT_COLOR which, video::SColor newColor) = 0;
//! returns size for the given size type
virtual s32 getSize(EGUI_DEFAULT_SIZE size) const = 0;
//! Returns a default text.
/** For example for Message box button captions:
"OK", "Cancel", "Yes", "No" and so on. */
virtual const wchar_t* getDefaultText(EGUI_DEFAULT_TEXT text) const = 0;
//! Sets a default text.
/** For example for Message box button captions:
"OK", "Cancel", "Yes", "No" and so on. */
virtual void setDefaultText(EGUI_DEFAULT_TEXT which, const wchar_t* newText) = 0;
//! sets a default size
virtual void setSize(EGUI_DEFAULT_SIZE which, s32 size) = 0;
//! returns the default font
virtual IGUIFont* getFont(EGUI_DEFAULT_FONT which=EGDF_DEFAULT) const = 0;
//! sets a default font
virtual void setFont(IGUIFont* font, EGUI_DEFAULT_FONT which=EGDF_DEFAULT) = 0;
//! returns the sprite bank
virtual IGUISpriteBank* getSpriteBank() const = 0;
//! sets the sprite bank
virtual void setSpriteBank(IGUISpriteBank* bank) = 0;
//! Returns a default icon
/** Returns the sprite index within the sprite bank */
virtual u32 getIcon(EGUI_DEFAULT_ICON icon) const = 0;
//! Sets a default icon
/** Sets the sprite index used for drawing icons like arrows,
close buttons and ticks in checkboxes
\param icon: Enum specifying which icon to change
\param index: The sprite index used to draw this icon */
virtual void setIcon(EGUI_DEFAULT_ICON icon, u32 index) = 0;
//! draws a standard 3d button pane
/** Used for drawing for example buttons in normal state.
It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and
EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details.
\param element: Pointer to the element which wishes to draw this. This parameter
is usually not used by IGUISkin, but can be used for example by more complex
implementations to find out how to draw the part exactly.
\param rect: Defining area where to draw.
\param clip: Clip area. */
virtual void draw3DButtonPaneStandard(IGUIElement* element,
const core::rect<s32>& rect,
const core::rect<s32>* clip=0) = 0;
//! draws a pressed 3d button pane
/** Used for drawing for example buttons in pressed state.
It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and
EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details.
\param element: Pointer to the element which wishes to draw this. This parameter
is usually not used by IGUISkin, but can be used for example by more complex
implementations to find out how to draw the part exactly.
\param rect: Defining area where to draw.
\param clip: Clip area. */
virtual void draw3DButtonPanePressed(IGUIElement* element,
const core::rect<s32>& rect,
const core::rect<s32>* clip=0) = 0;
//! draws a sunken 3d pane
/** Used for drawing the background of edit, combo or check boxes.
\param element: Pointer to the element which wishes to draw this. This parameter
is usually not used by IGUISkin, but can be used for example by more complex
implementations to find out how to draw the part exactly.
\param bgcolor: Background color.
\param flat: Specifies if the sunken pane should be flat or displayed as sunken
deep into the ground.
\param fillBackGround: Specifies if the background should be filled with the background
color or not be drawn at all.
\param rect: Defining area where to draw.
\param clip: Clip area. */
virtual void draw3DSunkenPane(IGUIElement* element,
video::SColor bgcolor, bool flat, bool fillBackGround,
const core::rect<s32>& rect,
const core::rect<s32>* clip=0) = 0;
//! draws a window background
/** Used for drawing the background of dialogs and windows.
\param element: Pointer to the element which wishes to draw this. This parameter
is usually not used by IGUISkin, but can be used for example by more complex
implementations to find out how to draw the part exactly.
\param titleBarColor: Title color.
\param drawTitleBar: True to enable title drawing.
\param rect: Defining area where to draw.
\param clip: Clip area.
\return Returns rect where it would be good to draw title bar text. */
virtual core::rect<s32> draw3DWindowBackground(IGUIElement* element,
bool drawTitleBar, video::SColor titleBarColor,
const core::rect<s32>& rect,
const core::rect<s32>* clip=0) = 0;
//! draws a standard 3d menu pane
/** Used for drawing for menus and context menus.
It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and
EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details.
\param element: Pointer to the element which wishes to draw this. This parameter
is usually not used by IGUISkin, but can be used for example by more complex
implementations to find out how to draw the part exactly.
\param rect: Defining area where to draw.
\param clip: Clip area. */
virtual void draw3DMenuPane(IGUIElement* element,
const core::rect<s32>& rect,
const core::rect<s32>* clip=0) = 0;
//! draws a standard 3d tool bar
/** Used for drawing for toolbars and menus.
\param element: Pointer to the element which wishes to draw this. This parameter
is usually not used by IGUISkin, but can be used for example by more complex
implementations to find out how to draw the part exactly.
\param rect: Defining area where to draw.
\param clip: Clip area. */
virtual void draw3DToolBar(IGUIElement* element,
const core::rect<s32>& rect,
const core::rect<s32>* clip=0) = 0;
//! draws a tab button
/** Used for drawing for tab buttons on top of tabs.
\param element: Pointer to the element which wishes to draw this. This parameter
is usually not used by IGUISkin, but can be used for example by more complex
implementations to find out how to draw the part exactly.
\param active: Specifies if the tab is currently active.
\param rect: Defining area where to draw.
\param clip: Clip area. */
virtual void draw3DTabButton(IGUIElement* element, bool active,
const core::rect<s32>& rect, const core::rect<s32>* clip=0) = 0;
//! draws a tab control body
/** \param element: Pointer to the element which wishes to draw this. This parameter
is usually not used by IGUISkin, but can be used for example by more complex
implementations to find out how to draw the part exactly.
\param border: Specifies if the border should be drawn.
\param background: Specifies if the background should be drawn.
\param rect: Defining area where to draw.
\param clip: Clip area. */
virtual void draw3DTabBody(IGUIElement* element, bool border, bool background,
const core::rect<s32>& rect, const core::rect<s32>* clip=0) = 0;
//! draws an icon, usually from the skin's sprite bank
/** \param element: Pointer to the element which wishes to draw this icon.
This parameter is usually not used by IGUISkin, but can be used for example
by more complex implementations to find out how to draw the part exactly.
\param icon: Specifies the icon to be drawn.
\param position: The position to draw the icon
\param starttime: The time at the start of the animation
\param currenttime: The present time, used to calculate the frame number
\param loop: Whether the animation should loop or not
\param clip: Clip area. */
virtual void drawIcon(IGUIElement* element, EGUI_DEFAULT_ICON icon,
const core::position2di position, u32 starttime=0, u32 currenttime=0,
bool loop=false, const core::rect<s32>* clip=0) = 0;
//! draws a 2d rectangle.
/** \param element: Pointer to the element which wishes to draw this icon.
This parameter is usually not used by IGUISkin, but can be used for example
by more complex implementations to find out how to draw the part exactly.
\param color: Color of the rectangle to draw. The alpha component specifies how
transparent the rectangle will be.
\param pos: Position of the rectangle.
\param clip: Pointer to rectangle against which the rectangle will be clipped.
If the pointer is null, no clipping will be performed. */
virtual void draw2DRectangle(IGUIElement* element, const video::SColor &color,
const core::rect<s32>& pos, const core::rect<s32>* clip = 0) = 0;
//! get the type of this skin
virtual EGUI_SKIN_TYPE getType() const { return EGST_UNKNOWN; };
};
} // end namespace gui
} // end namespace irr
#endif

View File

@ -0,0 +1,70 @@
// Copyright (C) 2006 Michael Zeilfelder
// This file uses the licence of the Irrlicht Engine.
#ifndef __I_GUI_SPIN_BOX_H_INCLUDED__
#define __I_GUI_SPIN_BOX_H_INCLUDED__
#include "IGUIElement.h"
namespace irr
{
namespace gui
{
class IGUIEditBox;
//! Single line edit box + spin buttons
class IGUISpinBox : public IGUIElement
{
public:
//! constructor
IGUISpinBox(IGUIEnvironment* environment, IGUIElement* parent,
s32 id, core::rect<s32> rectangle)
: IGUIElement(EGUIET_SPIN_BOX, environment, parent, id, rectangle) {}
//! destructor
virtual ~IGUISpinBox() {}
//! Access the edit box used in the spin control
/** \param enable: If set to true, the override color, which can be set
with IGUIEditBox::setOverrideColor is used, otherwise the
EGDC_BUTTON_TEXT color of the skin. */
virtual IGUIEditBox* getEditBox() const = 0;
//! set the current value of the spinbox
/** \param val: value to be set in the spinbox */
virtual void setValue(f32 val) = 0;
//! Get the current value of the spinbox
virtual f32 getValue() const = 0;
//! set the range of values which can be used in the spinbox
/** \param min: minimum value
\param max: maximum value */
virtual void setRange(f32 min, f32 max) = 0;
//! get the minimum value which can be used in the spinbox
virtual f32 getMin() const = 0;
//! get the maximum value which can be used in the spinbox
virtual f32 getMax() const = 0;
//! Step size by which values are changed when pressing the spinbuttons
/** The step size also determines the number of decimal places to display
\param step: stepsize used for value changes when pressing spinbuttons */
virtual void setStepSize(f32 step=1.f) = 0;
//! Sets the number of decimal places to display.
/** \param places: The number of decimal places to display, use -1 to reset */
virtual void setDecimalPlaces(s32 places) = 0;
//! get the current step size
virtual f32 getStepSize() const = 0;
};
} // end namespace gui
} // end namespace irr
#endif // __I_GUI_SPIN_BOX_H_INCLUDED__

View File

@ -0,0 +1,73 @@
#ifndef __I_GUI_SPRITE_BANK_H_INCLUDED__
#define __I_GUI_SPRITE_BANK_H_INCLUDED__
#include "IReferenceCounted.h"
#include "irrArray.h"
#include "SColor.h"
#include "rect.h"
namespace irr
{
namespace video
{
class ITexture;
} // end namespace video
namespace gui
{
struct SGUISpriteFrame
{
u32 textureNumber;
u32 rectNumber;
};
struct SGUISprite
{
SGUISprite() : Frames(), frameTime(0) { };
core::array<SGUISpriteFrame> Frames;
u32 frameTime;
};
//! Sprite bank interface.
class IGUISpriteBank : public virtual IReferenceCounted
{
public:
//! Destructor
virtual ~IGUISpriteBank() {}
//! Returns the list of rectangles held by the sprite bank
virtual core::array< core::rect<s32> >& getPositions() = 0;
//! Returns the array of animated sprites within the sprite bank
virtual core::array< SGUISprite >& getSprites() = 0;
//! Returns the number of textures held by the sprite bank
virtual u32 getTextureCount() const = 0;
//! Gets the texture with the specified index
virtual video::ITexture* getTexture(u32 index) const = 0;
//! Adds a texture to the sprite bank
virtual void addTexture(video::ITexture* texture) = 0;
//! Changes one of the textures in the sprite bank
virtual void setTexture(u32 index, video::ITexture* texture) = 0;
//! Draws a sprite in 2d with position and color
virtual void draw2DSprite(u32 index, const core::position2di& pos, const core::rect<s32>* clip=0,
const video::SColor& color= video::SColor(255,255,255,255),
u32 starttime=0, u32 currenttime=0, bool loop=true, bool center=false) = 0;
};
} // end namespace gui
} // end namespace irr
#endif // __I_GUI_SPRITE_BANK_H_INCLUDED__

View File

@ -0,0 +1,104 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_GUI_STATIC_TEXT_H_INCLUDED__
#define __I_GUI_STATIC_TEXT_H_INCLUDED__
#include "IGUIElement.h"
#include "SColor.h"
namespace irr
{
namespace gui
{
class IGUIFont;
//! Multi or single line text label.
class IGUIStaticText : public IGUIElement
{
public:
//! constructor
IGUIStaticText(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
: IGUIElement(EGUIET_STATIC_TEXT, environment, parent, id, rectangle) {}
//! destructor
virtual ~IGUIStaticText() {}
//! Sets another skin independent font.
/** If this is set to zero, the button uses the font of the skin.
\param font: New font to set. */
virtual void setOverrideFont(IGUIFont* font=0) = 0;
//! Gets the override font (if any)
//! \return The override font (may be 0)
virtual IGUIFont* getOverrideFont(void) const = 0;
//! Sets another color for the text.
/** If set, the static text does not use the EGDC_BUTTON_TEXT color defined
in the skin, but the set color instead. You don't need to call
IGUIStaticText::enableOverrrideColor(true) after this, this is done
by this function.
If you set a color, and you want the text displayed with the color
of the skin again, call IGUIStaticText::enableOverrideColor(false);
\param color: New color of the text. */
virtual void setOverrideColor(video::SColor color) = 0;
//! Gets the override color
//! \return: The override color
virtual video::SColor const& getOverrideColor(void) const = 0;
//! Sets if the static text should use the overide color or the color in the gui skin.
/** \param enable: If set to true, the override color, which can be set
with IGUIStaticText::setOverrideColor is used, otherwise the
EGDC_BUTTON_TEXT color of the skin. */
virtual void enableOverrideColor(bool enable) = 0;
//! Checks if an override color is enabled
//! \return true if the override color is enabled, false otherwise
virtual bool isOverrideColorEnabled(void) const = 0;
//! Sets another color for the background.
virtual void setBackgroundColor(video::SColor color) = 0;
//! Sets whether to draw the background
virtual void setDrawBackground(bool draw) = 0;
//! Sets whether to draw the border
virtual void setDrawBorder(bool draw) = 0;
//! Sets text justification mode
/** \param horizontal: EGUIA_UPPERLEFT for left justified (default),
EGUIA_LOWEERRIGHT for right justified, or EGUIA_CENTER for centered text.
\param vertical: EGUIA_UPPERLEFT to align with top edge,
EGUIA_LOWEERRIGHT for bottom edge, or EGUIA_CENTER for centered text (default). */
virtual void setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical) = 0;
//! Enables or disables word wrap for using the static text as multiline text control.
/** \param enable: If set to true, words going over one line are
broken on to the next line. */
virtual void setWordWrap(bool enable) = 0;
//! Checks if word wrap is enabled
//! \return true if word wrap is enabled, false otherwise
virtual bool isWordWrapEnabled(void) const = 0;
//! Returns the height of the text in pixels when it is drawn.
/** This is useful for adjusting the layout of gui elements based on the height
of the multiline text in this element.
\return Returns height of text in pixels. */
virtual s32 getTextHeight() const = 0;
//! Returns the width of the current text, in the current font
/** If the text is broken, this returns the width of the widest line
\return The width of the text, or the widest broken line. */
virtual s32 getTextWidth(void) const = 0;
};
} // end namespace gui
} // end namespace irr
#endif

View File

@ -0,0 +1,87 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_GUI_TAB_CONTROL_H_INCLUDED__
#define __I_GUI_TAB_CONTROL_H_INCLUDED__
#include "IGUIElement.h"
#include "SColor.h"
namespace irr
{
namespace gui
{
//! A tab, onto which other gui elements could be added.
class IGUITab : public IGUIElement
{
public:
//! constructor
IGUITab(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
: IGUIElement(EGUIET_TAB, environment, parent, id, rectangle) {}
//! destructor
virtual ~IGUITab() {}
//! Returns number of tab if in tabcontrol.
/** Can be accessed later IGUITabControl::getTab() by this number. */
virtual s32 getNumber() const = 0;
//! sets if the tab should draw its background
virtual void setDrawBackground(bool draw=true) = 0;
//! sets the color of the background, if it should be drawn.
virtual void setBackgroundColor(video::SColor c) = 0;
//! returns true if the tab is drawing its background, false if not
virtual bool isDrawingBackground() const = 0;
//! returns the color of the background
virtual video::SColor getBackgroundColor() const = 0;
};
//! A standard tab control
class IGUITabControl : public IGUIElement
{
public:
//! constructor
IGUITabControl(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
: IGUIElement(EGUIET_TAB_CONTROL, environment, parent, id, rectangle) {}
//! destructor
virtual ~IGUITabControl() {}
//! Adds a tab
virtual IGUITab* addTab(const wchar_t* caption, s32 id=-1) = 0;
//! Returns amount of tabs in the tabcontrol
virtual s32 getTabCount() const = 0;
//! Returns a tab based on zero based index
/** \param idx: zero based index of tab. Is a value betwenn 0 and getTabcount()-1;
\return Returns pointer to the Tab. Returns 0 if no tab
is corresponding to this tab. */
virtual IGUITab* getTab(s32 idx) const = 0;
//! Brings a tab to front.
/** \param idx: number of the tab.
\return Returns true if successful. */
virtual bool setActiveTab(s32 idx) = 0;
//! Brings a tab to front.
/** \param tab: pointer to the tab.
\return Returns true if successful. */
virtual bool setActiveTab(IGUIElement *tab) = 0;
//! Returns which tab is currently active
virtual s32 getActiveTab() const = 0;
};
} // end namespace gui
} // end namespace irr
#endif

View File

@ -0,0 +1,43 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_GUI_TOOL_BAR_H_INCLUDED__
#define __I_GUI_TOOL_BAR_H_INCLUDED__
#include "IGUIElement.h"
namespace irr
{
namespace video
{
class ITexture;
} // end namespace video
namespace gui
{
class IGUIButton;
//! Stays at the top of its parent like the menu bar and contains tool buttons
class IGUIToolBar : public IGUIElement
{
public:
//! constructor
IGUIToolBar(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
: IGUIElement(EGUIET_TOOL_BAR, environment, parent, id, rectangle) {}
//! destructor
virtual ~IGUIToolBar() {}
//! Adds a button to the tool bar
virtual IGUIButton* addButton(s32 id=-1, const wchar_t* text=0,const wchar_t* tooltiptext=0,
video::ITexture* img=0, video::ITexture* pressedimg=0,
bool isPushButton=false, bool useAlphaChannel=false) = 0;
};
} // end namespace gui
} // end namespace irr
#endif

View File

@ -0,0 +1,44 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_GUI_WINDOW_H_INCLUDED__
#define __I_GUI_WINDOW_H_INCLUDED__
#include "IGUIElement.h"
#include "EMessageBoxFlags.h"
namespace irr
{
namespace gui
{
class IGUIButton;
//! Default moveable window GUI element with border, caption and close icons.
class IGUIWindow : public IGUIElement
{
public:
//! constructor
IGUIWindow(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
: IGUIElement(EGUIET_WINDOW, environment, parent, id, rectangle) {}
//! destructor
virtual ~IGUIWindow() {}
//! Returns pointer to the close button
virtual IGUIButton* getCloseButton() const = 0;
//! Returns pointer to the minimize button
virtual IGUIButton* getMinimizeButton() const = 0;
//! Returns pointer to the maximize button
virtual IGUIButton* getMaximizeButton() const = 0;
};
} // end namespace gui
} // end namespace irr
#endif

View File

@ -0,0 +1,113 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_IMAGE_H_INCLUDED__
#define __I_IMAGE_H_INCLUDED__
#include "IReferenceCounted.h"
#include "position2d.h"
#include "SColor.h"
namespace irr
{
namespace video
{
//! An enum for the color format of textures used by the Irrlicht Engine.
/** A color format specifies how color information is stored. */
enum ECOLOR_FORMAT
{
//! 16 bit color format used by the software driver, and thus preferred
//! by all other irrlicht engine video drivers. There are 5 bits for every
//! color component, and a single bit is left for alpha information.
ECF_A1R5G5B5 = 0,
//! Standard 16 bit color format.
ECF_R5G6B5,
//! 24 bit color, no alpha channel, but 8 bit for red, green and blue.
ECF_R8G8B8,
//! Default 32 bit color format. 8 bits are used for every component:
//! red, green, blue and alpha.
ECF_A8R8G8B8
};
//! Interface for software image data.
/** Image loaders create these images from files. IVideoDrivers convert
these images into their (hardware) textures.
*/
class IImage : public virtual IReferenceCounted
{
public:
//! destructor
virtual ~IImage() {}
//! Lock function. Use this to get a pointer to the image data. After you
//! don't need the pointer anymore, you must call unlock().
//! \return Returns pointer to the image data. What type of data
//! is pointed to depends on the color format of the image. For example
//! if the color format is ECF_A8R8G8B8, it is of u32.
//! Be sure to call unlock() after you don't need the pointer any more.
virtual void* lock() = 0;
//! Unlock function.
//! Should be called after the pointer received by lock() is not
//! needed anymore.
virtual void unlock() = 0;
//! Returns width and height of image data.
virtual const core::dimension2d<s32>& getDimension() const = 0;
//! Returns bits per pixel.
virtual u32 getBitsPerPixel() const = 0;
//! Returns bytes per pixel
virtual u32 getBytesPerPixel() const = 0;
//! Returns image data size in bytes
virtual u32 getImageDataSizeInBytes() const = 0;
//! Returns image data size in pixels
virtual u32 getImageDataSizeInPixels() const = 0;
//! returns a pixel
virtual SColor getPixel(u32 x, u32 y) const = 0;
//! sets a pixel
virtual void setPixel(u32 x, u32 y, const SColor &color ) = 0;
//! returns the color format
virtual ECOLOR_FORMAT getColorFormat() const = 0;
//! returns mask for red value of a pixel
virtual u32 getRedMask() const = 0;
//! returns mask for green value of a pixel
virtual u32 getGreenMask() const = 0;
//! returns mask for blue value of a pixel
virtual u32 getBlueMask() const = 0;
//! returns mask for alpha value of a pixel
virtual u32 getAlphaMask() const = 0;
//! returns pitch of image
virtual u32 getPitch() const = 0;
//! copies the image into the target, scaling the image to fit
virtual void copyToScaling(void* target, s32 width, s32 height, ECOLOR_FORMAT format=ECF_A8R8G8B8, u32 pitch=0) = 0;
//! copies the image into the target, scaling the image to fit
virtual void copyToScaling(IImage* target) = 0;
};
} // end namespace video
} // end namespace irr
#endif

View File

@ -0,0 +1,48 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_SURFACE_LOADER_H_INCLUDED__
#define __I_SURFACE_LOADER_H_INCLUDED__
#include "IReferenceCounted.h"
#include "IImage.h"
namespace irr
{
namespace io
{
class IReadFile;
} // end namespace io
namespace video
{
//! Class which is able to create a image from a file.
/** If you want the Irrlicht Engine be able to load textures of
currently unsupported file formats (e.g .gif), then implement
this and add your new Surface loader with
IVideoDriver::addExternalImageLoader() to the engine. */
class IImageLoader : public virtual IReferenceCounted
{
public:
//! destructor
virtual ~IImageLoader() {}
//! returns true if the file maybe is able to be loaded by this class
//! based on the file extension (e.g. ".tga")
virtual bool isALoadableFileExtension(const c8* fileName) const = 0;
//! returns true if the file maybe is able to be loaded by this class
virtual bool isALoadableFileFormat(io::IReadFile* file) const = 0;
//! creates a surface from the file
virtual IImage* loadImage(io::IReadFile* file) const = 0;
};
} // end namespace video
} // end namespace irr
#endif

View File

@ -0,0 +1,36 @@
#ifndef _I_IMAGE_WRITER_H_INCLUDED__
#define _I_IMAGE_WRITER_H_INCLUDED__
#include "IReferenceCounted.h"
namespace irr
{
namespace io
{
class IWriteFile;
} // end namespace io
namespace video
{
class IImage;
//! Interface for writing software image data.
class IImageWriter : public IReferenceCounted
{
public:
//! destructor
virtual ~IImageWriter() { }
//! return true if this writer can write a file with the given extension
virtual bool isAWriteableFileExtension(const c8* fileName) const = 0;
//! write image to file
virtual bool writeImage(io::IWriteFile *file, IImage *image, u32 param = 0) const = 0;
};
} // namespace video
} // namespace irr
#endif // _I_IMAGE_WRITER_H_INCLUDED__

View File

@ -0,0 +1,49 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_LIGHT_SCENE_NODE_H_INCLUDED__
#define __I_LIGHT_SCENE_NODE_H_INCLUDED__
#include "ISceneNode.h"
#include "SLight.h"
namespace irr
{
namespace scene
{
//! Scene node which is a dynamic light.
/** You can switch the light on and off by
making it visible or not, and let it be animated by ordinary scene node animators.
If you set the light type to be directional, you will need to set the direction of the
light source manually in the SLight structure, the position of the scene node will have no
effect on this direction.
*/
class ILightSceneNode : public ISceneNode
{
public:
//! constructor
ILightSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id,
const core::vector3df& position = core::vector3df(0,0,0))
: ISceneNode(parent, mgr, id, position) {}
//! Sets the light data associated with this ILightSceneNode
virtual void setLightData(const video::SLight& light) = 0;
//! Gets the light data associated with this ILightSceneNode
//! \return Returns the light data.
virtual const video::SLight& getLightData() const = 0;
//! Gets the light data associated with this ILightSceneNode
//! \return Returns the light data.
virtual video::SLight& getLightData() = 0;
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,95 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_LOGGER_H_INCLUDED__
#define __I_LOGGER_H_INCLUDED__
#include "IReferenceCounted.h"
namespace irr
{
enum ELOG_LEVEL
{
//! High log level, warnings, errors and important information
//! texts are printed out.
ELL_INFORMATION = 0,
//! Default log level, warnings and errors are printed out
ELL_WARNING,
//! Low log level, only errors are printed into the log
ELL_ERROR,
//! Nothing is printed out to the log
ELL_NONE
};
//! Interface for logging messages, warnings and errors
class ILogger : public virtual IReferenceCounted
{
public:
//! destructor
virtual ~ILogger() {}
//! Returns the current set log level.
virtual ELOG_LEVEL getLogLevel() const = 0;
//! Sets a new log level. With this value, texts which are sent to
//! the logger are filtered out. For example setting this value to
//! ELL_WARNING, only warnings and
//! errors are printed out. Setting it to ELL_INFORMATION, which is
//! the default setting, warnings,
//! errors and informational texts are printed out.
//! \param ll: new log level filter value.
virtual void setLogLevel(ELOG_LEVEL ll) = 0;
//! Prints out a text into the log
//! \param text: Text to print out.
//! \param ll: Log level of the text. If the text is an error, set
//! it to ELL_ERROR, if it is warning set it to ELL_WARNING, and if it
//! is just an informational text, set it to ELL_INFORMATION. Texts are
//! filtered with these levels. If you want to be a text displayed,
//! independent on what level filter is set, use ELL_NONE.
virtual void log(const c8* text, ELOG_LEVEL ll=ELL_INFORMATION) = 0;
//! Prints out a text into the log
//! \param text: Text to print out.
//! \param hint: Additional info. This string is added after a " :" to the
//! string.
//! \param ll: Log level of the text. If the text is an error, set
//! it to ELL_ERROR, if it is warning set it to ELL_WARNING, and if it
//! is just an informational text, set it to ELL_INFORMATION. Texts are
//! filtered with these levels. If you want to be a text displayed,
//! independent on what level filter is set, use ELL_NONE.
virtual void log(const c8* text, const c8* hint, ELOG_LEVEL ll=ELL_INFORMATION) = 0;
//! Prints out a text into the log
//! \param text: Text to print out.
//! \param hint: Additional info. This string is added after a " :" to the
//! string.
//! \param ll: Log level of the text. If the text is an error, set
//! it to ELL_ERROR, if it is warning set it to ELL_WARNING, and if it
//! is just an informational text, set it to ELL_INFORMATION. Texts are
//! filtered with these levels. If you want to be a text displayed,
//! independent on what level filter is set, use ELL_NONE.
virtual void log(const wchar_t* text, const wchar_t* hint, ELOG_LEVEL ll=ELL_INFORMATION) = 0;
//! Prints out a text into the log
//! \param text: Text to print out.
//! \param ll: Log level of the text. If the text is an error, set
//! it to ELL_ERROR, if it is warning set it to ELL_WARNING, and if it
//! is just an informational text, set it to ELL_INFORMATION. Texts are
//! filtered with these levels. If you want to be a text displayed,
//! independent on what level filter is set, use ELL_NONE.
virtual void log(const wchar_t* text, ELOG_LEVEL ll=ELL_INFORMATION) = 0;
};
} // end namespace
#endif

View File

@ -0,0 +1,97 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_MATERIAL_RENDERER_H_INCLUDED__
#define __I_MATERIAL_RENDERER_H_INCLUDED__
#include "IReferenceCounted.h"
#include "SMaterial.h"
#include "S3DVertex.h"
namespace irr
{
namespace video
{
class IVideoDriver;
class IMaterialRendererServices;
//! Interface for material rendering. Can be used to extend the engine with new materials.
/** Refer to IVideoDriver::addMaterialRenderer() for more informations on how to extend the engine
with new materials.
*/
class IMaterialRenderer : public virtual IReferenceCounted
{
public:
//! destructor
virtual ~IMaterialRenderer() {}
//! Called by the IVideoDriver implementation the let the renderer set its needed render states.
/** This is called during the IVideoDriver::setMaterial() call.
When overriding this, you can set some renderstates or for example a vertex or pixel shader
if you like.
\param material: The new material parameters to be set. The renderer may change the material
flags in this material. For example if this material does not accept the zbuffer = true, it
can set it to false. This is useful, because in the next lastMaterial will be just the material
in this call.
\param lastMaterial: The material parameters which have been set before this material.
\param resetAllRenderstates: True if all renderstates should really be reset. This is usually
true if the last rendering mode was not a usual 3d rendering mode, but for example
a 2d rendering mode.
You should reset really all renderstates if this is true, no matter if the lastMaterial had
some similar settings. This is used because in most cases, some common renderstates are not
changed if they are already there, for example bilinear filtering, wireframe, gouraudshading,
lighting, zbuffer, zwriteenable, backfaceculling and fogenable.
\param services: Interface providing some methods for changing advanced, internal
states of a IVideoDriver. */
virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial,
bool resetAllRenderstates, IMaterialRendererServices* services) {};
//! Called every time before a new bunch of geometry is being drawn using this material with
//! for example drawIndexedTriangleList() call.
/** OnSetMaterial should normally only be called if the renderer decides that the renderstates should be changed, it won't be called if for
example two drawIndexedTriangleList() will be called with the same material set. This
method will be called every time. This is useful for example for materials with shaders,
which don't only set new renderstates but also shader constants.
\param service: Pointer to interface providing methos for setting constants and other things.
\param vtxtype: Vertex type with which the next rendering will be done. This can be used
by the material renderer to set some specific optimized shaders or if this is an incompatible
vertex type for this renderer, to refuse rendering for example.
\return Returns true if everything is ok, and false if nothing should be rendered.
The material renderer can choose to return false for example if he doesn't support the
specified vertex type. This is actually done in D3D8 and D3D9 when using a
normal mapped material with a vertex type other than EVT_TANGENTS. */
virtual bool OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype) { return true; };
//! Called by the IVideoDriver to unset this material.
/** Called during the
IVideoDriver::setMaterial() call before the new material will get the OnSetMaterial()
call. */
virtual void OnUnsetMaterial() {}
//! Returns if the material is transparent.
/** The scene managment needs to know this
for being able to sort the materials by opaque and transparent. */
virtual bool isTransparent() const { return false; }
//! Returns the render capability of the material.
/** Because some more complex materials
are implemented in multiple ways and need special hardware capabilities, it is possible
to query how the current material renderer is performing on the current hardware with this
function.
\return Returns 0 if everything is running fine. Any other value is material renderer
specific and means for example that the renderer switched back to a fall back material because
it cannot use the latest shaders. More specific examples:
Fixed function pipeline materials should return 0 in most cases, parallax mapped
material will only return 0 when at least pixel shader 1.4 is available on that machine. */
virtual s32 getRenderCapability() const { return 0; }
};
} // end namespace video
} // end namespace irr
#endif

View File

@ -0,0 +1,93 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_MATERIAL_RENDERER_SERVICES_H_INCLUDED__
#define __I_MATERIAL_RENDERER_SERVICES_H_INCLUDED__
#include "IReferenceCounted.h"
#include "SMaterial.h"
#include "S3DVertex.h"
namespace irr
{
namespace video
{
class IVideoDriver;
//! Interface providing some methods for changing advanced, internal states of a IVideoDriver.
class IMaterialRendererServices
{
public:
//! destructor
virtual ~IMaterialRendererServices() {}
//! Can be called by an IMaterialRenderer to make its work easier.
//! Sets all basic renderstates if needed.
//! Basic render states are diffuse, ambient, specular, and emissive color, specular power,
//! bilinear and trilinear filtering, wireframe mode,
//! grouraudshading, lighting, zbuffer, zwriteenable, backfaceculling and fog enabling.
virtual void setBasicRenderStates(const SMaterial& material,
const SMaterial& lastMaterial,
bool resetAllRenderstates) = 0;
//! Sets a constant for the vertex shader based on a name. This can be used if you used
//! a high level shader language like GLSL or HLSL to create a shader. Example: If you
//! created a shader which has variables named 'mWorldViewProj' (containing the
//! WorldViewProjection matrix) and another one named 'fTime' containing one float,
//! you can set them in your IShaderConstantSetCallBack derived class like this:
//! \code
//! virtual void OnSetConstants(video::IMaterialRendererServices* services, s32 userData)
//! {
//! video::IVideoDriver* driver = services->getVideoDriver();
//!
//! f32 time = (f32)os::Timer::getTime()/100000.0f;
//! services->setVertexShaderConstant("fTime", &time, 1);
//!
//! core::matrix4 worldViewProj(driver->getTransform(video::ETS_PROJECTION));
//! worldViewProj *= driver->getTransform(video::ETS_VIEW);
//! worldViewProj *= driver->getTransform(video::ETS_WORLD);
//! services->setVertexShaderConstant("mWorldViewProj", worldViewProj.M, 16);
//! }
//! \endcode
//! \param name: Name of the variable
//! \param floats: Pointer to array of floats
//! \param count: Amount of floats in array.
//! \return: Returns true if successful.
virtual bool setVertexShaderConstant(const c8* name, const f32* floats, int count) = 0;
//! Sets a vertex shader constant. Can be used if you created a shader using
//! pixel/vertex shader assembler or ARB_fragment_program or ARB_vertex_program.
//! \param data: Data to be set in the constants
//! \param startRegister: First register to be set
//! \param constantAmount: Amount of registers to be set. One register consists of 4 floats.
virtual void setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1) = 0;
//! Sets a constant for the pixel shader based on a name. This can be used if you used
//! a high level shader language like GLSL or HLSL to create a shader. See
//! setVertexShaderConstant() for an example on how to use this.
//! \param name: Name of the variable
//! \param floats: Pointer to array of floats
//! \param count: Amount of floats in array.
//! \return: Returns true if successful.
virtual bool setPixelShaderConstant(const c8* name, const f32* floats, int count) = 0;
//! Sets a pixel shader constant. Can be used if you created a shader using
//! pixel/vertex shader assembler or ARB_fragment_program or ARB_vertex_program.
//! \param data: Data to be set in the constants
//! \param startRegister: First register to be set.
//! \param constantAmount: Amount of registers to be set. One register consists of 4 floats.
virtual void setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1) = 0;
//! Returns a pointer to the IVideoDriver interface
virtual IVideoDriver* getVideoDriver() = 0;
};
} // end namespace video
} // end namespace irr
#endif

View File

@ -0,0 +1,62 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_MESH_H_INCLUDED__
#define __I_MESH_H_INCLUDED__
#include "IReferenceCounted.h"
#include "SMaterial.h"
namespace irr
{
namespace scene
{
class IMeshBuffer;
//! Class for accessing a mesh with multiple mesh buffers.
/** An IMesh is nothing more than a collection of some mesh buffers (IMeshBuffer).
SMesh is a simple implementation of an IMesh.
*/
class IMesh : public virtual IReferenceCounted
{
public:
//! destructor
virtual ~IMesh() { }
//! Returns the amount of mesh buffers.
/** \return Returns the amount of mesh buffers (IMeshBuffer) in this mesh. */
virtual u32 getMeshBufferCount() const = 0;
//! Returns pointer to a mesh buffer.
/** \param nr: Zero based index of the mesh buffer. The maximum value is
getMeshBufferCount() - 1;
\return Returns the pointer to the mesh buffer or
NULL if there is no such mesh buffer. */
virtual IMeshBuffer* getMeshBuffer(u32 nr) const = 0;
//! Returns pointer to a mesh buffer which fits a material
/** \param material: material to search for
\return Returns the pointer to the mesh buffer or
NULL if there is no such mesh buffer. */
virtual IMeshBuffer* getMeshBuffer( const video::SMaterial &material) const = 0;
//! Returns an axis aligned bounding box of the mesh.
/** \return A bounding box of this mesh is returned. */
virtual const core::aabbox3d<f32>& getBoundingBox() const = 0;
//! set user axis aligned bounding box
virtual void setBoundingBox( const core::aabbox3df& box) = 0;
//! Sets a flag of all contained materials to a new value.
/** \param flag: Flag to set in all materials.
\param newvalue: New value to set in all materials. */
virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue) = 0;
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,117 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_MESH_BUFFER_H_INCLUDED__
#define __I_MESH_BUFFER_H_INCLUDED__
#include "IReferenceCounted.h"
#include "SMaterial.h"
#include "aabbox3d.h"
#include "S3DVertex.h"
namespace irr
{
namespace scene
{
//! Enumeration for all primitive types there are.
enum E_PRIMITIVE_TYPE
{
//! All vertices are non-connected points.
EPT_POINTS=0,
//! All vertices form a single connected line.
EPT_LINE_STRIP,
//! Just as LINE_STRIP, but the last and the first vertex is also connected.
EPT_LINE_LOOP,
//! Every two vertices are connected creating n/2 lines.
EPT_LINES,
//! After the first two vertices each vertex defines a new triangle.
//! Always the two last and the new one form a new triangle.
EPT_TRIANGLE_STRIP,
//! After the first two vertices each vertex defines a new triangle.
//! All around the common first vertex.
EPT_TRIANGLE_FAN,
//! Explicitly set all vertices for each triangle.
EPT_TRIANGLES,
//! After the first two vertices each further tw vetices create a quad with the preceding two.
EPT_QUAD_STRIP,
//! Every four vertices create a quad.
EPT_QUADS,
//! Just as LINE_LOOP, but filled.
EPT_POLYGON,
//! The single vertices are expanded to quad billboards on the GPU.
EPT_POINT_SPRITES
};
//! Struct for holding a mesh with a single material
/** SMeshBuffer is a simple implementation of a MeshBuffer. */
class IMeshBuffer : public virtual IReferenceCounted
{
public:
//! destructor
virtual ~IMeshBuffer() { }
//! returns the material of this meshbuffer
virtual video::SMaterial& getMaterial() = 0;
//! returns the material of this meshbuffer
virtual const video::SMaterial& getMaterial() const = 0;
//! returns which type of vertex data is stored.
virtual video::E_VERTEX_TYPE getVertexType() const = 0;
//! returns pointer to vertex data. The data is an array of vertices. Which vertex
//! type is used can be determined with getVertexType().
virtual const void* getVertices() const = 0;
//! returns pointer to vertex data. The data is an array of vertices. Which vertex
//! type is used can be determined with getVertexType().
virtual void* getVertices() = 0;
//! returns amount of vertices
virtual u32 getVertexCount() const = 0;
//! returns pointer to Indices
virtual const u16* getIndices() const = 0;
//! returns pointer to Indices
virtual u16* getIndices() = 0;
//! returns amount of indices
virtual u32 getIndexCount() const = 0;
//! returns an axis aligned bounding box
virtual const core::aabbox3df& getBoundingBox() const = 0;
//! set user axis aligned bounding box
virtual void setBoundingBox( const core::aabbox3df& box) = 0;
//! recalculates the bounding box. should be called if the mesh changed.
virtual void recalculateBoundingBox() = 0;
//! append the vertices and indices to the current buffer
virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices) = 0;
//! append the meshbuffer to the current buffer
virtual void append(const IMeshBuffer* const other) = 0;
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,131 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_MESH_CACHE_H_INCLUDED__
#define __I_MESH_CACHE_H_INCLUDED__
#include "IReferenceCounted.h"
#include "irrString.h"
namespace irr
{
namespace scene
{
class IMesh;
class IAnimatedMesh;
class IAnimatedMeshSceneNode;
class IMeshLoader;
//! The mesh cache stores already loaded meshes and provides an interface to them.
/** You can access it using ISceneManager::getMeshCache(). All existing scene managers
will return a pointer to the same mesh cache, because it is shared between them. With
this interface, it is possible to manually add new loaded meshes (if
ISceneManager::getMesh() is not sufficient), to remove them and to iterate through
already loaded meshes. */
class IMeshCache : public virtual IReferenceCounted
{
public:
//! destructor
virtual ~IMeshCache() {}
//! Adds a mesh to the internal list of loaded meshes.
/** Usually, ISceneManager::getMesh() is called to load a mesh from a file.
That method searches the list of loaded meshes if a mesh has already been loaded and
returns a pointer to if it is in that list and already in memory. Otherwise it loads
the mesh. With IMeshCache::addMesh(), it is possible to pretend that a mesh already
has been loaded. This method can be used for example by mesh loaders who need to
load more than one mesh with one call. They can add additional meshes with this
method to the scene manager. The COLLADA loader for example uses this method.
\param filename: Filename of the mesh. When called ISceneManager::getMesh() with this
parameter, the method will return the mesh parameter given with this method.
\param mesh: Pointer to a mesh which will now be referenced by this name. */
virtual void addMesh(const c8* filename, IAnimatedMesh* mesh) = 0;
//! Removes a mesh from the cache.
/** After loading a mesh with getMesh(), the mesh can be removed from the cache
using this method, freeing a lot of memory. */
virtual void removeMesh(const IAnimatedMesh* const mesh) = 0;
//! Removes a mesh from the cache.
/** After loading a mesh with getMesh(), the mesh can be removed from the cache
using this method, freeing a lot of memory. */
virtual void removeMesh(const IMesh* const mesh) = 0;
//! Returns amount of loaded meshes in the cache.
/** You can load new meshes into the cache using getMesh() and addMesh().
If you ever need to access the internal mesh cache, you can do this using
removeMesh(), getMeshNumber(), getMeshByIndex() and getMeshFilename() */
virtual u32 getMeshCount() const = 0;
//! Returns current index number of the mesh, and -1 if it is not in the cache.
virtual s32 getMeshIndex(const IAnimatedMesh* const mesh) const = 0;
//! Returns current index number of the mesh, and -1 if it is not in the cache.
virtual s32 getMeshIndex(const IMesh* const mesh) const = 0;
//! Returns a mesh based on its index number.
/** \param index: Index of the mesh, number between 0 and getMeshCount()-1.
Note that this number is only valid until a new mesh is loaded or removed *
\return Returns pointer to the mesh or 0 if there is none with this number. */
virtual IAnimatedMesh* getMeshByIndex(u32 index) = 0;
//! Returns a mesh based on its file name.
/** \return Returns pointer to the mesh or 0 if there is none with this number. */
virtual IAnimatedMesh* getMeshByFilename(const c8* filename) = 0;
//! Returns name of a mesh based on its index number.
/** \param index: Index of the mesh, number between 0 and getMeshCount()-1.
Note that this is only valid until a new mesh is loaded */
virtual const c8* getMeshFilename(u32 index) const = 0;
//! Returns the filename of a loaded mesh, if there is any.
/** Returns 0 if there is none. */
virtual const c8* getMeshFilename(const IAnimatedMesh* const mesh) const = 0;
//! Returns the filename of a loaded mesh, if there is any.
/* Returns 0 if there is none.*/
virtual const c8* getMeshFilename(const IMesh* const mesh) const = 0;
//! Renames a loaded mesh, if possible.
/** Returns true if sucessful. Note that renaming meshes might change
the ordering of the meshes, and so the index of the meshes as returned by
getMeshIndex() or taken by some methods will change. */
virtual bool setMeshFilename(u32 index, const c8* filename) = 0;
//! Renames a loaded mesh, if possible.
/** Returns true if sucessful. Note that renaming meshes might change
the ordering of the meshes, and so the index of the meshes as returned by
getMeshIndex() or taken by some methods will change. */
virtual bool setMeshFilename(const IAnimatedMesh* const mesh, const c8* filename) = 0;
//! Renames a loaded mesh, if possible.
/** Returns true if sucessful. Note that renaming meshes might change
the ordering of the meshes, and so the index of the meshes as returned by
getMeshIndex() or taken by some methods will change. */
virtual bool setMeshFilename(const IMesh* const mesh, const c8* filename) = 0;
//! returns if a mesh already was loaded
virtual bool isMeshLoaded(const c8* filename) = 0;
//! Clears the whole mesh cache, removing all meshes.
/** All meshes will be reloaded completely when using ISceneManager::getMesh()
after calling this method.
Warning: If you have pointers to meshes that were loaded with ISceneManager::getMesh()
and you did not grab them, then they may become invalid. */
virtual void clear() = 0;
//! Clears all meshes that are held in the mesh cache but not used anywhere else.
/** Warning: If you have pointers to meshes that were loaded with ISceneManager::getMesh()
and you did not grab them, then they may become invalid. */
virtual void clearUnusedMeshes() = 0;
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,48 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_MESH_LOADER_H_INCLUDED__
#define __I_MESH_LOADER_H_INCLUDED__
#include "IReferenceCounted.h"
namespace irr
{
namespace io
{
class IReadFile;
} // end namespace io
namespace scene
{
class IAnimatedMesh;
//! Class which is able to load an animated mesh from a file.
/** If you want the Irrlicht Engine be able to load meshes of
currently unsupported file formats (e.g .cob), then implement
this and add your new Surface loader with
ISceneManager::addExternalMeshLoader() to the engine. */
class IMeshLoader : public virtual IReferenceCounted
{
public:
//! destructor
virtual ~IMeshLoader() {}
//! Returns true if the file maybe is able to be loaded by this class.
/** This decision should be based only on the file extension (e.g. ".cob") */
virtual bool isALoadableFileExtension(const c8* fileName) const = 0;
//! Creates/loads an animated mesh from the file.
/** \return Pointer to the created mesh. Returns 0 if loading failed.
If you no longer need the mesh, you should call IAnimatedMesh::drop().
See IReferenceCounted::drop() for more information. */
virtual IAnimatedMesh* createMesh(io::IReadFile* file) = 0;
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,121 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_MESH_MANIPULATOR_H_INCLUDED__
#define __I_MESH_MANIPULATOR_H_INCLUDED__
#include "IReferenceCounted.h"
#include "vector3d.h"
#include "aabbox3d.h"
#include "matrix4.h"
#include "IAnimatedMesh.h"
#include "SColor.h"
namespace irr
{
namespace scene
{
class IMesh;
class IMeshBuffer;
struct SMesh;
//! An interface for easily manipulate meshes.
/** Scale, set alpha value, flip surfaces, and so on. This exists for fixing problems
with wrong imported or exported meshes quickly after loading. It is not intended for doing mesh
modifications and/or animations during runtime.
*/
class IMeshManipulator : public virtual IReferenceCounted
{
public:
//! destructor
virtual ~IMeshManipulator() {}
//! Flips the direction of surfaces.
/** Changes backfacing triangles to frontfacing
triangles and vice versa.
\param mesh: Mesh on which the operation is performed. */
virtual void flipSurfaces(IMesh* mesh) const = 0;
//! Sets the alpha vertex color value of the whole mesh to a new value.
/** \param mesh: Mesh on which the operation is performed.
\param alpha: New alpha value. Must be a value between 0 and 255. */
virtual void setVertexColorAlpha(IMesh* mesh, s32 alpha) const = 0;
//! Sets the colors of all vertices to one color
virtual void setVertexColors(IMesh* mesh, video::SColor color) const = 0;
//! Recalculates all normals of the mesh.
/** \param mesh: Mesh on which the operation is performed.
\param smooth: If the normals shall be smoothed. */
virtual void recalculateNormals(IMesh* mesh, bool smooth = false) const = 0;
//! Recalculates all normals of the mesh buffer.
/** \param buffer: Mesh buffer on which the operation is performed.
\param smooth: If the normals shall be smoothed. */
virtual void recalculateNormals(IMeshBuffer* buffer, bool smooth = false) const = 0;
//! Scales the whole mesh.
/** \param mesh: Mesh on which the operation is performed.
\param scale: Scale factor. */
virtual void scaleMesh(IMesh* mesh, const core::vector3df& scale) const = 0;
//! Applies a transformation
/** \param mesh: Mesh on which the operation is performed.
\param m: transformation matrix. */
virtual void transformMesh(IMesh* mesh, const core::matrix4& m) const = 0;
//! Clones a static IMesh into a modifyable SMesh.
/** All meshbuffers in the returned SMesh
are of type SMeshBuffer or SMeshBufferLightMap.
\param mesh: Mesh to copy.
\return Returns the cloned mesh.
If you no longer need the cloned mesh, you should call SMesh::drop().
See IReferenceCounted::drop() for more information. */
virtual SMesh* createMeshCopy(IMesh* mesh) const = 0;
//! Creates a planar texture mapping on the mesh
/** \param mesh: Mesh on which the operation is performed.
\param resolution: resolution of the planar mapping. This is the value
specifying which is the relation between world space and
texture coordinate space. */
virtual void makePlanarTextureMapping(IMesh* mesh, f32 resolution=0.001f) const = 0;
//! Creates a copy of the mesh, which will only consist of S3DVertexTangents vertices.
/** This is useful if you want to draw tangent space normal mapped geometry because
it calculates the tangent and binormal data which is needed there.
\param mesh: Input mesh
\return Mesh consiting only of S3DVertexTangents vertices.
If you no longer need the cloned mesh, you should call IMesh::drop().
See IReferenceCounted::drop() for more information. */
virtual IMesh* createMeshWithTangents(IMesh* mesh) const = 0;
//! Creates a copy of the mesh, which will only consist of S3DVertex2TCoord vertices.
virtual IMesh* createMeshWith2TCoords(IMesh* mesh) const = 0;
//! Creates a copy of a mesh with all vertices unwelded
virtual IMesh* createMeshUniquePrimitives(IMesh* mesh) const = 0;
//! Creates a copy of a mesh with vertices welded
virtual IMesh* createMeshWelded(IMesh* mesh, f32 tolerance=core::ROUNDING_ERROR_32) const = 0;
//! Returns amount of polygons in mesh.
virtual s32 getPolyCount(IMesh* mesh) const = 0;
//! Returns amount of polygons in mesh.
virtual s32 getPolyCount(IAnimatedMesh* mesh) const = 0;
//! create a new AnimatedMesh and adds the mesh to it
virtual IAnimatedMesh * createAnimatedMesh(IMesh* mesh,
scene::E_ANIMATED_MESH_TYPE type = scene::EAMT_UNKNOWN) const = 0;
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,49 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_MESH_SCENE_NODE_H_INCLUDED__
#define __I_MESH_SCENE_NODE_H_INCLUDED__
#include "ISceneNode.h"
namespace irr
{
namespace scene
{
class IMesh;
//! A scene node displaying a static mesh
class IMeshSceneNode : public ISceneNode
{
public:
//! constructor
IMeshSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id,
const core::vector3df& position, const core::vector3df& rotation,
const core::vector3df& scale)
: ISceneNode(parent, mgr, id, position, rotation, scale) {}
//! Sets a new mesh to display
virtual void setMesh(IMesh* mesh) = 0;
//! Returns the current mesh
virtual IMesh* getMesh(void) = 0;
//! Sets if the scene node should not copy the materials of the mesh but use them in a read only style.
/* In this way it is possible to change the materials a mesh causing all mesh scene nodes
referencing this mesh to change too. */
virtual void setReadOnlyMaterials(bool readonly) = 0;
//! Returns if the scene node should not copy the materials of the mesh but use them in a read only style
virtual bool isReadOnlyMaterials() const = 0;
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,48 @@
#ifndef __IRR_I_MESH_WRITER_H_INCLUDED__
#define __IRR_I_MESH_WRITER_H_INCLUDED__
#include "IReferenceCounted.h"
#include "EMeshWriterEnums.h"
namespace irr
{
namespace io
{
class IWriteFile;
} // end namespace io
namespace scene
{
class IMesh;
// interface for writing meshes
class IMeshWriter : public virtual IReferenceCounted
{
public:
virtual ~IMeshWriter() {}
//! Returns the type of the mesh writer
/** For own implementations, use MAKE_IRR_ID as shown in the EMESH_WRITER_TYPE
enumeration to return your own unique mesh type id.*/
virtual EMESH_WRITER_TYPE getType() const = 0;
//! writes a static mesh
/** \return Returns true if sucessful */
virtual bool writeMesh(io::IWriteFile* file, scene::IMesh* mesh,
s32 flags=EMWF_NONE) = 0;
// writes an animated mesh
// for future use, no writer is able to write animated meshes currently
/* \return Returns true if sucessful */
//virtual bool writeAnimatedMesh(io::IWriteFile* file,
// scene::IAnimatedMesh* mesh,
// s32 flags=EMWF_NONE) = 0;
};
} // end namespace
} // end namespace
#endif

View File

@ -0,0 +1,44 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_META_TRIANGLE_SELECTOR_H_INCLUDED__
#define __I_META_TRIANGLE_SELECTOR_H_INCLUDED__
#include "ITriangleSelector.h"
namespace irr
{
namespace scene
{
//! Interface for making multiple triangle selectors work as one big selector.
/** This is nothing more than a collection of one or more triangle selectors
providing together the interface of one triangle selector. In this way,
collision tests can be done with different triangle soups in one pass.
*/
class IMetaTriangleSelector : public ITriangleSelector
{
public:
//! Adds a triangle selector to the collection of triangle selectors
//! in this metaTriangleSelector.
//! \param toAdd: Pointer to an triangle selector to add to the list.
virtual void addTriangleSelector(ITriangleSelector* toAdd) = 0;
//! Removes a specific triangle selector which was added before from the collection.
//! \param toRemove: Pointer to an triangle selector which is in the list
//! but will be removed.
//! \return Returns true if successful, false if not.
virtual bool removeTriangleSelector(ITriangleSelector* toRemove) = 0;
//! Removes all triangle selectors from the collection.
virtual void removeAllTriangleSelectors() = 0;
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,47 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_OS_OPERATOR_H_INCLUDED__
#define __I_OS_OPERATOR_H_INCLUDED__
#include "IReferenceCounted.h"
namespace irr
{
//! The Operating system operator provides operation system specific methods and informations.
class IOSOperator : public virtual IReferenceCounted
{
public:
//! destructor
virtual ~IOSOperator() {}
//! returns the current operation system version as string.
virtual const wchar_t* getOperationSystemVersion() const = 0;
//! copies text to the clipboard
virtual void copyToClipboard(const c8* text) const = 0;
//! gets text from the clipboard
//! \return Returns 0 if no string is in there.
virtual c8* getTextFromClipboard() const = 0;
//! gets the processor speed in megahertz
//! \param MHz: The integer variable to store the speed in.
//! \return Returns true if successful, false if not
virtual bool getProcessorSpeedMHz(u32* MHz) const = 0;
//! gets the total and available system RAM
//! \param Total: will contain the total system memory
//! \param Avail: will contain the available memory
//! \return Returns true if successful, false if not
virtual bool getSystemMemory(u32* Total, u32* Avail) const = 0;
};
} // end namespace
#endif

View File

@ -0,0 +1,84 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_PARTICLE_AFFECTOR_H_INCLUDED__
#define __I_PARTICLE_AFFECTOR_H_INCLUDED__
#include "IAttributeExchangingObject.h"
#include "SParticle.h"
namespace irr
{
namespace scene
{
//! Types of built in particle affectors
enum E_PARTICLE_AFFECTOR_TYPE
{
EPAT_NONE = 0,
EPAT_ATTRACT,
EPAT_FADE_OUT,
EPAT_GRAVITY,
EPAT_ROTATE,
EPAT_COUNT
};
//! Names for built in particle affectors
const c8* const ParticleAffectorTypeNames[] =
{
"None",
"Attract",
"FadeOut",
"Gravity",
"Rotate",
0
};
//! A particle affector modifies particles.
class IParticleAffector : public virtual io::IAttributeExchangingObject
{
public:
//! constructor
IParticleAffector() : Enabled(true) {}
//! Affects an array of particles.
//! \param now: Current time. (Same as ITimer::getTime() would return)
//! \param particlearray: Array of particles.
//! \param count: Amount of particles in array.
virtual void affect(u32 now, SParticle* particlearray, u32 count) = 0;
//! Sets whether or not the affector is currently enabled.
virtual void setEnabled(bool enabled) { Enabled = enabled; }
//! Gets whether or not the affector is currently enabled.
virtual bool getEnabled() const { return Enabled; }
//! Writes attributes of the object.
//! Implement this to expose the attributes of your scene node animator for
//! scripting languages, editors, debuggers or xml serialization purposes.
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const {}
//! Reads attributes of the object.
//! Implement this to set the attributes of your scene node animator for
//! scripting languages, editors, debuggers or xml deserialization purposes.
//! \param startIndex: start index where to start reading attributes.
//! \param in: The attributes to work with.
//! \param options: Additional options.
//! \return: returns last index of an attribute read by this affector
virtual s32 deserializeAttributes(s32 startIndex, io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) { return 0; }
//! Get emitter type
virtual E_PARTICLE_AFFECTOR_TYPE getType() const = 0;
protected:
bool Enabled;
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,56 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_PARTICLE_ANIMATED_MESH_SCENE_NODE_EMITTER_H_INCLUDED__
#define __I_PARTICLE_ANIMATED_MESH_SCENE_NODE_EMITTER_H_INCLUDED__
#include "IParticleEmitter.h"
#include "IAnimatedMeshSceneNode.h"
namespace irr
{
namespace scene
{
//! A particle emitter which emits particles from mesh vertices.
class IParticleAnimatedMeshSceneNodeEmitter : public IParticleEmitter
{
public:
//! Set Mesh to emit particles from
virtual void setAnimatedMeshSceneNode( IAnimatedMeshSceneNode* node ) = 0;
//! Set whether to use vertex normal for direction, or direction specified
virtual void setUseNormalDirection( bool useNormalDirection = true ) = 0;
//! Set the amount that the normal is divided by for getting a particles direction
virtual void setNormalDirectionModifier( f32 normalDirectionModifier ) = 0;
//! Sets whether to emit min<->max particles for every vertex per
//! second, or to pick min<->max vertices every second
virtual void setEveryMeshVertex( bool everyMeshVertex = true ) = 0;
//! Get Mesh we're emitting particles from
virtual const IAnimatedMeshSceneNode* getAnimatedMeshSceneNode() const = 0;
//! Get whether to use vertex normal for direction, or direction specified
virtual bool isUsingNormalDirection() const = 0;
//! Get the amount that the normal is divided by for getting a particles direction
virtual f32 getNormalDirectionModifier() const = 0;
//! Gets whether to emit min<->max particles for every vertex per
//! second, or to pick min<->max vertices every second
virtual bool getEveryMeshVertex() const = 0;
//! Get emitter type
virtual E_PARTICLE_EMITTER_TYPE getType() const { return EPET_ANIMATED_MESH; }
};
} // end namespace scene
} // end namespace irr
#endif // __I_PARTICLE_ANIMATED_MESH_SCENE_NODE_EMITTER_H_INCLUDED__

View File

@ -0,0 +1,59 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_PARTICLE_ATTRACTION_AFFECTOR_H_INCLUDED__
#define __I_PARTICLE_ATTRACTION_AFFECTOR_H_INCLUDED__
#include "IParticleAffector.h"
namespace irr
{
namespace scene
{
//! A particle affector which attracts or detracts particles.
class IParticleAttractionAffector : public IParticleAffector
{
public:
//! Set the point that particles will attract to
virtual void setPoint( const core::vector3df& point ) = 0;
//! Set whether or not the particles are attracting or detracting
virtual void setAttract( bool attract ) = 0;
//! Set whether or not this will affect particles in the X direction
virtual void setAffectX( bool affect ) = 0;
//! Set whether or not this will affect particles in the Y direction
virtual void setAffectY( bool affect ) = 0;
//! Set whether or not this will affect particles in the Z direction
virtual void setAffectZ( bool affect ) = 0;
//! Get the point that particles are attracted to
virtual const core::vector3df& getPoint() const = 0;
//! Get whether or not the particles are attracting or detracting
virtual bool getAttract() const = 0;
//! Get whether or not the particles X position are affected
virtual bool getAffectX() const = 0;
//! Get whether or not the particles Y position are affected
virtual bool getAffectY() const = 0;
//! Get whether or not the particles Z position are affected
virtual bool getAffectZ() const = 0;
//! Get emitter type
virtual E_PARTICLE_AFFECTOR_TYPE getType() const { return EPAT_ATTRACT; }
};
} // end namespace scene
} // end namespace irr
#endif // __I_PARTICLE_ATTRACTION_AFFECTOR_H_INCLUDED__

View File

@ -0,0 +1,36 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_PARTICLE_BOX_EMITTER_H_INCLUDED__
#define __I_PARTICLE_BOX_EMITTER_H_INCLUDED__
#include "IParticleEmitter.h"
#include "aabbox3d.h"
namespace irr
{
namespace scene
{
//! A particle emitter which emits particles from a box shaped space
class IParticleBoxEmitter : public IParticleEmitter
{
public:
//! Set the box shape
virtual void setBox( const core::aabbox3df& box ) = 0;
//! Get the box shape set
virtual const core::aabbox3df& getBox() const = 0;
//! Get emitter type
virtual E_PARTICLE_EMITTER_TYPE getType() const { return EPET_BOX; }
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,59 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_PARTICLE_CYLINDER_EMITTER_H_INCLUDED__
#define __I_PARTICLE_CYLINDER_EMITTER_H_INCLUDED__
#include "IParticleEmitter.h"
namespace irr
{
namespace scene
{
//! A particle emitter which emits from a cylindrically shaped space.
class IParticleCylinderEmitter : public IParticleEmitter
{
public:
//! Set the center of the radius for the cylinder, at one end of the cylinder
virtual void setCenter( const core::vector3df& center ) = 0;
//! Set the normal of the cylinder
virtual void setNormal( const core::vector3df& normal ) = 0;
//! Set the radius of the cylinder
virtual void setRadius( f32 radius ) = 0;
//! Set the length of the cylinder
virtual void setLength( f32 length ) = 0;
//! Set whether or not to draw points inside the cylinder
virtual void setOutlineOnly( bool outlineOnly = true ) = 0;
//! Get the center of the cylinder
virtual const core::vector3df& getCenter() const = 0;
//! Get the normal of the cylinder
virtual const core::vector3df& getNormal() const = 0;
//! Get the radius of the cylinder
virtual f32 getRadius() const = 0;
//! Get the center of the cylinder
virtual f32 getLength() const = 0;
//! Get whether or not to draw points inside the cylinder
virtual bool getOutlineOnly() const = 0;
//! Get emitter type
virtual E_PARTICLE_EMITTER_TYPE getType() const { return EPET_CYLINDER; }
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,113 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_PARTICLE_EMITTER_H_INCLUDED__
#define __I_PARTICLE_EMITTER_H_INCLUDED__
#include "IAttributeExchangingObject.h"
#include "SParticle.h"
namespace irr
{
namespace scene
{
//! Types of built in particle emitters
enum E_PARTICLE_EMITTER_TYPE
{
EPET_POINT = 0,
EPET_ANIMATED_MESH,
EPET_BOX,
EPET_CYLINDER,
EPET_MESH,
EPET_RING,
EPET_SPHERE,
EPET_COUNT
};
//! Names for built in particle emitters
const c8* const ParticleEmitterTypeNames[] =
{
"Point",
"AnimatedMesh",
"Box",
"Cylinder",
"Mesh",
"Ring",
"Sphere",
0
};
//! A particle emitter for using with particle systems.
/** A Particle emitter emitts new particles into a particle system.
*/
class IParticleEmitter : public virtual io::IAttributeExchangingObject
{
public:
//! Prepares an array with new particles to emitt into the system
//! and returns how much new particles there are.
//! \param now: Current time.
//! \param timeSinceLastCall: Time elapsed since last call, in milliseconds.
//! \param outArray: Pointer which will point to the array with the new
//! particles to add into the system.
//! \return Returns amount of new particles in the array. Can be 0.
virtual s32 emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray) = 0;
//! Set direction the emitter emits particles
virtual void setDirection( const core::vector3df& newDirection ) = 0;
//! Set minimum number of particles the emitter emits per second
virtual void setMinParticlesPerSecond( u32 minPPS ) = 0;
//! Set maximum number of particles the emitter emits per second
virtual void setMaxParticlesPerSecond( u32 maxPPS ) = 0;
//! Set minimum starting color for particles
virtual void setMinStartColor( const video::SColor& color ) = 0;
//! Set maximum starting color for particles
virtual void setMaxStartColor( const video::SColor& color ) = 0;
//! Get direction the emitter emits particles
virtual const core::vector3df& getDirection() const = 0;
//! Get the minimum number of particles the emitter emits per second
virtual u32 getMinParticlesPerSecond() const = 0;
//! Get the maximum number of particles the emitter emits per second
virtual u32 getMaxParticlesPerSecond() const = 0;
//! Get the minimum starting color for particles
virtual const video::SColor& getMinStartColor() const = 0;
//! Get the maximum starting color for particles
virtual const video::SColor& getMaxStartColor() const = 0;
//! Writes attributes of the object.
//! Implement this to expose the attributes of your scene node animator for
//! scripting languages, editors, debuggers or xml serialization purposes.
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const {}
//! Reads attributes of the object.
//! Implement this to set the attributes of your scene node animator for
//! scripting languages, editors, debuggers or xml deserialization purposes.
//! \param startIndex: start index where to start reading attributes.
//! \param in: The attributes to work with.
//! \param options: Additional options.
//! \return: returns last index of an attribute read by this affector
virtual s32 deserializeAttributes(s32 startIndex, io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) { return 0; }
//! Get emitter type
virtual E_PARTICLE_EMITTER_TYPE getType() const { return EPET_POINT; }
};
typedef IParticleEmitter IParticlePointEmitter;
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,43 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_PARTICLE_FADE_OUT_AFFECTOR_H_INCLUDED__
#define __I_PARTICLE_FADE_OUT_AFFECTOR_H_INCLUDED__
#include "IParticleAffector.h"
namespace irr
{
namespace scene
{
//! A particle affector which fades out the particles.
class IParticleFadeOutAffector : public IParticleAffector
{
public:
//! Sets the targetColor, i.e. the color the particles will interpolate
//! to over time.
virtual void setTargetColor( const video::SColor& targetColor ) = 0;
//! Sets the amount of time it takes for each particle to fade out.
virtual void setFadeOutTime( f32 fadeOutTime ) = 0;
//! Gets the targetColor, i.e. the color the particles will interpolate
//! to over time.
virtual const video::SColor& getTargetColor() const = 0;
//! Gets the amount of time it takes for each particle to fade out.
virtual f32 getFadeOutTime() const = 0;
//! Get emitter type
virtual E_PARTICLE_AFFECTOR_TYPE getType() const { return EPAT_FADE_OUT; }
};
} // end namespace scene
} // end namespace irr
#endif // __I_PARTICLE_FADE_OUT_AFFECTOR_H_INCLUDED__

View File

@ -0,0 +1,43 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_PARTICLE_GRAVITY_AFFECTOR_H_INCLUDED__
#define __I_PARTICLE_GRAVITY_AFFECTOR_H_INCLUDED__
#include "IParticleAffector.h"
namespace irr
{
namespace scene
{
//! A particle affector which applies gravity to particles.
class IParticleGravityAffector : public IParticleAffector
{
public:
//! Set the time in milliseconds when the gravity force is totally
//! lost and the particle does not move any more.
virtual void setTimeForceLost( f32 timeForceLost ) = 0;
//! Set the direction and force of gravity in all 3 dimensions.
virtual void setGravity( const core::vector3df& gravity ) = 0;
//! Get the time in milliseconds when the gravity force is totally
//! lost and the particle does not move any more.
virtual f32 getTimeForceLost() const = 0;
//! Get the direction and force of gravity.
virtual const core::vector3df& getGravity() const = 0;
//! Get emitter type
virtual E_PARTICLE_AFFECTOR_TYPE getType() const { return EPAT_GRAVITY; }
};
} // end namespace scene
} // end namespace irr
#endif // __I_PARTICLE_GRAVITY_AFFECTOR_H_INCLUDED__

View File

@ -0,0 +1,56 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_PARTICLE_MESH_EMITTER_H_INCLUDED__
#define __I_PARTICLE_MESH_EMITTER_H_INCLUDED__
#include "IParticleEmitter.h"
#include "IMesh.h"
namespace irr
{
namespace scene
{
//! A particle emitter which emits from vertices of a mesh
class IParticleMeshEmitter : public IParticleEmitter
{
public:
//! Set Mesh to emit particles from
virtual void setMesh( IMesh* mesh ) = 0;
//! Set whether to use vertex normal for direction, or direction specified
virtual void setUseNormalDirection( bool useNormalDirection = true ) = 0;
//! Set the amount that the normal is divided by for getting a particles direction
virtual void setNormalDirectionModifier( f32 normalDirectionModifier ) = 0;
//! Sets whether to emit min<->max particles for every vertex per second, or to pick
//! min<->max vertices every second
virtual void setEveryMeshVertex( bool everyMeshVertex = true ) = 0;
//! Get Mesh we're emitting particles from
virtual const IMesh* getMesh() const = 0;
//! Get whether to use vertex normal for direction, or direction specified
virtual bool isUsingNormalDirection() const = 0;
//! Get the amount that the normal is divided by for getting a particles direction
virtual f32 getNormalDirectionModifier() const = 0;
//! Gets whether to emit min<->max particles for every vertex per second, or to pick
//! min<->max vertices every second
virtual bool getEveryMeshVertex() const = 0;
//! Get emitter type
virtual E_PARTICLE_EMITTER_TYPE getType() const { return EPET_MESH; }
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,47 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_PARTICLE_RING_EMITTER_H_INCLUDED__
#define __I_PARTICLE_RING_EMITTER_H_INCLUDED__
#include "IParticleEmitter.h"
namespace irr
{
namespace scene
{
//! A particle emitter which emits particles along a ring shaped area.
class IParticleRingEmitter : public IParticleEmitter
{
public:
//! Set the center of the ring
virtual void setCenter( const core::vector3df& center ) = 0;
//! Set the radius of the ring
virtual void setRadius( f32 radius ) = 0;
//! Set the thickness of the ring
virtual void setRingThickness( f32 ringThickness ) = 0;
//! Get the center of the ring
virtual const core::vector3df& getCenter() const = 0;
//! Get the radius of the ring
virtual f32 getRadius() const = 0;
//! Get the thickness of the ring
virtual f32 getRingThickness() const = 0;
//! Get emitter type
virtual E_PARTICLE_EMITTER_TYPE getType() const { return EPET_RING; }
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,41 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_PARTICLE_ROTATION_AFFECTOR_H_INCLUDED__
#define __I_PARTICLE_ROTATION_AFFECTOR_H_INCLUDED__
#include "IParticleAffector.h"
namespace irr
{
namespace scene
{
//! A particle affector which rotates the particle system.
class IParticleRotationAffector : public IParticleAffector
{
public:
//! Set the point that particles will rotate around
virtual void setPivotPoint( const core::vector3df& point ) = 0;
//! Set the speed in degrees per second in all 3 dimensions
virtual void setSpeed( const core::vector3df& speed ) = 0;
//! Get the point that particles are attracted to
virtual const core::vector3df& getPivotPoint() const = 0;
//! Get the speed in degrees per second in all 3 dimensions
virtual const core::vector3df& getSpeed() const = 0;
//! Get emitter type
virtual E_PARTICLE_AFFECTOR_TYPE getType() const { return EPAT_ROTATE; }
};
} // end namespace scene
} // end namespace irr
#endif // __I_PARTICLE_ROTATION_AFFECTOR_H_INCLUDED__

View File

@ -0,0 +1,41 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_PARTICLE_SPHERE_EMITTER_H_INCLUDED__
#define __I_PARTICLE_SPHERE_EMITTER_H_INCLUDED__
#include "IParticleEmitter.h"
namespace irr
{
namespace scene
{
//! A particle emitter which emits from a spherical space.
class IParticleSphereEmitter : public IParticleEmitter
{
public:
//! Set the center of the sphere for particle emissions
virtual void setCenter( const core::vector3df& center ) = 0;
//! Set the radius of the sphere for particle emissions
virtual void setRadius( f32 radius ) = 0;
//! Get the center of the sphere for particle emissions
virtual const core::vector3df& getCenter() const = 0;
//! Get the radius of the sphere for particle emissions
virtual f32 getRadius() const = 0;
//! Get emitter type
virtual E_PARTICLE_EMITTER_TYPE getType() const { return EPET_SPHERE; }
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,416 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_PARTICLE_SYSTEM_SCENE_NODE_H_INCLUDED__
#define __I_PARTICLE_SYSTEM_SCENE_NODE_H_INCLUDED__
#include "ISceneNode.h"
#include "IParticleAnimatedMeshSceneNodeEmitter.h"
#include "IParticleBoxEmitter.h"
#include "IParticleCylinderEmitter.h"
#include "IParticleMeshEmitter.h"
#include "IParticleRingEmitter.h"
#include "IParticleSphereEmitter.h"
#include "IParticleAttractionAffector.h"
#include "IParticleFadeOutAffector.h"
#include "IParticleGravityAffector.h"
#include "IParticleRotationAffector.h"
#include "dimension2d.h"
namespace irr
{
namespace scene
{
//! A particle system scene node for creating snow, fire, exlosions, smoke...
/** A scene node controlling a particle System. The behavior of the particles
can be controlling by setting the right particle emitters and effectors.
You can for example easily a campfire by doing this:
\code
scene::IParticleSystemSceneNode* p = scenemgr->addParticleSystemSceneNode();
p->setParticleSize(core::dimension2d<f32>(20.0f, 10.0f));
scene::IParticleEmitter* em = p->createBoxEmitter(
core::aabbox3d<f32>(-5,0,-5,5,1,5),
core::vector3df(0.0f,0.03f,0.0f),
40,80, video::SColor(0,255,255,255),video::SColor(0,255,255,255), 1100,2000);
p->setEmitter(em);
em->drop();
scene::IParticleAffector* paf = p->createFadeOutParticleAffector();
p->addAffector(paf);
paf->drop();
\endcode
*/
class IParticleSystemSceneNode : public ISceneNode
{
public:
//! constructor
IParticleSystemSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id,
const core::vector3df& position = core::vector3df(0,0,0),
const core::vector3df& rotation = core::vector3df(0,0,0),
const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f))
: ISceneNode(parent, mgr, id, position, rotation, scale) {}
//! Sets the size of all particles.
virtual void setParticleSize(
const core::dimension2d<f32> &size = core::dimension2d<f32>(5.0f, 5.0f)) = 0;
//! Sets if the particles should be global. If it is, the particles are affected by
//! the movement of the particle system scene node too, otherwise they completely
//! ignore it. Default is true.
virtual void setParticlesAreGlobal(bool global) = 0;
//! Sets the particle emitter, which creates the particles.
//! A particle emitter can be created using one of the
//! methods. For example to create and use a simple PointEmitter,
//! call IParticleEmitter* p = createPointEmitter(); setEmitter(p); p->drop();
//! \param emitter: Sets the particle emitter. You can set this to 0
//! for removing the current emitter and stopping the particle system
//! emitting new particles.
virtual void setEmitter(IParticleEmitter* emitter) = 0;
//! Adds new particle effector to the particle system. A particle
//! affector modifies the particles. For example, the FadeOut
//! affector lets all particles fade out after some time. It is created
//! and used in this way: IParticleAffector* p = createFadeOutParticleAffector();
//! addAffector(p); p->drop();
//! Please note that a affector is not necessary for the particle
//! system to work.
//! \param affector: New affector.
virtual void addAffector(IParticleAffector* affector) = 0;
//! Removes all particle affectors in the particle system.
virtual void removeAllAffectors() = 0;
//! Creates a particle emitter for an animated mesh scene node
//! \param node: Pointer to the animated mesh scene node to emit particles from
//! \param useNormalDirection: If true, the direction of each particle created will
//! be the normal of the vertex that it's emitting from. The normal is divided by the
//! normalDirectionModifier parameter, which defaults to 100.0f.
//! \param direction: Direction and speed of particle emission.
//! \param normalDirectionModifier: If the emitter is using the normal direction
//! then the normal of the vertex that is being emitted from is divided by this number.
//! \param mbNumber: This allows you to specify a specific meshBuffer for the IMesh*
//! to emit particles from. The default value is -1, which means a random meshBuffer
//! picked from all of the meshes meshBuffers will be selected to pick a random vertex from.
//! If the value is 0 or greater, it will only pick random vertices from the meshBuffer
//! specified by this value.
//! \param everyMeshVertex: If true, the emitter will emit between min/max particles every second,
//! for every vertex in the mesh, if false, it will emit between min/max particles from random vertices
//! in the mesh.
//! \param minParticlesPerSecond: Minimal amount of particles emitted
//! per second.
//! \param maxParticlesPerSecond: Maximal amount of particles emitted
//! per second.
//! \param minStartColor: Minimal initial start color of a particle.
//! The real color of every particle is calculated as random interpolation
//! between minStartColor and maxStartColor.
//! \param maxStartColor: Maximal initial start color of a particle.
//! The real color of every particle is calculated as random interpolation
//! between minStartColor and maxStartColor.
//! \param lifeTimeMin: Minimal lifetime of a particle, in milliseconds.
//! \param lifeTimeMax: Maximal lifetime of a particle, in milliseconds.
//! \param maxAngleDegrees: Maximal angle in degrees, the emitting direction
//! of the particle will differ from the orignial direction.
//! \return Returns a pointer to the created particle emitter.
//! To set this emitter as new emitter of this particle system,
//! just call setEmitter(). Note that you'll have to drop() the
//! returned pointer, after you don't need it any more, see
//! IReferenceCounted::drop() for more informations.
virtual IParticleAnimatedMeshSceneNodeEmitter* createAnimatedMeshSceneNodeEmitter(
scene::IAnimatedMeshSceneNode* node, bool useNormalDirection = true,
const core::vector3df& direction = core::vector3df(0.0f,0.0f,0.0f),
f32 normalDirectionModifier = 100.0f, s32 mbNumber = -1,
bool everyMeshVertex = false,
u32 minParticlesPerSecond = 5, u32 maxParticlesPerSecond = 10,
const video::SColor& minStartColor = video::SColor(255,0,0,0),
const video::SColor& maxStartColor = video::SColor(255,255,255,255),
u32 lifeTimeMin = 2000, u32 lifeTimeMax = 4000,
s32 maxAngleDegrees = 0 ) = 0;
//! Creates a box particle emitter.
//! \param box: The box for the emitter.
//! \param direction: Direction and speed of particle emission.
//! \param minParticlesPerSecond: Minimal amount of particles emitted
//! per second.
//! \param maxParticlesPerSecond: Maximal amount of particles emitted
//! per second.
//! \param minStartColor: Minimal initial start color of a particle.
//! The real color of every particle is calculated as random interpolation
//! between minStartColor and maxStartColor.
//! \param maxStartColor: Maximal initial start color of a particle.
//! The real color of every particle is calculated as random interpolation
//! between minStartColor and maxStartColor.
//! \param lifeTimeMin: Minimal lifetime of a particle, in milliseconds.
//! \param lifeTimeMax: Maximal lifetime of a particle, in milliseconds.
//! \param maxAngleDegrees: Maximal angle in degrees, the emitting direction
//! of the particle will differ from the orignial direction.
//! \return Returns a pointer to the created particle emitter.
//! To set this emitter as new emitter of this particle system,
//! just call setEmitter(). Note that you'll have to drop() the
//! returned pointer, after you don't need it any more, see
//! IReferenceCounted::drop() for more informations.
virtual IParticleBoxEmitter* createBoxEmitter(
const core::aabbox3df& box = core::aabbox3df(-10,28,-10,10,30,10),
const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f),
u32 minParticlesPerSecond = 5,
u32 maxParticlesPerSecond = 10,
const video::SColor& minStartColor = video::SColor(255,0,0,0),
const video::SColor& maxStartColor = video::SColor(255,255,255,255),
u32 lifeTimeMin=2000, u32 lifeTimeMax=4000,
s32 maxAngleDegrees=0) = 0;
//! Creates a particle emitter for emitting from a cylinder
//! \param center: The center of the circle at the base of the cylinder
//! \param radius: The thickness of the cylinder
//! \param normal: Direction of the length of the cylinder
//! \param length: The length of the the cylinder
//! \param outlineOnly: Whether or not to put points inside the cylinder or on the outline only
//! \param direction: Direction and speed of particle emission.
//! \param minParticlesPerSecond: Minimal amount of particles emitted per second.
//! \param maxParticlesPerSecond: Maximal amount of particles emitted per second.
//! \param minStartColor: Minimal initial start color of a particle.
//! The real color of every particle is calculated as random interpolation
//! between minStartColor and maxStartColor.
//! \param maxStartColor: Maximal initial start color of a particle.
//! The real color of every particle is calculated as random interpolation
//! between minStartColor and maxStartColor.
//! \param lifeTimeMin: Minimal lifetime of a particle, in milliseconds.
//! \param lifeTimeMax: Maximal lifetime of a particle, in milliseconds.
//! \param maxAngleDegrees: Maximal angle in degrees, the emitting direction
//! of the particle will differ from the orignial direction.
//! \return Returns a pointer to the created particle emitter.
//! To set this emitter as new emitter of this particle system,
//! just call setEmitter(). Note that you'll have to drop() the
//! returned pointer, after you don't need it any more, see
//! IReferenceCounted::drop() for more informations.
virtual IParticleCylinderEmitter* createCylinderEmitter(
const core::vector3df& center, f32 radius,
const core::vector3df& normal, f32 length,
bool outlineOnly = false,
const core::vector3df& direction = core::vector3df(0.0f,0.0f,0.0f),
u32 minParticlesPerSecond = 5, u32 maxParticlesPerSecond = 10,
const video::SColor& minStartColor = video::SColor(255,0,0,0),
const video::SColor& maxStartColor = video::SColor(255,255,255,255),
u32 lifeTimeMin = 2000, u32 lifeTimeMax = 4000,
s32 maxAngleDegrees = 0 ) = 0;
//! Creates a mesh particle emitter.
//! \param mesh: Pointer to mesh to emit particles from
//! \param useNormalDirection: If true, the direction of each particle created will
//! be the normal of the vertex that it's emitting from. The normal is divided by the
//! normalDirectionModifier parameter, which defaults to 100.0f.
//! \param direction: Direction and speed of particle emission.
//! \param normalDirectionModifier: If the emitter is using the normal direction
//! then the normal of the vertex that is being emitted from is divided by this number.
//! \param mbNumber: This allows you to specify a specific meshBuffer for the IMesh*
//! to emit particles from. The default value is -1, which means a random meshBuffer
//! picked from all of the meshes meshBuffers will be selected to pick a random vertex from.
//! If the value is 0 or greater, it will only pick random vertices from the meshBuffer
//! specified by this value.
//! \param everyMeshVertex: If true, the emitter will emit between min/max particles every second,
//! for every vertex in the mesh, if false, it will emit between min/max particles from random vertices
//! in the mesh.
//! \param minParticlesPerSecond: Minimal amount of particles emitted per second.
//! \param maxParticlesPerSecond: Maximal amount of particles emitted per second.
//! \param minStartColor: Minimal initial start color of a particle.
//! The real color of every particle is calculated as random interpolation
//! between minStartColor and maxStartColor.
//! \param maxStartColor: Maximal initial start color of a particle.
//! The real color of every particle is calculated as random interpolation
//! between minStartColor and maxStartColor.
//! \param lifeTimeMin: Minimal lifetime of a particle, in milliseconds.
//! \param lifeTimeMax: Maximal lifetime of a particle, in milliseconds.
//! \param maxAngleDegrees: Maximal angle in degrees, the emitting direction
//! of the particle will differ from the orignial direction.
//! \return Returns a pointer to the created particle emitter.
//! To set this emitter as new emitter of this particle system,
//! just call setEmitter(). Note that you'll have to drop() the
//! returned pointer, after you don't need it any more, see
//! IReferenceCounted::drop() for more informations.
virtual IParticleMeshEmitter* createMeshEmitter(
scene::IMesh* mesh, bool useNormalDirection = true,
const core::vector3df& direction = core::vector3df(0.0f,0.0f,0.0f),
f32 normalDirectionModifier = 100.0f, s32 mbNumber = -1,
bool everyMeshVertex = false,
u32 minParticlesPerSecond = 5, u32 maxParticlesPerSecond = 10,
const video::SColor& minStartColor = video::SColor(255,0,0,0),
const video::SColor& maxStartColor = video::SColor(255,255,255,255),
u32 lifeTimeMin = 2000, u32 lifeTimeMax = 4000,
s32 maxAngleDegrees = 0 ) = 0;
//! Creates a point particle emitter.
//! \param direction: Direction and speed of particle emission.
//! \param minParticlesPerSecond: Minimal amount of particles emitted
//! per second.
//! \param maxParticlesPerSecond: Maximal amount of particles emitted
//! per second.
//! \param minStartColor: Minimal initial start color of a particle.
//! The real color of every particle is calculated as random interpolation
//! between minStartColor and maxStartColor.
//! \param maxStartColor: Maximal initial start color of a particle.
//! The real color of every particle is calculated as random interpolation
//! between minStartColor and maxStartColor.
//! \param lifeTimeMin: Minimal lifetime of a particle, in milliseconds.
//! \param lifeTimeMax: Maximal lifetime of a particle, in milliseconds.
//! \param maxAngleDegrees: Maximal angle in degrees, the emitting direction
//! of the particle will differ from the orignial direction.
//! \return Returns a pointer to the created particle emitter.
//! To set this emitter as new emitter of this particle system,
//! just call setEmitter(). Note that you'll have to drop() the
//! returned pointer, after you don't need it any more, see
//! IReferenceCounted::drop() for more informations.
virtual IParticlePointEmitter* createPointEmitter(
const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f),
u32 minParticlesPerSecond = 5,
u32 maxParticlesPerSecond = 10,
const video::SColor& minStartColor = video::SColor(255,0,0,0),
const video::SColor& maxStartColor = video::SColor(255,255,255,255),
u32 lifeTimeMin=2000, u32 lifeTimeMax=4000,
s32 maxAngleDegrees=0) = 0;
//! Creates a ring particle emitter.
//! \param center: Center of ring
//! \param radius: Distance of points from center, points will be rotated around the
//! Y axis at a random 360 degrees and will then be shifted by the provided ringThickness
//! values in each axis.
//! \param ringThickness : thickness of the ring or how wide the ring is
//! \param direction: Direction and speed of particle emission.
//! \param minParticlesPerSecond: Minimal amount of particles emitted
//! per second.
//! \param maxParticlesPerSecond: Maximal amount of particles emitted
//! per second.
//! \param minStartColor: Minimal initial start color of a particle.
//! The real color of every particle is calculated as random interpolation
//! between minStartColor and maxStartColor.
//! \param maxStartColor: Maximal initial start color of a particle.
//! The real color of every particle is calculated as random interpolation
//! between minStartColor and maxStartColor.
//! \param lifeTimeMin: Minimal lifetime of a particle, in milliseconds.
//! \param lifeTimeMax: Maximal lifetime of a particle, in milliseconds.
//! \param maxAngleDegrees: Maximal angle in degrees, the emitting direction
//! of the particle will differ from the orignial direction.
//! \return Returns a pointer to the created particle emitter.
//! To set this emitter as new emitter of this particle system,
//! just call setEmitter(). Note that you'll have to drop() the
//! returned pointer, after you don't need it any more, see
//! IReferenceCounted::drop() for more informations.
virtual IParticleRingEmitter* createRingEmitter(
const core::vector3df& center, f32 radius, f32 ringThickness,
const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f),
u32 minParticlesPerSecond = 5,
u32 maxParticlesPerSecond = 10,
const video::SColor& minStartColor = video::SColor(255,0,0,0),
const video::SColor& maxStartColor = video::SColor(255,255,255,255),
u32 lifeTimeMin=2000, u32 lifeTimeMax=4000,
s32 maxAngleDegrees=0) = 0;
//! Creates a sphere particle emitter.
//! \param center: Center of sphere
//! \param radius: Radius of sphere
//! \param direction: Direction and speed of particle emission.
//! \param minParticlesPerSecond: Minimal amount of particles emitted
//! per second.
//! \param maxParticlesPerSecond: Maximal amount of particles emitted
//! per second.
//! \param minStartColor: Minimal initial start color of a particle.
//! The real color of every particle is calculated as random interpolation
//! between minStartColor and maxStartColor.
//! \param maxStartColor: Maximal initial start color of a particle.
//! The real color of every particle is calculated as random interpolation
//! between minStartColor and maxStartColor.
//! \param lifeTimeMin: Minimal lifetime of a particle, in milliseconds.
//! \param lifeTimeMax: Maximal lifetime of a particle, in milliseconds.
//! \param maxAngleDegrees: Maximal angle in degrees, the emitting direction
//! of the particle will differ from the orignial direction.
//! \return Returns a pointer to the created particle emitter.
//! To set this emitter as new emitter of this particle system,
//! just call setEmitter(). Note that you'll have to drop() the
//! returned pointer, after you don't need it any more, see
//! IReferenceCounted::drop() for more informations.
virtual IParticleSphereEmitter* createSphereEmitter(
const core::vector3df& center, f32 radius,
const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f),
u32 minParticlesPerSecond = 5,
u32 maxParticlesPerSecond = 10,
const video::SColor& minStartColor = video::SColor(255,0,0,0),
const video::SColor& maxStartColor = video::SColor(255,255,255,255),
u32 lifeTimeMin=2000, u32 lifeTimeMax=4000,
s32 maxAngleDegrees=0) = 0;
//! Creates a point attraction affector. This affector modifies the positions of the
//! particles and attracts them to a specified point at a specified speed per second.
//! \param point: Point to attract particles to.
//! \param speed: Speed in units per second, to attract to the specified point.
//! \param attract: Whether the particles attract or detract from this point.
//! \param affectX: Whether or not this will affect the X position of the particle.
//! \param affectY: Whether or not this will affect the Y position of the particle.
//! \param affectZ: Whether or not this will affect the Z position of the particle.
//! \return Returns a pointer to the created particle affector.
//! To add this affector as new affector of this particle system,
//! just call addAffector(). Note that you'll have to drop() the
//! returned pointer, after you don't need it any more, see
//! IReferenceCounted::drop() for more informations.
virtual IParticleAttractionAffector* createAttractionAffector(
const core::vector3df& point, f32 speed = 1.0f, bool attract = true,
bool affectX = true, bool affectY = true, bool affectZ = true) = 0;
//! Creates a fade out particle affector. This affector modifies
//! the color of every particle and and reaches the final color
//! when the particle dies.
//! This affector looks really good, if the EMT_TRANSPARENT_VERTEX_ALPHA
//! material is used and the targetColor is video::SColor(0,0,0,0):
//! Particles are fading out into void with this setting.
//! \param targetColor: Color whereto the color of the particle is changed.
//! \param timeNeededToFadeOut: How much time in milli seconds
//! should the affector need to change the color to the targetColor.
//! \return Returns a pointer to the created particle affector.
//! To add this affector as new affector of this particle system,
//! just call addAffector(). Note that you'll have to drop() the
//! returned pointer, after you don't need it any more, see
//! IReferenceCounted::drop() for more informations.
virtual IParticleFadeOutAffector* createFadeOutParticleAffector(
const video::SColor& targetColor = video::SColor(0,0,0,0),
u32 timeNeededToFadeOut = 1000) = 0;
//! Creates a gravity affector. This affector modifies the direction
//! of the particle. It assumes that the particle is fired out of the
//! emitter with huge force, but is loosing this after some time
//! and is catched by the gravity then. This affector is ideal for
//! creating things like fountains.
//! \param gravity: Direction and force of gravity.
//! \param timeForceLost: Time in milli seconds when the force
//! of the emitter is totally lost and the particle does not move any more.
//! This is the time where gravity fully affects the particle.
//! \return Returns a pointer to the created particle affector.
//! To add this affector as new affector of this particle system,
//! just call addAffector(). Note that you'll have to drop() the
//! returned pointer, after you don't need it any more, see
//! IReferenceCounted::drop() for more informations.
virtual IParticleGravityAffector* createGravityAffector(
const core::vector3df& gravity = core::vector3df(0.0f,-0.03f,0.0f),
u32 timeForceLost = 1000) = 0;
//! Creates a rotation affector. This affector modifies the positions of the
//! particles and attracts them to a specified point at a specified speed per second.
//! \param speed: Rotation in degrees per second
//! \param pivotPoint: Point to rotate the particles around
//! \return Returns a pointer to the created particle affector.
//! To add this affector as new affector of this particle system,
//! just call addAffector(). Note that you'll have to drop() the
//! returned pointer, after you don't need it any more, see
//! IReferenceCounted::drop() for more informations.
virtual IParticleRotationAffector* createRotationAffector(
const core::vector3df& speed = core::vector3df(5.0f,5.0f,5.0f),
const core::vector3df& pivotPoint = core::vector3df(0.0f,0.0f,0.0f) ) = 0;
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,42 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_Q3_LEVEL_MESH_H_INCLUDED__
#define __I_Q3_LEVEL_MESH_H_INCLUDED__
#include "IAnimatedMesh.h"
#include "IQ3Shader.h"
namespace irr
{
namespace scene
{
//! Interface for a Mesh which can be loaded directly from a Quake3 .bsp-file.
/** The Mesh tries to load all textures of the map. There are currently
no additional methods in this class, but maybe there will be some in later
releases if there are feature requests. */
class IQ3LevelMesh : public IAnimatedMesh
{
public:
//! releases a Mesh from the Q3 Loader
virtual void releaseMesh ( s32 index ) = 0;
//! loads the shader definition
// either from file ( we assume /scripts on fileNameIsValid == 0 )
virtual const quake3::SShader * getShader ( const c8 * filename, s32 fileNameIsValid ) = 0;
//! returns a already loaded Shader
virtual const quake3::SShader * getShader ( u32 index ) const = 0;
//! get's an interface to the entities
virtual const quake3::tQ3EntityList & getEntityList () = 0;
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,609 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt / Thomas Alten
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_Q3_LEVEL_SHADER_H_INCLUDED__
#define __I_Q3_LEVEL_SHADER_H_INCLUDED__
#include "irrArray.h"
#include "fast_atof.h"
#include "IFileSystem.h"
#include "IVideoDriver.h"
#include "coreutil.h"
namespace irr
{
namespace scene
{
namespace quake3
{
static const core::stringc irrEmptyStringc("");
//! Hold the different Mesh Types used for getMesh
enum eQ3MeshIndex
{
E_Q3_MESH_GEOMETRY = 0,
E_Q3_MESH_ITEMS,
E_Q3_MESH_BILLBOARD,
E_Q3_MESH_SIZE
};
// we are not using gamma, so quake3 is very dark.
// define the standard multiplication for lightmaps and vertex colors
const video::E_MATERIAL_TYPE defaultLightMap = video::EMT_LIGHTMAP_M2;
const video::E_MODULATE_FUNC defaultModulate = video::EMFN_MODULATE_2X;
// some useful typedefs
typedef core::array< core::stringc > tStringList;
typedef core::array< video::ITexture* > tTexArray;
// name = "a b c .."
struct SVariable
{
core::stringc name;
core::stringc content;
void clear ()
{
name = "";
content = "";
}
s32 isValid () const
{
return name.size();
}
bool operator == ( const SVariable &other ) const
{
return name == other.name;
}
};
// string helper.. TODO: move to generic files
inline s32 isEqual ( const core::stringc &string, u32 &pos, const c8 *list[], u32 listSize )
{
const char * in = string.c_str () + pos;
for ( u32 i = 0; i != listSize; ++i )
{
if (string.size() < pos)
return -2;
u32 len = (u32) strlen ( list[i] );
if (string.size() < pos+len)
continue;
if ( in [len] != 0 && in [len] != ' ' )
continue;
if ( strncmp ( in, list[i], len ) )
continue;
pos += len + 1;
return (s32) i;
}
return -2;
}
inline f32 getAsFloat ( const core::stringc &string, u32 &pos )
{
const char * in = string.c_str () + pos;
f32 value = 0.f;
pos += (u32) ( core::fast_atof_move ( in, value ) - in ) + 1;
return value;
}
inline core::vector3df getAsVector3df ( const core::stringc &string, u32 &pos )
{
core::vector3df v;
v.X = getAsFloat ( string, pos );
v.Z = getAsFloat ( string, pos );
v.Y = getAsFloat ( string, pos );
return v;
}
/*
extract substrings
*/
inline void getAsStringList ( tStringList &list, s32 max, const core::stringc &string, u32 &startPos )
{
list.clear ();
s32 finish = 0;
s32 endPos;
do
{
endPos = string.findNext ( ' ', startPos );
if ( endPos == -1 )
{
finish = 1;
endPos = string.size();
}
list.push_back ( string.subString ( startPos, endPos - startPos ) );
startPos = endPos + 1;
if ( list.size() >= (u32) max )
finish = 1;
} while ( !finish );
}
struct SBlendFunc
{
SBlendFunc () : type ( video::EMT_SOLID ), param ( 0.f ) {}
video::E_MATERIAL_TYPE type;
f32 param;
};
// parses the content of Variable cull
inline bool getBackfaceCulling ( const core::stringc &string )
{
if ( string.size() == 0 )
return true;
bool ret = true;
static const c8 * funclist[] = { "none", "disable" };
u32 pos = 0;
switch ( isEqual ( string, pos, funclist, 2 ) )
{
case 0:
case 1:
ret = false;
break;
}
return ret;
}
// parses the content of Variable depthfunc
// return a z-test
inline u32 getDepthFunction ( const core::stringc &string )
{
if ( string.size() == 0 )
return 1;
u32 ret = 1;
static const c8 * funclist[] = { "lequal","equal" };
u32 pos = 0;
switch ( isEqual ( string, pos, funclist, 2 ) )
{
case 0:
ret = 1;
case 1:
ret = 2;
break;
}
return ret;
}
// parses the content of Variable blendfunc,alphafunc
inline static void getBlendFunc ( const core::stringc &string, SBlendFunc &blendfunc )
{
if ( string.size() == 0 )
return;
// maps to E_BLEND_FACTOR
static const c8 * funclist[] =
{
"gl_zero",
"gl_one",
"gl_dst_color",
"gl_one_minus_dst_color",
"gl_src_color",
"gl_one_minus_src_color",
"gl_src_alpha",
"gl_one_minus_src_alpha",
"gl_dst_alpha",
"gl_one_minus_dst_alpha",
"gl_src_alpha_sat",
"add",
"filter",
"blend",
"ge128",
"gt0"
};
u32 pos = 0;
s32 srcFact = isEqual ( string, pos, funclist, 16 );
if ( srcFact < 0 )
return;
u32 resolved = 0;
s32 dstFact = isEqual ( string, pos, funclist, 16 );
switch ( srcFact )
{
case video::EBF_ONE:
switch ( dstFact )
{
// gl_one gl_zero
case video::EBF_ZERO:
blendfunc.type = video::EMT_SOLID;
resolved = 1;
break;
// gl_one gl_one
case video::EBF_ONE:
blendfunc.type = video::EMT_TRANSPARENT_ADD_COLOR;
resolved = 1;
break;
} break;
case video::EBF_SRC_ALPHA:
switch ( dstFact )
{
// gl_src_alpha gl_one_minus_src_alpha
case video::EBF_ONE_MINUS_SRC_ALPHA:
blendfunc.type = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
blendfunc.param = 1.f / 255.f;
resolved = 1;
break;
} break;
case 11:
// add
blendfunc.type = video::EMT_TRANSPARENT_ADD_COLOR;
resolved = 1;
break;
case 12:
// filter = gl_dst_color gl_zero
blendfunc.type = video::EMT_ONETEXTURE_BLEND;
blendfunc.param = video::pack_texureBlendFunc ( video::EBF_DST_COLOR, video::EBF_ZERO, defaultModulate );
resolved = 1;
break;
case 13:
// blend
blendfunc.type = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
blendfunc.param = 1.f / 255.f;
resolved = 1;
break;
case 14:
// alphafunc ge128
blendfunc.type = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
blendfunc.param = 0.5f;
resolved = 1;
break;
case 15:
// alphafunc gt0
blendfunc.type = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
blendfunc.param = 1.f / 255.f;
resolved = 1;
break;
}
// use the generic blender
if ( 0 == resolved )
{
blendfunc.type = video::EMT_ONETEXTURE_BLEND;
blendfunc.param = video::pack_texureBlendFunc (
(video::E_BLEND_FACTOR) srcFact,
(video::E_BLEND_FACTOR) dstFact,
defaultModulate);
}
}
struct SModifierFunction
{
SModifierFunction ()
: masterfunc0 ( 0 ), masterfunc1(0), func ( 0 ),
tcgen( 8 ), base ( 0 ), amp ( 1 ), phase ( 0 ), freq ( 1 ), wave(1) {}
// "tcmod","deformvertexes","rgbgen", "tcgen"
s32 masterfunc0;
// depends
s32 masterfunc1;
// depends
s32 func;
s32 tcgen;
union
{
f32 base;
f32 bulgewidth;
};
union
{
f32 amp;
f32 bulgeheight;
};
f32 phase;
union
{
f32 freq;
f32 bulgespeed;
};
f32 wave;
f32 evaluate ( f32 dt ) const
{
// phase in 0 and 1..
f32 x = core::fract( (dt + phase ) * freq );
f32 y = 0.f;
switch ( func )
{
// sin
case 0:
y = (f32) sin ( x * core::PI64 * 2.0 );
break;
// cos
case 1:
y = (f32) cos ( x * core::PI64 * 2.0 );
break;
// square
case 2:
y = x < 0.5f ? 1.f : -1.f;
break;
// triangle
case 3:
y = x < 0.5f ? ( 2.f * x ) - 1.f : ( -2.f * x ) + 2.f;
break;
// sawtooth:
case 4:
y = x;
break;
// inverse sawtooth:
case 5:
y = 1.f - x;
break;
}
return base + ( y * amp );
}
};
//
inline void getModifierFunc ( SModifierFunction& fill, const core::stringc &string, u32 &pos )
{
if ( string.size() == 0 )
return;
static const c8 * funclist[] =
{
"sin","cos","square", "triangle", "sawtooth","inversesawtooth"
};
fill.func = quake3::isEqual ( string,pos, funclist,6 );
if ( fill.func == -2 )
fill.func = 0;
fill.base = quake3::getAsFloat ( string, pos );
fill.amp = quake3::getAsFloat ( string, pos );
fill.phase = quake3::getAsFloat ( string, pos );
fill.freq = quake3::getAsFloat ( string, pos );
}
struct SVarGroup
{
// simple assoziative array
s32 getIndex( const c8 * name ) const
{
SVariable search;
search.name = name;
return Variable.linear_search ( search );
}
// searches for Variable name and returns is content
// if Variable is not found a reference to an Empty String is returned
const core::stringc &get( const c8 * name ) const
{
s32 index = getIndex ( name );
if ( index < 0 )
return irrEmptyStringc;
return Variable [ index ].content;
}
bool isDefined ( const c8 * name, const c8 * content = 0 ) const
{
for ( u32 i = 0; i != Variable.size (); ++i )
{
if ( 0 == strcmp ( Variable[i].name.c_str(), name ) )
{
if ( 0 == content )
return true;
if ( 0 == strcmp ( Variable[i].content.c_str(), content ) )
return true;
}
}
return false;
}
core::array < SVariable > Variable;
};
struct SVarGroupList: public IReferenceCounted
{
SVarGroupList () {}
virtual ~SVarGroupList () {}
core::array < SVarGroup > VariableGroup;
};
//! A Parsed Shader Holding Variables ordered in Groups
class SShader
{
public:
bool operator == (const SShader &other ) const
{
return name == other.name;
}
bool operator < (const SShader &other ) const
{
return name < other.name;
}
const SVarGroup * getGroup ( u32 stage ) const
{
if ( 0 == VarGroup || stage >= VarGroup->VariableGroup.size () )
return 0;
return &VarGroup->VariableGroup [ stage ];
}
// id
s32 id;
// Shader: shader name ( also first variable in first Vargroup )
// Entity: classname ( variable in Group(1) )
core::stringc name;
SVarGroupList *VarGroup; // reference
};
typedef SShader SEntity;
typedef core::array < SEntity > tQ3EntityList;
/*
dump shader like original layout, regardless of internal data holding
no recursive folding..
*/
inline void dumpVarGroup ( core::stringc &dest, const SVarGroup * group, s32 stack )
{
core::stringc buf;
s32 i;
if ( stack > 0 )
{
buf = "";
for ( i = 0; i < stack - 1; ++i )
buf += '\t';
buf += "{\n";
dest.append ( buf );
}
for ( u32 g = 0; g != group->Variable.size(); ++g )
{
buf = "";
for ( i = 0; i < stack; ++i )
buf += '\t';
buf += group->Variable[g].name;
buf += " ";
buf += group->Variable[g].content;
buf += "\n";
dest.append ( buf );
}
if ( stack > 1 )
{
buf = "";
for ( i = 0; i < stack - 1; ++i )
buf += '\t';
buf += "}\n";
dest.append ( buf );
}
}
inline core::stringc & dumpShader ( core::stringc &dest, const SShader * shader )
{
dest = "";
if ( 0 == shader )
return dest;
const SVarGroup * group;
const u32 size = shader->VarGroup->VariableGroup.size ();
for ( u32 i = 0; i != size; ++i )
{
group = &shader->VarGroup->VariableGroup[ i ];
dumpVarGroup ( dest, group, core::clamp ( (s32) i, 0, 2 ) );
}
if ( size <= 1 )
{
dest.append ( "{\n" );
}
dest.append ( "}\n" );
return dest;
}
/*
quake3 doesn't care much about tga & jpg
load one or multiple files stored in name started at startPos to the texture array textures
if texture is not loaded 0 will be added ( to find missing textures easier)
*/
inline void getTextures ( tTexArray &textures ,
const core::stringc &name, u32 &startPos,
io::IFileSystem *fileSystem,
video::IVideoDriver* driver
)
{
static const char * extension[2] =
{
".jpg",
".tga"
};
tStringList stringList;
getAsStringList ( stringList, -1, name, startPos );
textures.clear();
core::stringc loadFile;
for ( u32 i = 0; i!= stringList.size (); ++i )
{
video::ITexture* texture = 0;
for ( u32 g = 0; g != 2 ; ++g )
{
core::cutFilenameExtension ( loadFile, stringList[i] ).append ( extension[g] );
if ( fileSystem->existFile ( loadFile.c_str() ) )
{
texture = driver->getTexture( loadFile.c_str () );
if ( texture )
{
break;
}
}
}
// take 0 Texture
textures.push_back(texture);
}
}
/*!
Manages various Quake3 Shader Styles
*/
class IShaderManager : public IReferenceCounted
{
};
} // end namespace quake3
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,60 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_READ_FILE_H_INCLUDED__
#define __I_READ_FILE_H_INCLUDED__
#include "IReferenceCounted.h"
namespace irr
{
namespace io
{
//! Interface providing read acess to a file.
class IReadFile : public virtual IReferenceCounted
{
public:
virtual ~IReadFile() {}
//! Reads an amount of bytes from the file.
//! \param buffer: Pointer to buffer where to read bytes will be written to.
//! \param sizeToRead: Amount of bytes to read from the file.
//! \return Returns how much bytes were read.
virtual s32 read(void* buffer, u32 sizeToRead) = 0;
//! Changes position in file, returns true if successful.
//! \param finalPos: Destination position in the file.
//! \param relativeMovement: If set to true, the position in the file is
//! changed relative to current position. Otherwise the position is changed
//! from beginning of file.
//! \return Returns true if successful, otherwise false.
virtual bool seek(long finalPos, bool relativeMovement = false) = 0;
//! Returns size of file.
//! \return Returns the size of the file in bytes.
virtual long getSize() const = 0;
//! Returns the current position in the file.
//! \return Returns the current position in the file in bytes.
virtual long getPos() const = 0;
//! Returns name of file.
//! \return Returns the file name as zero terminated character string.
virtual const c8* getFileName() const = 0;
};
//! Internal function, please do not use.
IReadFile* createReadFile(const c8* fileName);
//! Internal function, please do not use.
IReadFile* createLimitReadFile(const c8* fileName, IReadFile* alreadyOpenedFile, long areaSize);
//! Internal function, please do not use.
IReadFile* createMemoryReadFile(void* memory, long size, const c8* fileName, bool deleteMemoryWhenDropped);
} // end namespace io
} // end namespace irr
#endif

View File

@ -0,0 +1,159 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_IREFERENCE_COUNTED_H_INCLUDED__
#define __I_IREFERENCE_COUNTED_H_INCLUDED__
#include "irrTypes.h"
namespace irr
{
//! Base class of most objects of the Irrlicht Engine.
/** This class provides reference counting through the methods grab() and drop().
It also is able to store a debug string for every instance of an object.
Most objects of the Irrlicht
Engine are derived from IReferenceCounted, and so they are reference counted.
When you create an object in the Irrlicht engine, calling a method
which starts with 'create', an object is created, and you get a pointer
to the new object. If you no longer need the object, you have
to call drop(). This will destroy the object, if grab() was not called
in another part of you program, because this part still needs the object.
Note, that you only need to call drop() to the object, if you created it,
and the method had a 'create' in it.
A simple example:
If you want to create a texture, you may want to call an imaginable method
IDriver::createTexture. You call
ITexture* texture = driver->createTexture(dimension2d<s32>(128, 128));
If you no longer need the texture, call texture->drop().
If you want to load a texture, you may want to call imaginable method
IDriver::loadTexture. You do this like
ITexture* texture = driver->loadTexture("example.jpg");
You will not have to drop the pointer to the loaded texture, because
the name of the method does not start with 'create'. The texture
is stored somewhere by the driver.
*/
class IReferenceCounted
{
public:
//! Constructor.
IReferenceCounted()
: ReferenceCounter(1), DebugName(0)
{
}
//! Destructor.
virtual ~IReferenceCounted()
{
}
//! Grabs the object. Increments the reference counter by one.
//! Someone who calls grab() to an object, should later also call
//! drop() to it. If an object never gets as much drop() as grab()
//! calls, it will never be destroyed.
//! The IReferenceCounted class provides a basic reference counting mechanism
//! with its methods grab() and drop(). Most objects of the Irrlicht
//! Engine are derived from IReferenceCounted, and so they are reference counted.
//!
//! When you create an object in the Irrlicht engine, calling a method
//! which starts with 'create', an object is created, and you get a pointer
//! to the new object. If you no longer need the object, you have
//! to call drop(). This will destroy the object, if grab() was not called
//! in another part of you program, because this part still needs the object.
//! Note, that you only need to call drop() to the object, if you created it,
//! and the method had a 'create' in it.
//!
//! A simple example:
//!
//! If you want to create a texture, you may want to call an imaginable method
//! IDriver::createTexture. You call
//! ITexture* texture = driver->createTexture(dimension2d<s32>(128, 128));
//! If you no longer need the texture, call texture->drop().
//! If you want to load a texture, you may want to call imaginable method
//! IDriver::loadTexture. You do this like
//! ITexture* texture = driver->loadTexture("example.jpg");
//! You will not have to drop the pointer to the loaded texture, because
//! the name of the method does not start with 'create'. The texture
//! is stored somewhere by the driver.
void grab() const { ++ReferenceCounter; }
//! Drops the object. Decrements the reference counter by one.
//! Returns true, if the object was deleted.
//! The IReferenceCounted class provides a basic reference counting mechanism
//! with its methods grab() and drop(). Most objects of the Irrlicht
//! Engine are derived from IReferenceCounted, and so they are reference counted.
//!
//! When you create an object in the Irrlicht engine, calling a method
//! which starts with 'create', an object is created, and you get a pointer
//! to the new object. If you no longer need the object, you have
//! to call drop(). This will destroy the object, if grab() was not called
//! in another part of you program, because this part still needs the object.
//! Note, that you only need to call drop() to the object, if you created it,
//! and the method had a 'create' in it.
//!
//! A simple example:
//!
//! If you want to create a texture, you may want to call an imaginable method
//! IDriver::createTexture. You call
//! ITexture* texture = driver->createTexture(dimension2d<s32>(128, 128));
//! If you no longer need the texture, call texture->drop().
//! If you want to load a texture, you may want to call imaginable method
//! IDriver::loadTexture. You do this like
//! ITexture* texture = driver->loadTexture("example.jpg");
//! You will not have to drop the pointer to the loaded texture, because
//! the name of the method does not start with 'create'. The texture
//! is stored somewhere by the driver.
bool drop() const
{
_IRR_DEBUG_BREAK_IF(ReferenceCounter <= 0) // someone is doing bad reference counting.
--ReferenceCounter;
if (!ReferenceCounter)
{
delete this;
return true;
}
return false;
}
//! Returns the reference counter.
s32 getReferenceCount() const
{
return ReferenceCounter;
}
//! Returns the debug name of the object. The Debugname may only be set and
//! changed by the object itself. This method should only be used in Debug mode.
//! \return Returns a string, previously set by setDebugName();
const c8* getDebugName() const
{
return DebugName;
}
protected:
//! Sets the debug name of the object. The Debugname may only be set and
//! changed by the object itself. This method should only be used in Debug mode.
//! \param newName: New debug name to set.
void setDebugName(const c8* newName)
{
DebugName = newName;
}
private:
mutable s32 ReferenceCounter;
const c8* DebugName;
};
} // end namespace irr
#endif

View File

@ -0,0 +1,151 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_SCENE_COLLISION_MANAGER_H_INCLUDED__
#define __I_SCENE_COLLISION_MANAGER_H_INCLUDED__
#include "IReferenceCounted.h"
#include "vector3d.h"
#include "triangle3d.h"
#include "position2d.h"
#include "line3d.h"
namespace irr
{
namespace scene
{
class ISceneNode;
class ICameraSceneNode;
class ITriangleSelector;
//! The Scene Collision Manager provides methods for performing collision tests and picking on scene nodes.
class ISceneCollisionManager : public virtual IReferenceCounted
{
public:
//! destructor
virtual ~ISceneCollisionManager() {}
//! Finds the collision point of a line and lots of triangles, if there is one.
//! \param ray: Line with witch collisions are tested.
//! \param selector: TriangleSelector containing the triangles. It can
//! be created for example using ISceneManager::createTriangleSelector() or
//! ISceneManager::createTriangleOctTreeSelector().
//! \param outCollisionPoint: If a collision is detected, this will contain the
//! position of the nearest collision.
//! \param outTriangle: If a collision is detected, this will contain the triangle
//! with which the ray collided.
//! \return Returns true if a collision was detected and false if not.
virtual bool getCollisionPoint(const core::line3d<f32>& ray,
ITriangleSelector* selector, core::vector3df& outCollisionPoint,
core::triangle3df& outTriangle) = 0;
//! Collides a moving ellipsoid with a 3d world with gravity and returns
//! the resulting new position of the ellipsoid. This can be used for moving
//! a character in a 3d world: The character will slide at walls and is able
//! to walk up stairs. The method used how to calculate the collision result
//! position is based on the paper "Improved Collision detection and Response"
//! by Kasper Fauerby.
//! \param selector: TriangleSelector containing the triangles of the world.
//! It can be created for example using ISceneManager::createTriangleSelector() or
//! ISceneManager::createTriangleOctTreeSelector().
//! \param ellipsoidPosition: Position of the ellipsoid.
//! \param ellipsoidRadius: Radius of the ellipsoid.
//! \param ellipsoidDirectionAndSpeed: Direction and speed of
//! the movement of the ellipsoid.
//! \param triout: Optional parameter where the last triangle causing a
//! collision is stored, if there is a collision.
//! \param outFalling: Is set to true if the ellipsoid is falling down, caused
//! by gravity.
//! \param slidingSpeed: DOCUMENTATION NEEDED.
//! \param gravityDirectionAndSpeed: Direction and force of gravity.
//! \return Returns the new position of the ellipsoid.
virtual core::vector3df getCollisionResultPosition(
ITriangleSelector* selector,
const core::vector3df &ellipsoidPosition,
const core::vector3df& ellipsoidRadius,
const core::vector3df& ellipsoidDirectionAndSpeed,
core::triangle3df& triout,
bool& outFalling,
f32 slidingSpeed = 0.0005f,
const core::vector3df& gravityDirectionAndSpeed
= core::vector3df(0.0f, 0.0f, 0.0f)) = 0;
//! Returns a 3d ray which would go through the 2d screen coodinates.
//! \param pos: Screen coordinates in pixels.
//! \param camera: Camera from which the ray starts. If null, the
//! active camera is used.
//! \return Returns a ray starting from the position of the camera
//! and ending at a length of the far value of the camera at a position
//! which would be behind the 2d screen coodinates.
virtual core::line3d<f32> getRayFromScreenCoordinates(
core::position2d<s32> pos, ICameraSceneNode* camera = 0) = 0;
//! Calculates 2d screen position from a 3d position.
//! \param pos: 3D position in world space to be transformed into
//! 2d.
//! \param camera: Camera to be used. If null, the currently active
//! camera is used.
//! \return Returns the 2d screen coordinates which a object in the
//! 3d world would have if it would be rendered to the screen. If the
//! 3d position is behind the camera, it is set to (-10000,-10000). In
//! most cases you can ignore this fact, because if you use this method
//! for drawing a decorator over a 3d object, it will be clipped by the
//! screen borders.
virtual core::position2d<s32> getScreenCoordinatesFrom3DPosition(
core::vector3df pos, ICameraSceneNode* camera=0) = 0;
//! Returns the scene node, which is currently visible under the overgiven
//! screencoordinates, viewed from the currently active camera. The collision
//! tests are done using a bounding box for each scene node.
//! \param pos: Position in pixel screen coordinates, under which the returned
//! scene node will be.
//! \param idBitMask: Only scene nodes with an id with bits set like in this mask
//! will be tested. If the BitMask is 0, this feature is disabled.
//! \param bNoDebugObjects: Doesn't take debug objects into account when true. These
// are scene nodes with IsDebugObject() = true.
//! \return Returns the visible scene node under screen coordinates with matching
//! bits in its id. If there is no scene node under this position, 0 is returned.
virtual ISceneNode* getSceneNodeFromScreenCoordinatesBB(core::position2d<s32> pos,
s32 idBitMask=0, bool bNoDebugObjects = false) = 0;
//! Returns the nearest scene node which collides with a 3d ray and
//! which id matches a bitmask. The collision tests are done using a bounding
//! box for each scene node.
//! \param ray: Line with witch collisions are tested.
//! \param idBitMask: Only scene nodes with an id with bits set like in this mask
//! will be tested. If the BitMask is 0, this feature is disabled.
//! \param bNoDebugObjects: Doesn't take debug objects into account when true. These
// are scene nodes with IsDebugObject() = true.
//! \return Returns the scene node nearest to ray.start, which collides with the
//! ray and matches the idBitMask, if the mask is not null. If no scene
//! node is found, 0 is returned.
virtual ISceneNode* getSceneNodeFromRayBB(core::line3d<f32> ray,
s32 idBitMask=0, bool bNoDebugObjects = false) = 0;
//! Returns the scene node, at which the overgiven camera is looking at and
//! which id matches the bitmask. A ray is simply casted from the position
//! of the camera to the view target position, and all scene nodes are tested
//! against this ray. The collision tests are done using a bounding
//! box for each scene node.
//! \param camera: Camera from which the ray is casted.
//! \param idBitMask: Only scene nodes with an id with bits set like in this mask
//! will be tested. If the BitMask is 0, this feature is disabled.
//! \param bNoDebugObjects: Doesn't take debug objects into account when true. These
// are scene nodes with IsDebugObject() = true.
//! \return Returns the scene node nearest to the camera, which collides with the
//! ray and matches the idBitMask, if the mask is not null. If no scene
//! node is found, 0 is returned.
virtual ISceneNode* getSceneNodeFromCameraBB(ICameraSceneNode* camera,
s32 idBitMask=0, bool bNoDebugObjects = false) = 0;
};
} // end namespace scene
} // end namespace irr
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,710 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_SCENE_NODE_H_INCLUDED__
#define __I_SCENE_NODE_H_INCLUDED__
#include "IReferenceCounted.h"
#include "ESceneNodeTypes.h"
#include "ECullingTypes.h"
#include "EDebugSceneTypes.h"
#include "ISceneManager.h"
#include "ISceneNodeAnimator.h"
#include "ITriangleSelector.h"
#include "SMaterial.h"
#include "irrString.h"
#include "aabbox3d.h"
#include "matrix4.h"
#include "irrList.h"
#include "IAttributes.h"
#include "IAttributeExchangingObject.h"
namespace irr
{
namespace scene
{
//! Scene node interface.
/** A scene node is a node in the hirachical scene graph. Every scene node may have children,
which are other scene nodes. Children move relative the their parents position. If the parent of a node is not
visible, its children won't be visible too. In this way, it is for example easily possible
to attach a light to a moving car, or to place a walking character on a moving platform
on a moving ship. */
class ISceneNode : public io::IAttributeExchangingObject
{
public:
//! Constructor
ISceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id=-1,
const core::vector3df& position = core::vector3df(0,0,0),
const core::vector3df& rotation = core::vector3df(0,0,0),
const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f))
: RelativeTranslation(position), RelativeRotation(rotation), RelativeScale(scale),
Parent(parent), ID(id), SceneManager(mgr), TriangleSelector(0),
AutomaticCullingState(EAC_BOX), IsVisible(true),
DebugDataVisible(EDS_OFF), IsDebugObject(false)
{
if (Parent)
Parent->addChild(this);
updateAbsolutePosition();
}
//! Destructor
virtual ~ISceneNode()
{
// delete all children
removeAll();
// delete all animators
core::list<ISceneNodeAnimator*>::Iterator ait = Animators.begin();
for (; ait != Animators.end(); ++ait)
(*ait)->drop();
if (TriangleSelector)
TriangleSelector->drop();
}
//! This method is called just before the rendering process of the whole scene.
/** Nodes may register themselves in the render pipeline during this call,
precalculate the geometry which should be renderered, and prevent their
children from being able to register them selfes if they are clipped by simply
not calling their OnRegisterSceneNode-Method.
If you are implementing your own scene node, you should overwrite this method
with an implementtion code looking like this:
\code
if (IsVisible)
SceneManager->registerNodeForRendering(this);
ISceneNode::OnRegisterSceneNode();
\endcode
*/
virtual void OnRegisterSceneNode()
{
if (IsVisible)
{
core::list<ISceneNode*>::Iterator it = Children.begin();
for (; it != Children.end(); ++it)
(*it)->OnRegisterSceneNode();
}
}
//! OnAnimate() is called just before rendering the whole scene.
//! Nodes may calculate or store animations here, and may do other useful things,
//! dependent on what they are. Also, OnAnimate() should be called for all
//! child scene nodes here. This method will called once per frame, independent
//! of if the scene node is visible or not.
//! \param timeMs: Current time in milli seconds.
virtual void OnAnimate(u32 timeMs)
{
if (IsVisible)
{
// animate this node with all animators
core::list<ISceneNodeAnimator*>::Iterator ait = Animators.begin();
for (; ait != Animators.end(); ++ait)
(*ait)->animateNode(this, timeMs);
// update absolute position
updateAbsolutePosition();
// perform the post render process on all children
core::list<ISceneNode*>::Iterator it = Children.begin();
for (; it != Children.end(); ++it)
(*it)->OnAnimate(timeMs);
}
}
//! Renders the node.
virtual void render() = 0;
//! Returns the name of the node.
//! \return Returns name as wide character string.
virtual const c8* getName() const
{
return Name.c_str();
}
//! Sets the name of the node.
//! \param name: New name of the scene node.
virtual void setName(const c8* name)
{
Name = name;
}
//! Returns the axis aligned, not transformed bounding box of this node.
//! This means that if this node is a animated 3d character, moving in a room,
//! the bounding box will always be around the origin. To get the box in
//! real world coordinates, just transform it with the matrix you receive with
//! getAbsoluteTransformation() or simply use getTransformedBoundingBox(),
//! which does the same.
virtual const core::aabbox3d<f32>& getBoundingBox() const = 0;
//! Returns the axis aligned, transformed and animated absolute bounding box
//! of this node.
virtual const core::aabbox3d<f32> getTransformedBoundingBox() const
{
core::aabbox3d<f32> box = getBoundingBox();
AbsoluteTransformation.transformBox(box);
return box;
}
//! returns the absolute transformation of the node. Is recalculated every OnAnimate()-call.
const core::matrix4& getAbsoluteTransformation() const
{
return AbsoluteTransformation;
}
//! Returns the relative transformation of the scene node.
//! The relative transformation is stored internally as 3 vectors:
//! translation, rotation and scale. To get the relative transformation
//! matrix, it is calculated from these values.
//! \return Returns the relative transformation matrix.
virtual core::matrix4 getRelativeTransformation() const
{
core::matrix4 mat;
mat.setRotationDegrees(RelativeRotation);
mat.setTranslation(RelativeTranslation);
if (RelativeScale != core::vector3df(1,1,1))
{
core::matrix4 smat;
smat.setScale(RelativeScale);
mat *= smat;
}
return mat;
}
//! Returns true if the node is visible. This is only an option, set by the user and has
//! nothing to do with geometry culling
virtual bool isVisible() const
{
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
return IsVisible;
}
//! Sets if the node should be visible or not. All children of this node won't be visible too.
virtual void setVisible(bool isVisible)
{
IsVisible = isVisible;
}
//! Returns the id of the scene node. This id can be used to identify the node.
virtual s32 getID() const
{
return ID;
}
//! sets the id of the scene node. This id can be used to identify the node.
virtual void setID(s32 id)
{
ID = id;
}
//! Adds a child to this scene node. If the scene node already
//! has got a parent, it is removed from there as child.
virtual void addChild(ISceneNode* child)
{
if (child)
{
child->grab();
child->remove(); // remove from old parent
Children.push_back(child);
child->Parent = this;
}
}
//! Removes a child from this scene node.
//! \return Returns true if the child could be removed, and false if not.
virtual bool removeChild(ISceneNode* child)
{
core::list<ISceneNode*>::Iterator it = Children.begin();
for (; it != Children.end(); ++it)
if ((*it) == child)
{
(*it)->Parent = 0;
(*it)->drop();
Children.erase(it);
return true;
}
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
return false;
}
//! Removes all children of this scene node
virtual void removeAll()
{
core::list<ISceneNode*>::Iterator it = Children.begin();
for (; it != Children.end(); ++it)
{
(*it)->Parent = 0;
(*it)->drop();
}
Children.clear();
}
//! Removes this scene node from the scene, deleting it.
virtual void remove()
{
if (Parent)
Parent->removeChild(this);
}
//! Adds an animator which should animate this node.
virtual void addAnimator(ISceneNodeAnimator* animator)
{
if (animator)
{
Animators.push_back(animator);
animator->grab();
}
}
//! Returns a const reference to the list of all scene node animators.
const core::list<ISceneNodeAnimator*>& getAnimators() const
{
return Animators;
}
//! Removes an animator from this scene node.
virtual void removeAnimator(ISceneNodeAnimator* animator)
{
core::list<ISceneNodeAnimator*>::Iterator it = Animators.begin();
for (; it != Animators.end(); ++it)
if ((*it) == animator)
{
(*it)->drop();
Animators.erase(it);
return;
}
}
//! Removes all animators from this scene node.
virtual void removeAnimators()
{
core::list<ISceneNodeAnimator*>::Iterator it = Animators.begin();
for (; it != Animators.end(); ++it)
(*it)->drop();
Animators.clear();
}
//! Returns the material based on the zero based index i. To get the amount
//! of materials used by this scene node, use getMaterialCount().
//! This function is needed for inserting the node into the scene hirachy on a
//! optimal position for minimizing renderstate changes, but can also be used
//! to directly modify the material of a scene node.
//! \param num: Zero based index. The maximal value is getMaterialCount() - 1.
//! \return Returns the material of that index.
virtual video::SMaterial& getMaterial(u32 num)
{
return *((video::SMaterial*)0);
}
//! Returns amount of materials used by this scene node.
//! \return Returns current count of materials used by this scene node.
virtual u32 getMaterialCount() const
{
return 0;
}
//! Sets all material flags at once to a new value. Helpful for
//! example, if you want to be the the whole mesh to be lighted by
//! \param flag: Which flag of all materials to be set.
//! \param newvalue: New value of the flag.
void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue)
{
for (u32 i=0; i<getMaterialCount(); ++i)
getMaterial(i).setFlag(flag, newvalue);
}
//! Sets the texture of the specified layer in all materials of this
//! scene node to the new texture.
//! \param textureLayer: Layer of texture to be set. Must be a value greater or
//! equal than 0 and smaller than MATERIAL_MAX_TEXTURES.
//! \param texture: Texture to be used.
void setMaterialTexture(u32 textureLayer, video::ITexture* texture)
{
if (textureLayer >= video::MATERIAL_MAX_TEXTURES)
return;
for (u32 i=0; i<getMaterialCount(); ++i)
getMaterial(i).setTexture(textureLayer, texture);
}
//! Sets the material type of all materials s32 this scene node
//! to a new material type.
//! \param newType: New type of material to be set.
void setMaterialType(video::E_MATERIAL_TYPE newType)
{
for (u32 i=0; i<getMaterialCount(); ++i)
getMaterial(i).MaterialType = newType;
}
//! Gets the scale of the scene node.
/** \return Returns the scale of the scene node. */
virtual core::vector3df getScale() const
{
return RelativeScale;
}
//! Sets the scale of the scene node.
/** \param scale: New scale of the node */
virtual void setScale(const core::vector3df& scale)
{
RelativeScale = scale;
}
//! Gets the rotation of the node.
/** Note that this is the relative rotation of the node.
\return Current relative rotation of the scene node. */
virtual const core::vector3df& getRotation() const
{
return RelativeRotation;
}
//! Sets the rotation of the node.
/** This only modifies the relative rotation of the node.
\param rotation: New rotation of the node in degrees. */
virtual void setRotation(const core::vector3df& rotation)
{
RelativeRotation = rotation;
}
//! Gets the position of the node.
/** Note that the position is relative to the parent.
\return Returns the current position of the node relative to the parent. */
virtual const core::vector3df getPosition() const
{
return RelativeTranslation;
}
//! Sets the position of the node.
/** Note that the position is relative to the parent.
\param newpos: New relative postition of the scene node. */
virtual void setPosition(const core::vector3df& newpos)
{
RelativeTranslation = newpos;
}
//! Gets the abolute position of the node.
/** The position is absolute.
\return Returns the current absolute position of the scene node. */
virtual core::vector3df getAbsolutePosition() const
{
return AbsoluteTransformation.getTranslation();
}
//! Enables or disables automatic culling based on the bounding box.
/** Automatic culling is enabled by default. Note that not
all SceneNodes support culling (e.g. the billboard scene node)
and that some nodes always cull their geometry because it is their
only reason for existence, for example the OctreeSceneNode.
\param state: The culling state to be used. */
void setAutomaticCulling( E_CULLING_TYPE state)
{
AutomaticCullingState = state;
}
//! Gets the automatic culling state.
/** \return The node is culled based on its bounding box if this method
returns true, otherwise no culling is performed. */
E_CULLING_TYPE getAutomaticCulling() const
{
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
return AutomaticCullingState;
}
//! Sets if debug data like bounding boxes should be drawn.
/** Please note that not all scene nodes support this feature. */
virtual void setDebugDataVisible(E_DEBUG_SCENE_TYPE visible)
{
DebugDataVisible = visible;
}
//! Returns if debug data like bounding boxes are drawed.
E_DEBUG_SCENE_TYPE isDebugDataVisible() const
{
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
return DebugDataVisible;
}
//! Sets if this scene node is a debug object.
/** Debug objects have some special properties, for example they can be easily
excluded from collision detection or from serialization, etc. */
void setIsDebugObject(bool debugObject)
{
IsDebugObject = debugObject;
}
//! Returns if this scene node is a debug object.
/** Debug objects have some special properties, for example they can be easily
excluded from collision detection or from serialization, etc. */
bool isDebugObject() const
{
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
return IsDebugObject;
}
//! Returns a const reference to the list of all children.
const core::list<ISceneNode*>& getChildren() const
{
return Children;
}
//! Changes the parent of the scene node.
virtual void setParent(ISceneNode* newParent)
{
grab();
remove();
Parent = newParent;
if (Parent)
Parent->addChild(this);
drop();
}
//! Returns the triangle selector attached to this scene node.
//! The Selector can be used by the engine for doing collision
//! detection. You can create a TriangleSelector with
//! ISceneManager::createTriangleSelector() or
//! ISceneManager::createOctTreeTriangleSelector and set it with
//! ISceneNode::setTriangleSelector(). If a scene node got no triangle
//! selector, but collision tests should be done with it, a triangle
//! selector is created using the bounding box of the scene node.
//! \return Returns a pointer to the TriangleSelector or NULL, if there
//! is none.
virtual ITriangleSelector* getTriangleSelector() const
{
return TriangleSelector;
}
//! Sets the triangle selector of the scene node. The Selector can be
//! used by the engine for doing collision detection. You can create a
//! TriangleSelector with ISceneManager::createTriangleSelector() or
//! ISceneManager::createOctTreeTriangleSelector(). Some nodes may
//! create their own selector by default, so it would be good to
//! check if there is already a selector in this node by calling
//! ISceneNode::getTriangleSelector().
//! \param selector: New triangle selector for this scene node.
virtual void setTriangleSelector(ITriangleSelector* selector)
{
if (TriangleSelector)
TriangleSelector->drop();
TriangleSelector = selector;
if (TriangleSelector)
TriangleSelector->grab();
}
//! updates the absolute position based on the relative and the parents position
virtual void updateAbsolutePosition()
{
if (Parent )
{
AbsoluteTransformation =
Parent->getAbsoluteTransformation() * getRelativeTransformation();
}
else
AbsoluteTransformation = getRelativeTransformation();
}
//! Returns the parent of this scene node
scene::ISceneNode* getParent() const
{
return Parent;
}
//! Returns type of the scene node
virtual ESCENE_NODE_TYPE getType() const
{
return ESNT_UNKNOWN;
}
//! Writes attributes of the scene node.
//! Implement this to expose the attributes of your scene node for
//! scripting languages, editors, debuggers or xml serialization purposes.
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const
{
out->addString ("Name", Name.c_str());
out->addInt ("Id", ID );
out->addVector3d("Position", getPosition() );
out->addVector3d("Rotation", getRotation() );
out->addVector3d("Scale", getScale() );
out->addBool ("Visible", IsVisible );
out->addEnum ("AutomaticCulling", AutomaticCullingState, AutomaticCullingNames);
out->addInt ("DebugDataVisible", DebugDataVisible );
out->addBool ("IsDebugObject", IsDebugObject );
}
//! Reads attributes of the scene node.
//! Implement this to set the attributes of your scene node for
//! scripting languages, editors, debuggers or xml deserialization purposes.
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0)
{
Name = in->getAttributeAsString("Name");
ID = in->getAttributeAsInt("Id");
setPosition(in->getAttributeAsVector3d("Position"));
setRotation(in->getAttributeAsVector3d("Rotation"));
setScale(in->getAttributeAsVector3d("Scale"));
IsVisible = in->getAttributeAsBool("Visible");
AutomaticCullingState = (scene::E_CULLING_TYPE ) in->getAttributeAsEnumeration("AutomaticCulling", scene::AutomaticCullingNames);
DebugDataVisible = (scene::E_DEBUG_SCENE_TYPE ) in->getAttributeAsInt("DebugDataVisible");
IsDebugObject = in->getAttributeAsBool("IsDebugObject");
updateAbsolutePosition();
}
//! Creates a clone of this scene node and its children.
virtual ISceneNode* clone(ISceneNode* newParent=0, ISceneManager* newManager=0)
{
return 0; // to be implemented by derived classes
}
protected:
//! this method can be used by clone() implementations of derived classes
void cloneMembers(ISceneNode* toCopyFrom, ISceneManager* newManager)
{
Name = toCopyFrom->Name;
AbsoluteTransformation = toCopyFrom->AbsoluteTransformation;
RelativeTranslation = toCopyFrom->RelativeTranslation;
RelativeRotation = toCopyFrom->RelativeRotation;
RelativeScale = toCopyFrom->RelativeScale;
ID = toCopyFrom->ID;
setTriangleSelector(toCopyFrom->TriangleSelector);
AutomaticCullingState = toCopyFrom->AutomaticCullingState;
DebugDataVisible = toCopyFrom->DebugDataVisible;
IsVisible = toCopyFrom->IsVisible;
IsDebugObject = toCopyFrom->IsDebugObject;
if (newManager)
SceneManager = newManager;
else
SceneManager = toCopyFrom->SceneManager;
// clone children
core::list<ISceneNode*>::Iterator it = toCopyFrom->Children.begin();
for (; it != toCopyFrom->Children.end(); ++it)
(*it)->clone(this, newManager);
// clone animators
core::list<ISceneNodeAnimator*>::Iterator ait = toCopyFrom->Animators.begin();
for (; ait != toCopyFrom->Animators.end(); ++ait)
{
ISceneNodeAnimator* anim = (*ait)->createClone(this, SceneManager);
if (anim)
{
addAnimator(anim);
anim->drop();
}
}
}
//! name of the scene node.
core::stringc Name;
//! absolute transformation of the node.
core::matrix4 AbsoluteTransformation;
//! relative translation of the scene node.
core::vector3df RelativeTranslation;
//! relative rotation of the scene node.
core::vector3df RelativeRotation;
//! relative scale of the scene node.
core::vector3df RelativeScale;
//! Pointer to the parent
ISceneNode* Parent;
//! List of all children of this node
core::list<ISceneNode*> Children;
//! List of all animator nodes
core::list<ISceneNodeAnimator*> Animators;
//! id of the node.
s32 ID;
//! pointer to the scene manager
ISceneManager* SceneManager;
//! pointer to the triangle selector
ITriangleSelector* TriangleSelector;
//! automatic culling
E_CULLING_TYPE AutomaticCullingState;
//! is the node visible?
bool IsVisible;
//! flag if debug data should be drawn, such as Bounding Boxes.
E_DEBUG_SCENE_TYPE DebugDataVisible;
//! is debug object?
bool IsDebugObject;
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,59 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_SCENE_NODE_ANIMATOR_H_INCLUDED__
#define __I_SCENE_NODE_ANIMATOR_H_INCLUDED__
#include "IReferenceCounted.h"
#include "vector3d.h"
#include "ESceneNodeAnimatorTypes.h"
#include "IAttributeExchangingObject.h"
namespace irr
{
namespace io
{
class IAttributes;
} // end namespace io
namespace scene
{
class ISceneNode;
class ISceneManager;
//! Animates a scene node. Can animate position, rotation, material, and so on.
/** A scene node animator is able to animate a scene node in a very simple way. It may
change its position, rotation, scale and/or material. There are lots of animators
to choose from. You can create scene node animators with the ISceneManager interface.
*/
class ISceneNodeAnimator : public io::IAttributeExchangingObject
{
public:
//! destructor
virtual ~ISceneNodeAnimator() {}
//! Animates a scene node.
//! \param node: Node to animate.
//! \param timeMs: Current time in milli seconds.
virtual void animateNode(ISceneNode* node, u32 timeMs) = 0;
//! Creates a clone of this animator.
/** Please note that you will have to drop (IReferenceCounted::drop())
the returned pointer after calling this. */
virtual ISceneNodeAnimator* createClone(ISceneNode* node, ISceneManager* newManager=0)
{
return 0; // to be implemented by derived classes.
}
//! Returns type of the scene node animator
virtual ESCENE_NODE_ANIMATOR_TYPE getType() const
{
return ESNAT_UNKNOWN;
}
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,93 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_SCENE_NODE_ANIMATOR_COLLISION_RESPONSE_H_INCLUDED__
#define __I_SCENE_NODE_ANIMATOR_COLLISION_RESPONSE_H_INCLUDED__
#include "ISceneNode.h"
namespace irr
{
namespace scene
{
//! Special scene node animator for doing automatic collision detection and response.
/** This scene node animator can be attached to any scene node modifying it in that
way, that it cannot move through walls of the world, is influenced by gravity and
acceleration. This animator is useful for example for first person shooter
games. Attach it for example to a first person shooter camera, and the camera will
behave as the player control in a first person shooter game: The camera stops and
slides at walls, walks up stairs, falls down if there is no floor under it, and so on.
*/
class ISceneNodeAnimatorCollisionResponse : public ISceneNodeAnimator
{
public:
//! destructor
virtual ~ISceneNodeAnimatorCollisionResponse() {}
//! Returns if the attached scene node is falling, which means that
//! there is no blocking wall from the scene node in the direction of
//! the gravity. The implementation of this method is very fast,
//! no collision detection is done when invoking it.
//! \return Returns true if the scene node is falling, false if not.
virtual bool isFalling() const = 0;
//! Sets the radius of the ellipsoid with which collision detection and
//! response is done. If you have got a scene node, and you are unsure about
//! how big the radius should be, you could use the following code to determine
//! it:
//! \code
//! core::aabbox<f32> box = yourSceneNode->getBoundingBox();
//! core::vector3df radius = box.MaxEdge - box.getCenter();
//! \endcode
//! \param radius: New radius of the ellipsoid.
virtual void setEllipsoidRadius(const core::vector3df& radius) = 0;
//! Returns the radius of the ellipsoid with which the collision detection and
//! response is done.
//! \return Radius of the ellipsoid.
virtual core::vector3df getEllipsoidRadius() const = 0;
//! Sets the gravity of the environment. A good example value would be
//! core::vector3df(0,-100.0f,0) for letting gravity affect all object to
//! fall down. For bigger gravity, make increase the length of the vector.
//! You can disable gravity by setting it to core::vector3df(0,0,0);
//! \param gravity: New gravity vector.
virtual void setGravity(const core::vector3df& gravity) = 0;
//! Returns current vector of gravity.
//! \return Returns the gravity vector.
virtual core::vector3df getGravity() const = 0;
//! By default, the ellipsoid for collision detection is created around
//! the center of the scene node, which means that the ellipsoid surrounds
//! it completely. If this is not what you want, you may specify a translation
//! for the ellipsoid.
//! \param translation: Translation of the ellipsoid relative
//! to the position of the scene node.
virtual void setEllipsoidTranslation(const core::vector3df &translation) = 0;
//! Returns the translation of the ellipsoid for collision detection. See
//! ISceneNodeAnimatorCollisionResponse::setEllipsoidTranslation() for
//! more details.
//! \return Returns the tranlation of the ellipsoid relative to the position
//! of the scene node.
virtual core::vector3df getEllipsoidTranslation() const = 0;
//! Sets a triangle selector holding all triangles of the world with which
//! the scene node may collide.
//! \param newWorld: New triangle selector containing triangles to let the
//! scene node collide with.
virtual void setWorld(ITriangleSelector* newWorld) = 0;
//! Returns the current triangle selector containing all triangles for
//! collision detection.
virtual ITriangleSelector* getWorld() const = 0;
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,71 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_SCENE_NODE_ANIMATOR_FACTORY_H_INCLUDED__
#define __I_SCENE_NODE_ANIMATOR_FACTORY_H_INCLUDED__
#include "IReferenceCounted.h"
#include "ESceneNodeAnimatorTypes.h"
namespace irr
{
namespace scene
{
class ISceneNode;
class ISceneNodeAnimator;
//! Interface making it possible to dynamicly create scene nodes animators
/** To be able to add custom scene node animators to Irrlicht and to make it possible for the
scene manager to save and load those external animators, simply implement this
interface and register it in you scene manager via ISceneManager::registerSceneNodeAnimatorFactory.
Note: When implementing your own scene node factory, don't call ISceneNodeManager::grab() to
increase the reference counter of the scene node manager. This is not necessary because the
scene node manager will grab() the factory anyway, and otherwise cyclic references will
be created and the scene manager and all its nodes won't get deallocated.
*/
class ISceneNodeAnimatorFactory : public virtual IReferenceCounted
{
public:
virtual ~ISceneNodeAnimatorFactory() {}
//! creates a scene node animator based on its type id
/** \param type: Type of the scene node animator to add.
\param target: Target scene node of the new animator.
\return Returns pointer to the new scene node animator or null if not successful. You need to
drop this pointer after calling this, see IReferenceCounted::drop() for details. */
virtual ISceneNodeAnimator* createSceneNodeAnimator(ESCENE_NODE_ANIMATOR_TYPE type, ISceneNode* target) = 0;
//! creates a scene node animator based on its type name
/** \param typeName: Type of the scene node animator to add.
\param target: Target scene node of the new animator.
\return Returns pointer to the new scene node animator or null if not successful. You need to
drop this pointer after calling this, see IReferenceCounted::drop() for details. */
virtual ISceneNodeAnimator* createSceneNodeAnimator(const c8* typeName, ISceneNode* target) = 0;
//! returns amount of scene node animator types this factory is able to create
virtual u32 getCreatableSceneNodeAnimatorTypeCount() const = 0;
//! returns type of a createable scene node animator type
/** \param idx: Index of scene node animator type in this factory. Must be a value between 0 and
getCreatableSceneNodeTypeCount() */
virtual ESCENE_NODE_ANIMATOR_TYPE getCreateableSceneNodeAnimatorType(u32 idx) const = 0;
//! returns type name of a createable scene node animator type
/** \param idx: Index of scene node animator type in this factory. Must be a value between 0 and
getCreatableSceneNodeAnimatorTypeCount() */
virtual const c8* getCreateableSceneNodeAnimatorTypeName(u32 idx) const = 0;
//! returns type name of a createable scene node animator type
/** \param type: Type of scene node animator.
\return: Returns name of scene node animator type if this factory can create the type, otherwise 0. */
virtual const c8* getCreateableSceneNodeAnimatorTypeName(ESCENE_NODE_ANIMATOR_TYPE type) const = 0;
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,70 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_SCENE_NODE_FACTORY_H_INCLUDED__
#define __I_SCENE_NODE_FACTORY_H_INCLUDED__
#include "IReferenceCounted.h"
#include "ESceneNodeTypes.h"
namespace irr
{
namespace scene
{
class ISceneNode;
//! Interface making it possible to dynamicly create scene nodes
/** To be able to add custom scene nodes to Irrlicht and to make it possible for the
scene manager to save and load those external scene nodes, simply implement this
interface and register it in you scene manager via ISceneManager::registerSceneNodeFactory.
Note: When implementing your own scene node factory, don't call ISceneNodeManager::grab() to
increase the reference counter of the scene node manager. This is not necessary because the
scene node manager will grab() the factory anyway, and otherwise cyclic references will
be created and the scene manager and all its nodes won't get deallocated.
*/
class ISceneNodeFactory : public virtual IReferenceCounted
{
public:
virtual ~ISceneNodeFactory() {}
//! adds a scene node to the scene graph based on its type id
/** \param type: Type of the scene node to add.
\param parent: Parent scene node of the new node, can be null to add the scene node to the root.
\return Returns pointer to the new scene node or null if not successful. */
virtual ISceneNode* addSceneNode(ESCENE_NODE_TYPE type, ISceneNode* parent=0) = 0;
//! adds a scene node to the scene graph based on its type name
/** \param typeName: Type name of the scene node to add.
\param parent: Parent scene node of the new node, can be null to add the scene node to the root.
\return Returns pointer to the new scene node or null if not successful. */
virtual ISceneNode* addSceneNode(const c8* typeName, ISceneNode* parent=0) = 0;
//! returns amount of scene node types this factory is able to create
virtual u32 getCreatableSceneNodeTypeCount() const = 0;
//! returns type of a createable scene node type
/** \param idx: Index of scene node type in this factory. Must be a value between 0 and
getCreatableSceneNodeTypeCount() */
virtual ESCENE_NODE_TYPE getCreateableSceneNodeType(u32 idx) const = 0;
//! returns type name of a createable scene node type by index
/** \param idx: Index of scene node type in this factory. Must be a value between 0 and
getCreatableSceneNodeTypeCount() */
virtual const c8* getCreateableSceneNodeTypeName(u32 idx) const = 0;
//! returns type name of a createable scene node type
/** \param type: Type of scene node.
\return: Returns name of scene node type if this factory can create the type, otherwise 0. */
virtual const c8* getCreateableSceneNodeTypeName(ESCENE_NODE_TYPE type) const = 0;
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,48 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_SCENE_USER_DATA_SERIALIZER_H_INCLUDED__
#define __I_SCENE_USER_DATA_SERIALIZER_H_INCLUDED__
#include "IReferenceCounted.h"
namespace irr
{
namespace io
{
class IAttributes;
} // end namespace io
namespace scene
{
class ISceneNode;
//! Interface to read and write user data to and from .irr files.
/** This interface is to be imlpemented by the user, to make it possible to read
and write user data when reading or writing .irr files via ISceneManager.
To be used with ISceneManager::loadScene() and ISceneManager::saveScene() */
class ISceneUserDataSerializer
{
public:
virtual ~ISceneUserDataSerializer() {}
//! Called when the scene manager read a scene node while loading a file.
/** The userData pointer contains a list of attributes with userData which
were attached to the scene node in the read scene file.*/
virtual void OnReadUserData(ISceneNode* forSceneNode, io::IAttributes* userData) = 0;
//! Called when the scene manager is writing a scene node to an xml file for example.
/** Implement this method and return a list of attributes containing the user data
you want to be saved together with the scene node. Return 0 if no user data should
be added. Please note that the scene manager will call drop() to the returned pointer
after it no longer needs it, so if you didn't create a new object for the return value
and returning a longer existing IAttributes object, simply call grab() before returning it. */
virtual io::IAttributes* createUserData(ISceneNode* forSceneNode) = 0;
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,66 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_SHADER_CONSTANT_SET_CALLBACT_H_INCLUDED__
#define __I_SHADER_CONSTANT_SET_CALLBACT_H_INCLUDED__
#include "IReferenceCounted.h"
namespace irr
{
namespace video
{
class IMaterialRendererServices;
//! Interface making it possible to set constants for gpu programs every frame.
/** Implement this interface in an own class and pass a pointer to it to one of the methods in
IGPUProgrammingServices when creating a shader. The OnSetConstants method will be called
every frame now. */
class IShaderConstantSetCallBack : public virtual IReferenceCounted
{
public:
//! Destructor.
virtual ~IShaderConstantSetCallBack() {}
//! Called by the engine when the vertex and/or pixel shader constants for an material renderer should be set.
/**
Implement the IShaderConstantSetCallBack in an own class and implement your own
OnSetConstants method using the given IMaterialRendererServices interface.
Pass a pointer to this class to one of the methods in IGPUProgrammingServices
when creating a shader. The OnSetConstants method will now be called every time
before geometry is being drawn using your shader material. A sample implementation
would look like this:
\code
virtual void OnSetConstants(video::IMaterialRendererServices* services, s32 userData)
{
video::IVideoDriver* driver = services->getVideoDriver();
// set clip matrix at register 4
core::matrix4 worldViewProj(driver->getTransform(video::ETS_PROJECTION));
worldViewProj *= driver->getTransform(video::ETS_VIEW);
worldViewProj *= driver->getTransform(video::ETS_WORLD);
services->setVertexShaderConstant(&worldViewProj.M[0], 4, 4);
// for high level shading languages, this would be another solution:
//services->setVertexShaderConstant("mWorldViewProj", worldViewProj.M, 16);
// set some light color at register 9
video::SColorf col(0.0f,1.0f,1.0f,0.0f);
services->setVertexShaderConstant(reinterpret_cast<const f32*>(&col), 9, 1);
// for high level shading languages, this would be another solution:
//services->setVertexShaderConstant("myColor", reinterpret_cast<f32*>(&col), 4);
}
\endcode
\param services: Pointer to an interface providing methods to set the constants for the shader.
\param userData: Userdata int which can be specified when creating the shader.
*/
virtual void OnSetConstants(IMaterialRendererServices* services, s32 userData) = 0;
};
} // end namespace video
} // end namespace irr
#endif

View File

@ -0,0 +1,33 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_SHADOW_VOLUME_SCENE_NODE_H_INCLUDED__
#define __I_SHADOW_VOLUME_SCENE_NODE_H_INCLUDED__
#include "ISceneNode.h"
namespace irr
{
namespace scene
{
class IMesh;
//! Scene node for rendering a shadow volume into a stencil buffer.
class IShadowVolumeSceneNode : public ISceneNode
{
public:
//! constructor
IShadowVolumeSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id)
: ISceneNode(parent, mgr, id) {}
//! sets the mesh from which the shadow volume should be generated.
virtual void setMeshToRenderFrom(const IMesh* mesh) = 0;
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,204 @@
// Copyright (C) 2002-2006 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_SKINNED_MESH_H_INCLUDED__
#define __I_SKINNED_MESH_H_INCLUDED__
#include "irrArray.h"
#include "IBoneSceneNode.h"
#include "IAnimatedMesh.h"
#include "SSkinMeshBuffer.h"
namespace irr
{
namespace scene
{
enum E_INTERPOLATION_MODE
{
// constant interpolation
EIM_CONSTANT = 0,
// linear interpolation
EIM_LINEAR,
//! count of all available interpolation modes
EIM_COUNT
};
//! Interface for using some special functions of Skinned meshes
class ISkinnedMesh : public IAnimatedMesh
{
public:
//! Gets joint count.
//! \return Returns amount of joints in the skeletal animated mesh.
virtual u32 getJointCount() const = 0;
//! Gets the name of a joint.
//! \param number: Zero based index of joint. The last joint
//! has the number getJointCount()-1;
//! \return Returns name of joint and null if an error happened.
virtual const c8* getJointName(u32 number) const = 0;
//! Gets a joint number from its name
//! \param name: Name of the joint.
//! \return Returns the number of the joint or -1 if not found.
virtual s32 getJointNumber(const c8* name) const = 0;
//! uses animation from another mesh
//! the animation is linked (not copied) based on joint names (so make sure they are unique)
//! \return Returns true if all joints in this mesh were matched up (empty names will not be matched, and it's case sensitive)
//! unmatched joints will not be animated
virtual bool useAnimationFrom(const ISkinnedMesh *mesh) = 0;
//!Update Normals when Animating
//!False= Don't animate, faster
//!True= Update normals
virtual void updateNormalsWhenAnimating(bool on) = 0;
//!Sets Interpolation Mode
virtual void setInterpolationMode(E_INTERPOLATION_MODE mode) = 0;
//! Animates this mesh's joints based on frame input
virtual void animateMesh(f32 frame, f32 blend)=0;
//! Preforms a software skin on this mesh based of joint positions
virtual void skinMesh() = 0;
virtual void convertMeshToTangents() = 0;
//! A vertex weight
struct SWeight
{
//! Index of the mesh buffer
u16 buffer_id; //I doubt 32bits is needed
//! Index of the vertex
u32 vertex_id; //Store global ID here
//! Weight Strength/Percentage (0-1)
f32 strength;
private:
//! Internal members used by CSkinnedMesh
friend class CSkinnedMesh;
bool *Moved;
core::vector3df StaticPos;
core::vector3df StaticNormal;
};
//! Animation keyframe which describes a new position, scale or rotation
struct SPositionKey
{
f32 frame;
core::vector3df position;
};
struct SScaleKey
{
f32 frame;
core::vector3df scale;
};
struct SRotationKey
{
f32 frame;
core::quaternion rotation;
};
//! Joints
struct SJoint
{
SJoint() : UseAnimationFrom(0), LocalAnimatedMatrix_Animated(false), GlobalSkinningSpace(false),
positionHint(-1),scaleHint(-1),rotationHint(-1)
{
}
//! The name of this joint
core::stringc Name;
//! Local matrix of this joint
core::matrix4 LocalMatrix;
//! List of child joints
core::array<SJoint*> Children;
//! List of attached meshes
core::array<u32> AttachedMeshes;
//! Animation keys causing translation change
core::array<SPositionKey> PositionKeys;
//! Animation keys causing scale change
core::array<SScaleKey> ScaleKeys;
//! Animation keys causing rotation change
core::array<SRotationKey> RotationKeys;
//! Skin weights
core::array<SWeight> Weights;
//! Unnecessary for loaders, will be overwritten on finalize
core::matrix4 GlobalMatrix;
core::matrix4 GlobalAnimatedMatrix;
core::matrix4 LocalAnimatedMatrix;
core::vector3df Animatedposition;
core::vector3df Animatedscale;
core::quaternion Animatedrotation;
core::matrix4 GlobalInversedMatrix; //the x format pre-calculates this
private:
//! Internal members used by CSkinnedMesh
friend class CSkinnedMesh;
SJoint *UseAnimationFrom;
bool LocalAnimatedMatrix_Animated;
bool GlobalSkinningSpace;
s32 positionHint;
s32 scaleHint;
s32 rotationHint;
};
//Interface for the mesh loaders (finalize should lock these functions, and they should have some prefix like loader_
//these functions will use the needed arrays, set values, etc to help the loaders
//! exposed for loaders: to add mesh buffers
virtual core::array<SSkinMeshBuffer*> &getMeshBuffers() = 0;
//! exposed for loaders: joints list
virtual core::array<SJoint*> &getAllJoints() = 0;
//! exposed for loaders: joints list
virtual const core::array<SJoint*> &getAllJoints() const = 0;
//! loaders should call this after populating the mesh
virtual void finalize() = 0;
virtual SSkinMeshBuffer *createBuffer() = 0;
virtual SJoint *createJoint(SJoint *parent=0) = 0;
virtual SPositionKey *createPositionKey(SJoint *joint) = 0;
virtual SScaleKey *createScaleKey(SJoint *joint) = 0;
virtual SRotationKey *createRotationKey(SJoint *joint) = 0;
virtual SWeight *createWeight(SJoint *joint) = 0;
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,141 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
// The code for the TerrainSceneNode is based on the terrain renderer by Soconne and
// the GeoMipMapSceneNode developed by Spintz. They made their code available for Irrlicht
// and allowed it to be distributed under this licence. I only modified some parts.
// A lot of thanks go to them.
#ifndef __I_TERRAIN_SCENE_NODE_H__
#define __I_TERRAIN_SCENE_NODE_H__
#include "ETerrainElements.h"
#include "ISceneNode.h"
#include "SMeshBufferLightMap.h"
#include "irrArray.h"
namespace irr
{
namespace scene
{
class IMesh;
//! A scene node for displaying terrain using the geo mip map algorithm.
/** The code for the TerrainSceneNode is based on the Terrain renderer by Soconne and
* the GeoMipMapSceneNode developed by Spintz. They made their code available for Irrlicht
* and allowed it to be distributed under this licence. I only modified some parts.
* A lot of thanks go to them.
*
* This scene node is capable of very quickly loading
* terrains and updating the indices at runtime to enable viewing very large terrains. It uses a
* CLOD ( Continuous Level of Detail ) algorithm which updates the indices for each patch based on
* a LOD ( Level of Detail ) which is determined based on a patch's distance from the camera.
*
* The Patch Size of the terrain must always be a size of ( 2^N+1, i.e. 8+1(9), 16+1(17), etc. ).
* The MaxLOD available is directly dependent on the patch size of the terrain. LOD 0 contains all
* of the indices to draw all the triangles at the max detail for a patch. As each LOD goes up by 1
* the step taken, in generating indices increases by - 2^LOD, so for LOD 1, the step taken is 2, for
* LOD 2, the step taken is 4, LOD 3 - 8, etc. The step can be no larger than the size of the patch,
* so having a LOD of 8, with a patch size of 17, is asking the algoritm to generate indices every
* 2^8 ( 256 ) vertices, which is not possible with a patch size of 17. The maximum LOD for a patch
* size of 17 is 2^4 ( 16 ). So, with a MaxLOD of 5, you'll have LOD 0 ( full detail ), LOD 1 ( every
* 2 vertices ), LOD 2 ( every 4 vertices ), LOD 3 ( every 8 vertices ) and LOD 4 ( every 16 vertices ).
**/
class ITerrainSceneNode : public ISceneNode
{
public:
//! constructor
ITerrainSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id,
const core::vector3df& position = core::vector3df(0.0f, 0.0f, 0.0f),
const core::vector3df& rotation = core::vector3df(0.0f, 0.0f, 0.0f),
const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f) )
: ISceneNode (parent, mgr, id, position, rotation, scale) {}
//! destructor
virtual ~ITerrainSceneNode() {}
//! \return: Returns the bounding box of the entire terrain.
virtual const core::aabbox3d<f32>& getBoundingBox ( ) const = 0;
//! Returns the bounding box of a patch
virtual const core::aabbox3d<f32>& getBoundingBox (s32 patchX, s32 patchZ) const = 0;
//! Returns the number of indices currently in the meshbuffer for this scene node.
virtual u32 getIndexCount() const = 0;
//! Returns pointer to the mesh
virtual IMesh* getMesh() = 0;
//! Gets the meshbuffer data based on a specified level of detail.
/** \param mb: A reference to an SMeshBuffer object
\param LOD: the level of detail you want the indices from. */
virtual void getMeshBufferForLOD(SMeshBufferLightMap& mb, s32 LOD) const = 0;
//! Gets the indices for a specified patch at a specified Level of Detail.
/** \param indices: A reference to an array of u32 indices.
\param patchX: Patch x coordinate.
\param patchZ: Patch z coordinate.
\param LOD: The level of detail to get for that patch. If -1, then get
the CurrentLOD. If the CurrentLOD is set to -1, meaning it's not shown,
then it will retrieve the triangles at the highest LOD ( 0 ).
\return: Number if indices put into the buffer. */
virtual s32 getIndicesForPatch(core::array<u32>& indices,
s32 patchX, s32 patchZ, s32 LOD = 0 ) = 0;
//! Populates an array with the CurrentLOD of each patch.
/** \param LODs: A reference to a core::array<s32> to hold the values
\return: Returns the number of elements in the array */
virtual s32 getCurrentLODOfPatches(core::array<s32>& LODs) const = 0;
//! Manually sets the LOD of a patch
/** \param patchX: Patch x coordinate.
\param patchZ: Patch z coordinate.
\param LOD: The level of detail to set the patch to. */
virtual void setLODOfPatch( s32 patchX, s32 patchZ, s32 LOD ) = 0;
//! Returns center of terrain.
virtual const core::vector3df& getTerrainCenter() const = 0;
//! Returns height of a point of the terrain.
virtual f32 getHeight( f32 x, f32 y ) const = 0;
//! Sets the movement camera threshold.
/** It is used to determine when to recalculate
indices for the scene node. The default value is 10.0f. */
virtual void setCameraMovementDelta(f32 delta) = 0;
//! Sets the rotation camera threshold.
/** It is used to determine when to recalculate
indices for the scene node. The default value is 1.0f. */
virtual void setCameraRotationDelta(f32 delta) = 0;
//! Sets whether or not the node should dynamically update its associated selector when the geomipmap data changes.
/** \param bVal: Boolean value representing whether or not to update selector dynamically. */
virtual void setDynamicSelectorUpdate(bool bVal) = 0;
//! Override the default generation of distance thresholds.
/** For determining the LOD a patch
is rendered at. If any LOD is overridden, then the scene node will no longer apply
scaling factors to these values. If you override these distances, and then apply
a scale to the scene node, it is your responsibility to update the new distances to
work best with your new terrain size. */
virtual bool overrideLODDistance(s32 LOD, f64 newDistance) = 0;
//! Scales the base texture, similar to makePlanarTextureMapping.
/** \param scale: The scaling amount. Values above 1.0 increase the number of time the
texture is drawn on the terrain. Values below 0 will decrease the number of times the
texture is drawn on the terrain. Using negative values will flip the texture, as
well as still scaling it.
\param scale2: If set to 0 (default value), this will set the second texture coordinate set
to the same values as in the first set. If this is another value than zero, it will scale
the second texture coordinate set by this value. */
virtual void scaleTexture(f32 scale = 1.0f, f32 scale2 = 0.0f) = 0;
};
} // end namespace scene
} // end namespace irr
#endif // __IGEOMIPMAPSCENENODE_H__

View File

@ -0,0 +1,37 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_TEXT_SCENE_NODE_H_INCLUDED__
#define __I_TEXT_SCENE_NODE_H_INCLUDED__
#include "ISceneNode.h"
namespace irr
{
namespace scene
{
//! A scene node for displaying 2d text at a position in three dimensional space
class ITextSceneNode : public ISceneNode
{
public:
//! constructor
ITextSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id,
const core::vector3df& position = core::vector3df(0,0,0))
: ISceneNode(parent, mgr, id, position) {}
//! sets the text string
virtual void setText(const wchar_t* text) = 0;
//! sets the color of the text
virtual void setTextColor(video::SColor color) = 0;
};
} // end namespace scene
} // end namespace irr
#endif

Some files were not shown because too many files have changed in this diff Show More