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/planet.h
|
|
|
|
* \brief Planet rendering - Gfx::CPlanet class
|
|
|
|
*/
|
2012-06-22 14:31:55 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2012-06-25 14:37:03 +00:00
|
|
|
#include "common/event.h"
|
|
|
|
#include "math/point.h"
|
|
|
|
|
2012-08-09 20:49:13 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2012-06-25 14:37:03 +00:00
|
|
|
|
|
|
|
class CInstanceManager;
|
|
|
|
|
2012-06-22 14:31:55 +00:00
|
|
|
|
|
|
|
namespace Gfx {
|
|
|
|
|
2012-06-25 14:37:03 +00:00
|
|
|
class CEngine;
|
|
|
|
|
|
|
|
struct Planet
|
|
|
|
{
|
2012-08-09 20:49:13 +00:00
|
|
|
//! Initial position in degrees
|
|
|
|
Math::Point start;
|
|
|
|
//! Current position in degrees
|
|
|
|
Math::Point angle;
|
|
|
|
//! Dimensions (0..1)
|
|
|
|
float dim;
|
|
|
|
//! Speed
|
|
|
|
float speed;
|
|
|
|
//! Direction in the sky
|
|
|
|
float dir;
|
|
|
|
//! Name of the texture
|
|
|
|
std::string name;
|
|
|
|
//! Texture mapping
|
|
|
|
Math::Point uv1, uv2;
|
|
|
|
//! Transparent texture
|
|
|
|
bool transparent;
|
|
|
|
|
|
|
|
Planet()
|
|
|
|
{
|
|
|
|
dim = speed = dir = 0.0f;
|
|
|
|
transparent = false;
|
|
|
|
}
|
2012-06-25 14:37:03 +00:00
|
|
|
};
|
|
|
|
|
2012-08-09 20:49:13 +00:00
|
|
|
class CPlanet
|
|
|
|
{
|
2012-06-25 14:37:03 +00:00
|
|
|
public:
|
2012-08-09 20:49:13 +00:00
|
|
|
CPlanet(CInstanceManager* iMan, Gfx::CEngine* engine);
|
2012-06-26 20:23:05 +00:00
|
|
|
~CPlanet();
|
|
|
|
|
2012-08-09 20:49:13 +00:00
|
|
|
//! Removes all the planets
|
2012-06-26 20:23:05 +00:00
|
|
|
void Flush();
|
2012-08-09 20:49:13 +00:00
|
|
|
//! Management of an event
|
2012-06-26 20:23:05 +00:00
|
|
|
bool EventProcess(const Event &event);
|
2012-08-09 20:49:13 +00:00
|
|
|
//! Creates a new planet
|
|
|
|
void Create(int mode, Math::Point start, float dim, float speed, float dir,
|
|
|
|
const std::string& name, Math::Point uv1, Math::Point uv2);
|
|
|
|
//! Indicates if there is at least one planet
|
2012-06-26 20:23:05 +00:00
|
|
|
bool PlanetExist();
|
2012-08-09 20:49:13 +00:00
|
|
|
//! Load all the textures for the planets
|
2012-06-26 20:23:05 +00:00
|
|
|
void LoadTexture();
|
2012-08-09 20:49:13 +00:00
|
|
|
//! Draws all the planets
|
2012-06-26 20:23:05 +00:00
|
|
|
void Draw();
|
2012-08-09 20:49:13 +00:00
|
|
|
//@{
|
|
|
|
//! Choice of mode
|
2012-06-26 20:23:05 +00:00
|
|
|
void SetMode(int mode);
|
2012-08-09 20:49:13 +00:00
|
|
|
int GetMode();
|
|
|
|
//@}
|
2012-06-25 14:37:03 +00:00
|
|
|
|
|
|
|
protected:
|
2012-08-09 20:49:13 +00:00
|
|
|
//! Makes the planets evolve
|
2012-06-26 20:23:05 +00:00
|
|
|
bool EventFrame(const Event &event);
|
2012-06-25 14:37:03 +00:00
|
|
|
|
|
|
|
protected:
|
2012-08-09 20:49:13 +00:00
|
|
|
CInstanceManager* m_iMan;
|
|
|
|
Gfx::CEngine* m_engine;
|
2012-06-25 14:37:03 +00:00
|
|
|
|
2012-08-09 20:49:13 +00:00
|
|
|
float m_time;
|
|
|
|
int m_mode;
|
|
|
|
std::vector<Gfx::Planet> m_planet[2];
|
|
|
|
bool m_planetExist;
|
2012-06-25 14:37:03 +00:00
|
|
|
};
|
|
|
|
|
2012-06-22 14:31:55 +00:00
|
|
|
}; // namespace Gfx
|