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-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
4  * http://epsitec.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 #include "graphics/core/color.h"
28 
29 #include "math/point.h"
30 #include "math/vector.h"
31 
32 #include <vector>
33 #include <string>
34 
35 
36 struct Event;
37 
38 // Graphics module namespace
39 namespace Gfx
40 {
41 
42 class CEngine;
43 class CTerrain;
44 
54 class CCloud
55 {
56 public:
57  CCloud(CEngine* engine);
58  ~CCloud();
59 
60  bool EventProcess(const Event& event);
62  void Flush();
63 
65  void Create(const std::string& fileName, const Color& diffuse, const Color& ambient, float level);
67  void Draw();
68 
70 
71  void SetLevel(float level);
72  float GetLevel();
74 
76 
77  void SetEnabled(bool enabled);
78  bool GetEnabled();
80 
81 protected:
83  bool EventFrame(const Event &event);
85  void AdjustLevel(Math::Vector& pos, Math::Vector& eye, float deep,
86  Math::Point& uv1, Math::Point& uv2);
88  void CreateLine(int x, int y, int len);
89 
90 protected:
91  CEngine* m_engine = nullptr;
92  CTerrain* m_terrain = nullptr;
93 
94  bool m_enabled = true;
96  float m_level = 0.0f;
98  std::string m_fileName;
105  float m_time = 0.0f;
106  float m_lastTest = 0.0f;
107  int m_subdiv = 8;
108 
112  int m_brickCount = 0;
114  float m_brickSize = 0;
115 
120  struct CloudLine
121  {
123  short x = 0, y = 0;
126  short len = 0;
129  float px1 = 0, px2 = 0, pz = 0;
130  };
131  std::vector<CloudLine> m_lines;
132 };
133 
134 
135 } // namespace Gfx
136 
Color m_ambient
Ambient color.
Definition: cloud.h:104
Point struct and related functions.
float px1
X (1, 2) and Z coordinates (world coordinates)
Definition: cloud.h:129
Cloud layer renderer.
Definition: cloud.h:54
Color m_diffuse
Diffuse color.
Definition: cloud.h:102
int m_brickCount
Brick mosaic.
Definition: cloud.h:112
Color structs and related functions.
2D point
Definition: point.h:50
Terrain loader/generator and manager.
Definition: terrain.h:147
Namespace for (new) graphics code.
Definition: app.h:49
Vector struct and related functions.
The graphics engine.
Definition: engine.h:585
std::string m_fileName
Texture.
Definition: cloud.h:98
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:79
Cloud strip.
Definition: cloud.h:120
void Create(const std::string &fileName, const Color &diffuse, const Color &ambient, float level)
Creates all areas of cloud.
Definition: cloud.cpp:206
float m_brickSize
Size of a brick element.
Definition: cloud.h:114
void Flush()
Removes all the clouds.
Definition: cloud.cpp:241
bool EventFrame(const Event &event)
Makes the clouds evolve.
Definition: cloud.cpp:64
Math::Point m_speed
Feedrate (wind)
Definition: cloud.h:100
3D (3x1) vector
Definition: vector.h:53
void SetLevel(float level)
Management of cloud level.
Definition: cloud.cpp:246
void CreateLine(int x, int y, int len)
Updates the positions, relative to the ground.
Definition: cloud.cpp:189
Math::Vector m_wind
Wind speed.
Definition: cloud.h:110
RGBA color.
Definition: color.h:39
float m_level
Overall level.
Definition: cloud.h:96
Event sent by system, interface or game.
Definition: event.h:735
void Draw()
Draw the clouds.
Definition: cloud.cpp:95
void SetEnabled(bool enabled)
Management of clouds.
Definition: cloud.cpp:258