Commit e96027cb authored by Rogerborg's avatar Rogerborg

Have CBillboardTextSceneNode use the default GUI font if no font is specified....

Have CBillboardTextSceneNode use the default GUI font if no font is specified.  Also rename "shade_top"/"shade_down" to colorTop / colorBottom (and similarly for other "shade" parameters and members) in *BillboardSceneNode, *SceneManager and *TextSceneNode.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1798 dfc29bdd-3216-0410-991c-e03cc46cb475
parent f2066bde
......@@ -624,14 +624,14 @@ namespace scene
\param size: Size of the billboard. This size is 2 dimensional because a billboard only has
width and height.
\param id: An id of the node. This id can be used to identify the node.
\param shade_top: vertex color top
\param shade_down: vertex color down
\param colorTop: The color of the vertices at the top of the billboard (default: white).
\param colorBottom: The color of the vertices at the bottom of the billboard (default: white).
\return Returns pointer to the billboard if successful, otherwise NULL.
This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
virtual IBillboardSceneNode* addBillboardSceneNode(ISceneNode* parent = 0,
const core::dimension2d<f32>& size = core::dimension2d<f32>(10.0f, 10.0f),
const core::vector3df& position = core::vector3df(0,0,0), s32 id=-1,
video::SColor shade_top = 0xFFFFFFFF, video::SColor shade_down = 0xFFFFFFFF) = 0;
video::SColor colorTop = 0xFFFFFFFF, video::SColor colorBottom = 0xFFFFFFFF) = 0;
//! Adds a skybox scene node to the scene graph.
/** A skybox is a big cube with 6 textures on it and
......@@ -828,12 +828,22 @@ namespace scene
ISceneNode* parent = 0, const core::vector3df& position = core::vector3df(0,0,0),
s32 id=-1) = 0;
//! Adds a text scene node, which uses billboards
//! Adds a text scene node, which uses billboards. The node, and the text on it, will scale with distance.
/**
\param font The font to use on the billboard. Pass 0 to use the GUI environment's default font.
\param text The text to display on the billboard.
\param parent The billboard's parent. Pass 0 to use the root scene node.
\param size The billboard's width and height.
\param position The billboards position relative to its parent.
\param colorTop: The color of the vertices at the top of the billboard (default: white).
\param colorBottom: The color of the vertices at the bottom of the billboard (default: white).
\return Returns pointer to the billboard if successful, otherwise NULL.
This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
virtual IBillboardTextSceneNode* addBillboardTextSceneNode( gui::IGUIFont* font, const wchar_t* text,
ISceneNode* parent = 0,
const core::dimension2d<f32>& size = core::dimension2d<f32>(10.0f, 10.0f),
const core::vector3df& position = core::vector3df(0,0,0), s32 id=-1,
video::SColor shade_top = 0xFFFFFFFF, video::SColor shade_down = 0xFFFFFFFF) = 0;
video::SColor colorTop = 0xFFFFFFFF, video::SColor colorBottom = 0xFFFFFFFF) = 0;
//! Adds a Hill Plane mesh to the mesh pool.
/** The mesh is generated on the fly
......
......@@ -16,7 +16,7 @@ namespace scene
//! constructor
CBillboardSceneNode::CBillboardSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id,
const core::vector3df& position, const core::dimension2d<f32>& size,
video::SColor shade_top, video::SColor shade_down)
video::SColor colorTop, video::SColor colorBottom)
: IBillboardSceneNode(parent, mgr, id, position)
{
#ifdef _DEBUG
......@@ -33,16 +33,16 @@ CBillboardSceneNode::CBillboardSceneNode(ISceneNode* parent, ISceneManager* mgr,
indices[5] = 2;
vertices[0].TCoords.set(1.0f, 1.0f);
vertices[0].Color = shade_down;
vertices[0].Color = colorBottom;
vertices[1].TCoords.set(1.0f, 0.0f);
vertices[1].Color = shade_top;
vertices[1].Color = colorTop;
vertices[2].TCoords.set(0.0f, 0.0f);
vertices[2].Color = shade_top;
vertices[2].Color = colorTop;
vertices[3].TCoords.set(0.0f, 1.0f);
vertices[3].Color = shade_down;
vertices[3].Color = colorBottom;
}
......
......@@ -22,7 +22,7 @@ public:
//! constructor
CBillboardSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id,
const core::vector3df& position, const core::dimension2d<f32>& size,
video::SColor shade_top=video::SColor(0xFFFFFFFF),video::SColor shade_down=video::SColor(0xFFFFFFFF));
video::SColor colorTop=video::SColor(0xFFFFFFFF),video::SColor colorBottom=video::SColor(0xFFFFFFFF));
//! pre render event
virtual void OnRegisterSceneNode();
......
......@@ -429,16 +429,19 @@ IBillboardTextSceneNode* CSceneManager::addBillboardTextSceneNode(gui::IGUIFont*
const wchar_t* text, ISceneNode* parent,
const core::dimension2d<f32>& size,
const core::vector3df& position, s32 id,
video::SColor shade_top, video::SColor shade_down)
video::SColor colorTop, video::SColor colorBottom)
{
if (!font)
if (!font && GUIEnvironment)
font = GUIEnvironment->getBuiltInFont();
if(!font)
return 0;
if (!parent)
parent = this;
IBillboardTextSceneNode* node = new CBillboardTextSceneNode(parent, this, id, font, text, position, size,
shade_top, shade_down);
colorTop, colorBottom);
node->drop();
return node;
......@@ -702,14 +705,14 @@ ILightSceneNode* CSceneManager::addLightSceneNode(ISceneNode* parent,
//! lensflares and things like that.
IBillboardSceneNode* CSceneManager::addBillboardSceneNode(ISceneNode* parent,
const core::dimension2d<f32>& size, const core::vector3df& position, s32 id,
video::SColor shade_top, video::SColor shade_down
video::SColor colorTop, video::SColor colorBottom
)
{
if (!parent)
parent = this;
IBillboardSceneNode* node = new CBillboardSceneNode(parent, this, id, position, size,
shade_top, shade_down);
colorTop, colorBottom);
node->drop();
return node;
......
......@@ -156,7 +156,7 @@ namespace scene
virtual IBillboardSceneNode* addBillboardSceneNode(ISceneNode* parent = 0,
const core::dimension2d<f32>& size = core::dimension2d<f32>(10.0f, 10.0f),
const core::vector3df& position = core::vector3df(0,0,0), s32 id=-1,
video::SColor shade_top = 0xFFFFFFFF, video::SColor shade_down = 0xFFFFFFFF);
video::SColor shadeTop = 0xFFFFFFFF, video::SColor shadeBottom = 0xFFFFFFFF);
//! Adds a skybox scene node. A skybox is a big cube with 6 textures on it and
//! is drawn around the camera position.
......@@ -182,7 +182,7 @@ namespace scene
ISceneNode* parent = 0,
const core::dimension2d<f32>& size = core::dimension2d<f32>(10.0f, 10.0f),
const core::vector3df& position = core::vector3df(0,0,0), s32 id=-1,
video::SColor shade_top = 0xFFFFFFFF, video::SColor shade_down = 0xFFFFFFFF);
video::SColor colorTop = 0xFFFFFFFF, video::SColor colorBottom = 0xFFFFFFFF);
//! Adds a scene node, which can render a quake3 shader
virtual ISceneNode* addQuake3SceneNode(IMeshBuffer* meshBuffer, const quake3::SShader * shader,
......
......@@ -92,9 +92,9 @@ void CTextSceneNode::setTextColor(video::SColor color)
CBillboardTextSceneNode::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 shade_top,video::SColor shade_bottom )
video::SColor colorTop,video::SColor shade_bottom )
: IBillboardTextSceneNode(parent, mgr, id, position),
Font(0), Shade_top(shade_top), Shade_bottom(shade_bottom), Mesh(0)
Font(0), ColorTop(colorTop), ColorBottom(shade_bottom), Mesh(0)
{
#ifdef _DEBUG
setDebugName("CBillboardTextSceneNode");
......@@ -205,10 +205,10 @@ void CBillboardTextSceneNode::setText(const wchar_t* text)
buf->Vertices[firstVert+2].TCoords.set(tex[3], tex[2]);
buf->Vertices[firstVert+3].TCoords.set(tex[3], tex[1]);
buf->Vertices[firstVert+0].Color = Shade_bottom;
buf->Vertices[firstVert+3].Color = Shade_bottom;
buf->Vertices[firstVert+1].Color = Shade_top;
buf->Vertices[firstVert+2].Color = Shade_top;
buf->Vertices[firstVert+0].Color = ColorBottom;
buf->Vertices[firstVert+3].Color = ColorBottom;
buf->Vertices[firstVert+1].Color = ColorTop;
buf->Vertices[firstVert+2].Color = ColorTop;
buf->Indices[firstInd+0] = firstVert+0;
buf->Indices[firstInd+1] = firstVert+2;
......@@ -425,16 +425,16 @@ void CBillboardTextSceneNode::setColor(const video::SColor & overallColor)
//! \param bottomColor: the color to set the bottom vertices
void CBillboardTextSceneNode::setColor(const video::SColor & topColor, const video::SColor & bottomColor)
{
Shade_bottom = bottomColor;
Shade_top = topColor;
ColorBottom = bottomColor;
ColorTop = topColor;
for ( u32 i = 0; i != Text.size (); ++i )
{
const SSymbolInfo &info = Symbol[i];
SMeshBuffer* buf = (SMeshBuffer*)Mesh->getMeshBuffer(info.bufNo);
buf->Vertices[info.firstVert+0].Color = Shade_bottom;
buf->Vertices[info.firstVert+3].Color = Shade_bottom;
buf->Vertices[info.firstVert+1].Color = Shade_top;
buf->Vertices[info.firstVert+2].Color = Shade_top;
buf->Vertices[info.firstVert+0].Color = ColorBottom;
buf->Vertices[info.firstVert+3].Color = ColorBottom;
buf->Vertices[info.firstVert+1].Color = ColorTop;
buf->Vertices[info.firstVert+2].Color = ColorTop;
}
}
......@@ -444,8 +444,8 @@ void CBillboardTextSceneNode::setColor(const video::SColor & topColor, const vid
//! \param bottomColor: stores the color of the bottom vertices
void CBillboardTextSceneNode::getColor(video::SColor & topColor, video::SColor & bottomColor) const
{
topColor = Shade_top;
bottomColor = Shade_bottom;
topColor = ColorTop;
bottomColor = ColorBottom;
}
......
......@@ -64,7 +64,7 @@ namespace scene
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 shade_top, video::SColor shade_bottom);
video::SColor colorTop, video::SColor shade_bottom);
//! destructor
virtual ~CBillboardTextSceneNode();
......@@ -121,8 +121,8 @@ namespace scene
core::aabbox3d<f32> BBox;
video::SMaterial Material;
video::SColor Shade_top;
video::SColor Shade_bottom;
video::SColor ColorTop;
video::SColor ColorBottom;
struct SSymbolInfo
{
u32 bufNo;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment