Sdk: Integrate particles

Former-commit-id: fa4474b434340d15363ff2ffc91b58d2df3a62fc [formerly 8a52795fc49a847e7b558425fc03915b21139521]
Former-commit-id: ac159c0cf652699400f720ef6fdad0fbf649308f
This commit is contained in:
Lynix
2016-07-30 15:51:46 +02:00
parent e6a4bcca0d
commit 70ee053f3f
15 changed files with 272 additions and 2 deletions

View File

@@ -0,0 +1,45 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
#pragma once
#ifndef NDK_SERVER
#ifndef NDK_COMPONENTS_PARTICLEEMITTERCOMPONENT_HPP
#define NDK_COMPONENTS_PARTICLEEMITTERCOMPONENT_HPP
#include <Nazara/Graphics/ParticleEmitter.hpp>
#include <NDK/Component.hpp>
namespace Ndk
{
class NDK_API ParticleEmitterComponent : public Component<ParticleEmitterComponent>, public Nz::ParticleEmitter
{
public:
using SetupFunc = std::function<void(const EntityHandle& /*entity*/, Nz::ParticleMapper& /*mapper*/, unsigned int /*count*/)>;
ParticleEmitterComponent(Nz::ParticleGroup* group);
ParticleEmitterComponent(const ParticleEmitterComponent& emitter);
~ParticleEmitterComponent();
inline bool IsActive() const;
void SetActive(bool active = true);
void SetGroup(Nz::ParticleGroup* group);
inline void SetSetupFunc(SetupFunc func);
static ComponentIndex componentIndex;
private:
void SetupParticles(Nz::ParticleMapper& mapper, unsigned int count) const override;
SetupFunc m_setupFunc;
Nz::ParticleGroup* m_particleGroup;
bool m_isActive;
};
}
#include <NDK/Components/ParticleEmitterComponent.inl>
#endif // NDK_COMPONENTS_PARTICLEEMITTERCOMPONENT_HPP
#endif // NDK_SERVER

View File

@@ -0,0 +1,18 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
#include <NDK/Components/ParticleEmitterComponent.hpp>
namespace Ndk
{
inline bool ParticleEmitterComponent::IsActive() const
{
return m_isActive;
}
inline void Ndk::ParticleEmitterComponent::SetSetupFunc(SetupFunc func)
{
m_setupFunc = std::move(func);
}
}

View File

@@ -0,0 +1,35 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
#pragma once
#ifndef NDK_SERVER
#ifndef NDK_COMPONENTS_PARTICLEGROUPCOMPONENT_HPP
#define NDK_COMPONENTS_PARTICLEGROUPCOMPONENT_HPP
#include <Nazara/Graphics/ParticleGroup.hpp>
#include <NDK/Component.hpp>
namespace Ndk
{
class ParticleGroupComponent;
using ParticleGroupComponentHandle = Nz::ObjectHandle<ParticleGroupComponent>;
class NDK_API ParticleGroupComponent : public Component<ParticleGroupComponent>, public Nz::ParticleGroup
{
public:
inline ParticleGroupComponent(unsigned int maxParticleCount, Nz::ParticleLayout layout);
inline ParticleGroupComponent(unsigned int maxParticleCount, Nz::ParticleDeclarationConstRef declaration);
ParticleGroupComponent(const ParticleGroupComponent&) = default;
~ParticleGroupComponent() = default;
static ComponentIndex componentIndex;
};
}
#include <NDK/Components/ParticleGroupComponent.inl>
#endif // NDK_COMPONENTS_PARTICLEGROUPCOMPONENT_HPP
#endif // NDK_SERVER

View File

@@ -0,0 +1,17 @@
#include "ParticleGroupComponent.hpp"
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
namespace Ndk
{
inline ParticleGroupComponent::ParticleGroupComponent(unsigned int maxParticleCount, Nz::ParticleLayout layout) :
ParticleGroup(maxParticleCount, layout)
{
}
inline ParticleGroupComponent::ParticleGroupComponent(unsigned int maxParticleCount, Nz::ParticleDeclarationConstRef declaration) :
ParticleGroup(maxParticleCount, std::move(declaration))
{
}
}