mirror of
https://github.com/minetest/irrlicht.git
synced 2025-07-03 00:30:26 +02:00
Compare commits
2 Commits
1.9.0mt4
...
bitmapfont
Author | SHA1 | Date | |
---|---|---|---|
853939405b | |||
9b0bc2aaed |
133
include/CDynamicMeshBuffer.h
Normal file
133
include/CDynamicMeshBuffer.h
Normal file
@ -0,0 +1,133 @@
|
||||
// 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)
|
||||
: PrimitiveType(EPT_TRIANGLES)
|
||||
{
|
||||
VertexBuffer=new CVertexBuffer(vertexType);
|
||||
IndexBuffer=new CIndexBuffer(indexType);
|
||||
}
|
||||
|
||||
//! destructor
|
||||
virtual ~CDynamicMeshBuffer()
|
||||
{
|
||||
if (VertexBuffer)
|
||||
VertexBuffer->drop();
|
||||
if (IndexBuffer)
|
||||
IndexBuffer->drop();
|
||||
}
|
||||
|
||||
virtual IVertexBuffer& getVertexBuffer() const _IRR_OVERRIDE_
|
||||
{
|
||||
return *VertexBuffer;
|
||||
}
|
||||
|
||||
virtual IIndexBuffer& getIndexBuffer() const _IRR_OVERRIDE_
|
||||
{
|
||||
return *IndexBuffer;
|
||||
}
|
||||
|
||||
virtual void setVertexBuffer(IVertexBuffer *newVertexBuffer) _IRR_OVERRIDE_
|
||||
{
|
||||
if (newVertexBuffer)
|
||||
newVertexBuffer->grab();
|
||||
if (VertexBuffer)
|
||||
VertexBuffer->drop();
|
||||
|
||||
VertexBuffer=newVertexBuffer;
|
||||
}
|
||||
|
||||
virtual void setIndexBuffer(IIndexBuffer *newIndexBuffer) _IRR_OVERRIDE_
|
||||
{
|
||||
if (newIndexBuffer)
|
||||
newIndexBuffer->grab();
|
||||
if (IndexBuffer)
|
||||
IndexBuffer->drop();
|
||||
|
||||
IndexBuffer=newIndexBuffer;
|
||||
}
|
||||
|
||||
//! Get Material of this buffer.
|
||||
virtual const video::SMaterial& getMaterial() const _IRR_OVERRIDE_
|
||||
{
|
||||
return Material;
|
||||
}
|
||||
|
||||
//! Get Material of this buffer.
|
||||
virtual video::SMaterial& getMaterial() _IRR_OVERRIDE_
|
||||
{
|
||||
return Material;
|
||||
}
|
||||
|
||||
//! Get bounding box
|
||||
virtual const core::aabbox3d<f32>& getBoundingBox() const _IRR_OVERRIDE_
|
||||
{
|
||||
return BoundingBox;
|
||||
}
|
||||
|
||||
//! Set bounding box
|
||||
virtual void setBoundingBox( const core::aabbox3df& box) _IRR_OVERRIDE_
|
||||
{
|
||||
BoundingBox = box;
|
||||
}
|
||||
|
||||
//! Recalculate bounding box
|
||||
virtual void recalculateBoundingBox() _IRR_OVERRIDE_
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
//! Describe what kind of primitive geometry is used by the meshbuffer
|
||||
virtual void setPrimitiveType(E_PRIMITIVE_TYPE type) _IRR_OVERRIDE_
|
||||
{
|
||||
PrimitiveType = type;
|
||||
}
|
||||
|
||||
//! Get the kind of primitive geometry which is used by the meshbuffer
|
||||
virtual E_PRIMITIVE_TYPE getPrimitiveType() const _IRR_OVERRIDE_
|
||||
{
|
||||
return PrimitiveType;
|
||||
}
|
||||
|
||||
video::SMaterial Material;
|
||||
core::aabbox3d<f32> BoundingBox;
|
||||
//! Primitive type used for rendering (triangles, lines, ...)
|
||||
E_PRIMITIVE_TYPE PrimitiveType;
|
||||
private:
|
||||
CDynamicMeshBuffer(const CDynamicMeshBuffer&); // = delete in c++11, prevent copying
|
||||
|
||||
IVertexBuffer *VertexBuffer;
|
||||
IIndexBuffer *IndexBuffer;
|
||||
};
|
||||
|
||||
|
||||
} // end namespace scene
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
|
@ -121,6 +121,71 @@ namespace video
|
||||
texture which will not reflect can be set as second texture.*/
|
||||
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.
|
||||
The blend function is set to SMaterial::MaterialTypeParam with
|
||||
@ -151,6 +216,12 @@ namespace video
|
||||
"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
|
||||
};
|
||||
|
36
include/ETerrainElements.h
Normal file
36
include/ETerrainElements.h
Normal 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
|
||||
|
71
include/IAttributeExchangingObject.h
Normal file
71
include/IAttributeExchangingObject.h
Normal 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
|
||||
|
@ -125,9 +125,133 @@ public:
|
||||
//! 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.
|
||||
//! \param defaultNotFound Value returned when attributeName was not found
|
||||
//! \return Returns value of the attribute previously set by setAttribute()
|
||||
//! or defaultNotFound if attribute is not set.
|
||||
virtual core::stringc getAttributeAsString(const c8* attributeName, const core::stringc& defaultNotFound=core::stringc()) const = 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) const = 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) const = 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.
|
||||
//! \param defaultNotFound Value returned when attributeName was not found
|
||||
//! \return Returns value of the attribute previously set by setAttribute()
|
||||
//! or defaultNotFound if attribute is not set.
|
||||
virtual core::stringw getAttributeAsStringW(const c8* attributeName, const core::stringw& defaultNotFound = core::stringw()) const = 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) const = 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) const = 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) const = 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) const = 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.
|
||||
//! \param defaultNotFound Value returned when attributeName was not found
|
||||
//! \return Returns value of the attribute previously set by setAttribute()
|
||||
//! or defaultNotFound if attribute is not set.
|
||||
virtual core::array<core::stringw> getAttributeAsArray(const c8* attributeName, const core::array<core::stringw>& defaultNotFound = core::array<core::stringw>()) const = 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) const = 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
|
||||
@ -149,9 +273,476 @@ public:
|
||||
//! 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.
|
||||
//! \param defaultNotFound Value returned when attributeName was not found
|
||||
//! \return Returns value of the attribute previously set by setAttribute()
|
||||
virtual const c8* getAttributeAsEnumeration(const c8* attributeName, const c8* defaultNotFound = 0) const = 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, s32 defaultNotFound = -1) const = 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.
|
||||
\param defaultNotFound Value returned when the attribute referenced by the index was not found.
|
||||
\return Returns value of the attribute previously set by setAttribute()
|
||||
*/
|
||||
virtual s32 getAttributeAsEnumeration(s32 index, const c8* const* enumerationLiteralsToUse, s32 defaultNotFound = -1) const = 0;
|
||||
|
||||
//! Gets an attribute as enumeration
|
||||
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
|
||||
virtual const c8* getAttributeAsEnumeration(s32 index) const = 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) const = 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) const = 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.
|
||||
//! \param defaultNotFound Value returned when attributeName was not found
|
||||
//! \return Returns value of the attribute previously set by setAttribute()
|
||||
virtual video::SColor getAttributeAsColor(const c8* attributeName, const video::SColor& defaultNotFound = video::SColor(0)) const = 0;
|
||||
|
||||
//! Gets an attribute as color
|
||||
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
|
||||
virtual video::SColor getAttributeAsColor(s32 index) const = 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.
|
||||
//! \param defaultNotFound Value returned when attributeName was not found
|
||||
//! \return Returns value of the attribute previously set by setAttribute()
|
||||
virtual video::SColorf getAttributeAsColorf(const c8* attributeName, const video::SColorf& defaultNotFound = video::SColorf(0)) const = 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) const = 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, const core::vector3df& value) = 0;
|
||||
|
||||
//! Sets a attribute as 3d vector
|
||||
virtual void setAttribute(const c8* attributeName, const core::vector3df& v) = 0;
|
||||
|
||||
//! Gets an attribute as 3d vector
|
||||
//! \param attributeName: Name of the attribute to get.
|
||||
//! \param defaultNotFound Value returned when attributeName was not found
|
||||
//! \return Returns value of the attribute previously set by setAttribute()
|
||||
virtual core::vector3df getAttributeAsVector3d(const c8* attributeName, const core::vector3df& defaultNotFound=core::vector3df(0,0,0)) const = 0;
|
||||
|
||||
//! Gets an attribute as 3d vector
|
||||
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
|
||||
virtual core::vector3df getAttributeAsVector3d(s32 index) const = 0;
|
||||
|
||||
//! Sets an attribute as vector
|
||||
virtual void setAttribute(s32 index, const core::vector3df& v) = 0;
|
||||
|
||||
/*
|
||||
|
||||
Vector2d Attribute
|
||||
|
||||
*/
|
||||
|
||||
//! Adds an attribute as 2d vector
|
||||
virtual void addVector2d(const c8* attributeName, const core::vector2df& value) = 0;
|
||||
|
||||
//! Sets a attribute as 2d vector
|
||||
virtual void setAttribute(const c8* attributeName, const core::vector2df& v) = 0;
|
||||
|
||||
//! Gets an attribute as vector
|
||||
//! \param attributeName: Name of the attribute to get.
|
||||
//! \param defaultNotFound Value returned when attributeName was not found
|
||||
//! \return Returns value of the attribute previously set by setAttribute()
|
||||
virtual core::vector2df getAttributeAsVector2d(const c8* attributeName, const core::vector2df& defaultNotFound=core::vector2df(0,0)) const = 0;
|
||||
|
||||
//! Gets an attribute as position
|
||||
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
|
||||
virtual core::vector2df getAttributeAsVector2d(s32 index) const = 0;
|
||||
|
||||
//! Sets an attribute as 2d vector
|
||||
virtual void setAttribute(s32 index, const core::vector2df& v) = 0;
|
||||
|
||||
/*
|
||||
|
||||
Position2d Attribute
|
||||
|
||||
*/
|
||||
|
||||
//! Adds an attribute as 2d position
|
||||
virtual void addPosition2d(const c8* attributeName, const core::position2di& value) = 0;
|
||||
|
||||
//! Sets a attribute as 2d position
|
||||
virtual void setAttribute(const c8* attributeName, const core::position2di& v) = 0;
|
||||
|
||||
//! Gets an attribute as position
|
||||
//! \param attributeName: Name of the attribute to get.
|
||||
//! \param defaultNotFound Value returned when attributeName was not found
|
||||
//! \return Returns value of the attribute previously set by setAttribute()
|
||||
virtual core::position2di getAttributeAsPosition2d(const c8* attributeName, const core::position2di& defaultNotFound=core::position2di(0,0)) const = 0;
|
||||
|
||||
//! Gets an attribute as position
|
||||
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
|
||||
virtual core::position2di getAttributeAsPosition2d(s32 index) const = 0;
|
||||
|
||||
//! Sets an attribute as 2d position
|
||||
virtual void setAttribute(s32 index, const core::position2di& v) = 0;
|
||||
|
||||
/*
|
||||
|
||||
Rectangle Attribute
|
||||
|
||||
*/
|
||||
|
||||
//! Adds an attribute as rectangle
|
||||
virtual void addRect(const c8* attributeName, const core::rect<s32>& value) = 0;
|
||||
|
||||
//! Sets an attribute as rectangle
|
||||
virtual void setAttribute(const c8* attributeName, const core::rect<s32>& v) = 0;
|
||||
|
||||
//! Gets an attribute as rectangle
|
||||
//! \param attributeName: Name of the attribute to get.
|
||||
//! \param defaultNotFound Value returned when attributeName was not found
|
||||
//! \return Returns value of the attribute previously set by setAttribute()
|
||||
virtual core::rect<s32> getAttributeAsRect(const c8* attributeName, const core::rect<s32>& defaultNotFound = core::rect<s32>()) const = 0;
|
||||
|
||||
//! Gets an attribute as rectangle
|
||||
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
|
||||
virtual core::rect<s32> getAttributeAsRect(s32 index) const = 0;
|
||||
|
||||
//! Sets an attribute as rectangle
|
||||
virtual void setAttribute(s32 index, const core::rect<s32>& v) = 0;
|
||||
|
||||
|
||||
/*
|
||||
|
||||
Dimension2d Attribute
|
||||
|
||||
*/
|
||||
|
||||
//! Adds an attribute as dimension2d
|
||||
virtual void addDimension2d(const c8* attributeName, const core::dimension2d<u32>& value) = 0;
|
||||
|
||||
//! Sets an attribute as dimension2d
|
||||
virtual void setAttribute(const c8* attributeName, const core::dimension2d<u32>& v) = 0;
|
||||
|
||||
//! Gets an attribute as dimension2d
|
||||
//! \param attributeName: Name of the attribute to get.
|
||||
//! \param defaultNotFound Value returned when attributeName was not found
|
||||
//! \return Returns value of the attribute previously set by setAttribute()
|
||||
virtual core::dimension2d<u32> getAttributeAsDimension2d(const c8* attributeName, const core::dimension2d<u32>& defaultNotFound = core::dimension2d<u32>()) const = 0;
|
||||
|
||||
//! Gets an attribute as dimension2d
|
||||
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
|
||||
virtual core::dimension2d<u32> getAttributeAsDimension2d(s32 index) const = 0;
|
||||
|
||||
//! Sets an attribute as dimension2d
|
||||
virtual void setAttribute(s32 index, const 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.
|
||||
//! \param defaultNotFound Value returned when attributeName was not found
|
||||
//! \return Returns value of the attribute previously set by setAttribute()
|
||||
virtual core::matrix4 getAttributeAsMatrix(const c8* attributeName, const core::matrix4& defaultNotFound=core::matrix4()) const = 0;
|
||||
|
||||
//! Gets an attribute as matrix
|
||||
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
|
||||
virtual core::matrix4 getAttributeAsMatrix(s32 index) const = 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, const core::quaternion& v) = 0;
|
||||
|
||||
//! Sets an attribute as quaternion
|
||||
virtual void setAttribute(const c8* attributeName, const core::quaternion& v) = 0;
|
||||
|
||||
//! Gets an attribute as a quaternion
|
||||
//! \param attributeName: Name of the attribute to get.
|
||||
//! \param defaultNotFound Value returned when attributeName was not found
|
||||
//! \return Returns value of the attribute previously set by setAttribute()
|
||||
virtual core::quaternion getAttributeAsQuaternion(const c8* attributeName, const core::quaternion& defaultNotFound=core::quaternion(0,1,0, 0)) const = 0;
|
||||
|
||||
//! Gets an attribute as quaternion
|
||||
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
|
||||
virtual core::quaternion getAttributeAsQuaternion(s32 index) const = 0;
|
||||
|
||||
//! Sets an attribute as quaternion
|
||||
virtual void setAttribute(s32 index, const core::quaternion& v) = 0;
|
||||
|
||||
/*
|
||||
|
||||
3d bounding box
|
||||
|
||||
*/
|
||||
|
||||
//! Adds an attribute as axis aligned bounding box
|
||||
virtual void addBox3d(const c8* attributeName, const core::aabbox3df& v) = 0;
|
||||
|
||||
//! Sets an attribute as axis aligned bounding box
|
||||
virtual void setAttribute(const c8* attributeName, const core::aabbox3df& v) = 0;
|
||||
|
||||
//! Gets an attribute as a axis aligned bounding box
|
||||
//! \param attributeName: Name of the attribute to get.
|
||||
//! \param defaultNotFound Value returned when attributeName was not found
|
||||
//! \return Returns value of the attribute previously set by setAttribute()
|
||||
virtual core::aabbox3df getAttributeAsBox3d(const c8* attributeName, const core::aabbox3df& defaultNotFound=core::aabbox3df(0,0,0, 0,0,0)) const = 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) const = 0;
|
||||
|
||||
//! Sets an attribute as axis aligned bounding box
|
||||
virtual void setAttribute(s32 index, const core::aabbox3df& v) = 0;
|
||||
|
||||
/*
|
||||
|
||||
plane
|
||||
|
||||
*/
|
||||
|
||||
//! Adds an attribute as 3d plane
|
||||
virtual void addPlane3d(const c8* attributeName, const core::plane3df& v) = 0;
|
||||
|
||||
//! Sets an attribute as 3d plane
|
||||
virtual void setAttribute(const c8* attributeName, const core::plane3df& v) = 0;
|
||||
|
||||
//! Gets an attribute as a 3d plane
|
||||
//! \param attributeName: Name of the attribute to get.
|
||||
//! \param defaultNotFound Value returned when attributeName was not found
|
||||
//! \return Returns value of the attribute previously set by setAttribute()
|
||||
virtual core::plane3df getAttributeAsPlane3d(const c8* attributeName, const core::plane3df& defaultNotFound=core::plane3df(0,0,0, 0,1,0)) const = 0;
|
||||
|
||||
//! Gets an attribute as 3d plane
|
||||
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
|
||||
virtual core::plane3df getAttributeAsPlane3d(s32 index) const = 0;
|
||||
|
||||
//! Sets an attribute as 3d plane
|
||||
virtual void setAttribute(s32 index, const core::plane3df& v) = 0;
|
||||
|
||||
|
||||
/*
|
||||
|
||||
3d triangle
|
||||
|
||||
*/
|
||||
|
||||
//! Adds an attribute as 3d triangle
|
||||
virtual void addTriangle3d(const c8* attributeName, const core::triangle3df& v) = 0;
|
||||
|
||||
//! Sets an attribute as 3d trianle
|
||||
virtual void setAttribute(const c8* attributeName, const core::triangle3df& v) = 0;
|
||||
|
||||
//! Gets an attribute as a 3d triangle
|
||||
//! \param attributeName: Name of the attribute to get.
|
||||
//! \param defaultNotFound Value returned when attributeName was not found
|
||||
//! \return Returns value of the attribute previously set by setAttribute()
|
||||
virtual core::triangle3df getAttributeAsTriangle3d(const c8* attributeName, const core::triangle3df& defaultNotFound = core::triangle3df(core::vector3df(0,0,0), core::vector3df(0,0,0), core::vector3df(0,0,0))) const = 0;
|
||||
|
||||
//! Gets an attribute as 3d triangle
|
||||
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
|
||||
virtual core::triangle3df getAttributeAsTriangle3d(s32 index) const = 0;
|
||||
|
||||
//! Sets an attribute as 3d triangle
|
||||
virtual void setAttribute(s32 index, const core::triangle3df& v) = 0;
|
||||
|
||||
|
||||
/*
|
||||
|
||||
line 2d
|
||||
|
||||
*/
|
||||
|
||||
//! Adds an attribute as a 2d line
|
||||
virtual void addLine2d(const c8* attributeName, const core::line2df& v) = 0;
|
||||
|
||||
//! Sets an attribute as a 2d line
|
||||
virtual void setAttribute(const c8* attributeName, const core::line2df& v) = 0;
|
||||
|
||||
//! Gets an attribute as a 2d line
|
||||
//! \param attributeName: Name of the attribute to get.
|
||||
//! \param defaultNotFound Value returned when attributeName was not found
|
||||
//! \return Returns value of the attribute previously set by setAttribute()
|
||||
virtual core::line2df getAttributeAsLine2d(const c8* attributeName, const core::line2df& defaultNotFound = core::line2df(0,0, 0,0)) const = 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) const = 0;
|
||||
|
||||
//! Sets an attribute as a 2d line
|
||||
virtual void setAttribute(s32 index, const core::line2df& v) = 0;
|
||||
|
||||
|
||||
/*
|
||||
|
||||
line 3d
|
||||
|
||||
*/
|
||||
|
||||
//! Adds an attribute as a 3d line
|
||||
virtual void addLine3d(const c8* attributeName, const core::line3df& v) = 0;
|
||||
|
||||
//! Sets an attribute as a 3d line
|
||||
virtual void setAttribute(const c8* attributeName, const core::line3df& v) = 0;
|
||||
|
||||
//! Gets an attribute as a 3d line
|
||||
//! \param attributeName: Name of the attribute to get.
|
||||
//! \param defaultNotFound Value returned when attributeName was not found
|
||||
//! \return Returns value of the attribute previously set by setAttribute()
|
||||
virtual core::line3df getAttributeAsLine3d(const c8* attributeName, const core::line3df& defaultNotFound=core::line3df(0,0,0, 0,0,0)) const = 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) const = 0;
|
||||
|
||||
//! Sets an attribute as a 3d line
|
||||
virtual void setAttribute(s32 index, const 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.
|
||||
//! \param defaultNotFound Value returned when attributeName was not found
|
||||
virtual video::ITexture* getAttributeAsTexture(const c8* attributeName, video::ITexture* defaultNotFound=0) const = 0;
|
||||
|
||||
//! Gets an attribute as texture reference
|
||||
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
|
||||
virtual video::ITexture* getAttributeAsTexture(s32 index) const = 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 pointer
|
||||
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.
|
||||
//! \param defaultNotFound Value returned when attributeName was not found
|
||||
virtual void* getAttributeAsUserPointer(const c8* attributeName, void* defaultNotFound = 0) const = 0;
|
||||
|
||||
//! Gets an attribute as user pointer
|
||||
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
|
||||
virtual void* getAttributeAsUserPointer(s32 index) const = 0;
|
||||
|
||||
//! Sets an attribute as user pointer
|
||||
virtual void setAttribute(s32 index, void* userPointer) = 0;
|
||||
|
||||
};
|
||||
|
||||
} // end namespace io
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
@ -172,6 +172,27 @@ namespace scene
|
||||
/** @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 _IRR_OVERRIDE_
|
||||
{
|
||||
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) _IRR_OVERRIDE_
|
||||
{
|
||||
ISceneNode::deserializeAttributes(in, options);
|
||||
if (!in)
|
||||
return;
|
||||
|
||||
if ( in->findAttribute("IsOrthogonal") )
|
||||
IsOrthogonal = in->getAttributeAsBool("IsOrthogonal");
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
void cloneMembers(const ICameraSceneNode* toCopyFrom)
|
||||
|
211
include/IDynamicMeshBuffer.h
Normal file
211
include/IDynamicMeshBuffer.h
Normal 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() _IRR_OVERRIDE_ =0;
|
||||
|
||||
//! Get the material of this meshbuffer
|
||||
/** \return Material of this buffer. */
|
||||
virtual const video::SMaterial& getMaterial() const _IRR_OVERRIDE_ =0;
|
||||
|
||||
//! Get the axis aligned bounding box of this meshbuffer.
|
||||
/** \return Axis aligned bounding box of this buffer. */
|
||||
virtual const core::aabbox3df& getBoundingBox() const _IRR_OVERRIDE_ =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) _IRR_OVERRIDE_ =0;
|
||||
|
||||
//! Recalculates the bounding box. Should be called if the mesh changed.
|
||||
virtual void recalculateBoundingBox() _IRR_OVERRIDE_ =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) _IRR_OVERRIDE_
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//! 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) _IRR_OVERRIDE_
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// ------------------- To be removed? ------------------- //
|
||||
|
||||
//! get the current hardware mapping hint
|
||||
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Vertex() const _IRR_OVERRIDE_
|
||||
{
|
||||
return getVertexBuffer().getHardwareMappingHint();
|
||||
}
|
||||
|
||||
//! get the current hardware mapping hint
|
||||
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Index() const _IRR_OVERRIDE_
|
||||
{
|
||||
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 ) _IRR_OVERRIDE_
|
||||
{
|
||||
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) _IRR_OVERRIDE_
|
||||
{
|
||||
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 _IRR_OVERRIDE_
|
||||
{
|
||||
return getVertexBuffer().getChangedID();
|
||||
}
|
||||
|
||||
virtual u32 getChangedID_Index() const _IRR_OVERRIDE_
|
||||
{
|
||||
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 _IRR_OVERRIDE_
|
||||
{
|
||||
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 _IRR_OVERRIDE_
|
||||
{
|
||||
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() _IRR_OVERRIDE_
|
||||
{
|
||||
return getVertexBuffer().getData();
|
||||
}
|
||||
|
||||
//! Get amount of vertices in meshbuffer.
|
||||
/** \return Number of vertices in this buffer. */
|
||||
virtual u32 getVertexCount() const _IRR_OVERRIDE_
|
||||
{
|
||||
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 _IRR_OVERRIDE_
|
||||
{
|
||||
return getIndexBuffer().getType();
|
||||
}
|
||||
|
||||
//! Get access to indices.
|
||||
/** \return Pointer to indices array. */
|
||||
virtual const u16* getIndices() const _IRR_OVERRIDE_
|
||||
{
|
||||
return (u16*)getIndexBuffer().getData();
|
||||
}
|
||||
|
||||
//! Get access to indices.
|
||||
/** \return Pointer to indices array. */
|
||||
virtual u16* getIndices() _IRR_OVERRIDE_
|
||||
{
|
||||
return (u16*)getIndexBuffer().getData();
|
||||
}
|
||||
|
||||
//! Get amount of indices in this meshbuffer.
|
||||
/** \return Number of indices in this buffer. */
|
||||
virtual u32 getIndexCount() const _IRR_OVERRIDE_
|
||||
{
|
||||
return getIndexBuffer().size();
|
||||
}
|
||||
|
||||
//! returns position of vertex i
|
||||
virtual const core::vector3df& getPosition(u32 i) const _IRR_OVERRIDE_
|
||||
{
|
||||
return getVertexBuffer()[i].Pos;
|
||||
}
|
||||
|
||||
//! returns position of vertex i
|
||||
virtual core::vector3df& getPosition(u32 i) _IRR_OVERRIDE_
|
||||
{
|
||||
return getVertexBuffer()[i].Pos;
|
||||
}
|
||||
|
||||
//! returns texture coords of vertex i
|
||||
virtual const core::vector2df& getTCoords(u32 i) const _IRR_OVERRIDE_
|
||||
{
|
||||
return getVertexBuffer()[i].TCoords;
|
||||
}
|
||||
|
||||
//! returns texture coords of vertex i
|
||||
virtual core::vector2df& getTCoords(u32 i) _IRR_OVERRIDE_
|
||||
{
|
||||
return getVertexBuffer()[i].TCoords;
|
||||
}
|
||||
|
||||
//! returns normal of vertex i
|
||||
virtual const core::vector3df& getNormal(u32 i) const _IRR_OVERRIDE_
|
||||
{
|
||||
return getVertexBuffer()[i].Normal;
|
||||
}
|
||||
|
||||
//! returns normal of vertex i
|
||||
virtual core::vector3df& getNormal(u32 i) _IRR_OVERRIDE_
|
||||
{
|
||||
return getVertexBuffer()[i].Normal;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // end namespace scene
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -315,6 +315,14 @@ public:
|
||||
/** \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 occurred. */
|
||||
virtual bool existFile(const path& filename) const =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;
|
||||
};
|
||||
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
#ifndef __I_GUI_ELEMENT_H_INCLUDED__
|
||||
#define __I_GUI_ELEMENT_H_INCLUDED__
|
||||
|
||||
#include "IReferenceCounted.h"
|
||||
#include "IAttributeExchangingObject.h"
|
||||
#include "irrList.h"
|
||||
#include "rect.h"
|
||||
#include "irrString.h"
|
||||
@ -20,7 +20,7 @@ namespace irr
|
||||
namespace gui
|
||||
{
|
||||
//! Base class of all GUI elements.
|
||||
class IGUIElement : virtual public IReferenceCounted, public IEventReceiver
|
||||
class IGUIElement : public virtual io::IAttributeExchangingObject, public IEventReceiver
|
||||
{
|
||||
public:
|
||||
|
||||
@ -210,25 +210,25 @@ public:
|
||||
}
|
||||
|
||||
//! How left element border is aligned when parent is resized
|
||||
EGUI_ALIGNMENT getAlignLeft() const
|
||||
EGUI_ALIGNMENT getAlignLeft() const
|
||||
{
|
||||
return AlignLeft;
|
||||
}
|
||||
|
||||
//! How right element border is aligned when parent is resized
|
||||
EGUI_ALIGNMENT getAlignRight() const
|
||||
EGUI_ALIGNMENT getAlignRight() const
|
||||
{
|
||||
return AlignRight;
|
||||
}
|
||||
|
||||
//! How top element border is aligned when parent is resized
|
||||
EGUI_ALIGNMENT getAlignTop() const
|
||||
EGUI_ALIGNMENT getAlignTop() const
|
||||
{
|
||||
return AlignTop;
|
||||
}
|
||||
|
||||
//! How bottom element border is aligned when parent is resized
|
||||
EGUI_ALIGNMENT getAlignBottom() const
|
||||
EGUI_ALIGNMENT getAlignBottom() const
|
||||
{
|
||||
return AlignBottom;
|
||||
}
|
||||
@ -796,6 +796,62 @@ public:
|
||||
}
|
||||
|
||||
|
||||
//! Writes attributes of the scene node.
|
||||
/** Implement this to expose the attributes of your scene node for
|
||||
scripting languages, editors, debuggers or xml serialization purposes. */
|
||||
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const _IRR_OVERRIDE_
|
||||
{
|
||||
out->addString("Name", Name.c_str());
|
||||
out->addInt("Id", ID );
|
||||
out->addString("Caption", getText());
|
||||
out->addString("ToolTip", getToolTipText().c_str());
|
||||
out->addRect("Rect", DesiredRect);
|
||||
out->addPosition2d("MinSize", core::position2di(MinSize.Width, MinSize.Height));
|
||||
out->addPosition2d("MaxSize", core::position2di(MaxSize.Width, MaxSize.Height));
|
||||
out->addEnum("LeftAlign", AlignLeft, GUIAlignmentNames);
|
||||
out->addEnum("RightAlign", AlignRight, GUIAlignmentNames);
|
||||
out->addEnum("TopAlign", AlignTop, GUIAlignmentNames);
|
||||
out->addEnum("BottomAlign", AlignBottom, GUIAlignmentNames);
|
||||
out->addBool("Visible", IsVisible);
|
||||
out->addBool("Enabled", IsEnabled);
|
||||
out->addBool("TabStop", IsTabStop);
|
||||
out->addBool("TabGroup", IsTabGroup);
|
||||
out->addInt("TabOrder", TabOrder);
|
||||
out->addBool("NoClip", NoClip);
|
||||
}
|
||||
|
||||
|
||||
//! Reads attributes of the scene node.
|
||||
/** Implement this to set the attributes of your scene node for
|
||||
scripting languages, editors, debuggers or xml deserialization purposes. */
|
||||
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) _IRR_OVERRIDE_
|
||||
{
|
||||
setName(in->getAttributeAsString("Name", Name));
|
||||
setID(in->getAttributeAsInt("Id", ID));
|
||||
setText(in->getAttributeAsStringW("Caption", Text).c_str());
|
||||
setToolTipText(in->getAttributeAsStringW("ToolTip").c_str());
|
||||
setVisible(in->getAttributeAsBool("Visible", IsVisible));
|
||||
setEnabled(in->getAttributeAsBool("Enabled", IsEnabled));
|
||||
IsTabStop = in->getAttributeAsBool("TabStop", IsTabStop);
|
||||
IsTabGroup = in->getAttributeAsBool("TabGroup", IsTabGroup);
|
||||
TabOrder = in->getAttributeAsInt("TabOrder", TabOrder);
|
||||
|
||||
core::position2di p = in->getAttributeAsPosition2d("MaxSize", core::position2di(MaxSize.Width, MaxSize.Height));
|
||||
setMaxSize(core::dimension2du(p.X,p.Y));
|
||||
|
||||
p = in->getAttributeAsPosition2d("MinSize", core::position2di(MinSize.Width, MinSize.Height));
|
||||
setMinSize(core::dimension2du(p.X,p.Y));
|
||||
|
||||
setAlignment((EGUI_ALIGNMENT) in->getAttributeAsEnumeration("LeftAlign", GUIAlignmentNames, AlignLeft),
|
||||
(EGUI_ALIGNMENT)in->getAttributeAsEnumeration("RightAlign", GUIAlignmentNames, AlignRight),
|
||||
(EGUI_ALIGNMENT)in->getAttributeAsEnumeration("TopAlign", GUIAlignmentNames, AlignTop),
|
||||
(EGUI_ALIGNMENT)in->getAttributeAsEnumeration("BottomAlign", GUIAlignmentNames, AlignBottom));
|
||||
|
||||
setRelativePosition(in->getAttributeAsRect("Rect", DesiredRect));
|
||||
|
||||
setNotClipped(in->getAttributeAsBool("NoClip", NoClip));
|
||||
}
|
||||
|
||||
protected:
|
||||
// not virtual because needed in constructor
|
||||
void addChildToEnd(IGUIElement* child)
|
||||
|
@ -618,6 +618,12 @@ public:
|
||||
\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;
|
||||
|
||||
//! Find the next element which would be selected when pressing the tab-key
|
||||
/** If you set the focus for the result you can manually force focus-changes like they
|
||||
would happen otherwise by the tab-keys.
|
||||
|
@ -5,7 +5,7 @@
|
||||
#ifndef __I_GUI_SKIN_H_INCLUDED__
|
||||
#define __I_GUI_SKIN_H_INCLUDED__
|
||||
|
||||
#include "IReferenceCounted.h"
|
||||
#include "IAttributeExchangingObject.h"
|
||||
#include "EGUIAlignment.h"
|
||||
#include "SColor.h"
|
||||
#include "rect.h"
|
||||
@ -381,7 +381,7 @@ namespace gui
|
||||
};
|
||||
|
||||
//! A skin modifies the look of the GUI elements.
|
||||
class IGUISkin : virtual public IReferenceCounted
|
||||
class IGUISkin : public virtual io::IAttributeExchangingObject
|
||||
{
|
||||
public:
|
||||
|
||||
|
@ -21,6 +21,9 @@ public:
|
||||
//! generates a pseudo random number in the range 0..randMax()
|
||||
virtual s32 rand() const =0;
|
||||
|
||||
//! generates a pseudo random number in the range 0..1
|
||||
virtual f32 frand() const =0;
|
||||
|
||||
//! get maxmimum number generated by rand()
|
||||
virtual s32 randMax() const =0;
|
||||
};
|
||||
|
62
include/ISceneLoader.h
Normal file
62
include/ISceneLoader.h
Normal file
@ -0,0 +1,62 @@
|
||||
// Copyright (C) 2010-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_SCENE_LOADER_H_INCLUDED__
|
||||
#define __I_SCENE_LOADER_H_INCLUDED__
|
||||
|
||||
#include "IReferenceCounted.h"
|
||||
#include "path.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace io
|
||||
{
|
||||
class IReadFile;
|
||||
} // end namespace io
|
||||
namespace scene
|
||||
{
|
||||
class ISceneNode;
|
||||
class ISceneUserDataSerializer;
|
||||
|
||||
//! Class which can load a scene into the scene manager.
|
||||
/** If you want Irrlicht to be able to load currently unsupported
|
||||
scene file formats (e.g. .vrml), then implement this and add your
|
||||
new Sceneloader to the engine with ISceneManager::addExternalSceneLoader(). */
|
||||
class ISceneLoader : public virtual IReferenceCounted
|
||||
{
|
||||
public:
|
||||
|
||||
//! Returns true if the class might be able to load this file.
|
||||
/** This decision should be based on the file extension (e.g. ".vrml")
|
||||
only.
|
||||
\param filename Name of the file to test.
|
||||
\return True if the extension is a recognised type. */
|
||||
virtual bool isALoadableFileExtension(const io::path& filename) const = 0;
|
||||
|
||||
//! Returns true if the class might be able to load this file.
|
||||
/** This decision will be based on a quick look at the contents of the file.
|
||||
\param file The file to test.
|
||||
\return True if the extension is a recognised type. */
|
||||
virtual bool isALoadableFileFormat(io::IReadFile* file) const = 0;
|
||||
|
||||
//! Loads the scene into the scene manager.
|
||||
/** \param file File which contains the scene.
|
||||
\param userDataSerializer: If you want to load user data which may be attached
|
||||
to some some scene nodes in the file, implement the ISceneUserDataSerializer
|
||||
interface and provide it as parameter here. Otherwise, simply specify 0 as this
|
||||
parameter.
|
||||
\param rootNode The node to load the scene into, if none is provided then the
|
||||
scene will be loaded into the root node.
|
||||
\return Returns true on success, false on failure. Returns 0 if loading failed. */
|
||||
virtual bool loadScene(io::IReadFile* file, ISceneUserDataSerializer* userDataSerializer=0,
|
||||
ISceneNode* rootNode=0) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
} // end namespace scene
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "vector3d.h"
|
||||
#include "dimension2d.h"
|
||||
#include "SColor.h"
|
||||
#include "ETerrainElements.h"
|
||||
#include "ESceneNodeTypes.h"
|
||||
#include "EMeshWriterEnums.h"
|
||||
#include "SceneParameters.h"
|
||||
@ -110,8 +111,10 @@ namespace scene
|
||||
class IMeshManipulator;
|
||||
class IMeshSceneNode;
|
||||
class IMeshWriter;
|
||||
class ISceneLoader;
|
||||
class ISceneNode;
|
||||
class ISceneNodeFactory;
|
||||
class ISceneUserDataSerializer;
|
||||
|
||||
//! The Scene Manager manages scene nodes, mesh resources, cameras and all the other stuff.
|
||||
/** All Scene nodes can be created only here.
|
||||
@ -558,6 +561,24 @@ namespace scene
|
||||
\return A pointer to the specified loader, 0 if the index is incorrect. */
|
||||
virtual IMeshLoader* getMeshLoader(u32 index) const = 0;
|
||||
|
||||
//! Adds an external scene loader for extending the engine with new file formats.
|
||||
/** If you want the engine to be extended with
|
||||
file formats it currently is not able to load (e.g. .vrml), just implement
|
||||
the ISceneLoader interface in your loading class and add it with this method.
|
||||
Using this method it is also possible to override the built-in scene loaders
|
||||
with newer or updated versions without the need to recompile the engine.
|
||||
\param externalLoader: Implementation of a new mesh loader. */
|
||||
virtual void addExternalSceneLoader(ISceneLoader* externalLoader) = 0;
|
||||
|
||||
//! Returns the number of scene loaders supported by Irrlicht at this time
|
||||
virtual u32 getSceneLoaderCount() const = 0;
|
||||
|
||||
//! Retrieve the given scene 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 ISceneLoader* getSceneLoader(u32 index) const = 0;
|
||||
|
||||
//! Get pointer to the scene collision manager.
|
||||
/** \return Pointer to the collision manager
|
||||
This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
|
||||
@ -649,6 +670,80 @@ namespace scene
|
||||
See IReferenceCounted::drop() for more information. */
|
||||
virtual ISceneManager* createNewSceneManager(bool cloneContent=false) = 0;
|
||||
|
||||
//! Saves the current scene into a file.
|
||||
/** Scene nodes with the option isDebugObject set to true are
|
||||
not being saved. The scene is usually written to an .irr file,
|
||||
an xml based format. .irr files can Be edited with the Irrlicht
|
||||
Engine Editor, irrEdit (http://www.ambiera.com/irredit/). To
|
||||
load .irr files again, see ISceneManager::loadScene().
|
||||
\param filename Name of the file.
|
||||
\param userDataSerializer If you want to save some user data
|
||||
for every scene node into the file, implement the
|
||||
ISceneUserDataSerializer interface and provide it as parameter
|
||||
here. Otherwise, simply specify 0 as this parameter.
|
||||
\param node Node which is taken as the top node of the scene.
|
||||
This node and all of its descendants are saved into the scene
|
||||
file. Pass 0 or the scene manager to save the full scene (which
|
||||
is also the default).
|
||||
\return True if successful. */
|
||||
virtual bool saveScene(const io::path& filename, ISceneUserDataSerializer* userDataSerializer=0, ISceneNode* node=0) = 0;
|
||||
|
||||
//! Saves the current scene into a file.
|
||||
/** Scene nodes with the option isDebugObject set to true are
|
||||
not being saved. The scene is usually written to an .irr file,
|
||||
an xml based format. .irr files can Be edited with the Irrlicht
|
||||
Engine Editor, irrEdit (http://www.ambiera.com/irredit/). To
|
||||
load .irr files again, see ISceneManager::loadScene().
|
||||
\param file File where the scene is saved into.
|
||||
\param userDataSerializer If you want to save some user data
|
||||
for every scene node into the file, implement the
|
||||
ISceneUserDataSerializer interface and provide it as parameter
|
||||
here. Otherwise, simply specify 0 as this parameter.
|
||||
\param node Node which is taken as the top node of the scene.
|
||||
This node and all of its descendants are saved into the scene
|
||||
file. Pass 0 or the scene manager to save the full scene (which
|
||||
is also the default).
|
||||
\return True if successful. */
|
||||
virtual bool saveScene(io::IWriteFile* file, ISceneUserDataSerializer* userDataSerializer=0, ISceneNode* node=0) = 0;
|
||||
|
||||
//! Loads a scene. Note that the current scene is not cleared before.
|
||||
/** The scene is usually loaded from an .irr file, an xml based
|
||||
format, but other scene formats can be added to the engine via
|
||||
ISceneManager::addExternalSceneLoader. .irr files can Be edited
|
||||
with the Irrlicht Engine Editor, irrEdit
|
||||
(http://www.ambiera.com/irredit/) or saved directly by the engine
|
||||
using ISceneManager::saveScene().
|
||||
\param filename Name of the file to load from.
|
||||
\param userDataSerializer If you want to load user data
|
||||
possibily saved in that file for some scene nodes in the file,
|
||||
implement the ISceneUserDataSerializer interface and provide it
|
||||
as parameter here. Otherwise, simply specify 0 as this
|
||||
parameter.
|
||||
\param rootNode Node which is taken as the root node of the
|
||||
scene. Pass 0 to add the scene directly to the scene manager
|
||||
(which is also the default).
|
||||
\return True if successful. */
|
||||
virtual bool loadScene(const io::path& filename, ISceneUserDataSerializer* userDataSerializer=0, ISceneNode* rootNode=0) = 0;
|
||||
|
||||
//! Loads a scene. Note that the current scene is not cleared before.
|
||||
/** The scene is usually loaded from an .irr file, an xml based
|
||||
format, but other scene formats can be added to the engine via
|
||||
ISceneManager::addExternalSceneLoader. .irr files can Be edited
|
||||
with the Irrlicht Engine Editor, irrEdit
|
||||
(http://www.ambiera.com/irredit/) or saved directly by the engine
|
||||
using ISceneManager::saveScene().
|
||||
\param file File where the scene is loaded from.
|
||||
\param userDataSerializer If you want to load user data
|
||||
saved in that file for some scene nodes in the file,
|
||||
implement the ISceneUserDataSerializer interface and provide it
|
||||
as parameter here. Otherwise, simply specify 0 as this
|
||||
parameter.
|
||||
\param rootNode Node which is taken as the root node of the
|
||||
scene. Pass 0 to add the scene directly to the scene manager
|
||||
(which is also the default).
|
||||
\return True if successful. */
|
||||
virtual bool loadScene(io::IReadFile* file, ISceneUserDataSerializer* userDataSerializer=0, ISceneNode* rootNode=0) = 0;
|
||||
|
||||
//! Get a mesh writer implementation if available
|
||||
/** Note: You need to drop() the pointer after use again, see IReferenceCounted::drop()
|
||||
for details. */
|
||||
|
@ -5,7 +5,7 @@
|
||||
#ifndef __I_SCENE_NODE_H_INCLUDED__
|
||||
#define __I_SCENE_NODE_H_INCLUDED__
|
||||
|
||||
#include "IReferenceCounted.h"
|
||||
#include "IAttributeExchangingObject.h"
|
||||
#include "ESceneNodeTypes.h"
|
||||
#include "ECullingTypes.h"
|
||||
#include "EDebugSceneTypes.h"
|
||||
@ -34,7 +34,7 @@ namespace scene
|
||||
example easily possible to attach a light to a moving car, or to place
|
||||
a walking character on a moving platform on a moving ship.
|
||||
*/
|
||||
class ISceneNode : virtual public IReferenceCounted
|
||||
class ISceneNode : virtual public io::IAttributeExchangingObject
|
||||
{
|
||||
public:
|
||||
|
||||
@ -571,6 +571,67 @@ namespace scene
|
||||
return ESNT_UNKNOWN;
|
||||
}
|
||||
|
||||
|
||||
//! Writes attributes of the scene node.
|
||||
/** Implement this to expose the attributes of your scene node
|
||||
for scripting languages, editors, debuggers or xml
|
||||
serialization purposes.
|
||||
\param out The attribute container to write into.
|
||||
\param options Additional options which might influence the
|
||||
serialization. */
|
||||
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const _IRR_OVERRIDE_
|
||||
{
|
||||
if (!out)
|
||||
return;
|
||||
out->addString("Name", Name.c_str());
|
||||
out->addInt("Id", ID );
|
||||
|
||||
out->addVector3d("Position", getPosition() );
|
||||
out->addVector3d("Rotation", getRotation() );
|
||||
out->addVector3d("Scale", getScale() );
|
||||
|
||||
out->addBool("Visible", IsVisible );
|
||||
out->addInt("AutomaticCulling", AutomaticCullingState);
|
||||
out->addInt("DebugDataVisible", DebugDataVisible );
|
||||
out->addBool("IsDebugObject", IsDebugObject );
|
||||
}
|
||||
|
||||
|
||||
//! Reads attributes of the scene node.
|
||||
/** Implement this to set the attributes of your scene node for
|
||||
scripting languages, editors, debuggers or xml deserialization
|
||||
purposes.
|
||||
\param in The attribute container to read from.
|
||||
\param options Additional options which might influence the
|
||||
deserialization. */
|
||||
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) _IRR_OVERRIDE_
|
||||
{
|
||||
if (!in)
|
||||
return;
|
||||
Name = in->getAttributeAsString("Name", Name);
|
||||
ID = in->getAttributeAsInt("Id", ID);
|
||||
|
||||
setPosition(in->getAttributeAsVector3d("Position", RelativeTranslation));
|
||||
setRotation(in->getAttributeAsVector3d("Rotation", RelativeRotation));
|
||||
setScale(in->getAttributeAsVector3d("Scale", RelativeScale));
|
||||
|
||||
IsVisible = in->getAttributeAsBool("Visible", IsVisible);
|
||||
if (in->existsAttribute("AutomaticCulling"))
|
||||
{
|
||||
s32 tmpState = in->getAttributeAsEnumeration("AutomaticCulling",
|
||||
scene::AutomaticCullingNames);
|
||||
if (tmpState != -1)
|
||||
AutomaticCullingState = (u32)tmpState;
|
||||
else
|
||||
AutomaticCullingState = in->getAttributeAsInt("AutomaticCulling");
|
||||
}
|
||||
|
||||
DebugDataVisible = in->getAttributeAsInt("DebugDataVisible", DebugDataVisible);
|
||||
IsDebugObject = in->getAttributeAsBool("IsDebugObject", IsDebugObject);
|
||||
|
||||
updateAbsolutePosition();
|
||||
}
|
||||
|
||||
//! Creates a clone of this scene node and its children.
|
||||
/** \param newParent An optional new parent.
|
||||
\param newManager An optional new scene manager.
|
||||
|
51
include/ISceneUserDataSerializer.h
Normal file
51
include/ISceneUserDataSerializer.h
Normal file
@ -0,0 +1,51 @@
|
||||
// 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_SCENE_USER_DATA_SERIALIZER_H_INCLUDED__
|
||||
#define __I_SCENE_USER_DATA_SERIALIZER_H_INCLUDED__
|
||||
|
||||
#include "IReferenceCounted.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace io
|
||||
{
|
||||
class IAttributes;
|
||||
} // end namespace io
|
||||
namespace scene
|
||||
{
|
||||
class ISceneNode;
|
||||
|
||||
//! Interface to read and write user data to and from .irr files.
|
||||
/** This interface is to be implemented by the user, to make it possible to read
|
||||
and write user data when reading or writing .irr files via ISceneManager.
|
||||
To be used with ISceneManager::loadScene() and ISceneManager::saveScene() */
|
||||
class ISceneUserDataSerializer
|
||||
{
|
||||
public:
|
||||
|
||||
virtual ~ISceneUserDataSerializer() {}
|
||||
|
||||
//! Called when the scene manager create a scene node while loading a file.
|
||||
virtual void OnCreateNode(ISceneNode* node) = 0;
|
||||
|
||||
//! Called when the scene manager read a scene node while loading a file.
|
||||
/** The userData pointer contains a list of attributes with userData which
|
||||
were attached to the scene node in the read scene file.*/
|
||||
virtual void OnReadUserData(ISceneNode* forSceneNode, io::IAttributes* userData) = 0;
|
||||
|
||||
//! Called when the scene manager is writing a scene node to an xml file for example.
|
||||
/** Implement this method and return a list of attributes containing the user data
|
||||
you want to be saved together with the scene node. Return 0 if no user data should
|
||||
be added. Please note that the scene manager will call drop() to the returned pointer
|
||||
after it no longer needs it, so if you didn't create a new object for the return value
|
||||
and returning a longer existing IAttributes object, simply call grab() before returning it. */
|
||||
virtual io::IAttributes* createUserData(ISceneNode* forSceneNode) = 0;
|
||||
};
|
||||
|
||||
} // end namespace scene
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
|
@ -79,12 +79,6 @@ namespace scene
|
||||
/* This feature is not implemented in Irrlicht yet */
|
||||
virtual bool setHardwareSkinning(bool on) = 0;
|
||||
|
||||
//! Refreshes vertex data cached in joints such as positions and normals
|
||||
virtual void refreshJointCache() = 0;
|
||||
|
||||
//! Moves the mesh into static position.
|
||||
virtual void resetAnimation() = 0;
|
||||
|
||||
//! A vertex weight
|
||||
struct SWeight
|
||||
{
|
||||
|
@ -25,6 +25,7 @@ namespace irr
|
||||
namespace io
|
||||
{
|
||||
class IAttributes;
|
||||
struct SAttributeReadWriteOptions;
|
||||
class IReadFile;
|
||||
class IWriteFile;
|
||||
} // end namespace io
|
||||
@ -508,6 +509,20 @@ namespace video
|
||||
core::position2d<s32> colorKeyPixelPos,
|
||||
bool zeroTexels = false) const =0;
|
||||
|
||||
//! Creates a normal map from a height map texture.
|
||||
/** As input is considered to be a height map the texture is read like:
|
||||
- For a 32-bit texture only the red channel is regarded
|
||||
- For a 16-bit texture the rgb-values are averaged.
|
||||
Output channels red/green for X/Y and blue for up (Z).
|
||||
For a 32-bit texture we store additionally the height value in the
|
||||
alpha channel. This value is used by the video::EMT_PARALLAX_MAP_SOLID
|
||||
material and similar materials.
|
||||
On the borders the texture is considered to repeat.
|
||||
\param texture Height map texture which is converted to a normal map.
|
||||
\param amplitude Constant value by which the height
|
||||
information is multiplied.*/
|
||||
virtual void makeNormalMapTexture(video::ITexture* texture, f32 amplitude=1.0f) const =0;
|
||||
|
||||
//! Set a render target.
|
||||
/** This will only work if the driver supports the
|
||||
EVDF_RENDER_TO_TARGET feature, which can be queried with
|
||||
@ -1340,6 +1355,28 @@ namespace video
|
||||
When false the names will stay at the original index */
|
||||
virtual void swapMaterialRenderers(u32 idx1, u32 idx2, bool swapNames=true) = 0;
|
||||
|
||||
//! Creates material attributes list from a material
|
||||
/** This method is useful for serialization and more.
|
||||
Please note that the video driver will use the material
|
||||
renderer names from getMaterialRendererName() to write out the
|
||||
material type name, so they should be set before.
|
||||
\param material The material to serialize.
|
||||
\param options Additional options which might influence the
|
||||
serialization.
|
||||
\return The io::IAttributes container holding the material
|
||||
properties. */
|
||||
virtual io::IAttributes* createAttributesFromMaterial(const video::SMaterial& material,
|
||||
io::SAttributeReadWriteOptions* options=0) =0;
|
||||
|
||||
//! Fills an SMaterial structure from attributes.
|
||||
/** Please note that for setting material types of the
|
||||
material, the video driver will need to query the material
|
||||
renderers for their names, so all non built-in materials must
|
||||
have been created before calling this method.
|
||||
\param outMaterial The material to set the properties for.
|
||||
\param attributes The attributes to read from. */
|
||||
virtual void fillMaterialStructureFromAttributes(video::SMaterial& outMaterial, io::IAttributes* attributes) =0;
|
||||
|
||||
//! Returns driver and operating system specific data about the IVideoDriver.
|
||||
/** This method should only be used if the engine should be
|
||||
extended without having to modify the source of the engine.
|
||||
|
@ -64,15 +64,25 @@
|
||||
#if defined(_WIN32) || defined(_WIN64) || defined(WIN32) || defined(WIN64)
|
||||
#define _IRR_WINDOWS_
|
||||
#define _IRR_WINDOWS_API_
|
||||
#ifndef _IRR_COMPILE_WITH_SDL_DEVICE_
|
||||
#define _IRR_COMPILE_WITH_WINDOWS_DEVICE_
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER < 1500)
|
||||
# error "Only Microsoft Visual Studio 9.0 and later are supported."
|
||||
#endif
|
||||
|
||||
// XBox is deprecated (as DX8 is removed). Use Irrlicht 1.8 if you still want to work on this.
|
||||
#if defined(_XBOX)
|
||||
#undef _IRR_WINDOWS_
|
||||
#define _IRR_XBOX_PLATFORM_ // deprecated
|
||||
#define _IRR_WINDOWS_API_
|
||||
//#define _IRR_COMPILE_WITH_WINDOWS_DEVICE_
|
||||
#undef _IRR_COMPILE_WITH_WINDOWS_DEVICE_
|
||||
//#define _IRR_COMPILE_WITH_SDL_DEVICE_
|
||||
|
||||
#include <xtl.h>
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__) || defined(MACOSX)
|
||||
#if !defined(MACOSX)
|
||||
#define MACOSX // legacy support
|
||||
@ -88,9 +98,7 @@
|
||||
#define _IRR_COMPILE_WITH_IOS_BUILTIN_MAIN_
|
||||
#else
|
||||
#define _IRR_OSX_PLATFORM_
|
||||
#ifndef _IRR_COMPILE_WITH_SDL_DEVICE_
|
||||
#define _IRR_COMPILE_WITH_OSX_DEVICE_
|
||||
#endif
|
||||
#define NO_IRR_COMPILE_WITH_OGLES1_
|
||||
#define NO_IRR_COMPILE_WITH_OGLES2_
|
||||
#define NO_IRR_COMPILE_WITH_WEBGL1_
|
||||
@ -129,10 +137,8 @@
|
||||
#define _IRR_LINUX_PLATFORM_
|
||||
#endif
|
||||
#define _IRR_POSIX_API_
|
||||
#ifndef _IRR_COMPILE_WITH_SDL_DEVICE_
|
||||
#define _IRR_COMPILE_WITH_X11_DEVICE_
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
//! Define _IRR_COMPILE_WITH_JOYSTICK_SUPPORT_ if you want joystick events.
|
||||
@ -145,7 +151,7 @@
|
||||
|
||||
|
||||
//! Maximum number of texture an SMaterial can have, up to 8 are supported by Irrlicht.
|
||||
#define _IRR_MATERIAL_MAX_TEXTURES_ 4
|
||||
#define _IRR_MATERIAL_MAX_TEXTURES_ 8
|
||||
|
||||
//! Add a leak-hunter to Irrlicht which helps finding unreleased reference counted objects.
|
||||
//! NOTE: This is slow and should only be used for debugging
|
||||
|
43
include/SKeyMap.h
Normal file
43
include/SKeyMap.h
Normal 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 __S_KEY_MAP_H_INCLUDED__
|
||||
#define __S_KEY_MAP_H_INCLUDED__
|
||||
|
||||
#include "Keycodes.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
|
||||
//! enumeration for key actions. Used for example in the FPS Camera.
|
||||
enum EKEY_ACTION
|
||||
{
|
||||
EKA_MOVE_FORWARD = 0,
|
||||
EKA_MOVE_BACKWARD,
|
||||
EKA_STRAFE_LEFT,
|
||||
EKA_STRAFE_RIGHT,
|
||||
EKA_JUMP_UP,
|
||||
EKA_CROUCH,
|
||||
EKA_ROTATE_LEFT,
|
||||
EKA_ROTATE_RIGHT,
|
||||
EKA_COUNT,
|
||||
|
||||
//! This value is not used. It only forces this enumeration to compile in 32 bit.
|
||||
EKA_FORCE_32BIT = 0x7fffffff
|
||||
};
|
||||
|
||||
//! Struct storing which key belongs to which action.
|
||||
struct SKeyMap
|
||||
{
|
||||
SKeyMap() {}
|
||||
SKeyMap(EKEY_ACTION action, EKEY_CODE keyCode) : Action(action), KeyCode(keyCode) {}
|
||||
|
||||
EKEY_ACTION Action;
|
||||
EKEY_CODE KeyCode;
|
||||
};
|
||||
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
|
@ -282,6 +282,23 @@ namespace video
|
||||
*/
|
||||
const u32 MATERIAL_MAX_TEXTURES = _IRR_MATERIAL_MAX_TEXTURES_;
|
||||
|
||||
//! By default this is identical to MATERIAL_MAX_TEXTURES
|
||||
/** Users can modify this value if they are certain they don't need all
|
||||
available textures per material in their application. For example if you
|
||||
never need more than 2 textures per material you can set this to 2.
|
||||
|
||||
We (mostly) avoid dynamic memory in SMaterial, so the extra memory
|
||||
will still be allocated. But by lowering MATERIAL_MAX_TEXTURES_USED the
|
||||
material comparisons and assignments can be faster. Also several other
|
||||
places in the engine can be faster when reducing this value to the limit
|
||||
you need.
|
||||
|
||||
NOTE: This should only be changed once and before any call to createDevice.
|
||||
NOTE: Do not set it below 1 or above the value of _IRR_MATERIAL_MAX_TEXTURES_.
|
||||
NOTE: Going below 4 is usually not worth it.
|
||||
*/
|
||||
IRRLICHT_API extern u32 MATERIAL_MAX_TEXTURES_USED;
|
||||
|
||||
//! Struct for holding parameters for a material renderer
|
||||
// Note for implementors: Serialization is in CNullDriver
|
||||
class SMaterial
|
||||
@ -306,7 +323,7 @@ namespace video
|
||||
SMaterial(const SMaterial& other)
|
||||
{
|
||||
// These pointers are checked during assignment
|
||||
for (u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i)
|
||||
for (u32 i=0; i<MATERIAL_MAX_TEXTURES_USED; ++i)
|
||||
TextureLayer[i].TextureMatrix = 0;
|
||||
*this = other;
|
||||
}
|
||||
@ -355,7 +372,7 @@ namespace video
|
||||
f32 Shininess;
|
||||
|
||||
//! Free parameter, dependent on the material type.
|
||||
/** Mostly ignored, used for example in
|
||||
/** Mostly ignored, used for example in EMT_PARALLAX_MAP_SOLID,
|
||||
EMT_TRANSPARENT_ALPHA_CHANNEL and EMT_ONETEXTURE_BLEND. */
|
||||
f32 MaterialTypeParam;
|
||||
|
||||
@ -548,23 +565,23 @@ namespace video
|
||||
FrontfaceCulling = value; break;
|
||||
case EMF_BILINEAR_FILTER:
|
||||
{
|
||||
for (u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i)
|
||||
for (u32 i=0; i<MATERIAL_MAX_TEXTURES_USED; ++i)
|
||||
TextureLayer[i].BilinearFilter = value;
|
||||
}
|
||||
break;
|
||||
case EMF_TRILINEAR_FILTER:
|
||||
{
|
||||
for (u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i)
|
||||
for (u32 i=0; i<MATERIAL_MAX_TEXTURES_USED; ++i)
|
||||
TextureLayer[i].TrilinearFilter = value;
|
||||
}
|
||||
break;
|
||||
case EMF_ANISOTROPIC_FILTER:
|
||||
{
|
||||
if (value)
|
||||
for (u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i)
|
||||
for (u32 i=0; i<MATERIAL_MAX_TEXTURES_USED; ++i)
|
||||
TextureLayer[i].AnisotropicFilter = 0xFF;
|
||||
else
|
||||
for (u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i)
|
||||
for (u32 i=0; i<MATERIAL_MAX_TEXTURES_USED; ++i)
|
||||
TextureLayer[i].AnisotropicFilter = 0;
|
||||
}
|
||||
break;
|
||||
@ -574,7 +591,7 @@ namespace video
|
||||
NormalizeNormals = value; break;
|
||||
case EMF_TEXTURE_WRAP:
|
||||
{
|
||||
for (u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i)
|
||||
for (u32 i=0; i<MATERIAL_MAX_TEXTURES_USED; ++i)
|
||||
{
|
||||
TextureLayer[i].TextureWrapU = (E_TEXTURE_CLAMP)value;
|
||||
TextureLayer[i].TextureWrapV = (E_TEXTURE_CLAMP)value;
|
||||
@ -696,7 +713,7 @@ namespace video
|
||||
PolygonOffsetSlopeScale != b.PolygonOffsetSlopeScale ||
|
||||
UseMipMaps != b.UseMipMaps
|
||||
;
|
||||
for (u32 i=0; (i<MATERIAL_MAX_TEXTURES) && !different; ++i)
|
||||
for (u32 i=0; (i<MATERIAL_MAX_TEXTURES_USED) && !different; ++i)
|
||||
{
|
||||
different |= (TextureLayer[i] != b.TextureLayer[i]);
|
||||
}
|
||||
|
260
include/SSharedMeshBuffer.h
Normal file
260
include/SSharedMeshBuffer.h
Normal file
@ -0,0 +1,260 @@
|
||||
// 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 __S_SHARED_MESH_BUFFER_H_INCLUDED__
|
||||
#define __S_SHARED_MESH_BUFFER_H_INCLUDED__
|
||||
|
||||
#include "irrArray.h"
|
||||
#include "IMeshBuffer.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace scene
|
||||
{
|
||||
//! Implementation of the IMeshBuffer interface with shared vertex list
|
||||
struct SSharedMeshBuffer : public IMeshBuffer
|
||||
{
|
||||
//! constructor
|
||||
SSharedMeshBuffer()
|
||||
: IMeshBuffer()
|
||||
, Vertices(0), ChangedID_Vertex(1), ChangedID_Index(1)
|
||||
, MappingHintVertex(EHM_NEVER), MappingHintIndex(EHM_NEVER)
|
||||
, PrimitiveType(EPT_TRIANGLES)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
setDebugName("SSharedMeshBuffer");
|
||||
#endif
|
||||
}
|
||||
|
||||
//! constructor
|
||||
SSharedMeshBuffer(core::array<video::S3DVertex> *vertices) : IMeshBuffer(), Vertices(vertices), ChangedID_Vertex(1), ChangedID_Index(1), MappingHintVertex(EHM_NEVER), MappingHintIndex(EHM_NEVER)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
setDebugName("SSharedMeshBuffer");
|
||||
#endif
|
||||
}
|
||||
|
||||
//! returns the material of this meshbuffer
|
||||
virtual const video::SMaterial& getMaterial() const _IRR_OVERRIDE_
|
||||
{
|
||||
return Material;
|
||||
}
|
||||
|
||||
//! returns the material of this meshbuffer
|
||||
virtual video::SMaterial& getMaterial() _IRR_OVERRIDE_
|
||||
{
|
||||
return Material;
|
||||
}
|
||||
|
||||
//! returns pointer to vertices
|
||||
virtual const void* getVertices() const _IRR_OVERRIDE_
|
||||
{
|
||||
if (Vertices)
|
||||
return Vertices->const_pointer();
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
//! returns pointer to vertices
|
||||
virtual void* getVertices() _IRR_OVERRIDE_
|
||||
{
|
||||
if (Vertices)
|
||||
return Vertices->pointer();
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
//! returns amount of vertices
|
||||
virtual u32 getVertexCount() const _IRR_OVERRIDE_
|
||||
{
|
||||
if (Vertices)
|
||||
return Vertices->size();
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
//! returns pointer to indices
|
||||
virtual const u16* getIndices() const _IRR_OVERRIDE_
|
||||
{
|
||||
return Indices.const_pointer();
|
||||
}
|
||||
|
||||
//! returns pointer to indices
|
||||
virtual u16* getIndices() _IRR_OVERRIDE_
|
||||
{
|
||||
return Indices.pointer();
|
||||
}
|
||||
|
||||
//! returns amount of indices
|
||||
virtual u32 getIndexCount() const _IRR_OVERRIDE_
|
||||
{
|
||||
return Indices.size();
|
||||
}
|
||||
|
||||
//! Get type of index data which is stored in this meshbuffer.
|
||||
virtual video::E_INDEX_TYPE getIndexType() const _IRR_OVERRIDE_
|
||||
{
|
||||
return video::EIT_16BIT;
|
||||
}
|
||||
|
||||
//! returns an axis aligned bounding box
|
||||
virtual const core::aabbox3d<f32>& getBoundingBox() const _IRR_OVERRIDE_
|
||||
{
|
||||
return BoundingBox;
|
||||
}
|
||||
|
||||
//! set user axis aligned bounding box
|
||||
virtual void setBoundingBox( const core::aabbox3df& box) _IRR_OVERRIDE_
|
||||
{
|
||||
BoundingBox = box;
|
||||
}
|
||||
|
||||
//! returns which type of vertex data is stored.
|
||||
virtual video::E_VERTEX_TYPE getVertexType() const _IRR_OVERRIDE_
|
||||
{
|
||||
return video::EVT_STANDARD;
|
||||
}
|
||||
|
||||
//! recalculates the bounding box. should be called if the mesh changed.
|
||||
virtual void recalculateBoundingBox() _IRR_OVERRIDE_
|
||||
{
|
||||
if (!Vertices || Vertices->empty() || Indices.empty())
|
||||
BoundingBox.reset(0,0,0);
|
||||
else
|
||||
{
|
||||
BoundingBox.reset((*Vertices)[Indices[0]].Pos);
|
||||
for (u32 i=1; i<Indices.size(); ++i)
|
||||
BoundingBox.addInternalPoint((*Vertices)[Indices[i]].Pos);
|
||||
}
|
||||
}
|
||||
|
||||
//! returns position of vertex i
|
||||
virtual const core::vector3df& getPosition(u32 i) const _IRR_OVERRIDE_
|
||||
{
|
||||
_IRR_DEBUG_BREAK_IF(!Vertices);
|
||||
return (*Vertices)[Indices[i]].Pos;
|
||||
}
|
||||
|
||||
//! returns position of vertex i
|
||||
virtual core::vector3df& getPosition(u32 i) _IRR_OVERRIDE_
|
||||
{
|
||||
_IRR_DEBUG_BREAK_IF(!Vertices);
|
||||
return (*Vertices)[Indices[i]].Pos;
|
||||
}
|
||||
|
||||
//! returns normal of vertex i
|
||||
virtual const core::vector3df& getNormal(u32 i) const _IRR_OVERRIDE_
|
||||
{
|
||||
_IRR_DEBUG_BREAK_IF(!Vertices);
|
||||
return (*Vertices)[Indices[i]].Normal;
|
||||
}
|
||||
|
||||
//! returns normal of vertex i
|
||||
virtual core::vector3df& getNormal(u32 i) _IRR_OVERRIDE_
|
||||
{
|
||||
_IRR_DEBUG_BREAK_IF(!Vertices);
|
||||
return (*Vertices)[Indices[i]].Normal;
|
||||
}
|
||||
|
||||
//! returns texture coord of vertex i
|
||||
virtual const core::vector2df& getTCoords(u32 i) const _IRR_OVERRIDE_
|
||||
{
|
||||
_IRR_DEBUG_BREAK_IF(!Vertices);
|
||||
return (*Vertices)[Indices[i]].TCoords;
|
||||
}
|
||||
|
||||
//! returns texture coord of vertex i
|
||||
virtual core::vector2df& getTCoords(u32 i) _IRR_OVERRIDE_
|
||||
{
|
||||
_IRR_DEBUG_BREAK_IF(!Vertices);
|
||||
return (*Vertices)[Indices[i]].TCoords;
|
||||
}
|
||||
|
||||
//! append the vertices and indices to the current buffer
|
||||
virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices) _IRR_OVERRIDE_ {}
|
||||
//! append the meshbuffer to the current buffer
|
||||
virtual void append(const IMeshBuffer* const other) _IRR_OVERRIDE_ {}
|
||||
|
||||
//! get the current hardware mapping hint
|
||||
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Vertex() const _IRR_OVERRIDE_
|
||||
{
|
||||
return MappingHintVertex;
|
||||
}
|
||||
|
||||
//! get the current hardware mapping hint
|
||||
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Index() const _IRR_OVERRIDE_
|
||||
{
|
||||
return MappingHintIndex;
|
||||
}
|
||||
|
||||
//! set the hardware mapping hint, for driver
|
||||
virtual void setHardwareMappingHint( E_HARDWARE_MAPPING NewMappingHint, E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX ) _IRR_OVERRIDE_
|
||||
{
|
||||
if (buffer==EBT_VERTEX_AND_INDEX || buffer==EBT_VERTEX)
|
||||
MappingHintVertex=NewMappingHint;
|
||||
if (buffer==EBT_VERTEX_AND_INDEX || buffer==EBT_INDEX)
|
||||
MappingHintIndex=NewMappingHint;
|
||||
}
|
||||
|
||||
//! Describe what kind of primitive geometry is used by the meshbuffer
|
||||
virtual void setPrimitiveType(E_PRIMITIVE_TYPE type) _IRR_OVERRIDE_
|
||||
{
|
||||
PrimitiveType = type;
|
||||
}
|
||||
|
||||
//! Get the kind of primitive geometry which is used by the meshbuffer
|
||||
virtual E_PRIMITIVE_TYPE getPrimitiveType() const _IRR_OVERRIDE_
|
||||
{
|
||||
return PrimitiveType;
|
||||
}
|
||||
|
||||
//! flags the mesh as changed, reloads hardware buffers
|
||||
virtual void setDirty(E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX) _IRR_OVERRIDE_
|
||||
{
|
||||
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 _IRR_OVERRIDE_ {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 _IRR_OVERRIDE_ {return ChangedID_Index;}
|
||||
|
||||
//! Material of this meshBuffer
|
||||
video::SMaterial Material;
|
||||
|
||||
//! Shared Array of vertices
|
||||
core::array<video::S3DVertex> *Vertices;
|
||||
|
||||
//! Array of indices
|
||||
core::array<u16> Indices;
|
||||
|
||||
//! ID used for hardware buffer management
|
||||
u32 ChangedID_Vertex;
|
||||
|
||||
//! ID used for hardware buffer management
|
||||
u32 ChangedID_Index;
|
||||
|
||||
//! Bounding box
|
||||
core::aabbox3df BoundingBox;
|
||||
|
||||
//! hardware mapping hint
|
||||
E_HARDWARE_MAPPING MappingHintVertex;
|
||||
E_HARDWARE_MAPPING MappingHintIndex;
|
||||
|
||||
//! Primitive type used for rendering (triangles, lines, ...)
|
||||
E_PRIMITIVE_TYPE PrimitiveType;
|
||||
};
|
||||
|
||||
|
||||
} // end namespace scene
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
|
@ -48,6 +48,32 @@ namespace scene
|
||||
**/
|
||||
const c8* const OBJ_LOADER_IGNORE_MATERIAL_FILES = "OBJ_IgnoreMaterialFiles";
|
||||
|
||||
|
||||
//! Flag to ignore the b3d file's mipmapping flag
|
||||
/** Instead Irrlicht's texture creation flag is used. Use it like this:
|
||||
\code
|
||||
SceneManager->getParameters()->setAttribute(scene::B3D_LOADER_IGNORE_MIPMAP_FLAG, true);
|
||||
\endcode
|
||||
**/
|
||||
const c8* const B3D_LOADER_IGNORE_MIPMAP_FLAG = "B3D_IgnoreMipmapFlag";
|
||||
|
||||
//! Name of the parameter for setting the length of debug normals.
|
||||
/** Use it like this:
|
||||
\code
|
||||
SceneManager->getParameters()->setAttribute(scene::DEBUG_NORMAL_LENGTH, 1.5f);
|
||||
\endcode
|
||||
**/
|
||||
const c8* const DEBUG_NORMAL_LENGTH = "DEBUG_Normal_Length";
|
||||
|
||||
//! Name of the parameter for setting the color of debug normals.
|
||||
/** Use it like this:
|
||||
\code
|
||||
SceneManager->getParameters()->setAttributeAsColor(scene::DEBUG_NORMAL_COLOR, video::SColor(255, 255, 255, 255));
|
||||
\endcode
|
||||
**/
|
||||
const c8* const DEBUG_NORMAL_COLOR = "DEBUG_Normal_Color";
|
||||
|
||||
|
||||
} // end namespace scene
|
||||
} // end namespace irr
|
||||
|
||||
|
@ -920,10 +920,8 @@ public:
|
||||
if ((length+begin) > size())
|
||||
length = size()-begin;
|
||||
|
||||
// accounting for null terminator.
|
||||
s32 substrAllocLength = length + 1;
|
||||
string<T> o;
|
||||
o.reserve(substrAllocLength);
|
||||
o.reserve(length+1);
|
||||
|
||||
if ( !make_lower )
|
||||
{
|
||||
@ -936,7 +934,7 @@ public:
|
||||
o.array[i] = locale_lower ( array[i+begin] );
|
||||
}
|
||||
|
||||
o.array[substrAllocLength - 1] = 0;
|
||||
o.array[length] = 0;
|
||||
o.used = length + 1;
|
||||
|
||||
return o;
|
||||
|
@ -31,6 +31,7 @@
|
||||
|
||||
#include "IrrCompileConfig.h"
|
||||
#include "aabbox3d.h"
|
||||
#include "CDynamicMeshBuffer.h"
|
||||
#include "CIndexBuffer.h"
|
||||
#include "CMeshBuffer.h"
|
||||
#include "coreutil.h"
|
||||
@ -49,10 +50,12 @@
|
||||
#include "EMeshWriterEnums.h"
|
||||
#include "EMessageBoxFlags.h"
|
||||
#include "ESceneNodeTypes.h"
|
||||
#include "ETerrainElements.h"
|
||||
#include "fast_atof.h"
|
||||
#include "heapsort.h"
|
||||
#include "IAnimatedMesh.h"
|
||||
#include "IAnimatedMeshSceneNode.h"
|
||||
#include "IAttributeExchangingObject.h"
|
||||
#include "IAttributes.h"
|
||||
#include "IBillboardSceneNode.h"
|
||||
#include "IBoneSceneNode.h"
|
||||
@ -60,6 +63,7 @@
|
||||
#include "IContextManager.h"
|
||||
#include "ICursorControl.h"
|
||||
#include "IDummyTransformationSceneNode.h"
|
||||
#include "IDynamicMeshBuffer.h"
|
||||
#include "IEventReceiver.h"
|
||||
#include "IFileList.h"
|
||||
#include "IFileSystem.h"
|
||||
@ -119,9 +123,11 @@
|
||||
#include "irrTypes.h"
|
||||
#include "path.h"
|
||||
#include "ISceneCollisionManager.h"
|
||||
#include "ISceneLoader.h"
|
||||
#include "ISceneManager.h"
|
||||
#include "ISceneNode.h"
|
||||
#include "ISceneNodeFactory.h"
|
||||
#include "ISceneUserDataSerializer.h"
|
||||
#include "IShaderConstantSetCallBack.h"
|
||||
#include "ISkinnedMesh.h"
|
||||
#include "ITexture.h"
|
||||
@ -144,10 +150,12 @@
|
||||
#include "SColor.h"
|
||||
#include "SExposedVideoData.h"
|
||||
#include "SIrrCreationParameters.h"
|
||||
#include "SKeyMap.h"
|
||||
#include "SLight.h"
|
||||
#include "SMaterial.h"
|
||||
#include "SMesh.h"
|
||||
#include "SMeshBuffer.h"
|
||||
#include "SSharedMeshBuffer.h"
|
||||
#include "SSkinMeshBuffer.h"
|
||||
#include "SVertexIndex.h"
|
||||
#include "SViewFrustum.h"
|
||||
|
74
media/Shaders/COGLES2NormalMap.fsh
Normal file
74
media/Shaders/COGLES2NormalMap.fsh
Normal file
@ -0,0 +1,74 @@
|
||||
#define MAX_LIGHTS 2
|
||||
|
||||
precision mediump float;
|
||||
|
||||
/* Uniforms */
|
||||
|
||||
uniform sampler2D uTextureUnit0;
|
||||
uniform sampler2D uTextureUnit1;
|
||||
uniform int uFogEnable;
|
||||
uniform int uFogType;
|
||||
uniform vec4 uFogColor;
|
||||
uniform float uFogStart;
|
||||
uniform float uFogEnd;
|
||||
uniform float uFogDensity;
|
||||
|
||||
/* Varyings */
|
||||
|
||||
varying vec2 vTexCoord;
|
||||
varying vec3 vLightVector[MAX_LIGHTS];
|
||||
varying vec4 vLightColor[MAX_LIGHTS];
|
||||
varying float vFogCoord;
|
||||
|
||||
float computeFog()
|
||||
{
|
||||
const float LOG2 = 1.442695;
|
||||
float FogFactor = 0.0;
|
||||
|
||||
if (uFogType == 0) // Exp
|
||||
{
|
||||
FogFactor = exp2(-uFogDensity * vFogCoord * LOG2);
|
||||
}
|
||||
else if (uFogType == 1) // Linear
|
||||
{
|
||||
float Scale = 1.0 / (uFogEnd - uFogStart);
|
||||
FogFactor = (uFogEnd - vFogCoord) * Scale;
|
||||
}
|
||||
else if (uFogType == 2) // Exp2
|
||||
{
|
||||
FogFactor = exp2(-uFogDensity * uFogDensity * vFogCoord * vFogCoord * LOG2);
|
||||
}
|
||||
|
||||
FogFactor = clamp(FogFactor, 0.0, 1.0);
|
||||
|
||||
return FogFactor;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 Color = texture2D(uTextureUnit0, vTexCoord);
|
||||
vec3 Normal = texture2D(uTextureUnit1, vTexCoord).xyz * 2.0 - 1.0;
|
||||
|
||||
vec4 FinalColor = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
|
||||
for (int i = 0; i < int(MAX_LIGHTS); i++)
|
||||
{
|
||||
vec3 LightVector = normalize(vLightVector[i]);
|
||||
|
||||
float Lambert = max(dot(LightVector, Normal), 0.0);
|
||||
FinalColor += vec4(Lambert) * vLightColor[i];
|
||||
}
|
||||
|
||||
FinalColor *= Color;
|
||||
FinalColor.w = vLightColor[0].w;
|
||||
|
||||
if (bool(uFogEnable))
|
||||
{
|
||||
float FogFactor = computeFog();
|
||||
vec4 FogColor = uFogColor;
|
||||
FogColor.a = 1.0;
|
||||
FinalColor = mix(FogColor, FinalColor, FogFactor);
|
||||
}
|
||||
|
||||
gl_FragColor = FinalColor;
|
||||
}
|
52
media/Shaders/COGLES2NormalMap.vsh
Normal file
52
media/Shaders/COGLES2NormalMap.vsh
Normal file
@ -0,0 +1,52 @@
|
||||
#define MAX_LIGHTS 2
|
||||
|
||||
/* Attributes */
|
||||
|
||||
attribute vec3 inVertexPosition;
|
||||
attribute vec3 inVertexNormal;
|
||||
attribute vec3 inVertexTangent;
|
||||
attribute vec3 inVertexBinormal;
|
||||
attribute vec4 inVertexColor;
|
||||
attribute vec2 inTexCoord0;
|
||||
|
||||
/* Uniforms */
|
||||
|
||||
uniform mat4 uWVPMatrix;
|
||||
uniform mat4 uWVMatrix;
|
||||
uniform vec3 uLightPosition[MAX_LIGHTS];
|
||||
uniform vec4 uLightColor[MAX_LIGHTS];
|
||||
|
||||
/* Varyings */
|
||||
|
||||
varying vec2 vTexCoord;
|
||||
varying vec3 vLightVector[MAX_LIGHTS];
|
||||
varying vec4 vLightColor[MAX_LIGHTS];
|
||||
varying float vFogCoord;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = uWVPMatrix * vec4(inVertexPosition, 1.0);
|
||||
|
||||
vTexCoord = inTexCoord0;
|
||||
|
||||
for (int i = 0; i < int(MAX_LIGHTS); i++)
|
||||
{
|
||||
vec3 LightVector = uLightPosition[i] - inVertexPosition;
|
||||
|
||||
vLightVector[i].x = dot(inVertexTangent, LightVector);
|
||||
vLightVector[i].y = dot(inVertexBinormal, LightVector);
|
||||
vLightVector[i].z = dot(inVertexNormal, LightVector);
|
||||
|
||||
vLightColor[i].x = dot(LightVector, LightVector);
|
||||
vLightColor[i].x *= uLightColor[i].a;
|
||||
vLightColor[i] = vec4(inversesqrt(vLightColor[i].x));
|
||||
vLightColor[i] *= uLightColor[i];
|
||||
vLightColor[i].a = inVertexColor.a;
|
||||
|
||||
vLightColor[i].x = clamp(vLightColor[i].x, 0.0, 1.0);
|
||||
vLightColor[i].y = clamp(vLightColor[i].y, 0.0, 1.0);
|
||||
vLightColor[i].z = clamp(vLightColor[i].z, 0.0, 1.0);
|
||||
}
|
||||
|
||||
vFogCoord = length((uWVMatrix * vec4(inVertexPosition, 1.0)).xyz);
|
||||
}
|
82
media/Shaders/COGLES2ParallaxMap.fsh
Normal file
82
media/Shaders/COGLES2ParallaxMap.fsh
Normal file
@ -0,0 +1,82 @@
|
||||
#define MAX_LIGHTS 2
|
||||
|
||||
precision mediump float;
|
||||
|
||||
/* Uniforms */
|
||||
|
||||
uniform float uFactor;
|
||||
uniform sampler2D uTextureUnit0;
|
||||
uniform sampler2D uTextureUnit1;
|
||||
uniform int uFogEnable;
|
||||
uniform int uFogType;
|
||||
uniform vec4 uFogColor;
|
||||
uniform float uFogStart;
|
||||
uniform float uFogEnd;
|
||||
uniform float uFogDensity;
|
||||
|
||||
/* Varyings */
|
||||
|
||||
varying vec2 vTexCoord;
|
||||
varying vec3 vEyeVector;
|
||||
varying vec3 vLightVector[MAX_LIGHTS];
|
||||
varying vec4 vLightColor[MAX_LIGHTS];
|
||||
varying float vFogCoord;
|
||||
|
||||
float computeFog()
|
||||
{
|
||||
const float LOG2 = 1.442695;
|
||||
float FogFactor = 0.0;
|
||||
|
||||
if (uFogType == 0) // Exp
|
||||
{
|
||||
FogFactor = exp2(-uFogDensity * vFogCoord * LOG2);
|
||||
}
|
||||
else if (uFogType == 1) // Linear
|
||||
{
|
||||
float Scale = 1.0 / (uFogEnd - uFogStart);
|
||||
FogFactor = (uFogEnd - vFogCoord) * Scale;
|
||||
}
|
||||
else if (uFogType == 2) // Exp2
|
||||
{
|
||||
FogFactor = exp2(-uFogDensity * uFogDensity * vFogCoord * vFogCoord * LOG2);
|
||||
}
|
||||
|
||||
FogFactor = clamp(FogFactor, 0.0, 1.0);
|
||||
|
||||
return FogFactor;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 TempFetch = texture2D(uTextureUnit1, vTexCoord) * 2.0 - 1.0;
|
||||
TempFetch *= uFactor;
|
||||
|
||||
vec3 EyeVector = normalize(vEyeVector);
|
||||
vec2 TexCoord = EyeVector.xy * TempFetch.w + vTexCoord;
|
||||
|
||||
vec4 Color = texture2D(uTextureUnit0, TexCoord);
|
||||
vec3 Normal = texture2D(uTextureUnit1, TexCoord).xyz * 2.0 - 1.0;
|
||||
|
||||
vec4 FinalColor = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
|
||||
for (int i = 0; i < int(MAX_LIGHTS); i++)
|
||||
{
|
||||
vec3 LightVector = normalize(vLightVector[i]);
|
||||
|
||||
float Lambert = max(dot(LightVector, Normal), 0.0);
|
||||
FinalColor += vec4(Lambert) * vLightColor[i];
|
||||
}
|
||||
|
||||
FinalColor *= Color;
|
||||
FinalColor.w = vLightColor[0].w;
|
||||
|
||||
if (bool(uFogEnable))
|
||||
{
|
||||
float FogFactor = computeFog();
|
||||
vec4 FogColor = uFogColor;
|
||||
FogColor.a = 1.0;
|
||||
FinalColor = mix(FogColor, FinalColor, FogFactor);
|
||||
}
|
||||
|
||||
gl_FragColor = FinalColor;
|
||||
}
|
61
media/Shaders/COGLES2ParallaxMap.vsh
Normal file
61
media/Shaders/COGLES2ParallaxMap.vsh
Normal file
@ -0,0 +1,61 @@
|
||||
#define MAX_LIGHTS 2
|
||||
|
||||
/* Attributes */
|
||||
|
||||
attribute vec3 inVertexPosition;
|
||||
attribute vec3 inVertexNormal;
|
||||
attribute vec3 inVertexTangent;
|
||||
attribute vec3 inVertexBinormal;
|
||||
attribute vec4 inVertexColor;
|
||||
attribute vec2 inTexCoord0;
|
||||
|
||||
/* Uniforms */
|
||||
|
||||
uniform mat4 uWVPMatrix;
|
||||
uniform mat4 uWVMatrix;
|
||||
uniform vec3 uEyePosition;
|
||||
uniform vec3 uLightPosition[MAX_LIGHTS];
|
||||
uniform vec4 uLightColor[MAX_LIGHTS];
|
||||
|
||||
/* Varyings */
|
||||
|
||||
varying vec2 vTexCoord;
|
||||
varying vec3 vEyeVector;
|
||||
varying vec3 vLightVector[MAX_LIGHTS];
|
||||
varying vec4 vLightColor[MAX_LIGHTS];
|
||||
varying float vFogCoord;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = uWVPMatrix * vec4(inVertexPosition, 1.0);
|
||||
|
||||
vTexCoord = inTexCoord0;
|
||||
|
||||
vec3 EyeVector = uEyePosition - inVertexPosition;
|
||||
|
||||
vEyeVector.x = dot(inVertexTangent, EyeVector);
|
||||
vEyeVector.y = dot(inVertexBinormal, EyeVector);
|
||||
vEyeVector.z = dot(inVertexNormal, EyeVector);
|
||||
vEyeVector *= vec3(1.0, -1.0, -1.0);
|
||||
|
||||
for (int i = 0; i < int(MAX_LIGHTS); i++)
|
||||
{
|
||||
vec3 LightVector = uLightPosition[i] - inVertexPosition;
|
||||
|
||||
vLightVector[i].x = dot(inVertexTangent, LightVector);
|
||||
vLightVector[i].y = dot(inVertexBinormal, LightVector);
|
||||
vLightVector[i].z = dot(inVertexNormal, LightVector);
|
||||
|
||||
vLightColor[i].x = dot(LightVector, LightVector);
|
||||
vLightColor[i].x *= uLightColor[i].a;
|
||||
vLightColor[i] = vec4(inversesqrt(vLightColor[i].x));
|
||||
vLightColor[i] *= uLightColor[i];
|
||||
vLightColor[i].a = inVertexColor.a;
|
||||
|
||||
vLightColor[i].x = clamp(vLightColor[i].x, 0.0, 1.0);
|
||||
vLightColor[i].y = clamp(vLightColor[i].y, 0.0, 1.0);
|
||||
vLightColor[i].z = clamp(vLightColor[i].z, 0.0, 1.0);
|
||||
}
|
||||
|
||||
vFogCoord = length((uWVMatrix * vec4(inVertexPosition, 1.0)).xyz);
|
||||
}
|
@ -343,8 +343,8 @@ void CAnimatedMeshSceneNode::render()
|
||||
// show normals
|
||||
if (DebugDataVisible & scene::EDS_NORMALS)
|
||||
{
|
||||
const f32 debugNormalLength = 1.f;
|
||||
const video::SColor debugNormalColor = video::SColor(255, 34, 221, 221);
|
||||
const f32 debugNormalLength = SceneManager->getParameters()->getAttributeAsFloat(DEBUG_NORMAL_LENGTH);
|
||||
const video::SColor debugNormalColor = SceneManager->getParameters()->getAttributeAsColor(DEBUG_NORMAL_COLOR);
|
||||
const u32 count = m->getMeshBufferCount();
|
||||
|
||||
// draw normals
|
||||
@ -652,6 +652,54 @@ bool CAnimatedMeshSceneNode::isReadOnlyMaterials() const
|
||||
}
|
||||
|
||||
|
||||
//! Writes attributes of the scene node.
|
||||
void CAnimatedMeshSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const
|
||||
{
|
||||
IAnimatedMeshSceneNode::serializeAttributes(out, options);
|
||||
|
||||
if (options && (options->Flags&io::EARWF_USE_RELATIVE_PATHS) && options->Filename)
|
||||
{
|
||||
const io::path path = SceneManager->getFileSystem()->getRelativeFilename(
|
||||
SceneManager->getFileSystem()->getAbsolutePath(SceneManager->getMeshCache()->getMeshName(Mesh).getPath()),
|
||||
options->Filename);
|
||||
out->addString("Mesh", path.c_str());
|
||||
}
|
||||
else
|
||||
out->addString("Mesh", SceneManager->getMeshCache()->getMeshName(Mesh).getPath().c_str());
|
||||
out->addBool("Looping", Looping);
|
||||
out->addBool("ReadOnlyMaterials", ReadOnlyMaterials);
|
||||
out->addFloat("FramesPerSecond", FramesPerSecond);
|
||||
out->addInt("StartFrame", StartFrame);
|
||||
out->addInt("EndFrame", EndFrame);
|
||||
}
|
||||
|
||||
|
||||
//! Reads attributes of the scene node.
|
||||
void CAnimatedMeshSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options)
|
||||
{
|
||||
IAnimatedMeshSceneNode::deserializeAttributes(in, options);
|
||||
|
||||
io::path oldMeshStr = SceneManager->getMeshCache()->getMeshName(Mesh);
|
||||
io::path newMeshStr = in->getAttributeAsString("Mesh");
|
||||
|
||||
Looping = in->getAttributeAsBool("Looping");
|
||||
ReadOnlyMaterials = in->getAttributeAsBool("ReadOnlyMaterials");
|
||||
FramesPerSecond = in->getAttributeAsFloat("FramesPerSecond");
|
||||
StartFrame = in->getAttributeAsInt("StartFrame");
|
||||
EndFrame = in->getAttributeAsInt("EndFrame");
|
||||
|
||||
if (newMeshStr != "" && oldMeshStr != newMeshStr)
|
||||
{
|
||||
IAnimatedMesh* newAnimatedMesh = SceneManager->getMesh(newMeshStr.c_str());
|
||||
|
||||
if (newAnimatedMesh)
|
||||
setMesh(newAnimatedMesh);
|
||||
}
|
||||
|
||||
// TODO: read animation names instead of frame begin and ends
|
||||
}
|
||||
|
||||
|
||||
//! Sets a new mesh
|
||||
void CAnimatedMeshSceneNode::setMesh(IAnimatedMesh* mesh)
|
||||
{
|
||||
|
@ -114,6 +114,12 @@ namespace scene
|
||||
//! Returns the current mesh
|
||||
virtual IAnimatedMesh* getMesh(void) _IRR_OVERRIDE_ { return Mesh; }
|
||||
|
||||
//! Writes attributes of the scene node.
|
||||
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Reads attributes of the scene node.
|
||||
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) _IRR_OVERRIDE_;
|
||||
|
||||
//! Returns type of the scene node
|
||||
virtual ESCENE_NODE_TYPE getType() const _IRR_OVERRIDE_ { return ESNT_ANIMATED_MESH; }
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -113,9 +113,126 @@ public:
|
||||
//! Sets an attribute as float value
|
||||
virtual void setAttribute(s32 index, f32 value) _IRR_OVERRIDE_;
|
||||
|
||||
/*
|
||||
|
||||
String Attribute
|
||||
|
||||
*/
|
||||
|
||||
//! Adds an attribute as string
|
||||
virtual void addString(const c8* attributeName, const c8* value) _IRR_OVERRIDE_;
|
||||
|
||||
//! 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) _IRR_OVERRIDE_;
|
||||
|
||||
//! Gets an attribute as string.
|
||||
//! \param attributeName: Name of the attribute to get.
|
||||
//! \param defaultNotFound Value returned when attributeName was not found
|
||||
//! \return Returns value of the attribute previously set by setAttribute()
|
||||
//! or defaultNotFound if attribute is not set.
|
||||
virtual core::stringc getAttributeAsString(const c8* attributeName, const core::stringc& defaultNotFound=core::stringc()) const _IRR_OVERRIDE_;
|
||||
|
||||
//! 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) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Returns attribute value as string by index.
|
||||
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
|
||||
virtual core::stringc getAttributeAsString(s32 index) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Sets an attribute value as string.
|
||||
//! \param attributeName: Name for the attribute
|
||||
virtual void setAttribute(s32 index, const c8* value) _IRR_OVERRIDE_;
|
||||
|
||||
// wide strings
|
||||
|
||||
//! Adds an attribute as string
|
||||
virtual void addString(const c8* attributeName, const wchar_t* value) _IRR_OVERRIDE_;
|
||||
|
||||
//! 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) _IRR_OVERRIDE_;
|
||||
|
||||
//! Gets an attribute as string.
|
||||
//! \param attributeName: Name of the attribute to get.
|
||||
//! \param defaultNotFound Value returned when attributeName was not found
|
||||
//! \return Returns value of the attribute previously set by setAttribute()
|
||||
//! or defaultNotFound if attribute is not set.
|
||||
virtual core::stringw getAttributeAsStringW(const c8* attributeName, const core::stringw& defaultNotFound = core::stringw()) const _IRR_OVERRIDE_;
|
||||
|
||||
//! 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) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Returns attribute value as string by index.
|
||||
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
|
||||
virtual core::stringw getAttributeAsStringW(s32 index) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Sets an attribute value as string.
|
||||
//! \param attributeName: Name for the attribute
|
||||
virtual void setAttribute(s32 index, const wchar_t* value) _IRR_OVERRIDE_;
|
||||
|
||||
/*
|
||||
|
||||
Binary Data Attribute
|
||||
|
||||
*/
|
||||
|
||||
//! Adds an attribute as binary data
|
||||
virtual void addBinary(const c8* attributeName, void* data, s32 dataSizeInBytes) _IRR_OVERRIDE_;
|
||||
|
||||
//! Sets an attribute as binary data
|
||||
virtual void setAttribute(const c8* attributeName, void* data, s32 dataSizeInBytes) _IRR_OVERRIDE_;
|
||||
|
||||
//! Gets an attribute as binary data
|
||||
//! \param attributeName: Name of the attribute to get.
|
||||
virtual void getAttributeAsBinaryData(const c8* attributeName, void* outData, s32 maxSizeInBytes) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Gets an attribute as binary data
|
||||
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
|
||||
virtual void getAttributeAsBinaryData(s32 index, void* outData, s32 maxSizeInBytes) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Sets an attribute as binary data
|
||||
virtual void setAttribute(s32 index, void* data, s32 dataSizeInBytes) _IRR_OVERRIDE_;
|
||||
|
||||
|
||||
/*
|
||||
|
||||
Array Attribute
|
||||
|
||||
*/
|
||||
|
||||
//! Adds an attribute as wide string array
|
||||
virtual void addArray(const c8* attributeName, const core::array<core::stringw>& value) _IRR_OVERRIDE_;
|
||||
|
||||
//! 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) _IRR_OVERRIDE_;
|
||||
|
||||
//! Gets an attribute as an array of wide strings.
|
||||
//! \param attributeName: Name of the attribute to get.
|
||||
//! \param defaultNotFound Value returned when attributeName was not found
|
||||
//! \return Returns value of the attribute previously set by setAttribute()
|
||||
//! or defaultNotFound if attribute is not set.
|
||||
virtual core::array<core::stringw> getAttributeAsArray(const c8* attributeName, const core::array<core::stringw>& defaultNotFound = core::array<core::stringw>()) const _IRR_OVERRIDE_;
|
||||
|
||||
//! 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) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Sets an attribute as an array of wide strings
|
||||
virtual void setAttribute(s32 index, const core::array<core::stringw>& value) _IRR_OVERRIDE_;
|
||||
|
||||
/*
|
||||
|
||||
Bool Attribute
|
||||
|
||||
*/
|
||||
|
||||
//! Adds an attribute as bool
|
||||
@ -137,6 +254,463 @@ public:
|
||||
//! Sets an attribute as boolean value
|
||||
virtual void setAttribute(s32 index, bool value) _IRR_OVERRIDE_;
|
||||
|
||||
/*
|
||||
|
||||
Enumeration Attribute
|
||||
|
||||
*/
|
||||
|
||||
//! Adds an attribute as enum
|
||||
virtual void addEnum(const c8* attributeName, const c8* enumValue, const c8* const* enumerationLiterals) _IRR_OVERRIDE_;
|
||||
|
||||
//! Adds an attribute as enum
|
||||
virtual void addEnum(const c8* attributeName, s32 enumValue, const c8* const* enumerationLiterals) _IRR_OVERRIDE_;
|
||||
|
||||
//! Sets an attribute as enumeration
|
||||
virtual void setAttribute(const c8* attributeName, const c8* enumValue, const c8* const* enumerationLiterals) _IRR_OVERRIDE_;
|
||||
|
||||
//! Gets an attribute as enumeration
|
||||
//! \param attributeName: Name of the attribute to get.
|
||||
//! \param defaultNotFound Value returned when attributeName was not found
|
||||
//! \return Returns value of the attribute previously set by setAttribute()
|
||||
virtual const c8* getAttributeAsEnumeration(const c8* attributeName, const c8* defaultNotFound = 0) const _IRR_OVERRIDE_;
|
||||
|
||||
//! 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, s32 defaultNotFound ) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Gets an attribute as enumeration
|
||||
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
|
||||
virtual s32 getAttributeAsEnumeration(s32 index, const c8* const* enumerationLiteralsToUse, s32 defaultNotFound) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Gets an attribute as enumeration
|
||||
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
|
||||
virtual const c8* getAttributeAsEnumeration(s32 index) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Gets the list of enumeration literals of an enumeration attribute
|
||||
//! \param attributeName: Name of the attribute to get.
|
||||
virtual void getAttributeEnumerationLiteralsOfEnumeration(const c8* attributeName, core::array<core::stringc>& outLiterals) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Gets the list of enumeration literals of an enumeration attribute
|
||||
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
|
||||
virtual void getAttributeEnumerationLiteralsOfEnumeration(s32 index, core::array<core::stringc>& outLiterals) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Sets an attribute as enumeration
|
||||
virtual void setAttribute(s32 index, const c8* enumValue, const c8* const* enumerationLiterals) _IRR_OVERRIDE_;
|
||||
|
||||
|
||||
/*
|
||||
|
||||
SColor Attribute
|
||||
|
||||
*/
|
||||
|
||||
//! Adds an attribute as color
|
||||
virtual void addColor(const c8* attributeName, video::SColor value) _IRR_OVERRIDE_;
|
||||
|
||||
//! Sets a attribute as color
|
||||
virtual void setAttribute(const c8* attributeName, video::SColor color) _IRR_OVERRIDE_;
|
||||
|
||||
//! Gets an attribute as color
|
||||
//! \param attributeName: Name of the attribute to get.
|
||||
//! \param defaultNotFound Value returned when attributeName was not found
|
||||
//! \return Returns value of the attribute previously set by setAttribute()
|
||||
virtual video::SColor getAttributeAsColor(const c8* attributeName, const video::SColor& defaultNotFound = video::SColor(0)) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Gets an attribute as color
|
||||
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
|
||||
virtual video::SColor getAttributeAsColor(s32 index) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Sets an attribute as color
|
||||
virtual void setAttribute(s32 index, video::SColor color) _IRR_OVERRIDE_;
|
||||
|
||||
/*
|
||||
|
||||
SColorf Attribute
|
||||
|
||||
*/
|
||||
|
||||
//! Adds an attribute as floating point color
|
||||
virtual void addColorf(const c8* attributeName, video::SColorf value) _IRR_OVERRIDE_;
|
||||
|
||||
//! Sets a attribute as floating point color
|
||||
virtual void setAttribute(const c8* attributeName, video::SColorf color) _IRR_OVERRIDE_;
|
||||
|
||||
//! Gets an attribute as floating point color
|
||||
//! \param attributeName: Name of the attribute to get.
|
||||
//! \param defaultNotFound Value returned when attributeName was not found
|
||||
//! \return Returns value of the attribute previously set by setAttribute()
|
||||
virtual video::SColorf getAttributeAsColorf(const c8* attributeName, const video::SColorf& defaultNotFound = video::SColorf(0)) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Gets an attribute as floating point color
|
||||
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
|
||||
virtual video::SColorf getAttributeAsColorf(s32 index) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Sets an attribute as floating point color
|
||||
virtual void setAttribute(s32 index, video::SColorf color) _IRR_OVERRIDE_;
|
||||
|
||||
|
||||
/*
|
||||
|
||||
Vector3d Attribute
|
||||
|
||||
*/
|
||||
|
||||
//! Adds an attribute as 3d vector
|
||||
virtual void addVector3d(const c8* attributeName, const core::vector3df& value) _IRR_OVERRIDE_;
|
||||
|
||||
//! Sets a attribute as 3d vector
|
||||
virtual void setAttribute(const c8* attributeName, const core::vector3df& v) _IRR_OVERRIDE_;
|
||||
|
||||
//! Gets an attribute as 3d vector
|
||||
//! \param attributeName: Name of the attribute to get.
|
||||
//! \param defaultNotFound Value returned when attributeName was not found
|
||||
//! \return Returns value of the attribute previously set by setAttribute()
|
||||
virtual core::vector3df getAttributeAsVector3d(const c8* attributeName, const core::vector3df& defaultNotFound=core::vector3df(0,0,0)) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Gets an attribute as 3d vector
|
||||
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
|
||||
virtual core::vector3df getAttributeAsVector3d(s32 index) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Sets an attribute as vector
|
||||
virtual void setAttribute(s32 index, const core::vector3df& v) _IRR_OVERRIDE_;
|
||||
|
||||
|
||||
/*
|
||||
|
||||
Vector2d Attribute
|
||||
|
||||
*/
|
||||
|
||||
//! Adds an attribute as 2d vector
|
||||
virtual void addVector2d(const c8* attributeName, const core::vector2df& value) _IRR_OVERRIDE_;
|
||||
|
||||
//! Sets a attribute as 2d vector
|
||||
virtual void setAttribute(const c8* attributeName, const core::vector2df& v) _IRR_OVERRIDE_;
|
||||
|
||||
//! Gets an attribute as 2d vector
|
||||
//! \param attributeName: Name of the attribute to get.
|
||||
//! \param defaultNotFound Value returned when attributeName was not found
|
||||
//! \return Returns value of the attribute previously set by setAttribute()
|
||||
virtual core::vector2df getAttributeAsVector2d(const c8* attributeName, const core::vector2df& defaultNotFound=core::vector2df(0,0)) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Gets an attribute as 3d vector
|
||||
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
|
||||
virtual core::vector2df getAttributeAsVector2d(s32 index) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Sets an attribute as vector
|
||||
virtual void setAttribute(s32 index, const core::vector2df& v) _IRR_OVERRIDE_;
|
||||
|
||||
|
||||
/*
|
||||
|
||||
Position2d Attribute
|
||||
|
||||
*/
|
||||
|
||||
//! Adds an attribute as 2d position
|
||||
virtual void addPosition2d(const c8* attributeName, const core::position2di& value) _IRR_OVERRIDE_;
|
||||
|
||||
//! Sets a attribute as 2d position
|
||||
virtual void setAttribute(const c8* attributeName, const core::position2di& v) _IRR_OVERRIDE_;
|
||||
|
||||
//! Gets an attribute as position
|
||||
//! \param attributeName: Name of the attribute to get.
|
||||
//! \param defaultNotFound Value returned when attributeName was not found
|
||||
//! \return Returns value of the attribute previously set by setAttribute()
|
||||
virtual core::position2di getAttributeAsPosition2d(const c8* attributeName, const core::position2di& defaultNotFound=core::position2di(0,0)) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Gets an attribute as position
|
||||
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
|
||||
virtual core::position2di getAttributeAsPosition2d(s32 index) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Sets an attribute as 2d position
|
||||
virtual void setAttribute(s32 index, const core::position2di& v) _IRR_OVERRIDE_;
|
||||
|
||||
/*
|
||||
|
||||
Rectangle Attribute
|
||||
|
||||
*/
|
||||
|
||||
//! Adds an attribute as rectangle
|
||||
virtual void addRect(const c8* attributeName, const core::rect<s32>& value) _IRR_OVERRIDE_;
|
||||
|
||||
//! Sets an attribute as rectangle
|
||||
virtual void setAttribute(const c8* attributeName, const core::rect<s32>& v) _IRR_OVERRIDE_;
|
||||
|
||||
//! Gets an attribute as rectangle
|
||||
//! \param attributeName: Name of the attribute to get.
|
||||
//! \param defaultNotFound Value returned when attributeName was not found
|
||||
//! \return Returns value of the attribute previously set by setAttribute()
|
||||
virtual core::rect<s32> getAttributeAsRect(const c8* attributeName, const core::rect<s32>& defaultNotFound = core::rect<s32>()) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Gets an attribute as rectangle
|
||||
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
|
||||
virtual core::rect<s32> getAttributeAsRect(s32 index) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Sets an attribute as rectangle
|
||||
virtual void setAttribute(s32 index, const core::rect<s32>& v) _IRR_OVERRIDE_;
|
||||
|
||||
|
||||
/*
|
||||
|
||||
Dimension2d Attribute
|
||||
|
||||
*/
|
||||
|
||||
//! Adds an attribute as dimension2d
|
||||
virtual void addDimension2d(const c8* attributeName, const core::dimension2d<u32>& value) _IRR_OVERRIDE_;
|
||||
|
||||
//! Sets an attribute as dimension2d
|
||||
virtual void setAttribute(const c8* attributeName, const core::dimension2d<u32>& v) _IRR_OVERRIDE_;
|
||||
|
||||
//! Gets an attribute as dimension2d
|
||||
//! \param attributeName: Name of the attribute to get.
|
||||
//! \param defaultNotFound Value returned when attributeName was not found
|
||||
//! \return Returns value of the attribute previously set by setAttribute()
|
||||
virtual core::dimension2d<u32> getAttributeAsDimension2d(const c8* attributeName, const core::dimension2d<u32>& defaultNotFound = core::dimension2d<u32>()) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Gets an attribute as dimension2d
|
||||
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
|
||||
virtual core::dimension2d<u32> getAttributeAsDimension2d(s32 index) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Sets an attribute as dimension2d
|
||||
virtual void setAttribute(s32 index, const core::dimension2d<u32>& v) _IRR_OVERRIDE_;
|
||||
|
||||
|
||||
/*
|
||||
|
||||
matrix attribute
|
||||
|
||||
*/
|
||||
|
||||
//! Adds an attribute as matrix
|
||||
virtual void addMatrix(const c8* attributeName, const core::matrix4& v) _IRR_OVERRIDE_;
|
||||
|
||||
//! Sets an attribute as matrix
|
||||
virtual void setAttribute(const c8* attributeName, const core::matrix4& v) _IRR_OVERRIDE_;
|
||||
|
||||
//! Gets an attribute as a matrix4
|
||||
//! \param attributeName: Name of the attribute to get.
|
||||
//! \param defaultNotFound Value returned when attributeName was not found
|
||||
//! \return Returns value of the attribute previously set by setAttribute()
|
||||
virtual core::matrix4 getAttributeAsMatrix(const c8* attributeName, const core::matrix4& defaultNotFound=core::matrix4()) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Gets an attribute as matrix
|
||||
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
|
||||
virtual core::matrix4 getAttributeAsMatrix(s32 index) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Sets an attribute as matrix
|
||||
virtual void setAttribute(s32 index, const core::matrix4& v) _IRR_OVERRIDE_;
|
||||
|
||||
/*
|
||||
quaternion attribute
|
||||
|
||||
*/
|
||||
|
||||
//! Adds an attribute as quaternion
|
||||
virtual void addQuaternion(const c8* attributeName, const core::quaternion& v) _IRR_OVERRIDE_;
|
||||
|
||||
//! Sets an attribute as quaternion
|
||||
virtual void setAttribute(const c8* attributeName, const core::quaternion& v) _IRR_OVERRIDE_;
|
||||
|
||||
//! Gets an attribute as a quaternion
|
||||
//! \param attributeName: Name of the attribute to get.
|
||||
//! \param defaultNotFound Value returned when attributeName was not found
|
||||
//! \return Returns value of the attribute previously set by setAttribute()
|
||||
virtual core::quaternion getAttributeAsQuaternion(const c8* attributeName, const core::quaternion& defaultNotFound=core::quaternion(0,1,0, 0)) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Gets an attribute as quaternion
|
||||
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
|
||||
virtual core::quaternion getAttributeAsQuaternion(s32 index) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Sets an attribute as quaternion
|
||||
virtual void setAttribute(s32 index, const core::quaternion& v) _IRR_OVERRIDE_;
|
||||
|
||||
/*
|
||||
|
||||
3d bounding box
|
||||
|
||||
*/
|
||||
|
||||
//! Adds an attribute as axis aligned bounding box
|
||||
virtual void addBox3d(const c8* attributeName, const core::aabbox3df& v) _IRR_OVERRIDE_;
|
||||
|
||||
//! Sets an attribute as axis aligned bounding box
|
||||
virtual void setAttribute(const c8* attributeName, const core::aabbox3df& v) _IRR_OVERRIDE_;
|
||||
|
||||
//! Gets an attribute as a axis aligned bounding box
|
||||
//! \param attributeName: Name of the attribute to get.
|
||||
//! \param defaultNotFound Value returned when attributeName was not found
|
||||
//! \return Returns value of the attribute previously set by setAttribute()
|
||||
virtual core::aabbox3df getAttributeAsBox3d(const c8* attributeName, const core::aabbox3df& defaultNotFound=core::aabbox3df(0,0,0, 0,0,0)) const _IRR_OVERRIDE_;
|
||||
|
||||
//! 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) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Sets an attribute as axis aligned bounding box
|
||||
virtual void setAttribute(s32 index, const core::aabbox3df& v) _IRR_OVERRIDE_;
|
||||
|
||||
/*
|
||||
|
||||
plane
|
||||
|
||||
*/
|
||||
|
||||
//! Adds an attribute as 3d plane
|
||||
virtual void addPlane3d(const c8* attributeName, const core::plane3df& v) _IRR_OVERRIDE_;
|
||||
|
||||
//! Sets an attribute as 3d plane
|
||||
virtual void setAttribute(const c8* attributeName, const core::plane3df& v) _IRR_OVERRIDE_;
|
||||
|
||||
//! Gets an attribute as a 3d plane
|
||||
//! \param attributeName: Name of the attribute to get.
|
||||
//! \param defaultNotFound Value returned when attributeName was not found
|
||||
//! \return Returns value of the attribute previously set by setAttribute()
|
||||
virtual core::plane3df getAttributeAsPlane3d(const c8* attributeName, const core::plane3df& defaultNotFound=core::plane3df(0,0,0, 0,1,0)) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Gets an attribute as 3d plane
|
||||
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
|
||||
virtual core::plane3df getAttributeAsPlane3d(s32 index) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Sets an attribute as 3d plane
|
||||
virtual void setAttribute(s32 index, const core::plane3df& v) _IRR_OVERRIDE_;
|
||||
|
||||
|
||||
/*
|
||||
|
||||
3d triangle
|
||||
|
||||
*/
|
||||
|
||||
//! Adds an attribute as 3d triangle
|
||||
virtual void addTriangle3d(const c8* attributeName, const core::triangle3df& v) _IRR_OVERRIDE_;
|
||||
|
||||
//! Sets an attribute as 3d triangle
|
||||
virtual void setAttribute(const c8* attributeName, const core::triangle3df& v) _IRR_OVERRIDE_;
|
||||
|
||||
//! Gets an attribute as a 3d triangle
|
||||
//! \param attributeName: Name of the attribute to get.
|
||||
//! \param defaultNotFound Value returned when attributeName was not found
|
||||
//! \return Returns value of the attribute previously set by setAttribute()
|
||||
virtual core::triangle3df getAttributeAsTriangle3d(const c8* attributeName, const core::triangle3df& defaultNotFound = core::triangle3df(core::vector3df(0,0,0), core::vector3df(0,0,0), core::vector3df(0,0,0))) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Gets an attribute as 3d triangle
|
||||
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
|
||||
virtual core::triangle3df getAttributeAsTriangle3d(s32 index) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Sets an attribute as 3d triangle
|
||||
virtual void setAttribute(s32 index, const core::triangle3df& v) _IRR_OVERRIDE_;
|
||||
|
||||
|
||||
/*
|
||||
|
||||
line 2d
|
||||
|
||||
*/
|
||||
|
||||
//! Adds an attribute as a 2d line
|
||||
virtual void addLine2d(const c8* attributeName, const core::line2df& v) _IRR_OVERRIDE_;
|
||||
|
||||
//! Sets an attribute as a 2d line
|
||||
virtual void setAttribute(const c8* attributeName, const core::line2df& v) _IRR_OVERRIDE_;
|
||||
|
||||
//! Gets an attribute as a 2d line
|
||||
//! \param attributeName: Name of the attribute to get.
|
||||
//! \param defaultNotFound Value returned when attributeName was not found
|
||||
//! \return Returns value of the attribute previously set by setAttribute()
|
||||
virtual core::line2df getAttributeAsLine2d(const c8* attributeName, const core::line2df& defaultNotFound = core::line2df(0,0, 0,0)) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Gets an attribute as a 2d line
|
||||
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
|
||||
virtual core::line2df getAttributeAsLine2d(s32 index) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Sets an attribute as a 2d line
|
||||
virtual void setAttribute(s32 index, const core::line2df& v) _IRR_OVERRIDE_;
|
||||
|
||||
|
||||
/*
|
||||
|
||||
line 3d
|
||||
|
||||
*/
|
||||
|
||||
//! Adds an attribute as a 3d line
|
||||
virtual void addLine3d(const c8* attributeName, const core::line3df& v) _IRR_OVERRIDE_;
|
||||
|
||||
//! Sets an attribute as a 3d line
|
||||
virtual void setAttribute(const c8* attributeName, const core::line3df& v) _IRR_OVERRIDE_;
|
||||
|
||||
//! Gets an attribute as a 3d line
|
||||
//! \param attributeName: Name of the attribute to get.
|
||||
//! \param defaultNotFound Value returned when attributeName was not found
|
||||
//! \return Returns value of the attribute previously set by setAttribute()
|
||||
virtual core::line3df getAttributeAsLine3d(const c8* attributeName, const core::line3df& defaultNotFound=core::line3df(0,0,0, 0,0,0)) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Gets an attribute as a 3d line
|
||||
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
|
||||
virtual core::line3df getAttributeAsLine3d(s32 index) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Sets an attribute as a 3d line
|
||||
virtual void setAttribute(s32 index, const core::line3df& v) _IRR_OVERRIDE_;
|
||||
|
||||
|
||||
/*
|
||||
|
||||
Texture Attribute
|
||||
|
||||
*/
|
||||
|
||||
//! Adds an attribute as texture reference
|
||||
virtual void addTexture(const c8* attributeName, video::ITexture* texture, const io::path& filename = "") _IRR_OVERRIDE_;
|
||||
|
||||
//! Sets an attribute as texture reference
|
||||
virtual void setAttribute(const c8* attributeName, video::ITexture* texture, const io::path& filename = "") _IRR_OVERRIDE_;
|
||||
|
||||
//! Gets an attribute as texture reference
|
||||
//! \param attributeName: Name of the attribute to get.
|
||||
//! \param defaultNotFound Value returned when attributeName was not found
|
||||
virtual video::ITexture* getAttributeAsTexture(const c8* attributeName, video::ITexture* defaultNotFound=0) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Gets an attribute as texture reference
|
||||
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
|
||||
virtual video::ITexture* getAttributeAsTexture(s32 index) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Sets an attribute as texture reference
|
||||
virtual void setAttribute(s32 index, video::ITexture* texture, const io::path& filename = "") _IRR_OVERRIDE_;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
User Pointer Attribute
|
||||
|
||||
*/
|
||||
|
||||
//! Adds an attribute as user pointer
|
||||
virtual void addUserPointer(const c8* attributeName, void* userPointer) _IRR_OVERRIDE_;
|
||||
|
||||
//! Sets an attribute as user pointer
|
||||
virtual void setAttribute(const c8* attributeName, void* userPointer) _IRR_OVERRIDE_;
|
||||
|
||||
//! Gets an attribute as user pointer
|
||||
//! \param attributeName: Name of the attribute to get.
|
||||
//! \param defaultNotFound Value returned when attributeName was not found
|
||||
virtual void* getAttributeAsUserPointer(const c8* attributeName, void* defaultNotFound = 0) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Gets an attribute as user pointer
|
||||
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
|
||||
virtual void* getAttributeAsUserPointer(s32 index) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Sets an attribute as user pointer
|
||||
virtual void setAttribute(s32 index, void* userPointer) _IRR_OVERRIDE_;
|
||||
|
||||
protected:
|
||||
|
||||
core::array<IAttribute*> Attributes;
|
||||
|
@ -26,7 +26,7 @@ namespace scene
|
||||
|
||||
//! Constructor
|
||||
CB3DMeshFileLoader::CB3DMeshFileLoader(scene::ISceneManager* smgr)
|
||||
: AnimatedMesh(0), B3DFile(0), NormalsInFile(false),
|
||||
: SceneManager(smgr), AnimatedMesh(0), B3DFile(0), NormalsInFile(false),
|
||||
HasVertexColors(false), ShowWarning(true)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
@ -130,8 +130,7 @@ bool CB3DMeshFileLoader::load()
|
||||
else
|
||||
{
|
||||
os::Printer::log("Unknown chunk found in mesh base - skipping");
|
||||
if (!B3DFile->seek(B3dStack.getLast().startposition + B3dStack.getLast().length))
|
||||
return false;
|
||||
B3DFile->seek(B3dStack.getLast().startposition + B3dStack.getLast().length);
|
||||
B3dStack.erase(B3dStack.size()-1);
|
||||
}
|
||||
}
|
||||
@ -227,8 +226,7 @@ bool CB3DMeshFileLoader::readChunkNODE(CSkinnedMesh::SJoint *inJoint)
|
||||
else
|
||||
{
|
||||
os::Printer::log("Unknown chunk found in node chunk - skipping");
|
||||
if (!B3DFile->seek(B3dStack.getLast().startposition + B3dStack.getLast().length))
|
||||
return false;
|
||||
B3DFile->seek(B3dStack.getLast().startposition + B3dStack.getLast().length);
|
||||
B3dStack.erase(B3dStack.size()-1);
|
||||
}
|
||||
}
|
||||
@ -310,8 +308,7 @@ bool CB3DMeshFileLoader::readChunkMESH(CSkinnedMesh::SJoint *inJoint)
|
||||
else
|
||||
{
|
||||
os::Printer::log("Unknown chunk found in mesh - skipping");
|
||||
if (!B3DFile->seek(B3dStack.getLast().startposition + B3dStack.getLast().length))
|
||||
return false;
|
||||
B3DFile->seek(B3dStack.getLast().startposition + B3dStack.getLast().length);
|
||||
B3dStack.erase(B3dStack.size()-1);
|
||||
}
|
||||
}
|
||||
|
@ -68,6 +68,7 @@ private:
|
||||
|
||||
core::array<video::S3DVertex2TCoords> BaseVertices;
|
||||
|
||||
ISceneManager* SceneManager;
|
||||
CSkinnedMesh* AnimatedMesh;
|
||||
io::IReadFile* B3DFile;
|
||||
|
||||
|
@ -220,6 +220,42 @@ void CBillboardSceneNode::getSize(f32& height, f32& bottomEdgeWidth,
|
||||
}
|
||||
|
||||
|
||||
//! Writes attributes of the scene node.
|
||||
void CBillboardSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const
|
||||
{
|
||||
IBillboardSceneNode::serializeAttributes(out, options);
|
||||
|
||||
out->addFloat("Width", Size.Width);
|
||||
out->addFloat("TopEdgeWidth", TopEdgeWidth);
|
||||
out->addFloat("Height", Size.Height);
|
||||
out->addColor("Shade_Top", Buffer->Vertices[1].Color);
|
||||
out->addColor("Shade_Down", Buffer->Vertices[0].Color);
|
||||
}
|
||||
|
||||
|
||||
//! Reads attributes of the scene node.
|
||||
void CBillboardSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options)
|
||||
{
|
||||
IBillboardSceneNode::deserializeAttributes(in, options);
|
||||
|
||||
Size.Width = in->getAttributeAsFloat("Width");
|
||||
Size.Height = in->getAttributeAsFloat("Height");
|
||||
|
||||
if (in->existsAttribute("TopEdgeWidth"))
|
||||
{
|
||||
TopEdgeWidth = in->getAttributeAsFloat("TopEdgeWidth");
|
||||
if (Size.Width != TopEdgeWidth)
|
||||
setSize(Size.Height, Size.Width, TopEdgeWidth);
|
||||
}
|
||||
else
|
||||
setSize(Size);
|
||||
Buffer->Vertices[1].Color = in->getAttributeAsColor("Shade_Top");
|
||||
Buffer->Vertices[0].Color = in->getAttributeAsColor("Shade_Down");
|
||||
Buffer->Vertices[2].Color = Buffer->Vertices[1].Color;
|
||||
Buffer->Vertices[3].Color = Buffer->Vertices[0].Color;
|
||||
}
|
||||
|
||||
|
||||
//! Set the color of all vertices of the billboard
|
||||
//! \param overallColor: the color to set
|
||||
void CBillboardSceneNode::setColor(const video::SColor& overallColor)
|
||||
|
@ -72,6 +72,12 @@ public:
|
||||
//! Get the real boundingbox used by the billboard (which depends on the active camera)
|
||||
virtual const core::aabbox3d<f32>& getTransformedBillboardBoundingBox(const irr::scene::ICameraSceneNode* camera) _IRR_OVERRIDE_;
|
||||
|
||||
//! Writes attributes of the scene node.
|
||||
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Reads attributes of the scene node.
|
||||
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) _IRR_OVERRIDE_;
|
||||
|
||||
//! Returns type of the scene node
|
||||
virtual ESCENE_NODE_TYPE getType() const _IRR_OVERRIDE_ { return ESNT_BILLBOARD; }
|
||||
|
||||
|
@ -85,6 +85,96 @@ inline u32 GetClipCode( const AbsRectangle &r, const core::position2d<s32> &p )
|
||||
return code;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Cohen Sutherland clipping
|
||||
@return: 1 if valid
|
||||
*/
|
||||
|
||||
static int ClipLine(const AbsRectangle &clipping,
|
||||
core::position2d<s32> &p0,
|
||||
core::position2d<s32> &p1,
|
||||
const core::position2d<s32>& p0_in,
|
||||
const core::position2d<s32>& p1_in)
|
||||
{
|
||||
u32 code0;
|
||||
u32 code1;
|
||||
u32 code;
|
||||
|
||||
p0 = p0_in;
|
||||
p1 = p1_in;
|
||||
|
||||
code0 = GetClipCode( clipping, p0 );
|
||||
code1 = GetClipCode( clipping, p1 );
|
||||
|
||||
// trivial accepted
|
||||
while ( code0 | code1 )
|
||||
{
|
||||
s32 x=0;
|
||||
s32 y=0;
|
||||
|
||||
// trivial reject
|
||||
if ( code0 & code1 )
|
||||
return 0;
|
||||
|
||||
if ( code0 )
|
||||
{
|
||||
// clip first point
|
||||
code = code0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// clip last point
|
||||
code = code1;
|
||||
}
|
||||
|
||||
if ( (code & CLIPCODE_BOTTOM) == CLIPCODE_BOTTOM )
|
||||
{
|
||||
// clip bottom viewport
|
||||
y = clipping.y1;
|
||||
x = p0.X + ( p1.X - p0.X ) * ( y - p0.Y ) / ( p1.Y - p0.Y );
|
||||
}
|
||||
else
|
||||
if ( (code & CLIPCODE_TOP) == CLIPCODE_TOP )
|
||||
{
|
||||
// clip to viewport
|
||||
y = clipping.y0;
|
||||
x = p0.X + ( p1.X - p0.X ) * ( y - p0.Y ) / ( p1.Y - p0.Y );
|
||||
}
|
||||
else
|
||||
if ( (code & CLIPCODE_RIGHT) == CLIPCODE_RIGHT )
|
||||
{
|
||||
// clip right viewport
|
||||
x = clipping.x1;
|
||||
y = p0.Y + ( p1.Y - p0.Y ) * ( x - p0.X ) / ( p1.X - p0.X );
|
||||
}
|
||||
else
|
||||
if ( (code & CLIPCODE_LEFT) == CLIPCODE_LEFT )
|
||||
{
|
||||
// clip left viewport
|
||||
x = clipping.x0;
|
||||
y = p0.Y + ( p1.Y - p0.Y ) * ( x - p0.X ) / ( p1.X - p0.X );
|
||||
}
|
||||
|
||||
if ( code == code0 )
|
||||
{
|
||||
// modify first point
|
||||
p0.X = x;
|
||||
p0.Y = y;
|
||||
code0 = GetClipCode( clipping, p0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
// modify second point
|
||||
p1.X = x;
|
||||
p1.Y = y;
|
||||
code1 = GetClipCode( clipping, p1 );
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
*/
|
||||
inline void GetClip(AbsRectangle &clipping, video::IImage * t)
|
||||
@ -136,6 +226,263 @@ inline u32 PixelLerp32(const u32 source, const u32 value)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*/
|
||||
static void RenderLine32_Decal(video::IImage *t,
|
||||
const core::position2d<s32> &p0,
|
||||
const core::position2d<s32> &p1,
|
||||
u32 argb )
|
||||
{
|
||||
s32 dx = p1.X - p0.X;
|
||||
s32 dy = p1.Y - p0.Y;
|
||||
|
||||
s32 c;
|
||||
s32 m;
|
||||
s32 d = 0;
|
||||
s32 run;
|
||||
|
||||
s32 xInc = 4;
|
||||
s32 yInc = (s32) t->getPitch();
|
||||
|
||||
if ( dx < 0 )
|
||||
{
|
||||
xInc = -xInc;
|
||||
dx = -dx;
|
||||
}
|
||||
|
||||
if ( dy < 0 )
|
||||
{
|
||||
yInc = -yInc;
|
||||
dy = -dy;
|
||||
}
|
||||
|
||||
u32 *dst;
|
||||
dst = (u32*) ( (u8*) t->getData() + ( p0.Y * t->getPitch() ) + ( p0.X * 4 ) );
|
||||
|
||||
if ( dy > dx )
|
||||
{
|
||||
s32 tmp;
|
||||
tmp = dx;
|
||||
dx = dy;
|
||||
dy = tmp;
|
||||
tmp = xInc;
|
||||
xInc = yInc;
|
||||
yInc = tmp;
|
||||
}
|
||||
|
||||
c = dx << 1;
|
||||
m = dy << 1;
|
||||
|
||||
run = dx;
|
||||
do
|
||||
{
|
||||
*dst = argb;
|
||||
|
||||
dst = (u32*) ( (u8*) dst + xInc ); // x += xInc
|
||||
d += m;
|
||||
if ( d > dx )
|
||||
{
|
||||
dst = (u32*) ( (u8*) dst + yInc ); // y += yInc
|
||||
d -= c;
|
||||
}
|
||||
run -= 1;
|
||||
} while (run>=0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*/
|
||||
static void RenderLine32_Blend(video::IImage *t,
|
||||
const core::position2d<s32> &p0,
|
||||
const core::position2d<s32> &p1,
|
||||
u32 argb, u32 alpha)
|
||||
{
|
||||
s32 dx = p1.X - p0.X;
|
||||
s32 dy = p1.Y - p0.Y;
|
||||
|
||||
s32 c;
|
||||
s32 m;
|
||||
s32 d = 0;
|
||||
s32 run;
|
||||
|
||||
s32 xInc = 4;
|
||||
s32 yInc = (s32) t->getPitch();
|
||||
|
||||
if ( dx < 0 )
|
||||
{
|
||||
xInc = -xInc;
|
||||
dx = -dx;
|
||||
}
|
||||
|
||||
if ( dy < 0 )
|
||||
{
|
||||
yInc = -yInc;
|
||||
dy = -dy;
|
||||
}
|
||||
|
||||
u32 *dst;
|
||||
dst = (u32*) ( (u8*) t->getData() + ( p0.Y * t->getPitch() ) + ( p0.X * 4 ) );
|
||||
|
||||
if ( dy > dx )
|
||||
{
|
||||
s32 tmp;
|
||||
tmp = dx;
|
||||
dx = dy;
|
||||
dy = tmp;
|
||||
tmp = xInc;
|
||||
xInc = yInc;
|
||||
yInc = tmp;
|
||||
}
|
||||
|
||||
c = dx << 1;
|
||||
m = dy << 1;
|
||||
|
||||
run = dx;
|
||||
const u32 packA = packAlpha ( alpha );
|
||||
do
|
||||
{
|
||||
*dst = packA | PixelBlend32( *dst, argb, alpha );
|
||||
|
||||
dst = (u32*) ( (u8*) dst + xInc ); // x += xInc
|
||||
d += m;
|
||||
if ( d > dx )
|
||||
{
|
||||
dst = (u32*) ( (u8*) dst + yInc ); // y += yInc
|
||||
d -= c;
|
||||
}
|
||||
run -= 1;
|
||||
} while (run>=0);
|
||||
}
|
||||
|
||||
/*
|
||||
*/
|
||||
static void RenderLine16_Decal(video::IImage *t,
|
||||
const core::position2d<s32> &p0,
|
||||
const core::position2d<s32> &p1,
|
||||
u32 argb )
|
||||
{
|
||||
s32 dx = p1.X - p0.X;
|
||||
s32 dy = p1.Y - p0.Y;
|
||||
|
||||
s32 c;
|
||||
s32 m;
|
||||
s32 d = 0;
|
||||
s32 run;
|
||||
|
||||
s32 xInc = 2;
|
||||
s32 yInc = (s32) t->getPitch();
|
||||
|
||||
if ( dx < 0 )
|
||||
{
|
||||
xInc = -xInc;
|
||||
dx = -dx;
|
||||
}
|
||||
|
||||
if ( dy < 0 )
|
||||
{
|
||||
yInc = -yInc;
|
||||
dy = -dy;
|
||||
}
|
||||
|
||||
u16 *dst;
|
||||
dst = (u16*) ( (u8*) t->getData() + ( p0.Y * t->getPitch() ) + ( p0.X * 2 ) );
|
||||
|
||||
if ( dy > dx )
|
||||
{
|
||||
s32 tmp;
|
||||
tmp = dx;
|
||||
dx = dy;
|
||||
dy = tmp;
|
||||
tmp = xInc;
|
||||
xInc = yInc;
|
||||
yInc = tmp;
|
||||
}
|
||||
|
||||
c = dx << 1;
|
||||
m = dy << 1;
|
||||
|
||||
run = dx;
|
||||
do
|
||||
{
|
||||
*dst = (u16)argb;
|
||||
|
||||
dst = (u16*) ( (u8*) dst + xInc ); // x += xInc
|
||||
d += m;
|
||||
if ( d > dx )
|
||||
{
|
||||
dst = (u16*) ( (u8*) dst + yInc ); // y += yInc
|
||||
d -= c;
|
||||
}
|
||||
run -= 1;
|
||||
} while (run>=0);
|
||||
}
|
||||
|
||||
/*
|
||||
*/
|
||||
static void RenderLine16_Blend(video::IImage *t,
|
||||
const core::position2d<s32> &p0,
|
||||
const core::position2d<s32> &p1,
|
||||
u16 argb,
|
||||
u16 alpha)
|
||||
{
|
||||
s32 dx = p1.X - p0.X;
|
||||
s32 dy = p1.Y - p0.Y;
|
||||
|
||||
s32 c;
|
||||
s32 m;
|
||||
s32 d = 0;
|
||||
s32 run;
|
||||
|
||||
s32 xInc = 2;
|
||||
s32 yInc = (s32) t->getPitch();
|
||||
|
||||
if ( dx < 0 )
|
||||
{
|
||||
xInc = -xInc;
|
||||
dx = -dx;
|
||||
}
|
||||
|
||||
if ( dy < 0 )
|
||||
{
|
||||
yInc = -yInc;
|
||||
dy = -dy;
|
||||
}
|
||||
|
||||
u16 *dst;
|
||||
dst = (u16*) ( (u8*) t->getData() + ( p0.Y * t->getPitch() ) + ( p0.X * 2 ) );
|
||||
|
||||
if ( dy > dx )
|
||||
{
|
||||
s32 tmp;
|
||||
tmp = dx;
|
||||
dx = dy;
|
||||
dy = tmp;
|
||||
tmp = xInc;
|
||||
xInc = yInc;
|
||||
yInc = tmp;
|
||||
}
|
||||
|
||||
c = dx << 1;
|
||||
m = dy << 1;
|
||||
|
||||
run = dx;
|
||||
const u16 packA = alpha ? 0x8000 : 0;
|
||||
do
|
||||
{
|
||||
*dst = packA | PixelBlend16( *dst, argb, alpha );
|
||||
|
||||
dst = (u16*) ( (u8*) dst + xInc ); // x += xInc
|
||||
d += m;
|
||||
if ( d > dx )
|
||||
{
|
||||
dst = (u16*) ( (u8*) dst + yInc ); // y += yInc
|
||||
d -= c;
|
||||
}
|
||||
run -= 1;
|
||||
} while (run>=0);
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
*/
|
||||
static void executeBlit_TextureCopy_x_to_x( const SBlitJob * job )
|
||||
@ -1057,6 +1404,123 @@ static s32 Blit(eBlitter operation,
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if defined(SOFTWARE_DRIVER_2_2D_AS_2D)
|
||||
static s32 StretchBlit(eBlitter operation,
|
||||
video::IImage* dest, const core::rect<s32>* destClipping,const core::rect<s32> *destRect,
|
||||
video::IImage* const source,const core::rect<s32> *srcRect, const core::dimension2d<u32>* source_org,
|
||||
u32 argb)
|
||||
{
|
||||
tExecuteBlit blitter = getBlitter2( operation, dest, source );
|
||||
if ( 0 == blitter )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
SBlitJob job;
|
||||
|
||||
AbsRectangle destClip;
|
||||
AbsRectangle v;
|
||||
setClip(destClip, destClipping, dest, 0, 0);
|
||||
setClip(v, destRect, 0, 1, 0);
|
||||
if (!intersect(job.Dest, destClip, v))
|
||||
return 0;
|
||||
|
||||
// Clipping
|
||||
setClip ( job.Source, srcRect, source, 1, source_org);
|
||||
|
||||
job.width = job.Dest.x1-job.Dest.x0;
|
||||
job.height = job.Dest.y1-job.Dest.y0;
|
||||
|
||||
job.argb = argb;
|
||||
|
||||
// use original dest size, despite any clipping
|
||||
const int dst_w = v.x1 - v.x0; // destRect->getWidth();
|
||||
const int dst_h = v.y1 - v.y0; // destRect->getHeight();
|
||||
const int src_w = job.Source.x1 - job.Source.x0;
|
||||
const int src_h = job.Source.y1 - job.Source.y0;
|
||||
|
||||
job.stretch = dst_w != src_w || dst_h != src_h;
|
||||
job.x_stretch = dst_w ? (float)src_w / (float)dst_w : 1.f;
|
||||
job.y_stretch = dst_h ? (float)src_h / (float)dst_h : 1.f;
|
||||
|
||||
|
||||
if ( source )
|
||||
{
|
||||
job.srcPitch = source->getPitch();
|
||||
job.srcPixelMul = source->getBytesPerPixel();
|
||||
|
||||
//dest-clippling. advance source. loosing subpixel precision
|
||||
job.Source.x0 += (s32)floorf(job.x_stretch * (job.Dest.x0 - v.x0));
|
||||
job.Source.y0 += (s32)floorf(job.y_stretch * (job.Dest.y0 - v.y0));
|
||||
|
||||
job.src = (void*) ( (u8*) source->getData() + ( job.Source.y0 * job.srcPitch ) + ( job.Source.x0 * job.srcPixelMul ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
// use srcPitch for color operation on dest
|
||||
job.srcPitch = job.width * dest->getBytesPerPixel();
|
||||
}
|
||||
|
||||
job.dstPitch = dest->getPitch();
|
||||
job.dstPixelMul = dest->getBytesPerPixel();
|
||||
job.dst = (void*) ( (u8*) dest->getData() + ( job.Dest.y0 * job.dstPitch ) + ( job.Dest.x0 * job.dstPixelMul ) );
|
||||
|
||||
blitter( &job );
|
||||
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Methods for Software drivers
|
||||
//! draws a rectangle
|
||||
static void drawRectangle(video::IImage* img, const core::rect<s32>& rect, const video::SColor &color)
|
||||
{
|
||||
Blit(color.getAlpha() == 0xFF ? BLITTER_COLOR : BLITTER_COLOR_ALPHA,
|
||||
img, 0, &rect.UpperLeftCorner, 0, &rect, color.color);
|
||||
}
|
||||
|
||||
|
||||
//! draws a line from to with color
|
||||
static void drawLine(video::IImage* img, const core::position2d<s32>& from,
|
||||
const core::position2d<s32>& to, const video::SColor &color)
|
||||
{
|
||||
AbsRectangle clip;
|
||||
GetClip(clip, img);
|
||||
|
||||
core::position2d<s32> p[2];
|
||||
if (ClipLine( clip, p[0], p[1], from, to))
|
||||
{
|
||||
u32 alpha = extractAlpha(color.color);
|
||||
|
||||
switch(img->getColorFormat())
|
||||
{
|
||||
case video::ECF_A1R5G5B5:
|
||||
if (alpha == 256)
|
||||
{
|
||||
RenderLine16_Decal(img, p[0], p[1], video::A8R8G8B8toA1R5G5B5(color.color));
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderLine16_Blend(img, p[0], p[1], video::A8R8G8B8toA1R5G5B5(color.color), alpha >> 3);
|
||||
}
|
||||
break;
|
||||
case video::ECF_A8R8G8B8:
|
||||
if (alpha == 256)
|
||||
{
|
||||
RenderLine32_Decal(img, p[0], p[1], color.color);
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderLine32_Blend(img, p[0], p[1], color.color, alpha);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -96,6 +96,26 @@ void CBoneSceneNode::updateAbsolutePositionOfAllChildren()
|
||||
}
|
||||
|
||||
|
||||
void CBoneSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const
|
||||
{
|
||||
IBoneSceneNode::serializeAttributes(out, options);
|
||||
out->addInt("BoneIndex", BoneIndex);
|
||||
out->addEnum("AnimationMode", AnimationMode, BoneAnimationModeNames);
|
||||
}
|
||||
|
||||
|
||||
void CBoneSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options)
|
||||
{
|
||||
BoneIndex = in->getAttributeAsInt("BoneIndex");
|
||||
AnimationMode = (E_BONE_ANIMATION_MODE)in->getAttributeAsEnumeration("AnimationMode", BoneAnimationModeNames);
|
||||
// for legacy files (before 1.5)
|
||||
const core::stringc boneName = in->getAttributeAsString("BoneName");
|
||||
setName(boneName);
|
||||
IBoneSceneNode::deserializeAttributes(in, options);
|
||||
// TODO: add/replace bone in parent with bone from mesh
|
||||
}
|
||||
|
||||
|
||||
} // namespace scene
|
||||
} // namespace irr
|
||||
|
||||
|
@ -43,6 +43,12 @@ namespace scene
|
||||
|
||||
virtual void updateAbsolutePositionOfAllChildren() _IRR_OVERRIDE_;
|
||||
|
||||
//! Writes attributes of the scene node.
|
||||
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Reads attributes of the scene node.
|
||||
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) _IRR_OVERRIDE_;
|
||||
|
||||
//! How the relative transformation of the bone is used
|
||||
virtual void setSkinningSpace(E_BONE_SKINNING_SPACE space) _IRR_OVERRIDE_
|
||||
{
|
||||
|
@ -300,6 +300,41 @@ void CCameraSceneNode::recalculateViewArea()
|
||||
}
|
||||
|
||||
|
||||
//! Writes attributes of the scene node.
|
||||
void CCameraSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const
|
||||
{
|
||||
ICameraSceneNode::serializeAttributes(out, options);
|
||||
|
||||
out->addVector3d("Target", Target);
|
||||
out->addVector3d("UpVector", UpVector);
|
||||
out->addFloat("Fovy", Fovy);
|
||||
out->addFloat("Aspect", Aspect);
|
||||
out->addFloat("ZNear", ZNear);
|
||||
out->addFloat("ZFar", ZFar);
|
||||
out->addBool("Binding", TargetAndRotationAreBound);
|
||||
out->addBool("ReceiveInput", InputReceiverEnabled);
|
||||
}
|
||||
|
||||
//! Reads attributes of the scene node.
|
||||
void CCameraSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options)
|
||||
{
|
||||
ICameraSceneNode::deserializeAttributes(in, options);
|
||||
|
||||
Target = in->getAttributeAsVector3d("Target");
|
||||
UpVector = in->getAttributeAsVector3d("UpVector");
|
||||
Fovy = in->getAttributeAsFloat("Fovy");
|
||||
Aspect = in->getAttributeAsFloat("Aspect");
|
||||
ZNear = in->getAttributeAsFloat("ZNear");
|
||||
ZFar = in->getAttributeAsFloat("ZFar");
|
||||
TargetAndRotationAreBound = in->getAttributeAsBool("Binding");
|
||||
if ( in->findAttribute("ReceiveInput") )
|
||||
InputReceiverEnabled = in->getAttributeAsBool("ReceiveInput");
|
||||
|
||||
recalculateProjectionMatrix();
|
||||
recalculateViewArea();
|
||||
}
|
||||
|
||||
|
||||
//! Set the binding between the camera's rotation adn target.
|
||||
void CCameraSceneNode::bindTargetAndRotation(bool bound)
|
||||
{
|
||||
|
@ -130,6 +130,12 @@ namespace scene
|
||||
//! Returns if the input receiver of the camera is currently enabled.
|
||||
virtual bool isInputReceiverEnabled() const _IRR_OVERRIDE_;
|
||||
|
||||
//! Writes attributes of the scene node.
|
||||
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Reads attributes of the scene node.
|
||||
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) _IRR_OVERRIDE_;
|
||||
|
||||
//! Returns type of the scene node
|
||||
virtual ESCENE_NODE_TYPE getType() const _IRR_OVERRIDE_ { return ESNT_CAMERA; }
|
||||
|
||||
|
@ -760,9 +760,10 @@ void CColorConverter::convert_viaFormat(const void* sP, ECOLOR_FORMAT sF, s32 sN
|
||||
IRR_CASE_IIMAGE_COMPRESSED_FORMAT
|
||||
os::Printer::log("CColorConverter::convert_viaFormat method doesn't support compressed images.", ELL_WARNING);
|
||||
break;
|
||||
|
||||
#ifndef _DEBUG
|
||||
default:
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case ECF_R5G6B5:
|
||||
@ -783,9 +784,10 @@ void CColorConverter::convert_viaFormat(const void* sP, ECOLOR_FORMAT sF, s32 sN
|
||||
IRR_CASE_IIMAGE_COMPRESSED_FORMAT
|
||||
os::Printer::log("CColorConverter::convert_viaFormat method doesn't support compressed images.", ELL_WARNING);
|
||||
break;
|
||||
|
||||
#ifndef _DEBUG
|
||||
default:
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case ECF_A8R8G8B8:
|
||||
@ -806,9 +808,10 @@ void CColorConverter::convert_viaFormat(const void* sP, ECOLOR_FORMAT sF, s32 sN
|
||||
IRR_CASE_IIMAGE_COMPRESSED_FORMAT
|
||||
os::Printer::log("CColorConverter::convert_viaFormat method doesn't support compressed images.", ELL_WARNING);
|
||||
break;
|
||||
|
||||
#ifndef _DEBUG
|
||||
default:
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case ECF_R8G8B8:
|
||||
@ -829,17 +832,19 @@ void CColorConverter::convert_viaFormat(const void* sP, ECOLOR_FORMAT sF, s32 sN
|
||||
IRR_CASE_IIMAGE_COMPRESSED_FORMAT
|
||||
os::Printer::log("CColorConverter::convert_viaFormat method doesn't support compressed images.", ELL_WARNING);
|
||||
break;
|
||||
|
||||
#ifndef _DEBUG
|
||||
default:
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
IRR_CASE_IIMAGE_COMPRESSED_FORMAT
|
||||
os::Printer::log("CColorConverter::convert_viaFormat method doesn't support compressed images.", ELL_WARNING);
|
||||
break;
|
||||
|
||||
#ifndef _DEBUG
|
||||
default:
|
||||
break;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "CFileList.h"
|
||||
#include "stdio.h"
|
||||
#include "os.h"
|
||||
#include "CAttributes.h"
|
||||
#include "CReadFile.h"
|
||||
#include "CMemoryFile.h"
|
||||
#include "CLimitReadFile.h"
|
||||
@ -938,5 +939,12 @@ IFileSystem* createFileSystem()
|
||||
}
|
||||
|
||||
|
||||
//! Creates a new empty collection of attributes, usable for serialization and more.
|
||||
IAttributes* CFileSystem::createEmptyAttributes(video::IVideoDriver* driver)
|
||||
{
|
||||
return new CAttributes(driver);
|
||||
}
|
||||
|
||||
|
||||
} // end namespace irr
|
||||
} // end namespace io
|
||||
|
@ -127,6 +127,9 @@ public:
|
||||
//! determines if a file exists and would be able to be opened.
|
||||
virtual bool existFile(const io::path& filename) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Creates a new empty collection of attributes, usable for serialization and more.
|
||||
virtual IAttributes* createEmptyAttributes(video::IVideoDriver* driver) _IRR_OVERRIDE_;
|
||||
|
||||
private:
|
||||
|
||||
// don't expose, needs refactoring
|
||||
|
@ -556,6 +556,103 @@ bool CGUIButton::isDrawingBorder() const
|
||||
}
|
||||
|
||||
|
||||
//! Writes attributes of the element.
|
||||
void CGUIButton::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const
|
||||
{
|
||||
IGUIButton::serializeAttributes(out,options);
|
||||
|
||||
out->addBool ("PushButton", IsPushButton );
|
||||
if (IsPushButton)
|
||||
out->addBool("Pressed", Pressed);
|
||||
|
||||
for ( u32 i=0; i<(u32)EGBIS_COUNT; ++i )
|
||||
{
|
||||
if ( ButtonImages[i].Texture )
|
||||
{
|
||||
core::stringc name( GUIButtonImageStateNames[i] );
|
||||
out->addTexture(name.c_str(), ButtonImages[i].Texture);
|
||||
name += "Rect";
|
||||
out->addRect(name.c_str(), ButtonImages[i].SourceRect);
|
||||
}
|
||||
}
|
||||
|
||||
out->addBool ("UseAlphaChannel", UseAlphaChannel);
|
||||
out->addBool ("Border", DrawBorder);
|
||||
out->addBool ("ScaleImage", ScaleImage);
|
||||
|
||||
for ( u32 i=0; i<(u32)EGBS_COUNT; ++i )
|
||||
{
|
||||
if ( ButtonSprites[i].Index >= 0 )
|
||||
{
|
||||
core::stringc nameIndex( GUIButtonStateNames[i] );
|
||||
nameIndex += "Index";
|
||||
out->addInt(nameIndex.c_str(), ButtonSprites[i].Index );
|
||||
|
||||
core::stringc nameColor( GUIButtonStateNames[i] );
|
||||
nameColor += "Color";
|
||||
out->addColor(nameColor.c_str(), ButtonSprites[i].Color );
|
||||
|
||||
core::stringc nameLoop( GUIButtonStateNames[i] );
|
||||
nameLoop += "Loop";
|
||||
out->addBool(nameLoop.c_str(), ButtonSprites[i].Loop );
|
||||
|
||||
core::stringc nameScale( GUIButtonStateNames[i] );
|
||||
nameScale += "Scale";
|
||||
out->addBool(nameScale.c_str(), ButtonSprites[i].Scale );
|
||||
}
|
||||
}
|
||||
|
||||
// out->addString ("OverrideFont", OverrideFont);
|
||||
}
|
||||
|
||||
|
||||
//! Reads attributes of the element
|
||||
void CGUIButton::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0)
|
||||
{
|
||||
IGUIButton::deserializeAttributes(in,options);
|
||||
|
||||
IsPushButton = in->getAttributeAsBool("PushButton", IsPushButton);
|
||||
Pressed = IsPushButton ? in->getAttributeAsBool("Pressed", Pressed) : false;
|
||||
|
||||
for ( u32 i=0; i<(u32)EGBIS_COUNT; ++i )
|
||||
{
|
||||
core::stringc nameRect( GUIButtonImageStateNames[i] );
|
||||
nameRect += "Rect";
|
||||
|
||||
setImage((EGUI_BUTTON_IMAGE_STATE)i,
|
||||
in->getAttributeAsTexture(GUIButtonImageStateNames[i], ButtonImages[i].Texture),
|
||||
in->getAttributeAsRect(nameRect.c_str(), ButtonImages[i].SourceRect) );
|
||||
}
|
||||
|
||||
setDrawBorder(in->getAttributeAsBool("Border", DrawBorder));
|
||||
setUseAlphaChannel(in->getAttributeAsBool("UseAlphaChannel", UseAlphaChannel));
|
||||
setScaleImage(in->getAttributeAsBool("ScaleImage", ScaleImage));
|
||||
|
||||
for ( u32 i=0; i<(u32)EGBS_COUNT; ++i )
|
||||
{
|
||||
core::stringc nameIndex( GUIButtonStateNames[i] );
|
||||
nameIndex += "Index";
|
||||
ButtonSprites[i].Index = in->getAttributeAsInt(nameIndex.c_str(), ButtonSprites[i].Index );
|
||||
|
||||
core::stringc nameColor( GUIButtonStateNames[i] );
|
||||
nameColor += "Color";
|
||||
ButtonSprites[i].Color = in->getAttributeAsColor(nameColor.c_str(), ButtonSprites[i].Color );
|
||||
|
||||
core::stringc nameLoop( GUIButtonStateNames[i] );
|
||||
nameLoop += "Loop";
|
||||
ButtonSprites[i].Loop = in->getAttributeAsBool(nameLoop.c_str(), ButtonSprites[i].Loop );
|
||||
|
||||
core::stringc nameScale( GUIButtonStateNames[i] );
|
||||
nameScale += "Scale";
|
||||
ButtonSprites[i].Scale = in->getAttributeAsBool(nameScale.c_str(), ButtonSprites[i].Scale );
|
||||
}
|
||||
|
||||
// setOverrideFont(in->getAttributeAsString("OverrideFont"));
|
||||
|
||||
updateAbsolutePosition();
|
||||
}
|
||||
|
||||
|
||||
} // end namespace gui
|
||||
} // end namespace irr
|
||||
|
||||
|
@ -155,6 +155,12 @@ namespace gui
|
||||
return ClickControlState;
|
||||
}
|
||||
|
||||
//! Writes attributes of the element.
|
||||
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Reads attributes of the element
|
||||
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) _IRR_OVERRIDE_;
|
||||
|
||||
protected:
|
||||
void drawSprite(EGUI_BUTTON_STATE state, u32 startTime, const core::position2di& center);
|
||||
EGUI_BUTTON_IMAGE_STATE getImageState(bool pressed) const;
|
||||
|
@ -225,6 +225,28 @@ bool CGUICheckBox::isDrawBorderEnabled() const
|
||||
}
|
||||
|
||||
|
||||
//! Writes attributes of the element.
|
||||
void CGUICheckBox::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const
|
||||
{
|
||||
IGUICheckBox::serializeAttributes(out,options);
|
||||
|
||||
out->addBool("Checked", Checked);
|
||||
out->addBool("Border", Border);
|
||||
out->addBool("Background", Background);
|
||||
}
|
||||
|
||||
|
||||
//! Reads attributes of the element
|
||||
void CGUICheckBox::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0)
|
||||
{
|
||||
Checked = in->getAttributeAsBool ("Checked");
|
||||
Border = in->getAttributeAsBool ("Border", Border);
|
||||
Background = in->getAttributeAsBool ("Background", Background);
|
||||
|
||||
IGUICheckBox::deserializeAttributes(in,options);
|
||||
}
|
||||
|
||||
|
||||
} // end namespace gui
|
||||
} // end namespace irr
|
||||
|
||||
|
@ -48,6 +48,12 @@ namespace gui
|
||||
//! draws the element and its children
|
||||
virtual void draw() _IRR_OVERRIDE_;
|
||||
|
||||
//! Writes attributes of the element.
|
||||
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Reads attributes of the element
|
||||
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) _IRR_OVERRIDE_;
|
||||
|
||||
private:
|
||||
|
||||
u32 CheckTime;
|
||||
|
@ -486,6 +486,52 @@ void CGUIComboBox::openCloseMenu()
|
||||
}
|
||||
|
||||
|
||||
//! Writes attributes of the element.
|
||||
void CGUIComboBox::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const
|
||||
{
|
||||
IGUIComboBox::serializeAttributes(out,options);
|
||||
|
||||
out->addEnum ("HTextAlign", HAlign, GUIAlignmentNames);
|
||||
out->addEnum ("VTextAlign", VAlign, GUIAlignmentNames);
|
||||
out->addInt("MaxSelectionRows", (s32)MaxSelectionRows );
|
||||
|
||||
out->addInt ("Selected", Selected );
|
||||
out->addInt ("ItemCount", Items.size());
|
||||
for (u32 i=0; i < Items.size(); ++i)
|
||||
{
|
||||
core::stringc s = "Item";
|
||||
s += i;
|
||||
s += "Text";
|
||||
out->addString(s.c_str(), Items[i].Name.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//! Reads attributes of the element
|
||||
void CGUIComboBox::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0)
|
||||
{
|
||||
IGUIComboBox::deserializeAttributes(in,options);
|
||||
|
||||
setTextAlignment( (EGUI_ALIGNMENT) in->getAttributeAsEnumeration("HTextAlign", GUIAlignmentNames),
|
||||
(EGUI_ALIGNMENT) in->getAttributeAsEnumeration("VTextAlign", GUIAlignmentNames));
|
||||
setMaxSelectionRows( (u32)(in->getAttributeAsInt("MaxSelectionRows")) );
|
||||
|
||||
// clear the list
|
||||
clear();
|
||||
// get item count
|
||||
u32 c = in->getAttributeAsInt("ItemCount");
|
||||
// add items
|
||||
for (u32 i=0; i < c; ++i)
|
||||
{
|
||||
core::stringc s = "Item";
|
||||
s += i;
|
||||
s += "Text";
|
||||
addItem(in->getAttributeAsStringW(s.c_str()).c_str(), 0);
|
||||
}
|
||||
|
||||
setSelected(in->getAttributeAsInt("Selected"));
|
||||
}
|
||||
|
||||
} // end namespace gui
|
||||
} // end namespace irr
|
||||
|
||||
|
@ -74,6 +74,12 @@ namespace gui
|
||||
//! draws the element and its children
|
||||
virtual void draw() _IRR_OVERRIDE_;
|
||||
|
||||
//! Writes attributes of the element.
|
||||
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Reads attributes of the element
|
||||
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) _IRR_OVERRIDE_;
|
||||
|
||||
private:
|
||||
|
||||
void openCloseMenu();
|
||||
|
@ -735,6 +735,113 @@ void CGUIContextMenu::setItemCommandId(u32 idx, s32 id)
|
||||
}
|
||||
|
||||
|
||||
//! Writes attributes of the element.
|
||||
void CGUIContextMenu::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const
|
||||
{
|
||||
IGUIElement::serializeAttributes(out,options);
|
||||
out->addPosition2d("Position", Pos);
|
||||
|
||||
if (Parent->getType() == EGUIET_CONTEXT_MENU || Parent->getType() == EGUIET_MENU )
|
||||
{
|
||||
const IGUIContextMenu* const ptr = (const IGUIContextMenu*)Parent;
|
||||
// find the position of this item in its parent's list
|
||||
u32 i;
|
||||
// VC6 needs the cast for this
|
||||
for (i=0; (i<ptr->getItemCount()) && (ptr->getSubMenu(i) != (const IGUIContextMenu*)this); ++i)
|
||||
; // do nothing
|
||||
|
||||
out->addInt("ParentItem", i);
|
||||
}
|
||||
|
||||
out->addInt("CloseHandling", (s32)CloseHandling);
|
||||
|
||||
// write out the item list
|
||||
out->addInt("ItemCount", Items.size());
|
||||
|
||||
core::stringc tmp;
|
||||
|
||||
for (u32 i=0; i < Items.size(); ++i)
|
||||
{
|
||||
tmp = "IsSeparator"; tmp += i;
|
||||
out->addBool(tmp.c_str(), Items[i].IsSeparator);
|
||||
|
||||
if (!Items[i].IsSeparator)
|
||||
{
|
||||
tmp = "Text"; tmp += i;
|
||||
out->addString(tmp.c_str(), Items[i].Text.c_str());
|
||||
tmp = "CommandID"; tmp += i;
|
||||
out->addInt(tmp.c_str(), Items[i].CommandId);
|
||||
tmp = "Enabled"; tmp += i;
|
||||
out->addBool(tmp.c_str(), Items[i].Enabled);
|
||||
tmp = "Checked"; tmp += i;
|
||||
out->addBool(tmp.c_str(), Items[i].Checked);
|
||||
tmp = "AutoChecking"; tmp += i;
|
||||
out->addBool(tmp.c_str(), Items[i].AutoChecking);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//! Reads attributes of the element
|
||||
void CGUIContextMenu::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0)
|
||||
{
|
||||
IGUIElement::deserializeAttributes(in,options);
|
||||
|
||||
Pos = in->getAttributeAsPosition2d("Position");
|
||||
|
||||
// link to this item's parent
|
||||
if (Parent && ( Parent->getType() == EGUIET_CONTEXT_MENU || Parent->getType() == EGUIET_MENU ) )
|
||||
((CGUIContextMenu*)Parent)->setSubMenu(in->getAttributeAsInt("ParentItem"),this);
|
||||
|
||||
CloseHandling = (ECONTEXT_MENU_CLOSE)in->getAttributeAsInt("CloseHandling");
|
||||
|
||||
removeAllItems();
|
||||
|
||||
// read the item list
|
||||
const s32 count = in->getAttributeAsInt("ItemCount");
|
||||
|
||||
for (s32 i=0; i<count; ++i)
|
||||
{
|
||||
core::stringc tmp;
|
||||
core::stringw txt;
|
||||
s32 commandid=-1;
|
||||
bool enabled=true;
|
||||
bool checked=false;
|
||||
bool autochecking=false;
|
||||
|
||||
tmp = "IsSeparator"; tmp += i;
|
||||
if ( in->existsAttribute(tmp.c_str()) && in->getAttributeAsBool(tmp.c_str()) )
|
||||
addSeparator();
|
||||
else
|
||||
{
|
||||
tmp = "Text"; tmp += i;
|
||||
if ( in->existsAttribute(tmp.c_str()) )
|
||||
txt = in->getAttributeAsStringW(tmp.c_str());
|
||||
|
||||
tmp = "CommandID"; tmp += i;
|
||||
if ( in->existsAttribute(tmp.c_str()) )
|
||||
commandid = in->getAttributeAsInt(tmp.c_str());
|
||||
|
||||
tmp = "Enabled"; tmp += i;
|
||||
if ( in->existsAttribute(tmp.c_str()) )
|
||||
enabled = in->getAttributeAsBool(tmp.c_str());
|
||||
|
||||
tmp = "Checked"; tmp += i;
|
||||
if ( in->existsAttribute(tmp.c_str()) )
|
||||
checked = in->getAttributeAsBool(tmp.c_str());
|
||||
|
||||
tmp = "AutoChecking"; tmp += i;
|
||||
if ( in->existsAttribute(tmp.c_str()) )
|
||||
autochecking = in->getAttributeAsBool(tmp.c_str());
|
||||
|
||||
addItem(core::stringw(txt.c_str()).c_str(), commandid, enabled, false, checked, autochecking);
|
||||
}
|
||||
}
|
||||
|
||||
recalculateSize();
|
||||
}
|
||||
|
||||
|
||||
// because sometimes the element has no parent at click time
|
||||
void CGUIContextMenu::setEventParent(IGUIElement *parent)
|
||||
{
|
||||
|
@ -112,6 +112,12 @@ namespace gui
|
||||
//! When an eventparent is set it receives events instead of the usual parent element
|
||||
virtual void setEventParent(IGUIElement *parent) _IRR_OVERRIDE_;
|
||||
|
||||
//! Writes attributes of the element.
|
||||
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Reads attributes of the element
|
||||
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) _IRR_OVERRIDE_;
|
||||
|
||||
protected:
|
||||
|
||||
void closeAllSubMenus();
|
||||
|
@ -1650,6 +1650,60 @@ bool CGUIEditBox::acceptsIME()
|
||||
return isEnabled();
|
||||
}
|
||||
|
||||
//! Writes attributes of the element.
|
||||
void CGUIEditBox::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const
|
||||
{
|
||||
// IGUIEditBox::serializeAttributes(out,options);
|
||||
|
||||
out->addBool ("Border", Border);
|
||||
out->addBool ("Background", Background);
|
||||
out->addBool ("OverrideColorEnabled", OverrideColorEnabled );
|
||||
out->addColor ("OverrideColor", OverrideColor);
|
||||
// out->addFont("OverrideFont", OverrideFont);
|
||||
out->addInt ("MaxChars", Max);
|
||||
out->addBool ("WordWrap", WordWrap);
|
||||
out->addBool ("MultiLine", MultiLine);
|
||||
out->addBool ("AutoScroll", AutoScroll);
|
||||
out->addBool ("PasswordBox", PasswordBox);
|
||||
core::stringw ch = L" ";
|
||||
ch[0] = PasswordChar;
|
||||
out->addString("PasswordChar", ch.c_str());
|
||||
out->addEnum ("HTextAlign", HAlign, GUIAlignmentNames);
|
||||
out->addEnum ("VTextAlign", VAlign, GUIAlignmentNames);
|
||||
|
||||
IGUIEditBox::serializeAttributes(out,options);
|
||||
}
|
||||
|
||||
|
||||
//! Reads attributes of the element
|
||||
void CGUIEditBox::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0)
|
||||
{
|
||||
IGUIEditBox::deserializeAttributes(in,options);
|
||||
|
||||
setDrawBorder( in->getAttributeAsBool("Border", Border) );
|
||||
setDrawBackground( in->getAttributeAsBool("Background", Background) );
|
||||
setOverrideColor(in->getAttributeAsColor("OverrideColor", OverrideColor));
|
||||
enableOverrideColor(in->getAttributeAsBool("OverrideColorEnabled", OverrideColorEnabled));
|
||||
setMax(in->getAttributeAsInt("MaxChars", Max));
|
||||
setWordWrap(in->getAttributeAsBool("WordWrap", WordWrap));
|
||||
setMultiLine(in->getAttributeAsBool("MultiLine", MultiLine));
|
||||
setAutoScroll(in->getAttributeAsBool("AutoScroll", AutoScroll));
|
||||
core::stringw ch = L" ";
|
||||
ch[0] = PasswordChar;
|
||||
ch = in->getAttributeAsStringW("PasswordChar", ch);
|
||||
|
||||
if (!ch.size())
|
||||
setPasswordBox(in->getAttributeAsBool("PasswordBox", PasswordBox));
|
||||
else
|
||||
setPasswordBox(in->getAttributeAsBool("PasswordBox", PasswordBox), ch[0]);
|
||||
|
||||
setTextAlignment( (EGUI_ALIGNMENT) in->getAttributeAsEnumeration("HTextAlign", GUIAlignmentNames, (s32)HAlign),
|
||||
(EGUI_ALIGNMENT) in->getAttributeAsEnumeration("VTextAlign", GUIAlignmentNames, (s32)VAlign));
|
||||
|
||||
// setOverrideFont(in->getAttributeAsFont("OverrideFont"));
|
||||
}
|
||||
|
||||
|
||||
} // end namespace gui
|
||||
} // end namespace irr
|
||||
|
||||
|
@ -142,6 +142,13 @@ namespace gui
|
||||
//! Returns whether the element takes input from the IME
|
||||
virtual bool acceptsIME() _IRR_OVERRIDE_;
|
||||
|
||||
|
||||
//! Writes attributes of the element.
|
||||
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Reads attributes of the element
|
||||
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) _IRR_OVERRIDE_;
|
||||
|
||||
protected:
|
||||
//! Breaks the single text line.
|
||||
void breakText();
|
||||
|
@ -811,6 +811,49 @@ bool CGUIEnvironment::loadGUI(io::IReadFile* file, IGUIElement* parent)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//! Writes attributes of the environment
|
||||
void CGUIEnvironment::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const
|
||||
{
|
||||
IGUISkin* skin = getSkin();
|
||||
|
||||
if (skin)
|
||||
{
|
||||
out->addEnum("Skin", getSkin()->getType(), GUISkinTypeNames);
|
||||
skin->serializeAttributes(out, options);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//! Reads attributes of the environment
|
||||
void CGUIEnvironment::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options)
|
||||
{
|
||||
if (in->existsAttribute("Skin"))
|
||||
{
|
||||
IGUISkin *skin = getSkin();
|
||||
|
||||
EGUI_SKIN_TYPE t = (EGUI_SKIN_TYPE) in->getAttributeAsEnumeration("Skin",GUISkinTypeNames);
|
||||
if ( !skin || t != skin->getType())
|
||||
{
|
||||
skin = createSkin(t);
|
||||
setSkin(skin);
|
||||
skin->drop();
|
||||
}
|
||||
|
||||
skin = getSkin();
|
||||
|
||||
if (skin)
|
||||
{
|
||||
skin->deserializeAttributes(in, options);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
RelativeRect = AbsoluteRect =
|
||||
core::rect<s32>(Driver ? core::dimension2di(Driver->getScreenSize()) : core::dimension2d<s32>(0,0));
|
||||
}
|
||||
|
||||
|
||||
//! adds a button. The returned pointer must not be dropped.
|
||||
IGUIButton* CGUIEnvironment::addButton(const core::rect<s32>& rectangle, IGUIElement* parent, s32 id, const wchar_t* text, const wchar_t *tooltiptext)
|
||||
{
|
||||
@ -1235,23 +1278,23 @@ IGUIFont* CGUIEnvironment::getFont(const io::path& filename)
|
||||
}
|
||||
|
||||
IGUIFont* ifont=0;
|
||||
#if 0
|
||||
io::IReadFile *file = FileSystem->createAndOpenFile(filename);
|
||||
if (file)
|
||||
{
|
||||
CGUIFont* font = new CGUIFont(this, filename);
|
||||
ifont = (IGUIFont*)font;
|
||||
|
||||
// load the font
|
||||
io::path directory;
|
||||
core::splitFilename(filename, &directory);
|
||||
if (!font->load(file, directory))
|
||||
{
|
||||
CGUIFont* font = new CGUIFont(this, filename);
|
||||
ifont = (IGUIFont*)font;
|
||||
|
||||
// load the font
|
||||
io::path directory;
|
||||
core::splitFilename(filename, &directory);
|
||||
if (!font->load(xml, directory))
|
||||
{
|
||||
font->drop();
|
||||
font = 0;
|
||||
ifont = 0;
|
||||
}
|
||||
font->drop();
|
||||
font = 0;
|
||||
ifont = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
file->drop();
|
||||
}
|
||||
|
||||
if (!ifont)
|
||||
{
|
||||
|
@ -248,6 +248,12 @@ public:
|
||||
if not specified, the root element will be used */
|
||||
virtual bool loadGUI(io::IReadFile* file, IGUIElement* parent=0) _IRR_OVERRIDE_;
|
||||
|
||||
//! Writes attributes of the environment
|
||||
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Reads attributes of the environment.
|
||||
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) _IRR_OVERRIDE_;
|
||||
|
||||
//! Find the next element which would be selected when pressing the tab-key
|
||||
virtual IGUIElement* getNextElement(bool reverse=false, bool group=false) _IRR_OVERRIDE_;
|
||||
|
||||
|
@ -348,6 +348,36 @@ void CGUIFileOpenDialog::draw()
|
||||
IGUIElement::draw();
|
||||
}
|
||||
|
||||
|
||||
//! Writes attributes of the element.
|
||||
/* Not sure if this will really work out properly. Saving paths can be
|
||||
rather problematic. */
|
||||
void CGUIFileOpenDialog::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const
|
||||
{
|
||||
IGUIFileOpenDialog::serializeAttributes(out,options);
|
||||
|
||||
out->addString("StartDirectory", StartDirectory.c_str());
|
||||
out->addBool("RestoreDirectory", (RestoreDirectory.size()!=0));
|
||||
}
|
||||
|
||||
|
||||
//! Reads attributes of the element
|
||||
/* Note that these paths changes will happen at arbitrary places upon
|
||||
load of the gui description. This may be undesired. */
|
||||
void CGUIFileOpenDialog::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options)
|
||||
{
|
||||
StartDirectory = in->getAttributeAsString("StartDirectory");
|
||||
const bool restore = in->getAttributeAsBool("RestoreDirectory");
|
||||
if (restore)
|
||||
RestoreDirectory = FileSystem->getWorkingDirectory();
|
||||
else
|
||||
RestoreDirectory = "";
|
||||
if (StartDirectory.size())
|
||||
FileSystem->changeWorkingDirectoryTo(StartDirectory);
|
||||
|
||||
IGUIFileOpenDialog::deserializeAttributes(in,options);
|
||||
}
|
||||
|
||||
void CGUIFileOpenDialog::pathToStringW(irr::core::stringw& result, const irr::io::path& p)
|
||||
{
|
||||
core::multibyteToWString(result, p);
|
||||
|
@ -49,6 +49,9 @@ namespace gui
|
||||
//! draws the element and its children
|
||||
virtual void draw() _IRR_OVERRIDE_;
|
||||
|
||||
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const _IRR_OVERRIDE_;
|
||||
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) _IRR_OVERRIDE_;
|
||||
|
||||
protected:
|
||||
|
||||
void setFileName(const irr::io::path& name);
|
||||
|
@ -6,6 +6,7 @@
|
||||
#ifdef _IRR_COMPILE_WITH_GUI_
|
||||
|
||||
#include "os.h"
|
||||
#include "fast_atof.h"
|
||||
#include "coreutil.h"
|
||||
#include "IGUIEnvironment.h"
|
||||
#include "IReadFile.h"
|
||||
@ -62,132 +63,118 @@ CGUIFont::~CGUIFont()
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
//! loads a font file from xml
|
||||
bool CGUIFont::load(io::IXMLReader* xml, const io::path& directory)
|
||||
//! loads a font file from tsv
|
||||
bool CGUIFont::load(io::IReadFile* file, const io::path& directory)
|
||||
{
|
||||
if (!SpriteBank)
|
||||
return false;
|
||||
|
||||
SpriteBank->clear();
|
||||
|
||||
while (xml->read())
|
||||
const long size = file->getSize();
|
||||
core::stringc Buffer;
|
||||
Buffer.reserve(size + 1);
|
||||
if (file->read(&Buffer[0], size) != static_cast<size_t>(size))
|
||||
{
|
||||
if (io::EXN_ELEMENT == xml->getNodeType())
|
||||
os::Printer::log("Could not read from file", ELL_ERROR);
|
||||
return false;
|
||||
}
|
||||
Buffer[size] = 0;
|
||||
const c8 *P = &Buffer[0], *End = P + size;
|
||||
|
||||
#define SkipSpace() \
|
||||
while (P < End && (*P == ' ' || *P == '\t' || *P == '\v')) { P++; }
|
||||
#define SkipLine(rest) \
|
||||
while (rest && P < End && *P != '\r' && *P != '\n') P++; \
|
||||
while (P < End && (*P == '\r' || *P == '\n')) { P++; }
|
||||
|
||||
while (P < End)
|
||||
{
|
||||
if (!strncmp(P, "Texture:", 8))
|
||||
{
|
||||
if (core::stringw(L"Texture") == xml->getNodeName())
|
||||
// add a texture
|
||||
P += 8;
|
||||
SkipSpace()
|
||||
core::stringc fn;
|
||||
for (; P < End && *P != '\r' && *P != '\n'; P++)
|
||||
fn.append(*P);
|
||||
SkipLine(0)
|
||||
|
||||
bool flags[3];
|
||||
pushTextureCreationFlags(flags);
|
||||
|
||||
// load texture
|
||||
io::path textureFullName = core::mergeFilename(directory, fn);
|
||||
SpriteBank->setTexture(0, Driver->getTexture(textureFullName));
|
||||
|
||||
popTextureCreationFlags(flags);
|
||||
|
||||
if (!SpriteBank->getTexture(0))
|
||||
{
|
||||
// add a texture
|
||||
core::stringc fn = xml->getAttributeValue(L"filename");
|
||||
u32 i = (u32)xml->getAttributeValueAsInt(L"index");
|
||||
core::stringw alpha = xml->getAttributeValue(L"hasAlpha");
|
||||
|
||||
while (i+1 > SpriteBank->getTextureCount())
|
||||
SpriteBank->addTexture(0);
|
||||
|
||||
bool flags[3];
|
||||
pushTextureCreationFlags(flags);
|
||||
|
||||
// load texture
|
||||
io::path textureFullName = core::mergeFilename(directory, fn);
|
||||
SpriteBank->setTexture(i, Driver->getTexture(textureFullName));
|
||||
|
||||
popTextureCreationFlags(flags);
|
||||
|
||||
// couldn't load texture, abort.
|
||||
if (!SpriteBank->getTexture(i))
|
||||
{
|
||||
os::Printer::log("Unable to load all textures in the font, aborting", ELL_ERROR);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// colorkey texture rather than alpha channel?
|
||||
if (alpha == core::stringw("false"))
|
||||
Driver->makeColorKeyTexture(SpriteBank->getTexture(i), core::position2di(0,0));
|
||||
}
|
||||
}
|
||||
else if (core::stringw(L"c") == xml->getNodeName())
|
||||
{
|
||||
// adding a character to this font
|
||||
SFontArea a;
|
||||
SGUISpriteFrame f;
|
||||
SGUISprite s;
|
||||
core::rect<s32> rectangle;
|
||||
|
||||
a.underhang = xml->getAttributeValueAsInt(L"u");
|
||||
a.overhang = xml->getAttributeValueAsInt(L"o");
|
||||
a.spriteno = SpriteBank->getSprites().size();
|
||||
s32 texno = xml->getAttributeValueAsInt(L"i");
|
||||
|
||||
// parse rectangle
|
||||
core::stringc rectstr = xml->getAttributeValue(L"r");
|
||||
wchar_t ch = xml->getAttributeValue(L"c")[0];
|
||||
|
||||
const c8 *c = rectstr.c_str();
|
||||
s32 val;
|
||||
val = 0;
|
||||
while (*c >= '0' && *c <= '9')
|
||||
{
|
||||
val *= 10;
|
||||
val += *c - '0';
|
||||
c++;
|
||||
}
|
||||
rectangle.UpperLeftCorner.X = val;
|
||||
while (*c == L' ' || *c == L',') c++;
|
||||
|
||||
val = 0;
|
||||
while (*c >= '0' && *c <= '9')
|
||||
{
|
||||
val *= 10;
|
||||
val += *c - '0';
|
||||
c++;
|
||||
}
|
||||
rectangle.UpperLeftCorner.Y = val;
|
||||
while (*c == L' ' || *c == L',') c++;
|
||||
|
||||
val = 0;
|
||||
while (*c >= '0' && *c <= '9')
|
||||
{
|
||||
val *= 10;
|
||||
val += *c - '0';
|
||||
c++;
|
||||
}
|
||||
rectangle.LowerRightCorner.X = val;
|
||||
while (*c == L' ' || *c == L',') c++;
|
||||
|
||||
val = 0;
|
||||
while (*c >= '0' && *c <= '9')
|
||||
{
|
||||
val *= 10;
|
||||
val += *c - '0';
|
||||
c++;
|
||||
}
|
||||
rectangle.LowerRightCorner.Y = val;
|
||||
|
||||
CharacterMap.insert(ch,Areas.size());
|
||||
|
||||
// make frame
|
||||
f.rectNumber = SpriteBank->getPositions().size();
|
||||
f.textureNumber = texno;
|
||||
|
||||
// add frame to sprite
|
||||
s.Frames.push_back(f);
|
||||
s.frameTime = 0;
|
||||
|
||||
// add rectangle to sprite bank
|
||||
SpriteBank->getPositions().push_back(rectangle);
|
||||
a.width = rectangle.getWidth();
|
||||
|
||||
// add sprite to sprite bank
|
||||
SpriteBank->getSprites().push_back(s);
|
||||
|
||||
// add character to font
|
||||
Areas.push_back(a);
|
||||
os::Printer::log("Unable to load texture in the font, aborting", ELL_ERROR);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// adding a character to this font
|
||||
SFontArea a;
|
||||
SGUISpriteFrame f;
|
||||
SGUISprite s;
|
||||
core::rect<s32> rect;
|
||||
wchar_t ch;
|
||||
|
||||
// Format of a line:
|
||||
// <char (hex)> <X1> <Y1> <X2> <Y2> [u] [o]
|
||||
|
||||
ch = static_cast<wchar_t>(core::strtoul16(P, &P));
|
||||
SkipSpace()
|
||||
|
||||
rect.UpperLeftCorner.X = core::strtol10(P, &P);
|
||||
SkipSpace()
|
||||
rect.UpperLeftCorner.Y = core::strtol10(P, &P);
|
||||
SkipSpace()
|
||||
rect.LowerRightCorner.X = core::strtol10(P, &P);
|
||||
SkipSpace()
|
||||
rect.LowerRightCorner.Y = core::strtol10(P, &P);
|
||||
SkipSpace()
|
||||
|
||||
if (core::isdigit(*P))
|
||||
{
|
||||
a.underhang = core::strtol10(P, &P);
|
||||
SkipSpace()
|
||||
if (core::isdigit(*P))
|
||||
a.overhang = core::strtol10(P, &P);
|
||||
}
|
||||
|
||||
SkipLine(1)
|
||||
|
||||
CharacterMap.insert(ch, Areas.size());
|
||||
|
||||
// make frame
|
||||
f.rectNumber = SpriteBank->getPositions().size();
|
||||
f.textureNumber = 0;
|
||||
|
||||
// add frame to sprite
|
||||
s.Frames.push_back(f);
|
||||
s.frameTime = 0;
|
||||
|
||||
// add rectangle to sprite bank
|
||||
SpriteBank->getPositions().push_back(rect);
|
||||
a.width = rect.getWidth();
|
||||
a.spriteno = SpriteBank->getSprites().size();
|
||||
|
||||
// add sprite to sprite bank
|
||||
SpriteBank->getSprites().push_back(s);
|
||||
|
||||
// add character to font
|
||||
Areas.push_back(a);
|
||||
}
|
||||
}
|
||||
|
||||
#undef SkipSpace
|
||||
#undef SkipLine
|
||||
|
||||
// set bad character
|
||||
WrongCharacter = getAreaFromCharacter(L' ');
|
||||
|
||||
@ -195,7 +182,6 @@ bool CGUIFont::load(io::IXMLReader* xml, const io::path& directory)
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void CGUIFont::setMaxHeight()
|
||||
|
@ -44,6 +44,10 @@ public:
|
||||
//! loads a font from a texture file
|
||||
bool load(io::IReadFile* file);
|
||||
|
||||
//! loads a font from a TSV file
|
||||
// \param directory Directory in which the bitmaps can be found
|
||||
bool load(io::IReadFile* file, const io::path& directory);
|
||||
|
||||
//! draws an text and clips it to the specified rectangle if wanted
|
||||
virtual void draw(const core::stringw& text, const core::rect<s32>& position,
|
||||
video::SColor color, bool hcenter=false,
|
||||
|
@ -174,6 +174,44 @@ core::rect<f32> CGUIImage::getDrawBounds() const
|
||||
return DrawBounds;
|
||||
}
|
||||
|
||||
//! Writes attributes of the element.
|
||||
void CGUIImage::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const
|
||||
{
|
||||
IGUIImage::serializeAttributes(out,options);
|
||||
|
||||
out->addTexture ("Texture", Texture);
|
||||
out->addBool ("UseAlphaChannel", UseAlphaChannel);
|
||||
out->addColor ("Color", Color);
|
||||
out->addBool ("ScaleImage", ScaleImage);
|
||||
out->addRect ("SourceRect", SourceRect);
|
||||
out->addFloat ("DrawBoundsX1", DrawBounds.UpperLeftCorner.X);
|
||||
out->addFloat ("DrawBoundsY1", DrawBounds.UpperLeftCorner.Y);
|
||||
out->addFloat ("DrawBoundsX2", DrawBounds.LowerRightCorner.X);
|
||||
out->addFloat ("DrawBoundsY2", DrawBounds.LowerRightCorner.Y);
|
||||
out->addBool ("DrawBackground", DrawBackground);
|
||||
}
|
||||
|
||||
|
||||
//! Reads attributes of the element
|
||||
void CGUIImage::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0)
|
||||
{
|
||||
IGUIImage::deserializeAttributes(in,options);
|
||||
|
||||
setImage(in->getAttributeAsTexture("Texture", Texture));
|
||||
setUseAlphaChannel(in->getAttributeAsBool("UseAlphaChannel", UseAlphaChannel));
|
||||
setColor(in->getAttributeAsColor("Color", Color));
|
||||
setScaleImage(in->getAttributeAsBool("ScaleImage", ScaleImage));
|
||||
setSourceRect(in->getAttributeAsRect("SourceRect", SourceRect));
|
||||
|
||||
DrawBounds.UpperLeftCorner.X = in->getAttributeAsFloat("DrawBoundsX1", DrawBounds.UpperLeftCorner.X);
|
||||
DrawBounds.UpperLeftCorner.Y = in->getAttributeAsFloat("DrawBoundsY1", DrawBounds.UpperLeftCorner.Y);
|
||||
DrawBounds.LowerRightCorner.X = in->getAttributeAsFloat("DrawBoundsX2", DrawBounds.LowerRightCorner.X);
|
||||
DrawBounds.LowerRightCorner.Y = in->getAttributeAsFloat("DrawBoundsY2", DrawBounds.LowerRightCorner.Y);
|
||||
setDrawBounds(DrawBounds);
|
||||
|
||||
setDrawBackground(in->getAttributeAsBool("DrawBackground", DrawBackground));
|
||||
}
|
||||
|
||||
|
||||
} // end namespace gui
|
||||
} // end namespace irr
|
||||
|
@ -76,6 +76,12 @@ namespace gui
|
||||
return DrawBackground;
|
||||
}
|
||||
|
||||
//! Writes attributes of the element.
|
||||
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Reads attributes of the element
|
||||
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) _IRR_OVERRIDE_;
|
||||
|
||||
protected:
|
||||
void checkBounds(core::rect<s32>& rect)
|
||||
{
|
||||
|
@ -149,6 +149,28 @@ void CGUIInOutFader::fadeOut(u32 time)
|
||||
setColor(Color[0],Color[1]);
|
||||
}
|
||||
|
||||
|
||||
//! Writes attributes of the element.
|
||||
void CGUIInOutFader::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const
|
||||
{
|
||||
IGUIInOutFader::serializeAttributes(out,options);
|
||||
|
||||
out->addColor ("FullColor", FullColor);
|
||||
out->addColor ("TransColor", TransColor);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//! Reads attributes of the element
|
||||
void CGUIInOutFader::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0)
|
||||
{
|
||||
IGUIInOutFader::deserializeAttributes(in,options);
|
||||
|
||||
FullColor = in->getAttributeAsColor("FullColor");
|
||||
TransColor = in->getAttributeAsColor("TransColor");
|
||||
}
|
||||
|
||||
|
||||
} // end namespace gui
|
||||
} // end namespace irr
|
||||
|
||||
|
@ -42,6 +42,12 @@ namespace gui
|
||||
//! Returns if the fade in or out process is done.
|
||||
virtual bool isReady() const _IRR_OVERRIDE_;
|
||||
|
||||
//! Writes attributes of the element.
|
||||
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Reads attributes of the element
|
||||
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) _IRR_OVERRIDE_;
|
||||
|
||||
private:
|
||||
|
||||
enum EFadeAction
|
||||
|
@ -685,6 +685,86 @@ bool CGUIListBox::getSerializationLabels(EGUI_LISTBOX_COLOR colorType, core::str
|
||||
}
|
||||
|
||||
|
||||
//! Writes attributes of the element.
|
||||
void CGUIListBox::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const
|
||||
{
|
||||
IGUIListBox::serializeAttributes(out,options);
|
||||
|
||||
// todo: out->addString ("IconBank", IconBank->getName?);
|
||||
out->addBool ("DrawBack", DrawBack);
|
||||
out->addBool ("MoveOverSelect", MoveOverSelect);
|
||||
out->addBool ("AutoScroll", AutoScroll);
|
||||
|
||||
out->addInt("ItemCount", Items.size());
|
||||
for (u32 i=0;i<Items.size(); ++i)
|
||||
{
|
||||
core::stringc label("text");
|
||||
label += i;
|
||||
out->addString(label.c_str(), Items[i].Text.c_str() );
|
||||
|
||||
for ( s32 c=0; c < (s32)EGUI_LBC_COUNT; ++c )
|
||||
{
|
||||
core::stringc useColorLabel, colorLabel;
|
||||
if ( !getSerializationLabels((EGUI_LISTBOX_COLOR)c, useColorLabel, colorLabel) )
|
||||
return;
|
||||
label = useColorLabel; label += i;
|
||||
if ( Items[i].OverrideColors[c].Use )
|
||||
{
|
||||
out->addBool(label.c_str(), true );
|
||||
label = colorLabel; label += i;
|
||||
out->addColor(label.c_str(), Items[i].OverrideColors[c].Color);
|
||||
}
|
||||
else
|
||||
{
|
||||
out->addBool(label.c_str(), false );
|
||||
}
|
||||
}
|
||||
}
|
||||
out->addInt("Selected", Selected);
|
||||
}
|
||||
|
||||
|
||||
//! Reads attributes of the element
|
||||
void CGUIListBox::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0)
|
||||
{
|
||||
clear();
|
||||
|
||||
DrawBack = in->getAttributeAsBool("DrawBack", DrawBack);
|
||||
MoveOverSelect = in->getAttributeAsBool("MoveOverSelect", MoveOverSelect);
|
||||
AutoScroll = in->getAttributeAsBool("AutoScroll", AutoScroll);
|
||||
|
||||
IGUIListBox::deserializeAttributes(in,options);
|
||||
|
||||
const s32 count = in->getAttributeAsInt("ItemCount");
|
||||
for (s32 i=0; i<count; ++i)
|
||||
{
|
||||
core::stringc label("text");
|
||||
ListItem item;
|
||||
|
||||
label += i;
|
||||
item.Text = in->getAttributeAsStringW(label.c_str());
|
||||
|
||||
addItem(item.Text.c_str(), item.Icon);
|
||||
|
||||
for ( u32 c=0; c < EGUI_LBC_COUNT; ++c )
|
||||
{
|
||||
core::stringc useColorLabel, colorLabel;
|
||||
if ( !getSerializationLabels((EGUI_LISTBOX_COLOR)c, useColorLabel, colorLabel) )
|
||||
return;
|
||||
label = useColorLabel; label += i;
|
||||
Items[i].OverrideColors[c].Use = in->getAttributeAsBool(label.c_str());
|
||||
if ( Items[i].OverrideColors[c].Use )
|
||||
{
|
||||
label = colorLabel; label += i;
|
||||
Items[i].OverrideColors[c].Color = in->getAttributeAsColor(label.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
Selected = in->getAttributeAsInt("Selected", Selected);
|
||||
recalculateScrollPos();
|
||||
}
|
||||
|
||||
|
||||
void CGUIListBox::recalculateItemWidth(s32 icon)
|
||||
{
|
||||
if (IconBank && icon > -1 &&
|
||||
|
@ -88,6 +88,12 @@ namespace gui
|
||||
//! Update the position and size of the listbox, and update the scrollbar
|
||||
virtual void updateAbsolutePosition() _IRR_OVERRIDE_;
|
||||
|
||||
//! Writes attributes of the element.
|
||||
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Reads attributes of the element
|
||||
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) _IRR_OVERRIDE_;
|
||||
|
||||
//! set all item colors at given index to color
|
||||
virtual void setItemOverrideColor(u32 index, video::SColor color) _IRR_OVERRIDE_;
|
||||
|
||||
|
@ -413,6 +413,49 @@ bool CGUIMessageBox::OnEvent(const SEvent& event)
|
||||
return CGUIWindow::OnEvent(event);
|
||||
}
|
||||
|
||||
|
||||
//! Writes attributes of the element.
|
||||
void CGUIMessageBox::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const
|
||||
{
|
||||
CGUIWindow::serializeAttributes(out,options);
|
||||
|
||||
out->addBool ("OkayButton", (Flags & EMBF_OK) != 0 );
|
||||
out->addBool ("CancelButton", (Flags & EMBF_CANCEL) != 0 );
|
||||
out->addBool ("YesButton", (Flags & EMBF_YES) != 0 );
|
||||
out->addBool ("NoButton", (Flags & EMBF_NO) != 0 );
|
||||
out->addTexture ("Texture", IconTexture);
|
||||
|
||||
out->addString ("MessageText", MessageText.c_str());
|
||||
}
|
||||
|
||||
|
||||
//! Reads attributes of the element
|
||||
void CGUIMessageBox::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0)
|
||||
{
|
||||
Flags = 0;
|
||||
|
||||
Flags = in->getAttributeAsBool("OkayButton") ? EMBF_OK : 0;
|
||||
Flags |= in->getAttributeAsBool("CancelButton")? EMBF_CANCEL : 0;
|
||||
Flags |= in->getAttributeAsBool("YesButton") ? EMBF_YES : 0;
|
||||
Flags |= in->getAttributeAsBool("NoButton") ? EMBF_NO : 0;
|
||||
|
||||
if ( IconTexture )
|
||||
{
|
||||
IconTexture->drop();
|
||||
IconTexture = NULL;
|
||||
}
|
||||
IconTexture = in->getAttributeAsTexture("Texture");
|
||||
if ( IconTexture )
|
||||
IconTexture->grab();
|
||||
|
||||
MessageText = in->getAttributeAsStringW("MessageText").c_str();
|
||||
|
||||
CGUIWindow::deserializeAttributes(in,options);
|
||||
|
||||
refreshControls();
|
||||
}
|
||||
|
||||
|
||||
} // end namespace gui
|
||||
} // end namespace irr
|
||||
|
||||
|
@ -32,6 +32,12 @@ namespace gui
|
||||
//! called if an event happened.
|
||||
virtual bool OnEvent(const SEvent& event) _IRR_OVERRIDE_;
|
||||
|
||||
//! Writes attributes of the element.
|
||||
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Reads attributes of the element
|
||||
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) _IRR_OVERRIDE_;
|
||||
|
||||
private:
|
||||
|
||||
void refreshControls();
|
||||
|
@ -230,6 +230,24 @@ void CGUIModalScreen::updateAbsolutePosition()
|
||||
IGUIElement::updateAbsolutePosition();
|
||||
}
|
||||
|
||||
|
||||
//! Writes attributes of the element.
|
||||
void CGUIModalScreen::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const
|
||||
{
|
||||
IGUIElement::serializeAttributes(out,options);
|
||||
|
||||
out->addInt("BlinkMode", BlinkMode );
|
||||
}
|
||||
|
||||
//! Reads attributes of the element
|
||||
void CGUIModalScreen::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0)
|
||||
{
|
||||
IGUIElement::deserializeAttributes(in, options);
|
||||
|
||||
BlinkMode = in->getAttributeAsInt("BlinkMode", BlinkMode);
|
||||
}
|
||||
|
||||
|
||||
} // end namespace gui
|
||||
} // end namespace irr
|
||||
|
||||
|
@ -46,6 +46,12 @@ namespace gui
|
||||
//! Modals are infinite so every point is inside
|
||||
virtual bool isPointInside(const core::position2d<s32>& point) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Writes attributes of the element.
|
||||
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Reads attributes of the element
|
||||
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) _IRR_OVERRIDE_;
|
||||
|
||||
//! Set when to blink.
|
||||
//! Bitset of following values (can be combined)
|
||||
//! 0 = never
|
||||
|
@ -532,6 +532,39 @@ void CGUIScrollBar::refreshControls()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//! Writes attributes of the element.
|
||||
void CGUIScrollBar::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const
|
||||
{
|
||||
IGUIScrollBar::serializeAttributes(out,options);
|
||||
|
||||
out->addBool("Horizontal", Horizontal);
|
||||
out->addInt ("Value", Pos);
|
||||
out->addInt ("Min", Min);
|
||||
out->addInt ("Max", Max);
|
||||
out->addInt ("SmallStep", SmallStep);
|
||||
out->addInt ("LargeStep", LargeStep);
|
||||
// CurrentIconColor - not serialized as continuously updated
|
||||
}
|
||||
|
||||
|
||||
//! Reads attributes of the element
|
||||
void CGUIScrollBar::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0)
|
||||
{
|
||||
IGUIScrollBar::deserializeAttributes(in,options);
|
||||
|
||||
Horizontal = in->getAttributeAsBool("Horizontal", Horizontal);
|
||||
setMin(in->getAttributeAsInt("Min", Min));
|
||||
setMax(in->getAttributeAsInt("Max", Max));
|
||||
setPos(in->getAttributeAsInt("Value", Pos));
|
||||
setSmallStep(in->getAttributeAsInt("SmallStep", SmallStep));
|
||||
setLargeStep(in->getAttributeAsInt("LargeStep", LargeStep));
|
||||
// CurrentIconColor - not serialized as continuously updated
|
||||
|
||||
refreshControls();
|
||||
}
|
||||
|
||||
|
||||
} // end namespace gui
|
||||
} // end namespace irr
|
||||
|
||||
|
@ -70,6 +70,12 @@ namespace gui
|
||||
//! updates the rectangle
|
||||
virtual void updateAbsolutePosition() _IRR_OVERRIDE_;
|
||||
|
||||
//! Writes attributes of the element.
|
||||
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Reads attributes of the element
|
||||
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) _IRR_OVERRIDE_;
|
||||
|
||||
private:
|
||||
|
||||
void refreshControls();
|
||||
|
@ -971,6 +971,43 @@ void CGUISkin::draw2DRectangle(IGUIElement* element,
|
||||
Driver->draw2DRectangle(color, pos, clip);
|
||||
}
|
||||
|
||||
|
||||
//! Writes attributes of the skin
|
||||
void CGUISkin::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const
|
||||
{
|
||||
u32 i;
|
||||
for (i=0; i<EGDC_COUNT; ++i)
|
||||
out->addColor(GUISkinColorNames[i], Colors[i]);
|
||||
|
||||
for (i=0; i<EGDS_COUNT; ++i)
|
||||
out->addInt(GUISkinSizeNames[i], Sizes[i]);
|
||||
|
||||
for (i=0; i<EGDT_COUNT; ++i)
|
||||
out->addString(GUISkinTextNames[i], Texts[i].c_str());
|
||||
|
||||
for (i=0; i<EGDI_COUNT; ++i)
|
||||
out->addInt(GUISkinIconNames[i], Icons[i]);
|
||||
}
|
||||
|
||||
|
||||
//! Reads attributes of the skikn
|
||||
void CGUISkin::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options)
|
||||
{
|
||||
u32 i;
|
||||
for (i=0; i<EGDC_COUNT; ++i)
|
||||
Colors[i] = in->getAttributeAsColor(GUISkinColorNames[i], Colors[i]);
|
||||
|
||||
for (i=0; i<EGDS_COUNT; ++i)
|
||||
Sizes[i] = in->getAttributeAsInt(GUISkinSizeNames[i], Sizes[i]);
|
||||
|
||||
for (i=0; i<EGDT_COUNT; ++i)
|
||||
Texts[i] = in->getAttributeAsStringW(GUISkinTextNames[i], Texts[i]);
|
||||
|
||||
for (i=0; i<EGDI_COUNT; ++i)
|
||||
Icons[i] = in->getAttributeAsInt(GUISkinIconNames[i], Icons[i]);
|
||||
}
|
||||
|
||||
|
||||
} // end namespace gui
|
||||
} // end namespace irr
|
||||
|
||||
|
@ -216,6 +216,12 @@ namespace gui
|
||||
//! get the type of this skin
|
||||
virtual EGUI_SKIN_TYPE getType() const _IRR_OVERRIDE_;
|
||||
|
||||
//! Writes attributes of the skin
|
||||
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Reads attributes of the skin
|
||||
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) _IRR_OVERRIDE_;
|
||||
|
||||
private:
|
||||
|
||||
video::SColor Colors[EGDC_COUNT];
|
||||
|
@ -316,6 +316,29 @@ const wchar_t* CGUISpinBox::getText() const
|
||||
}
|
||||
|
||||
|
||||
//! Writes attributes of the element.
|
||||
void CGUISpinBox::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const
|
||||
{
|
||||
IGUIElement::serializeAttributes(out, options);
|
||||
out->addFloat("Min", getMin());
|
||||
out->addFloat("Max", getMax());
|
||||
out->addFloat("Step", getStepSize());
|
||||
out->addInt("DecimalPlaces", DecimalPlaces);
|
||||
out->addInt("ValidateOn", (s32)ValidateOn);
|
||||
}
|
||||
|
||||
|
||||
//! Reads attributes of the element
|
||||
void CGUISpinBox::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options)
|
||||
{
|
||||
IGUIElement::deserializeAttributes(in, options);
|
||||
setRange(in->getAttributeAsFloat("Min", RangeMin), in->getAttributeAsFloat("Max", RangeMax));
|
||||
setStepSize(in->getAttributeAsFloat("Step", StepSize));
|
||||
setDecimalPlaces(in->getAttributeAsInt("DecimalPlaces", DecimalPlaces));
|
||||
setValidateOn((u32)in->getAttributeAsInt("ValidateOn", (s32)ValidateOn) );
|
||||
}
|
||||
|
||||
|
||||
} // end namespace gui
|
||||
} // end namespace irr
|
||||
|
||||
|
@ -83,6 +83,12 @@ namespace gui
|
||||
//! Gets when the spinbox has to validate entered text.
|
||||
virtual u32 getValidateOn() const _IRR_OVERRIDE_;
|
||||
|
||||
//! Writes attributes of the element.
|
||||
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Reads attributes of the element
|
||||
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) _IRR_OVERRIDE_;
|
||||
|
||||
protected:
|
||||
virtual void verifyValueRange();
|
||||
void refreshSprites();
|
||||
|
@ -590,6 +590,51 @@ s32 CGUIStaticText::getTextWidth() const
|
||||
}
|
||||
|
||||
|
||||
//! Writes attributes of the element.
|
||||
//! Implement this to expose the attributes of your element for
|
||||
//! scripting languages, editors, debuggers or xml serialization purposes.
|
||||
void CGUIStaticText::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const
|
||||
{
|
||||
IGUIStaticText::serializeAttributes(out,options);
|
||||
|
||||
out->addBool ("Border", Border);
|
||||
out->addBool ("OverrideColorEnabled",OverrideColorEnabled);
|
||||
out->addBool ("OverrideBGColorEnabled",OverrideBGColorEnabled);
|
||||
out->addBool ("WordWrap", WordWrap);
|
||||
out->addBool ("Background", Background);
|
||||
out->addBool ("RightToLeft", RightToLeft);
|
||||
out->addBool ("RestrainTextInside", RestrainTextInside);
|
||||
out->addColor ("OverrideColor", OverrideColor);
|
||||
out->addColor ("BGColor", BGColor);
|
||||
out->addEnum ("HTextAlign", HAlign, GUIAlignmentNames);
|
||||
out->addEnum ("VTextAlign", VAlign, GUIAlignmentNames);
|
||||
|
||||
// out->addFont ("OverrideFont", OverrideFont);
|
||||
}
|
||||
|
||||
|
||||
//! Reads attributes of the element
|
||||
void CGUIStaticText::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0)
|
||||
{
|
||||
IGUIStaticText::deserializeAttributes(in,options);
|
||||
|
||||
Border = in->getAttributeAsBool("Border", Border);
|
||||
enableOverrideColor(in->getAttributeAsBool("OverrideColorEnabled", OverrideColorEnabled));
|
||||
OverrideBGColorEnabled = in->getAttributeAsBool("OverrideBGColorEnabled", OverrideBGColorEnabled);
|
||||
setWordWrap(in->getAttributeAsBool("WordWrap", WordWrap));
|
||||
Background = in->getAttributeAsBool("Background", Background);
|
||||
RightToLeft = in->getAttributeAsBool("RightToLeft", RightToLeft);
|
||||
RestrainTextInside = in->getAttributeAsBool("RestrainTextInside", RestrainTextInside);
|
||||
OverrideColor = in->getAttributeAsColor("OverrideColor", OverrideColor);
|
||||
BGColor = in->getAttributeAsColor("BGColor", BGColor);
|
||||
|
||||
setTextAlignment( (EGUI_ALIGNMENT) in->getAttributeAsEnumeration("HTextAlign", GUIAlignmentNames, (s32)HAlign),
|
||||
(EGUI_ALIGNMENT) in->getAttributeAsEnumeration("VTextAlign", GUIAlignmentNames, (s32)VAlign));
|
||||
|
||||
// OverrideFont = in->getAttributeAsFont("OverrideFont");
|
||||
}
|
||||
|
||||
|
||||
} // end namespace gui
|
||||
} // end namespace irr
|
||||
|
||||
|
@ -112,6 +112,12 @@ namespace gui
|
||||
//! Checks if the text should be interpreted as right-to-left text
|
||||
virtual bool isRightToLeft() const _IRR_OVERRIDE_;
|
||||
|
||||
//! Writes attributes of the element.
|
||||
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Reads attributes of the element
|
||||
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) _IRR_OVERRIDE_;
|
||||
|
||||
private:
|
||||
|
||||
//! Breaks the single text line.
|
||||
|
@ -98,6 +98,45 @@ video::SColor CGUITab::getBackgroundColor() const
|
||||
}
|
||||
|
||||
|
||||
//! Writes attributes of the element.
|
||||
void CGUITab::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const
|
||||
{
|
||||
IGUITab::serializeAttributes(out,options);
|
||||
|
||||
IGUITabControl* parentTabControl = Parent && Parent->getType() == EGUIET_TAB_CONTROL ? static_cast<IGUITabControl*>(Parent) : 0;
|
||||
if ( parentTabControl )
|
||||
out->addInt ("TabNumber", parentTabControl->getTabIndex(this)); // order of children and tabs can be different, so we save tab-number
|
||||
out->addBool ("DrawBackground", DrawBackground);
|
||||
out->addColor ("BackColor", BackColor);
|
||||
out->addBool ("OverrideTextColorEnabled", OverrideTextColorEnabled);
|
||||
out->addColor ("TextColor", TextColor);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//! Reads attributes of the element
|
||||
void CGUITab::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0)
|
||||
{
|
||||
IGUITab::deserializeAttributes(in,options);
|
||||
|
||||
setDrawBackground(in->getAttributeAsBool("DrawBackground", DrawBackground));
|
||||
setBackgroundColor(in->getAttributeAsColor("BackColor", BackColor));
|
||||
bool overrideColor = in->getAttributeAsBool("OverrideTextColorEnabled", OverrideTextColorEnabled);
|
||||
setTextColor(in->getAttributeAsColor("TextColor", TextColor));
|
||||
OverrideTextColorEnabled = overrideColor; // because setTextColor does set OverrideTextColorEnabled always to true
|
||||
|
||||
IGUITabControl* parentTabControl = Parent && Parent->getType() == EGUIET_TAB_CONTROL ? static_cast<IGUITabControl*>(Parent) : 0;
|
||||
if (parentTabControl)
|
||||
{
|
||||
s32 idx = in->getAttributeAsInt("TabNumber", -1);
|
||||
if ( idx >= 0 )
|
||||
parentTabControl->insertTab(idx, this, true);
|
||||
else
|
||||
parentTabControl->addTab(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Tabcontrol
|
||||
// ------------------------------------------------------------------
|
||||
@ -981,6 +1020,38 @@ void CGUITabControl::updateAbsolutePosition()
|
||||
}
|
||||
|
||||
|
||||
//! Writes attributes of the element.
|
||||
void CGUITabControl::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const
|
||||
{
|
||||
IGUITabControl::serializeAttributes(out,options);
|
||||
|
||||
out->addInt ("ActiveTab", ActiveTabIndex);
|
||||
out->addBool("Border", Border);
|
||||
out->addBool("FillBackground", FillBackground);
|
||||
out->addInt ("TabHeight", TabHeight);
|
||||
out->addInt ("TabMaxWidth", TabMaxWidth);
|
||||
out->addEnum("TabVerticalAlignment", s32(VerticalAlignment), GUIAlignmentNames);
|
||||
}
|
||||
|
||||
|
||||
//! Reads attributes of the element
|
||||
void CGUITabControl::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0)
|
||||
{
|
||||
Border = in->getAttributeAsBool("Border");
|
||||
FillBackground = in->getAttributeAsBool("FillBackground");
|
||||
|
||||
ActiveTabIndex = -1;
|
||||
|
||||
setTabHeight(in->getAttributeAsInt("TabHeight"));
|
||||
TabMaxWidth = in->getAttributeAsInt("TabMaxWidth");
|
||||
|
||||
IGUITabControl::deserializeAttributes(in,options);
|
||||
|
||||
ActiveTabIndex = in->getAttributeAsInt("ActiveTab", -1); // not setActiveTab as tabs are loaded later
|
||||
setTabVerticalAlignment( static_cast<EGUI_ALIGNMENT>(in->getAttributeAsEnumeration("TabVerticalAlignment" , GUIAlignmentNames)) );
|
||||
}
|
||||
|
||||
|
||||
} // end namespace irr
|
||||
} // end namespace gui
|
||||
|
||||
|
@ -49,6 +49,12 @@ namespace gui
|
||||
|
||||
virtual video::SColor getTextColor() const _IRR_OVERRIDE_;
|
||||
|
||||
//! Writes attributes of the element.
|
||||
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Reads attributes of the element
|
||||
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) _IRR_OVERRIDE_;
|
||||
|
||||
private:
|
||||
|
||||
video::SColor BackColor;
|
||||
@ -121,9 +127,14 @@ namespace gui
|
||||
//! Removes a child.
|
||||
virtual void removeChild(IGUIElement* child) _IRR_OVERRIDE_;
|
||||
|
||||
//! Writes attributes of the element.
|
||||
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const _IRR_OVERRIDE_;
|
||||
//! Set the height of the tabs
|
||||
virtual void setTabHeight( s32 height ) _IRR_OVERRIDE_;
|
||||
|
||||
//! Reads attributes of the element
|
||||
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) _IRR_OVERRIDE_;
|
||||
|
||||
//! Get the height of the tabs
|
||||
virtual s32 getTabHeight() const _IRR_OVERRIDE_;
|
||||
|
||||
|
@ -1135,6 +1135,160 @@ bool CGUITable::isDrawBackgroundEnabled() const
|
||||
return DrawBack;
|
||||
}
|
||||
|
||||
//! Writes attributes of the element.
|
||||
void CGUITable::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const
|
||||
{
|
||||
IGUITable::serializeAttributes(out, options);
|
||||
|
||||
out->addInt("ColumnCount", Columns.size());
|
||||
u32 i;
|
||||
for (i=0;i<Columns.size(); ++i)
|
||||
{
|
||||
core::stringc label;
|
||||
|
||||
label = "Column"; label += i; label += "name";
|
||||
out->addString(label.c_str(), Columns[i].Name.c_str() );
|
||||
label = "Column"; label += i; label += "width";
|
||||
out->addInt(label.c_str(), Columns[i].Width );
|
||||
label = "Column"; label += i; label += "OrderingMode";
|
||||
out->addEnum(label.c_str(), Columns[i].OrderingMode, GUIColumnOrderingNames);
|
||||
}
|
||||
|
||||
out->addInt("RowCount", Rows.size());
|
||||
for (i=0;i<Rows.size(); ++i)
|
||||
{
|
||||
core::stringc label;
|
||||
|
||||
// Height currently not used and could be recalculated anyway
|
||||
//label = "Row"; label += i; label += "height";
|
||||
//out->addInt(label.c_str(), Rows[i].Height );
|
||||
|
||||
//label = "Row"; label += i; label += "ItemCount";
|
||||
//out->addInt(label.c_str(), Rows[i].Items.size());
|
||||
u32 c;
|
||||
for ( c=0; c < Rows[i].Items.size(); ++c )
|
||||
{
|
||||
label = "Row"; label += i; label += "cell"; label += c; label += "text";
|
||||
out->addString(label.c_str(), Rows[i].Items[c].Text.c_str() );
|
||||
// core::stringw BrokenText; // can be recalculated
|
||||
label = "Row"; label += i; label += "cell"; label += c; label += "color";
|
||||
out->addColor(label.c_str(), Rows[i].Items[c].Color );
|
||||
label = "Row"; label += i; label += "cell"; label += c; label += "IsOverrideColor";
|
||||
out->addColor(label.c_str(), Rows[i].Items[c].IsOverrideColor );
|
||||
// void *data; // can't be serialized
|
||||
}
|
||||
}
|
||||
|
||||
// s32 ItemHeight; // can be calculated
|
||||
// TotalItemHeight // calculated
|
||||
// TotalItemWidth // calculated
|
||||
// gui::IGUIFont* ActiveFont; // TODO: we don't have a sane font-serialization so far
|
||||
// gui::IGUIScrollBar* VerticalScrollBar; // not serialized
|
||||
// gui::IGUIScrollBar* HorizontalScrollBar; // not serialized
|
||||
|
||||
out->addBool ("Clip", Clip);
|
||||
out->addBool ("DrawBack", DrawBack);
|
||||
out->addBool ("MoveOverSelect", MoveOverSelect);
|
||||
|
||||
// s32 CurrentResizedColumn; // runtime info - depends on user action
|
||||
out->addBool ("ResizableColumns", ResizableColumns);
|
||||
|
||||
// s32 Selected; // runtime info - depends on user action
|
||||
out->addInt("CellWidthPadding", CellWidthPadding );
|
||||
out->addInt("CellHeightPadding", CellHeightPadding );
|
||||
// s32 ActiveTab; // runtime info - depends on user action
|
||||
// bool Selecting; // runtime info - depends on user action
|
||||
out->addEnum("CurrentOrdering", CurrentOrdering, GUIOrderingModeNames);
|
||||
out->addInt("DrawFlags", DrawFlags);
|
||||
}
|
||||
|
||||
|
||||
//! Reads attributes of the element
|
||||
void CGUITable::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options)
|
||||
{
|
||||
IGUITable::deserializeAttributes(in, options);
|
||||
|
||||
Columns.clear();
|
||||
u32 columnCount = in->getAttributeAsInt("ColumnCount");
|
||||
u32 i;
|
||||
for (i=0;i<columnCount; ++i)
|
||||
{
|
||||
core::stringc label;
|
||||
Column column;
|
||||
|
||||
label = "Column"; label += i; label += "name";
|
||||
column.Name = core::stringw(in->getAttributeAsString(label.c_str()).c_str());
|
||||
label = "Column"; label += i; label += "width";
|
||||
column.Width = in->getAttributeAsInt(label.c_str());
|
||||
label = "Column"; label += i; label += "OrderingMode";
|
||||
|
||||
column.OrderingMode = EGCO_NONE;
|
||||
s32 co = in->getAttributeAsEnumeration(label.c_str(), GUIColumnOrderingNames);
|
||||
if (co > 0)
|
||||
column.OrderingMode = EGUI_COLUMN_ORDERING(co);
|
||||
|
||||
Columns.push_back(column);
|
||||
}
|
||||
|
||||
Rows.clear();
|
||||
u32 rowCount = in->getAttributeAsInt("RowCount");
|
||||
for (i=0; i<rowCount; ++i)
|
||||
{
|
||||
core::stringc label;
|
||||
|
||||
Row row;
|
||||
|
||||
// Height currently not used and could be recalculated anyway
|
||||
//label = "Row"; label += i; label += "height";
|
||||
//row.Height = in->getAttributeAsInt(label.c_str() );
|
||||
|
||||
Rows.push_back(row);
|
||||
|
||||
//label = "Row"; label += i; label += "ItemCount";
|
||||
//u32 itemCount = in->getAttributeAsInt(label.c_str());
|
||||
u32 c;
|
||||
for ( c=0; c < columnCount; ++c )
|
||||
{
|
||||
Cell cell;
|
||||
|
||||
label = "Row"; label += i; label += "cell"; label += c; label += "text";
|
||||
cell.Text = core::stringw(in->getAttributeAsString(label.c_str()).c_str());
|
||||
breakText( cell.Text, cell.BrokenText, Columns[c].Width );
|
||||
label = "Row"; label += i; label += "cell"; label += c; label += "color";
|
||||
cell.Color = in->getAttributeAsColor(label.c_str());
|
||||
label = "Row"; label += i; label += "cell"; label += c; label += "IsOverrideColor";
|
||||
cell.IsOverrideColor = in->getAttributeAsBool(label.c_str());
|
||||
|
||||
cell.Data = NULL;
|
||||
|
||||
Rows[Rows.size()-1].Items.push_back(cell);
|
||||
}
|
||||
}
|
||||
|
||||
ItemHeight = 0; // calculated
|
||||
TotalItemHeight = 0; // calculated
|
||||
TotalItemWidth = 0; // calculated
|
||||
|
||||
Clip = in->getAttributeAsBool("Clip", Clip);
|
||||
DrawBack = in->getAttributeAsBool("DrawBack", DrawBack);
|
||||
MoveOverSelect = in->getAttributeAsBool("MoveOverSelect", MoveOverSelect);
|
||||
|
||||
CurrentResizedColumn = -1;
|
||||
ResizeStart = 0;
|
||||
ResizableColumns = in->getAttributeAsBool("ResizableColumns", ResizableColumns);
|
||||
|
||||
Selected = -1;
|
||||
CellWidthPadding = in->getAttributeAsInt("CellWidthPadding", CellWidthPadding);
|
||||
CellHeightPadding = in->getAttributeAsInt("CellHeightPadding", CellHeightPadding);
|
||||
ActiveTab = -1;
|
||||
Selecting = false;
|
||||
|
||||
CurrentOrdering = (EGUI_ORDERING_MODE) in->getAttributeAsEnumeration("CurrentOrdering", GUIOrderingModeNames, (s32)CurrentOrdering);
|
||||
DrawFlags = in->getAttributeAsInt("DrawFlags", DrawFlags);
|
||||
|
||||
refreshControls();
|
||||
}
|
||||
|
||||
} // end namespace gui
|
||||
} // end namespace irr
|
||||
|
||||
|
@ -168,6 +168,16 @@ namespace gui
|
||||
/** \return true if background drawing is enabled, false otherwise */
|
||||
virtual bool isDrawBackgroundEnabled() const _IRR_OVERRIDE_;
|
||||
|
||||
//! 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 _IRR_OVERRIDE_;
|
||||
|
||||
//! 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) _IRR_OVERRIDE_;
|
||||
|
||||
protected:
|
||||
void refreshControls();
|
||||
void checkScrollbars();
|
||||
|
@ -356,6 +356,47 @@ core::rect<s32> CGUIWindow::getClientRect() const
|
||||
return ClientRect;
|
||||
}
|
||||
|
||||
|
||||
//! Writes attributes of the element.
|
||||
void CGUIWindow::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const
|
||||
{
|
||||
IGUIWindow::serializeAttributes(out,options);
|
||||
|
||||
out->addBool("IsDraggable", IsDraggable);
|
||||
out->addBool("DrawBackground", DrawBackground);
|
||||
out->addBool("DrawTitlebar", DrawTitlebar);
|
||||
|
||||
// Currently we can't just serialize attributes of sub-elements.
|
||||
// To do this we either
|
||||
// a) allow further serialization after attribute serialiation (second function, callback or event)
|
||||
// b) add an IGUIElement attribute
|
||||
// c) extend the attribute system to allow attributes to have sub-attributes
|
||||
// We just serialize the most important info for now until we can do one of the above solutions.
|
||||
out->addBool("IsCloseVisible", CloseButton->isVisible());
|
||||
out->addBool("IsMinVisible", MinButton->isVisible());
|
||||
out->addBool("IsRestoreVisible", RestoreButton->isVisible());
|
||||
}
|
||||
|
||||
|
||||
//! Reads attributes of the element
|
||||
void CGUIWindow::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0)
|
||||
{
|
||||
IGUIWindow::deserializeAttributes(in,options);
|
||||
|
||||
Dragging = false;
|
||||
IsActive = false;
|
||||
IsDraggable = in->getAttributeAsBool("IsDraggable");
|
||||
DrawBackground = in->getAttributeAsBool("DrawBackground");
|
||||
DrawTitlebar = in->getAttributeAsBool("DrawTitlebar");
|
||||
|
||||
CloseButton->setVisible(in->getAttributeAsBool("IsCloseVisible"));
|
||||
MinButton->setVisible(in->getAttributeAsBool("IsMinVisible"));
|
||||
RestoreButton->setVisible(in->getAttributeAsBool("IsRestoreVisible"));
|
||||
|
||||
updateClientRect();
|
||||
}
|
||||
|
||||
|
||||
} // end namespace gui
|
||||
} // end namespace irr
|
||||
|
||||
|
@ -66,6 +66,12 @@ namespace gui
|
||||
//! Returns the rectangle of the drawable area (without border and without titlebar)
|
||||
virtual core::rect<s32> getClientRect() const _IRR_OVERRIDE_;
|
||||
|
||||
//! Writes attributes of the element.
|
||||
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Reads attributes of the element
|
||||
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) _IRR_OVERRIDE_;
|
||||
|
||||
protected:
|
||||
|
||||
void updateClientRect();
|
||||
|
@ -102,7 +102,7 @@ namespace
|
||||
#if defined(_IRR_LINUX_X11_XINPUT2_)
|
||||
int XI_EXTENSIONS_OPCODE;
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
namespace irr
|
||||
{
|
||||
|
@ -17,7 +17,8 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "SIrrCreationParameters.h"
|
||||
#include <SDL2/SDL_video.h>
|
||||
#include <SDL/SDL_syswm.h>
|
||||
#include <SDL/SDL_video.h>
|
||||
|
||||
#ifdef _IRR_EMSCRIPTEN_PLATFORM_
|
||||
#ifdef _IRR_COMPILE_WITH_OGLES2_
|
||||
@ -26,6 +27,10 @@
|
||||
#include <emscripten.h>
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma comment(lib, "SDL.lib")
|
||||
#endif // _MSC_VER
|
||||
|
||||
static int SDLDeviceInstances = 0;
|
||||
|
||||
namespace irr
|
||||
@ -106,7 +111,6 @@ EM_BOOL CIrrDeviceSDL::MouseLeaveCallback(int eventType, const EmscriptenMouseEv
|
||||
|
||||
return EM_FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool CIrrDeviceSDL::isNoUnicodeKey(EKEY_CODE key) const
|
||||
{
|
||||
@ -175,11 +179,12 @@ bool CIrrDeviceSDL::isNoUnicodeKey(EKEY_CODE key) const
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//! constructor
|
||||
CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param)
|
||||
: CIrrDeviceStub(param),
|
||||
Window((SDL_Window*)param.WindowId), SDL_Flags(0),
|
||||
Screen((SDL_Surface*)param.WindowId), SDL_Flags(SDL_ANYFORMAT),
|
||||
MouseX(0), MouseY(0), MouseXRel(0), MouseYRel(0), MouseButtonStates(0),
|
||||
Width(param.WindowSize.Width), Height(param.WindowSize.Height),
|
||||
Resizable(param.WindowResizable == 1 ? true : false), WindowMinimized(false)
|
||||
@ -205,36 +210,22 @@ CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param)
|
||||
{
|
||||
os::Printer::log("SDL initialized", ELL_INFORMATION);
|
||||
}
|
||||
|
||||
#if defined(_IRR_WINDOWS_)
|
||||
SDL_putenv("SDL_VIDEODRIVER=directx");
|
||||
#elif defined(_IRR_OSX_PLATFORM_)
|
||||
SDL_putenv("SDL_VIDEODRIVER=Quartz");
|
||||
#elif !defined(_IRR_EMSCRIPTEN_PLATFORM_)
|
||||
SDL_putenv("SDL_VIDEODRIVER=x11");
|
||||
#endif
|
||||
}
|
||||
|
||||
// create keymap
|
||||
createKeyMap();
|
||||
|
||||
if ( CreationParams.Fullscreen )
|
||||
SDL_Flags |= SDL_WINDOW_FULLSCREEN;
|
||||
else if ( Resizable )
|
||||
SDL_Flags |= SDL_WINDOW_RESIZABLE;
|
||||
if (CreationParams.DriverType == video::EDT_OPENGL)
|
||||
{
|
||||
SDL_Flags |= SDL_WINDOW_OPENGL;
|
||||
if (!CreationParams.Doublebuffer)
|
||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 0);
|
||||
}
|
||||
#ifdef _IRR_EMSCRIPTEN_PLATFORM_
|
||||
SDL_Flags |= SDL_WINDOW_OPENGL;
|
||||
#endif //_IRR_EMSCRIPTEN_PLATFORM_
|
||||
|
||||
// create window
|
||||
if (CreationParams.DriverType != video::EDT_NULL)
|
||||
{
|
||||
// create the window, only if we do not use the null device
|
||||
createWindow();
|
||||
}
|
||||
// SDL_putenv("SDL_WINDOWID=");
|
||||
|
||||
SDL_VERSION(&Info.version);
|
||||
|
||||
#ifndef _IRR_EMSCRIPTEN_PLATFORM_
|
||||
SDL_GetWindowWMInfo(Window,&Info);
|
||||
SDL_GetWMInfo(&Info);
|
||||
#endif //_IRR_EMSCRIPTEN_PLATFORM_
|
||||
core::stringc sdlversion = "SDL Version ";
|
||||
sdlversion += Info.version.major;
|
||||
@ -244,20 +235,45 @@ CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param)
|
||||
sdlversion += Info.version.patch;
|
||||
|
||||
Operator = new COSOperator(sdlversion);
|
||||
if (SDLDeviceInstances == 1) {
|
||||
if ( SDLDeviceInstances == 1 )
|
||||
{
|
||||
os::Printer::log(sdlversion.c_str(), ELL_INFORMATION);
|
||||
}
|
||||
|
||||
// create keymap
|
||||
createKeyMap();
|
||||
// enable key to character translation
|
||||
SDL_EnableUNICODE(1);
|
||||
|
||||
(void)SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
|
||||
|
||||
if ( CreationParams.Fullscreen )
|
||||
SDL_Flags |= SDL_FULLSCREEN;
|
||||
else if ( Resizable )
|
||||
SDL_Flags |= SDL_RESIZABLE;
|
||||
if (CreationParams.DriverType == video::EDT_OPENGL)
|
||||
SDL_Flags |= SDL_OPENGL;
|
||||
else if (CreationParams.Doublebuffer)
|
||||
SDL_Flags |= SDL_DOUBLEBUF;
|
||||
#ifdef _IRR_EMSCRIPTEN_PLATFORM_
|
||||
SDL_Flags |= SDL_OPENGL;
|
||||
#endif //_IRR_EMSCRIPTEN_PLATFORM_
|
||||
|
||||
// create window
|
||||
if (CreationParams.DriverType != video::EDT_NULL)
|
||||
{
|
||||
// create the window, only if we do not use the null device
|
||||
createWindow();
|
||||
}
|
||||
|
||||
// create cursor control
|
||||
CursorControl = new CCursorControl(this);
|
||||
|
||||
// create driver
|
||||
createDriver();
|
||||
|
||||
if (VideoDriver) {
|
||||
if (VideoDriver)
|
||||
createGUIAndScene();
|
||||
VideoDriver->OnResize(core::dimension2d<u32>(Width, Height));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -271,12 +287,6 @@ CIrrDeviceSDL::~CIrrDeviceSDL()
|
||||
for (u32 i=0; i<numJoysticks; ++i)
|
||||
SDL_JoystickClose(Joysticks[i]);
|
||||
#endif
|
||||
if (Window)
|
||||
{
|
||||
SDL_GL_MakeCurrent(Window, NULL);
|
||||
SDL_GL_DeleteContext(Context);
|
||||
SDL_DestroyWindow(Window);
|
||||
}
|
||||
SDL_Quit();
|
||||
|
||||
os::Printer::log("Quit SDL", ELL_INFORMATION);
|
||||
@ -341,9 +351,9 @@ bool CIrrDeviceSDL::createWindow()
|
||||
{
|
||||
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0);
|
||||
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0);
|
||||
}
|
||||
}
|
||||
|
||||
SDL_CreateWindowAndRenderer(0, 0, SDL_Flags, &Window, &Renderer); // 0,0 will use the canvas size
|
||||
Screen = SDL_SetVideoMode( 0, 0, 32, SDL_Flags); // 0,0 will use the canvas size
|
||||
|
||||
logAttributes();
|
||||
|
||||
@ -358,63 +368,66 @@ bool CIrrDeviceSDL::createWindow()
|
||||
if ( Close )
|
||||
return false;
|
||||
|
||||
if (CreationParams.DriverType == video::EDT_OPENGL) {
|
||||
if (CreationParams.Bits == 16) {
|
||||
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 4);
|
||||
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 4);
|
||||
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 4);
|
||||
SDL_GL_SetAttribute(
|
||||
SDL_GL_ALPHA_SIZE, CreationParams.WithAlphaChannel ? 1 : 0);
|
||||
} else {
|
||||
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
|
||||
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
|
||||
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
|
||||
SDL_GL_SetAttribute(
|
||||
SDL_GL_ALPHA_SIZE, CreationParams.WithAlphaChannel ? 8 : 0);
|
||||
if (CreationParams.DriverType == video::EDT_OPENGL)
|
||||
{
|
||||
if (CreationParams.Bits==16)
|
||||
{
|
||||
SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 4 );
|
||||
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 4 );
|
||||
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 4 );
|
||||
SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, CreationParams.WithAlphaChannel?1:0 );
|
||||
}
|
||||
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, CreationParams.ZBufferBits);
|
||||
else
|
||||
{
|
||||
SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 );
|
||||
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 );
|
||||
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 );
|
||||
SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, CreationParams.WithAlphaChannel?8:0 );
|
||||
}
|
||||
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, CreationParams.ZBufferBits);
|
||||
if (CreationParams.Doublebuffer)
|
||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
||||
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, CreationParams.Stencilbuffer ? 8 : 0);
|
||||
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
|
||||
SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, CreationParams.Stencilbuffer ? 8 : 0);
|
||||
if (CreationParams.Stereobuffer)
|
||||
SDL_GL_SetAttribute(SDL_GL_STEREO, 1);
|
||||
if (CreationParams.AntiAlias > 1) {
|
||||
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
|
||||
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, CreationParams.AntiAlias);
|
||||
SDL_GL_SetAttribute( SDL_GL_STEREO, 1 );
|
||||
if (CreationParams.AntiAlias>1)
|
||||
{
|
||||
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 );
|
||||
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, CreationParams.AntiAlias );
|
||||
}
|
||||
if (!Window)
|
||||
Window = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, Width, Height, SDL_Flags);
|
||||
if (!Window && CreationParams.AntiAlias > 1) {
|
||||
while (--CreationParams.AntiAlias > 1) {
|
||||
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, CreationParams.AntiAlias);
|
||||
Window = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, Width, Height, SDL_Flags);
|
||||
if (Window)
|
||||
if ( !Screen )
|
||||
Screen = SDL_SetVideoMode( Width, Height, CreationParams.Bits, SDL_Flags );
|
||||
if ( !Screen && CreationParams.AntiAlias>1)
|
||||
{
|
||||
while (--CreationParams.AntiAlias>1)
|
||||
{
|
||||
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, CreationParams.AntiAlias );
|
||||
Screen = SDL_SetVideoMode( Width, Height, CreationParams.Bits, SDL_Flags );
|
||||
if (Screen)
|
||||
break;
|
||||
}
|
||||
if (!Window) {
|
||||
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0);
|
||||
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0);
|
||||
Window = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, Width, Height, SDL_Flags);
|
||||
if (Window)
|
||||
os::Printer::log("AntiAliasing disabled due to lack of support!");
|
||||
if ( !Screen )
|
||||
{
|
||||
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 0 );
|
||||
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, 0 );
|
||||
Screen = SDL_SetVideoMode( Width, Height, CreationParams.Bits, SDL_Flags );
|
||||
if (Screen)
|
||||
os::Printer::log("AntiAliasing disabled due to lack of support!" );
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( !Screen )
|
||||
Screen = SDL_SetVideoMode( Width, Height, CreationParams.Bits, SDL_Flags );
|
||||
|
||||
if (Window)
|
||||
{
|
||||
Context = SDL_GL_CreateContext(Window);
|
||||
}
|
||||
} else if (!Window)
|
||||
Window = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, Width, Height, SDL_Flags);
|
||||
|
||||
if ( !Window && CreationParams.Doublebuffer)
|
||||
if ( !Screen && CreationParams.Doublebuffer)
|
||||
{
|
||||
// Try single buffer
|
||||
if (CreationParams.DriverType == video::EDT_OPENGL)
|
||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
||||
Window = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, Width, Height, SDL_Flags);
|
||||
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
|
||||
SDL_Flags &= ~SDL_DOUBLEBUF;
|
||||
Screen = SDL_SetVideoMode( Width, Height, CreationParams.Bits, SDL_Flags );
|
||||
}
|
||||
if ( !Window )
|
||||
if ( !Screen )
|
||||
{
|
||||
os::Printer::log( "Could not initialize display!" );
|
||||
return false;
|
||||
@ -510,9 +523,9 @@ void CIrrDeviceSDL::createDriver()
|
||||
if ( VideoDriver && CreationParams.WindowSize.Width == 0 && CreationParams.WindowSize.Height == 0 && Width > 0 && Height > 0 )
|
||||
{
|
||||
#ifdef _IRR_EMSCRIPTEN_PLATFORM_
|
||||
SDL_CreateWindowAndRenderer(Width, Height, SDL_Flags, &Window, &Renderer);
|
||||
Screen = SDL_SetVideoMode( Width, Height, 32, SDL_Flags );
|
||||
#else //_IRR_EMSCRIPTEN_PLATFORM_
|
||||
Window = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, Width, Height, SDL_Flags);
|
||||
Screen = SDL_SetVideoMode( Width, Height, 0, SDL_Flags );
|
||||
#endif //_IRR_EMSCRIPTEN_PLATFOR
|
||||
VideoDriver->OnResize(core::dimension2d<u32>(Width, Height));
|
||||
}
|
||||
@ -544,14 +557,10 @@ bool CIrrDeviceSDL::run()
|
||||
|
||||
postEventFromUser(irrevent);
|
||||
break;
|
||||
case SDL_MOUSEWHEEL:
|
||||
irrevent.EventType = irr::EET_MOUSE_INPUT_EVENT;
|
||||
irrevent.MouseInput.Event = irr::EMIE_MOUSE_WHEEL;
|
||||
irrevent.MouseInput.Wheel = static_cast<float>(SDL_event.wheel.y);
|
||||
postEventFromUser(irrevent);
|
||||
break;
|
||||
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
|
||||
irrevent.EventType = irr::EET_MOUSE_INPUT_EVENT;
|
||||
irrevent.MouseInput.X = SDL_event.button.x;
|
||||
irrevent.MouseInput.Y = SDL_event.button.y;
|
||||
@ -596,7 +605,7 @@ bool CIrrDeviceSDL::run()
|
||||
else
|
||||
{
|
||||
irrevent.MouseInput.Event = irr::EMIE_LMOUSE_LEFT_UP;
|
||||
MouseButtonStates &= ~irr::EMBSM_LEFT;
|
||||
MouseButtonStates &= !irr::EMBSM_LEFT;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -609,7 +618,7 @@ bool CIrrDeviceSDL::run()
|
||||
else
|
||||
{
|
||||
irrevent.MouseInput.Event = irr::EMIE_RMOUSE_LEFT_UP;
|
||||
MouseButtonStates &= ~irr::EMBSM_RIGHT;
|
||||
MouseButtonStates &= !irr::EMBSM_RIGHT;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -622,9 +631,19 @@ bool CIrrDeviceSDL::run()
|
||||
else
|
||||
{
|
||||
irrevent.MouseInput.Event = irr::EMIE_MMOUSE_LEFT_UP;
|
||||
MouseButtonStates &= ~irr::EMBSM_MIDDLE;
|
||||
MouseButtonStates &= !irr::EMBSM_MIDDLE;
|
||||
}
|
||||
break;
|
||||
|
||||
case SDL_BUTTON_WHEELUP:
|
||||
irrevent.MouseInput.Event = irr::EMIE_MOUSE_WHEEL;
|
||||
irrevent.MouseInput.Wheel = 1.0f;
|
||||
break;
|
||||
|
||||
case SDL_BUTTON_WHEELDOWN:
|
||||
irrevent.MouseInput.Event = irr::EMIE_MOUSE_WHEEL;
|
||||
irrevent.MouseInput.Wheel = -1.0f;
|
||||
break;
|
||||
}
|
||||
|
||||
irrevent.MouseInput.ButtonStates = MouseButtonStates;
|
||||
@ -672,25 +691,19 @@ bool CIrrDeviceSDL::run()
|
||||
}
|
||||
#endif
|
||||
irrevent.EventType = irr::EET_KEY_INPUT_EVENT;
|
||||
|
||||
if (isNoUnicodeKey(key))
|
||||
irrevent.KeyInput.Char = 0;
|
||||
else
|
||||
irrevent.KeyInput.Char = SDL_event.key.keysym.sym;
|
||||
|
||||
irrevent.KeyInput.Char = SDL_event.key.keysym.unicode;
|
||||
irrevent.KeyInput.Key = key;
|
||||
#ifdef _IRR_EMSCRIPTEN_PLATFORM_
|
||||
// On emscripten SDL does not (yet?) return 0 for invalid keysym.unicode's.
|
||||
// Instead it sets keysym.unicode to keysym.sym.
|
||||
// But we need to distinguish control keys from characters here as that info
|
||||
// is necessary in other places like the editbox.
|
||||
if ( isNoUnicodeKey(key) )
|
||||
irrevent.KeyInput.Char = 0;
|
||||
#endif
|
||||
irrevent.KeyInput.PressedDown = (SDL_event.type == SDL_KEYDOWN);
|
||||
irrevent.KeyInput.Shift = (SDL_event.key.keysym.mod & KMOD_SHIFT) != 0;
|
||||
irrevent.KeyInput.Control = (SDL_event.key.keysym.mod & KMOD_CTRL ) != 0;
|
||||
|
||||
// SDL2 no longer provides unicode character in the key event so we ensure the character is in the correct case
|
||||
// TODO: Unicode input doesn't work like this, should probably use SDL_TextInputEvent
|
||||
bool convertCharToUppercase =
|
||||
irrevent.KeyInput.Shift != !!(SDL_event.key.keysym.mod & KMOD_CAPS);
|
||||
|
||||
if (convertCharToUppercase)
|
||||
irrevent.KeyInput.Char = irr::core::locale_upper(irrevent.KeyInput.Char);
|
||||
|
||||
postEventFromUser(irrevent);
|
||||
}
|
||||
break;
|
||||
@ -699,25 +712,25 @@ bool CIrrDeviceSDL::run()
|
||||
Close = true;
|
||||
break;
|
||||
|
||||
case SDL_WINDOWEVENT:
|
||||
switch (SDL_event.window.event)
|
||||
case SDL_ACTIVEEVENT:
|
||||
if (SDL_event.active.state == SDL_APPACTIVE)
|
||||
WindowMinimized = (SDL_event.active.gain!=1);
|
||||
break;
|
||||
|
||||
case SDL_VIDEORESIZE:
|
||||
if ((SDL_event.resize.w != (int)Width) || (SDL_event.resize.h != (int)Height))
|
||||
{
|
||||
case SDL_WINDOWEVENT_MAXIMIZED:
|
||||
WindowMinimized = true;
|
||||
break;
|
||||
case SDL_WINDOWEVENT_RESTORED:
|
||||
WindowMinimized = false;
|
||||
break;
|
||||
case SDL_WINDOWEVENT_RESIZED:
|
||||
if ((SDL_event.window.data1 != (int)Width) || (SDL_event.window.data2 != (int)Height))
|
||||
{
|
||||
Width = SDL_event.window.data1;
|
||||
Height = SDL_event.window.data2;
|
||||
if (VideoDriver)
|
||||
VideoDriver->OnResize(core::dimension2d<u32>(Width, Height));
|
||||
}
|
||||
break;
|
||||
Width = SDL_event.resize.w;
|
||||
Height = SDL_event.resize.h;
|
||||
#ifdef _IRR_EMSCRIPTEN_PLATFORM_
|
||||
Screen = SDL_SetVideoMode( 0, 0, 32, SDL_Flags ); // 0,0 will use the canvas size
|
||||
#else //_IRR_EMSCRIPTEN_PLATFORM_
|
||||
Screen = SDL_SetVideoMode( Width, Height, 0, SDL_Flags );
|
||||
#endif //_IRR_EMSCRIPTEN_PLATFOR
|
||||
if (VideoDriver)
|
||||
VideoDriver->OnResize(core::dimension2d<u32>(Width, Height));
|
||||
}
|
||||
break;
|
||||
|
||||
case SDL_USEREVENT:
|
||||
irrevent.EventType = irr::EET_USER_EVENT;
|
||||
@ -830,13 +843,13 @@ bool CIrrDeviceSDL::activateJoysticks(core::array<SJoystickInfo> & joystickInfo)
|
||||
int joystick = 0;
|
||||
for (; joystick<numJoysticks; ++joystick)
|
||||
{
|
||||
Joysticks.push_back( SDL_JoystickOpen(joystick));
|
||||
Joysticks.push_back(SDL_JoystickOpen(joystick));
|
||||
SJoystickInfo info;
|
||||
|
||||
info.Joystick = joystick;
|
||||
info.Axes = SDL_JoystickNumAxes(Joysticks[joystick]);
|
||||
info.Buttons = SDL_JoystickNumButtons(Joysticks[joystick]);
|
||||
info.Name = SDL_JoystickName(Joysticks[joystick]);
|
||||
info.Name = SDL_JoystickName(joystick);
|
||||
info.PovHat = (SDL_JoystickNumHats(Joysticks[joystick]) > 0)
|
||||
? SJoystickInfo::POV_HAT_PRESENT : SJoystickInfo::POV_HAT_ABSENT;
|
||||
|
||||
@ -859,11 +872,6 @@ bool CIrrDeviceSDL::activateJoysticks(core::array<SJoystickInfo> & joystickInfo)
|
||||
return false;
|
||||
}
|
||||
|
||||
void CIrrDeviceSDL::SwapWindow()
|
||||
{
|
||||
SDL_GL_SwapWindow(Window);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! pause execution temporarily
|
||||
@ -890,9 +898,8 @@ void CIrrDeviceSDL::sleep(u32 timeMs, bool pauseTimer)
|
||||
//! sets the caption of the window
|
||||
void CIrrDeviceSDL::setWindowCaption(const wchar_t* text)
|
||||
{
|
||||
core::stringc textc;
|
||||
core::wStringToMultibyte(textc, text);
|
||||
SDL_SetWindowTitle(Window, textc.c_str());
|
||||
core::stringc textc = text;
|
||||
SDL_WM_SetCaption( textc.c_str( ), textc.c_str( ) );
|
||||
}
|
||||
|
||||
|
||||
@ -908,7 +915,7 @@ bool CIrrDeviceSDL::present(video::IImage* surface, void* windowId, core::rect<s
|
||||
surface->getRedMask(), surface->getGreenMask(), surface->getBlueMask(), surface->getAlphaMask());
|
||||
if (!sdlSurface)
|
||||
return false;
|
||||
SDL_SetSurfaceAlphaMod(sdlSurface, 0);
|
||||
SDL_SetAlpha(sdlSurface, 0, 0);
|
||||
SDL_SetColorKey(sdlSurface, 0, 0);
|
||||
sdlSurface->format->BitsPerPixel=surface->getBitsPerPixel();
|
||||
sdlSurface->format->BytesPerPixel=surface->getBytesPerPixel();
|
||||
@ -957,7 +964,7 @@ bool CIrrDeviceSDL::present(video::IImage* surface, void* windowId, core::rect<s
|
||||
|
||||
SDL_Surface* scr = (SDL_Surface* )windowId;
|
||||
if (!scr)
|
||||
scr = SDL_GetWindowSurface(Window);
|
||||
scr = Screen;
|
||||
if (scr)
|
||||
{
|
||||
if (srcClip)
|
||||
@ -971,7 +978,7 @@ bool CIrrDeviceSDL::present(video::IImage* surface, void* windowId, core::rect<s
|
||||
}
|
||||
else
|
||||
SDL_BlitSurface(sdlSurface, NULL, scr, NULL);
|
||||
SDL_RenderPresent(SDL_GetRenderer(Window));
|
||||
SDL_Flip(scr);
|
||||
}
|
||||
|
||||
SDL_FreeSurface(sdlSurface);
|
||||
@ -987,6 +994,53 @@ void CIrrDeviceSDL::closeDevice()
|
||||
}
|
||||
|
||||
|
||||
//! \return Pointer to a list with all video modes supported
|
||||
video::IVideoModeList* CIrrDeviceSDL::getVideoModeList()
|
||||
{
|
||||
#ifdef _IRR_EMSCRIPTEN_PLATFORM_
|
||||
os::Printer::log("VideoModeList not available on the web." , ELL_WARNING);
|
||||
return VideoModeList;
|
||||
#else // !_IRR_EMSCRIPTEN_PLATFORM_
|
||||
if (!VideoModeList->getVideoModeCount())
|
||||
{
|
||||
// enumerate video modes.
|
||||
const SDL_VideoInfo *vi = SDL_GetVideoInfo();
|
||||
|
||||
SDL_PixelFormat pixelFormat = *(vi->vfmt);
|
||||
|
||||
core::array<Uint8> checkBitsPerPixel;
|
||||
checkBitsPerPixel.push_back(8);
|
||||
checkBitsPerPixel.push_back(16);
|
||||
checkBitsPerPixel.push_back(24);
|
||||
checkBitsPerPixel.push_back(32);
|
||||
if ( pixelFormat.BitsPerPixel > 32 )
|
||||
checkBitsPerPixel.push_back(pixelFormat.BitsPerPixel);
|
||||
|
||||
for ( u32 i=0; i<checkBitsPerPixel.size(); ++i)
|
||||
{
|
||||
pixelFormat.BitsPerPixel = checkBitsPerPixel[i];
|
||||
SDL_Rect **modes = SDL_ListModes(&pixelFormat, SDL_Flags|SDL_FULLSCREEN);
|
||||
if (modes != 0)
|
||||
{
|
||||
if (modes == (SDL_Rect **)-1)
|
||||
{
|
||||
core::stringc strLog("All modes available for bit-depth ");
|
||||
strLog += core::stringc(pixelFormat.BitsPerPixel);
|
||||
os::Printer::log(strLog.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
for (u32 i=0; modes[i]; ++i)
|
||||
VideoModeList->addMode(core::dimension2d<u32>(modes[i]->w, modes[i]->h), vi->vfmt->BitsPerPixel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return VideoModeList;
|
||||
#endif // !_IRR_EMSCRIPTEN_PLATFORM_
|
||||
}
|
||||
|
||||
//! Sets if the window should be resizable in windowed mode.
|
||||
void CIrrDeviceSDL::setResizable(bool resize)
|
||||
{
|
||||
@ -994,15 +1048,24 @@ void CIrrDeviceSDL::setResizable(bool resize)
|
||||
os::Printer::log("Resizable not available on the web." , ELL_WARNING);
|
||||
return;
|
||||
#else // !_IRR_EMSCRIPTEN_PLATFORM_
|
||||
if (resize != Resizable) {
|
||||
if (resize)
|
||||
SDL_Flags |= SDL_WINDOW_RESIZABLE;
|
||||
else
|
||||
SDL_Flags &= ~SDL_WINDOW_RESIZABLE;
|
||||
|
||||
if (Window) {
|
||||
SDL_SetWindowResizable(Window, (SDL_bool)resize);
|
||||
if (resize != Resizable)
|
||||
{
|
||||
#if defined(_IRR_COMPILE_WITH_OPENGL_) && defined(_IRR_WINDOWS_)
|
||||
if ( SDL_Flags & SDL_OPENGL )
|
||||
{
|
||||
// For unknown reasons the hack with sharing resources which was added in Irrlicht 1.8.5 for this no longer works in 1.9
|
||||
// But at least we got a new WindowResizable flag since Irrlicht 1.9.
|
||||
os::Printer::log("setResizable not supported with this device/driver combination. Use SIrrCreationParameters.WindowResizable instead.", ELL_WARNING);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (resize)
|
||||
SDL_Flags |= SDL_RESIZABLE;
|
||||
else
|
||||
SDL_Flags &= ~SDL_RESIZABLE;
|
||||
|
||||
Screen = SDL_SetVideoMode( 0, 0, 0, SDL_Flags );
|
||||
Resizable = resize;
|
||||
}
|
||||
#endif // !_IRR_EMSCRIPTEN_PLATFORM_
|
||||
@ -1012,9 +1075,7 @@ void CIrrDeviceSDL::setResizable(bool resize)
|
||||
//! Minimizes window if possible
|
||||
void CIrrDeviceSDL::minimizeWindow()
|
||||
{
|
||||
if (Window) {
|
||||
SDL_MinimizeWindow(Window);
|
||||
}
|
||||
SDL_WM_IconifyWindow();
|
||||
}
|
||||
|
||||
|
||||
@ -1061,15 +1122,15 @@ bool CIrrDeviceSDL::isWindowActive() const
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
const u32 windowFlags = SDL_GetWindowFlags(Window);
|
||||
return windowFlags & SDL_WINDOW_SHOWN && windowFlags & SDL_WINDOW_INPUT_FOCUS;
|
||||
const Uint8 appState = SDL_GetAppState();
|
||||
return (appState&SDL_APPACTIVE && appState&SDL_APPINPUTFOCUS) ? true : false;
|
||||
}
|
||||
|
||||
|
||||
//! returns if window has focus.
|
||||
bool CIrrDeviceSDL::isWindowFocused() const
|
||||
{
|
||||
return SDL_GetWindowFlags(Window) & SDL_WINDOW_INPUT_FOCUS;
|
||||
return (SDL_GetAppState()&SDL_APPINPUTFOCUS) ? true : false;
|
||||
}
|
||||
|
||||
|
||||
@ -1102,19 +1163,18 @@ bool CIrrDeviceSDL::getGammaRamp( f32 &red, f32 &green, f32 &blue, f32 &brightne
|
||||
//! returns color format of the window.
|
||||
video::ECOLOR_FORMAT CIrrDeviceSDL::getColorFormat() const
|
||||
{
|
||||
if (Window)
|
||||
if (Screen)
|
||||
{
|
||||
SDL_Surface *surface = SDL_GetWindowSurface(Window);
|
||||
if (surface->format->BitsPerPixel == 16)
|
||||
if (Screen->format->BitsPerPixel==16)
|
||||
{
|
||||
if (surface->format->Amask != 0)
|
||||
if (Screen->format->Amask != 0)
|
||||
return video::ECF_A1R5G5B5;
|
||||
else
|
||||
return video::ECF_R5G6B5;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (surface->format->Amask != 0)
|
||||
if (Screen->format->Amask != 0)
|
||||
return video::ECF_A8R8G8B8;
|
||||
else
|
||||
return video::ECF_R8G8B8;
|
||||
@ -1162,9 +1222,9 @@ void CIrrDeviceSDL::createKeyMap()
|
||||
KeyMap.push_back(SKeyMap(SDLK_DOWN, KEY_DOWN));
|
||||
|
||||
// select missing
|
||||
KeyMap.push_back(SKeyMap(SDLK_PRINTSCREEN, KEY_PRINT));
|
||||
KeyMap.push_back(SKeyMap(SDLK_PRINT, KEY_PRINT));
|
||||
// execute missing
|
||||
KeyMap.push_back(SKeyMap(SDLK_PRINTSCREEN, KEY_SNAPSHOT));
|
||||
KeyMap.push_back(SKeyMap(SDLK_PRINT, KEY_SNAPSHOT));
|
||||
|
||||
KeyMap.push_back(SKeyMap(SDLK_INSERT, KEY_INSERT));
|
||||
KeyMap.push_back(SKeyMap(SDLK_DELETE, KEY_DELETE));
|
||||
@ -1208,21 +1268,21 @@ void CIrrDeviceSDL::createKeyMap()
|
||||
KeyMap.push_back(SKeyMap(SDLK_y, KEY_KEY_Y));
|
||||
KeyMap.push_back(SKeyMap(SDLK_z, KEY_KEY_Z));
|
||||
|
||||
KeyMap.push_back(SKeyMap(SDLK_LGUI, KEY_LWIN));
|
||||
KeyMap.push_back(SKeyMap(SDLK_RGUI, KEY_RWIN));
|
||||
KeyMap.push_back(SKeyMap(SDLK_LSUPER, KEY_LWIN));
|
||||
KeyMap.push_back(SKeyMap(SDLK_RSUPER, KEY_RWIN));
|
||||
// apps missing
|
||||
KeyMap.push_back(SKeyMap(SDLK_POWER, KEY_SLEEP)); //??
|
||||
|
||||
KeyMap.push_back(SKeyMap(SDLK_KP_0, KEY_NUMPAD0));
|
||||
KeyMap.push_back(SKeyMap(SDLK_KP_1, KEY_NUMPAD1));
|
||||
KeyMap.push_back(SKeyMap(SDLK_KP_2, KEY_NUMPAD2));
|
||||
KeyMap.push_back(SKeyMap(SDLK_KP_3, KEY_NUMPAD3));
|
||||
KeyMap.push_back(SKeyMap(SDLK_KP_4, KEY_NUMPAD4));
|
||||
KeyMap.push_back(SKeyMap(SDLK_KP_5, KEY_NUMPAD5));
|
||||
KeyMap.push_back(SKeyMap(SDLK_KP_6, KEY_NUMPAD6));
|
||||
KeyMap.push_back(SKeyMap(SDLK_KP_7, KEY_NUMPAD7));
|
||||
KeyMap.push_back(SKeyMap(SDLK_KP_8, KEY_NUMPAD8));
|
||||
KeyMap.push_back(SKeyMap(SDLK_KP_9, KEY_NUMPAD9));
|
||||
KeyMap.push_back(SKeyMap(SDLK_KP0, KEY_NUMPAD0));
|
||||
KeyMap.push_back(SKeyMap(SDLK_KP1, KEY_NUMPAD1));
|
||||
KeyMap.push_back(SKeyMap(SDLK_KP2, KEY_NUMPAD2));
|
||||
KeyMap.push_back(SKeyMap(SDLK_KP3, KEY_NUMPAD3));
|
||||
KeyMap.push_back(SKeyMap(SDLK_KP4, KEY_NUMPAD4));
|
||||
KeyMap.push_back(SKeyMap(SDLK_KP5, KEY_NUMPAD5));
|
||||
KeyMap.push_back(SKeyMap(SDLK_KP6, KEY_NUMPAD6));
|
||||
KeyMap.push_back(SKeyMap(SDLK_KP7, KEY_NUMPAD7));
|
||||
KeyMap.push_back(SKeyMap(SDLK_KP8, KEY_NUMPAD8));
|
||||
KeyMap.push_back(SKeyMap(SDLK_KP9, KEY_NUMPAD9));
|
||||
KeyMap.push_back(SKeyMap(SDLK_KP_MULTIPLY, KEY_MULTIPLY));
|
||||
KeyMap.push_back(SKeyMap(SDLK_KP_PLUS, KEY_ADD));
|
||||
// KeyMap.push_back(SKeyMap(SDLK_KP_, KEY_SEPARATOR));
|
||||
@ -1247,8 +1307,8 @@ void CIrrDeviceSDL::createKeyMap()
|
||||
KeyMap.push_back(SKeyMap(SDLK_F15, KEY_F15));
|
||||
// no higher F-keys
|
||||
|
||||
KeyMap.push_back(SKeyMap(SDLK_NUMLOCKCLEAR, KEY_NUMLOCK));
|
||||
KeyMap.push_back(SKeyMap(SDLK_SCROLLLOCK, KEY_SCROLL));
|
||||
KeyMap.push_back(SKeyMap(SDLK_NUMLOCK, KEY_NUMLOCK));
|
||||
KeyMap.push_back(SKeyMap(SDLK_SCROLLOCK, KEY_SCROLL));
|
||||
KeyMap.push_back(SKeyMap(SDLK_LSHIFT, KEY_LSHIFT));
|
||||
KeyMap.push_back(SKeyMap(SDLK_RSHIFT, KEY_RSHIFT));
|
||||
KeyMap.push_back(SKeyMap(SDLK_LCTRL, KEY_LCONTROL));
|
||||
|
@ -20,8 +20,8 @@
|
||||
#include <emscripten/html5.h>
|
||||
#endif
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL2/SDL_syswm.h>
|
||||
#include <SDL/SDL.h>
|
||||
#include <SDL/SDL_syswm.h>
|
||||
|
||||
namespace irr
|
||||
{
|
||||
@ -66,6 +66,9 @@ namespace irr
|
||||
//! notifies the device that it should close itself
|
||||
virtual void closeDevice() _IRR_OVERRIDE_;
|
||||
|
||||
//! \return Returns a pointer to a list with all video modes supported
|
||||
virtual video::IVideoModeList* getVideoModeList() _IRR_OVERRIDE_;
|
||||
|
||||
//! Sets if the window should be resizable in windowed mode.
|
||||
virtual void setResizable(bool resize=false) _IRR_OVERRIDE_;
|
||||
|
||||
@ -100,8 +103,6 @@ namespace irr
|
||||
return EIDT_SDL;
|
||||
}
|
||||
|
||||
void SwapWindow();
|
||||
|
||||
//! Implementation of the linux cursor control
|
||||
class CCursorControl : public gui::ICursorControl
|
||||
{
|
||||
@ -151,7 +152,7 @@ namespace irr
|
||||
//! Sets the new position of the cursor.
|
||||
virtual void setPosition(s32 x, s32 y) _IRR_OVERRIDE_
|
||||
{
|
||||
SDL_WarpMouseInWindow(Device->Window, x, y);
|
||||
SDL_WarpMouse( x, y );
|
||||
}
|
||||
|
||||
//! Returns the current position of the mouse cursor.
|
||||
@ -223,9 +224,9 @@ namespace irr
|
||||
static EM_BOOL MouseEnterCallback(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData);
|
||||
static EM_BOOL MouseLeaveCallback(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData);
|
||||
|
||||
// Check if it's a special key like left, right, up down and so on which shouldn't have a Unicode character.
|
||||
bool isNoUnicodeKey(EKEY_CODE key) const;
|
||||
#endif
|
||||
// Check if it's a special key like left, right, up down and so on which shouldn't have a Unicode character.
|
||||
bool isNoUnicodeKey(EKEY_CODE key) const;
|
||||
|
||||
//! create the driver
|
||||
void createDriver();
|
||||
@ -235,8 +236,8 @@ namespace irr
|
||||
void createKeyMap();
|
||||
|
||||
void logAttributes();
|
||||
SDL_GLContext Context;
|
||||
SDL_Window *Window;
|
||||
|
||||
SDL_Surface* Screen;
|
||||
int SDL_Flags;
|
||||
#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_)
|
||||
core::array<SDL_Joystick*> Joysticks;
|
||||
|
@ -308,6 +308,11 @@ namespace
|
||||
return os::Randomizer::rand();
|
||||
}
|
||||
|
||||
virtual f32 frand() const _IRR_OVERRIDE_
|
||||
{
|
||||
return os::Randomizer::frand();
|
||||
}
|
||||
|
||||
virtual s32 randMax() const _IRR_OVERRIDE_
|
||||
{
|
||||
return os::Randomizer::randMax();
|
||||
|
@ -18,28 +18,10 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "^(GNU|Clang|AppleClang)$")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-g")
|
||||
|
||||
add_compile_options(-Wall -pipe -fno-exceptions -fno-rtti)
|
||||
|
||||
# Enable SSE for floating point math on 32-bit x86 by default
|
||||
# reasoning see minetest issue #11810 and https://gcc.gnu.org/wiki/FloatingPointMath
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
include(CheckCXXSourceCompiles)
|
||||
check_cxx_source_compiles("#ifndef __i686__\n#error\n#endif\nint main(){}" IS_I686)
|
||||
if(IS_I686)
|
||||
message(STATUS "Detected Intel x86: using SSE instead of x87 FPU")
|
||||
add_compile_options(-mfpmath=sse -msse)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
elseif(MSVC)
|
||||
string(APPEND CMAKE_CXX_STANDARD_LIBRARIES " msvcrt.lib") # ???? fuck off
|
||||
|
||||
add_compile_options(/GR- /Zl)
|
||||
|
||||
# Enable SSE for floating point math on 32-bit x86 by default
|
||||
# reasoning see minetest issue #11810 and https://gcc.gnu.org/wiki/FloatingPointMath
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
add_compile_options(/arch:SSE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Required libs
|
||||
@ -56,7 +38,6 @@ unset(OGLES1_ENABLED CACHE)
|
||||
unset(OGLES2_ENABLED CACHE)
|
||||
unset(OGL_ENABLED CACHE)
|
||||
unset(XINPUT2_ENABLED CACHE)
|
||||
unset(SDL_ENABLED CACHE)
|
||||
|
||||
check_symbol_exists(_IRR_COMPILE_WITH_OGLES1_ "IrrCompileConfig.h" OGLES1_ENABLED)
|
||||
if(OGLES1_ENABLED)
|
||||
@ -80,12 +61,6 @@ if(XINPUT2_ENABLED)
|
||||
find_library(XINPUT_LIBRARY Xi REQUIRED)
|
||||
endif()
|
||||
|
||||
check_symbol_exists(_IRR_COMPILE_WITH_SDL_DEVICE_ "IrrCompileConfig.h" SDL_ENABLED)
|
||||
if(SDL_ENABLED)
|
||||
find_package(SDL2 CONFIG REQUIRED)
|
||||
message(STATUS "Found SDL2: ${SDL2_LIBRARIES}")
|
||||
endif()
|
||||
|
||||
# Platform-specific libs
|
||||
|
||||
if(ANDROID)
|
||||
@ -108,7 +83,6 @@ set(link_includes
|
||||
"${ZLIB_INCLUDE_DIR}"
|
||||
"${JPEG_INCLUDE_DIR}"
|
||||
"${PNG_INCLUDE_DIR}"
|
||||
"${SDL2_INCLUDE_DIRS}"
|
||||
|
||||
${OPENGL_INCLUDE_DIR}
|
||||
${OPENGLES2_INCLUDE_DIR}
|
||||
@ -122,7 +96,6 @@ set(link_libs
|
||||
"${ZLIB_LIBRARY}"
|
||||
"${JPEG_LIBRARY}"
|
||||
"${PNG_LIBRARY}"
|
||||
"${SDL2_LIBRARIES}"
|
||||
|
||||
${OPENGL_LIBRARIES}
|
||||
${OPENGLES_LIBRARY}
|
||||
@ -171,6 +144,8 @@ set(IRRDRVROBJ
|
||||
CNullDriver.cpp
|
||||
COpenGLCacheHandler.cpp
|
||||
COpenGLDriver.cpp
|
||||
COpenGLNormalMapRenderer.cpp
|
||||
COpenGLParallaxMapRenderer.cpp
|
||||
COpenGLShaderMaterialRenderer.cpp
|
||||
COpenGLSLMaterialRenderer.cpp
|
||||
COpenGLExtensionHandler.cpp
|
||||
@ -180,6 +155,8 @@ set(IRRDRVROBJ
|
||||
COGLES2ExtensionHandler.cpp
|
||||
COGLES2FixedPipelineRenderer.cpp
|
||||
COGLES2MaterialRenderer.cpp
|
||||
COGLES2NormalMapRenderer.cpp
|
||||
COGLES2ParallaxMapRenderer.cpp
|
||||
COGLES2Renderer2D.cpp
|
||||
CWebGL1Driver.cpp
|
||||
CGLXManager.cpp
|
||||
|
@ -3,7 +3,6 @@
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#include "CMeshManipulator.h"
|
||||
#include "ISkinnedMesh.h"
|
||||
#include "SMesh.h"
|
||||
#include "CMeshBuffer.h"
|
||||
#include "SAnimatedMesh.h"
|
||||
@ -147,21 +146,9 @@ void CMeshManipulator::recalculateNormals(scene::IMesh* mesh, bool smooth, bool
|
||||
if (!mesh)
|
||||
return;
|
||||
|
||||
if (mesh->getMeshType() == EAMT_SKINNED)
|
||||
{
|
||||
ISkinnedMesh *smesh = (ISkinnedMesh *) mesh;
|
||||
smesh->resetAnimation();
|
||||
}
|
||||
|
||||
const u32 bcount = mesh->getMeshBufferCount();
|
||||
for ( u32 b=0; b<bcount; ++b)
|
||||
recalculateNormals(mesh->getMeshBuffer(b), smooth, angleWeighted);
|
||||
|
||||
if (mesh->getMeshType() == EAMT_SKINNED)
|
||||
{
|
||||
ISkinnedMesh *smesh = (ISkinnedMesh *) mesh;
|
||||
smesh->refreshJointCache();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -170,8 +170,8 @@ void CMeshSceneNode::render()
|
||||
if (DebugDataVisible & scene::EDS_NORMALS)
|
||||
{
|
||||
// draw normals
|
||||
const f32 debugNormalLength = 1.f;
|
||||
const video::SColor debugNormalColor = video::SColor(255, 34, 221, 221);
|
||||
const f32 debugNormalLength = SceneManager->getParameters()->getAttributeAsFloat(DEBUG_NORMAL_LENGTH);
|
||||
const video::SColor debugNormalColor = SceneManager->getParameters()->getAttributeAsColor(DEBUG_NORMAL_COLOR);
|
||||
const u32 count = Mesh->getMeshBufferCount();
|
||||
|
||||
for (u32 i=0; i != count; ++i)
|
||||
@ -276,6 +276,75 @@ void CMeshSceneNode::copyMaterials()
|
||||
}
|
||||
|
||||
|
||||
//! Writes attributes of the scene node.
|
||||
void CMeshSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const
|
||||
{
|
||||
IMeshSceneNode::serializeAttributes(out, options);
|
||||
|
||||
if (options && (options->Flags&io::EARWF_USE_RELATIVE_PATHS) && options->Filename)
|
||||
{
|
||||
const io::path path = SceneManager->getFileSystem()->getRelativeFilename(
|
||||
SceneManager->getFileSystem()->getAbsolutePath(SceneManager->getMeshCache()->getMeshName(Mesh).getPath()),
|
||||
options->Filename);
|
||||
out->addString("Mesh", path.c_str());
|
||||
}
|
||||
else
|
||||
out->addString("Mesh", SceneManager->getMeshCache()->getMeshName(Mesh).getPath().c_str());
|
||||
out->addBool("ReadOnlyMaterials", ReadOnlyMaterials);
|
||||
}
|
||||
|
||||
|
||||
//! Reads attributes of the scene node.
|
||||
void CMeshSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options)
|
||||
{
|
||||
io::path oldMeshStr = SceneManager->getMeshCache()->getMeshName(Mesh);
|
||||
io::path newMeshStr = in->getAttributeAsString("Mesh");
|
||||
ReadOnlyMaterials = in->getAttributeAsBool("ReadOnlyMaterials");
|
||||
|
||||
if (newMeshStr != "" && oldMeshStr != newMeshStr)
|
||||
{
|
||||
IMesh* newMesh = 0;
|
||||
IAnimatedMesh* newAnimatedMesh = SceneManager->getMesh(newMeshStr.c_str());
|
||||
|
||||
if (newAnimatedMesh)
|
||||
newMesh = newAnimatedMesh->getMesh(0);
|
||||
|
||||
if (newMesh)
|
||||
setMesh(newMesh);
|
||||
}
|
||||
|
||||
// optional attribute to assign the hint to the whole mesh
|
||||
if (in->existsAttribute("HardwareMappingHint") &&
|
||||
in->existsAttribute("HardwareMappingBufferType"))
|
||||
{
|
||||
scene::E_HARDWARE_MAPPING mapping = scene::EHM_NEVER;
|
||||
scene::E_BUFFER_TYPE bufferType = scene::EBT_NONE;
|
||||
|
||||
core::stringc smapping = in->getAttributeAsString("HardwareMappingHint");
|
||||
if (smapping.equals_ignore_case("static"))
|
||||
mapping = scene::EHM_STATIC;
|
||||
else if (smapping.equals_ignore_case("dynamic"))
|
||||
mapping = scene::EHM_DYNAMIC;
|
||||
else if (smapping.equals_ignore_case("stream"))
|
||||
mapping = scene::EHM_STREAM;
|
||||
|
||||
core::stringc sbufferType = in->getAttributeAsString("HardwareMappingBufferType");
|
||||
if (sbufferType.equals_ignore_case("vertex"))
|
||||
bufferType = scene::EBT_VERTEX;
|
||||
else if (sbufferType.equals_ignore_case("index"))
|
||||
bufferType = scene::EBT_INDEX;
|
||||
else if (sbufferType.equals_ignore_case("vertexindex"))
|
||||
bufferType = scene::EBT_VERTEX_AND_INDEX;
|
||||
|
||||
IMesh* mesh = getMesh();
|
||||
if (mesh)
|
||||
mesh->setHardwareMappingHint(mapping, bufferType);
|
||||
}
|
||||
|
||||
IMeshSceneNode::deserializeAttributes(in, options);
|
||||
}
|
||||
|
||||
|
||||
//! 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. */
|
||||
|
@ -45,6 +45,12 @@ namespace scene
|
||||
//! returns amount of materials used by this scene node.
|
||||
virtual u32 getMaterialCount() const _IRR_OVERRIDE_;
|
||||
|
||||
//! Writes attributes of the scene node.
|
||||
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Reads attributes of the scene node.
|
||||
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) _IRR_OVERRIDE_;
|
||||
|
||||
//! Returns type of the scene node
|
||||
virtual ESCENE_NODE_TYPE getType() const _IRR_OVERRIDE_ { return ESNT_MESH; }
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include "IAnimatedMeshSceneNode.h"
|
||||
#include "CMeshManipulator.h"
|
||||
#include "CColorConverter.h"
|
||||
#include "IReferenceCounted.h"
|
||||
#include "IAttributeExchangingObject.h"
|
||||
#include "IRenderTarget.h"
|
||||
|
||||
|
||||
@ -1291,6 +1291,124 @@ void CNullDriver::makeColorKeyTexture(video::ITexture* texture,
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! Creates a normal map from a height map texture.
|
||||
//! \param amplitude: Constant value by which the height information is multiplied.
|
||||
void CNullDriver::makeNormalMapTexture(video::ITexture* texture, f32 amplitude) const
|
||||
{
|
||||
if (!texture)
|
||||
return;
|
||||
|
||||
if (texture->getColorFormat() != ECF_A1R5G5B5 &&
|
||||
texture->getColorFormat() != ECF_A8R8G8B8 )
|
||||
{
|
||||
os::Printer::log("Error: Unsupported texture color format for making normal map.", ELL_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
core::dimension2d<u32> dim = texture->getSize();
|
||||
amplitude = amplitude / 255.0f;
|
||||
f32 vh = dim.Height / (f32)dim.Width;
|
||||
f32 hh = dim.Width / (f32)dim.Height;
|
||||
|
||||
if (texture->getColorFormat() == ECF_A8R8G8B8)
|
||||
{
|
||||
// ECF_A8R8G8B8 version
|
||||
|
||||
s32 *p = (s32*)texture->lock();
|
||||
|
||||
if (!p)
|
||||
{
|
||||
os::Printer::log("Could not lock texture for making normal map.", ELL_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
// copy texture
|
||||
|
||||
u32 pitch = texture->getPitch() / 4;
|
||||
|
||||
s32* in = new s32[dim.Height * pitch];
|
||||
memcpy(in, p, dim.Height * pitch * 4);
|
||||
|
||||
for (s32 x=0; x < s32(pitch); ++x)
|
||||
for (s32 y=0; y < s32(dim.Height); ++y)
|
||||
{
|
||||
// TODO: this could be optimized really a lot
|
||||
|
||||
core::vector3df h1((x-1)*hh, nml32(x-1, y, pitch, dim.Height, in)*amplitude, y*vh);
|
||||
core::vector3df h2((x+1)*hh, nml32(x+1, y, pitch, dim.Height, in)*amplitude, y*vh);
|
||||
//core::vector3df v1(x*hh, nml32(x, y-1, pitch, dim.Height, in)*amplitude, (y-1)*vh);
|
||||
//core::vector3df v2(x*hh, nml32(x, y+1, pitch, dim.Height, in)*amplitude, (y+1)*vh);
|
||||
core::vector3df v1(x*hh, nml32(x, y+1, pitch, dim.Height, in)*amplitude, (y-1)*vh);
|
||||
core::vector3df v2(x*hh, nml32(x, y-1, pitch, dim.Height, in)*amplitude, (y+1)*vh);
|
||||
|
||||
core::vector3df v = v1-v2;
|
||||
core::vector3df h = h1-h2;
|
||||
|
||||
core::vector3df n = v.crossProduct(h);
|
||||
n.normalize();
|
||||
n *= 0.5f;
|
||||
n += core::vector3df(0.5f,0.5f,0.5f); // now between 0 and 1
|
||||
n *= 255.0f;
|
||||
|
||||
s32 height = (s32)nml32(x, y, pitch, dim.Height, in);
|
||||
p[y*pitch + x] = video::SColor(
|
||||
height, // store height in alpha
|
||||
(s32)n.X, (s32)n.Z, (s32)n.Y).color;
|
||||
}
|
||||
|
||||
delete [] in;
|
||||
texture->unlock();
|
||||
}
|
||||
else
|
||||
{
|
||||
// ECF_A1R5G5B5 version
|
||||
|
||||
s16 *p = (s16*)texture->lock();
|
||||
|
||||
if (!p)
|
||||
{
|
||||
os::Printer::log("Could not lock texture for making normal map.", ELL_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
u32 pitch = texture->getPitch() / 2;
|
||||
|
||||
// copy texture
|
||||
|
||||
s16* in = new s16[dim.Height * pitch];
|
||||
memcpy(in, p, dim.Height * pitch * 2);
|
||||
|
||||
for (s32 x=0; x < s32(pitch); ++x)
|
||||
for (s32 y=0; y < s32(dim.Height); ++y)
|
||||
{
|
||||
// TODO: this could be optimized really a lot
|
||||
|
||||
core::vector3df h1((x-1)*hh, nml16(x-1, y, pitch, dim.Height, in)*amplitude, y*vh);
|
||||
core::vector3df h2((x+1)*hh, nml16(x+1, y, pitch, dim.Height, in)*amplitude, y*vh);
|
||||
core::vector3df v1(x*hh, nml16(x, y-1, pitch, dim.Height, in)*amplitude, (y-1)*vh);
|
||||
core::vector3df v2(x*hh, nml16(x, y+1, pitch, dim.Height, in)*amplitude, (y+1)*vh);
|
||||
|
||||
core::vector3df v = v1-v2;
|
||||
core::vector3df h = h1-h2;
|
||||
|
||||
core::vector3df n = v.crossProduct(h);
|
||||
n.normalize();
|
||||
n *= 0.5f;
|
||||
n += core::vector3df(0.5f,0.5f,0.5f); // now between 0 and 1
|
||||
n *= 255.0f;
|
||||
|
||||
p[y*pitch + x] = video::RGBA16((u32)n.X, (u32)n.Z, (u32)n.Y);
|
||||
}
|
||||
|
||||
delete [] in;
|
||||
texture->unlock();
|
||||
}
|
||||
|
||||
texture->regenerateMipMapLevels();
|
||||
}
|
||||
|
||||
|
||||
//! Returns the maximum amount of primitives (mostly vertices) which
|
||||
//! the device is able to render with one drawIndexedTriangleList
|
||||
//! call.
|
||||
@ -2000,6 +2118,193 @@ void CNullDriver::swapMaterialRenderers(u32 idx1, u32 idx2, bool swapNames)
|
||||
}
|
||||
}
|
||||
|
||||
//! Creates material attributes list from a material, usable for serialization and more.
|
||||
io::IAttributes* CNullDriver::createAttributesFromMaterial(const video::SMaterial& material,
|
||||
io::SAttributeReadWriteOptions* options)
|
||||
{
|
||||
io::CAttributes* attr = new io::CAttributes(this);
|
||||
|
||||
attr->addEnum("Type", material.MaterialType, sBuiltInMaterialTypeNames);
|
||||
|
||||
attr->addColor("Ambient", material.AmbientColor);
|
||||
attr->addColor("Diffuse", material.DiffuseColor);
|
||||
attr->addColor("Emissive", material.EmissiveColor);
|
||||
attr->addColor("Specular", material.SpecularColor);
|
||||
|
||||
attr->addFloat("Shininess", material.Shininess);
|
||||
attr->addFloat("Param1", material.MaterialTypeParam);
|
||||
attr->addFloat("Param2", material.MaterialTypeParam2);
|
||||
attr->addFloat("Thickness", material.Thickness);
|
||||
|
||||
core::stringc prefix="Texture";
|
||||
u32 i;
|
||||
for (i=0; i<MATERIAL_MAX_TEXTURES; ++i)
|
||||
{
|
||||
video::ITexture* texture = material.getTexture(i);
|
||||
if (options && (options->Flags&io::EARWF_USE_RELATIVE_PATHS) && options->Filename && texture)
|
||||
{
|
||||
io::path path = FileSystem->getRelativeFilename(
|
||||
FileSystem->getAbsolutePath(material.getTexture(i)->getName()), options->Filename);
|
||||
attr->addTexture((prefix+core::stringc(i+1)).c_str(), material.getTexture(i), path);
|
||||
}
|
||||
else
|
||||
{
|
||||
attr->addTexture((prefix+core::stringc(i+1)).c_str(), texture);
|
||||
}
|
||||
}
|
||||
|
||||
attr->addBool("Wireframe", material.Wireframe);
|
||||
attr->addBool("PointCloud", material.PointCloud);
|
||||
attr->addBool("GouraudShading", material.GouraudShading);
|
||||
attr->addBool("Lighting", material.Lighting);
|
||||
attr->addEnum("ZWriteEnable", (irr::s32)material.ZWriteEnable, video::ZWriteNames);
|
||||
attr->addInt("ZBuffer", material.ZBuffer);
|
||||
attr->addBool("BackfaceCulling", material.BackfaceCulling);
|
||||
attr->addBool("FrontfaceCulling", material.FrontfaceCulling);
|
||||
attr->addBool("FogEnable", material.FogEnable);
|
||||
attr->addBool("NormalizeNormals", material.NormalizeNormals);
|
||||
attr->addBool("UseMipMaps", material.UseMipMaps);
|
||||
attr->addInt("AntiAliasing", material.AntiAliasing);
|
||||
attr->addInt("ColorMask", material.ColorMask);
|
||||
attr->addInt("ColorMaterial", material.ColorMaterial);
|
||||
attr->addInt("BlendOperation", material.BlendOperation);
|
||||
attr->addFloat("BlendFactor", material.BlendFactor);
|
||||
attr->addInt("PolygonOffsetFactor", material.PolygonOffsetFactor);
|
||||
attr->addEnum("PolygonOffsetDirection", material.PolygonOffsetDirection, video::PolygonOffsetDirectionNames);
|
||||
attr->addFloat("PolygonOffsetDepthBias", material.PolygonOffsetDepthBias);
|
||||
attr->addFloat("PolygonOffsetSlopeScale", material.PolygonOffsetSlopeScale);
|
||||
|
||||
// TODO: Would be nice to have a flag that only serializes rest of texture data when a texture pointer exists.
|
||||
prefix = "BilinearFilter";
|
||||
for (i=0; i<MATERIAL_MAX_TEXTURES; ++i)
|
||||
attr->addBool((prefix+core::stringc(i+1)).c_str(), material.TextureLayer[i].BilinearFilter);
|
||||
prefix = "TrilinearFilter";
|
||||
for (i=0; i<MATERIAL_MAX_TEXTURES; ++i)
|
||||
attr->addBool((prefix+core::stringc(i+1)).c_str(), material.TextureLayer[i].TrilinearFilter);
|
||||
prefix = "AnisotropicFilter";
|
||||
for (i=0; i<MATERIAL_MAX_TEXTURES; ++i)
|
||||
attr->addInt((prefix+core::stringc(i+1)).c_str(), material.TextureLayer[i].AnisotropicFilter);
|
||||
prefix="TextureWrapU";
|
||||
for (i=0; i<MATERIAL_MAX_TEXTURES; ++i)
|
||||
attr->addEnum((prefix+core::stringc(i+1)).c_str(), material.TextureLayer[i].TextureWrapU, aTextureClampNames);
|
||||
prefix="TextureWrapV";
|
||||
for (i=0; i<MATERIAL_MAX_TEXTURES; ++i)
|
||||
attr->addEnum((prefix+core::stringc(i+1)).c_str(), material.TextureLayer[i].TextureWrapV, aTextureClampNames);
|
||||
prefix="TextureWrapW";
|
||||
for (i=0; i<MATERIAL_MAX_TEXTURES; ++i)
|
||||
attr->addEnum((prefix+core::stringc(i+1)).c_str(), material.TextureLayer[i].TextureWrapW, aTextureClampNames);
|
||||
prefix="LODBias";
|
||||
for (i=0; i<MATERIAL_MAX_TEXTURES; ++i)
|
||||
attr->addInt((prefix+core::stringc(i+1)).c_str(), material.TextureLayer[i].LODBias);
|
||||
|
||||
return attr;
|
||||
}
|
||||
|
||||
|
||||
//! Fills an SMaterial structure from attributes.
|
||||
void CNullDriver::fillMaterialStructureFromAttributes(video::SMaterial& outMaterial, io::IAttributes* attr)
|
||||
{
|
||||
outMaterial.MaterialType = video::EMT_SOLID;
|
||||
|
||||
core::stringc name = attr->getAttributeAsString("Type");
|
||||
|
||||
u32 i;
|
||||
|
||||
for ( i=0; i < MaterialRenderers.size(); ++i)
|
||||
if ( name == MaterialRenderers[i].Name )
|
||||
{
|
||||
outMaterial.MaterialType = (video::E_MATERIAL_TYPE)i;
|
||||
break;
|
||||
}
|
||||
|
||||
outMaterial.AmbientColor = attr->getAttributeAsColor("Ambient", outMaterial.AmbientColor);
|
||||
outMaterial.DiffuseColor = attr->getAttributeAsColor("Diffuse", outMaterial.DiffuseColor);
|
||||
outMaterial.EmissiveColor = attr->getAttributeAsColor("Emissive", outMaterial.EmissiveColor);
|
||||
outMaterial.SpecularColor = attr->getAttributeAsColor("Specular", outMaterial.SpecularColor);
|
||||
|
||||
outMaterial.Shininess = attr->getAttributeAsFloat("Shininess", outMaterial.Shininess);
|
||||
outMaterial.MaterialTypeParam = attr->getAttributeAsFloat("Param1", outMaterial.MaterialTypeParam);
|
||||
outMaterial.MaterialTypeParam2 = attr->getAttributeAsFloat("Param2", outMaterial.MaterialTypeParam2);
|
||||
outMaterial.Thickness = attr->getAttributeAsFloat("Thickness", outMaterial.Thickness);
|
||||
|
||||
core::stringc prefix="Texture";
|
||||
for (i=0; i<MATERIAL_MAX_TEXTURES; ++i)
|
||||
outMaterial.setTexture(i, attr->getAttributeAsTexture((prefix+core::stringc(i+1)).c_str()));
|
||||
|
||||
outMaterial.Wireframe = attr->getAttributeAsBool("Wireframe", outMaterial.Wireframe);
|
||||
outMaterial.PointCloud = attr->getAttributeAsBool("PointCloud", outMaterial.PointCloud);
|
||||
outMaterial.GouraudShading = attr->getAttributeAsBool("GouraudShading", outMaterial.GouraudShading);
|
||||
outMaterial.Lighting = attr->getAttributeAsBool("Lighting", outMaterial.Lighting);
|
||||
|
||||
io::E_ATTRIBUTE_TYPE attType = attr->getAttributeType("ZWriteEnable");
|
||||
if (attType == io::EAT_BOOL ) // Before Irrlicht 1.9
|
||||
outMaterial.ZWriteEnable = attr->getAttributeAsBool("ZWriteEnable", outMaterial.ZWriteEnable != video::EZW_OFF ) ? video::EZW_AUTO : video::EZW_OFF;
|
||||
else if (attType == io::EAT_ENUM )
|
||||
outMaterial.ZWriteEnable = (video::E_ZWRITE)attr->getAttributeAsEnumeration("ZWriteEnable", video::ZWriteNames, outMaterial.ZWriteEnable);
|
||||
|
||||
outMaterial.ZBuffer = (u8)attr->getAttributeAsInt("ZBuffer", outMaterial.ZBuffer);
|
||||
outMaterial.BackfaceCulling = attr->getAttributeAsBool("BackfaceCulling", outMaterial.BackfaceCulling);
|
||||
outMaterial.FrontfaceCulling = attr->getAttributeAsBool("FrontfaceCulling", outMaterial.FrontfaceCulling);
|
||||
outMaterial.FogEnable = attr->getAttributeAsBool("FogEnable", outMaterial.FogEnable);
|
||||
outMaterial.NormalizeNormals = attr->getAttributeAsBool("NormalizeNormals", outMaterial.NormalizeNormals);
|
||||
outMaterial.UseMipMaps = attr->getAttributeAsBool("UseMipMaps", outMaterial.UseMipMaps);
|
||||
|
||||
outMaterial.AntiAliasing = attr->getAttributeAsInt("AntiAliasing", outMaterial.AntiAliasing);
|
||||
outMaterial.ColorMask = attr->getAttributeAsInt("ColorMask", outMaterial.ColorMask);
|
||||
outMaterial.ColorMaterial = attr->getAttributeAsInt("ColorMaterial", outMaterial.ColorMaterial);
|
||||
outMaterial.BlendOperation = (video::E_BLEND_OPERATION)attr->getAttributeAsInt("BlendOperation", outMaterial.BlendOperation);
|
||||
outMaterial.BlendFactor = attr->getAttributeAsFloat("BlendFactor", outMaterial.BlendFactor);
|
||||
outMaterial.PolygonOffsetFactor = attr->getAttributeAsInt("PolygonOffsetFactor", outMaterial.PolygonOffsetFactor);
|
||||
outMaterial.PolygonOffsetDirection = (video::E_POLYGON_OFFSET)attr->getAttributeAsEnumeration("PolygonOffsetDirection", video::PolygonOffsetDirectionNames, outMaterial.PolygonOffsetDirection);
|
||||
outMaterial.PolygonOffsetDepthBias = attr->getAttributeAsFloat("PolygonOffsetDepthBias", outMaterial.PolygonOffsetDepthBias);
|
||||
outMaterial.PolygonOffsetSlopeScale = attr->getAttributeAsFloat("PolygonOffsetSlopeScale", outMaterial.PolygonOffsetSlopeScale);
|
||||
|
||||
prefix = "BilinearFilter";
|
||||
if (attr->existsAttribute(prefix.c_str())) // legacy
|
||||
outMaterial.setFlag(EMF_BILINEAR_FILTER, attr->getAttributeAsBool(prefix.c_str()));
|
||||
else
|
||||
for (i=0; i<MATERIAL_MAX_TEXTURES; ++i)
|
||||
outMaterial.TextureLayer[i].BilinearFilter = attr->getAttributeAsBool((prefix+core::stringc(i+1)).c_str(), outMaterial.TextureLayer[i].BilinearFilter);
|
||||
|
||||
prefix = "TrilinearFilter";
|
||||
if (attr->existsAttribute(prefix.c_str())) // legacy
|
||||
outMaterial.setFlag(EMF_TRILINEAR_FILTER, attr->getAttributeAsBool(prefix.c_str()));
|
||||
else
|
||||
for (i=0; i<MATERIAL_MAX_TEXTURES; ++i)
|
||||
outMaterial.TextureLayer[i].TrilinearFilter = attr->getAttributeAsBool((prefix+core::stringc(i+1)).c_str(), outMaterial.TextureLayer[i].TrilinearFilter);
|
||||
|
||||
prefix = "AnisotropicFilter";
|
||||
if (attr->existsAttribute(prefix.c_str())) // legacy
|
||||
outMaterial.setFlag(EMF_ANISOTROPIC_FILTER, attr->getAttributeAsBool(prefix.c_str()));
|
||||
else
|
||||
for (i=0; i<MATERIAL_MAX_TEXTURES; ++i)
|
||||
outMaterial.TextureLayer[i].AnisotropicFilter = attr->getAttributeAsInt((prefix+core::stringc(i+1)).c_str(), outMaterial.TextureLayer[i].AnisotropicFilter);
|
||||
|
||||
prefix = "TextureWrap";
|
||||
if (attr->existsAttribute(prefix.c_str())) // legacy
|
||||
{
|
||||
for (i=0; i<MATERIAL_MAX_TEXTURES; ++i)
|
||||
{
|
||||
outMaterial.TextureLayer[i].TextureWrapU = (E_TEXTURE_CLAMP)attr->getAttributeAsEnumeration((prefix+core::stringc(i+1)).c_str(), aTextureClampNames);
|
||||
outMaterial.TextureLayer[i].TextureWrapV = outMaterial.TextureLayer[i].TextureWrapU;
|
||||
outMaterial.TextureLayer[i].TextureWrapW = outMaterial.TextureLayer[i].TextureWrapW;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i=0; i<MATERIAL_MAX_TEXTURES; ++i)
|
||||
{
|
||||
outMaterial.TextureLayer[i].TextureWrapU = (E_TEXTURE_CLAMP)attr->getAttributeAsEnumeration((prefix+"U"+core::stringc(i+1)).c_str(), aTextureClampNames, outMaterial.TextureLayer[i].TextureWrapU);
|
||||
outMaterial.TextureLayer[i].TextureWrapV = (E_TEXTURE_CLAMP)attr->getAttributeAsEnumeration((prefix+"V"+core::stringc(i+1)).c_str(), aTextureClampNames, outMaterial.TextureLayer[i].TextureWrapV);
|
||||
outMaterial.TextureLayer[i].TextureWrapW = (E_TEXTURE_CLAMP)attr->getAttributeAsEnumeration((prefix+"W"+core::stringc(i+1)).c_str(), aTextureClampNames, outMaterial.TextureLayer[i].TextureWrapW);
|
||||
}
|
||||
}
|
||||
|
||||
prefix="LODBias";
|
||||
for (i=0; i<MATERIAL_MAX_TEXTURES; ++i)
|
||||
outMaterial.TextureLayer[i].LODBias = attr->getAttributeAsInt((prefix+core::stringc(i+1)).c_str(), outMaterial.TextureLayer[i].LODBias);
|
||||
}
|
||||
|
||||
|
||||
//! Returns driver and operating system specific data about the IVideoDriver.
|
||||
const SExposedVideoData& CNullDriver::getExposedVideoData()
|
||||
|
@ -335,6 +335,10 @@ namespace video
|
||||
virtual void makeColorKeyTexture(video::ITexture* texture, core::position2d<s32> colorKeyPixelPos,
|
||||
bool zeroTexels) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Creates a normal map from a height map texture.
|
||||
//! \param amplitude: Constant value by which the height information is multiplied.
|
||||
virtual void makeNormalMapTexture(video::ITexture* texture, f32 amplitude=1.0f) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Returns the maximum amount of primitives (mostly vertices) which
|
||||
//! the device is able to render with one drawIndexedTriangleList
|
||||
//! call.
|
||||
@ -617,6 +621,13 @@ namespace video
|
||||
//! Swap the material renderers used for certain id's
|
||||
virtual void swapMaterialRenderers(u32 idx1, u32 idx2, bool swapNames) _IRR_OVERRIDE_;
|
||||
|
||||
//! Creates material attributes list from a material, usable for serialization and more.
|
||||
virtual io::IAttributes* createAttributesFromMaterial(const video::SMaterial& material,
|
||||
io::SAttributeReadWriteOptions* options=0) _IRR_OVERRIDE_;
|
||||
|
||||
//! Fills an SMaterial structure from attributes.
|
||||
virtual void fillMaterialStructureFromAttributes(video::SMaterial& outMaterial, io::IAttributes* attributes) _IRR_OVERRIDE_;
|
||||
|
||||
//! looks if the image is already loaded
|
||||
virtual video::ITexture* findTexture(const io::path& filename) _IRR_OVERRIDE_;
|
||||
|
||||
@ -709,6 +720,35 @@ namespace video
|
||||
// prints renderer version
|
||||
void printVersion();
|
||||
|
||||
//! normal map lookup 32 bit version
|
||||
inline f32 nml32(int x, int y, int pitch, int height, s32 *p) const
|
||||
{
|
||||
if (x < 0)
|
||||
x = pitch-1;
|
||||
if (x >= pitch)
|
||||
x = 0;
|
||||
if (y < 0)
|
||||
y = height-1;
|
||||
if (y >= height)
|
||||
y = 0;
|
||||
return (f32)(((p[(y * pitch) + x])>>16) & 0xff);
|
||||
}
|
||||
|
||||
//! normal map lookup 16 bit version
|
||||
inline f32 nml16(int x, int y, int pitch, int height, s16 *p) const
|
||||
{
|
||||
if (x < 0)
|
||||
x = pitch-1;
|
||||
if (x >= pitch)
|
||||
x = 0;
|
||||
if (y < 0)
|
||||
y = height-1;
|
||||
if (y >= height)
|
||||
y = 0;
|
||||
|
||||
return (f32) getAverage ( p[(y * pitch) + x] );
|
||||
}
|
||||
|
||||
inline bool getWriteZBuffer(const SMaterial& material) const
|
||||
{
|
||||
switch ( material.ZWriteEnable )
|
||||
|
@ -26,6 +26,8 @@ namespace scene
|
||||
#define _IRR_DEBUG_OBJ_LOADER_
|
||||
#endif
|
||||
|
||||
static const u32 WORD_BUFFER_LENGTH = 512;
|
||||
|
||||
//! Constructor
|
||||
COBJMeshFileLoader::COBJMeshFileLoader(scene::ISceneManager* smgr, io::IFileSystem* fs)
|
||||
: SceneManager(smgr), FileSystem(fs)
|
||||
@ -316,7 +318,16 @@ IAnimatedMesh* COBJMeshFileLoader::createMesh(io::IReadFile* file)
|
||||
Materials[m]->Meshbuffer->recalculateBoundingBox();
|
||||
if (Materials[m]->RecalculateNormals)
|
||||
SceneManager->getMeshManipulator()->recalculateNormals(Materials[m]->Meshbuffer);
|
||||
mesh->addMeshBuffer( Materials[m]->Meshbuffer );
|
||||
if (Materials[m]->Meshbuffer->Material.MaterialType == video::EMT_PARALLAX_MAP_SOLID)
|
||||
{
|
||||
SMesh tmp;
|
||||
tmp.addMeshBuffer(Materials[m]->Meshbuffer);
|
||||
IMesh* tangentMesh = SceneManager->getMeshManipulator()->createMeshWithTangents(&tmp);
|
||||
mesh->addMeshBuffer(tangentMesh->getMeshBuffer(0));
|
||||
tangentMesh->drop();
|
||||
}
|
||||
else
|
||||
mesh->addMeshBuffer( Materials[m]->Meshbuffer );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,8 @@
|
||||
|
||||
#include "COGLES2MaterialRenderer.h"
|
||||
#include "COGLES2FixedPipelineRenderer.h"
|
||||
#include "COGLES2NormalMapRenderer.h"
|
||||
#include "COGLES2ParallaxMapRenderer.h"
|
||||
#include "COGLES2Renderer2D.h"
|
||||
|
||||
#include "EVertexAttributes.h"
|
||||
@ -246,6 +248,12 @@ COGLES2Driver::~COGLES2Driver()
|
||||
COGLES2MaterialSolidCB* TransparentAlphaChannelRefCB = new COGLES2MaterialSolidCB();
|
||||
COGLES2MaterialSolidCB* TransparentVertexAlphaCB = new COGLES2MaterialSolidCB();
|
||||
COGLES2MaterialReflectionCB* TransparentReflection2LayerCB = new COGLES2MaterialReflectionCB();
|
||||
COGLES2MaterialNormalMapCB* NormalMapCB = new COGLES2MaterialNormalMapCB();
|
||||
COGLES2MaterialNormalMapCB* NormalMapAddColorCB = new COGLES2MaterialNormalMapCB();
|
||||
COGLES2MaterialNormalMapCB* NormalMapVertexAlphaCB = new COGLES2MaterialNormalMapCB();
|
||||
COGLES2MaterialParallaxMapCB* ParallaxMapCB = new COGLES2MaterialParallaxMapCB();
|
||||
COGLES2MaterialParallaxMapCB* ParallaxMapAddColorCB = new COGLES2MaterialParallaxMapCB();
|
||||
COGLES2MaterialParallaxMapCB* ParallaxMapVertexAlphaCB = new COGLES2MaterialParallaxMapCB();
|
||||
COGLES2MaterialOneTextureBlendCB* OneTextureBlendCB = new COGLES2MaterialOneTextureBlendCB();
|
||||
|
||||
// Create built-in materials.
|
||||
@ -334,6 +342,30 @@ COGLES2Driver::~COGLES2Driver()
|
||||
addHighLevelShaderMaterialFromFiles(VertexShader, "main", EVST_VS_2_0, FragmentShader, "main", EPST_PS_2_0, "", "main",
|
||||
EGST_GS_4_0, scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0, TransparentReflection2LayerCB, EMT_TRANSPARENT_ALPHA_CHANNEL, 0);
|
||||
|
||||
VertexShader = OGLES2ShaderPath + "COGLES2NormalMap.vsh";
|
||||
FragmentShader = OGLES2ShaderPath + "COGLES2NormalMap.fsh";
|
||||
|
||||
addHighLevelShaderMaterialFromFiles(VertexShader, "main", EVST_VS_2_0, FragmentShader, "main", EPST_PS_2_0, "", "main",
|
||||
EGST_GS_4_0, scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0, NormalMapCB, EMT_SOLID, 0);
|
||||
|
||||
addHighLevelShaderMaterialFromFiles(VertexShader, "main", EVST_VS_2_0, FragmentShader, "main", EPST_PS_2_0, "", "main",
|
||||
EGST_GS_4_0, scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0, NormalMapAddColorCB, EMT_TRANSPARENT_ADD_COLOR, 0);
|
||||
|
||||
addHighLevelShaderMaterialFromFiles(VertexShader, "main", EVST_VS_2_0, FragmentShader, "main", EPST_PS_2_0, "", "main",
|
||||
EGST_GS_4_0, scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0, NormalMapVertexAlphaCB, EMT_TRANSPARENT_ALPHA_CHANNEL, 0);
|
||||
|
||||
VertexShader = OGLES2ShaderPath + "COGLES2ParallaxMap.vsh";
|
||||
FragmentShader = OGLES2ShaderPath + "COGLES2ParallaxMap.fsh";
|
||||
|
||||
addHighLevelShaderMaterialFromFiles(VertexShader, "main", EVST_VS_2_0, FragmentShader, "main", EPST_PS_2_0, "", "main",
|
||||
EGST_GS_4_0, scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0, ParallaxMapCB, EMT_SOLID, 0);
|
||||
|
||||
addHighLevelShaderMaterialFromFiles(VertexShader, "main", EVST_VS_2_0, FragmentShader, "main", EPST_PS_2_0, "", "main",
|
||||
EGST_GS_4_0, scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0, ParallaxMapAddColorCB, EMT_TRANSPARENT_ADD_COLOR, 0);
|
||||
|
||||
addHighLevelShaderMaterialFromFiles(VertexShader, "main", EVST_VS_2_0, FragmentShader, "main", EPST_PS_2_0, "", "main",
|
||||
EGST_GS_4_0, scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0, ParallaxMapVertexAlphaCB, EMT_TRANSPARENT_ALPHA_CHANNEL, 0);
|
||||
|
||||
VertexShader = OGLES2ShaderPath + "COGLES2Solid.vsh";
|
||||
FragmentShader = OGLES2ShaderPath + "COGLES2OneTextureBlend.fsh";
|
||||
|
||||
@ -359,6 +391,12 @@ COGLES2Driver::~COGLES2Driver()
|
||||
TransparentAlphaChannelRefCB->drop();
|
||||
TransparentVertexAlphaCB->drop();
|
||||
TransparentReflection2LayerCB->drop();
|
||||
NormalMapCB->drop();
|
||||
NormalMapAddColorCB->drop();
|
||||
NormalMapVertexAlphaCB->drop();
|
||||
ParallaxMapCB->drop();
|
||||
ParallaxMapAddColorCB->drop();
|
||||
ParallaxMapVertexAlphaCB->drop();
|
||||
OneTextureBlendCB->drop();
|
||||
|
||||
// Create 2D material renderers
|
||||
|
@ -37,6 +37,8 @@ namespace video
|
||||
{
|
||||
|
||||
class COGLES2FixedPipelineRenderer;
|
||||
class COGLES2NormalMapRenderer;
|
||||
class COGLES2ParallaxMapRenderer;
|
||||
class COGLES2Renderer2D;
|
||||
|
||||
class COGLES2Driver : public CNullDriver, public IMaterialRendererServices, public COGLES2ExtensionHandler
|
||||
|
@ -47,6 +47,7 @@ namespace video
|
||||
glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, DimAliasedPoint);
|
||||
|
||||
Feature.MaxTextureUnits = core::min_(Feature.MaxTextureUnits, static_cast<u8>(MATERIAL_MAX_TEXTURES));
|
||||
Feature.MaxTextureUnits = core::min_(Feature.MaxTextureUnits, static_cast<u8>(MATERIAL_MAX_TEXTURES_USED));
|
||||
Feature.ColorAttachment = 1;
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user