Commit ca0a9cca authored by hybrid's avatar hybrid

Change new billboard API to use more common names and a better usable...

Change new billboard API to use more common names and a better usable interface. Fixed documentation. Proposal for fix made by greenya.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3995 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 025fd696
......@@ -29,11 +29,12 @@ public:
//! Sets the size of the billboard, making it rectangular.
virtual void setSize(const core::dimension2d<f32>& size) = 0;
//! Sets the widths of the bottom and top edges of the billboard independently.
/** \param[in] startEdgeWidth The width of the start (bottom) edge of the billboard.
\param[in] endEdgeWidth The width of the end (top) edge of the billboard.
//! Sets the size of the billboard with independent widths of the bottom and top edges.
/** \param[in] height The height of the billboard.
\param[in] bottomEdgeWidth The width of the bottom edge of the billboard.
\param[in] topEdgeWidth The width of the top edge of the billboard.
*/
virtual void setWidths(f32 startEdgeWidth, f32 endEdgeWidth) = 0;
virtual void setSize(f32 height, f32 bottomEdgeWidth, f32 topEdgeWidth) = 0;
//! Returns the size of the billboard.
/** This will return the width of the bottom edge of the billboard.
......@@ -42,11 +43,12 @@ public:
*/
virtual const core::dimension2d<f32>& getSize() const = 0;
//! Gets the widths of the top and bottom edges of the billboard.
/** \param[out] startEdgeWidth The width of the start (bottom) edge of the billboard.
\param[out] endEdgeWidth The width of the end (top) edge of the billboard.
//! Gets the size of the the billboard and handles independent top and bottom edge widths correctly.
/** \param[out] height The height of the billboard.
\param[out] bottomEdgeWidth The width of the bottom edge of the billboard.
\param[out] topEdgeWidth The width of the top edge of the billboard.
*/
virtual void getWidths(f32& startEdgeWidth, f32& endEdgeWidth) const =0;
virtual void getSize(f32& height, f32& bottomEdgeWidth, f32& topEdgeWidth) const =0;
//! Set the color of all vertices of the billboard
/** \param[in] overallColor Color to set */
......
......@@ -152,16 +152,19 @@ void CBillboardSceneNode::setSize(const core::dimension2d<f32>& size)
}
void CBillboardSceneNode::setWidths(f32 bottomEdgeWidth, f32 topEdgeWidth)
void CBillboardSceneNode::setSize(f32 height, f32 bottomEdgeWidth, f32 topEdgeWidth)
{
Size.Width = bottomEdgeWidth;
Size.set(bottomEdgeWidth, height);
TopEdgeWidth = topEdgeWidth;
if (core::equals(Size.Width, 0.f))
Size.Width = 1.0f;
if (core::equals(Size.Height, 0.0f))
Size.Height = 1.0f;
if (core::equals(TopEdgeWidth, 0.f))
if (core::equals(Size.Width, 0.f) && core::equals(TopEdgeWidth, 0.f))
{
Size.Width = 1.0f;
TopEdgeWidth = 1.0f;
}
const f32 avg = (core::max_(Size.Width,TopEdgeWidth) + Size.Height)/6;
BBox.MinEdge.set(-avg,-avg,-avg);
......@@ -190,9 +193,10 @@ const core::dimension2d<f32>& CBillboardSceneNode::getSize() const
//! Gets the widths of the top and bottom edges of the billboard.
void CBillboardSceneNode::getWidths(f32& bottomEdgeWidth,
void CBillboardSceneNode::getSize(f32& height, f32& bottomEdgeWidth,
f32& topEdgeWidth) const
{
height = Size.Height;
bottomEdgeWidth = Size.Width;
topEdgeWidth = TopEdgeWidth;
}
......@@ -206,8 +210,8 @@ void CBillboardSceneNode::serializeAttributes(io::IAttributes* out, io::SAttribu
out->addFloat("Width", Size.Width);
out->addFloat("TopEdgeWidth", TopEdgeWidth);
out->addFloat("Height", Size.Height);
out->addColor ("Shade_Top", vertices[1].Color );
out->addColor ("Shade_Down", vertices[0].Color );
out->addColor("Shade_Top", vertices[1].Color);
out->addColor("Shade_Down", vertices[0].Color);
}
......@@ -219,13 +223,14 @@ void CBillboardSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttrib
Size.Width = in->getAttributeAsFloat("Width");
Size.Height = in->getAttributeAsFloat("Height");
setSize(Size);
if (in->existsAttribute("TopEdgeWidth"))
{
TopEdgeWidth = in->getAttributeAsFloat("TopEdgeWidth");
if (Size.Width != TopEdgeWidth)
setWidths(Size.Width, TopEdgeWidth);
setSize(Size.Height, Size.Width, TopEdgeWidth);
}
else
setSize(Size);
vertices[1].Color = in->getAttributeAsColor("Shade_Top");
vertices[0].Color = in->getAttributeAsColor("Shade_Down");
vertices[2].Color = vertices[1].Color;
......
......@@ -38,13 +38,13 @@ public:
virtual void setSize(const core::dimension2d<f32>& size);
//! Sets the widths of the top and bottom edges of the billboard independently.
virtual void setWidths(f32 bottomEdgeWidth, f32 topEdgeWidth);
virtual void setSize(f32 height, f32 bottomEdgeWidth, f32 topEdgeWidth);
//! gets the size of the billboard
virtual const core::dimension2d<f32>& getSize() const;
//! Gets the widths of the top and bottom edges of the billboard.
virtual void getWidths(f32& bottomEdgeWidth, f32& topEdgeWidth) const;
virtual void getSize(f32& height, f32& bottomEdgeWidth, f32& topEdgeWidth) const;
virtual video::SMaterial& getMaterial(u32 i);
......
......@@ -115,13 +115,14 @@ namespace scene
//! \param bottomColor: stores the color of the bottom vertices
virtual void getColor(video::SColor & topColor, video::SColor & bottomColor) const;
virtual void setWidths(f32 bottomEdgeWidth, f32 topEdgeWidth)
virtual void setSize(f32 height, f32 bottomEdgeWidth, f32 topEdgeWidth)
{
setSize(core::dimension2df(bottomEdgeWidth, Size.Height));
setSize(core::dimension2df(bottomEdgeWidth, height));
}
virtual void getWidths(f32& bottomEdgeWidth, f32& topEdgeWidth) const
virtual void getSize(f32& height, f32& bottomEdgeWidth, f32& topEdgeWidth) const
{
height = Size.Height;
bottomEdgeWidth = Size.Width;
topEdgeWidth = Size.Width;
}
......
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