Colobot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
cloud.h
Go to the documentation of this file.
1 // * This file is part of the COLOBOT source code
2 // * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
3 // * Copyright (C) 2012, Polish Portal of Colobot (PPC)
4 // *
5 // * This program is free software: you can redistribute it and/or modify
6 // * it under the terms of the GNU General Public License as published by
7 // * the Free Software Foundation, either version 3 of the License, or
8 // * (at your option) any later version.
9 // *
10 // * This program is distributed in the hope that it will be useful,
11 // * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // * GNU General Public License for more details.
14 // *
15 // * You should have received a copy of the GNU General Public License
16 // * along with this program. If not, see http://www.gnu.org/licenses/.
17 
23 #pragma once
24 
25 
26 #include "common/event.h"
27 
28 #include "graphics/core/color.h"
29 
30 #include "math/point.h"
31 #include "math/vector.h"
32 
33 #include <vector>
34 #include <string>
35 
36 
37 // Graphics module namespace
38 namespace Gfx {
39 
40 class CEngine;
41 class CTerrain;
42 
47 struct CloudLine
48 {
50 
51  short x, y;
53 
54  short len;
56  float px1, px2, pz;
57 
58  CloudLine()
59  {
60  x = y = 0;
61  len = 0;
62  px1 = px2 = pz = 0;
63  }
64 };
65 
66 
76 class CCloud
77 {
78 public:
79  CCloud(CEngine* engine);
80  ~CCloud();
81 
82  bool EventProcess(const Event& event);
84  void Flush();
85 
87  void Create(const std::string& fileName, const Color& diffuse, const Color& ambient, float level);
89  void Draw();
90 
92 
93  void SetLevel(float level);
94  float GetLevel();
96 
98 
99  void SetEnabled(bool enable);
100  bool GetEnabled();
102 
103 protected:
105  bool EventFrame(const Event &event);
107  void AdjustLevel(Math::Vector& pos, Math::Vector& eye, float deep,
108  Math::Point& uv1, Math::Point& uv2);
110  void CreateLine(int x, int y, int len);
111 
112 protected:
113  CEngine* m_engine;
114  CTerrain* m_terrain;
115 
116  bool m_enabled;
118  float m_level;
120  std::string m_fileName;
127  float m_time;
128  float m_lastTest;
129  int m_subdiv;
130 
136  float m_brickSize;
137 
138  std::vector<CloudLine> m_lines;
139 };
140 
141 
142 } // namespace Gfx
143