<commit_before>/**
 *  For conditions of distribution and use, see copyright notice in license.txt
 *
 *  @file   EC_Billboard.h
 *  @brief  EC_Billboard shows a billboard (3D sprite) that is attached to an entity.
 *  @note   The entity must have EC_Placeable component available in advance.
 */

#pragma once

#include "IComponent.h"
#include "Math/float3.h"
#include "AssetReference.h"
#include "AssetRefListener.h"
#include "OgreModuleFwd.h"

class EC_Placeable;

namespace Ogre
{
    class BillboardSet;
    class Billboard;
}

/// EC_Billboard shows a billboard (3D sprite) that is attached to an entity.
/**
<table class="header">
<tr>
<td>
<h2>Billboard</h2>
Billboard shows a billboard (3D sprite) that is attached to an entity.


Registered by TundraLogicModule.

<b>Attributes</b>:
<ul>
<li>AssetReference: materialRef
<div>Material used by the billboard.</div>
<li>float3: position
<div>Position of billboard relative to the placeable component's position.</div> 
<li>float: width
<div>Billboard width.</div>
<li>float: height
<div>Billboard height.</div>
<li>float: rotation
<div>Billboard rotation in degrees.</div>
<li>bool: show
<div>Whether to show the billboard.</div>
<li>float: autoHideTime
<div>Time in seconds after which the billboard will hide itself automatically after showing. Negative values will not hide.</div> 
</ul>

<b>Exposes the following scriptable functions:</b>
<ul>
<li>"Show": Shows billboard (and autohides after autoHideTime seconds, if it's positive). Does not affect the "show" -attribute.
<li>"Hide: Hides the billboard. Does not affect the "show" -attribute.
</ul>

<b>Reacts on the following actions:</b>
<ul>
<li>...
</ul>
</td>
</tr>

Does not emit any actions.

<b>Depends on components Placeable</b>.  
</table>
*/
class EC_Billboard : public IComponent
{
    Q_OBJECT
    COMPONENT_NAME("EC_Billboard", 2)

public:
    /// Do not directly allocate new components using operator new, but use the factory-based SceneAPI::CreateComponent functions instead.
    explicit EC_Billboard(Scene* scene);

    /// Destructor.
    ~EC_Billboard();

    /// Material asset reference for the billboard
    Q_PROPERTY(AssetReference materialRef READ getmaterialRef WRITE setmaterialRef);
    DEFINE_QPROPERTY_ATTRIBUTE(AssetReference, materialRef);
    
    /// Billboard position in relation to the placeable component
    Q_PROPERTY(float3 position READ getposition WRITE setposition);
    DEFINE_QPROPERTY_ATTRIBUTE(float3, position);
    
    /// Billboard width
    Q_PROPERTY(float width READ getwidth WRITE setwidth);
    DEFINE_QPROPERTY_ATTRIBUTE(float, width);
    
    /// Billboard height
    Q_PROPERTY(float height READ getheight WRITE setheight);
    DEFINE_QPROPERTY_ATTRIBUTE(float, height);
    
    /// Billboard rotation in degrees
    Q_PROPERTY(float rotation READ getrotation WRITE setrotation);
    DEFINE_QPROPERTY_ATTRIBUTE(float, rotation);
    
    /// Show flag
    Q_PROPERTY(bool show READ getshow WRITE setshow);
    DEFINE_QPROPERTY_ATTRIBUTE(bool, show);

    /// Time (in seconds) in which to autohide the billboard after showing. Negative values never hide
    Q_PROPERTY(float autoHideTime READ getautoHideTime WRITE setautoHideTime);
    DEFINE_QPROPERTY_ATTRIBUTE(float, autoHideTime);

public slots:

    /// Show billboard. If autoHideTime is positive, it will be autohidden after the time has passed
    void Show();
    
    /// Hide billboard
    void Hide();
    
private slots:
    /// Component has been assigned to an entity
    void OnParentEntitySet();
    
    /// Check for placeable being added to the entity
    void CheckForPlaceable();
    
    /// Component removed; check if it was the placeable
    void OnComponentRemoved(IComponent* component, AttributeChange::Type change);
    
    /// Called when some of the attributes has been changed
    void OnAttributeUpdated(IAttribute *attribute);
    
    /// Called when material asset has been downloaded.
    void OnMaterialAssetLoaded(AssetPtr material);
    
    /// Called when material asset failed to load
    void OnMaterialAssetFailed(IAssetTransfer* transfer, QString reason);
    
private:
    /// Create billboardset & billboard
    void CreateBillboard();<commit_msg>EC_Billboard: Expose the internal Ogre::Billboard and Ogre::BillboardSet in similar fashion that eg. EC_Camera exposes Ogre::Camera.<commit_after>/**
 *  For conditions of distribution and use, see copyright notice in license.txt
 *
 *  @file   EC_Billboard.h
 *  @brief  EC_Billboard shows a billboard (3D sprite) that is attached to an entity.
 *  @note   The entity must have EC_Placeable component available in advance.
 */

#pragma once

#include "IComponent.h"
#include "Math/float3.h"
#include "AssetReference.h"
#include "AssetRefListener.h"
#include "OgreModuleFwd.h"

class EC_Placeable;

namespace Ogre
{
    class BillboardSet;
    class Billboard;
}

/// EC_Billboard shows a billboard (3D sprite) that is attached to an entity.
/**
<table class="header">
<tr>
<td>
<h2>Billboard</h2>
Billboard shows a billboard (3D sprite) that is attached to an entity.


Registered by TundraLogicModule.

<b>Attributes</b>:
<ul>
<li>AssetReference: materialRef
<div>Material used by the billboard.</div>
<li>float3: position
<div>Position of billboard relative to the placeable component's position.</div> 
<li>float: width
<div>Billboard width.</div>
<li>float: height
<div>Billboard height.</div>
<li>float: rotation
<div>Billboard rotation in degrees.</div>
<li>bool: show
<div>Whether to show the billboard.</div>
<li>float: autoHideTime
<div>Time in seconds after which the billboard will hide itself automatically after showing. Negative values will not hide.</div> 
</ul>

<b>Exposes the following scriptable functions:</b>
<ul>
<li>"Show": Shows billboard (and autohides after autoHideTime seconds, if it's positive). Does not affect the "show" -attribute.
<li>"Hide: Hides the billboard. Does not affect the "show" -attribute.
</ul>

<b>Reacts on the following actions:</b>
<ul>
<li>...
</ul>
</td>
</tr>

Does not emit any actions.

<b>Depends on components Placeable</b>.  
</table>
*/
class EC_Billboard : public IComponent
{
    Q_OBJECT
    COMPONENT_NAME("EC_Billboard", 2)

public:
    /// Do not directly allocate new components using operator new, but use the factory-based SceneAPI::CreateComponent functions instead.
    explicit EC_Billboard(Scene* scene);

    /// Destructor.
    ~EC_Billboard();

    /// Material asset reference for the billboard
    Q_PROPERTY(AssetReference materialRef READ getmaterialRef WRITE setmaterialRef);
    DEFINE_QPROPERTY_ATTRIBUTE(AssetReference, materialRef);
    
    /// Billboard position in relation to the placeable component
    Q_PROPERTY(float3 position READ getposition WRITE setposition);
    DEFINE_QPROPERTY_ATTRIBUTE(float3, position);
    
    /// Billboard width
    Q_PROPERTY(float width READ getwidth WRITE setwidth);
    DEFINE_QPROPERTY_ATTRIBUTE(float, width);
    
    /// Billboard height
    Q_PROPERTY(float height READ getheight WRITE setheight);
    DEFINE_QPROPERTY_ATTRIBUTE(float, height);
    
    /// Billboard rotation in degrees
    Q_PROPERTY(float rotation READ getrotation WRITE setrotation);
    DEFINE_QPROPERTY_ATTRIBUTE(float, rotation);
    
    /// Show flag
    Q_PROPERTY(bool show READ getshow WRITE setshow);
    DEFINE_QPROPERTY_ATTRIBUTE(bool, show);

    /// Time (in seconds) in which to autohide the billboard after showing. Negative values never hide
    Q_PROPERTY(float autoHideTime READ getautoHideTime WRITE setautoHideTime);
    DEFINE_QPROPERTY_ATTRIBUTE(float, autoHideTime);

public slots:
    /// Show billboard. If autoHideTime is positive, it will be autohidden after the time has passed
    void Show();
    
    /// Hide billboard
    void Hide();

public:
    /// Returns the Ogre Billboard ptr.
    Ogre::Billboard *GetBillBoard() const { return billboard_; }
    
    /// Returns the Ogre BillboardSet ptr.
    Ogre::BillboardSet *GetBillBoardSet() const { return billboardSet_; }
    
private slots:
    /// Component has been assigned to an entity
    void OnParentEntitySet();
    
    /// Check for placeable being added to the entity
    void CheckForPlaceable();
    
    /// Component removed; check if it was the placeable
    void OnComponentRemoved(IComponent* component, AttributeChange::Type change);
    
    /// Called when some of the attributes has been changed
    void OnAttributeUpdated(IAttribute *attribute);
    
    /// Called when material asset has been downloaded.
    void OnMaterialAssetLoaded(AssetPtr material);
    
    /// Called when material asset failed to load
    void OnMaterialAssetFailed(IAssetTransfer* transfer, QString reason);
    
private:
    /// Create billboardset & billboard
    void CreateBillboard();
{'fraction_non_alphanumeric': 0.09268514311676511, 'fraction_numerical': 0.002271694684234439, 'mean_word_length': 3.8889505830094393, 'pattern_counts': {'":': 2, '<': 95, '<?xml version=': 0, '>': 95, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5824084', 'n_tokens_mistral': 2542, 'n_tokens_neox': 2554, 'n_words': 886}