2012-06-22 14:31:55 +00:00
|
|
|
// * This file is part of the COLOBOT source code
|
|
|
|
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
|
|
|
|
// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
|
|
|
|
// *
|
|
|
|
// * 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://www.gnu.org/licenses/.
|
|
|
|
|
2012-08-11 16:39:16 +00:00
|
|
|
/**
|
|
|
|
* \file graphics/engine/pyro.h
|
2012-09-19 21:50:28 +00:00
|
|
|
* \brief Fire effect rendering - CPyro class
|
2012-08-11 16:39:16 +00:00
|
|
|
*/
|
2012-06-22 14:31:55 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2012-09-19 21:50:28 +00:00
|
|
|
|
2012-09-09 15:51:10 +00:00
|
|
|
#include "common/event.h"
|
|
|
|
#include "common/global.h"
|
2012-09-19 21:50:28 +00:00
|
|
|
|
2012-07-26 20:26:19 +00:00
|
|
|
#include "graphics/engine/engine.h"
|
2012-09-19 21:50:28 +00:00
|
|
|
|
2012-08-09 20:50:04 +00:00
|
|
|
#include "object/object.h"
|
2012-06-25 14:37:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
class CObject;
|
|
|
|
class CRobotMain;
|
2012-09-19 21:50:28 +00:00
|
|
|
class CSoundInterface;
|
2012-06-25 14:37:03 +00:00
|
|
|
|
2012-06-22 14:31:55 +00:00
|
|
|
|
2012-09-19 21:50:28 +00:00
|
|
|
// Graphics module namespace
|
2012-06-22 14:31:55 +00:00
|
|
|
namespace Gfx {
|
|
|
|
|
2012-06-25 14:37:03 +00:00
|
|
|
class CEngine;
|
|
|
|
class CTerrain;
|
|
|
|
class CCamera;
|
|
|
|
class CParticle;
|
|
|
|
class CLight;
|
|
|
|
|
|
|
|
|
2012-10-02 22:30:17 +00:00
|
|
|
/**
|
|
|
|
* \enum PyroType
|
|
|
|
* \brief Type of pyro effect
|
|
|
|
*/
|
2012-06-25 14:37:03 +00:00
|
|
|
enum PyroType
|
|
|
|
{
|
2012-06-26 20:23:05 +00:00
|
|
|
PT_NULL = 0,
|
2012-10-02 22:30:17 +00:00
|
|
|
PT_FRAGT = 1, //! < fragmentation of technical object
|
|
|
|
PT_FRAGO = 2, //! < fragmentation of organic object
|
|
|
|
PT_FRAGW = 4, //! < fragmentation of object under water
|
|
|
|
PT_EXPLOT = 5, //! < explosion of technical object
|
|
|
|
PT_EXPLOO = 6, //! < explosion of organic object
|
|
|
|
PT_EXPLOW = 8, //! < explosion of object under water
|
|
|
|
PT_SHOTT = 9, //! < hit technical object
|
|
|
|
PT_SHOTH = 10, //! < hit human
|
|
|
|
PT_SHOTM = 11, //! < hit queen
|
|
|
|
PT_SHOTW = 12, //! < hit under water
|
|
|
|
PT_EGG = 13, //! < break the egg
|
|
|
|
PT_BURNT = 14, //! < burning of technical object
|
|
|
|
PT_BURNO = 15, //! < burning of organic object
|
|
|
|
PT_SPIDER = 16, //! < spider explosion
|
|
|
|
PT_FALL = 17, //! < cargo falling
|
|
|
|
PT_WPCHECK = 18, //! < indicator reaches
|
|
|
|
PT_FLCREATE = 19, //! < flag create
|
|
|
|
PT_FLDELETE = 20, //! < flag destroy
|
|
|
|
PT_RESET = 21, //! < reset position of the object
|
|
|
|
PT_WIN = 22, //! < fireworks
|
|
|
|
PT_LOST = 23, //! < black smoke
|
|
|
|
PT_DEADG = 24, //! < shooting death
|
|
|
|
PT_DEADW = 25, //! < drowning death
|
|
|
|
PT_FINDING = 26, //! < object discovered
|
2012-06-25 14:37:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct PyroBurnPart
|
|
|
|
{
|
2012-06-26 20:23:05 +00:00
|
|
|
int part;
|
|
|
|
Math::Vector initialPos;
|
|
|
|
Math::Vector finalPos;
|
|
|
|
Math::Vector initialAngle;
|
|
|
|
Math::Vector finalAngle;
|
2012-06-25 14:37:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct PyroLightOper
|
|
|
|
{
|
2012-10-02 22:30:17 +00:00
|
|
|
float progress;
|
|
|
|
float intensity;
|
2012-09-19 21:50:28 +00:00
|
|
|
Color color;
|
2012-06-25 14:37:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-08-12 22:14:42 +00:00
|
|
|
/**
|
|
|
|
* \class CPyro
|
|
|
|
* \brief Fire effect renderer
|
|
|
|
*
|
2012-10-05 16:59:03 +00:00
|
|
|
* TODO: documentation
|
2012-08-12 22:14:42 +00:00
|
|
|
*/
|
2012-08-09 20:50:04 +00:00
|
|
|
class CPyro
|
|
|
|
{
|
2012-06-25 14:37:03 +00:00
|
|
|
public:
|
2013-02-16 21:37:43 +00:00
|
|
|
CPyro();
|
2012-06-26 20:23:05 +00:00
|
|
|
~CPyro();
|
2012-06-25 14:37:03 +00:00
|
|
|
|
2012-10-05 16:59:03 +00:00
|
|
|
//! Creates pyrotechnic effect
|
2012-10-02 22:30:17 +00:00
|
|
|
bool Create(PyroType type, CObject* obj, float force=1.0f);
|
2012-10-05 16:59:03 +00:00
|
|
|
//! Destroys the object
|
|
|
|
void DeleteObject();
|
|
|
|
|
|
|
|
//! Indicates whether the pyrotechnic effect is complete
|
2012-06-26 20:23:05 +00:00
|
|
|
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
|
2012-10-02 22:30:17 +00:00
|
|
|
void CreateLight(Math::Vector pos, float height);
|
2012-10-05 16:59:03 +00:00
|
|
|
//! Removes the binding to a pyrotechnic effect
|
2012-08-09 20:50:04 +00:00
|
|
|
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
|
2012-10-02 22:30:17 +00:00
|
|
|
void CreateTriangle(CObject* obj, ObjectType type, int part);
|
2012-06-25 14:37:03 +00:00
|
|
|
|
2012-10-05 16:59:03 +00:00
|
|
|
//! Starts the explosion of a vehicle
|
2012-06-26 20:23:05 +00:00
|
|
|
void ExploStart();
|
2012-10-05 16:59:03 +00:00
|
|
|
//! Ends the explosion of a vehicle
|
2012-06-26 20:23:05 +00:00
|
|
|
void ExploTerminate();
|
2012-06-25 14:37:03 +00:00
|
|
|
|
2012-10-05 16:59:03 +00:00
|
|
|
//! Starts a vehicle fire
|
2012-06-26 20:23:05 +00:00
|
|
|
void BurnStart();
|
2012-10-05 16:59:03 +00:00
|
|
|
//! Adds a part move
|
2012-06-26 20:23:05 +00:00
|
|
|
void BurnAddPart(int part, Math::Vector pos, Math::Vector angle);
|
2012-10-05 16:59:03 +00:00
|
|
|
//! Advances of a vehicle fire
|
2012-06-26 20:23:05 +00:00
|
|
|
void BurnProgress();
|
2012-10-05 16:59:03 +00:00
|
|
|
//! Indicates whether a part should be retained
|
2012-06-26 20:23:05 +00:00
|
|
|
bool BurnIsKeepPart(int part);
|
2012-10-05 16:59:03 +00:00
|
|
|
//! Ends the fire of an insect or a vehicle
|
2012-06-26 20:23:05 +00:00
|
|
|
void BurnTerminate();
|
2012-06-25 14:37:03 +00:00
|
|
|
|
2012-10-05 16:59:03 +00:00
|
|
|
//! Start of an object freight falling
|
2012-06-26 20:23:05 +00:00
|
|
|
void FallStart();
|
2012-10-05 16:59:03 +00:00
|
|
|
//! Seeks an object to explode by the falling ball of bees
|
2012-06-26 20:23:05 +00:00
|
|
|
CObject* FallSearchBeeExplo();
|
2012-10-05 16:59:03 +00:00
|
|
|
//! Fall of an object's freight
|
2012-06-26 20:23:05 +00:00
|
|
|
void FallProgress(float rTime);
|
2012-10-05 16:59:03 +00:00
|
|
|
//! Indicates whether the fall is over
|
2012-06-26 20:23:05 +00:00
|
|
|
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
|
2012-06-26 20:23:05 +00:00
|
|
|
void LightOperFlush();
|
2012-10-05 16:59:03 +00:00
|
|
|
//! Adds an animation operation of the light
|
2012-06-26 20:23:05 +00:00
|
|
|
void LightOperAdd(float progress, float intensity, float r, float g, float b);
|
2012-10-05 16:59:03 +00:00
|
|
|
//! Updates the associated light
|
2012-06-26 20:23:05 +00:00
|
|
|
void LightOperFrame(float rTime);
|
2012-06-25 14:37:03 +00:00
|
|
|
|
|
|
|
protected:
|
2012-10-02 22:30:17 +00:00
|
|
|
CEngine* m_engine;
|
|
|
|
CTerrain* m_terrain;
|
|
|
|
CCamera* m_camera;
|
|
|
|
CParticle* m_particle;
|
|
|
|
CLightManager* m_lightMan;
|
|
|
|
CObject* m_object;
|
|
|
|
CRobotMain* m_main;
|
|
|
|
CSoundInterface* m_sound;
|
2012-08-09 20:50:04 +00:00
|
|
|
|
|
|
|
Math::Vector m_pos; // center of the effect
|
|
|
|
Math::Vector m_posPower; // center of the battery
|
|
|
|
bool m_power; // battery exists?
|
2012-10-02 22:30:17 +00:00
|
|
|
PyroType m_type;
|
2012-06-26 20:23:05 +00:00
|
|
|
float m_force;
|
|
|
|
float m_size;
|
|
|
|
float m_progress;
|
|
|
|
float m_speed;
|
|
|
|
float m_time;
|
2012-10-02 22:30:17 +00:00
|
|
|
float m_lastParticle;
|
|
|
|
float m_lastParticleSmoke;
|
2012-06-26 20:23:05 +00:00
|
|
|
int m_soundChannel;
|
|
|
|
|
|
|
|
int m_lightRank;
|
|
|
|
int m_lightOperTotal;
|
2012-10-02 22:30:17 +00:00
|
|
|
PyroLightOper m_lightOper[10];
|
2012-06-26 20:23:05 +00:00
|
|
|
float m_lightHeight;
|
|
|
|
|
|
|
|
ObjectType m_burnType;
|
|
|
|
int m_burnPartTotal;
|
2012-10-02 22:30:17 +00:00
|
|
|
PyroBurnPart m_burnPart[10];
|
2012-06-26 20:23:05 +00:00
|
|
|
int m_burnKeepPart[10];
|
|
|
|
float m_burnFall;
|
|
|
|
|
|
|
|
float m_fallFloor;
|
|
|
|
float m_fallSpeed;
|
|
|
|
float m_fallBulletTime;
|
2012-08-09 20:50:04 +00:00
|
|
|
bool m_fallEnding;
|
2012-06-26 20:23:05 +00:00
|
|
|
|
|
|
|
int m_crashSphereUsed; // number of spheres used
|
2012-08-09 20:50:04 +00:00
|
|
|
Math::Vector m_crashSpherePos[50];
|
2012-06-26 20:23:05 +00:00
|
|
|
float m_crashSphereRadius[50];
|
2012-06-25 14:37:03 +00:00
|
|
|
};
|
2012-06-22 14:31:55 +00:00
|
|
|
|
2012-09-19 21:50:28 +00:00
|
|
|
|
|
|
|
} // namespace Gfx
|
2013-05-26 15:47:54 +00:00
|
|
|
|