53 lines
1.6 KiB
C++
53 lines
1.6 KiB
C++
#include "TeleportZone.h"
|
|
#include "render/Renderer.h"
|
|
#include "render/TextureManager.h"
|
|
|
|
namespace ZL {
|
|
|
|
void TeleportZone::initSparks(std::shared_ptr<Texture> activeTex, std::shared_ptr<Texture> inactiveTex)
|
|
{
|
|
activeTexture = activeTex;
|
|
inactiveTexture = inactiveTex;
|
|
sparks = std::make_unique<SparkEmitter>();
|
|
std::vector<Vector3f> emitPoints;
|
|
emitPoints.push_back(Vector3f{ position.x(), position.y(), position.z() });
|
|
sparks->setEmissionPoints(emitPoints);
|
|
sparks->setTexture(active ? activeTex : inactiveTex);
|
|
sparks->setEmissionRate(50.0f);
|
|
sparks->setMaxParticles(160);
|
|
sparks->setParticleSize(0.10f);
|
|
sparks->setBiasX(0.0f);
|
|
sparks->setEmissionDirection(Vector3f{ 0.0f, 1.0f, 0.0f });
|
|
sparks->setEmissionRadius(radius);
|
|
sparks->setSpeedRange(0.5f, 1.0f);
|
|
sparks->setZSpeedRange(0.5f, 1.5f);
|
|
sparks->setScaleRange(0.5f, 1.0f);
|
|
sparks->setLifeTimeRange(1500.0f, 2500.0f);
|
|
sparks->setUseWorldSpace(true);
|
|
sparks->markConfigured();
|
|
}
|
|
|
|
void TeleportZone::setActive(bool isActive)
|
|
{
|
|
active = isActive;
|
|
if (sparks && activeTexture && inactiveTexture)
|
|
sparks->setTexture(isActive ? activeTexture : inactiveTexture);
|
|
}
|
|
|
|
void TeleportZone::update(float deltaMs)
|
|
{
|
|
if (sparks) sparks->update(deltaMs);
|
|
}
|
|
|
|
void TeleportZone::prepareForDraw(const Eigen::Matrix4f& viewMatrix)
|
|
{
|
|
if (sparks) sparks->prepareForDraw(viewMatrix);
|
|
}
|
|
|
|
void TeleportZone::draw(Renderer& renderer, float zoom, int width, int height)
|
|
{
|
|
if (sparks) sparks->draw(renderer, zoom, width, height);
|
|
}
|
|
|
|
} // namespace ZL
|