colobot/colobot-base/graphics/engine/pyro.h

190 lines
5.6 KiB
C
Raw Normal View History

/*
* This file is part of the Colobot: Gold Edition source code
2023-08-06 21:15:48 +00:00
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
2015-08-22 14:40:02 +00:00
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://gnu.org/licenses
*/
/**
* \file graphics/engine/pyro.h
2012-09-19 21:50:28 +00:00
* \brief Fire effect rendering - CPyro class
*/
#pragma once
2012-09-19 21:50:28 +00:00
2015-08-15 12:02:07 +00:00
#include "common/error.h"
2012-09-19 21:50:28 +00:00
#include "graphics/core/color.h"
#include "graphics/engine/pyro_type.h"
2012-09-19 21:50:28 +00:00
#include "math/sphere.h"
#include "object/object_type.h"
2012-06-25 14:37:03 +00:00
#include <vector>
2012-06-25 14:37:03 +00:00
class CObject;
class CRobotMain;
2012-09-19 21:50:28 +00:00
class CSoundInterface;
struct Event;
2012-06-25 14:37:03 +00:00
2012-09-19 21:50:28 +00:00
// Graphics module namespace
2015-08-02 09:40:47 +00:00
namespace Gfx
{
2012-06-25 14:37:03 +00:00
class CEngine;
class CTerrain;
class CCamera;
class CParticle;
class CLightManager;
2012-06-25 14:37:03 +00:00
/**
* \class CPyro
* \brief Fire effect renderer
*
2012-10-05 16:59:03 +00:00
* TODO: documentation
*/
class CPyro
{
protected:
friend class CPyroManager;
2012-06-25 14:37:03 +00:00
2012-10-05 16:59:03 +00:00
//! Creates pyrotechnic effect
bool Create(PyroType type, CObject* obj, float force);
2012-10-05 16:59:03 +00:00
//! Destroys the object
void DeleteObject();
public:
CPyro(); // should only be called by CPyroManager
~CPyro();
2012-10-05 16:59:03 +00:00
//! Indicates whether the pyrotechnic effect is complete
Error IsEnded();
2012-10-05 16:59:03 +00:00
//! Indicates that the object binds to the effect no longer exists, without deleting it
2012-10-02 22:30:17 +00:00
void CutObjectLink(CObject* obj);
2012-06-25 14:37:03 +00:00
2012-10-05 16:59:03 +00:00
//! Management of an event
bool EventProcess(const Event& event);
2012-06-25 14:37:03 +00:00
protected:
2012-10-05 16:59:03 +00:00
//! Displays the error or eventual information
//! Information can be linked to the destruction of an insect, a vehicle or building
2012-10-02 22:30:17 +00:00
void DisplayError(PyroType type, CObject* obj);
2012-10-05 16:59:03 +00:00
//! Creates light to accompany a pyrotechnic effect
void CreateLight(glm::vec3 pos, float height);
2012-10-05 16:59:03 +00:00
//! Removes the binding to a pyrotechnic effect
void DeleteObject(bool primary, bool secondary);
2012-06-25 14:37:03 +00:00
2012-10-05 16:59:03 +00:00
//! Creates an explosion with triangular form of particles
void CreateTriangle(CObject* obj, ObjectType oType, int part);
2012-06-25 14:37:03 +00:00
2012-10-05 16:59:03 +00:00
//! Starts the explosion of a vehicle
void ExploStart();
2012-10-05 16:59:03 +00:00
//! Ends the explosion of a vehicle
void ExploTerminate();
2012-06-25 14:37:03 +00:00
2012-10-05 16:59:03 +00:00
//! Starts a vehicle fire
void BurnStart();
2012-10-05 16:59:03 +00:00
//! Adds a part move
void BurnAddPart(int part, glm::vec3 pos, glm::vec3 angle);
2012-10-05 16:59:03 +00:00
//! Advances of a vehicle fire
void BurnProgress();
2012-10-05 16:59:03 +00:00
//! Indicates whether a part should be retained
bool BurnIsKeepPart(int part);
2012-10-05 16:59:03 +00:00
//! Ends the fire of an insect or a vehicle
void BurnTerminate();
2012-06-25 14:37:03 +00:00
2012-10-05 16:59:03 +00:00
//! Start of an object freight falling
void FallStart();
2012-10-05 16:59:03 +00:00
//! Seeks an object to explode by the falling ball of bees
CObject* FallSearchBeeExplo();
2012-10-05 16:59:03 +00:00
//! Fall of an object's freight
void FallProgress(float rTime);
2012-10-05 16:59:03 +00:00
//! Indicates whether the fall is over
Error FallIsEnded();
2012-06-25 14:37:03 +00:00
2012-10-05 16:59:03 +00:00
//! Empty the table of operations of animation of light
void LightOperFlush();
2012-10-05 16:59:03 +00:00
//! Adds an animation operation of the light
void LightOperAdd(float progress, float intensity, float r, float g, float b);
2012-10-05 16:59:03 +00:00
//! Updates the associated light
void LightOperFrame(float rTime);
2012-06-25 14:37:03 +00:00
protected:
CEngine* m_engine = nullptr;
CTerrain* m_terrain = nullptr;
CCamera* m_camera = nullptr;
CParticle* m_particle = nullptr;
CLightManager* m_lightMan = nullptr;
CObject* m_object = nullptr;
CRobotMain* m_main = nullptr;
CSoundInterface* m_sound = nullptr;
glm::vec3 m_pos = { 0, 0, 0 }; // center of the effect
glm::vec3 m_posPower = { 0, 0, 0 }; // center of the battery
bool m_power = false; // battery exists?
PyroType m_type = PT_NULL;
float m_force = 0.0f;
float m_size = 0.0f;
float m_progress = 0.0f;
float m_speed = 0.0f;
float m_time = 0.0f;
float m_lastParticle = 0.0f;
float m_lastParticleSmoke = 0.0f;
int m_soundChannel = -1;
int m_lightRank = -1;
float m_lightHeight = 0.0f;
struct PyroLightOper
{
float progress = 0.0f;
float intensity = 0.0f;
Color color;
};
std::vector<PyroLightOper> m_lightOper;
ObjectType m_burnType = OBJECT_NULL;
int m_burnPartTotal = 0;
struct PyroBurnPart
{
int part = 0;
glm::vec3 initialPos = { 0, 0, 0 };
glm::vec3 finalPos = { 0, 0, 0 };
glm::vec3 initialAngle = { 0, 0, 0 };
glm::vec3 finalAngle = { 0, 0, 0 };
};
2012-10-02 22:30:17 +00:00
PyroBurnPart m_burnPart[10];
2015-08-15 22:06:27 +00:00
int m_burnKeepPart[10] = {};
float m_burnFall = 0.0f;
float m_fallFloor = 0.0f;
float m_fallSpeed = 0.0f;
float m_fallBulletTime = 0.0f;
bool m_fallEnding = false;
std::vector<Math::Sphere> m_crashSpheres;
float m_resetAngle = 0.0f;
2012-06-25 14:37:03 +00:00
};
2012-09-19 21:50:28 +00:00
} // namespace Gfx