Added source-code.

This commit is contained in:
Deathsbreed 2014-10-19 10:36:32 -05:00
parent 6f5934732f
commit b4d523cc94
189 changed files with 39680 additions and 1 deletions

12
.gitignore vendored Normal file
View File

@ -0,0 +1,12 @@
# Ignore binary files
bin/*
# Ignore CMake files
CMakeCache.txt
CMakeFiles/
cmake_install.cmake
Makefile
# Ignore library and include files
libs/*
include/*

16
CMakeLists.txt Normal file
View File

@ -0,0 +1,16 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(Castle)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/include/irrlicht")
FILE(GLOB SRCS src/*.cpp)
ADD_EXECUTABLE(castle ${SRCS})
IF((${CMAKE_SYSTEM_NAME} MATCHES "Windows") AND (EXISTS "${CMAKE_SOURCE_DIR}/libs/libIrrlicht.dll"))
TARGET_LINK_LIBRARIES(castle "${CMAKE_SOURCE_DIR}/libs/libIrrlicht.dll")
ELSEIF(EXISTS "${CMAKE_SOURCE_DIR}/libs/libIrrlicht.so")
TARGET_LINK_LIBRARIES(castle "${CMAKE_SOURCE_DIR}/libs/libIrrlicht.so")
ENDIF()

View File

@ -1,4 +1,18 @@
CastleTour
==========
A combination of a few Irrlicht tutorials.
This repo is a combination of a few Irrlicht tutorials.
### Compiling
So far I'm using CMake (and only on Debian GNU/Linux). First, compile Irrlicht, move the include and library files to the [include directory](/include) and the [library directory](/libs) (make sure they are named ```libIrrlicht.so``` if you're running Linux and ```libIrrlicht.dll``` if you're running Windows). Then run the following commands from the root directory of the project:
```
$ cmake .
$ make
```
The binary should be in the [binary directory](/bin).
### Contributing
Feel free to add. This is something I'm using to learn Irrlicht, and it would help if I had a better [CMakeLists](/CMakeLists.txt) file that could compile on multiple platforms.
### License
Since this really isn't my code but Irrlicht code I placed it under the [Unlicense](/LICENSE), because kind of like a tutorial.

View File

@ -0,0 +1,116 @@
// Copyright (C) 2008-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __C_DYNAMIC_MESHBUFFER_H_INCLUDED__
#define __C_DYNAMIC_MESHBUFFER_H_INCLUDED__
#include "IDynamicMeshBuffer.h"
#include "CVertexBuffer.h"
#include "CIndexBuffer.h"
namespace irr
{
namespace scene
{
class CDynamicMeshBuffer: public IDynamicMeshBuffer
{
public:
//! constructor
CDynamicMeshBuffer(video::E_VERTEX_TYPE vertexType, video::E_INDEX_TYPE indexType)
{
VertexBuffer=new CVertexBuffer(vertexType);
IndexBuffer=new CIndexBuffer(indexType);
}
//! destructor
virtual ~CDynamicMeshBuffer()
{
if (VertexBuffer)
VertexBuffer->drop();
if (IndexBuffer)
IndexBuffer->drop();
}
virtual IVertexBuffer& getVertexBuffer() const
{
return *VertexBuffer;
}
virtual IIndexBuffer& getIndexBuffer() const
{
return *IndexBuffer;
}
virtual void setVertexBuffer(IVertexBuffer *newVertexBuffer)
{
if (newVertexBuffer)
newVertexBuffer->grab();
if (VertexBuffer)
VertexBuffer->drop();
VertexBuffer=newVertexBuffer;
}
virtual void setIndexBuffer(IIndexBuffer *newIndexBuffer)
{
if (newIndexBuffer)
newIndexBuffer->grab();
if (IndexBuffer)
IndexBuffer->drop();
IndexBuffer=newIndexBuffer;
}
//! Get Material of this buffer.
virtual const video::SMaterial& getMaterial() const
{
return Material;
}
//! Get Material of this buffer.
virtual video::SMaterial& getMaterial()
{
return Material;
}
//! Get bounding box
virtual const core::aabbox3d<f32>& getBoundingBox() const
{
return BoundingBox;
}
//! Set bounding box
virtual void setBoundingBox( const core::aabbox3df& box)
{
BoundingBox = box;
}
//! Recalculate bounding box
virtual void recalculateBoundingBox()
{
if (!getVertexBuffer().size())
BoundingBox.reset(0,0,0);
else
{
BoundingBox.reset(getVertexBuffer()[0].Pos);
for (u32 i=1; i<getVertexBuffer().size(); ++i)
BoundingBox.addInternalPoint(getVertexBuffer()[i].Pos);
}
}
video::SMaterial Material;
core::aabbox3d<f32> BoundingBox;
private:
IVertexBuffer *VertexBuffer;
IIndexBuffer *IndexBuffer;
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,226 @@
// Copyright (C) 2008-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __C_INDEX_BUFFER_H_INCLUDED__
#define __C_INDEX_BUFFER_H_INCLUDED__
#include "IIndexBuffer.h"
namespace irr
{
namespace scene
{
class CIndexBuffer : public IIndexBuffer
{
class IIndexList
{
public:
virtual ~IIndexList(){};
virtual u32 stride() const =0;
virtual u32 size() const =0;
virtual void push_back(const u32 &element) =0;
virtual u32 operator [](u32 index) const =0;
virtual u32 getLast() =0;
virtual void setValue(u32 index, u32 value) =0;
virtual void set_used(u32 usedNow) =0;
virtual void reallocate(u32 new_size) =0;
virtual u32 allocated_size() const =0;
virtual void* pointer() =0;
virtual video::E_INDEX_TYPE getType() const =0;
};
template <class T>
class CSpecificIndexList : public IIndexList
{
public:
core::array<T> Indices;
virtual u32 stride() const {return sizeof(T);}
virtual u32 size() const {return Indices.size();}
virtual void push_back(const u32 &element)
{
// push const ref due to compiler problem with gcc 4.6, big endian
Indices.push_back((const T&)element);
}
virtual u32 operator [](u32 index) const
{
return (u32)(Indices[index]);
}
virtual u32 getLast() {return (u32)Indices.getLast();}
virtual void setValue(u32 index, u32 value)
{
Indices[index]=(T)value;
}
virtual void set_used(u32 usedNow)
{
Indices.set_used(usedNow);
}
virtual void reallocate(u32 new_size)
{
Indices.reallocate(new_size);
}
virtual u32 allocated_size() const
{
return Indices.allocated_size();
}
virtual void* pointer() {return Indices.pointer();}
virtual video::E_INDEX_TYPE getType() const
{
if (sizeof(T)==sizeof(u16))
return video::EIT_16BIT;
else
return video::EIT_32BIT;
}
};
public:
IIndexList *Indices;
CIndexBuffer(video::E_INDEX_TYPE IndexType) :Indices(0), MappingHint(EHM_NEVER), ChangedID(1)
{
setType(IndexType);
}
CIndexBuffer(const IIndexBuffer &IndexBufferCopy) :Indices(0), MappingHint(EHM_NEVER), ChangedID(1)
{
setType(IndexBufferCopy.getType());
reallocate(IndexBufferCopy.size());
for (u32 n=0;n<IndexBufferCopy.size();++n)
push_back(IndexBufferCopy[n]);
}
virtual ~CIndexBuffer()
{
delete Indices;
}
//virtual void setType(video::E_INDEX_TYPE IndexType);
virtual void setType(video::E_INDEX_TYPE IndexType)
{
IIndexList *NewIndices=0;
switch (IndexType)
{
case video::EIT_16BIT:
{
NewIndices=new CSpecificIndexList<u16>;
break;
}
case video::EIT_32BIT:
{
NewIndices=new CSpecificIndexList<u32>;
break;
}
}
if (Indices)
{
NewIndices->reallocate( Indices->size() );
for(u32 n=0;n<Indices->size();++n)
NewIndices->push_back((*Indices)[n]);
delete Indices;
}
Indices=NewIndices;
}
virtual void* getData() {return Indices->pointer();}
virtual video::E_INDEX_TYPE getType() const {return Indices->getType();}
virtual u32 stride() const {return Indices->stride();}
virtual u32 size() const
{
return Indices->size();
}
virtual void push_back(const u32 &element)
{
Indices->push_back(element);
}
virtual u32 operator [](u32 index) const
{
return (*Indices)[index];
}
virtual u32 getLast()
{
return Indices->getLast();
}
virtual void setValue(u32 index, u32 value)
{
Indices->setValue(index, value);
}
virtual void set_used(u32 usedNow)
{
Indices->set_used(usedNow);
}
virtual void reallocate(u32 new_size)
{
Indices->reallocate(new_size);
}
virtual u32 allocated_size() const
{
return Indices->allocated_size();
}
virtual void* pointer()
{
return Indices->pointer();
}
//! get the current hardware mapping hint
virtual E_HARDWARE_MAPPING getHardwareMappingHint() const
{
return MappingHint;
}
//! set the hardware mapping hint, for driver
virtual void setHardwareMappingHint( E_HARDWARE_MAPPING NewMappingHint )
{
MappingHint=NewMappingHint;
}
//! flags the mesh as changed, reloads hardware buffers
virtual void setDirty()
{
++ChangedID;
}
//! Get the currently used ID for identification of changes.
/** This shouldn't be used for anything outside the VideoDriver. */
virtual u32 getChangedID() const {return ChangedID;}
E_HARDWARE_MAPPING MappingHint;
u32 ChangedID;
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,301 @@
// Copyright (C) 2002-2012 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:
//! Default constructor for empty meshbuffer
CMeshBuffer():ChangedID_Vertex(1),ChangedID_Index(1),MappingHint_Vertex(EHM_NEVER), MappingHint_Index(EHM_NEVER)
{
#ifdef _DEBUG
setDebugName("SMeshBuffer");
#endif
}
//! Get material of this meshbuffer
/** \return Material of this buffer */
virtual const video::SMaterial& getMaterial() const
{
return Material;
}
//! Get material of this meshbuffer
/** \return Material of this buffer */
virtual video::SMaterial& getMaterial()
{
return Material;
}
//! Get pointer to vertices
/** \return Pointer to vertices. */
virtual const void* getVertices() const
{
return Vertices.const_pointer();
}
//! Get pointer to vertices
/** \return Pointer to vertices. */
virtual void* getVertices()
{
return Vertices.pointer();
}
//! Get number of vertices
/** \return Number of vertices. */
virtual u32 getVertexCount() const
{
return Vertices.size();
}
//! Get type of index data which is stored in this meshbuffer.
/** \return Index type of this buffer. */
virtual video::E_INDEX_TYPE getIndexType() const
{
return video::EIT_16BIT;
}
//! Get pointer to indices
/** \return Pointer to indices. */
virtual const u16* getIndices() const
{
return Indices.const_pointer();
}
//! Get pointer to indices
/** \return Pointer to indices. */
virtual u16* getIndices()
{
return Indices.pointer();
}
//! Get number of indices
/** \return Number of indices. */
virtual u32 getIndexCount() const
{
return Indices.size();
}
//! Get the axis aligned bounding box
/** \return Axis aligned bounding box of this buffer. */
virtual const core::aabbox3d<f32>& getBoundingBox() const
{
return BoundingBox;
}
//! Set the axis aligned bounding box
/** \param box New axis aligned bounding box for this buffer. */
//! set user axis aligned bounding box
virtual void setBoundingBox(const core::aabbox3df& box)
{
BoundingBox = box;
}
//! Recalculate 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);
}
}
//! Get type of vertex data stored in this buffer.
/** \return Type of vertex data. */
virtual video::E_VERTEX_TYPE getVertexType() const
{
return T().getType();
}
//! returns position of vertex i
virtual const core::vector3df& getPosition(u32 i) const
{
return Vertices[i].Pos;
}
//! returns position of vertex i
virtual core::vector3df& getPosition(u32 i)
{
return Vertices[i].Pos;
}
//! returns normal of vertex i
virtual const core::vector3df& getNormal(u32 i) const
{
return Vertices[i].Normal;
}
//! returns normal of vertex i
virtual core::vector3df& getNormal(u32 i)
{
return Vertices[i].Normal;
}
//! returns texture coord of vertex i
virtual const core::vector2df& getTCoords(u32 i) const
{
return Vertices[i].TCoords;
}
//! returns texture coord of vertex i
virtual core::vector2df& getTCoords(u32 i)
{
return Vertices[i].TCoords;
}
//! Append the vertices and indices to the current buffer
/** Only works for compatible types, i.e. either the same type
or the main buffer is of standard type. Otherwise, behavior is
undefined.
*/
virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices)
{
if (vertices == getVertices())
return;
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
/** Only works for compatible types, i.e. either the same type
or the main buffer is of standard type. Otherwise, behavior is
undefined.
\param other Meshbuffer to be appended to this one.
*/
virtual void append(const IMeshBuffer* const other)
{
/*
if (this==other)
return;
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());
*/
}
//! get the current hardware mapping hint
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Vertex() const
{
return MappingHint_Vertex;
}
//! get the current hardware mapping hint
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Index() const
{
return MappingHint_Index;
}
//! set the hardware mapping hint, for driver
virtual void setHardwareMappingHint( E_HARDWARE_MAPPING NewMappingHint, E_BUFFER_TYPE Buffer=EBT_VERTEX_AND_INDEX )
{
if (Buffer==EBT_VERTEX_AND_INDEX || Buffer==EBT_VERTEX)
MappingHint_Vertex=NewMappingHint;
if (Buffer==EBT_VERTEX_AND_INDEX || Buffer==EBT_INDEX)
MappingHint_Index=NewMappingHint;
}
//! flags the mesh as changed, reloads hardware buffers
virtual void setDirty(E_BUFFER_TYPE Buffer=EBT_VERTEX_AND_INDEX)
{
if (Buffer==EBT_VERTEX_AND_INDEX ||Buffer==EBT_VERTEX)
++ChangedID_Vertex;
if (Buffer==EBT_VERTEX_AND_INDEX || Buffer==EBT_INDEX)
++ChangedID_Index;
}
//! Get the currently used ID for identification of changes.
/** This shouldn't be used for anything outside the VideoDriver. */
virtual u32 getChangedID_Vertex() const {return ChangedID_Vertex;}
//! Get the currently used ID for identification of changes.
/** This shouldn't be used for anything outside the VideoDriver. */
virtual u32 getChangedID_Index() const {return ChangedID_Index;}
u32 ChangedID_Vertex;
u32 ChangedID_Index;
//! hardware mapping hint
E_HARDWARE_MAPPING MappingHint_Vertex;
E_HARDWARE_MAPPING MappingHint_Index;
//! 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;
};
//! Standard meshbuffer
typedef CMeshBuffer<video::S3DVertex> SMeshBuffer;
//! Meshbuffer with two texture coords per vertex, e.g. for lightmaps
typedef CMeshBuffer<video::S3DVertex2TCoords> SMeshBufferLightMap;
//! Meshbuffer with vertices having tangents stored, e.g. for normal mapping
typedef CMeshBuffer<video::S3DVertexTangents> SMeshBufferTangents;
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,210 @@
// Copyright (C) 2008-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __C_VERTEX_BUFFER_H_INCLUDED__
#define __C_VERTEX_BUFFER_H_INCLUDED__
#include "IVertexBuffer.h"
namespace irr
{
namespace scene
{
class CVertexBuffer : public IVertexBuffer
{
class IVertexList
{
public:
virtual ~IVertexList(){};
virtual u32 stride() const =0;
virtual u32 size() const =0;
virtual void push_back (const video::S3DVertex &element) =0;
virtual video::S3DVertex& operator [](const u32 index) const =0;
virtual video::S3DVertex& getLast() =0;
virtual void set_used(u32 usedNow) =0;
virtual void reallocate(u32 new_size) =0;
virtual u32 allocated_size() const =0;
virtual video::S3DVertex* pointer() =0;
virtual video::E_VERTEX_TYPE getType() const =0;
};
template <class T>
class CSpecificVertexList : public IVertexList
{
public:
core::array<T> Vertices;
virtual u32 stride() const {return sizeof(T);}
virtual u32 size() const {return Vertices.size();}
virtual void push_back (const video::S3DVertex &element)
{Vertices.push_back((T&)element);}
virtual video::S3DVertex& operator [](const u32 index) const
{return (video::S3DVertex&)Vertices[index];}
virtual video::S3DVertex& getLast()
{return (video::S3DVertex&)Vertices.getLast();}
virtual void set_used(u32 usedNow)
{Vertices.set_used(usedNow);}
virtual void reallocate(u32 new_size)
{Vertices.reallocate(new_size);}
virtual u32 allocated_size() const
{
return Vertices.allocated_size();
}
virtual video::S3DVertex* pointer() {return Vertices.pointer();}
virtual video::E_VERTEX_TYPE getType() const {return T().getType();}
};
public:
IVertexList *Vertices;
CVertexBuffer(video::E_VERTEX_TYPE vertexType) : Vertices(0),
MappingHint(EHM_NEVER), ChangedID(1)
{
setType(vertexType);
}
CVertexBuffer(const IVertexBuffer &VertexBufferCopy) :
Vertices(0), MappingHint(EHM_NEVER),
ChangedID(1)
{
setType(VertexBufferCopy.getType());
reallocate(VertexBufferCopy.size());
for (u32 n=0;n<VertexBufferCopy.size();++n)
push_back(VertexBufferCopy[n]);
}
virtual ~CVertexBuffer()
{
delete Vertices;
}
virtual void setType(video::E_VERTEX_TYPE vertexType)
{
IVertexList *NewVertices=0;
switch (vertexType)
{
case video::EVT_STANDARD:
{
NewVertices=new CSpecificVertexList<video::S3DVertex>;
break;
}
case video::EVT_2TCOORDS:
{
NewVertices=new CSpecificVertexList<video::S3DVertex2TCoords>;
break;
}
case video::EVT_TANGENTS:
{
NewVertices=new CSpecificVertexList<video::S3DVertexTangents>;
break;
}
}
if (Vertices)
{
NewVertices->reallocate( Vertices->size() );
for(u32 n=0;n<Vertices->size();++n)
NewVertices->push_back((*Vertices)[n]);
delete Vertices;
}
Vertices=NewVertices;
}
virtual void* getData() {return Vertices->pointer();}
virtual video::E_VERTEX_TYPE getType() const {return Vertices->getType();}
virtual u32 stride() const {return Vertices->stride();}
virtual u32 size() const
{
return Vertices->size();
}
virtual void push_back (const video::S3DVertex &element)
{
Vertices->push_back(element);
}
virtual video::S3DVertex& operator [](const u32 index) const
{
return (*Vertices)[index];
}
virtual video::S3DVertex& getLast()
{
return Vertices->getLast();
}
virtual void set_used(u32 usedNow)
{
Vertices->set_used(usedNow);
}
virtual void reallocate(u32 new_size)
{
Vertices->reallocate(new_size);
}
virtual u32 allocated_size() const
{
return Vertices->allocated_size();
}
virtual video::S3DVertex* pointer()
{
return Vertices->pointer();
}
//! get the current hardware mapping hint
virtual E_HARDWARE_MAPPING getHardwareMappingHint() const
{
return MappingHint;
}
//! set the hardware mapping hint, for driver
virtual void setHardwareMappingHint( E_HARDWARE_MAPPING NewMappingHint )
{
MappingHint=NewMappingHint;
}
//! flags the mesh as changed, reloads hardware buffers
virtual void setDirty()
{
++ChangedID;
}
//! Get the currently used ID for identification of changes.
/** This shouldn't be used for anything outside the VideoDriver. */
virtual u32 getChangedID() const {return ChangedID;}
E_HARDWARE_MAPPING MappingHint;
u32 ChangedID;
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,101 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __E_ATTRIBUTES_H_INCLUDED__
#define __E_ATTRIBUTES_H_INCLUDED__
namespace irr
{
namespace io
{
//! 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 attribute
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,
// dimension attribute
EAT_DIMENSION2D,
// known attribute type count
EAT_COUNT,
// unknown attribute
EAT_UNKNOWN
};
} // end namespace io
} // end namespace irr
#endif

View File

@ -0,0 +1,41 @@
// Copyright (C) 2002-2012 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,
EAC_OCC_QUERY = 8
};
//! 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
"occ_query", // occlusion query
0
};
} // end namespace scene
} // end namespace irr
#endif // __E_CULLING_TYPES_H_INCLUDED__

View File

@ -0,0 +1,50 @@
// Copyright (C) 2002-2012 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,
//! EDS_BBOX | EDS_BBOX_BUFFERS
EDS_BBOX_ALL = EDS_BBOX | EDS_BBOX_BUFFERS,
//! 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,60 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __E_DEVICE_TYPES_H_INCLUDED__
#define __E_DEVICE_TYPES_H_INCLUDED__
namespace irr
{
//! An enum for the different device types supported by the Irrlicht Engine.
enum E_DEVICE_TYPE
{
//! A device native to Microsoft Windows
/** This device uses the Win32 API and works in all versions of Windows. */
EIDT_WIN32,
//! A device native to Windows CE devices
/** This device works on Windows Mobile, Pocket PC and Microsoft SmartPhone devices */
EIDT_WINCE,
//! A device native to Unix style operating systems.
/** This device uses the X11 windowing system and works in Linux, Solaris, FreeBSD, OSX and
other operating systems which support X11. */
EIDT_X11,
//! A device native to Mac OSX
/** This device uses Apple's Cocoa API and works in Mac OSX 10.2 and above. */
EIDT_OSX,
//! A device which uses Simple DirectMedia Layer
/** The SDL device works under all platforms supported by SDL but first must be compiled
in by defining the IRR_USE_SDL_DEVICE macro in IrrCompileConfig.h */
EIDT_SDL,
//! A device for raw framebuffer access
/** Best used with embedded devices and mobile systems.
Does not need X11 or other graphical subsystems.
May support hw-acceleration via OpenGL-ES for FBDirect */
EIDT_FRAMEBUFFER,
//! A simple text only device supported by all platforms.
/** This device allows applications to run from the command line without opening a window.
It can render the output of the software drivers to the console as ASCII. It only supports
mouse and keyboard in Windows operating systems. */
EIDT_CONSOLE,
//! This selection allows Irrlicht to choose the best device from the ones available.
/** If this selection is chosen then Irrlicht will try to use the IrrlichtDevice native
to your operating system. If this is unavailable then the X11, SDL and then console device
will be tried. This ensures that Irrlicht will run even if your platform is unsupported,
although it may not be able to render anything. */
EIDT_BEST
};
} // end namespace irr
#endif // __E_DEVICE_TYPES_H_INCLUDED__

View File

@ -0,0 +1,133 @@
// Copyright (C) 2002-2012 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-square textures supported?
EVDF_TEXTURE_NSQUARE,
//! Are non-power-of-two textures supported?
EVDF_TEXTURE_NPOT,
//! Are framebuffer objects supported?
EVDF_FRAMEBUFFER_OBJECT,
//! Are vertex buffer objects supported?
EVDF_VERTEX_BUFFER_OBJECT,
//! Supports Alpha To Coverage
EVDF_ALPHA_TO_COVERAGE,
//! Supports Color masks (disabling color planes in output)
EVDF_COLOR_MASK,
//! Supports multiple render targets at once
EVDF_MULTIPLE_RENDER_TARGETS,
//! Supports separate blend settings for multiple render targets
EVDF_MRT_BLEND,
//! Supports separate color masks for multiple render targets
EVDF_MRT_COLOR_MASK,
//! Supports separate blend functions for multiple render targets
EVDF_MRT_BLEND_FUNC,
//! Supports geometry shaders
EVDF_GEOMETRY_SHADER,
//! Supports occlusion queries
EVDF_OCCLUSION_QUERY,
//! Supports polygon offset/depth bias for avoiding z-fighting
EVDF_POLYGON_OFFSET,
//! Support for different blend functions. Without, only ADD is available
EVDF_BLEND_OPERATIONS,
//! Support for texture coord transformation via texture matrix
EVDF_TEXTURE_MATRIX,
//! Support for NVidia's CG shader language
EVDF_CG,
//! Only used for counting the elements of this enum
EVDF_COUNT
};
} // end namespace video
} // end namespace irr
#endif

View File

@ -0,0 +1,64 @@
// Copyright (C) 2002-2012 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 driver, 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
/** 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,
//! Direct3D8 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,
//! No driver, just for counting the elements
EDT_COUNT
};
} // end namespace video
} // end namespace irr
#endif

View File

@ -0,0 +1,38 @@
// Copyright (C) 2002-2012 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_ALIGNMENT_H_INCLUDED__
#define __E_GUI_ALIGNMENT_H_INCLUDED__
namespace irr
{
namespace gui
{
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,
//! Stretched to fit parent
EGUIA_SCALE
};
//! Names for alignments
const c8* const GUIAlignmentNames[] =
{
"upperLeft",
"lowerRight",
"center",
"scale",
0
};
} // namespace gui
} // namespace irr
#endif // __E_GUI_ALIGNMENT_H_INCLUDED__

View File

@ -0,0 +1,140 @@
// Copyright (C) 2002-2012 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__
#include "irrTypes.h"
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 spin box (IGUISpinBox)
EGUIET_SPIN_BOX,
//! A static text (IGUIStaticText)
EGUIET_STATIC_TEXT,
//! A tab (IGUITab)
EGUIET_TAB,
//! A tab control
EGUIET_TAB_CONTROL,
//! A Table
EGUIET_TABLE,
//! A tool bar (IGUIToolBar)
EGUIET_TOOL_BAR,
//! A Tree View
EGUIET_TREE_VIEW,
//! A window
EGUIET_WINDOW,
//! Unknown type.
EGUIET_ELEMENT,
//! The root of the GUI
EGUIET_ROOT,
//! Not an element, amount of elements in there
EGUIET_COUNT,
//! This enum is never used, it only forces the compiler to compile this enumeration 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",
"spinBox",
"staticText",
"tab",
"tabControl",
"table",
"toolBar",
"treeview",
"window",
"element",
"root",
0
};
} // end namespace gui
} // end namespace irr
#endif

View File

@ -0,0 +1,44 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __E_HARDWARE_BUFFER_FLAGS_INCLUDED__
#define __E_HARDWARE_BUFFER_FLAGS_INCLUDED__
namespace irr
{
namespace scene
{
enum E_HARDWARE_MAPPING
{
//! Don't store on the hardware
EHM_NEVER=0,
//! Rarely changed, usually stored completely on the hardware
EHM_STATIC,
//! Sometimes changed, driver optimized placement
EHM_DYNAMIC,
//! Always changed, cache optimizing on the GPU
EHM_STREAM
};
enum E_BUFFER_TYPE
{
//! Does not change anything
EBT_NONE=0,
//! Change the vertex mapping
EBT_VERTEX,
//! Change the index mapping
EBT_INDEX,
//! Change both vertex and index mapping to the same value
EBT_VERTEX_AND_INDEX
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,95 @@
// Copyright (C) 2002-2012 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 = 0x1,
//! Draw as point cloud or filled triangles? Default: false
EMF_POINTCLOUD = 0x2,
//! Flat or Gouraud shading? Default: true
EMF_GOURAUD_SHADING = 0x4,
//! Will this material be lighted? Default: true
EMF_LIGHTING = 0x8,
//! Is the ZBuffer enabled? Default: true
EMF_ZBUFFER = 0x10,
//! 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 = 0x20,
//! Is backface culling enabled? Default: true
EMF_BACK_FACE_CULLING = 0x40,
//! Is frontface culling enabled? Default: false
/** Overrides EMF_BACK_FACE_CULLING if both are enabled. */
EMF_FRONT_FACE_CULLING = 0x80,
//! Is bilinear filtering enabled? Default: true
EMF_BILINEAR_FILTER = 0x100,
//! Is trilinear filtering enabled? Default: false
/** If the trilinear filter flag is enabled,
the bilinear filtering flag is ignored. */
EMF_TRILINEAR_FILTER = 0x200,
//! 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 = 0x400,
//! Is fog enabled? Default: false
EMF_FOG_ENABLE = 0x800,
//! Normalizes normals. Default: false
/** 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 = 0x1000,
//! Access to all layers texture wrap settings. Overwrites separate layer settings.
EMF_TEXTURE_WRAP = 0x2000,
//! AntiAliasing mode
EMF_ANTI_ALIASING = 0x4000,
//! ColorMask bits, for enabling the color planes
EMF_COLOR_MASK = 0x8000,
//! ColorMaterial enum for vertex color interpretation
EMF_COLOR_MATERIAL = 0x10000,
//! Flag for enabling/disabling mipmap usage
EMF_USE_MIP_MAPS = 0x20000,
//! Flag for blend operation
EMF_BLEND_OPERATION = 0x40000,
//! Flag for polygon offset
EMF_POLYGON_OFFSET = 0x80000
};
} // end namespace video
} // end namespace irr
#endif // __E_MATERIAL_FLAGS_H_INCLUDED__

View File

@ -0,0 +1,234 @@
// Copyright (C) 2002-2012 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.
*/
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. Dynamic light is
ignored. */
EMT_LIGHTMAP,
//! Material type with lightmap technique like EMT_LIGHTMAP.
/** But lightmap and diffuse texture are added instead of modulated. */
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. Dynamic light is
ignored. The texture colors are effectively multiplied 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. Dynamic 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,
//! Look like a reflection of the environment around it.
/** To make this possible, a texture called 'sphere map' is
used, which must be set as the first texture. */
EMT_SPHERE_MAP,
//! A reflecting material with an optional non reflecting texture layer.
/** The reflection map should be set as first texture. */
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
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. 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 first texture. The
transparency depends on the alpha value in the vertex colors. A
texture which will not reflect can be set as second texture.
Please note that this material type is currently not 100%
implemented in OpenGL. */
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 to 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. */
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 to 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. */
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 to 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. */
EMT_NORMAL_MAP_TRANSPARENT_VERTEX_ALPHA,
//! Just like EMT_NORMAL_MAP_SOLID, but uses parallax mapping.
/** 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
automatically 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 like EMT_PARALLAX_MAP_SOLID, but transparent.
/** Using EMT_TRANSPARENT_ADD_COLOR as base material. */
EMT_PARALLAX_MAP_TRANSPARENT_ADD_COLOR,
//! A material like EMT_PARALLAX_MAP_SOLID, but 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 first texture. Generic blending method. */
EMT_ONETEXTURE_BLEND,
//! This value is not used. It only forces this enumeration to compile to 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,59 @@
// Copyright (C) 2002-2012 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__
#include "irrTypes.h"
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),
//! OBJ mesh writer for .obj files
EMWT_OBJ = MAKE_IRR_ID('o','b','j',0),
//! PLY mesh writer for .ply files
EMWT_PLY = MAKE_IRR_ID('p','l','y',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 consumes less disk space
EMWF_WRITE_COMPRESSED = 0x2,
//! write in binary format rather than text
EMWF_WRITE_BINARY = 0x4
};
} // end namespace scene
} // end namespace irr
#endif // __E_MESH_WRITER_ENUMS_H_INCLUDED__

View File

@ -0,0 +1,36 @@
// Copyright (C) 2002-2012 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,56 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __E_PRIMITIVE_TYPES_H_INCLUDED__
#define __E_PRIMITIVE_TYPES_H_INCLUDED__
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
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,58 @@
// Copyright (C) 2002-2012 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,
//! FPS camera animator
ESNAT_CAMERA_FPS,
//! Maya camera animator
ESNAT_CAMERA_MAYA,
//! 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 this enumeration to 32 bit.
ESNAT_FORCE_32_BIT = 0x7fffffff
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,106 @@
// Copyright (C) 2002-2012 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
{
//! of type CSceneManager (note that ISceneManager is not(!) an ISceneNode)
ESNT_SCENE_MANAGER = MAKE_IRR_ID('s','m','n','g'),
//! 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','_'),
//! Sky Dome Scene Node
ESNT_SKY_DOME = MAKE_IRR_ID('s','k','y','d'),
//! Shadow Volume Scene Node
ESNT_SHADOW_VOLUME = MAKE_IRR_ID('s','h','d','w'),
//! Octree Scene Node
ESNT_OCTREE = MAKE_IRR_ID('o','c','t','r'),
//! 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','_'),
//! 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 Shader Scene Node
ESNT_Q3SHADER_SCENE_NODE = MAKE_IRR_ID('q','3','s','h'),
//! Quake3 Model Scene Node ( has tag to link to )
ESNT_MD3_SCENE_NODE = MAKE_IRR_ID('m','d','3','_'),
//! Volume Light Scene Node
ESNT_VOLUME_LIGHT = MAKE_IRR_ID('v','o','l','l'),
//! Maya Camera Scene Node
/** Legacy, for loading version <= 1.4.x .irr files */
ESNT_CAMERA_MAYA = MAKE_IRR_ID('c','a','m','M'),
//! First Person Shooter Camera
/** Legacy, for loading version <= 1.4.x .irr files */
ESNT_CAMERA_FPS = MAKE_IRR_ID('c','a','m','F'),
//! Unknown scene node
ESNT_UNKNOWN = MAKE_IRR_ID('u','n','k','n'),
//! Will match with any scene node when checking types
ESNT_ANY = MAKE_IRR_ID('a','n','y','_')
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,90 @@
#ifndef __E_SHADER_TYPES_H_INCLUDED__
#define __E_SHADER_TYPES_H_INCLUDED__
#include "irrTypes.h"
namespace irr
{
namespace video
{
//! 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,
EVST_VS_4_0,
EVST_VS_4_1,
EVST_VS_5_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",
"vs_4_0",
"vs_4_1",
"vs_5_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,
EPST_PS_4_0,
EPST_PS_4_1,
EPST_PS_5_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",
"ps_4_0",
"ps_4_1",
"ps_5_0",
0 };
//! Enum for supported geometry shader types
enum E_GEOMETRY_SHADER_TYPE
{
EGST_GS_4_0 = 0,
//! This is not a type, but a value indicating how much types there are.
EGST_COUNT
};
//! String names for supported geometry shader types
const c8* const GEOMETRY_SHADER_TYPE_NAMES[] = {
"gs_4_0",
0 };
} // end namespace video
} // end namespace irr
#endif // __E_SHADER_TYPES_H_INCLUDED__

View File

@ -0,0 +1,36 @@
// Copyright (C) 2002-2012 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,115 @@
// Copyright (C) 2002-2012 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
{
//! Possible types of (animated) meshes.
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,
//! Halflife MDL model file
EAMT_MDL_HALFLIFE,
//! 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:
//! Gets the frame count of the animated mesh.
/** \return The amount of frames. If the amount is 1,
it is a static, non animated mesh. */
virtual u32 getFrameCount() const = 0;
//! Gets the animation speed of the animated mesh.
/** \return The number of frames per second to play the
animation with by default. If the amount is 0,
it is a static, non animated mesh. */
virtual f32 getAnimationSpeed() const = 0;
//! Sets the animation speed of the animated mesh.
/** \param fps Number of frames per second to play the
animation with by default. If the amount is 0,
it is not animated. The actual speed is set in the
scene node the mesh is instantiated in.*/
virtual void setAnimationSpeed(f32 fps) =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-2012 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 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 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;
//! Get amount of md2 animations in this file.
virtual s32 getAnimationCount() const = 0;
//! Get 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,304 @@
// Copyright (C) 2007-2012 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
{
//! First frame
s32 first;
//! Last frame
s32 num;
//! Looping frames
s32 looping;
//! Frames per second
s32 fps;
};
// byte-align structures
#include "irrpack.h"
//! 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. artefact md2
s32 frameStart; //starting position of frame-structur
s32 tagStart; //starting position of tag-structures
s32 tagEnd; //ending position of tag-structures/starting position of mesh-structures
s32 fileSize;
} PACK_STRUCT;
//! this holds the header info of an MD3 mesh section
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;
} PACK_STRUCT;
//! Compressed Vertex Data
struct SMD3Vertex
{
s16 position[3];
u8 normal[2];
} PACK_STRUCT;
//! Texture Coordinate
struct SMD3TexCoord
{
f32 u;
f32 v;
} PACK_STRUCT;
//! Triangle Index
struct SMD3Face
{
s32 Index[3];
} PACK_STRUCT;
// Default alignment
#include "irrunpack.h"
//! Holding Frame Data for a Mesh
struct SMD3MeshBuffer : public IReferenceCounted
{
SMD3MeshHeader MeshHeader;
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 SMD3QuaternionTag
{
virtual ~SMD3QuaternionTag()
{
position.X = 0.f;
}
// construct copy constructor
SMD3QuaternionTag( const SMD3QuaternionTag & copyMe )
{
*this = copyMe;
}
// construct for searching
SMD3QuaternionTag( const core::stringc& name )
: Name ( name ) {}
// construct from a position and euler angles in degrees
SMD3QuaternionTag ( const core::vector3df &pos, const core::vector3df &angle )
: position(pos), rotation(angle * core::DEGTORAD) {}
// set to matrix
void setto ( core::matrix4 &m )
{
rotation.getMatrix ( m, position );
}
bool operator == ( const SMD3QuaternionTag &other ) const
{
return Name == other.Name;
}
SMD3QuaternionTag & operator=( const SMD3QuaternionTag & copyMe )
{
Name = copyMe.Name;
position = copyMe.position;
rotation = copyMe.rotation;
return *this;
}
core::stringc Name;
core::vector3df position;
core::quaternion rotation;
};
//! holds a associative list of named quaternions
struct SMD3QuaternionTagList
{
SMD3QuaternionTagList()
{
Container.setAllocStrategy(core::ALLOC_STRATEGY_SAFE);
}
// construct copy constructor
SMD3QuaternionTagList(const SMD3QuaternionTagList& copyMe)
{
*this = copyMe;
}
virtual ~SMD3QuaternionTagList() {}
SMD3QuaternionTag* get(const core::stringc& name)
{
SMD3QuaternionTag search ( name );
s32 index = Container.linear_search ( search );
if ( index >= 0 )
return &Container[index];
return 0;
}
u32 size () const
{
return Container.size();
}
void set_used(u32 new_size)
{
s32 diff = (s32) new_size - (s32) Container.allocated_size();
if ( diff > 0 )
{
SMD3QuaternionTag e("");
for ( s32 i = 0; i < diff; ++i )
Container.push_back(e);
}
}
const SMD3QuaternionTag& operator[](u32 index) const
{
return Container[index];
}
SMD3QuaternionTag& operator[](u32 index)
{
return Container[index];
}
void push_back(const SMD3QuaternionTag& other)
{
Container.push_back(other);
}
SMD3QuaternionTagList& operator = (const SMD3QuaternionTagList & copyMe)
{
Container = copyMe.Container;
return *this;
}
private:
core::array < SMD3QuaternionTag > Container;
};
//! Holding Frames Buffers and Tag Infos
struct SMD3Mesh: public IReferenceCounted
{
SMD3Mesh ()
{
MD3Header.numFrames = 0;
}
virtual ~SMD3Mesh()
{
for (u32 i=0; i<Buffer.size(); ++i)
Buffer[i]->drop();
}
core::stringc Name;
core::array<SMD3MeshBuffer*> Buffer;
SMD3QuaternionTagList TagList;
SMD3Header MD3Header;
};
//! 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;
//! get the tag list of the mesh.
virtual SMD3QuaternionTagList* getTagList(s32 frame, s32 detailLevel, s32 startFrameLoop, s32 endFrameLoop) =0;
//! get the original md3 mesh.
virtual SMD3Mesh* getOriginalMesh() =0;
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,228 @@
// Copyright (C) 2002-2012 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"
namespace irr
{
namespace scene
{
class IShadowVolumeSceneNode;
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
};
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 True if successful, false if not. */
virtual bool setFrameLoop(s32 begin, s32 end) = 0;
//! Sets the speed with which the animation is played.
/** \param framesPerSecond: Frames per second played. */
virtual void setAnimationSpeed(f32 framesPerSecond) = 0;
//! Gets the speed with which the animation is played.
/** \return Frames per second played. */
virtual f32 getAnimationSpeed() const =0;
//! Creates shadow volume scene node as child of this node.
/** 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 shadowMesh: Optional custom mesh for shadow volume.
\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 (for zfail shadow volume we support only
finite shadows, so camera zfar must be larger than shadow back cap,
which is depend on infinity parameter).
\return Pointer to the created shadow scene node. This pointer
should not be dropped. See IReferenceCounted::drop() for more
information. */
virtual IShadowVolumeSceneNode* addShadowVolumeSceneNode(const IMesh* shadowMesh=0,
s32 id=-1, bool zfailmethod=true, f32 infinity=1000.0f) = 0;
//! Get 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 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;
//! Gets joint count.
/** \return Amount of joints in the mesh. */
virtual u32 getJointCount() const = 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 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 currently 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;
//! returns the current loop mode
/** When true the animations are played looped */
virtual bool getLoopMode() const = 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;
//! Get 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 SMD3QuaternionTag* getMD3TagTransformation( const core::stringc & tagname) = 0;
//! Set how the joints should be updated on render
virtual void setJointMode(E_JOINT_UPDATE_ON_RENDER mode)=0;
//! Sets the transition time in seconds
/** Note: This needs to enable joints, and setJointmode set to
EJUOR_CONTROL. You must call animateJoints(), or the mesh will
not animate. */
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 its transformation.
/** Culling is unaffected. */
virtual void setRenderFromIdentity( bool On )=0;
//! Creates a clone of this scene node and its children.
/** \param newParent An optional new parent.
\param newManager An optional new scene manager.
\return The newly created clone of this node. */
virtual ISceneNode* clone(ISceneNode* newParent=0, ISceneManager* newManager=0) = 0;
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,71 @@
// Copyright (C) 2002-2012 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;
//! Enumeration 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 fschar_t* Filename;
};
//! An object which is able to serialize and deserialize its attributes into an attributes object
class IAttributeExchangingObject : virtual public 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,738 @@
// Copyright (C) 2002-2012 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 "dimension2d.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"
#include "EAttributes.h"
#include "path.h"
namespace irr
{
namespace video
{
class ITexture;
} // end namespace video
namespace io
{
class IXMLWriter;
//! 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) const =0;
//! Removes all attributes
virtual void clear() = 0;
//! Reads attributes from a xml file.
//! \param reader The XML reader to read from
//! \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) const =0;
//! Gets an attribute as integer value
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
virtual s32 getAttributeAsInt(s32 index) const =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 index Index value, must be between 0 and getAttributeCount()-1.
//! \param value String to which the attribute is set.
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 index Index value, must be between 0 and getAttributeCount()-1.
//! \param value String to which the attribute is set.
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.
\param outData Pointer to buffer where data shall be stored.
\param maxSizeInBytes Maximum number of bytes to write into outData.
*/
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.
\param outData Pointer to buffer where data shall be stored.
\param maxSizeInBytes Maximum number of bytes to write into outData.
*/
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, const 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, const 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.
\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(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.
//! \param outLiterals Set of strings to choose the enum name from.
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.
//! \param outLiterals Set of strings to choose the enum name from.
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;
/*
Vector2d Attribute
*/
//! Adds an attribute as 2d vector
virtual void addVector2d(const c8* attributeName, core::vector2df value) = 0;
//! Sets a attribute as 2d vector
virtual void setAttribute(const c8* attributeName, core::vector2df v) = 0;
//! Gets an attribute as vector
//! \param attributeName: Name of the attribute to get.
//! \return Returns value of the attribute previously set by setAttribute()
virtual core::vector2df getAttributeAsVector2d(const c8* attributeName) = 0;
//! Gets an attribute as position
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
virtual core::vector2df getAttributeAsVector2d(s32 index) = 0;
//! Sets an attribute as 2d vector
virtual void setAttribute(s32 index, core::vector2df 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;
/*
Dimension2d Attribute
*/
//! Adds an attribute as dimension2d
virtual void addDimension2d(const c8* attributeName, core::dimension2d<u32> value) = 0;
//! Sets an attribute as dimension2d
virtual void setAttribute(const c8* attributeName, core::dimension2d<u32> v) = 0;
//! Gets an attribute as dimension2d
//! \param attributeName: Name of the attribute to get.
//! \return Returns value of the attribute previously set by setAttribute()
virtual core::dimension2d<u32> getAttributeAsDimension2d(const c8* attributeName) = 0;
//! Gets an attribute as dimension2d
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
virtual core::dimension2d<u32> getAttributeAsDimension2d(s32 index) = 0;
//! Sets an attribute as dimension2d
virtual void setAttribute(s32 index, core::dimension2d<u32> 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, const io::path& filename = "") = 0;
//! Sets an attribute as texture reference
virtual void setAttribute(const c8* attributeName, video::ITexture* texture, const io::path& filename = "") = 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, const io::path& filename = "") = 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,75 @@
// Copyright (C) 2002-2012 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, making it rectangular.
virtual void setSize(const core::dimension2d<f32>& size) = 0;
//! Sets the size of the billboard with independent widths of the bottom and top edges.
/** \param[in] height The height of the billboard.
\param[in] bottomEdgeWidth The width of the bottom edge of the billboard.
\param[in] topEdgeWidth The width of the top edge of the billboard.
*/
virtual void setSize(f32 height, f32 bottomEdgeWidth, f32 topEdgeWidth) = 0;
//! Returns the size of the billboard.
/** This will return the width of the bottom edge of the billboard.
Use getWidths() to retrieve the bottom and top edges independently.
\return Size of the billboard.
*/
virtual const core::dimension2d<f32>& getSize() const = 0;
//! Gets the size of the the billboard and handles independent top and bottom edge widths correctly.
/** \param[out] height The height of the billboard.
\param[out] bottomEdgeWidth The width of the bottom edge of the billboard.
\param[out] topEdgeWidth The width of the top edge of the billboard.
*/
virtual void getSize(f32& height, f32& bottomEdgeWidth, f32& topEdgeWidth) const =0;
//! Set the color of all vertices of the billboard
/** \param[in] overallColor Color to set */
virtual void setColor(const video::SColor& overallColor) = 0;
//! Set the color of the top and bottom vertices of the billboard
/** \param[in] topColor Color to set the top vertices
\param[in] bottomColor 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[out] topColor Stores the color of the top vertices
\param[out] 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,62 @@
// Copyright (C) 2002-2012 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_TEXT_SCENE_NODE_H_INCLUDED__
#define __I_BILLBOARD_TEXT_SCENE_NODE_H_INCLUDED__
#include "IBillboardSceneNode.h"
namespace irr
{
namespace scene
{
//! A billboard text scene node.
/** Acts like a billboard which displays the currently set text.
Due to the exclusion of RTTI in Irrlicht we have to avoid multiple
inheritance. Hence, changes to the ITextSceneNode interface have
to be copied here manually.
*/
class IBillboardTextSceneNode : public IBillboardSceneNode
{
public:
//! Constructor
IBillboardTextSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id,
const core::vector3df& position = core::vector3df(0,0,0))
: IBillboardSceneNode(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;
//! 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

View File

@ -0,0 +1,108 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_BONE_SCENE_NODE_H_INCLUDED__
#define __I_BONE_SCENE_NODE_H_INCLUDED__
#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,
};
//! Interface for bones used for skeletal animation.
/** Used with ISkinnedMesh and IAnimatedMeshSceneNode. */
class IBoneSceneNode : public ISceneNode
{
public:
IBoneSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id=-1) :
ISceneNode(parent, mgr, id),positionHint(-1),scaleHint(-1),rotationHint(-1) { }
//! Get the name of the bone
/** \deprecated Use getName instead. This method may be removed by Irrlicht 1.9 */
_IRR_DEPRECATED_ virtual const c8* getBoneName() const { return getName(); }
//! Get the index of the bone
virtual u32 getBoneIndex() const = 0;
//! Sets the animation mode of the bone.
/** \return 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;
//! Get 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;
//! The animation method.
virtual void OnAnimate(u32 timeMs) =0;
//! The render method.
/** 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() const =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,207 @@
// Copyright (C) 2002-2012 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) {}
//! 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.
\param isOrthogonal Set this to true if the matrix is an
orthogonal one (e.g. from matrix4::buildProjectionMatrixOrtho).
*/
virtual void setProjectionMatrix(const core::matrix4& projection, bool isOrthogonal=false) =0;
//! Gets the current projection matrix of the camera.
/** \return The current projection matrix of the camera. */
virtual const core::matrix4& getProjectionMatrix() const =0;
//! Gets the current view matrix of the camera.
/** \return The current view matrix of the camera. */
virtual const core::matrix4& getViewMatrix() const =0;
//! Sets a custom view matrix affector.
/** The matrix passed here, will be multiplied with the view
matrix when it gets updated. This allows for custom camera
setups like, for example, a reflection camera.
\param affector The affector matrix. */
virtual void setViewMatrixAffector(const core::matrix4& affector) =0;
//! Get the custom view matrix affector.
/** \return The affector matrix. */
virtual const core::matrix4& getViewMatrixAffector() 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::addCameraSceneNodeMaya or
ISceneManager::addCameraSceneNodeFPS, 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
/** If the camera's target and rotation are bound ( @see
bindTargetAndRotation() ) then calling this will also change
the camera's scene node rotation to match the target.
Note that setTarget uses the current absolute position
internally, so if you changed setPosition since last rendering you must
call updateAbsolutePosition before using this function.
\param pos Look at target of the camera, in world co-ordinates. */
virtual void setTarget(const core::vector3df& pos) =0;
//! Sets the rotation of the node.
/** This only modifies the relative rotation of the node.
If the camera's target and rotation are bound ( @see
bindTargetAndRotation() ) then calling this will also change
the camera's target to match the rotation.
\param rotation New rotation of the node in degrees. */
virtual void setRotation(const core::vector3df& rotation) =0;
//! Gets the current look at target of the camera
/** \return The current look at target of the camera, in world co-ordinates */
virtual const 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 The up vector of the camera, in world space. */
virtual const core::vector3df& getUpVector() const =0;
//! Gets the value of the near plane of the camera.
/** \return 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 The value of the far plane of the camera. */
virtual f32 getFarValue() const =0;
//! Gets the aspect ratio of the camera.
/** \return The aspect ratio of the camera. */
virtual f32 getAspectRatio() const =0;
//! Gets the field of view of the camera.
/** \return The field of view of the camera in radians. */
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 radians. */
virtual void setFOV(f32 fovy) =0;
//! Get the view frustum.
/** Needed sometimes by bspTree or LOD render nodes.
\return 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;
//! Checks if the input receiver of the camera is currently enabled.
virtual bool isInputReceiverEnabled() const =0;
//! Checks if a camera is orthogonal.
virtual bool isOrthogonal() const
{
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
return IsOrthogonal;
}
//! Binds the camera scene node's rotation to its target position and vice vera, or unbinds them.
/** When bound, calling setRotation() will update the camera's
target position to be along its +Z axis, and likewise calling
setTarget() will update its rotation so that its +Z axis will
point at the target point. FPS camera use this binding by
default; other cameras do not.
\param bound True to bind the camera's scene node rotation
and targetting, false to unbind them.
@see getTargetAndRotationBinding() */
virtual void bindTargetAndRotation(bool bound) =0;
//! Queries if the camera scene node's rotation and its target position are bound together.
/** @see bindTargetAndRotation() */
virtual bool getTargetAndRotationBinding(void) const =0;
//! Writes attributes of the camera node
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const
{
ISceneNode::serializeAttributes(out, options);
if (!out)
return;
out->addBool ("IsOrthogonal", IsOrthogonal );
}
//! Reads attributes of the camera node
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0)
{
ISceneNode::deserializeAttributes(in, options);
if (!in)
return;
if ( in->findAttribute("IsOrthogonal") )
IsOrthogonal = in->getAttributeAsBool("IsOrthogonal");
}
protected:
void cloneMembers(ICameraSceneNode* toCopyFrom)
{
IsOrthogonal = toCopyFrom->IsOrthogonal;
}
bool IsOrthogonal;
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,405 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __IRR_I_COLLADA_MESH_WRITER_H_INCLUDED__
#define __IRR_I_COLLADA_MESH_WRITER_H_INCLUDED__
#include "IMeshWriter.h"
#include "ISceneNode.h"
#include "IAnimatedMesh.h"
#include "SMaterial.h"
namespace irr
{
namespace io
{
class IWriteFile;
} // end namespace io
namespace scene
{
//! Lighting models - more or less the way Collada categorizes materials
enum E_COLLADA_TECHNIQUE_FX
{
//! Blinn-phong which is default for opengl and dx fixed function pipelines.
//! But several well-known renderers don't support it and prefer phong.
ECTF_BLINN,
//! Phong shading, default in many external renderers.
ECTF_PHONG,
//! diffuse shaded surface that is independent of lighting.
ECTF_LAMBERT,
// constantly shaded surface that is independent of lighting.
ECTF_CONSTANT
};
//! How to interpret the opacity in collada
enum E_COLLADA_TRANSPARENT_FX
{
//! default - only alpha channel of color or texture is used.
ECOF_A_ONE = 0,
//! Alpha values for each RGB channel of color or texture are used.
ECOF_RGB_ZERO = 1
};
//! Color names collada uses in it's color samplers
enum E_COLLADA_COLOR_SAMPLER
{
ECCS_DIFFUSE,
ECCS_AMBIENT,
ECCS_EMISSIVE,
ECCS_SPECULAR,
ECCS_TRANSPARENT,
ECCS_REFLECTIVE
};
//! Irrlicht colors which can be mapped to E_COLLADA_COLOR_SAMPLER values
enum E_COLLADA_IRR_COLOR
{
//! Don't write this element at all
ECIC_NONE,
//! Check IColladaMeshWriterProperties for custom color
ECIC_CUSTOM,
//! Use SMaterial::DiffuseColor
ECIC_DIFFUSE,
//! Use SMaterial::AmbientColor
ECIC_AMBIENT,
//! Use SMaterial::EmissiveColor
ECIC_EMISSIVE,
//! Use SMaterial::SpecularColor
ECIC_SPECULAR
};
//! Control when geometry elements are created
enum E_COLLADA_GEOMETRY_WRITING
{
//! Default - write each mesh exactly once to collada. Optimal but will not work with many tools.
ECGI_PER_MESH,
//! Write each mesh as often as it's used with different materials-names in the scene.
//! Material names which are used here are created on export, so using the IColladaMeshWriterNames
//! interface you have some control over how many geometries are written.
ECGI_PER_MESH_AND_MATERIAL
};
//! Callback interface for properties which can be used to influence collada writing
class IColladaMeshWriterProperties : public virtual IReferenceCounted
{
public:
virtual ~IColladaMeshWriterProperties () {}
//! Which lighting model should be used in the technique (FX) section when exporting effects (materials)
virtual E_COLLADA_TECHNIQUE_FX getTechniqueFx(const video::SMaterial& material) const = 0;
//! Which texture index should be used when writing the texture of the given sampler color.
/** \return the index to the texture-layer or -1 if that texture should never be exported
Note: for ECCS_TRANSPARENT by default the alpha channel is used, if you want to use RGB you have to set
also the ECOF_RGB_ZERO flag in getTransparentFx. */
virtual s32 getTextureIdx(const video::SMaterial & material, E_COLLADA_COLOR_SAMPLER cs) const = 0;
//! Return which color from Irrlicht should be used for the color requested by collada
/** Note that collada allows exporting either texture or color, not both.
So color mapping is only checked if we have no valid texture already.
By default we try to return best fits when possible. For example ECCS_DIFFUSE is mapped to ECIC_DIFFUSE.
When ECIC_CUSTOM is returned then the result of getCustomColor will be used. */
virtual E_COLLADA_IRR_COLOR getColorMapping(const video::SMaterial & material, E_COLLADA_COLOR_SAMPLER cs) const = 0;
//! Return custom colors for certain color types requested by collada.
/** Only used when getColorMapping returns ECIC_CUSTOM for the same paramters. */
virtual video::SColor getCustomColor(const video::SMaterial & material, E_COLLADA_COLOR_SAMPLER cs) const = 0;
//! Return the transparence color interpretation.
/** Not this is only about ECCS_TRANSPARENT and does not affect getTransparency. */
virtual E_COLLADA_TRANSPARENT_FX getTransparentFx(const video::SMaterial& material) const = 0;
//! Transparency value for that material.
/** This value is additional to transparent settings, if both are set they will be multiplicated.
\return 1.0 for fully transparent, 0.0 for not transparent and not written at all when < 0.f */
virtual f32 getTransparency(const video::SMaterial& material) const = 0;
//! Reflectivity value for that material
/** The amount of perfect mirror reflection to be added to the reflected light
\return 0.0 - 1.0 for reflectivity and element is not written at all when < 0.f */
virtual f32 getReflectivity(const video::SMaterial& material) const = 0;
//! Return index of refraction for that material
/** By default we don't write that.
\return a value greater equal 0.f to write \<index_of_refraction\> when it is lesser than 0 nothing will be written */
virtual f32 getIndexOfRefraction(const video::SMaterial& material) const = 0;
//! Should node be used in scene export? (only needed for scene-writing, ignored in mesh-writing)
//! By default all visible nodes are exported.
virtual bool isExportable(const irr::scene::ISceneNode * node) const = 0;
//! Return the mesh for the given node. If it has no mesh or shouldn't export it's mesh
//! you can return 0 in which case only the transformation matrix of the node will be used.
// Note: Function is not const because there is no const getMesh() function.
virtual IMesh* getMesh(irr::scene::ISceneNode * node) = 0;
//! Return if the node has it's own material overwriting the mesh-materials
/** Usually true except for mesh-nodes which have isReadOnlyMaterials set.
This is mostly important for naming (as ISceneNode::getMaterial() already returns the correct material).
You have to override it when exporting custom scenenodes with own materials.
\return true => The node's own material is used, false => ignore node material and use the one from the mesh */
virtual bool useNodeMaterial(const scene::ISceneNode* node) const = 0;
};
//! Callback interface to use custom names on collada writing.
/** You can either modify names and id's written to collada or you can use
this interface to just find out which names are used on writing.
*/
class IColladaMeshWriterNames : public virtual IReferenceCounted
{
public:
virtual ~IColladaMeshWriterNames () {}
//! Return a unique name for the given mesh
/** Note that names really must be unique here per mesh-pointer, so
mostly it's a good idea to return the nameForMesh from
IColladaMeshWriter::getDefaultNameGenerator(). Also names must follow
the xs::NCName standard to be valid, you can run them through
IColladaMeshWriter::toNCName to ensure that.
\param mesh Pointer to the mesh which needs a name
\param instance When E_COLLADA_GEOMETRY_WRITING is not ECGI_PER_MESH then
several instances of the same mesh can be written and this counts them.
*/
virtual irr::core::stringw nameForMesh(const scene::IMesh* mesh, int instance) = 0;
//! Return a unique name for the given node
/** Note that names really must be unique here per node-pointer, so
mostly it's a good idea to return the nameForNode from
IColladaMeshWriter::getDefaultNameGenerator(). Also names must follow
the xs::NCName standard to be valid, you can run them through
IColladaMeshWriter::toNCName to ensure that.
*/
virtual irr::core::stringw nameForNode(const scene::ISceneNode* node) = 0;
//! Return a name for the material
/** There is one material created in the writer for each unique name.
So you can use this to control the number of materials which get written.
For example Irrlicht does by default write one material for each material
instanced by a node. So if you know that in your application material
instances per node are identical between different nodes you can reduce
the number of exported materials using that knowledge by using identical
names for such shared materials.
Names must follow the xs::NCName standard to be valid, you can run them
through IColladaMeshWriter::toNCName to ensure that.
*/
virtual irr::core::stringw nameForMaterial(const video::SMaterial & material, int materialId, const scene::IMesh* mesh, const scene::ISceneNode* node) = 0;
};
//! Interface for writing meshes
class IColladaMeshWriter : public IMeshWriter
{
public:
IColladaMeshWriter()
: Properties(0), DefaultProperties(0), NameGenerator(0), DefaultNameGenerator(0)
, WriteTextures(true), WriteDefaultScene(true), ExportSMaterialOnce(true)
, AmbientLight(0.f, 0.f, 0.f, 1.f)
, GeometryWriting(ECGI_PER_MESH)
{
}
//! Destructor
virtual ~IColladaMeshWriter()
{
if ( Properties )
Properties->drop();
if ( DefaultProperties )
DefaultProperties->drop();
if ( NameGenerator )
NameGenerator->drop();
if ( DefaultNameGenerator )
DefaultNameGenerator->drop();
}
//! writes a scene starting with the given node
virtual bool writeScene(io::IWriteFile* file, scene::ISceneNode* root) = 0;
//! Set if texture information should be written
virtual void setWriteTextures(bool write)
{
WriteTextures = write;
}
//! Get if texture information should be written
virtual bool getWriteTextures() const
{
return WriteTextures;
}
//! Set if a default scene should be written when writing meshes.
/** Many collada readers fail to read a mesh if the collada files doesn't contain a scene as well.
The scene is doing an instantiation of the mesh.
When using writeScene this flag is ignored (as we have scene there already)
*/
virtual void setWriteDefaultScene(bool write)
{
WriteDefaultScene = write;
}
//! Get if a default scene should be written
virtual bool getWriteDefaultScene() const
{
return WriteDefaultScene;
}
//! Sets ambient color of the scene to write
virtual void setAmbientLight(const video::SColorf &ambientColor)
{
AmbientLight = ambientColor;
}
//! Return ambient light of the scene which is written
virtual video::SColorf getAmbientLight() const
{
return AmbientLight;
}
//! Control when and how often a mesh is written
/** Optimally ECGI_PER_MESH would be always sufficent - writing geometry once per mesh.
Unfortunately many tools (at the time of writing this nearly all of them) have trouble
on import when different materials are used per node. So when you override materials
per node and importing the resuling collada has materials problems in other tools try
using other values here.
\param writeStyle One of the E_COLLADA_GEOMETRY_WRITING settings.
*/
virtual void setGeometryWriting(E_COLLADA_GEOMETRY_WRITING writeStyle)
{
GeometryWriting = writeStyle;
}
//! Get the current style of geometry writing.
virtual E_COLLADA_GEOMETRY_WRITING getGeometryWriting() const
{
return GeometryWriting;
}
//! Make certain there is only one collada material generated per Irrlicht material
/** Checks before creating a collada material-name if an identical
irr:::video::SMaterial has been exported already. If so don't export it with
another name. This is set by default and leads to way smaller .dae files.
Note that if you need to disable this flag for some reason you can still
get a similar effect using the IColladaMeshWriterNames::nameForMaterial
by returning identical names for identical materials there.
*/
virtual void setExportSMaterialsOnlyOnce(bool exportOnce)
{
ExportSMaterialOnce = exportOnce;
}
virtual bool getExportSMaterialsOnlyOnce() const
{
return ExportSMaterialOnce;
}
//! Set properties to use by the meshwriter instead of it's default properties.
/** Overloading properties with an own class allows modifying the writing process in certain ways.
By default properties are set to the DefaultProperties. */
virtual void setProperties(IColladaMeshWriterProperties * p)
{
if ( p == Properties )
return;
if ( p )
p->grab();
if ( Properties )
Properties->drop();
Properties = p;
}
//! Get properties which are currently used.
virtual IColladaMeshWriterProperties * getProperties() const
{
return Properties;
}
//! Return the original default properties of the writer.
/** You can use this pointer in your own properties to access and return default values. */
IColladaMeshWriterProperties * getDefaultProperties() const
{
return DefaultProperties;
}
//! Install a generator to create custom names on export.
virtual void setNameGenerator(IColladaMeshWriterNames * nameGenerator)
{
if ( nameGenerator == NameGenerator )
return;
if ( nameGenerator )
nameGenerator->grab();
if ( NameGenerator )
NameGenerator->drop();
NameGenerator = nameGenerator;
}
//! Get currently used name generator
virtual IColladaMeshWriterNames * getNameGenerator() const
{
return NameGenerator;
}
//! Return the original default name generator of the writer.
/** You can use this pointer in your own generator to access and return default values. */
IColladaMeshWriterNames * getDefaultNameGenerator() const
{
return DefaultNameGenerator;
}
//! Restrict the characters of oldString a set of allowed characters in xs::NCName and add the prefix.
/** A tool function to help when using a custom name generator to generative valid names for collada names and id's. */
virtual irr::core::stringw toNCName(const irr::core::stringw& oldString, const irr::core::stringw& prefix=irr::core::stringw(L"_NC_")) const = 0;
protected:
// NOTE: You usually should also call setProperties with the same paraemter when using setDefaultProperties
virtual void setDefaultProperties(IColladaMeshWriterProperties * p)
{
if ( p == DefaultProperties )
return;
if ( p )
p->grab();
if ( DefaultProperties )
DefaultProperties->drop();
DefaultProperties = p;
}
// NOTE: You usually should also call setNameGenerator with the same paraemter when using setDefaultProperties
virtual void setDefaultNameGenerator(IColladaMeshWriterNames * p)
{
if ( p == DefaultNameGenerator )
return;
if ( p )
p->grab();
if ( DefaultNameGenerator )
DefaultNameGenerator->drop();
DefaultNameGenerator = p;
}
private:
IColladaMeshWriterProperties * Properties;
IColladaMeshWriterProperties * DefaultProperties;
IColladaMeshWriterNames * NameGenerator;
IColladaMeshWriterNames * DefaultNameGenerator;
bool WriteTextures;
bool WriteDefaultScene;
bool ExportSMaterialOnce;
video::SColorf AmbientLight;
E_COLLADA_GEOMETRY_WRITING GeometryWriting;
};
} // end namespace
} // end namespace
#endif

View File

@ -0,0 +1,192 @@
// Copyright (C) 2002-2012 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
{
class IGUISpriteBank;
//! Default icons for cursors
enum ECURSOR_ICON
{
// Following cursors might be system specific, or might use an Irrlicht icon-set. No guarantees so far.
ECI_NORMAL, // arrow
ECI_CROSS, // Crosshair
ECI_HAND, // Hand
ECI_HELP, // Arrow and question mark
ECI_IBEAM, // typical text-selection cursor
ECI_NO, // should not click icon
ECI_WAIT, // hourclass
ECI_SIZEALL, // arrow in all directions
ECI_SIZENESW, // resizes in direction north-east or south-west
ECI_SIZENWSE, // resizes in direction north-west or south-east
ECI_SIZENS, // resizes in direction north or south
ECI_SIZEWE, // resizes in direction west or east
ECI_UP, // up-arrow
// Implementer note: Should we add system specific cursors, which use guaranteed the system icons,
// then I would recommend using a naming scheme like ECI_W32_CROSS, ECI_X11_CROSSHAIR and adding those
// additionally.
ECI_COUNT // maximal of defined cursors. Note that higher values can be created at runtime
};
//! Names for ECURSOR_ICON
const c8* const GUICursorIconNames[ECI_COUNT+1] =
{
"normal",
"cross",
"hand",
"help",
"ibeam",
"no",
"wait",
"sizeall",
"sizenesw",
"sizenwse",
"sizens",
"sizewe",
"sizeup",
0
};
//! structure used to set sprites as cursors.
struct SCursorSprite
{
SCursorSprite()
: SpriteBank(0), SpriteId(-1)
{
}
SCursorSprite( gui::IGUISpriteBank * spriteBank, s32 spriteId, const core::position2d<s32> &hotspot=(core::position2d<s32>(0,0)) )
: SpriteBank(spriteBank), SpriteId(spriteId), HotSpot(hotspot)
{
}
IGUISpriteBank * SpriteBank;
s32 SpriteId;
core::position2d<s32> HotSpot;
};
//! platform specific behavior flags for the cursor
enum ECURSOR_PLATFORM_BEHAVIOR
{
//! default - no platform specific behavior
ECPB_NONE = 0,
//! On X11 try caching cursor updates as XQueryPointer calls can be expensive.
/** Update cursor positions only when the irrlicht timer has been updated or the timer is stopped.
This means you usually get one cursor update per device->run() which will be fine in most cases.
See this forum-thread for a more detailed explanation:
http://irrlicht.sourceforge.net/forum/viewtopic.php?f=7&t=45525
*/
ECPB_X11_CACHE_UPDATES = 1
};
//! 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 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 const 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;
//! Sets the active cursor icon
/** Setting cursor icons is so far only supported on Win32 and Linux */
virtual void setActiveIcon(ECURSOR_ICON iconId) {}
//! Gets the currently active icon
virtual ECURSOR_ICON getActiveIcon() const { return gui::ECI_NORMAL; }
//! Add a custom sprite as cursor icon.
/** \return Identification for the icon */
virtual ECURSOR_ICON addIcon(const gui::SCursorSprite& icon) { return gui::ECI_NORMAL; }
//! replace a cursor icon.
/** Changing cursor icons is so far only supported on Win32 and Linux
Note that this only changes the icons within your application, system cursors outside your
application will not be affected.
*/
virtual void changeIcon(ECURSOR_ICON iconId, const gui::SCursorSprite& sprite) {}
//! Return a system-specific size which is supported for cursors. Larger icons will fail, smaller icons might work.
virtual core::dimension2di getSupportedIconSize() const { return core::dimension2di(0,0); }
//! Set platform specific behavior flags.
virtual void setPlatformBehavior(ECURSOR_PLATFORM_BEHAVIOR behavior) {}
//! Return platform specific behavior.
/** \return Behavior set by setPlatformBehavior or ECPB_NONE for platforms not implementing specific behaviors.
*/
virtual ECURSOR_PLATFORM_BEHAVIOR getPlatformBehavior() const { return ECPB_NONE; }
};
} // end namespace gui
} // end namespace irr
#endif

View File

@ -0,0 +1,42 @@
// Copyright (C) 2002-2012 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,211 @@
// Copyright (C) 2008-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_DYNAMIC_MESH_BUFFER_H_INCLUDED__
#define __I_DYNAMIC_MESH_BUFFER_H_INCLUDED__
#include "IMeshBuffer.h"
#include "IVertexBuffer.h"
#include "IIndexBuffer.h"
namespace irr
{
namespace scene
{
/** a dynamic meshBuffer */
class IDynamicMeshBuffer : public IMeshBuffer
{
public:
virtual IVertexBuffer &getVertexBuffer() const =0;
virtual IIndexBuffer &getIndexBuffer() const =0;
virtual void setVertexBuffer(IVertexBuffer *vertexBuffer) =0;
virtual void setIndexBuffer(IIndexBuffer *indexBuffer) =0;
//! Get the material of this meshbuffer
/** \return Material of this buffer. */
virtual video::SMaterial& getMaterial() =0;
//! Get the material of this meshbuffer
/** \return Material of this buffer. */
virtual const video::SMaterial& getMaterial() const =0;
//! Get the axis aligned bounding box of this meshbuffer.
/** \return Axis aligned bounding box of this buffer. */
virtual const core::aabbox3df& getBoundingBox() const =0;
//! Set axis aligned bounding box
/** \param box User defined axis aligned bounding box to use
for this buffer. */
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
/** Only works for compatible vertex types.
\param vertices Pointer to a vertex array.
\param numVertices Number of vertices in the array.
\param indices Pointer to index array.
\param numIndices Number of indices in array. */
virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices)
{
}
//! Append the meshbuffer to the current buffer
/** Only works for compatible vertex types
\param other Buffer to append to this one. */
virtual void append(const IMeshBuffer* const other)
{
}
// ------------------- To be removed? ------------------- //
//! get the current hardware mapping hint
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Vertex() const
{
return getVertexBuffer().getHardwareMappingHint();
}
//! get the current hardware mapping hint
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Index() const
{
return getIndexBuffer().getHardwareMappingHint();
}
//! set the hardware mapping hint, for driver
virtual void setHardwareMappingHint( E_HARDWARE_MAPPING NewMappingHint, E_BUFFER_TYPE Buffer=EBT_VERTEX_AND_INDEX )
{
if (Buffer==EBT_VERTEX_AND_INDEX || Buffer==EBT_VERTEX)
getVertexBuffer().setHardwareMappingHint(NewMappingHint);
if (Buffer==EBT_VERTEX_AND_INDEX || Buffer==EBT_INDEX)
getIndexBuffer().setHardwareMappingHint(NewMappingHint);
}
//! flags the mesh as changed, reloads hardware buffers
virtual void setDirty(E_BUFFER_TYPE Buffer=EBT_VERTEX_AND_INDEX)
{
if (Buffer==EBT_VERTEX_AND_INDEX || Buffer==EBT_VERTEX)
getVertexBuffer().setDirty();
if (Buffer==EBT_VERTEX_AND_INDEX || Buffer==EBT_INDEX)
getIndexBuffer().setDirty();
}
virtual u32 getChangedID_Vertex() const
{
return getVertexBuffer().getChangedID();
}
virtual u32 getChangedID_Index() const
{
return getIndexBuffer().getChangedID();
}
// ------------------- Old interface ------------------- //
//! Get type of vertex data which is stored in this meshbuffer.
/** \return Vertex type of this buffer. */
virtual video::E_VERTEX_TYPE getVertexType() const
{
return getVertexBuffer().getType();
}
//! Get access to vertex data. The data is an array of vertices.
/** Which vertex type is used can be determined by getVertexType().
\return Pointer to array of vertices. */
virtual const void* getVertices() const
{
return getVertexBuffer().getData();
}
//! Get access to vertex data. The data is an array of vertices.
/** Which vertex type is used can be determined by getVertexType().
\return Pointer to array of vertices. */
virtual void* getVertices()
{
return getVertexBuffer().getData();
}
//! Get amount of vertices in meshbuffer.
/** \return Number of vertices in this buffer. */
virtual u32 getVertexCount() const
{
return getVertexBuffer().size();
}
//! Get type of index data which is stored in this meshbuffer.
/** \return Index type of this buffer. */
virtual video::E_INDEX_TYPE getIndexType() const
{
return getIndexBuffer().getType();
}
//! Get access to Indices.
/** \return Pointer to indices array. */
virtual const u16* getIndices() const
{
return (u16*)getIndexBuffer().getData();
}
//! Get access to Indices.
/** \return Pointer to indices array. */
virtual u16* getIndices()
{
return (u16*)getIndexBuffer().getData();
}
//! Get amount of indices in this meshbuffer.
/** \return Number of indices in this buffer. */
virtual u32 getIndexCount() const
{
return getIndexBuffer().size();
}
//! returns position of vertex i
virtual const core::vector3df& getPosition(u32 i) const
{
return getVertexBuffer()[i].Pos;
}
//! returns position of vertex i
virtual core::vector3df& getPosition(u32 i)
{
return getVertexBuffer()[i].Pos;
}
//! returns texture coords of vertex i
virtual const core::vector2df& getTCoords(u32 i) const
{
return getVertexBuffer()[i].TCoords;
}
//! returns texture coords of vertex i
virtual core::vector2df& getTCoords(u32 i)
{
return getVertexBuffer()[i].TCoords;
}
//! returns normal of vertex i
virtual const core::vector3df& getNormal(u32 i) const
{
return getVertexBuffer()[i].Normal;
}
//! returns normal of vertex i
virtual core::vector3df& getNormal(u32 i)
{
return getVertexBuffer()[i].Normal;
}
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,490 @@
// Copyright (C) 2002-2012 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 "Keycodes.h"
#include "irrString.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 its elements,
then finally the input receiving scene manager where it is passed to the active camera.
*/
EET_MOUSE_INPUT_EVENT,
//! A key input event.
/** Like mouse events, keyboard events are created by the device and passed to
IrrlichtDevice::postEventFromUser. They take the same path as mouse events. */
EET_KEY_INPUT_EVENT,
//! A joystick (joypad, gamepad) input event.
/** Joystick events are created by polling all connected joysticks once per
device run() and then passing the events to IrrlichtDevice::postEventFromUser.
They take the same path as mouse events.
Windows, SDL: Implemented.
Linux: Implemented, with POV hat issues.
MacOS / Other: Not yet implemented.
*/
EET_JOYSTICK_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. The Irrlicht 'window handle'
can be obtained from IrrlichtDevice::getExposedVideoData()
The usage and behavior depends on the operating system:
Windows: send a WM_USER message to the Irrlicht Window; the
wParam and lParam will be used to populate the
UserData1 and UserData2 members of the SUserEvent.
Linux: send a ClientMessage via XSendEvent to the Irrlicht
Window; the data.l[0] and data.l[1] members will be
casted to s32 and used as UserData1 and UserData2.
MacOS: Not yet implemented
*/
EET_USER_EVENT,
//! This enum is never used, it only forces the compiler to
//! compile these enumeration values to 32 bit.
EGUIET_FORCE_32_BIT = 0x7fffffff
};
//! 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,
//! Left mouse button double click.
//! This event is generated after the second EMIE_LMOUSE_PRESSED_DOWN event.
EMIE_LMOUSE_DOUBLE_CLICK,
//! Right mouse button double click.
//! This event is generated after the second EMIE_RMOUSE_PRESSED_DOWN event.
EMIE_RMOUSE_DOUBLE_CLICK,
//! Middle mouse button double click.
//! This event is generated after the second EMIE_MMOUSE_PRESSED_DOWN event.
EMIE_MMOUSE_DOUBLE_CLICK,
//! Left mouse button triple click.
//! This event is generated after the third EMIE_LMOUSE_PRESSED_DOWN event.
EMIE_LMOUSE_TRIPLE_CLICK,
//! Right mouse button triple click.
//! This event is generated after the third EMIE_RMOUSE_PRESSED_DOWN event.
EMIE_RMOUSE_TRIPLE_CLICK,
//! Middle mouse button triple click.
//! This event is generated after the third EMIE_MMOUSE_PRESSED_DOWN event.
EMIE_MMOUSE_TRIPLE_CLICK,
//! No real event. Just for convenience to get number of events
EMIE_COUNT
};
//! Masks for mouse button states
enum E_MOUSE_BUTTON_STATE_MASK
{
EMBSM_LEFT = 0x01,
EMBSM_RIGHT = 0x02,
EMBSM_MIDDLE = 0x04,
//! currently only on windows
EMBSM_EXTRA1 = 0x08,
//! currently only on windows
EMBSM_EXTRA2 = 0x10,
EMBSM_FORCE_32_BIT = 0x7fffffff
};
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.
/** If an element has sub-elements you also get this message for the subelements */
EGET_ELEMENT_HOVERED,
//! The mouse cursor left the hovered element.
/** If an element has sub-elements you also get this message for the subelements */
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 selected.
/** NOTE: You also get this event currently when the same item was clicked again after more than 500 ms. */
EGET_LISTBOX_CHANGED,
//! An item in the listbox was selected, which was already selected.
/** NOTE: You get the event currently only if the item was clicked again within 500 ms or selected by "enter" or "space". */
EGET_LISTBOX_SELECTED_AGAIN,
//! A file has been selected in the file dialog
EGET_FILE_SELECTED,
//! A directory has been selected in the file dialog
EGET_DIRECTORY_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 'ENTER' was pressed
EGET_EDITBOX_ENTER,
//! The text in an editbox was changed. This does not include automatic changes in text-breaking.
EGET_EDITBOX_CHANGED,
//! The marked area in an editbox was changed.
EGET_EDITBOX_MARKING_CHANGED,
//! 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,
//! A table has changed
EGET_TABLE_CHANGED,
EGET_TABLE_HEADER_CHANGED,
EGET_TABLE_SELECTED_AGAIN,
//! A tree view node lost selection. See IGUITreeView::getLastEventNode().
EGET_TREEVIEW_NODE_DESELECT,
//! A tree view node was selected. See IGUITreeView::getLastEventNode().
EGET_TREEVIEW_NODE_SELECT,
//! A tree view node was expanded. See IGUITreeView::getLastEventNode().
EGET_TREEVIEW_NODE_EXPAND,
//! A tree view node was collapsed. See IGUITreeView::getLastEventNode().
EGET_TREEVIEW_NODE_COLLAPSE,
//! deprecated - use EGET_TREEVIEW_NODE_COLLAPSE instead. This
//! may be removed by Irrlicht 1.9
EGET_TREEVIEW_NODE_COLLAPS = EGET_TREEVIEW_NODE_COLLAPSE,
//! No real event. Just for convenience to get number of events
EGET_COUNT
};
} // end namespace gui
//! SEvents hold information about an event. See irr::IEventReceiver for details on event handling.
struct SEvent
{
//! Any kind of GUI event.
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;
};
//! Any kind of mouse event.
struct SMouseInput
{
//! X position of mouse cursor
s32 X;
//! Y position of mouse cursor
s32 Y;
//! mouse wheel delta, often 1.0 or -1.0, but can have other values < 0.f or > 0.f;
/** Only valid if event was EMIE_MOUSE_WHEEL */
f32 Wheel;
//! True if shift was also pressed
bool Shift:1;
//! True if ctrl was also pressed
bool Control:1;
//! A bitmap of button states. You can use isButtonPressed() to determine
//! if a button is pressed or not.
//! Currently only valid if the event was EMIE_MOUSE_MOVED
u32 ButtonStates;
//! Is the left button pressed down?
bool isLeftPressed() const { return 0 != ( ButtonStates & EMBSM_LEFT ); }
//! Is the right button pressed down?
bool isRightPressed() const { return 0 != ( ButtonStates & EMBSM_RIGHT ); }
//! Is the middle button pressed down?
bool isMiddlePressed() const { return 0 != ( ButtonStates & EMBSM_MIDDLE ); }
//! Type of mouse event
EMOUSE_INPUT_EVENT Event;
};
//! Any kind of keyboard 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 true, then the key was left up
bool PressedDown:1;
//! True if shift was also pressed
bool Shift:1;
//! True if ctrl was also pressed
bool Control:1;
};
//! A joystick event.
/** Unlike other events, joystick events represent the result of polling
* each connected joystick once per run() of the device. Joystick events will
* not be generated by default. If joystick support is available for the
* active device, _IRR_COMPILE_WITH_JOYSTICK_EVENTS_ is defined, and
* @ref irr::IrrlichtDevice::activateJoysticks() has been called, an event of
* this type will be generated once per joystick per @ref IrrlichtDevice::run()
* regardless of whether the state of the joystick has actually changed. */
struct SJoystickEvent
{
enum
{
NUMBER_OF_BUTTONS = 32,
AXIS_X = 0, // e.g. analog stick 1 left to right
AXIS_Y, // e.g. analog stick 1 top to bottom
AXIS_Z, // e.g. throttle, or analog 2 stick 2 left to right
AXIS_R, // e.g. rudder, or analog 2 stick 2 top to bottom
AXIS_U,
AXIS_V,
NUMBER_OF_AXES
};
/** A bitmap of button states. You can use IsButtonPressed() to
( check the state of each button from 0 to (NUMBER_OF_BUTTONS - 1) */
u32 ButtonStates;
/** For AXIS_X, AXIS_Y, AXIS_Z, AXIS_R, AXIS_U and AXIS_V
* Values are in the range -32768 to 32767, with 0 representing
* the center position. You will receive the raw value from the
* joystick, and so will usually want to implement a dead zone around
* the center of the range. Axes not supported by this joystick will
* always have a value of 0. On Linux, POV hats are represented as axes,
* usually the last two active axis.
*/
s16 Axis[NUMBER_OF_AXES];
/** The POV represents the angle of the POV hat in degrees * 100,
* from 0 to 35,900. A value of 65535 indicates that the POV hat
* is centered (or not present).
* This value is only supported on Windows. On Linux, the POV hat
* will be sent as 2 axes instead. */
u16 POV;
//! The ID of the joystick which generated this event.
/** This is an internal Irrlicht index; it does not map directly
* to any particular hardware joystick. */
u8 Joystick;
//! A helper function to check if a button is pressed.
bool IsButtonPressed(u32 button) const
{
if(button >= (u32)NUMBER_OF_BUTTONS)
return false;
return (ButtonStates & (1 << button)) ? true : false;
}
};
//! Any kind of log event.
struct SLogEvent
{
//! Pointer to text which has been logged
const c8* Text;
//! Log level in which the text has been logged
ELOG_LEVEL Level;
};
//! Any kind of user event.
struct SUserEvent
{
//! Some user specified data as int
s32 UserData1;
//! Another user specified data as int
s32 UserData2;
};
EEVENT_TYPE EventType;
union
{
struct SGUIEvent GUIEvent;
struct SMouseInput MouseInput;
struct SKeyInput KeyInput;
struct SJoystickEvent JoystickEvent;
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:
//! Destructor
virtual ~IEventReceiver() {}
//! Called if an event happened.
/** Please take care that you should only return 'true' when you want to _prevent_ Irrlicht
* from processing the event any further. So 'true' does mean that an event is completely done.
* Therefore your return value for all unprocessed events should be 'false'.
\return True if the event was processed.
*/
virtual bool OnEvent(const SEvent& event) = 0;
};
//! Information on a joystick, returned from @ref irr::IrrlichtDevice::activateJoysticks()
struct SJoystickInfo
{
//! The ID of the joystick
/** This is an internal Irrlicht index; it does not map directly
* to any particular hardware joystick. It corresponds to the
* irr::SJoystickEvent Joystick ID. */
u8 Joystick;
//! The name that the joystick uses to identify itself.
core::stringc Name;
//! The number of buttons that the joystick has.
u32 Buttons;
//! The number of axes that the joystick has, i.e. X, Y, Z, R, U, V.
/** Note: with a Linux device, the POV hat (if any) will use two axes. These
* will be included in this count. */
u32 Axes;
//! An indication of whether the joystick has a POV hat.
/** A Windows device will identify the presence or absence or the POV hat. A
* Linux device cannot, and will always return POV_HAT_UNKNOWN. */
enum
{
//! A hat is definitely present.
POV_HAT_PRESENT,
//! A hat is definitely not present.
POV_HAT_ABSENT,
//! The presence or absence of a hat cannot be determined.
POV_HAT_UNKNOWN
} PovHat;
}; // struct SJoystickInfo
} // end namespace irr
#endif

View File

@ -0,0 +1,132 @@
// Copyright (C) 2002-2012 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_FILE_ARCHIVE_H_INCLUDED__
#define __I_FILE_ARCHIVE_H_INCLUDED__
#include "IReadFile.h"
#include "IFileList.h"
namespace irr
{
namespace io
{
//! FileSystemType: which Filesystem should be used for e.g. browsing
enum EFileSystemType
{
FILESYSTEM_NATIVE = 0, // Native OS FileSystem
FILESYSTEM_VIRTUAL // Virtual FileSystem
};
//! Contains the different types of archives
enum E_FILE_ARCHIVE_TYPE
{
//! A PKZIP archive
EFAT_ZIP = MAKE_IRR_ID('Z','I','P', 0),
//! A gzip archive
EFAT_GZIP = MAKE_IRR_ID('g','z','i','p'),
//! A virtual directory
EFAT_FOLDER = MAKE_IRR_ID('f','l','d','r'),
//! An ID Software PAK archive
EFAT_PAK = MAKE_IRR_ID('P','A','K', 0),
//! A Nebula Device archive
EFAT_NPK = MAKE_IRR_ID('N','P','K', 0),
//! A Tape ARchive
EFAT_TAR = MAKE_IRR_ID('T','A','R', 0),
//! A wad Archive, Quake2, Halflife
EFAT_WAD = MAKE_IRR_ID('W','A','D', 0),
//! The type of this archive is unknown
EFAT_UNKNOWN = MAKE_IRR_ID('u','n','k','n')
};
//! The FileArchive manages archives and provides access to files inside them.
class IFileArchive : public virtual IReferenceCounted
{
public:
//! Opens a file based on its name
/** Creates and returns a new IReadFile for a file in the archive.
\param filename The file to open
\return Returns A pointer to the created file on success,
or 0 on failure. */
virtual IReadFile* createAndOpenFile(const path& filename) =0;
//! Opens a file based on its position in the file list.
/** Creates and returns
\param index The zero based index of the file.
\return Returns a pointer to the created file on success, or 0 on failure. */
virtual IReadFile* createAndOpenFile(u32 index) =0;
//! Returns the complete file tree
/** \return Returns the complete directory tree for the archive,
including all files and folders */
virtual const IFileList* getFileList() const =0;
//! get the archive type
virtual E_FILE_ARCHIVE_TYPE getType() const { return EFAT_UNKNOWN; }
//! An optionally used password string
/** This variable is publicly accessible from the interface in order to
avoid single access patterns to this place, and hence allow some more
obscurity.
*/
core::stringc Password;
};
//! Class which is able to create an archive from a file.
/** If you want the Irrlicht Engine be able to load archives of
currently unsupported file formats (e.g .wad), then implement
this and add your new Archive loader with
IFileSystem::addArchiveLoader() to the engine. */
class IArchiveLoader : public virtual IReferenceCounted
{
public:
//! Check if the file might be loaded by this class
/** Check based on the file extension (e.g. ".zip")
\param filename Name of file to check.
\return True if file seems to be loadable. */
virtual bool isALoadableFileFormat(const path& filename) const =0;
//! Check if the file might be loaded by this class
/** This check may look into the file.
\param file File handle to check.
\return True if file seems to be loadable. */
virtual bool isALoadableFileFormat(io::IReadFile* file) const =0;
//! Check to see if the loader can create archives of this type.
/** Check based on the archive type.
\param fileType The archive type to check.
\return True if the archile loader supports this type, false if not */
virtual bool isALoadableFileFormat(E_FILE_ARCHIVE_TYPE fileType) const =0;
//! Creates an archive from the filename
/** \param filename File to use.
\param ignoreCase Searching is performed without regarding the case
\param ignorePaths Files are searched for without checking for the directories
\return Pointer to newly created archive, or 0 upon error. */
virtual IFileArchive* createArchive(const path& filename, bool ignoreCase, bool ignorePaths) const =0;
//! Creates an archive from the file
/** \param file File handle to use.
\param ignoreCase Searching is performed without regarding the case
\param ignorePaths Files are searched for without checking for the directories
\return Pointer to newly created archive, or 0 upon error. */
virtual IFileArchive* createArchive(io::IReadFile* file, bool ignoreCase, bool ignorePaths) const =0;
};
} // end namespace io
} // end namespace irr
#endif

View File

@ -0,0 +1,94 @@
// Copyright (C) 2002-2012 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"
#include "path.h"
namespace irr
{
namespace io
{
//! Provides a list of files and folders.
/** File lists usually contain a list of all files in a given folder,
but can also contain a complete directory structure. */
class IFileList : public virtual IReferenceCounted
{
public:
//! Get the number of files in the filelist.
/** \return 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 must be less than the amount getFileCount() returns.
\return File name of the file. Returns 0, if an error occured. */
virtual const io::path& getFileName(u32 index) const = 0;
//! Gets the full name of a file in the list including the path, based on an index.
/** \param index is the zero based index of the file which name should
be returned. The index must be less than the amount getFileCount() returns.
\return File name of the file. Returns 0 if an error occured. */
virtual const io::path& getFullFileName(u32 index) const = 0;
//! Returns the size of a file in the file list, based on an index.
/** \param index is the zero based index of the file which should be returned.
The index must be less than the amount getFileCount() returns.
\return The size of the file in bytes. */
virtual u32 getFileSize(u32 index) const = 0;
//! Returns the file offset of a file in the file list, based on an index.
/** \param index is the zero based index of the file which should be returned.
The index must be less than the amount getFileCount() returns.
\return The offset of the file in bytes. */
virtual u32 getFileOffset(u32 index) const = 0;
//! Returns the ID of a file in the file list, based on an index.
/** This optional ID can be used to link the file list entry to information held
elsewhere. For example this could be an index in an IFileArchive, linking the entry
to its data offset, uncompressed size and CRC.
\param index is the zero based index of the file which should be returned.
The index must be less than the amount getFileCount() returns.
\return The ID of the file. */
virtual u32 getID(u32 index) const = 0;
//! Check if the file is a directory
/** \param index The zero based index which will be checked. The index
must be less than the amount getFileCount() returns.
\return True if the file is a directory, else false. */
virtual bool isDirectory(u32 index) const = 0;
//! Searches for a file or folder in the list
/** Searches for a file by name
\param filename The name of the file to search for.
\param isFolder True if you are searching for a directory path, false if you are searching for a file
\return Returns the index of the file in the file list, or -1 if
no matching name name was found. */
virtual s32 findFile(const io::path& filename, bool isFolder=false) const = 0;
//! Returns the base path of the file list
virtual const io::path& getPath() const = 0;
//! Add as a file or folder to the list
/** \param fullPath The file name including path, from the root of the file list.
\param isDirectory True if this is a directory rather than a file.
\param offset The file offset inside an archive
\param size The size of the file in bytes.
\param id The ID of the file in the archive which owns it */
virtual u32 addItem(const io::path& fullPath, u32 offset, u32 size, bool isDirectory, u32 id=0) = 0;
//! Sorts the file list. You should call this after adding any items to the file list
virtual void sort() = 0;
};
} // end namespace irr
} // end namespace io
#endif

View File

@ -0,0 +1,385 @@
// Copyright (C) 2002-2012 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 "IFileArchive.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:
//! Opens a file for read access.
/** \param filename: Name of file to open.
\return 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 path& 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 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 path& fileName, bool deleteMemoryWhenDropped=false) =0;
//! Creates an IReadFile interface for accessing files inside files.
/** This is useful e.g. for archives.
\param fileName: The name given to this file
\param alreadyOpenedFile: Pointer to the enclosing file
\param pos: Start of the file inside alreadyOpenedFile
\param areaSize: The length of the file
\return 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* createLimitReadFile(const path& fileName,
IReadFile* alreadyOpenedFile, long pos, long areaSize) =0;
//! Creates an IWriteFile interface for accessing memory like a file.
/** This allows you to use a pointer to memory where an IWriteFile is requested.
You are responsible for allocating enough memory.
\param memory: A pointer to the start of the file in memory (allocated by you)
\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 IWriteFile when it is dropped.
\return Pointer to the created file interface.
The returned pointer should be dropped when no longer needed.
See IReferenceCounted::drop() for more information.
*/
virtual IWriteFile* createMemoryWriteFile(void* memory, s32 len, const path& 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 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 path& filename, bool append=false) =0;
//! Adds an archive to the file system.
/** After calling this, the Irrlicht Engine will also search and open
files directly from this archive. 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 just renamed .zip files. By
default Irrlicht supports ZIP, PAK, TAR, PNK, and directories as
archives. You can provide your own archive types by implementing
IArchiveLoader and passing an instance to addArchiveLoader.
Irrlicht supports AES-encrypted zip files, and the advanced compression
techniques lzma and bzip2.
\param filename: Filename of the 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.
\param archiveType: If no specific E_FILE_ARCHIVE_TYPE is selected then
the type of archive will depend on the extension of the file name. If
you use a different extension then you can use this parameter to force
a specific type of archive.
\param password An optional password, which is used in case of encrypted archives.
\param retArchive A pointer that will be set to the archive that is added.
\return True if the archive was added successfully, false if not. */
virtual bool addFileArchive(const path& filename, bool ignoreCase=true,
bool ignorePaths=true,
E_FILE_ARCHIVE_TYPE archiveType=EFAT_UNKNOWN,
const core::stringc& password="",
IFileArchive** retArchive=0) =0;
//! Adds an archive to the file system.
/** After calling this, the Irrlicht Engine will also search and open
files directly from this archive. 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 just renamed .zip files. By
default Irrlicht supports ZIP, PAK, TAR, PNK, and directories as
archives. You can provide your own archive types by implementing
IArchiveLoader and passing an instance to addArchiveLoader.
Irrlicht supports AES-encrypted zip files, and the advanced compression
techniques lzma and bzip2.
If you want to add a directory as an archive, prefix its name with a
slash in order to let Irrlicht recognize it as a folder mount (mypath/).
Using this technique one can build up a search order, because archives
are read first, and can be used more easily with relative filenames.
\param file: 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.
\param archiveType: If no specific E_FILE_ARCHIVE_TYPE is selected then
the type of archive will depend on the extension of the file name. If
you use a different extension then you can use this parameter to force
a specific type of archive.
\param password An optional password, which is used in case of encrypted archives.
\param retArchive A pointer that will be set to the archive that is added.
\return True if the archive was added successfully, false if not. */
virtual bool addFileArchive(IReadFile* file, bool ignoreCase=true,
bool ignorePaths=true,
E_FILE_ARCHIVE_TYPE archiveType=EFAT_UNKNOWN,
const core::stringc& password="",
IFileArchive** retArchive=0) =0;
//! Adds an archive to the file system.
/** \param archive: The archive to add to the file system.
\return True if the archive was added successfully, false if not. */
virtual bool addFileArchive(IFileArchive* archive) =0;
//! Get the number of archives currently attached to the file system
virtual u32 getFileArchiveCount() const =0;
//! Removes an archive from the file system.
/** This will close the archive and free any file handles, but will not
close resources which have already been loaded and are now cached, for
example textures and meshes.
\param index: The index of the archive to remove
\return True on success, false on failure */
virtual bool removeFileArchive(u32 index) =0;
//! Removes an archive from the file system.
/** This will close the archive and free any file handles, but will not
close resources which have already been loaded and are now cached, for
example textures and meshes. Note that a relative filename might be
interpreted differently on each call, depending on the current working
directory. In case you want to remove an archive that was added using
a relative path name, you have to change to the same working directory
again. This means, that the filename given on creation is not an
identifier for the archive, but just a usual filename that is used for
locating the archive to work with.
\param filename The archive pointed to by the name will be removed
\return True on success, false on failure */
virtual bool removeFileArchive(const path& filename) =0;
//! Removes an archive from the file system.
/** This will close the archive and free any file handles, but will not
close resources which have already been loaded and are now cached, for
example textures and meshes.
\param archive The archive to remove.
\return True on success, false on failure */
virtual bool removeFileArchive(const IFileArchive* archive) =0;
//! Changes the search order of attached archives.
/**
\param sourceIndex: The index of the archive to change
\param relative: The relative change in position, archives with a lower index are searched first */
virtual bool moveFileArchive(u32 sourceIndex, s32 relative) =0;
//! Get the archive at a given index.
virtual IFileArchive* getFileArchive(u32 index) =0;
//! Adds an external archive loader to the engine.
/** Use this function to add support for new archive types to the
engine, for example proprietary or encrypted file storage. */
virtual void addArchiveLoader(IArchiveLoader* loader) =0;
//! Gets the number of archive loaders currently added
virtual u32 getArchiveLoaderCount() const = 0;
//! Retrieve the given archive loader
/** \param index The index of the loader to retrieve. This parameter is an 0-based
array index.
\return A pointer to the specified loader, 0 if the index is incorrect. */
virtual IArchiveLoader* getArchiveLoader(u32 index) const = 0;
//! Adds a zip archive to the file system.
/** \deprecated This function is provided for compatibility
with older versions of Irrlicht and may be removed in Irrlicht 1.9,
you should use addFileArchive instead.
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 no 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 True if the archive was added successfully, false if not. */
_IRR_DEPRECATED_ virtual bool addZipFileArchive(const c8* filename, bool ignoreCase=true, bool ignorePaths=true)
{
return addFileArchive(filename, ignoreCase, ignorePaths, EFAT_ZIP);
}
//! Adds an unzipped archive (or basedirectory with subdirectories..) to the file system.
/** \deprecated This function is provided for compatibility
with older versions of Irrlicht and may be removed in Irrlicht 1.9,
you should use addFileArchive instead.
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 True if the archive was added successful, false if not. */
_IRR_DEPRECATED_ virtual bool addFolderFileArchive(const c8* filename, bool ignoreCase=true, bool ignorePaths=true)
{
return addFileArchive(filename, ignoreCase, ignorePaths, EFAT_FOLDER);
}
//! Adds a pak archive to the file system.
/** \deprecated This function is provided for compatibility
with older versions of Irrlicht and may be removed in Irrlicht 1.9,
you should use addFileArchive instead.
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 True if the archive was added successful, false if not. */
_IRR_DEPRECATED_ virtual bool addPakFileArchive(const c8* filename, bool ignoreCase=true, bool ignorePaths=true)
{
return addFileArchive(filename, ignoreCase, ignorePaths, EFAT_PAK);
}
//! Get the current working directory.
/** \return Current working directory as a string. */
virtual const path& 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 True if successful, otherwise false. */
virtual bool changeWorkingDirectoryTo(const path& newDirectory) =0;
//! Converts a relative path to an absolute (unique) path, resolving symbolic links if required
/** \param filename Possibly relative file or directory name to query.
\result Absolute filename which points to the same file. */
virtual path getAbsolutePath(const path& filename) const =0;
//! Get the directory a file is located in.
/** \param filename: The file to get the directory from.
\return String containing the directory of the file. */
virtual path getFileDir(const path& filename) const =0;
//! Get the base part of a filename, i.e. the name without the directory part.
/** If no directory is prefixed, the full name is returned.
\param filename: The file to get the basename from
\param keepExtension True if filename with extension is returned otherwise everything
after the final '.' is removed as well. */
virtual path getFileBasename(const path& filename, bool keepExtension=true) const =0;
//! flatten a path and file name for example: "/you/me/../." becomes "/you"
virtual path& flattenFilename(path& directory, const path& root="/") const =0;
//! Get the relative filename, relative to the given directory
virtual path getRelativeFilename(const path& filename, const path& directory) 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() =0;
//! Creates an empty filelist
/** \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* createEmptyFileList(const io::path& path, bool ignoreCase, bool ignorePaths) =0;
//! Set the active type of file system.
virtual EFileSystemType setFileListSystem(EFileSystemType listType) =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 True if file exists, and false if it does not exist or an error occured. */
virtual bool existFile(const path& 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 path& 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 path& 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 path& 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 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,474 @@
// Copyright (C) 2002-2012 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 "EShaderTypes.h"
#include "EMaterialTypes.h"
#include "EPrimitiveTypes.h"
#include "path.h"
namespace irr
{
namespace io
{
class IReadFile;
} // end namespace io
namespace video
{
class IVideoDriver;
class IShaderConstantSetCallBack;
//! Enumeration for different types of shading languages
enum E_GPU_SHADING_LANGUAGE
{
//! The default language, so HLSL for Direct3D and GLSL for OpenGL.
EGSL_DEFAULT = 0,
//! Cg shading language.*/
EGSL_CG
};
//! Interface making it possible to create and use programs running on the GPU.
class IGPUProgrammingServices
{
public:
//! Destructor
virtual ~IGPUProgrammingServices() {}
//! Adds a new high-level shading material renderer to the VideoDriver.
/** Currently only HLSL/D3D9 and GLSL/OpenGL are 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 (p.e. "main")
\param vsCompileTarget Vertex shader version 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
pixelShaderProgram (p.e. "main")
\param psCompileTarget Pixel shader version the high level shader
shall be compiled to.
\param geometryShaderProgram String containing the source of the
geometry shader program. This can be 0 if no geometry shader shall be
used.
\param geometryShaderEntryPointName Entry name of the function of the
geometryShaderProgram (p.e. "main")
\param gsCompileTarget Geometry shader version the high level shader
shall be compiled to.
\param inType Type of vertices passed to geometry shader
\param outType Type of vertices created by geometry shader
\param verticesOut Maximal number of vertices created by geometry
shader. If 0, maximal number supported is assumed.
\param callback Pointer to an implementation of
IShaderConstantSetCallBack in which you can set the needed vertex,
pixel, and geometry 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.
\param shaderLang a type of shading language used in current shader.
\return 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 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,
E_VERTEX_SHADER_TYPE vsCompileTarget,
const c8* pixelShaderProgram,
const c8* pixelShaderEntryPointName,
E_PIXEL_SHADER_TYPE psCompileTarget,
const c8* geometryShaderProgram,
const c8* geometryShaderEntryPointName = "main",
E_GEOMETRY_SHADER_TYPE gsCompileTarget = EGST_GS_4_0,
scene::E_PRIMITIVE_TYPE inType = scene::EPT_TRIANGLES,
scene::E_PRIMITIVE_TYPE outType = scene::EPT_TRIANGLE_STRIP,
u32 verticesOut = 0,
IShaderConstantSetCallBack* callback = 0,
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
s32 userData = 0,
E_GPU_SHADING_LANGUAGE shadingLang = EGSL_DEFAULT) = 0;
//! convenience function for use without geometry shaders
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,
E_GPU_SHADING_LANGUAGE shadingLang=EGSL_DEFAULT)
{
return addHighLevelShaderMaterial(
vertexShaderProgram, vertexShaderEntryPointName,
vsCompileTarget, pixelShaderProgram,
pixelShaderEntryPointName, psCompileTarget,
0, "main", EGST_GS_4_0,
scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0,
callback, baseMaterial, userData, shadingLang);
}
//! convenience function for use with many defaults, without geometry shader
/** All shader names are set to "main" and compile targets are shader
type 1.1.
*/
s32 addHighLevelShaderMaterial(
const c8* vertexShaderProgram,
const c8* pixelShaderProgram=0,
IShaderConstantSetCallBack* callback=0,
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
s32 userData=0)
{
return addHighLevelShaderMaterial(
vertexShaderProgram, "main",
EVST_VS_1_1, pixelShaderProgram,
"main", EPST_PS_1_1,
0, "main", EGST_GS_4_0,
scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0,
callback, baseMaterial, userData);
}
//! convenience function for use with many defaults, with geometry shader
/** All shader names are set to "main" and compile targets are shader
type 1.1 and geometry shader 4.0.
*/
s32 addHighLevelShaderMaterial(
const c8* vertexShaderProgram,
const c8* pixelShaderProgram = 0,
const c8* geometryShaderProgram = 0,
scene::E_PRIMITIVE_TYPE inType = scene::EPT_TRIANGLES,
scene::E_PRIMITIVE_TYPE outType = scene::EPT_TRIANGLE_STRIP,
u32 verticesOut = 0,
IShaderConstantSetCallBack* callback = 0,
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
s32 userData = 0 )
{
return addHighLevelShaderMaterial(
vertexShaderProgram, "main",
EVST_VS_1_1, pixelShaderProgram,
"main", EPST_PS_1_1,
geometryShaderProgram, "main", EGST_GS_4_0,
inType, outType, verticesOut,
callback, baseMaterial, userData);
}
//! Like IGPUProgrammingServices::addShaderMaterial(), but loads from files.
/** \param vertexShaderProgramFileName Text file containing the source
of the vertex shader program. Set to empty string if no vertex shader
shall be created.
\param vertexShaderEntryPointName Name of the entry function of the
vertexShaderProgram (p.e. "main")
\param vsCompileTarget Vertex shader version the high level shader
shall be compiled to.
\param pixelShaderProgramFileName Text file containing the source of
the pixel shader program. Set to empty string if no pixel shader shall
be created.
\param pixelShaderEntryPointName Entry name of the function of the
pixelShaderProgram (p.e. "main")
\param psCompileTarget Pixel shader version the high level shader
shall be compiled to.
\param geometryShaderProgramFileName Name of the source of
the geometry shader program. Set to empty string if no geometry shader
shall be created.
\param geometryShaderEntryPointName Entry name of the function of the
geometryShaderProgram (p.e. "main")
\param gsCompileTarget Geometry shader version the high level shader
shall be compiled to.
\param inType Type of vertices passed to geometry shader
\param outType Type of vertices created by geometry shader
\param verticesOut Maximal number of vertices created by geometry
shader. If 0, maximal number supported is assumed.
\param callback Pointer to an implementation of
IShaderConstantSetCallBack in which you can set the needed vertex,
pixel, and geometry 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.
\param shaderLang a type of shading language used in current shader.
\return 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 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 io::path& vertexShaderProgramFileName,
const c8* vertexShaderEntryPointName,
E_VERTEX_SHADER_TYPE vsCompileTarget,
const io::path& pixelShaderProgramFileName,
const c8* pixelShaderEntryPointName,
E_PIXEL_SHADER_TYPE psCompileTarget,
const io::path& geometryShaderProgramFileName,
const c8* geometryShaderEntryPointName = "main",
E_GEOMETRY_SHADER_TYPE gsCompileTarget = EGST_GS_4_0,
scene::E_PRIMITIVE_TYPE inType = scene::EPT_TRIANGLES,
scene::E_PRIMITIVE_TYPE outType = scene::EPT_TRIANGLE_STRIP,
u32 verticesOut = 0,
IShaderConstantSetCallBack* callback = 0,
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
s32 userData = 0,
E_GPU_SHADING_LANGUAGE shadingLang = EGSL_DEFAULT) = 0;
//! convenience function for use without geometry shaders
s32 addHighLevelShaderMaterialFromFiles(
const io::path& vertexShaderProgramFileName,
const c8* vertexShaderEntryPointName = "main",
E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1,
const io::path& pixelShaderProgramFileName = "",
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,
E_GPU_SHADING_LANGUAGE shadingLang = EGSL_DEFAULT)
{
return addHighLevelShaderMaterialFromFiles(
vertexShaderProgramFileName, vertexShaderEntryPointName,
vsCompileTarget, pixelShaderProgramFileName,
pixelShaderEntryPointName, psCompileTarget,
"", "main", EGST_GS_4_0,
scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0,
callback, baseMaterial, userData, shadingLang);
}
//! convenience function for use with many defaults, without geometry shader
/** All shader names are set to "main" and compile targets are shader
type 1.1.
*/
s32 addHighLevelShaderMaterialFromFiles(
const io::path& vertexShaderProgramFileName,
const io::path& pixelShaderProgramFileName = "",
IShaderConstantSetCallBack* callback = 0,
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
s32 userData = 0 )
{
return addHighLevelShaderMaterialFromFiles(
vertexShaderProgramFileName, "main",
EVST_VS_1_1, pixelShaderProgramFileName,
"main", EPST_PS_1_1,
"", "main", EGST_GS_4_0,
scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0,
callback, baseMaterial, userData);
}
//! convenience function for use with many defaults, with geometry shader
/** All shader names are set to "main" and compile targets are shader
type 1.1 and geometry shader 4.0.
*/
s32 addHighLevelShaderMaterialFromFiles(
const io::path& vertexShaderProgramFileName,
const io::path& pixelShaderProgramFileName = "",
const io::path& geometryShaderProgramFileName = "",
scene::E_PRIMITIVE_TYPE inType = scene::EPT_TRIANGLES,
scene::E_PRIMITIVE_TYPE outType = scene::EPT_TRIANGLE_STRIP,
u32 verticesOut = 0,
IShaderConstantSetCallBack* callback = 0,
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
s32 userData = 0 )
{
return addHighLevelShaderMaterialFromFiles(
vertexShaderProgramFileName, "main",
EVST_VS_1_1, pixelShaderProgramFileName,
"main", EPST_PS_1_1,
geometryShaderProgramFileName, "main", EGST_GS_4_0,
inType, outType, verticesOut,
callback, baseMaterial, userData);
}
//! Like IGPUProgrammingServices::addShaderMaterial(), but loads from files.
/** \param vertexShaderProgram Text file handle containing the source
of the vertex shader program. Set to 0 if no vertex shader shall be
created.
\param vertexShaderEntryPointName Name of the entry function of the
vertexShaderProgram
\param vsCompileTarget Vertex shader version the high level shader
shall be compiled to.
\param pixelShaderProgram Text file handle containing the source of
the pixel shader program. Set to 0 if no pixel shader shall be created.
\param pixelShaderEntryPointName Entry name of the function of the
pixelShaderProgram (p.e. "main")
\param psCompileTarget Pixel shader version the high level shader
shall be compiled to.
\param geometryShaderProgram Text file handle containing the source of
the geometry shader program. Set to 0 if no geometry shader shall be
created.
\param geometryShaderEntryPointName Entry name of the function of the
geometryShaderProgram (p.e. "main")
\param gsCompileTarget Geometry shader version the high level shader
shall be compiled to.
\param inType Type of vertices passed to geometry shader
\param outType Type of vertices created by geometry shader
\param verticesOut Maximal number of vertices created by geometry
shader. If 0, maximal number supported is assumed.
\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.
\param shaderLang a type of shading language used in current shader.
\return 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 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,
E_VERTEX_SHADER_TYPE vsCompileTarget,
io::IReadFile* pixelShaderProgram,
const c8* pixelShaderEntryPointName,
E_PIXEL_SHADER_TYPE psCompileTarget,
io::IReadFile* geometryShaderProgram,
const c8* geometryShaderEntryPointName = "main",
E_GEOMETRY_SHADER_TYPE gsCompileTarget = EGST_GS_4_0,
scene::E_PRIMITIVE_TYPE inType = scene::EPT_TRIANGLES,
scene::E_PRIMITIVE_TYPE outType = scene::EPT_TRIANGLE_STRIP,
u32 verticesOut = 0,
IShaderConstantSetCallBack* callback = 0,
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
s32 userData = 0,
E_GPU_SHADING_LANGUAGE shadingLang = EGSL_DEFAULT) = 0;
//! convenience function for use without geometry shaders
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,
E_GPU_SHADING_LANGUAGE shadingLang = EGSL_DEFAULT)
{
return addHighLevelShaderMaterialFromFiles(
vertexShaderProgram, vertexShaderEntryPointName,
vsCompileTarget, pixelShaderProgram,
pixelShaderEntryPointName, psCompileTarget,
0, "main", EGST_GS_4_0,
scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0,
callback, baseMaterial, userData, shadingLang);
}
//! Adds a new ASM shader material renderer to the VideoDriver
/** Note that it is a good idea to call IVideoDriver::queryFeature() in
advance 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 loads 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 loads 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 io::path& vertexShaderProgramFileName,
const io::path& 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,151 @@
// Copyright (C) 2002-2012 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.
/** \par This element can create the following events of type EGUI_EVENT_TYPE:
\li EGET_BUTTON_CLICKED
*/
class IGUIButton : public IGUIElement
{
public:
//! constructor
IGUIButton(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
: IGUIElement(EGUIET_BUTTON, environment, parent, id, rectangle) {}
//! 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;
//! Get the font which is used right now for drawing
/** Currently this is the override font when one is set and the
font of the active skin otherwise */
virtual IGUIFont* getActiveFont() const = 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) = 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) = 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) = 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=true) = 0;
//! Sets the pressed state of the button if this is a pushbutton
virtual void setPressed(bool pressed=true) = 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=true) = 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=true) = 0;
//! Returns if the border and button face are being drawn using the skin
virtual bool isDrawingBorder() const = 0;
//! Sets if the button should scale the button images to fit
virtual void setScaleImage(bool scaleImage=true) = 0;
//! Checks whether the button scales the used images
virtual bool isScalingImage() const = 0;
};
} // end namespace gui
} // end namespace irr
#endif

View File

@ -0,0 +1,38 @@
// Copyright (C) 2002-2012 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.
/** \par This element can create the following events of type EGUI_EVENT_TYPE:
\li EGET_CHECKBOX_CHANGED
*/
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) {}
//! 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,30 @@
// Copyright (C) 2002-2012 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 color 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) {}
};
} // end namespace gui
} // end namespace irr
#endif

View File

@ -0,0 +1,74 @@
// Copyright (C) 2002-2012 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
/** \par This element can create the following events of type EGUI_EVENT_TYPE:
\li EGET_COMBO_BOX_CHANGED
*/
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) {}
//! 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;
//! Returns item data of an item. the idx may be a value from 0 to itemCount-1
virtual u32 getItemData(u32 idx) const = 0;
//! Returns index based on item data
virtual s32 getIndexForItemData(u32 data ) const = 0;
//! Adds an item and returns the index of it
virtual u32 addItem(const wchar_t* text, u32 data = 0) = 0;
//! Removes an item from the combo box.
/** Warning. This will change the index of all following items */
virtual void removeItem(u32 idx) = 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 idx) = 0;
//! Sets text justification of the text area
/** \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;
//! Set the maximal number of rows for the selection listbox
virtual void setMaxSelectionRows(u32 max) = 0;
//! Get the maximimal number of rows for the selection listbox
virtual u32 getMaxSelectionRows() const = 0;
};
} // end namespace gui
} // end namespace irr
#endif

View File

@ -0,0 +1,162 @@
// Copyright (C) 2002-2012 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
{
//! Close behavior.
//! Default is ECMC_REMOVE
enum ECONTEXT_MENU_CLOSE
{
//! do nothing - menu stays open
ECMC_IGNORE = 0,
//! remove the gui element
ECMC_REMOVE = 1,
//! call setVisible(false)
ECMC_HIDE = 2
// note to implementors - this is planned as bitset, so continue with 4 if you need to add further flags.
};
//! GUI Context menu interface.
/** \par This element can create the following events of type EGUI_EVENT_TYPE:
\li EGET_ELEMENT_CLOSED
\li EGET_MENU_ITEM_SELECTED
*/
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) {}
//! set behavior when menus are closed
virtual void setCloseHandling(ECONTEXT_MENU_CLOSE onClose) = 0;
//! get current behavior when the menu will be closed
virtual ECONTEXT_MENU_CLOSE getCloseHandling() const = 0;
//! 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 access this submenu via getSubMenu().
\param checked: Specifies if the menu item should be initially checked.
\param autoChecking: Specifies if the item should be checked by clicking
\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, bool autoChecking=false) = 0;
//! Insert a menu item at specified position.
/** \param idx: Position to insert the new element,
should be smaller than itemcount otherwise the item is added to the end.
\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 access this submenu via getSubMenu().
\param checked: Specifies if the menu item should be initially checked.
\param autoChecking: Specifies if the item should be checked by clicking
\return Returns the index of the new item */
virtual u32 insertItem(u32 idx, const wchar_t* text, s32 commandId=-1, bool enabled=true,
bool hasSubMenu=false, bool checked=false, bool autoChecking=false) = 0;
//! Find an item by it's CommandID
/**
\param commandId: We are looking for the first item which has this commandID
\param idxStartSearch: Start searching from this index.
\return Returns the index of the item when found or otherwise -1. */
virtual s32 findItemWithCommandId(s32 commandId, u32 idxStartSearch=0) const = 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;
//! should the element change the checked status on clicking
virtual void setItemAutoChecking(u32 idx, bool autoChecking) = 0;
//! does the element change the checked status on clicking
virtual bool getItemAutoChecking(u32 idx) const = 0;
//! When an eventparent is set it receives events instead of the usual parent element
virtual void setEventParent(IGUIElement *parent) = 0;
};
} // end namespace gui
} // end namespace irr
#endif

View File

@ -0,0 +1,135 @@
// Copyright (C) 2002-2012 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.
/** \par This element can create the following events of type EGUI_EVENT_TYPE:
\li EGET_EDITBOX_ENTER
\li EGET_EDITBOX_CHANGED
\li EGET_EDITBOX_MARKING_CHANGED
*/
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) {}
//! 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() const = 0;
//! Get the font which is used right now for drawing
/** Currently this is the override font when one is set and the
font of the active skin otherwise */
virtual IGUIFont* getActiveFont() const = 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;
//! Gets the override color
virtual video::SColor getOverrideColor() const = 0;
//! Sets if the text should use the override 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;
//! Checks if an override color is enabled
/** \return true if the override color is enabled, false otherwise */
virtual bool isOverrideColorEnabled(void) const = 0;
//! Sets whether to draw the background
virtual void setDrawBackground(bool draw) = 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_LOWERRIGHT for right justified, or EGUIA_CENTER for centered text.
\param vertical: EGUIA_UPPERLEFT to align with top edge,
EGUIA_LOWERRIGHT 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 multi-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 The size in pixels of the text */
virtual core::dimension2du 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

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,66 @@
// Copyright (C) 2002-2012 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 dynamically 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:
//! 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 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 Pointer to the new element or null if not successful. */
virtual IGUIElement* addGUIElement(const c8* typeName, IGUIElement* parent=0) = 0;
//! Get amount of GUI element types this factory is able to create
virtual s32 getCreatableGUIElementTypeCount() const = 0;
//! Get 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;
//! Get 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 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,620 @@
// Copyright (C) 2002-2012 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"
#include "path.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 IGUITreeView;
class IGUIImageList;
class IGUIFileOpenDialog;
class IGUIColorSelectDialog;
class IGUIInOutFader;
class IGUIStaticText;
class IGUIEditBox;
class IGUISpinBox;
class IGUITabControl;
class IGUITab;
class IGUITable;
class IGUIContextMenu;
class IGUIComboBox;
class IGUIToolBar;
class IGUIButton;
class IGUIWindow;
class IGUIElementFactory;
//! GUI Environment. Used as factory and manager of all other GUI elements.
/** \par This element can create the following events of type EGUI_EVENT_TYPE (which are passed on to focused sub-elements):
\li EGET_ELEMENT_FOCUS_LOST
\li EGET_ELEMENT_FOCUSED
\li EGET_ELEMENT_LEFT
\li EGET_ELEMENT_HOVERED
*/
class IGUIEnvironment : public virtual IReferenceCounted
{
public:
//! Draws all gui elements by traversing the GUI environment starting at the root node.
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.
\param element Pointer to the element which shall get the focus.
\return True on success, false on failure */
virtual bool setFocus(IGUIElement* element) = 0;
//! Returns the element which holds the focus.
/** \return Pointer to the element with focus. */
virtual IGUIElement* getFocus() const = 0;
//! Returns the element which was last under the mouse cursor
/** NOTE: This information is updated _after_ the user-eventreceiver
received it's mouse-events. To find the hovered element while catching
mouse events you have to use instead:
IGUIEnvironment::getRootGUIElement()->getElementFromPoint(mousePos);
\return Pointer to the element under the mouse. */
virtual IGUIElement* getHovered() 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.
\param element Pointer to the element which shall lose the focus.
\return True on success, false on failure */
virtual bool removeFocus(IGUIElement* element) = 0;
//! Returns whether the element has focus
/** \param element Pointer to the element which is tested.
\return True if the element has focus, else false. */
virtual bool hasFocus(IGUIElement* element) const = 0;
//! Returns the current video driver.
/** \return Pointer to the video driver. */
virtual video::IVideoDriver* getVideoDriver() const = 0;
//! Returns the file system.
/** \return Pointer to the file system. */
virtual io::IFileSystem* getFileSystem() const = 0;
//! returns a pointer to the OS operator
/** \return 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 engine internally.
\param event The event to post.
\return True if succeeded, else false. */
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 engine internally.
\param evr Pointer to the new receiver. */
virtual void setUserEventReceiver(IEventReceiver* evr) = 0;
//! Returns pointer to the current gui skin.
/** \return Pointer to the 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
\param skin New skin to use.
*/
virtual void setSkin(IGUISkin* skin) = 0;
//! Creates a new GUI Skin based on a template.
/** Use setSkin() to set the created skin.
\param type The type of the new skin.
\return 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;
//! Creates the image list from the given texture.
/** \param texture Texture to split into images
\param imageSize Dimension of each image
\param useAlphaChannel Flag whether alpha channel of the texture should be honored.
\return Pointer to the font. Returns 0 if the font could not be loaded.
This pointer should not be dropped. See IReferenceCounted::drop() for
more information. */
virtual IGUIImageList* createImageList( video::ITexture* texture,
core::dimension2d<s32> imageSize,
bool useAlphaChannel ) = 0;
//! Returns pointer to the font with the specified filename.
/** Loads the font if it was not loaded before.
\param filename Filename of the Font.
\return Pointer to the font. Returns 0 if the font could not be loaded.
This pointer should not be dropped. See IReferenceCounted::drop() for
more information. */
virtual IGUIFont* getFont(const io::path& filename) = 0;
//! Adds an externally loaded font to the font list.
/** This method allows to attach an already loaded font to the list of
existing fonts. The font is grabbed if non-null and adding was successful.
\param name Name the font should be stored as.
\param font Pointer to font to add.
\return Pointer to the font stored. This can differ from given parameter if the name previously existed. */
virtual IGUIFont* addFont(const io::path& name, IGUIFont* font) = 0;
//! remove loaded font
virtual void removeFont(IGUIFont* font) = 0;
//! Returns the default built-in font.
/** \return Pointer to the default built-in font.
This pointer should not be dropped. See IReferenceCounted::drop() for
more information. */
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.
\param filename Filename of the sprite bank's origin.
\return Pointer to the sprite bank. Returns 0 if it could not be loaded.
This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
virtual IGUISpriteBank* getSpriteBank(const io::path& filename) = 0;
//! Adds an empty sprite bank to the manager
/** \param name Name of the new sprite bank.
\return Pointer to the sprite bank.
This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
virtual IGUISpriteBank* addEmptySpriteBank(const io::path& name) = 0;
//! Returns the root gui element.
/** This is the first gui element, the (direct or indirect) parent of all
other gui elements. It is a valid IGUIElement, with dimensions the same
size as the screen.
\return Pointer to the root element of the GUI. The returned pointer
should not be dropped. See IReferenceCounted::drop() for more
information. */
virtual IGUIElement* getRootGUIElement() = 0;
//! Adds a button element.
/** \param rectangle Rectangle specifying the borders of the button.
\param parent Parent gui element of the button.
\param id Id with which the gui element can be identified.
\param text Text displayed on the button.
\param tooltiptext Text displayed in the tooltip.
\return Pointer to the created button. Returns 0 if an error occurred.
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 rectangle Rectangle specifying the borders of the window.
\param modal Defines if the dialog is modal. This means, that all other
gui elements which were created before the window cannot be used until
it is removed.
\param text Text displayed as the window title.
\param parent Parent gui element of the window.
\param id Id with which the gui element can be identified.
\return Pointer to the created window. Returns 0 if an error occurred.
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 receive
input until its last child is removed, it then deletes itself.
\param parent Parent gui element of the modal.
\return Pointer to the created modal. Returns 0 if an error occurred.
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.
\param image Optional texture which will be displayed beside the text as an image
\return Pointer to the created message box. Returns 0 if an error
occurred. 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, video::ITexture* image=0) = 0;
//! Adds a scrollbar.
/** \param horizontal Specifies if the scroll bar is drawn horizontal
or vertical.
\param rectangle Rectangle specifying the borders of the scrollbar.
\param parent Parent gui element of the scroll bar.
\param id Id to identify the gui element.
\return Pointer to the created scrollbar. Returns 0 if an error
occurred. 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.
\param parent Parent gui element of the image.
\param id Id to identify the gui element.
\param text Title text of the image.
\return Pointer to the created image element. Returns 0 if an error
occurred. 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.
\param rectangle Rectangle specifying the borders of the image.
\param parent Parent gui element of the image.
\param id Id to identify the gui element.
\param text Title text of the image.
\param useAlphaChannel Sets if the image should use the alpha channel
of the texture to draw itself.
\return Pointer to the created image element. Returns 0 if an error
occurred. 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, bool useAlphaChannel=true) = 0;
//! Adds a checkbox element.
/** \param checked Define the initial state of the check box.
\param rectangle Rectangle specifying the borders of the check box.
\param parent Parent gui element of the check box.
\param id Id to identify the gui element.
\param text Title text of the check box.
\return Pointer to the created check box. Returns 0 if an error
occurred. 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.
/** \param rectangle Rectangle specifying the borders of the list box.
\param parent Parent gui element of the list box.
\param id Id to identify the gui element.
\param drawBackground Flag whether the background should be drawn.
\return Pointer to the created list box. Returns 0 if an error occurred.
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 a tree view element.
/** \param rectangle Position and dimension of list box.
\param parent Parent gui element of the list box.
\param id Id to identify the gui element.
\param drawBackground Flag whether the background should be drawn.
\param scrollBarVertical Flag whether a vertical scrollbar should be used
\param scrollBarHorizontal Flag whether a horizontal scrollbar should be used
\return Pointer to the created list box. Returns 0 if an error occurred.
This pointer should not be dropped. See IReferenceCounted::drop() for
more information. */
virtual IGUITreeView* addTreeView(const core::rect<s32>& rectangle,
IGUIElement* parent=0, s32 id=-1, bool drawBackground=false,
bool scrollBarVertical = true, bool scrollBarHorizontal = false) = 0;
//! Adds a mesh viewer. Not 100% implemented yet.
/** \param rectangle Rectangle specifying the borders of the mesh viewer.
\param parent Parent gui element of the mesh viewer.
\param id Id to identify the gui element.
\param text Title text of the mesh viewer.
\return Pointer to the created mesh viewer. Returns 0 if an error
occurred. 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 title Text to be displayed as the title of the 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.
\param parent Parent gui element of the dialog.
\param id Id to identify the gui element.
\param restoreCWD If set to true, the current workingn directory will be
restored after the dialog is closed in some way. Otherwise the working
directory will be the one that the file dialog was last showing.
\param startDir Optional path for which the file dialog will be opened.
\return Pointer to the created file open dialog. Returns 0 if an error
occurred. 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,
bool restoreCWD=false, io::path::char_type* startDir=0) = 0;
//! Adds a color select dialog.
/** \param title The title of the dialog.
\param modal Defines if the dialog is modal. This means, that all other
gui elements which were created before the dialog cannot be used
until it is removed.
\param parent The parent of the dialog.
\param id The ID of the dialog.
\return Pointer to the created file open dialog. Returns 0 if an error
occurred. 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.
/** \param text Text to be displayed. Can be altered after creation by SetText().
\param rectangle Rectangle specifying the borders of the static text
\param border Set to true if the static text should have a 3d border.
\param wordWrap Enable if the text should wrap into multiple lines.
\param parent Parent item of the element, e.g. a window.
\param id The ID of the element.
\param fillBackground Enable if the background shall be filled.
Defaults to false.
\return Pointer to the created static text. Returns 0 if an error
occurred. 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, ctrl+C, shift+Left, shift+Right, Home, End, and so on.
\param text Text to be displayed. Can be altered after creation
by setText().
\param rectangle Rectangle specifying the borders of the edit box.
\param border Set to true if the edit box should have a 3d border.
\param parent Parent item of the element, e.g. a window.
Set it to 0 to place the edit box directly in the environment.
\param id The ID of the element.
\return Pointer to the created edit box. Returns 0 if an error occurred.
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 Text to be displayed. Can be altered after creation by setText().
\param rectangle Rectangle specifying the borders of the spin box.
\param border Set to true if the spin box should have a 3d border.
\param parent Parent item of the element, e.g. a window.
Set it to 0 to place the spin box directly in the environment.
\param id The ID of the element.
\return Pointer to the created spin box. Returns 0 if an error occurred.
This pointer should not be dropped. See IReferenceCounted::drop() for
more information. */
virtual IGUISpinBox* addSpinBox(const wchar_t* text, const core::rect<s32>& rectangle,
bool border=true,IGUIElement* parent=0, s32 id=-1) = 0;
//! Adds an element for fading in or out.
/** \param rectangle Rectangle specifying the borders of the fader.
If the pointer is NULL, the whole screen is used.
\param parent Parent item of the element, e.g. a window.
\param id An identifier for the fader.
\return Pointer to the created in-out-fader. Returns 0 if an error
occurred. 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 Rectangle specifying the borders of the tab control.
\param parent 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.
\param border Specifies if a flat 3d border should be drawn. This is
usually not necessary unless you place the control directly into
the environment without a window as parent.
\param id An identifier for the tab control.
\return Pointer to the created tab control element. Returns 0 if an
error occurred. 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 Rectangle specifying the borders of the tab.
\param parent Parent item of the element, e.g. a window.
Set it to 0 to place the tab directly in the environment.
\param id An identifier for the tab.
\return Pointer to the created tab. Returns 0 if an
error occurred. This pointer should not be dropped. See
IReferenceCounted::drop() for more information. */
virtual IGUITab* addTab(const core::rect<s32>& rectangle,
IGUIElement* parent=0, s32 id=-1) = 0;
//! Adds a context menu to the environment.
/** \param rectangle Rectangle specifying the borders of the menu.
Note that the menu is resizing itself based on what items you add.
\param parent Parent item of the element, e.g. a window.
Set it to 0 to place the menu directly in the environment.
\param id An identifier for the menu.
\return Pointer to the created context menu. Returns 0 if an
error occurred. This pointer should not be dropped. See
IReferenceCounted::drop() for more information. */
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 Parent item of the element, e.g. a window.
Set it to 0 to place the menu directly in the environment.
\param id An identifier for the menu.
\return Pointer to the created menu. Returns 0 if an
error occurred. This pointer should not be dropped. See
IReferenceCounted::drop() for more information. */
virtual IGUIContextMenu* addMenu(IGUIElement* parent=0, s32 id=-1) = 0;
//! Adds a toolbar to the environment.
/** It is like a menu that is always placed on top of its parent, and
contains buttons.
\param parent Parent item of the element, e.g. a window.
Set it to 0 to place the tool bar directly in the environment.
\param id An identifier for the tool bar.
\return Pointer to the created tool bar. Returns 0 if an
error occurred. This pointer should not be dropped. See
IReferenceCounted::drop() for more information. */
virtual IGUIToolBar* addToolBar(IGUIElement* parent=0, s32 id=-1) = 0;
//! Adds a combo box to the environment.
/** \param rectangle Rectangle specifying the borders of the combo box.
\param parent Parent item of the element, e.g. a window.
Set it to 0 to place the combo box directly in the environment.
\param id An identifier for the combo box.
\return Pointer to the created combo box. Returns 0 if an
error occurred. This pointer should not be dropped. See
IReferenceCounted::drop() for more information. */
virtual IGUIComboBox* addComboBox(const core::rect<s32>& rectangle,
IGUIElement* parent=0, s32 id=-1) = 0;
//! Adds a table to the environment
/** \param rectangle Rectangle specifying the borders of the table.
\param parent Parent item of the element, e.g. a window. Set it to 0
to place the element directly in the environment.
\param id An identifier for the table.
\param drawBackground Flag whether the background should be drawn.
\return Pointer to the created table. Returns 0 if an error occurred.
This pointer should not be dropped. See IReferenceCounted::drop() for
more information. */
virtual IGUITable* addTable(const core::rect<s32>& rectangle,
IGUIElement* parent=0, s32 id=-1, bool drawBackground=false) =0;
//! Get the default element factory which can create all built-in elements
/** \return Pointer to the factory.
This pointer should not be dropped. See IReferenceCounted::drop() for
more information. */
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 automatically, for example when loading
data from xml files.
\param factoryToAdd Pointer to new factory. */
virtual void registerGUIElementFactory(IGUIElementFactory* factoryToAdd) = 0;
//! Get amount of registered gui element factories.
/** \return Amount of registered gui element factories. */
virtual u32 getRegisteredGUIElementFactoryCount() const = 0;
//! Get a gui element factory by index
/** \param index Index of the factory.
\return Factory at given index, or 0 if no such factory exists. */
virtual IGUIElementFactory* getGUIElementFactory(u32 index) const = 0;
//! Adds a GUI element by its name
/** Each factory is checked if it can create an element of the given
name. The first match will be created.
\param elementName Name of the element to be created.
\param parent Parent of the new element, if not 0.
\return New GUI element, or 0 if no such element exists. */
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.
\return True if saving succeeded, else false. */
virtual bool saveGUI(const io::path& 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.
\return True if saving succeeded, else false. */
virtual bool saveGUI(io::IWriteFile* file, IGUIElement* start=0) = 0;
//! Loads the gui. Note that the current gui is not cleared before.
/** When a parent is set the elements will be added below the parent, the parent itself does not deserialize.
When the file contains skin-settings from the gui-environment those are always serialized into the
guienvironment independent of the parent setting.
\param filename Name of the file.
\param parent Parent for the loaded GUI, root if 0.
\return True if loading succeeded, else false. */
virtual bool loadGUI(const io::path& filename, IGUIElement* parent=0) = 0;
//! Loads the gui. Note that the current gui is not cleared before.
/** When a parent is set the elements will be added below the parent, the parent itself does not deserialize.
When the file contains skin-settings from the gui-environment those are always serialized into the
guienvironment independent of the parent setting.
\param file The file to load from.
\param parent Parent for the loaded GUI, root if 0.
\return True if loading succeeded, else false. */
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* node) =0;
};
} // end namespace gui
} // end namespace irr
#endif

View File

@ -0,0 +1,44 @@
// Copyright (C) 2002-2012 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"
#include "path.h"
namespace irr
{
namespace gui
{
//! Standard file chooser dialog.
/** \warning When the user selects a folder this does change the current working directory
\par This element can create the following events of type EGUI_EVENT_TYPE:
\li EGET_DIRECTORY_SELECTED
\li EGET_FILE_SELECTED
\li EGET_FILE_CHOOSE_DIALOG_CANCELLED
*/
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) {}
//! Returns the filename of the selected file. Returns NULL, if no file was selected.
virtual const wchar_t* getFileName() const = 0;
//! Returns the directory of the selected file. Returns NULL, if no directory was selected.
virtual const io::path& getDirectoryName() = 0;
};
} // end namespace gui
} // end namespace irr
#endif

104
include/irrlicht/IGUIFont.h Normal file
View File

@ -0,0 +1,104 @@
// Copyright (C) 2002-2012 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"
#include "irrString.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:
//! Draws some 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: Specifies if the text should be centered horizontally into the rectangle.
\param vcenter: Specifies 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 core::stringw& text, const core::rect<s32>& position,
video::SColor color, bool hcenter=false, bool vcenter=false,
const core::rect<s32>* clip=0) = 0;
//! Calculates the width and height of a given string of text.
/** \return Returns width and height of the area covered by the text if
it would be drawn. */
virtual core::dimension2d<u32> 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 width for the font.
virtual void setKerningWidth (s32 kerning) = 0;
//! Sets global kerning height for the font.
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;
//! Define which characters should not be drawn by the font.
/** For example " " would not draw any space which is usually blank in
most fonts.
\param s String of symbols which are not send down to the videodriver
*/
virtual void setInvisibleCharacters( const wchar_t *s ) = 0;
};
} // end namespace gui
} // end namespace irr
#endif

View File

@ -0,0 +1,46 @@
// Copyright (C) 2002-2012 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:
//! 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,58 @@
// Copyright (C) 2002-2012 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) {}
//! Sets an image texture
virtual void setImage(video::ITexture* image) = 0;
//! Gets the image texture
virtual video::ITexture* getImage() const = 0;
//! Sets the color 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;
//! Gets the color of the image
virtual video::SColor getColor() const = 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,45 @@
// This file is part of the "Irrlicht Engine".
// written by Reinhard Ostermeier, reinhard@nospam.r-ostermeier.de
#ifndef __I_GUI_IMAGE_LIST_H_INCLUDED__
#define __I_GUI_IMAGE_LIST_H_INCLUDED__
#include "IGUIElement.h"
#include "rect.h"
#include "irrTypes.h"
namespace irr
{
namespace gui
{
//! Font interface.
class IGUIImageList : public virtual IReferenceCounted
{
public:
//! Destructor
virtual ~IGUIImageList() {};
//! Draws an image and clips it to the specified rectangle if wanted
//! \param index: Index of the image
//! \param destPos: Position of the image to draw
//! \param clip: Optional pointer to a rectalgle against which the text will be clipped.
//! If the pointer is null, no clipping will be done.
virtual void draw(s32 index, const core::position2d<s32>& destPos,
const core::rect<s32>* clip = 0) = 0;
//! Returns the count of Images in the list.
//! \return Returns the count of Images in the list.
virtual s32 getImageCount() const = 0;
//! Returns the size of the images in the list.
//! \return Returns the size of the images in the list.
virtual core::dimension2d<s32> getImageSize() const = 0;
};
} // end namespace gui
} // end namespace irr
#endif

View File

@ -0,0 +1,67 @@
// Copyright (C) 2002-2012 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) {}
//! 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 specifying 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 specifying 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,138 @@
// Copyright (C) 2002-2012 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 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.
/** \par This element can create the following events of type EGUI_EVENT_TYPE:
\li EGET_LISTBOX_CHANGED
\li EGET_LISTBOX_SELECTED_AGAIN
*/
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) {}
//! 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 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;
//! get the the id of the item at the given absolute coordinates
/** \return The id of the listitem or -1 when no item is at those coordinates*/
virtual s32 getItemAt(s32 xpos, s32 ypos) const = 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;
//! sets the selected item. Set this to 0 if no item should be selected
virtual void setSelected(const wchar_t *item) = 0;
//! set whether the listbox should scroll to newly selected items
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, 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, 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 its 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;
//! set global itemHeight
virtual void setItemHeight( s32 height ) = 0;
//! Sets whether to draw the background
virtual void setDrawBackground(bool draw) = 0;
};
} // end namespace gui
} // end namespace irr
#endif

View File

@ -0,0 +1,53 @@
// Copyright (C) 2002-2012 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) {}
//! 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,65 @@
// Copyright (C) 2002-2012 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.
/** \par This element can create the following events of type EGUI_EVENT_TYPE:
\li EGET_SCROLL_BAR_CHANGED
*/
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) {}
//! sets the maximum value of the scrollbar.
virtual void setMax(s32 max) = 0;
//! gets the maximum value of the scrollbar.
virtual s32 getMax() const = 0;
//! sets the minimum value of the scrollbar.
virtual void setMin(s32 min) = 0;
//! gets the minimum value of the scrollbar.
virtual s32 getMin() const = 0;
//! gets the small step value
virtual s32 getSmallStep() const = 0;
//! Sets the small step
/** That is 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
/** That is 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

574
include/irrlicht/IGUISkin.h Normal file
View File

@ -0,0 +1,574 @@
// Copyright (C) 2002-2012 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 "EGUIAlignment.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,
//! this value is not used, it only specifies the number of skin types
EGST_COUNT
};
//! Names for gui element types
const c8* const GUISkinTypeNames[EGST_COUNT+1] =
{
"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,
//! Grayed (disabled) window symbols like on close buttons, scroll bars and check boxes
EGDC_GRAY_WINDOW_SYMBOL,
//! Window background for editable field (editbox, checkbox-field)
EGDC_EDITABLE,
//! Grayed (disabled) window background for editable field (editbox, checkbox-field)
EGDC_GRAY_EDITABLE,
//! Show focus of window background for editable field (editbox or when checkbox-field is pressed)
EGDC_FOCUSED_EDITABLE,
//! 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[EGDC_COUNT+1] =
{
"3DDarkShadow",
"3DShadow",
"3DFace",
"3DHighlight",
"3DLight",
"ActiveBorder",
"ActiveCaption",
"AppWorkspace",
"ButtonText",
"GrayText",
"Highlight",
"HighlightText",
"InactiveBorder",
"InactiveCaption",
"ToolTip",
"ToolTipBackground",
"ScrollBar",
"Window",
"WindowSymbol",
"Icon",
"IconHighlight",
"GrayWindowSymbol",
"Editable",
"GrayEditable",
"FocusedEditable",
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,
//! \deprecated This may be removed by Irrlicht 1.9
EGDS_MESSAGE_BOX_WIDTH,
//! \deprecated This may be removed by Irrlicht 1.9
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,
//! distance for text in the title bar, from the left of the window rect
EGDS_TITLEBARTEXT_DISTANCE_X,
//! distance for text in the title bar, from the top of the window rect
EGDS_TITLEBARTEXT_DISTANCE_Y,
//! free space in a messagebox between borders and contents on all sides
EGDS_MESSAGE_BOX_GAP_SPACE,
//! minimal space to reserve for messagebox text-width
EGDS_MESSAGE_BOX_MIN_TEXT_WIDTH,
//! maximal space to reserve for messagebox text-width
EGDS_MESSAGE_BOX_MAX_TEXT_WIDTH,
//! minimal space to reserve for messagebox text-height
EGDS_MESSAGE_BOX_MIN_TEXT_HEIGHT,
//! maximal space to reserve for messagebox text-height
EGDS_MESSAGE_BOX_MAX_TEXT_HEIGHT,
//! pixels to move the button image to the right when a pushbutton is pressed
EGDS_BUTTON_PRESSED_IMAGE_OFFSET_X,
//! pixels to move the button image down when a pushbutton is pressed
EGDS_BUTTON_PRESSED_IMAGE_OFFSET_Y,
//! pixels to move the button text to the right when a pushbutton is pressed
EGDS_BUTTON_PRESSED_TEXT_OFFSET_X,
//! pixels to move the button text down when a pushbutton is pressed
EGDS_BUTTON_PRESSED_TEXT_OFFSET_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[EGDS_COUNT+1] =
{
"ScrollBarSize",
"MenuHeight",
"WindowButtonWidth",
"CheckBoxWidth",
"MessageBoxWidth",
"MessageBoxHeight",
"ButtonWidth",
"ButtonHeight",
"TextDistanceX",
"TextDistanceY",
"TitleBarTextX",
"TitleBarTextY",
"MessageBoxGapSpace",
"MessageBoxMinTextWidth",
"MessageBoxMaxTextWidth",
"MessageBoxMinTextHeight",
"MessageBoxMaxTextHeight",
"ButtonPressedImageOffsetX",
"ButtonPressedImageOffsetY"
"ButtonPressedTextOffsetX",
"ButtonPressedTextOffsetY",
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[EGDT_COUNT+1] =
{
"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[EGDI_COUNT+1] =
{
"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[EGDF_COUNT+1] =
{
"defaultFont",
"buttonFont",
"windowFont",
"menuFont",
"tooltipFont",
0
};
//! A skin modifies the look of the GUI elements.
class IGUISkin : public virtual io::IAttributeExchangingObject
{
public:
//! 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.
\param checkClientArea: When set to non-null the function will not draw anything,
but will instead return the clientArea which can be used for drawing by the calling window.
That is the area without borders and without titlebar.
\return Returns rect where it would be good to draw title bar text. This will
work even when checkClientArea is set to a non-null value.*/
virtual core::rect<s32> draw3DWindowBackground(IGUIElement* element,
bool drawTitleBar, video::SColor titleBarColor,
const core::rect<s32>& rect,
const core::rect<s32>* clip=0,
core::rect<s32>* checkClientArea=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.
\param alignment Alignment of GUI element. */
virtual void draw3DTabButton(IGUIElement* element, bool active,
const core::rect<s32>& rect, const core::rect<s32>* clip=0, gui::EGUI_ALIGNMENT alignment=EGUIA_UPPERLEFT) = 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.
\param tabHeight Height of tab.
\param alignment Alignment of GUI element. */
virtual void draw3DTabBody(IGUIElement* element, bool border, bool background,
const core::rect<s32>& rect, const core::rect<s32>* clip=0, s32 tabHeight=-1, gui::EGUI_ALIGNMENT alignment=EGUIA_UPPERLEFT ) = 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,69 @@
// Copyright (C) 2006-2012 Michael Zeilfelder
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#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
/** \par This element can create the following events of type EGUI_EVENT_TYPE:
\li EGET_SPINBOX_CHANGED
*/
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) {}
//! Access the edit box used in the spin control
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.
//! Note that this also rounds the range to the same number of decimal places.
/** \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,95 @@
// Copyright (C) 2002-2012 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_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
{
//! A single sprite frame.
struct SGUISpriteFrame
{
u32 textureNumber;
u32 rectNumber;
};
//! A sprite composed of several frames.
struct SGUISprite
{
SGUISprite() : Frames(), frameTime(0) {}
core::array<SGUISpriteFrame> Frames;
u32 frameTime;
};
//! Sprite bank interface.
/** See http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=25742&highlight=spritebank
* for more information how to use the spritebank.
*/
class IGUISpriteBank : public virtual IReferenceCounted
{
public:
//! 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;
//! Add the texture and use it for a single non-animated sprite.
//! The texture and the corresponding rectangle and sprite will all be added to the end of each array.
//! returns the index of the sprite or -1 on failure
virtual s32 addTextureAsSprite(video::ITexture* texture) = 0;
//! clears sprites, rectangles and textures
virtual void clear() = 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;
//! Draws a sprite batch in 2d using an array of positions and a color
virtual void draw2DSpriteBatch(const core::array<u32>& indices, const core::array<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,135 @@
// Copyright (C) 2002-2012 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) {}
//! 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;
//! Get the font which is used right now for drawing
/** Currently this is the override font when one is set and the
font of the active skin otherwise */
virtual IGUIFont* getActiveFont() 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 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;
//! Gets the background color
/** \return: The background color */
virtual video::SColor getBackgroundColor() const = 0;
//! Checks if background drawing is enabled
/** \return true if background drawing is enabled, false otherwise */
virtual bool isDrawBackgroundEnabled() const = 0;
//! Sets whether to draw the border
virtual void setDrawBorder(bool draw) = 0;
//! Checks if border drawing is enabled
/** \return true if border drawing is enabled, false otherwise */
virtual bool isDrawBorderEnabled() const = 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 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;
//! Set whether the text in this label should be clipped if it goes outside bounds
virtual void setTextRestrainedInside(bool restrainedInside) = 0;
//! Checks if the text in this label should be clipped if it goes outside bounds
virtual bool isTextRestrainedInside() const = 0;
//! Set whether the string should be interpreted as right-to-left (RTL) text
/** \note This component does not implement the Unicode bidi standard, the
text of the component should be already RTL if you call this. The
main difference when RTL is enabled is that the linebreaks for multiline
elements are performed starting from the end.
*/
virtual void setRightToLeft(bool rtl) = 0;
//! Checks whether the text in this element should be interpreted as right-to-left
virtual bool isRightToLeft() const = 0;
};
} // end namespace gui
} // end namespace irr
#endif

View File

@ -0,0 +1,136 @@
// Copyright (C) 2002-2012 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"
#include "IGUISkin.h"
namespace irr
{
namespace gui
{
//! A tab-page, onto which other gui elements could be added.
/** IGUITab refers to the page itself, not to the tab in the tabbar of an IGUITabControl. */
class IGUITab : public IGUIElement
{
public:
//! constructor
IGUITab(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
: IGUIElement(EGUIET_TAB, environment, parent, id, rectangle) {}
//! Returns zero based index of tab if in tabcontrol.
/** Can be accessed later IGUITabControl::getTab() by this number.
Note that this number can change when other tabs are inserted or removed .
*/
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;
//! sets the color of the text
virtual void setTextColor(video::SColor c) = 0;
//! gets the color of the text
virtual video::SColor getTextColor() const = 0;
};
//! A standard tab control
/** \par This element can create the following events of type EGUI_EVENT_TYPE:
\li EGET_TAB_CHANGED
*/
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) {}
//! Adds a tab
virtual IGUITab* addTab(const wchar_t* caption, s32 id=-1) = 0;
//! Insert the tab at the given index
/** \return The tab on success or NULL on failure. */
virtual IGUITab* insertTab(s32 idx, const wchar_t* caption, s32 id=-1) = 0;
//! Removes a tab from the tabcontrol
virtual void removeTab(s32 idx) = 0;
//! Clears the tabcontrol removing all tabs
virtual void clear() = 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(IGUITab *tab) = 0;
//! Returns which tab is currently active
virtual s32 getActiveTab() const = 0;
//! get the the id of the tab at the given absolute coordinates
/** \return The id of the tab or -1 when no tab is at those coordinates*/
virtual s32 getTabAt(s32 xpos, s32 ypos) const = 0;
//! Set the height of the tabs
virtual void setTabHeight( s32 height ) = 0;
//! Get the height of the tabs
/** return Returns the height of the tabs */
virtual s32 getTabHeight() const = 0;
//! set the maximal width of a tab. Per default width is 0 which means "no width restriction".
virtual void setTabMaxWidth(s32 width ) = 0;
//! get the maximal width of a tab
virtual s32 getTabMaxWidth() const = 0;
//! Set the alignment of the tabs
/** Use EGUIA_UPPERLEFT or EGUIA_LOWERRIGHT */
virtual void setTabVerticalAlignment( gui::EGUI_ALIGNMENT alignment ) = 0;
//! Get the alignment of the tabs
/** return Returns the alignment of the tabs */
virtual gui::EGUI_ALIGNMENT getTabVerticalAlignment() const = 0;
//! Set the extra width added to tabs on each side of the text
virtual void setTabExtraWidth( s32 extraWidth ) = 0;
//! Get the extra width added to tabs on each side of the text
/** return Returns the extra width of the tabs */
virtual s32 getTabExtraWidth() const = 0;
};
} // end namespace gui
} // end namespace irr
#endif

View File

@ -0,0 +1,205 @@
// Copyright (C) 2003-2012 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_TABLE_H_INCLUDED__
#define __I_GUI_TABLE_H_INCLUDED__
#include "IGUIElement.h"
#include "irrTypes.h"
#include "SColor.h"
#include "IGUISkin.h"
namespace irr
{
namespace gui
{
//! modes for ordering used when a column header is clicked
enum EGUI_COLUMN_ORDERING
{
//! Do not use ordering
EGCO_NONE,
//! Send a EGET_TABLE_HEADER_CHANGED message when a column header is clicked.
EGCO_CUSTOM,
//! Sort it ascending by it's ascii value like: a,b,c,...
EGCO_ASCENDING,
//! Sort it descending by it's ascii value like: z,x,y,...
EGCO_DESCENDING,
//! Sort it ascending on first click, descending on next, etc
EGCO_FLIP_ASCENDING_DESCENDING,
//! Not used as mode, only to get maximum value for this enum
EGCO_COUNT
};
//! Names for EGUI_COLUMN_ORDERING types
const c8* const GUIColumnOrderingNames[] =
{
"none",
"custom",
"ascend",
"descend",
"ascend_descend",
0,
};
enum EGUI_ORDERING_MODE
{
//! No element ordering
EGOM_NONE,
//! Elements are ordered from the smallest to the largest.
EGOM_ASCENDING,
//! Elements are ordered from the largest to the smallest.
EGOM_DESCENDING,
//! this value is not used, it only specifies the amount of default ordering types
//! available.
EGOM_COUNT
};
const c8* const GUIOrderingModeNames[] =
{
"none",
"ascending",
"descending",
0
};
enum EGUI_TABLE_DRAW_FLAGS
{
EGTDF_ROWS = 1,
EGTDF_COLUMNS = 2,
EGTDF_ACTIVE_ROW = 4,
EGTDF_COUNT
};
//! Default list box GUI element.
/** \par This element can create the following events of type EGUI_EVENT_TYPE:
\li EGET_TABLE_CHANGED
\li EGET_TABLE_SELECTED_AGAIN
\li EGET_TABLE_HEADER_CHANGED
*/
class IGUITable : public IGUIElement
{
public:
//! constructor
IGUITable(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
: IGUIElement(EGUIET_TABLE, environment, parent, id, rectangle) {}
//! Adds a column
/** If columnIndex is outside the current range, do push new colum at the end */
virtual void addColumn(const wchar_t* caption, s32 columnIndex=-1) = 0;
//! remove a column from the table
virtual void removeColumn(u32 columnIndex) = 0;
//! Returns the number of columns in the table control
virtual s32 getColumnCount() const = 0;
//! Makes a column active. This will trigger an ordering process.
/** \param idx: The id of the column to make active.
\param doOrder: Do also the ordering which depending on mode for active column
\return True if successful. */
virtual bool setActiveColumn(s32 idx, bool doOrder=false) = 0;
//! Returns which header is currently active
virtual s32 getActiveColumn() const = 0;
//! Returns the ordering used by the currently active column
virtual EGUI_ORDERING_MODE getActiveColumnOrdering() const = 0;
//! Set the width of a column
virtual void setColumnWidth(u32 columnIndex, u32 width) = 0;
//! Get the width of a column
virtual u32 getColumnWidth(u32 columnIndex) const = 0;
//! columns can be resized by drag 'n drop
virtual void setResizableColumns(bool resizable) = 0;
//! can columns be resized by dran 'n drop?
virtual bool hasResizableColumns() const = 0;
//! This tells the table control which ordering mode should be used when a column header is clicked.
/** \param columnIndex The index of the column header.
\param mode: One of the modes defined in EGUI_COLUMN_ORDERING */
virtual void setColumnOrdering(u32 columnIndex, EGUI_COLUMN_ORDERING mode) = 0;
//! Returns which row is currently selected
virtual s32 getSelected() const = 0;
//! set wich row is currently selected
virtual void setSelected( s32 index ) = 0;
//! Get amount of rows in the tabcontrol
virtual s32 getRowCount() const = 0;
//! adds a row to the table
/** \param rowIndex Zero based index of rows. The row will be
inserted at this position, if a row already exist there, it
will be placed after it. If the row is larger than the actual
number of row by more than one, it won't be created. Note that
if you create a row that's not at the end, there might be
performance issues.
\return index of inserted row. */
virtual u32 addRow(u32 rowIndex) = 0;
//! Remove a row from the table
virtual void removeRow(u32 rowIndex) = 0;
//! clears the table rows, but keeps the columns intact
virtual void clearRows() = 0;
//! Swap two row positions.
virtual void swapRows(u32 rowIndexA, u32 rowIndexB) = 0;
//! This tells the table to start ordering all the rows.
/** You need to explicitly tell the table to re order the rows
when a new row is added or the cells data is changed. This
makes the system more flexible and doesn't make you pay the
cost of ordering when adding a lot of rows.
\param columnIndex: When set to -1 the active column is used.
\param mode Ordering mode of the rows. */
virtual void orderRows(s32 columnIndex=-1, EGUI_ORDERING_MODE mode=EGOM_NONE) = 0;
//! Set the text of a cell
virtual void setCellText(u32 rowIndex, u32 columnIndex, const core::stringw& text) = 0;
//! Set the text of a cell, and set a color of this cell.
virtual void setCellText(u32 rowIndex, u32 columnIndex, const core::stringw& text, video::SColor color) = 0;
//! Set the data of a cell
virtual void setCellData(u32 rowIndex, u32 columnIndex, void *data) = 0;
//! Set the color of a cell text
virtual void setCellColor(u32 rowIndex, u32 columnIndex, video::SColor color) = 0;
//! Get the text of a cell
virtual const wchar_t* getCellText(u32 rowIndex, u32 columnIndex ) const = 0;
//! Get the data of a cell
virtual void* getCellData(u32 rowIndex, u32 columnIndex ) const = 0;
//! clears the table, deletes all items in the table
virtual void clear() = 0;
//! Set flags, as defined in EGUI_TABLE_DRAW_FLAGS, which influence the layout
virtual void setDrawFlags(s32 flags) = 0;
//! Get the flags, as defined in EGUI_TABLE_DRAW_FLAGS, which influence the layout
virtual s32 getDrawFlags() const = 0;
};
} // end namespace gui
} // end namespace irr
#endif

View File

@ -0,0 +1,40 @@
// Copyright (C) 2002-2012 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) {}
//! 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,278 @@
// written by Reinhard Ostermeier, reinhard@nospam.r-ostermeier.de
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_GUI_TREE_VIEW_H_INCLUDED__
#define __I_GUI_TREE_VIEW_H_INCLUDED__
#include "IGUIElement.h"
#include "IGUIImageList.h"
#include "irrTypes.h"
namespace irr
{
namespace gui
{
class IGUIFont;
class IGUITreeView;
//! Node for gui tree view
/** \par This element can create the following events of type EGUI_EVENT_TYPE:
\li EGET_TREEVIEW_NODE_EXPAND
\li EGET_TREEVIEW_NODE_COLLAPS
\li EGET_TREEVIEW_NODE_DESELECT
\li EGET_TREEVIEW_NODE_SELECT
*/
class IGUITreeViewNode : public IReferenceCounted
{
public:
//! returns the owner (tree view) of this node
virtual IGUITreeView* getOwner() const = 0;
//! Returns the parent node of this node.
/** For the root node this will return 0. */
virtual IGUITreeViewNode* getParent() const = 0;
//! returns the text of the node
virtual const wchar_t* getText() const = 0;
//! sets the text of the node
virtual void setText( const wchar_t* text ) = 0;
//! returns the icon text of the node
virtual const wchar_t* getIcon() const = 0;
//! sets the icon text of the node
virtual void setIcon( const wchar_t* icon ) = 0;
//! returns the image index of the node
virtual u32 getImageIndex() const = 0;
//! sets the image index of the node
virtual void setImageIndex( u32 imageIndex ) = 0;
//! returns the image index of the node
virtual u32 getSelectedImageIndex() const = 0;
//! sets the image index of the node
virtual void setSelectedImageIndex( u32 imageIndex ) = 0;
//! returns the user data (void*) of this node
virtual void* getData() const = 0;
//! sets the user data (void*) of this node
virtual void setData( void* data ) = 0;
//! returns the user data2 (IReferenceCounted) of this node
virtual IReferenceCounted* getData2() const = 0;
//! sets the user data2 (IReferenceCounted) of this node
virtual void setData2( IReferenceCounted* data ) = 0;
//! returns the child item count
virtual u32 getChildCount() const = 0;
//! removes all children (recursive) from this node
virtual void clearChildren() = 0;
//! removes all children (recursive) from this node
/** \deprecated Deprecated in 1.8, use clearChildren() instead.
This method may be removed by Irrlicht 1.9 */
_IRR_DEPRECATED_ void clearChilds()
{
return clearChildren();
}
//! returns true if this node has child nodes
virtual bool hasChildren() const = 0;
//! returns true if this node has child nodes
/** \deprecated Deprecated in 1.8, use hasChildren() instead.
This method may be removed by Irrlicht 1.9 */
_IRR_DEPRECATED_ bool hasChilds() const
{
return hasChildren();
}
//! Adds a new node behind the last child node.
/** \param text text of the new node
\param icon icon text of the new node
\param imageIndex index of the image for the new node (-1 = none)
\param selectedImageIndex index of the selected image for the new node (-1 = same as imageIndex)
\param data user data (void*) of the new node
\param data2 user data2 (IReferenceCounted*) of the new node
\return The new node
*/
virtual IGUITreeViewNode* addChildBack(
const wchar_t* text, const wchar_t* icon = 0,
s32 imageIndex=-1, s32 selectedImageIndex=-1,
void* data=0, IReferenceCounted* data2=0) =0;
//! Adds a new node before the first child node.
/** \param text text of the new node
\param icon icon text of the new node
\param imageIndex index of the image for the new node (-1 = none)
\param selectedImageIndex index of the selected image for the new node (-1 = same as imageIndex)
\param data user data (void*) of the new node
\param data2 user data2 (IReferenceCounted*) of the new node
\return The new node
*/
virtual IGUITreeViewNode* addChildFront(
const wchar_t* text, const wchar_t* icon = 0,
s32 imageIndex=-1, s32 selectedImageIndex=-1,
void* data=0, IReferenceCounted* data2=0 ) =0;
//! Adds a new node behind the other node.
/** The other node has also te be a child node from this node.
\param other Node to insert after
\param text text of the new node
\param icon icon text of the new node
\param imageIndex index of the image for the new node (-1 = none)
\param selectedImageIndex index of the selected image for the new node (-1 = same as imageIndex)
\param data user data (void*) of the new node
\param data2 user data2 (IReferenceCounted*) of the new node
\return The new node or 0 if other is no child node from this
*/
virtual IGUITreeViewNode* insertChildAfter(
IGUITreeViewNode* other,
const wchar_t* text, const wchar_t* icon = 0,
s32 imageIndex=-1, s32 selectedImageIndex=-1,
void* data=0, IReferenceCounted* data2=0) =0;
//! Adds a new node before the other node.
/** The other node has also te be a child node from this node.
\param other Node to insert before
\param text text of the new node
\param icon icon text of the new node
\param imageIndex index of the image for the new node (-1 = none)
\param selectedImageIndex index of the selected image for the new node (-1 = same as imageIndex)
\param data user data (void*) of the new node
\param data2 user data2 (IReferenceCounted*) of the new node
\return The new node or 0 if other is no child node from this
*/
virtual IGUITreeViewNode* insertChildBefore(
IGUITreeViewNode* other,
const wchar_t* text, const wchar_t* icon = 0,
s32 imageIndex=-1, s32 selectedImageIndex=-1,
void* data=0, IReferenceCounted* data2=0) = 0;
//! Return the first child node from this node.
/** \return The first child node or 0 if this node has no children. */
virtual IGUITreeViewNode* getFirstChild() const = 0;
//! Return the last child node from this node.
/** \return The last child node or 0 if this node has no children. */
virtual IGUITreeViewNode* getLastChild() const = 0;
//! Returns the previous sibling node from this node.
/** \return The previous sibling node from this node or 0 if this is
the first node from the parent node.
*/
virtual IGUITreeViewNode* getPrevSibling() const = 0;
//! Returns the next sibling node from this node.
/** \return The next sibling node from this node or 0 if this is
the last node from the parent node.
*/
virtual IGUITreeViewNode* getNextSibling() const = 0;
//! Returns the next visible (expanded, may be out of scrolling) node from this node.
/** \return The next visible node from this node or 0 if this is
the last visible node. */
virtual IGUITreeViewNode* getNextVisible() const = 0;
//! Deletes a child node.
/** \return Returns true if the node was found as a child and is deleted. */
virtual bool deleteChild( IGUITreeViewNode* child ) = 0;
//! Moves a child node one position up.
/** \return True if the node was found as achild node and was not already the first child. */
virtual bool moveChildUp( IGUITreeViewNode* child ) = 0;
//! Moves a child node one position down.
/** \return True if the node was found as achild node and was not already the last child. */
virtual bool moveChildDown( IGUITreeViewNode* child ) = 0;
//! Returns true if the node is expanded (children are visible).
virtual bool getExpanded() const = 0;
//! Sets if the node is expanded.
virtual void setExpanded( bool expanded ) = 0;
//! Returns true if the node is currently selected.
virtual bool getSelected() const = 0;
//! Sets this node as selected.
virtual void setSelected( bool selected ) = 0;
//! Returns true if this node is the root node.
virtual bool isRoot() const = 0;
//! Returns the level of this node.
/** The root node has level 0. Direct children of the root has level 1 ... */
virtual s32 getLevel() const = 0;
//! Returns true if this node is visible (all parents are expanded).
virtual bool isVisible() const = 0;
};
//! Default tree view GUI element.
/** Displays a windows like tree buttons to expand/collaps the child
nodes of an node and optional tree lines. Each node consits of an
text, an icon text and a void pointer for user data. */
class IGUITreeView : public IGUIElement
{
public:
//! constructor
IGUITreeView(IGUIEnvironment* environment, IGUIElement* parent,
s32 id, core::rect<s32> rectangle)
: IGUIElement( EGUIET_TREE_VIEW, environment, parent, id, rectangle ) {}
//! returns the root node (not visible) from the tree.
virtual IGUITreeViewNode* getRoot() const = 0;
//! returns the selected node of the tree or 0 if none is selected
virtual IGUITreeViewNode* getSelected() const = 0;
//! returns true if the tree lines are visible
virtual bool getLinesVisible() const = 0;
//! sets if the tree lines are visible
/** \param visible true for visible, false for invisible */
virtual void setLinesVisible( bool visible ) = 0;
//! Sets the font which should be used as icon font.
/** This font is set to the Irrlicht engine built-in-font by
default. Icons can be displayed in front of every list item.
An icon is a string, displayed with the icon font. When using
the build-in-font of the Irrlicht engine as icon font, the icon
strings defined in GUIIcons.h can be used.
*/
virtual void setIconFont( IGUIFont* font ) = 0;
//! Sets the image list which should be used for the image and selected image of every node.
/** The default is 0 (no images). */
virtual void setImageList( IGUIImageList* imageList ) = 0;
//! Returns the image list which is used for the nodes.
virtual IGUIImageList* getImageList() const = 0;
//! Sets if the image is left of the icon. Default is true.
virtual void setImageLeftOfIcon( bool bLeftOf ) = 0;
//! Returns if the Image is left of the icon. Default is true.
virtual bool getImageLeftOfIcon() const = 0;
//! Returns the node which is associated to the last event.
/** This pointer is only valid inside the OnEvent call! */
virtual IGUITreeViewNode* getLastEventNode() const = 0;
};
} // end namespace gui
} // end namespace irr
#endif

View File

@ -0,0 +1,74 @@
// Copyright (C) 2002-2012 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.
/** \par This element can create the following events of type EGUI_EVENT_TYPE:
\li EGET_ELEMENT_CLOSED
*/
class IGUIWindow : public IGUIElement
{
public:
//! constructor
IGUIWindow(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
: IGUIElement(EGUIET_WINDOW, environment, parent, id, rectangle) {}
//! Returns pointer to the close button
/** You can hide the button by calling setVisible(false) on the result. */
virtual IGUIButton* getCloseButton() const = 0;
//! Returns pointer to the minimize button
/** You can hide the button by calling setVisible(false) on the result. */
virtual IGUIButton* getMinimizeButton() const = 0;
//! Returns pointer to the maximize button
/** You can hide the button by calling setVisible(false) on the result. */
virtual IGUIButton* getMaximizeButton() const = 0;
//! Returns true if the window can be dragged with the mouse, false if not
virtual bool isDraggable() const = 0;
//! Sets whether the window can be dragged by the mouse
virtual void setDraggable(bool draggable) = 0;
//! Set if the window background will be drawn
virtual void setDrawBackground(bool draw) = 0;
//! Get if the window background will be drawn
virtual bool getDrawBackground() const = 0;
//! Set if the window titlebar will be drawn
//! Note: If the background is not drawn, then the titlebar is automatically also not drawn
virtual void setDrawTitlebar(bool draw) = 0;
//! Get if the window titlebar will be drawn
virtual bool getDrawTitlebar() const = 0;
//! Returns the rectangle of the drawable area (without border and without titlebar)
/** The coordinates are given relative to the top-left position of the gui element.<br>
So to get absolute positions you have to add the resulting rectangle to getAbsolutePosition().UpperLeftCorner.<br>
To get it relative to the parent element you have to add the resulting rectangle to getRelativePosition().UpperLeftCorner.
Beware that adding a menu will not change the clientRect as menus are own gui elements, so in that case you might want to subtract
the menu area additionally. */
virtual core::rect<s32> getClientRect() const = 0;
};
} // end namespace gui
} // end namespace irr
#endif

View File

@ -0,0 +1,177 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_GEOMETRY_CREATOR_H_INCLUDED__
#define __I_GEOMETRY_CREATOR_H_INCLUDED__
#include "IReferenceCounted.h"
#include "IMesh.h"
#include "IImage.h"
namespace irr
{
namespace video
{
class IVideoDriver;
class SMaterial;
}
namespace scene
{
//! Helper class for creating geometry on the fly.
/** You can get an instance of this class through ISceneManager::getGeometryCreator() */
class IGeometryCreator : public IReferenceCounted
{
public:
//! Creates a simple cube mesh.
/**
\param size Dimensions of the cube.
\return Generated mesh.
*/
virtual IMesh* createCubeMesh(const core::vector3df& size=core::vector3df(5.f,5.f,5.f)) const =0;
//! Create a pseudo-random mesh representing a hilly terrain.
/**
\param tileSize The size of each tile.
\param tileCount The number of tiles in each dimension.
\param material The material to apply to the mesh.
\param hillHeight The maximum height of the hills.
\param countHills The number of hills along each dimension.
\param textureRepeatCount The number of times to repeat the material texture along each dimension.
\return Generated mesh.
*/
virtual IMesh* createHillPlaneMesh(
const core::dimension2d<f32>& tileSize,
const core::dimension2d<u32>& tileCount,
video::SMaterial* material, f32 hillHeight,
const core::dimension2d<f32>& countHills,
const core::dimension2d<f32>& textureRepeatCount) const =0;
//! Create a simple rectangular textured plane mesh.
/**
\param tileSize The size of each tile.
\param tileCount The number of tiles in each dimension.
\param material The material to apply to the mesh.
\param textureRepeatCount The number of times to repeat the material texture along each dimension.
\return Generated mesh.
*/
IMesh* createPlaneMesh(
const core::dimension2d<f32>& tileSize,
const core::dimension2d<u32>& tileCount=core::dimension2du(1,1),
video::SMaterial* material=0,
const core::dimension2df& textureRepeatCount=core::dimension2df(1.f,1.f)) const
{
return createHillPlaneMesh(tileSize, tileCount, material, 0.f, core::dimension2df(), textureRepeatCount);
}
//! Create a terrain mesh from an image representing a heightfield.
/**
\param texture The texture to apply to the terrain.
\param heightmap An image that will be interpreted as a heightmap. The
brightness (average color) of each pixel is interpreted as a height,
with a 255 brightness pixel producing the maximum height.
\param stretchSize The size that each pixel will produce, i.e. a
512x512 heightmap
and a stretchSize of (10.f, 20.f) will produce a mesh of size
5120.f x 10240.f
\param maxHeight The maximum height of the terrain.
\param driver The current video driver.
\param defaultVertexBlockSize (to be documented)
\param debugBorders (to be documented)
\return Generated mesh.
*/
virtual IMesh* createTerrainMesh(video::IImage* texture,
video::IImage* heightmap,
const core::dimension2d<f32>& stretchSize,
f32 maxHeight, video::IVideoDriver* driver,
const core::dimension2d<u32>& defaultVertexBlockSize,
bool debugBorders=false) const =0;
//! Create an arrow mesh, composed of a cylinder and a cone.
/**
\param tesselationCylinder Number of quads composing the cylinder.
\param tesselationCone Number of triangles composing the cone's roof.
\param height Total height of the arrow
\param cylinderHeight Total height of the cylinder, should be lesser
than total height
\param widthCylinder Diameter of the cylinder
\param widthCone Diameter of the cone's base, should be not smaller
than the cylinder's diameter
\param colorCylinder color of the cylinder
\param colorCone color of the cone
\return Generated mesh.
*/
virtual IMesh* createArrowMesh(const u32 tesselationCylinder = 4,
const u32 tesselationCone = 8, const f32 height = 1.f,
const f32 cylinderHeight = 0.6f, const f32 widthCylinder = 0.05f,
const f32 widthCone = 0.3f, const video::SColor colorCylinder = 0xFFFFFFFF,
const video::SColor colorCone = 0xFFFFFFFF) const =0;
//! Create a sphere mesh.
/**
\param radius Radius of the sphere
\param polyCountX Number of quads used for the horizontal tiling
\param polyCountY Number of quads used for the vertical tiling
\return Generated mesh.
*/
virtual IMesh* createSphereMesh(f32 radius = 5.f,
u32 polyCountX = 16, u32 polyCountY = 16) const =0;
//! Create a cylinder mesh.
/**
\param radius Radius of the cylinder.
\param length Length of the cylinder.
\param tesselation Number of quads around the circumference of the cylinder.
\param color The color of the cylinder.
\param closeTop If true, close the ends of the cylinder, otherwise leave them open.
\param oblique (to be documented)
\return Generated mesh.
*/
virtual IMesh* createCylinderMesh(f32 radius, f32 length,
u32 tesselation,
const video::SColor& color=video::SColor(0xffffffff),
bool closeTop=true, f32 oblique=0.f) const =0;
//! Create a cone mesh.
/**
\param radius Radius of the cone.
\param length Length of the cone.
\param tesselation Number of quads around the circumference of the cone.
\param colorTop The color of the top of the cone.
\param colorBottom The color of the bottom of the cone.
\param oblique (to be documented)
\return Generated mesh.
*/
virtual IMesh* createConeMesh(f32 radius, f32 length, u32 tesselation,
const video::SColor& colorTop=video::SColor(0xffffffff),
const video::SColor& colorBottom=video::SColor(0xffffffff),
f32 oblique=0.f) const =0;
//! Create a volume light mesh.
/**
\param subdivideU Horizontal patch count.
\param subdivideV Vertical patch count.
\param footColor Color at the bottom of the light.
\param tailColor Color at the mid of the light.
\param lpDistance Virtual distance of the light point for normals.
\param lightDim Dimensions of the light.
\return Generated mesh.
*/
virtual IMesh* createVolumeLightMesh(
const u32 subdivideU=32, const u32 subdivideV=32,
const video::SColor footColor = 0xffffffff,
const video::SColor tailColor = 0xffffffff,
const f32 lpDistance = 8.f,
const core::vector3df& lightDim = core::vector3df(1.f,1.2f,1.f)) const =0;
};
} // end namespace scene
} // end namespace irr
#endif // __I_GEOMETRY_CREATOR_H_INCLUDED__

155
include/irrlicht/IImage.h Normal file
View File

@ -0,0 +1,155 @@
// Copyright (C) 2002-2012 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 "rect.h"
#include "SColor.h"
namespace irr
{
namespace video
{
//! 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:
//! 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 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<u32>& 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, bool blend = false ) = 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, u32 width, u32 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;
//! copies this surface into another
virtual void copyTo(IImage* target, const core::position2d<s32>& pos=core::position2d<s32>(0,0)) =0;
//! copies this surface into another
virtual void copyTo(IImage* target, const core::position2d<s32>& pos, const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect=0) =0;
//! copies this surface into another, using the alpha mask and cliprect and a color to add with
virtual void copyToWithAlpha(IImage* target, const core::position2d<s32>& pos,
const core::rect<s32>& sourceRect, const SColor &color,
const core::rect<s32>* clipRect = 0) =0;
//! copies this surface into another, scaling it to fit, appyling a box filter
virtual void copyToScalingBoxFilter(IImage* target, s32 bias = 0, bool blend = false) = 0;
//! fills the surface with given color
virtual void fill(const SColor &color) =0;
//! get the amount of Bits per Pixel of the given color format
static u32 getBitsPerPixelFromFormat(const ECOLOR_FORMAT format)
{
switch(format)
{
case ECF_A1R5G5B5:
return 16;
case ECF_R5G6B5:
return 16;
case ECF_R8G8B8:
return 24;
case ECF_A8R8G8B8:
return 32;
case ECF_R16F:
return 16;
case ECF_G16R16F:
return 32;
case ECF_A16B16G16R16F:
return 64;
case ECF_R32F:
return 32;
case ECF_G32R32F:
return 64;
case ECF_A32B32G32R32F:
return 128;
default:
return 0;
}
}
//! test if the color format is only viable for RenderTarget textures
/** Since we don't have support for e.g. floating point IImage formats
one should test if the color format can be used for arbitrary usage, or
if it is restricted to RTTs. */
static bool isRenderTargetOnlyFormat(const ECOLOR_FORMAT format)
{
switch(format)
{
case ECF_A1R5G5B5:
case ECF_R5G6B5:
case ECF_R8G8B8:
case ECF_A8R8G8B8:
return false;
default:
return true;
}
}
};
} // end namespace video
} // end namespace irr
#endif

View File

@ -0,0 +1,53 @@
// Copyright (C) 2002-2012 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"
#include "path.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:
//! Check if the file might be loaded by this class
/** Check is based on the file extension (e.g. ".tga")
\param filename Name of file to check.
\return True if file seems to be loadable. */
virtual bool isALoadableFileExtension(const io::path& filename) const = 0;
//! Check if the file might be loaded by this class
/** Check might look into the file.
\param file File handle to check.
\return True if file seems to be loadable. */
virtual bool isALoadableFileFormat(io::IReadFile* file) const = 0;
//! Creates a surface from the file
/** \param file File handle to check.
\return Pointer to newly created image, or 0 upon error. */
virtual IImage* loadImage(io::IReadFile* file) const = 0;
};
} // end namespace video
} // end namespace irr
#endif

View File

@ -0,0 +1,45 @@
// Copyright (C) 2002-2012 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_WRITER_H_INCLUDED__
#define _I_IMAGE_WRITER_H_INCLUDED__
#include "IReferenceCounted.h"
#include "irrString.h"
#include "coreutil.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:
//! Check if this writer can write a file with the given extension
/** \param filename Name of the file to check.
\return True if file extension specifies a writable type. */
virtual bool isAWriteableFileExtension(const io::path& filename) const = 0;
//! Write image to file
/** \param file File handle to write to.
\param image Image to write into file.
\param param Writer specific parameter, influencing e.g. quality.
\return True if image was successfully written. */
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,65 @@
// Copyright (C) 2008-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_INDEX_BUFFER_H_INCLUDED__
#define __I_INDEX_BUFFER_H_INCLUDED__
#include "IReferenceCounted.h"
#include "irrArray.h"
#include "SVertexIndex.h"
namespace irr
{
namespace video
{
}
namespace scene
{
class IIndexBuffer : public virtual IReferenceCounted
{
public:
virtual void* getData() =0;
virtual video::E_INDEX_TYPE getType() const =0;
virtual void setType(video::E_INDEX_TYPE IndexType) =0;
virtual u32 stride() const =0;
virtual u32 size() const =0;
virtual void push_back (const u32 &element) =0;
virtual u32 operator [](u32 index) const =0;
virtual u32 getLast() =0;
virtual void setValue(u32 index, u32 value) =0;
virtual void set_used(u32 usedNow) =0;
virtual void reallocate(u32 new_size) =0;
virtual u32 allocated_size() const=0;
virtual void* pointer() =0;
//! get the current hardware mapping hint
virtual E_HARDWARE_MAPPING getHardwareMappingHint() const =0;
//! set the hardware mapping hint, for driver
virtual void setHardwareMappingHint( E_HARDWARE_MAPPING NewMappingHint ) =0;
//! flags the meshbuffer as changed, reloads hardware buffers
virtual void setDirty() = 0;
//! Get the currently used ID for identification of changes.
/** This shouldn't be used for anything outside the VideoDriver. */
virtual u32 getChangedID() const = 0;
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,62 @@
// Written by Colin MacDonald - all rights assigned to Nikolaus Gebhardt
// Copyright (C) 2008-2012 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_MANAGER_H_INCLUDED__
#define __I_LIGHT_MANAGER_H_INCLUDED__
#include "IReferenceCounted.h"
#include "irrArray.h"
namespace irr
{
namespace scene
{
class ILightSceneNode;
//! ILightManager provides an interface for user applications to manipulate the list of lights in the scene.
/** The light list can be trimmed or re-ordered before device/ hardware
lights are created, and/or individual lights can be switched on and off
before or after each scene node is rendered. It is assumed that the
ILightManager implementation will store any data that it wishes to
retain, i.e. the ISceneManager to which it is assigned, the lightList,
the current render pass, and the current scene node. */
class ILightManager : public IReferenceCounted
{
public:
//! Called after the scene's light list has been built, but before rendering has begun.
/** As actual device/hardware lights are not created until the
ESNRP_LIGHT render pass, this provides an opportunity for the
light manager to trim or re-order the light list, before any
device/hardware lights have actually been created.
\param lightList: the Scene Manager's light list, which
the light manager may modify. This reference will remain valid
until OnPostRender().
*/
virtual void OnPreRender(core::array<ISceneNode*> & lightList) = 0;
//! Called after the last scene node is rendered.
/** After this call returns, the lightList passed to OnPreRender() becomes invalid. */
virtual void OnPostRender(void) = 0;
//! Called before a render pass begins
/** \param renderPass: the render pass that's about to begin */
virtual void OnRenderPassPreRender(E_SCENE_NODE_RENDER_PASS renderPass) = 0;
//! Called after the render pass specified in OnRenderPassPreRender() ends
/** \param[in] renderPass: the render pass that has finished */
virtual void OnRenderPassPostRender(E_SCENE_NODE_RENDER_PASS renderPass) = 0;
//! Called before the given scene node is rendered
/** \param[in] node: the scene node that's about to be rendered */
virtual void OnNodePreRender(ISceneNode* node) = 0;
//! Called after the the node specified in OnNodePreRender() has been rendered
/** \param[in] node: the scene node that has just been rendered */
virtual void OnNodePostRender(ISceneNode* node) = 0;
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,86 @@
// Copyright (C) 2002-2012 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. It can be
animated by ordinary scene node animators. If the light type is directional or
spot, the direction of the light source is defined by the rotation of the scene
node (assuming (0,0,1) as the local direction of the light).
*/
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
/** \param light The new light data. */
virtual void setLightData(const video::SLight& light) = 0;
//! Gets the light data associated with this ILightSceneNode
/** \return The light data. */
virtual const video::SLight& getLightData() const = 0;
//! Gets the light data associated with this ILightSceneNode
/** \return The light data. */
virtual video::SLight& getLightData() = 0;
//! Sets if the node should be visible or not.
/** All children of this node won't be visible either, when set
to true.
\param isVisible If the node shall be visible. */
virtual void setVisible(bool isVisible) = 0;
//! Sets the light's radius of influence.
/** Outside this radius the light won't lighten geometry and cast no
shadows. Setting the radius will also influence the attenuation, setting
it to (0,1/radius,0). If you want to override this behavior, set the
attenuation after the radius.
\param radius The new radius. */
virtual void setRadius(f32 radius) = 0;
//! Gets the light's radius of influence.
/** \return The current radius. */
virtual f32 getRadius() const = 0;
//! Sets the light type.
/** \param type The new type. */
virtual void setLightType(video::E_LIGHT_TYPE type) = 0;
//! Gets the light type.
/** \return The current light type. */
virtual video::E_LIGHT_TYPE getLightType() const = 0;
//! Sets whether this light casts shadows.
/** Enabling this flag won't automatically cast shadows, the meshes
will still need shadow scene nodes attached. But one can enable or
disable distinct lights for shadow casting for performance reasons.
\param shadow True if this light shall cast shadows. */
virtual void enableCastShadow(bool shadow=true) = 0;
//! Check whether this light casts shadows.
/** \return True if light would cast shadows, else false. */
virtual bool getCastShadow() const = 0;
};
} // end namespace scene
} // end namespace irr
#endif

102
include/irrlicht/ILogger.h Normal file
View File

@ -0,0 +1,102 @@
// Copyright (C) 2002-2012 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
{
//! Possible log levels.
//! When used has filter ELL_DEBUG means => log everything and ELL_NONE means => log (nearly) nothing.
//! When used to print logging information ELL_DEBUG will have lowest priority while ELL_NONE
//! messages are never filtered and always printed.
enum ELOG_LEVEL
{
//! Used for printing information helpful in debugging
ELL_DEBUG,
//! Useful information to print. For example hardware infos or something started/stopped.
ELL_INFORMATION,
//! Warnings that something isn't as expected and can cause oddities
ELL_WARNING,
//! Something did go wrong.
ELL_ERROR,
//! Logs with ELL_NONE will never be filtered.
//! And used as filter it will remove all logging except ELL_NONE messages.
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;
virtual void log(const c8* 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 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,101 @@
// Copyright (C) 2002-2012 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:
//! 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,115 @@
// Copyright (C) 2002-2012 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 "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.
\param material The new material to be used.
\param lastMaterial The material used until now.
\param resetAllRenderstates Set to true if all renderstates should be
set, regardless of their current state. */
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 True if successful.
*/
virtual bool setVertexShaderConstant(const c8* name, const f32* floats, int count) = 0;
//! Bool interface for the above.
virtual bool setVertexShaderConstant(const c8* name, const bool* bools, int count) = 0;
//! Int interface for the above.
virtual bool setVertexShaderConstant(const c8* name, const s32* ints, 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 True if successful. */
virtual bool setPixelShaderConstant(const c8* name, const f32* floats, int count) = 0;
//! Bool interface for the above.
virtual bool setPixelShaderConstant(const c8* name, const bool* bools, int count) = 0;
//! Int interface for the above.
virtual bool setPixelShaderConstant(const c8* name, const s32* ints, 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;
//! Get pointer to the IVideoDriver interface
/** \return Pointer to the IVideoDriver interface */
virtual IVideoDriver* getVideoDriver() = 0;
};
} // end namespace video
} // end namespace irr
#endif

75
include/irrlicht/IMesh.h Normal file
View File

@ -0,0 +1,75 @@
// Copyright (C) 2002-2012 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"
#include "EHardwareBufferFlags.h"
namespace irr
{
namespace scene
{
class IMeshBuffer;
//! Class which holds the geometry of an object.
/** An IMesh is nothing more than a collection of some mesh buffers
(IMeshBuffer). SMesh is a simple implementation of an IMesh.
A mesh is usually added to an IMeshSceneNode in order to be rendered.
*/
class IMesh : public virtual IReferenceCounted
{
public:
//! Get the amount of mesh buffers.
/** \return Amount of mesh buffers (IMeshBuffer) in this mesh. */
virtual u32 getMeshBufferCount() const = 0;
//! Get pointer to a mesh buffer.
/** \param nr: Zero based index of the mesh buffer. The maximum value is
getMeshBufferCount() - 1;
\return Pointer to the mesh buffer or 0 if there is no such
mesh buffer. */
virtual IMeshBuffer* getMeshBuffer(u32 nr) const = 0;
//! Get pointer to a mesh buffer which fits a material
/** \param material: material to search for
\return Pointer to the mesh buffer or 0 if there is no such
mesh buffer. */
virtual IMeshBuffer* getMeshBuffer( const video::SMaterial &material) const = 0;
//! Get an axis aligned bounding box of the mesh.
/** \return Bounding box of this mesh. */
virtual const core::aabbox3d<f32>& getBoundingBox() const = 0;
//! Set user-defined axis aligned bounding box
/** \param box New bounding box to use for the mesh. */
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;
//! Set the hardware mapping hint
/** This methods allows to define optimization hints for the
hardware. This enables, e.g., the use of hardware buffers on
pltforms that support this feature. This can lead to noticeable
performance gains. */
virtual void setHardwareMappingHint(E_HARDWARE_MAPPING newMappingHint, E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX) = 0;
//! Flag the meshbuffer as changed, reloads hardware buffers
/** This method has to be called every time the vertices or
indices have changed. Otherwise, changes won't be updated
on the GPU in the next render cycle. */
virtual void setDirty(E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX) = 0;
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,154 @@
// Copyright (C) 2002-2012 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"
#include "SVertexIndex.h"
#include "EHardwareBufferFlags.h"
#include "EPrimitiveTypes.h"
namespace irr
{
namespace scene
{
//! Struct for holding a mesh with a single material.
/** A part of an IMesh which has the same material on each face of that
group. Logical groups of an IMesh need not be put into separate mesh
buffers, but can be. Separately animated parts of the mesh must be put
into separate mesh buffers.
Some mesh buffer implementations have limitations on the number of
vertices the buffer can hold. In that case, logical grouping can help.
Moreover, the number of vertices should be optimized for the GPU upload,
which often depends on the type of gfx card. Typial figures are
1000-10000 vertices per buffer.
SMeshBuffer is a simple implementation of a MeshBuffer, which supports
up to 65535 vertices.
Since meshbuffers are used for drawing, and hence will be exposed
to the driver, chances are high that they are grab()'ed from somewhere.
It's therefore required to dynamically allocate meshbuffers which are
passed to a video driver and only drop the buffer once it's not used in
the current code block anymore.
*/
class IMeshBuffer : public virtual IReferenceCounted
{
public:
//! Get the material of this meshbuffer
/** \return Material of this buffer. */
virtual video::SMaterial& getMaterial() = 0;
//! Get the material of this meshbuffer
/** \return Material of this buffer. */
virtual const video::SMaterial& getMaterial() const = 0;
//! Get type of vertex data which is stored in this meshbuffer.
/** \return Vertex type of this buffer. */
virtual video::E_VERTEX_TYPE getVertexType() const = 0;
//! Get access to vertex data. The data is an array of vertices.
/** Which vertex type is used can be determined by getVertexType().
\return Pointer to array of vertices. */
virtual const void* getVertices() const = 0;
//! Get access to vertex data. The data is an array of vertices.
/** Which vertex type is used can be determined by getVertexType().
\return Pointer to array of vertices. */
virtual void* getVertices() = 0;
//! Get amount of vertices in meshbuffer.
/** \return Number of vertices in this buffer. */
virtual u32 getVertexCount() const = 0;
//! Get type of index data which is stored in this meshbuffer.
/** \return Index type of this buffer. */
virtual video::E_INDEX_TYPE getIndexType() const =0;
//! Get access to Indices.
/** \return Pointer to indices array. */
virtual const u16* getIndices() const = 0;
//! Get access to Indices.
/** \return Pointer to indices array. */
virtual u16* getIndices() = 0;
//! Get amount of indices in this meshbuffer.
/** \return Number of indices in this buffer. */
virtual u32 getIndexCount() const = 0;
//! Get the axis aligned bounding box of this meshbuffer.
/** \return Axis aligned bounding box of this buffer. */
virtual const core::aabbox3df& getBoundingBox() const = 0;
//! Set axis aligned bounding box
/** \param box User defined axis aligned bounding box to use
for this buffer. */
virtual void setBoundingBox(const core::aabbox3df& box) = 0;
//! Recalculates the bounding box. Should be called if the mesh changed.
virtual void recalculateBoundingBox() = 0;
//! returns position of vertex i
virtual const core::vector3df& getPosition(u32 i) const = 0;
//! returns position of vertex i
virtual core::vector3df& getPosition(u32 i) = 0;
//! returns normal of vertex i
virtual const core::vector3df& getNormal(u32 i) const = 0;
//! returns normal of vertex i
virtual core::vector3df& getNormal(u32 i) = 0;
//! returns texture coord of vertex i
virtual const core::vector2df& getTCoords(u32 i) const = 0;
//! returns texture coord of vertex i
virtual core::vector2df& getTCoords(u32 i) = 0;
//! Append the vertices and indices to the current buffer
/** Only works for compatible vertex types.
\param vertices Pointer to a vertex array.
\param numVertices Number of vertices in the array.
\param indices Pointer to index array.
\param numIndices Number of indices in array. */
virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices) = 0;
//! Append the meshbuffer to the current buffer
/** Only works for compatible vertex types
\param other Buffer to append to this one. */
virtual void append(const IMeshBuffer* const other) = 0;
//! get the current hardware mapping hint
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Vertex() const = 0;
//! get the current hardware mapping hint
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Index() const = 0;
//! set the hardware mapping hint, for driver
virtual void setHardwareMappingHint( E_HARDWARE_MAPPING newMappingHint, E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX ) = 0;
//! flags the meshbuffer as changed, reloads hardware buffers
virtual void setDirty(E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX) = 0;
//! Get the currently used ID for identification of changes.
/** This shouldn't be used for anything outside the VideoDriver. */
virtual u32 getChangedID_Vertex() const = 0;
//! Get the currently used ID for identification of changes.
/** This shouldn't be used for anything outside the VideoDriver. */
virtual u32 getChangedID_Index() const = 0;
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,177 @@
// Copyright (C) 2002-2012 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 "path.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 name Name of the mesh. When calling
ISceneManager::getMesh() with this name it will return the mesh
set by this method.
\param mesh Pointer to a mesh which will now be referenced by
this name. */
virtual void addMesh(const io::path& name, IAnimatedMesh* mesh) = 0;
//! Removes the 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.
\param mesh Pointer to the mesh which shall be removed. */
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 getMeshName().
\return Number of meshes in cache. */
virtual u32 getMeshCount() const = 0;
//! Returns current index number of the mesh or -1 when not found.
/** \param mesh Pointer to the mesh to search for.
\return Index of the mesh in the cache, or -1 if not found. */
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 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 name (often a filename).
/** \deprecated Use getMeshByName() instead. This method may be removed by
Irrlicht 1.9 */
_IRR_DEPRECATED_ IAnimatedMesh* getMeshByFilename(const io::path& filename)
{
return getMeshByName(filename);
}
//! Get the name of a loaded mesh, based on its index. (Name is often identical to the filename).
/** \deprecated Use getMeshName() instead. This method may be removed by
Irrlicht 1.9 */
_IRR_DEPRECATED_ const io::path& getMeshFilename(u32 index) const
{
return getMeshName(index).getInternalName();
}
//! Get the name of a loaded mesh, if there is any. (Name is often identical to the filename).
/** \deprecated Use getMeshName() instead. This method may be removed by
Irrlicht 1.9 */
_IRR_DEPRECATED_ const io::path& getMeshFilename(const IMesh* const mesh) const
{
return getMeshName(mesh).getInternalName();
}
//! Renames a loaded mesh.
/** \deprecated Use renameMesh() instead. This method may be removed by
Irrlicht 1.9 */
_IRR_DEPRECATED_ bool setMeshFilename(u32 index, const io::path& filename)
{
return renameMesh(index, filename);
}
//! Renames a loaded mesh.
/** \deprecated Use renameMesh() instead. This method may be removed by
Irrlicht 1.9 */
_IRR_DEPRECATED_ bool setMeshFilename(const IMesh* const mesh, const io::path& filename)
{
return renameMesh(mesh, filename);
}
//! Returns a mesh based on its name.
/** \param name Name of the mesh. Usually a filename.
\return Pointer to the mesh or 0 if there is none with this number. */
virtual IAnimatedMesh* getMeshByName(const io::path& name) = 0;
//! Get the name of a loaded mesh, based on its index.
/** \param index: Index of the mesh, number between 0 and getMeshCount()-1.
\return The name if mesh was found and has a name, else the path is empty. */
virtual const io::SNamedPath& getMeshName(u32 index) const = 0;
//! Get the name of the loaded mesh if there is any.
/** \param mesh Pointer to mesh to query.
\return The name if mesh was found and has a name, else the path is empty. */
virtual const io::SNamedPath& getMeshName(const IMesh* const mesh) const = 0;
//! Renames a loaded mesh.
/** 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.
\param index The index of the mesh in the cache.
\param name New name for the mesh.
\return True if mesh was renamed. */
virtual bool renameMesh(u32 index, const io::path& name) = 0;
//! Renames the loaded mesh
/** 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.
\param mesh Mesh to be renamed.
\param name New name for the mesh.
\return True if mesh was renamed. */
virtual bool renameMesh(const IMesh* const mesh, const io::path& name) = 0;
//! Check if a mesh was already loaded.
/** \param name Name of the mesh. Usually a filename.
\return True if the mesh has been loaded, else false. */
virtual bool isMeshLoaded(const io::path& name) = 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,53 @@
// Copyright (C) 2002-2012 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"
#include "path.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 Irrlicht be able to load meshes of
currently unsupported file formats (e.g. .cob), then implement
this and add your new Meshloader with
ISceneManager::addExternalMeshLoader() to the engine. */
class IMeshLoader : public virtual IReferenceCounted
{
public:
//! Destructor
virtual ~IMeshLoader() {}
//! Returns true if the file might be loaded by this class.
/** This decision should be based on the file extension (e.g. ".cob")
only.
\param filename Name of the file to test.
\return True if the file might be loaded by this class. */
virtual bool isALoadableFileExtension(const io::path& filename) const = 0;
//! Creates/loads an animated mesh from the file.
/** \param file File handler to load the file from.
\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,393 @@
// Copyright (C) 2002-2012 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 "IMeshBuffer.h"
#include "SVertexManipulator.h"
namespace irr
{
namespace scene
{
struct SMesh;
//! An interface for easy manipulation of 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:
//! 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. */
void setVertexColorAlpha(IMesh* mesh, s32 alpha) const
{
apply(scene::SVertexColorSetAlphaManipulator(alpha), mesh);
}
//! Sets the alpha vertex color value of the whole mesh to a new value.
/** \param buffer Meshbuffer on which the operation is performed.
\param alpha New alpha value. Must be a value between 0 and 255. */
void setVertexColorAlpha(IMeshBuffer* buffer, s32 alpha) const
{
apply(scene::SVertexColorSetAlphaManipulator(alpha), buffer);
}
//! Sets the colors of all vertices to one color
/** \param mesh Mesh on which the operation is performed.
\param color New color. */
void setVertexColors(IMesh* mesh, video::SColor color) const
{
apply(scene::SVertexColorSetManipulator(color), mesh);
}
//! Sets the colors of all vertices to one color
/** \param buffer Meshbuffer on which the operation is performed.
\param color New color. */
void setVertexColors(IMeshBuffer* buffer, video::SColor color) const
{
apply(scene::SVertexColorSetManipulator(color), buffer);
}
//! Recalculates all normals of the mesh.
/** \param mesh: Mesh on which the operation is performed.
\param smooth: If the normals shall be smoothed.
\param angleWeighted: If the normals shall be smoothed in relation to their angles. More expensive, but also higher precision. */
virtual void recalculateNormals(IMesh* mesh, bool smooth = false,
bool angleWeighted = 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.
\param angleWeighted: If the normals shall be smoothed in relation to their angles. More expensive, but also higher precision. */
virtual void recalculateNormals(IMeshBuffer* buffer,
bool smooth = false, bool angleWeighted = false) const=0;
//! Recalculates tangents, requires a tangent mesh
/** \param mesh Mesh on which the operation is performed.
\param recalculateNormals If the normals shall be recalculated, otherwise original normals of the mesh are used unchanged.
\param smooth If the normals shall be smoothed.
\param angleWeighted If the normals shall be smoothed in relation to their angles. More expensive, but also higher precision.
*/
virtual void recalculateTangents(IMesh* mesh,
bool recalculateNormals=false, bool smooth=false,
bool angleWeighted=false) const=0;
//! Recalculates tangents, requires a tangent mesh buffer
/** \param buffer Meshbuffer on which the operation is performed.
\param recalculateNormals If the normals shall be recalculated, otherwise original normals of the buffer are used unchanged.
\param smooth If the normals shall be smoothed.
\param angleWeighted If the normals shall be smoothed in relation to their angles. More expensive, but also higher precision.
*/
virtual void recalculateTangents(IMeshBuffer* buffer,
bool recalculateNormals=false, bool smooth=false,
bool angleWeighted=false) const=0;
//! Scales the actual mesh, not a scene node.
/** \param mesh Mesh on which the operation is performed.
\param factor Scale factor for each axis. */
void scale(IMesh* mesh, const core::vector3df& factor) const
{
apply(SVertexPositionScaleManipulator(factor), mesh, true);
}
//! Scales the actual meshbuffer, not a scene node.
/** \param buffer Meshbuffer on which the operation is performed.
\param factor Scale factor for each axis. */
void scale(IMeshBuffer* buffer, const core::vector3df& factor) const
{
apply(SVertexPositionScaleManipulator(factor), buffer, true);
}
//! Scales the actual mesh, not a scene node.
/** \deprecated Use scale() instead. This method may be removed by Irrlicht 1.9
\param mesh Mesh on which the operation is performed.
\param factor Scale factor for each axis. */
_IRR_DEPRECATED_ void scaleMesh(IMesh* mesh, const core::vector3df& factor) const {return scale(mesh,factor);}
//! Scale the texture coords of a mesh.
/** \param mesh Mesh on which the operation is performed.
\param factor Vector which defines the scale for each axis.
\param level Number of texture coord, starting from 1. Support for level 2 exists for LightMap buffers. */
void scaleTCoords(scene::IMesh* mesh, const core::vector2df& factor, u32 level=1) const
{
apply(SVertexTCoordsScaleManipulator(factor, level), mesh);
}
//! Scale the texture coords of a meshbuffer.
/** \param buffer Meshbuffer on which the operation is performed.
\param factor Vector which defines the scale for each axis.
\param level Number of texture coord, starting from 1. Support for level 2 exists for LightMap buffers. */
void scaleTCoords(scene::IMeshBuffer* buffer, const core::vector2df& factor, u32 level=1) const
{
apply(SVertexTCoordsScaleManipulator(factor, level), buffer);
}
//! Applies a transformation to a mesh
/** \param mesh Mesh on which the operation is performed.
\param m transformation matrix. */
void transform(IMesh* mesh, const core::matrix4& m) const
{
apply(SVertexPositionTransformManipulator(m), mesh, true);
}
//! Applies a transformation to a meshbuffer
/** \param buffer Meshbuffer on which the operation is performed.
\param m transformation matrix. */
void transform(IMeshBuffer* buffer, const core::matrix4& m) const
{
apply(SVertexPositionTransformManipulator(m), buffer, true);
}
//! Applies a transformation to a mesh
/** \deprecated Use transform() instead. This method may be removed by Irrlicht 1.9
\param mesh Mesh on which the operation is performed.
\param m transformation matrix. */
_IRR_DEPRECATED_ virtual void transformMesh(IMesh* mesh, const core::matrix4& m) const {return transform(mesh,m);}
//! 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 planar texture mapping on the meshbuffer
/** \param meshbuffer: Buffer 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(scene::IMeshBuffer* meshbuffer, f32 resolution=0.001f) const=0;
//! Creates a planar texture mapping on the buffer
/** This method is currently implemented towards the LWO planar mapping. A more general biasing might be required.
\param mesh Mesh on which the operation is performed.
\param resolutionS Resolution of the planar mapping in horizontal direction. This is the ratio between object space and texture space.
\param resolutionT Resolution of the planar mapping in vertical direction. This is the ratio between object space and texture space.
\param axis The axis along which the texture is projected. The allowed values are 0 (X), 1(Y), and 2(Z).
\param offset Vector added to the vertex positions (in object coordinates).
*/
virtual void makePlanarTextureMapping(scene::IMesh* mesh,
f32 resolutionS, f32 resolutionT,
u8 axis, const core::vector3df& offset) const=0;
//! Creates a planar texture mapping on the meshbuffer
/** This method is currently implemented towards the LWO planar mapping. A more general biasing might be required.
\param buffer Buffer on which the operation is performed.
\param resolutionS Resolution of the planar mapping in horizontal direction. This is the ratio between object space and texture space.
\param resolutionT Resolution of the planar mapping in vertical direction. This is the ratio between object space and texture space.
\param axis The axis along which the texture is projected. The allowed values are 0 (X), 1(Y), and 2(Z).
\param offset Vector added to the vertex positions (in object coordinates).
*/
virtual void makePlanarTextureMapping(scene::IMeshBuffer* buffer,
f32 resolutionS, f32 resolutionT,
u8 axis, const core::vector3df& offset) const=0;
//! Clones a static IMesh into a modifiable SMesh.
/** All meshbuffers in the returned SMesh
are of type SMeshBuffer or SMeshBufferLightMap.
\param mesh Mesh to copy.
\return 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 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
\param recalculateNormals The normals are recalculated if set,
otherwise the original ones are kept. Note that keeping the
normals may introduce inaccurate tangents if the normals are
very different to those calculated from the faces.
\param smooth The normals/tangents are smoothed across the
meshbuffer's faces if this flag is set.
\param angleWeighted Improved smoothing calculation used
\param recalculateTangents Whether are actually calculated, or just the mesh with proper type is created.
\return Mesh consisting 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,
bool recalculateNormals=false, bool smooth=false,
bool angleWeighted=false, bool recalculateTangents=true) const=0;
//! Creates a copy of the mesh, which will only consist of S3DVertex2TCoord vertices.
/** \param mesh Input mesh
\return Mesh consisting only of S3DVertex2TCoord vertices. If
you no longer need the cloned mesh, you should call
IMesh::drop(). See IReferenceCounted::drop() for more
information. */
virtual IMesh* createMeshWith2TCoords(IMesh* mesh) const = 0;
//! Creates a copy of the mesh, which will only consist of S3DVertex vertices.
/** \param mesh Input mesh
\return Mesh consisting only of S3DVertex vertices. If
you no longer need the cloned mesh, you should call
IMesh::drop(). See IReferenceCounted::drop() for more
information. */
virtual IMesh* createMeshWith1TCoords(IMesh* mesh) const = 0;
//! Creates a copy of a mesh with all vertices unwelded
/** \param mesh Input mesh
\return Mesh consisting only of unique faces. All vertices
which were previously shared are now duplicated. If you no
longer need the cloned mesh, you should call IMesh::drop(). See
IReferenceCounted::drop() for more information. */
virtual IMesh* createMeshUniquePrimitives(IMesh* mesh) const = 0;
//! Creates a copy of a mesh with vertices welded
/** \param mesh Input mesh
\param tolerance The threshold for vertex comparisons.
\return Mesh without redundant vertices. If you no longer need
the cloned mesh, you should call IMesh::drop(). See
IReferenceCounted::drop() for more information. */
virtual IMesh* createMeshWelded(IMesh* mesh, f32 tolerance=core::ROUNDING_ERROR_f32) const = 0;
//! Get amount of polygons in mesh.
/** \param mesh Input mesh
\return Number of polygons in mesh. */
virtual s32 getPolyCount(IMesh* mesh) const = 0;
//! Get amount of polygons in mesh.
/** \param mesh Input mesh
\return Number of polygons in mesh. */
virtual s32 getPolyCount(IAnimatedMesh* mesh) const = 0;
//! Create a new AnimatedMesh and adds the mesh to it
/** \param mesh Input mesh
\param type The type of the animated mesh to create.
\return Newly created animated mesh with mesh as its only
content. When you don't need the animated mesh anymore, you
should call IAnimatedMesh::drop(). See
IReferenceCounted::drop() for more information. */
virtual IAnimatedMesh * createAnimatedMesh(IMesh* mesh,
scene::E_ANIMATED_MESH_TYPE type = scene::EAMT_UNKNOWN) const = 0;
//! Vertex cache optimization according to the Forsyth paper
/** More information can be found at
http://home.comcast.net/~tom_forsyth/papers/fast_vert_cache_opt.html
The function is thread-safe (read: you can optimize several
meshes in different threads).
\param mesh Source mesh for the operation.
\return A new mesh optimized for the vertex cache. */
virtual IMesh* createForsythOptimizedMesh(const IMesh *mesh) const = 0;
//! Apply a manipulator on the Meshbuffer
/** \param func A functor defining the mesh manipulation.
\param buffer The Meshbuffer to apply the manipulator to.
\param boundingBoxUpdate Specifies if the bounding box should be updated during manipulation.
\return True if the functor was successfully applied, else false. */
template <typename Functor>
bool apply(const Functor& func, IMeshBuffer* buffer, bool boundingBoxUpdate=false) const
{
return apply_(func, buffer, boundingBoxUpdate, func);
}
//! Apply a manipulator on the Mesh
/** \param func A functor defining the mesh manipulation.
\param mesh The Mesh to apply the manipulator to.
\param boundingBoxUpdate Specifies if the bounding box should be updated during manipulation.
\return True if the functor was successfully applied, else false. */
template <typename Functor>
bool apply(const Functor& func, IMesh* mesh, bool boundingBoxUpdate=false) const
{
if (!mesh)
return true;
bool result = true;
core::aabbox3df bufferbox;
for (u32 i=0; i<mesh->getMeshBufferCount(); ++i)
{
result &= apply(func, mesh->getMeshBuffer(i), boundingBoxUpdate);
if (boundingBoxUpdate)
{
if (0==i)
bufferbox.reset(mesh->getMeshBuffer(i)->getBoundingBox());
else
bufferbox.addInternalBox(mesh->getMeshBuffer(i)->getBoundingBox());
}
}
if (boundingBoxUpdate)
mesh->setBoundingBox(bufferbox);
return result;
}
protected:
//! Apply a manipulator based on the type of the functor
/** \param func A functor defining the mesh manipulation.
\param buffer The Meshbuffer to apply the manipulator to.
\param boundingBoxUpdate Specifies if the bounding box should be updated during manipulation.
\param typeTest Unused parameter, which handles the proper call selection based on the type of the Functor which is passed in two times.
\return True if the functor was successfully applied, else false. */
template <typename Functor>
bool apply_(const Functor& func, IMeshBuffer* buffer, bool boundingBoxUpdate, const IVertexManipulator& typeTest) const
{
if (!buffer)
return true;
core::aabbox3df bufferbox;
for (u32 i=0; i<buffer->getVertexCount(); ++i)
{
switch (buffer->getVertexType())
{
case video::EVT_STANDARD:
{
video::S3DVertex* verts = (video::S3DVertex*)buffer->getVertices();
func(verts[i]);
}
break;
case video::EVT_2TCOORDS:
{
video::S3DVertex2TCoords* verts = (video::S3DVertex2TCoords*)buffer->getVertices();
func(verts[i]);
}
break;
case video::EVT_TANGENTS:
{
video::S3DVertexTangents* verts = (video::S3DVertexTangents*)buffer->getVertices();
func(verts[i]);
}
break;
}
if (boundingBoxUpdate)
{
if (0==i)
bufferbox.reset(buffer->getPosition(0));
else
bufferbox.addInternalPoint(buffer->getPosition(i));
}
}
if (boundingBoxUpdate)
buffer->setBoundingBox(bufferbox);
return true;
}
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,79 @@
// Copyright (C) 2002-2012 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 IShadowVolumeSceneNode;
class IMesh;
//! A scene node displaying a static mesh
class IMeshSceneNode : public ISceneNode
{
public:
//! Constructor
/** Use setMesh() to set the mesh to display.
*/
IMeshSceneNode(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,1,1))
: ISceneNode(parent, mgr, id, position, rotation, scale) {}
//! Sets a new mesh to display
/** \param mesh Mesh to display. */
virtual void setMesh(IMesh* mesh) = 0;
//! Get the currently defined mesh for display.
/** \return Pointer to mesh which is displayed by this node. */
virtual IMesh* getMesh(void) = 0;
//! Creates shadow volume scene node as child of this node.
/** 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 shadowMesh: Optional custom mesh for shadow volume.
\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 (for zfail shadow volume we support only
finite shadows, so camera zfar must be larger than shadow back cap,
which is depend on infinity parameter).
\return Pointer to the created shadow scene node. This pointer
should not be dropped. See IReferenceCounted::drop() for more
information. */
virtual IShadowVolumeSceneNode* addShadowVolumeSceneNode(const IMesh* shadowMesh=0,
s32 id=-1, bool zfailmethod=true, f32 infinity=1000.0f) = 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 of a mesh
causing all mesh scene nodes referencing this mesh to change, too.
\param readonly Flag if the materials shall be read-only. */
virtual void setReadOnlyMaterials(bool readonly) = 0;
//! Check if the scene node should not copy the materials of the mesh but use them in a read only style
/** This flag can be set by setReadOnlyMaterials().
\return Whether the materials are read-only. */
virtual bool isReadOnlyMaterials() const = 0;
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,58 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#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:
//! Destructor
virtual ~IMeshWriter() {}
//! Get 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.
\return Type of the mesh writer. */
virtual EMESH_WRITER_TYPE getType() const = 0;
//! Write a static mesh.
/** \param file File handle to write the mesh to.
\param mesh Pointer to mesh to be written.
\param flags Optional flags to set properties of the writer.
\return 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,43 @@
// Copyright (C) 2002-2012 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.
/** \param toAdd: Pointer to an triangle selector to add to the list. */
virtual void addTriangleSelector(ITriangleSelector* toAdd) = 0;
//! Removes a specific triangle selector from the collection.
/** \param toRemove: Pointer to an triangle selector which is in the
list but will be removed.
\return 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,50 @@
// Copyright (C) 2002-2012 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"
#include "irrString.h"
namespace irr
{
//! The Operating system operator provides operation system specific methods and informations.
class IOSOperator : public virtual IReferenceCounted
{
public:
//! Get the current operation system version as string.
virtual const core::stringc& getOperatingSystemVersion() const = 0;
//! Get the current operation system version as string.
/** \deprecated Use getOperatingSystemVersion instead. This method will be removed in Irrlicht 1.9. */
_IRR_DEPRECATED_ const wchar_t* getOperationSystemVersion() const
{
return core::stringw(getOperatingSystemVersion()).c_str();
}
//! Copies text to the clipboard
virtual void copyToClipboard(const c8* text) const = 0;
//! Get text from the clipboard
/** \return Returns 0 if no string is in there. */
virtual const c8* getTextFromClipboard() const = 0;
//! Get the processor speed in megahertz
/** \param MHz The integer variable to store the speed in.
\return True if successful, false if not */
virtual bool getProcessorSpeedMHz(u32* MHz) const = 0;
//! Get the total and available system RAM
/** \param Total: will contain the total system memory
\param Avail: will contain the available memory
\return True if successful, false if not */
virtual bool getSystemMemory(u32* Total, u32* Avail) const = 0;
};
} // end namespace
#endif

View File

@ -0,0 +1,72 @@
// Copyright (C) 2002-2012 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_SCALE,
EPAT_COUNT
};
//! Names for built in particle affectors
const c8* const ParticleAffectorTypeNames[] =
{
"None",
"Attract",
"FadeOut",
"Gravity",
"Rotate",
"Scale",
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; }
//! 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,54 @@
// Copyright (C) 2002-2012 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 or to pick min<->max vertices
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 or to pick min<->max vertices
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-2012 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-2012 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-2012 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,129 @@
// Copyright (C) 2002-2012 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
/** \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 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;
//! Set the maximum starting size for particles
virtual void setMaxStartSize( const core::dimension2df& size ) = 0;
//! Set the minimum starting size for particles
virtual void setMinStartSize( const core::dimension2df& size ) = 0;
//! Set the minimum particle life-time in milliseconds
virtual void setMinLifeTime( u32 lifeTimeMin ) = 0;
//! Set the maximum particle life-time in milliseconds
virtual void setMaxLifeTime( u32 lifeTimeMax ) = 0;
//! Set maximal random derivation from the direction
virtual void setMaxAngleDegrees( s32 maxAngleDegrees ) = 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;
//! Get the maximum starting size for particles
virtual const core::dimension2df& getMaxStartSize() const = 0;
//! Get the minimum starting size for particles
virtual const core::dimension2df& getMinStartSize() const = 0;
//! Get the minimum particle life-time in milliseconds
virtual u32 getMinLifeTime() const = 0;
//! Get the maximum particle life-time in milliseconds
virtual u32 getMaxLifeTime() const = 0;
//! Get maximal random derivation from the direction
virtual s32 getMaxAngleDegrees() const = 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,41 @@
// Copyright (C) 2002-2012 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 time in milliseconds it takes for each particle to fade out (minimal 1 ms)
virtual void setFadeOutTime( u32 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 time in milliseconds it takes for each particle to fade out.
virtual u32 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,42 @@
// Copyright (C) 2002-2012 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
/** At that point 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
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,54 @@
// Copyright (C) 2002-2012 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 or to pick min<->max vertices
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 or to pick min<->max vertices
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-2012 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

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