Separated ParticleEmitter
Renamed ParticleEmitter to ParticleSystem Added class ParticleEmitter (First implementation, this will probably change) Former-commit-id: a1f80db340983da5e85cedc974dd6b24a98e25b0
This commit is contained in:
@@ -12,8 +12,8 @@
|
||||
#include <Nazara/Core/ResourceRef.hpp>
|
||||
|
||||
class NzParticleController;
|
||||
class NzParticleEmitter;
|
||||
class NzParticleMapper;
|
||||
class NzParticleSystem;
|
||||
|
||||
using NzParticleControllerConstRef = NzResourceRef<const NzParticleController>;
|
||||
using NzParticleControllerRef = NzResourceRef<NzParticleController>;
|
||||
@@ -25,7 +25,7 @@ class NAZARA_API NzParticleController : public NzResource
|
||||
NzParticleController(const NzParticleController& controller);
|
||||
virtual ~NzParticleController();
|
||||
|
||||
virtual void Apply(NzParticleEmitter& emitter, NzParticleMapper& mapper, unsigned int startId, unsigned int endId, float elapsedTime) = 0;
|
||||
virtual void Apply(NzParticleSystem& system, NzParticleMapper& mapper, unsigned int startId, unsigned int endId, float elapsedTime) = 0;
|
||||
};
|
||||
|
||||
#endif // NAZARA_PARTICLECONTROLLER_HPP
|
||||
|
||||
@@ -8,92 +8,36 @@
|
||||
#define NAZARA_PARTICLEEMITTER_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Updatable.hpp>
|
||||
#include <Nazara/Graphics/ParticleController.hpp>
|
||||
#include <Nazara/Graphics/ParticleDeclaration.hpp>
|
||||
#include <Nazara/Graphics/ParticleGenerator.hpp>
|
||||
#include <Nazara/Graphics/ParticleRenderer.hpp>
|
||||
#include <Nazara/Graphics/SceneNode.hpp>
|
||||
#include <Nazara/Math/BoundingVolume.hpp>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
#include <Nazara/Utility/Node.hpp>
|
||||
|
||||
class NAZARA_API NzParticleEmitter : public NzSceneNode, NzUpdatable
|
||||
class NzParticleMapper;
|
||||
class NzParticleSystem;
|
||||
|
||||
class NAZARA_API NzParticleEmitter : public NzNode
|
||||
{
|
||||
public:
|
||||
NzParticleEmitter(unsigned int maxParticleCount, nzParticleLayout layout);
|
||||
NzParticleEmitter(unsigned int maxParticleCount, NzParticleDeclaration* declaration);
|
||||
NzParticleEmitter(const NzParticleEmitter& emitter);
|
||||
NzParticleEmitter();
|
||||
NzParticleEmitter(const NzParticleEmitter& emitter) = default;
|
||||
NzParticleEmitter(NzParticleEmitter&& emitter) = default;
|
||||
~NzParticleEmitter();
|
||||
virtual ~NzParticleEmitter();
|
||||
|
||||
void AddController(NzParticleController* controller);
|
||||
void AddGenerator(NzParticleGenerator* generator);
|
||||
void AddToRenderQueue(NzAbstractRenderQueue* renderQueue) const;
|
||||
|
||||
void* CreateParticle();
|
||||
void* CreateParticles(unsigned int count);
|
||||
|
||||
void EnableFixedStep(bool fixedStep);
|
||||
|
||||
void* GenerateParticle();
|
||||
void* GenerateParticles(unsigned int count);
|
||||
|
||||
const NzBoundingVolumef& GetBoundingVolume() const override;
|
||||
virtual void Emit(NzParticleSystem& system, float elapsedTime) const;
|
||||
|
||||
unsigned int GetEmissionCount() const;
|
||||
float GetEmissionRate() const;
|
||||
float GetFixedStepSize() const;
|
||||
unsigned int GetMaxParticleCount() const;
|
||||
unsigned int GetParticleCount() const;
|
||||
unsigned int GetParticleSize() const;
|
||||
|
||||
nzSceneNodeType GetSceneNodeType() const override;
|
||||
|
||||
bool IsDrawable() const;
|
||||
bool IsFixedStepEnabled() const;
|
||||
|
||||
void KillParticle(unsigned int index);
|
||||
void KillParticles();
|
||||
|
||||
void RemoveController(NzParticleController* controller);
|
||||
void RemoveGenerator(NzParticleGenerator* generator);
|
||||
|
||||
void SetEmissionCount(unsigned int count);
|
||||
void SetEmissionRate(float rate);
|
||||
void SetFixedStepSize(float stepSize);
|
||||
void SetRenderer(NzParticleRenderer* renderer);
|
||||
|
||||
NzParticleEmitter& operator=(const NzParticleEmitter& emitter);
|
||||
NzParticleEmitter& operator=(const NzParticleEmitter& emitter) = default;
|
||||
NzParticleEmitter& operator=(NzParticleEmitter&& emitter) = default;
|
||||
|
||||
private:
|
||||
void GenerateAABB() const;
|
||||
void Register() override;
|
||||
void ResizeBuffer();
|
||||
void Unregister() override;
|
||||
void UpdateBoundingVolume() const;
|
||||
void Update() override;
|
||||
virtual void SetupParticles(NzParticleMapper& mapper, unsigned int count) const = 0;
|
||||
|
||||
std::set<unsigned int, std::greater<unsigned int>> m_dyingParticles;
|
||||
mutable std::vector<nzUInt8> m_buffer;
|
||||
std::vector<NzParticleControllerRef> m_controllers;
|
||||
std::vector<NzParticleGeneratorRef> m_generators;
|
||||
mutable NzBoundingVolumef m_boundingVolume;
|
||||
NzParticleDeclarationConstRef m_declaration;
|
||||
NzParticleRendererRef m_renderer;
|
||||
mutable bool m_boundingVolumeUpdated;
|
||||
bool m_fixedStepEnabled;
|
||||
bool m_processing;
|
||||
float m_emissionAccumulator;
|
||||
mutable float m_emissionAccumulator;
|
||||
float m_emissionRate;
|
||||
float m_stepAccumulator;
|
||||
float m_stepSize;
|
||||
unsigned int m_emissionCount;
|
||||
unsigned int m_maxParticleCount;
|
||||
unsigned int m_particleCount;
|
||||
unsigned int m_particleSize;
|
||||
};
|
||||
|
||||
#endif // NAZARA_PARTICLEEMITTER_HPP
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
#include <Nazara/Core/Resource.hpp>
|
||||
#include <Nazara/Core/ResourceRef.hpp>
|
||||
|
||||
class NzParticleEmitter;
|
||||
class NzParticleGenerator;
|
||||
class NzParticleMapper;
|
||||
class NzParticleSystem;
|
||||
|
||||
using NzParticleGeneratorConstRef = NzResourceRef<const NzParticleGenerator>;
|
||||
using NzParticleGeneratorRef = NzResourceRef<NzParticleGenerator>;
|
||||
@@ -25,7 +25,7 @@ class NAZARA_API NzParticleGenerator : public NzResource
|
||||
NzParticleGenerator(const NzParticleGenerator& generator);
|
||||
virtual ~NzParticleGenerator();
|
||||
|
||||
virtual void Generate(NzParticleEmitter& emitter, NzParticleMapper& mapper, unsigned int startId, unsigned int endId) = 0;
|
||||
virtual void Generate(NzParticleSystem& system, NzParticleMapper& mapper, unsigned int startId, unsigned int endId) = 0;
|
||||
};
|
||||
|
||||
#endif // NAZARA_PARTICLEGENERATOR_HPP
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
#include <Nazara/Core/ResourceRef.hpp>
|
||||
|
||||
class NzAbstractRenderQueue;
|
||||
class NzParticleEmitter;
|
||||
class NzParticleMapper;
|
||||
class NzParticleRenderer;
|
||||
class NzParticleSystem;
|
||||
|
||||
using NzParticleRendererConstRef = NzResourceRef<const NzParticleRenderer>;
|
||||
using NzParticleRendererRef = NzResourceRef<NzParticleRenderer>;
|
||||
@@ -26,7 +26,7 @@ class NAZARA_API NzParticleRenderer : public NzResource
|
||||
NzParticleRenderer(const NzParticleRenderer& renderer);
|
||||
virtual ~NzParticleRenderer();
|
||||
|
||||
virtual void Render(const NzParticleEmitter& emitter, const NzParticleMapper& mapper, unsigned int startId, unsigned int endId, NzAbstractRenderQueue* renderQueue) = 0;
|
||||
virtual void Render(const NzParticleSystem& system, const NzParticleMapper& mapper, unsigned int startId, unsigned int endId, NzAbstractRenderQueue* renderQueue) = 0;
|
||||
};
|
||||
|
||||
#endif // NAZARA_PARTICLERENDERER_HPP
|
||||
|
||||
95
include/Nazara/Graphics/ParticleSystem.hpp
Normal file
95
include/Nazara/Graphics/ParticleSystem.hpp
Normal file
@@ -0,0 +1,95 @@
|
||||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Graphics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_PARTICLESYSTEM_HPP
|
||||
#define NAZARA_PARTICLESYSTEM_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Updatable.hpp>
|
||||
#include <Nazara/Graphics/ParticleController.hpp>
|
||||
#include <Nazara/Graphics/ParticleDeclaration.hpp>
|
||||
#include <Nazara/Graphics/ParticleEmitter.hpp>
|
||||
#include <Nazara/Graphics/ParticleGenerator.hpp>
|
||||
#include <Nazara/Graphics/ParticleRenderer.hpp>
|
||||
#include <Nazara/Graphics/SceneNode.hpp>
|
||||
#include <Nazara/Math/BoundingVolume.hpp>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
class NAZARA_API NzParticleSystem : public NzSceneNode, NzUpdatable
|
||||
{
|
||||
public:
|
||||
NzParticleSystem(unsigned int maxParticleCount, nzParticleLayout layout);
|
||||
NzParticleSystem(unsigned int maxParticleCount, const NzParticleDeclaration* declaration);
|
||||
NzParticleSystem(const NzParticleSystem& emitter);
|
||||
NzParticleSystem(NzParticleSystem&& emitter) = default;
|
||||
~NzParticleSystem();
|
||||
|
||||
void AddController(NzParticleController* controller);
|
||||
void AddEmitter(NzParticleEmitter* emitter);
|
||||
void AddGenerator(NzParticleGenerator* generator);
|
||||
void AddToRenderQueue(NzAbstractRenderQueue* renderQueue) const;
|
||||
|
||||
void* CreateParticle();
|
||||
void* CreateParticles(unsigned int count);
|
||||
|
||||
void EnableFixedStep(bool fixedStep);
|
||||
|
||||
void* GenerateParticle();
|
||||
void* GenerateParticles(unsigned int count);
|
||||
|
||||
const NzBoundingVolumef& GetBoundingVolume() const override;
|
||||
const NzParticleDeclaration* GetDeclaration() const;
|
||||
float GetFixedStepSize() const;
|
||||
unsigned int GetMaxParticleCount() const;
|
||||
unsigned int GetParticleCount() const;
|
||||
unsigned int GetParticleSize() const;
|
||||
nzSceneNodeType GetSceneNodeType() const override;
|
||||
|
||||
bool IsDrawable() const;
|
||||
bool IsFixedStepEnabled() const;
|
||||
|
||||
void KillParticle(unsigned int index);
|
||||
void KillParticles();
|
||||
|
||||
void RemoveController(NzParticleController* controller);
|
||||
void RemoveEmitter(NzParticleEmitter* emitter);
|
||||
void RemoveGenerator(NzParticleGenerator* generator);
|
||||
|
||||
void SetFixedStepSize(float stepSize);
|
||||
void SetRenderer(NzParticleRenderer* renderer);
|
||||
|
||||
NzParticleSystem& operator=(const NzParticleSystem& emitter);
|
||||
NzParticleSystem& operator=(NzParticleSystem&& emitter) = default;
|
||||
|
||||
private:
|
||||
void GenerateAABB() const;
|
||||
void Register() override;
|
||||
void ResizeBuffer();
|
||||
void Unregister() override;
|
||||
void UpdateBoundingVolume() const;
|
||||
void Update() override;
|
||||
|
||||
std::set<unsigned int, std::greater<unsigned int>> m_dyingParticles;
|
||||
mutable std::vector<nzUInt8> m_buffer;
|
||||
std::vector<NzParticleControllerRef> m_controllers;
|
||||
std::vector<NzParticleEmitter*> m_emitters;
|
||||
std::vector<NzParticleGeneratorRef> m_generators;
|
||||
mutable NzBoundingVolumef m_boundingVolume;
|
||||
NzParticleDeclarationConstRef m_declaration;
|
||||
NzParticleRendererRef m_renderer;
|
||||
mutable bool m_boundingVolumeUpdated;
|
||||
bool m_fixedStepEnabled;
|
||||
bool m_processing;
|
||||
float m_stepAccumulator;
|
||||
float m_stepSize;
|
||||
unsigned int m_maxParticleCount;
|
||||
unsigned int m_particleCount;
|
||||
unsigned int m_particleSize;
|
||||
};
|
||||
|
||||
#endif // NAZARA_PARTICLESYSTEM_HPP
|
||||
Reference in New Issue
Block a user