Colobot
cloud.h
Go to the documentation of this file.
1 /*
2  * This file is part of the Colobot: Gold Edition source code
3  * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam
4  * http://epsiteс.ch; http://colobot.info; http://github.com/colobot
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14  * See the GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see http://gnu.org/licenses
18  */
19 
25 #pragma once
26 
27 
28 #include "common/event.h"
29 
30 #include "graphics/core/color.h"
31 
32 #include "math/point.h"
33 #include "math/vector.h"
34 
35 #include <vector>
36 #include <string>
37 
38 
39 // Graphics module namespace
40 namespace Gfx {
41 
42 class CEngine;
43 class CTerrain;
44 
49 struct CloudLine
50 {
52  short x, y;
55  short len;
58  float px1, px2, pz;
59 
60  CloudLine()
61  {
62  x = y = 0;
63  len = 0;
64  px1 = px2 = pz = 0;
65  }
66 };
67 
68 
78 class CCloud
79 {
80 public:
81  CCloud(CEngine* engine);
82  ~CCloud();
83 
84  bool EventProcess(const Event& event);
86  void Flush();
87 
89  void Create(const std::string& fileName, const Color& diffuse, const Color& ambient, float level);
91  void Draw();
92 
94 
95  void SetLevel(float level);
96  float GetLevel();
98 
100 
101  void SetEnabled(bool enable);
102  bool GetEnabled();
104 
105 protected:
107  bool EventFrame(const Event &event);
109  void AdjustLevel(Math::Vector& pos, Math::Vector& eye, float deep,
110  Math::Point& uv1, Math::Point& uv2);
112  void CreateLine(int x, int y, int len);
113 
114 protected:
115  CEngine* m_engine;
116  CTerrain* m_terrain;
117 
118  bool m_enabled;
120  float m_level;
122  std::string m_fileName;
129  float m_time;
130  float m_lastTest;
131  int m_subdiv;
132 
138  float m_brickSize;
139 
140  std::vector<CloudLine> m_lines;
141 };
142 
143 
144 } // namespace Gfx
145 
float px1
X (1, 2) and Z coordinates (world coordinates)
Definition: cloud.h:58
void SetEnabled(bool enable)
Management of clouds.
Definition: cloud.cpp:263
Color m_ambient
Ambient color.
Definition: cloud.h:128
Point struct and related functions.
short len
Length in X direction (terrain coordinates)
Definition: cloud.h:56
Cloud layer renderer.
Definition: cloud.h:78
Color m_diffuse
Diffuse color.
Definition: cloud.h:126
int m_brickCount
Brick mosaic.
Definition: cloud.h:136
Cloud strip.
Definition: cloud.h:49
Color structs and related functions.
short x
Beginning (terrain coordinates)
Definition: cloud.h:53
2D point
Definition: point.h:49
Terrain loader/generator and manager.
Definition: terrain.h:222
Namespace for (new) graphics code.
Definition: app.h:49
Vector struct and related functions.
The graphics engine.
Definition: engine.h:684
std::string m_fileName
Texture.
Definition: cloud.h:122
Event types, structs and event queue.
void AdjustLevel(Math::Vector &pos, Math::Vector &eye, float deep, Math::Point &uv1, Math::Point &uv2)
Adjusts the position to normal, to imitate the clouds at movement.
Definition: cloud.cpp:84
void Create(const std::string &fileName, const Color &diffuse, const Color &ambient, float level)
Creates all areas of cloud.
Definition: cloud.cpp:211
float m_brickSize
Size of a brick element.
Definition: cloud.h:138
void Flush()
Removes all the clouds.
Definition: cloud.cpp:246
bool EventFrame(const Event &event)
Makes the clouds evolve.
Definition: cloud.cpp:69
Math::Point m_speed
Feedrate (wind)
Definition: cloud.h:124
3D (3x1) vector
Definition: vector.h:52
void SetLevel(float level)
Management of cloud level.
Definition: cloud.cpp:251
void CreateLine(int x, int y, int len)
Updates the positions, relative to the ground.
Definition: cloud.cpp:194
Math::Vector m_wind
Wind speed.
Definition: cloud.h:134
RGBA color.
Definition: color.h:38
float m_level
Overall level.
Definition: cloud.h:120
Event sent by system, interface or game.
Definition: event.h:678
void Draw()
Draw the clouds.
Definition: cloud.cpp:100