1 // Copyright (C) 2002-2012 Nikolaus Gebhardt
2 // This file is part of the "Irrlicht Engine".
3 // For conditions of distribution and use, see copyright notice in irrlicht.h
7 #include "IBillboardSceneNode.h"
8 #include "SMeshBuffer.h"
15 //! Scene node which is a billboard. A billboard is like a 3d sprite: A 2d element,
16 //! which always looks to the camera.
17 class CBillboardSceneNode
: virtual public IBillboardSceneNode
21 CBillboardSceneNode(ISceneNode
*parent
, ISceneManager
*mgr
, s32 id
,
22 const core::vector3df
&position
, const core::dimension2d
<f32
> &size
,
23 video::SColor colorTop
= video::SColor(0xFFFFFFFF),
24 video::SColor colorBottom
= video::SColor(0xFFFFFFFF));
26 virtual ~CBillboardSceneNode();
29 void OnRegisterSceneNode() override
;
32 void render() override
;
34 //! returns the axis aligned bounding box of this node
35 const core::aabbox3d
<f32
> &getBoundingBox() const override
;
37 //! sets the size of the billboard
38 void setSize(const core::dimension2d
<f32
> &size
) override
;
40 //! Sets the widths of the top and bottom edges of the billboard independently.
41 void setSize(f32 height
, f32 bottomEdgeWidth
, f32 topEdgeWidth
) override
;
43 //! gets the size of the billboard
44 const core::dimension2d
<f32
> &getSize() const override
;
46 //! Gets the widths of the top and bottom edges of the billboard.
47 void getSize(f32
&height
, f32
&bottomEdgeWidth
, f32
&topEdgeWidth
) const override
;
49 video::SMaterial
&getMaterial(u32 i
) override
;
51 //! returns amount of materials used by this scene node.
52 u32
getMaterialCount() const override
;
54 //! Set the color of all vertices of the billboard
55 //! \param overallColor: the color to set
56 void setColor(const video::SColor
&overallColor
) override
;
58 //! Set the color of the top and bottom vertices of the billboard
59 //! \param topColor: the color to set the top vertices
60 //! \param bottomColor: the color to set the bottom vertices
61 virtual void setColor(const video::SColor
&topColor
,
62 const video::SColor
&bottomColor
) override
;
64 //! Gets the color of the top and bottom vertices of the billboard
65 //! \param[out] topColor: stores the color of the top vertices
66 //! \param[out] bottomColor: stores the color of the bottom vertices
67 virtual void getColor(video::SColor
&topColor
,
68 video::SColor
&bottomColor
) const override
;
70 //! Get the real boundingbox used by the billboard (which depends on the active camera)
71 const core::aabbox3d
<f32
> &getTransformedBillboardBoundingBox(const irr::scene::ICameraSceneNode
*camera
) override
;
73 //! Get the amount of mesh buffers.
74 u32
getMeshBufferCount() const override
76 return Buffer
? 1 : 0;
79 //! Get pointer to the mesh buffer.
80 IMeshBuffer
*getMeshBuffer(u32 nr
) const override
87 //! Returns type of the scene node
88 ESCENE_NODE_TYPE
getType() const override
{ return ESNT_BILLBOARD
; }
90 //! Creates a clone of this scene node and its children.
91 ISceneNode
*clone(ISceneNode
*newParent
= 0, ISceneManager
*newManager
= 0) override
;
94 void updateMesh(const irr::scene::ICameraSceneNode
*camera
);
97 //! Size.Width is the bottom edge width
98 core::dimension2d
<f32
> Size
;
101 //! BoundingBox which is large enough to contain the billboard independent of the camera
102 // TODO: BUG - still can be wrong with scaling < 1. Billboards should calculate relative coordinates for their mesh
103 // and then use the node-scaling. But needs some work...
104 /** Note that we can't use the real boundingbox for culling because at that point
105 the camera which is used to calculate the billboard is not yet updated. So we only
106 know the real boundingbox after rendering - which is too late for culling. */
107 core::aabbox3d
<f32
> BBoxSafe
;
109 scene::SMeshBuffer
*Buffer
;
112 } // end namespace scene
113 } // end namespace irr