2019-12-12 17:32:41 +01:00
|
|
|
// 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
|
|
|
|
|
2021-08-27 17:55:04 +02:00
|
|
|
#ifndef IRR_C_TEXT_SCENE_NODE_H_INCLUDED
|
|
|
|
#define IRR_C_TEXT_SCENE_NODE_H_INCLUDED
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
#include "ITextSceneNode.h"
|
|
|
|
#include "IBillboardTextSceneNode.h"
|
|
|
|
#include "IGUIFont.h"
|
|
|
|
#include "IGUIFontBitmap.h"
|
|
|
|
#include "ISceneCollisionManager.h"
|
|
|
|
#include "SMesh.h"
|
|
|
|
|
|
|
|
namespace irr
|
|
|
|
{
|
|
|
|
namespace scene
|
|
|
|
{
|
|
|
|
|
|
|
|
class ICameraSceneNode;
|
|
|
|
|
|
|
|
class CTextSceneNode : public ITextSceneNode
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
//! constructor
|
|
|
|
CTextSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id,
|
|
|
|
gui::IGUIFont* font, scene::ISceneCollisionManager* coll,
|
|
|
|
const core::vector3df& position = core::vector3df(0,0,0), const wchar_t* text=0,
|
|
|
|
video::SColor color=video::SColor(100,0,0,0));
|
|
|
|
|
|
|
|
//! destructor
|
|
|
|
virtual ~CTextSceneNode();
|
|
|
|
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void OnRegisterSceneNode() IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! renders the node.
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void render() IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! returns the axis aligned bounding box of this node
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual const core::aabbox3d<f32>& getBoundingBox() const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! sets the text string
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setText(const wchar_t* text) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! get the text string
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual const wchar_t* getText() const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! sets the color of the text
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setTextColor(video::SColor color) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! get the color of the text
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual video::SColor getTextColor() const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! set the font used to draw the text
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setFont(gui::IGUIFont* font) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Get the font used to draw the text
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual gui::IGUIFont* getFont() const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Returns type of the scene node
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual ESCENE_NODE_TYPE getType() const IRR_OVERRIDE { return ESNT_TEXT; }
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
core::stringw Text;
|
|
|
|
video::SColor Color;
|
|
|
|
gui::IGUIFont* Font;
|
|
|
|
scene::ISceneCollisionManager* Coll;
|
|
|
|
core::aabbox3d<f32> Box;
|
|
|
|
};
|
|
|
|
|
|
|
|
class CBillboardTextSceneNode : public IBillboardTextSceneNode
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
CBillboardTextSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id,
|
|
|
|
gui::IGUIFont* font,const wchar_t* text,
|
|
|
|
const core::vector3df& position, const core::dimension2d<f32>& size,
|
|
|
|
video::SColor colorTop, video::SColor shade_bottom);
|
|
|
|
|
|
|
|
//! destructor
|
|
|
|
virtual ~CBillboardTextSceneNode();
|
|
|
|
|
|
|
|
//! sets the vertex positions etc
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void OnAnimate(u32 timeMs) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! registers the node into the transparent pass
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void OnRegisterSceneNode() IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! renders the node.
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void render() IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! returns the axis aligned bounding box of this node
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual const core::aabbox3d<f32>& getBoundingBox() const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! sets the text string
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setText(const wchar_t* text) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! get the text string
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual const wchar_t* getText() const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Get the font used to draw the text
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual gui::IGUIFont* getFont() const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! sets the size of the billboard
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setSize(const core::dimension2d<f32>& size) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! gets the size of the billboard
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual const core::dimension2d<f32>& getSize() const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual video::SMaterial& getMaterial(u32 i) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! returns amount of materials used by this scene node.
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual u32 getMaterialCount() const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Returns type of the scene node
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual ESCENE_NODE_TYPE getType() const IRR_OVERRIDE { return ESNT_BILLBOARD_TEXT; }
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Set the color of all vertices of the billboard
|
|
|
|
//! \param overallColor: the color to set
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setColor(const video::SColor & overallColor) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Set the color of the top and bottom vertices of the billboard
|
|
|
|
//! \param topColor: the color to set the top vertices
|
|
|
|
//! \param bottomColor: the color to set the bottom vertices
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setColor(const video::SColor & topColor, const video::SColor & bottomColor) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Gets the color of the top and bottom vertices of the billboard
|
|
|
|
//! \param topColor: stores the color of the top vertices
|
|
|
|
//! \param bottomColor: stores the color of the bottom vertices
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void getColor(video::SColor & topColor, video::SColor & bottomColor) const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setSize(f32 height, f32 bottomEdgeWidth, f32 topEdgeWidth) IRR_OVERRIDE
|
2019-12-12 17:32:41 +01:00
|
|
|
{
|
|
|
|
setSize(core::dimension2df(bottomEdgeWidth, height));
|
|
|
|
}
|
|
|
|
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void getSize(f32& height, f32& bottomEdgeWidth, f32& topEdgeWidth) const IRR_OVERRIDE
|
2019-12-12 17:32:41 +01:00
|
|
|
{
|
|
|
|
height = Size.Height;
|
|
|
|
bottomEdgeWidth = Size.Width;
|
|
|
|
topEdgeWidth = Size.Width;
|
|
|
|
}
|
|
|
|
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual const core::aabbox3d<f32>& getTransformedBillboardBoundingBox(const irr::scene::ICameraSceneNode* camera) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
2022-02-08 22:00:12 +01:00
|
|
|
//! Get the amount of mesh buffers.
|
2022-04-12 23:58:35 +02:00
|
|
|
virtual u32 getMeshBufferCount() const IRR_OVERRIDE
|
2022-02-08 22:00:12 +01:00
|
|
|
{
|
|
|
|
return Mesh ? Mesh->getMeshBufferCount() : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//! Get pointer to the mesh buffer.
|
2022-04-12 23:58:35 +02:00
|
|
|
virtual IMeshBuffer* getMeshBuffer(u32 nr) const IRR_OVERRIDE
|
2022-02-08 22:00:12 +01:00
|
|
|
{
|
|
|
|
return Mesh ? Mesh->getMeshBuffer(nr) : 0;
|
|
|
|
}
|
|
|
|
|
2019-12-12 17:32:41 +01:00
|
|
|
protected:
|
|
|
|
void updateMesh(const irr::scene::ICameraSceneNode* camera);
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
core::stringw Text;
|
|
|
|
gui::IGUIFontBitmap* Font;
|
|
|
|
|
|
|
|
core::dimension2d<f32> Size;
|
|
|
|
core::aabbox3d<f32> BBox;
|
|
|
|
video::SMaterial Material;
|
|
|
|
|
|
|
|
video::SColor ColorTop;
|
|
|
|
video::SColor ColorBottom;
|
|
|
|
struct SSymbolInfo
|
|
|
|
{
|
|
|
|
u32 bufNo;
|
|
|
|
f32 Width;
|
|
|
|
f32 Kerning;
|
|
|
|
u32 firstInd;
|
|
|
|
u32 firstVert;
|
|
|
|
};
|
|
|
|
|
|
|
|
core::array < SSymbolInfo > Symbol;
|
|
|
|
|
|
|
|
SMesh *Mesh;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace scene
|
|
|
|
} // end namespace irr
|
|
|
|
|
|
|
|
#endif
|