2014-10-14 13:11:37 +00:00
|
|
|
|
/*
|
|
|
|
|
* This file is part of the Colobot: Gold Edition source code
|
|
|
|
|
* Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam
|
|
|
|
|
* http://epsiteс.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
|
|
|
|
|
*/
|
2012-06-22 14:31:55 +00:00
|
|
|
|
|
2012-08-11 16:39:16 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file graphics/engine/lightning.h
|
2012-09-19 21:50:28 +00:00
|
|
|
|
* \brief Lightning rendering - CLightning class (aka blitz)
|
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"
|
2012-09-19 21:50:28 +00:00
|
|
|
|
|
2012-06-25 17:59:17 +00:00
|
|
|
|
#include "math/vector.h"
|
2012-06-25 14:37:03 +00:00
|
|
|
|
|
|
|
|
|
|
2012-06-25 17:59:17 +00:00
|
|
|
|
class CObject;
|
2012-10-05 13:26:24 +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;
|
|
|
|
|
|
2012-10-05 13:26:24 +00:00
|
|
|
|
//! Radius of lightning protection
|
|
|
|
|
const float LTNG_PROTECTION_RADIUS = 200.0f;
|
2012-06-25 14:37:03 +00:00
|
|
|
|
|
|
|
|
|
|
2012-08-12 22:14:42 +00:00
|
|
|
|
/**
|
|
|
|
|
* \class CLightning
|
|
|
|
|
* \brief Lightning effect renderer
|
|
|
|
|
*
|
2012-10-05 13:26:24 +00:00
|
|
|
|
* TODO: documentation
|
2012-08-12 22:14:42 +00:00
|
|
|
|
*/
|
2012-06-25 14:37:03 +00:00
|
|
|
|
class CLightning
|
|
|
|
|
{
|
|
|
|
|
public:
|
2013-02-16 21:37:43 +00:00
|
|
|
|
CLightning(CEngine* engine);
|
2012-06-26 20:23:05 +00:00
|
|
|
|
~CLightning();
|
2012-06-25 14:37:03 +00:00
|
|
|
|
|
2012-10-05 13:26:24 +00:00
|
|
|
|
//! Triggers lightning
|
2012-06-26 20:23:05 +00:00
|
|
|
|
bool Create(float sleep, float delay, float magnetic);
|
2012-10-05 13:26:24 +00:00
|
|
|
|
|
|
|
|
|
//! Removes lightning
|
|
|
|
|
void Flush();
|
|
|
|
|
|
|
|
|
|
//! Gives the status of lightning
|
2012-06-26 20:23:05 +00:00
|
|
|
|
bool GetStatus(float &sleep, float &delay, float &magnetic, float &progress);
|
2012-10-05 13:26:24 +00:00
|
|
|
|
//! Specifies the status of lightning
|
2012-06-26 20:23:05 +00:00
|
|
|
|
bool SetStatus(float sleep, float delay, float magnetic, float progress);
|
2012-10-05 13:26:24 +00:00
|
|
|
|
|
|
|
|
|
//! Management of an event
|
|
|
|
|
bool EventProcess(const Event &event);
|
|
|
|
|
|
|
|
|
|
//! Draws lightning
|
2012-06-26 20:23:05 +00:00
|
|
|
|
void Draw();
|
2012-06-25 14:37:03 +00:00
|
|
|
|
|
|
|
|
|
protected:
|
2012-10-05 13:26:24 +00:00
|
|
|
|
//! Updates lightning
|
2012-06-26 20:23:05 +00:00
|
|
|
|
bool EventFrame(const Event &event);
|
2012-10-05 13:26:24 +00:00
|
|
|
|
//! Seeks for the object closest to the lightning
|
2012-06-26 20:23:05 +00:00
|
|
|
|
CObject* SearchObject(Math::Vector pos);
|
2012-06-25 14:37:03 +00:00
|
|
|
|
|
|
|
|
|
protected:
|
2012-10-05 13:26:24 +00:00
|
|
|
|
CEngine* m_engine;
|
|
|
|
|
CTerrain* m_terrain;
|
|
|
|
|
CCamera* m_camera;
|
|
|
|
|
CSoundInterface* m_sound;
|
2012-06-26 20:23:05 +00:00
|
|
|
|
|
2012-10-05 13:26:24 +00:00
|
|
|
|
bool m_lightningExists;
|
2012-06-26 20:23:05 +00:00
|
|
|
|
float m_sleep;
|
|
|
|
|
float m_delay;
|
|
|
|
|
float m_magnetic;
|
2012-10-05 13:26:24 +00:00
|
|
|
|
|
2012-06-26 20:23:05 +00:00
|
|
|
|
float m_speed;
|
|
|
|
|
float m_progress;
|
|
|
|
|
Math::Vector m_pos;
|
2012-10-05 13:26:24 +00:00
|
|
|
|
|
|
|
|
|
enum LightningPhase
|
|
|
|
|
{
|
|
|
|
|
LP_WAIT,
|
|
|
|
|
LP_FLASH,
|
|
|
|
|
};
|
|
|
|
|
LightningPhase m_phase;
|
|
|
|
|
|
|
|
|
|
static const short FLASH_SEGMENTS = 50;
|
|
|
|
|
Math::Point m_shift[FLASH_SEGMENTS];
|
|
|
|
|
float m_width[FLASH_SEGMENTS];
|
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
|
|
|
|
|