Colobot
static_object.h
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 
20 #pragma once
21 
22 #include "object/object.h"
23 
24 #include <memory>
25 #include <unordered_map>
26 
27 namespace Gfx
28 {
29 class CModelManager;
30 class CEngine;
31 class CModel;
32 class CTerrain;
33 } // namespace Gfx
34 
35 class CStaticObject;
36 using CStaticObjectUPtr = std::unique_ptr<CStaticObject>;
37 
38 class CStaticObject : public CObject
39 {
40 public:
41  CStaticObject(int id,
42  ObjectType type,
43  const std::string& key,
44  const Math::Vector& position,
45  float angleY,
46  const Gfx::CModel& model,
47  Gfx::CEngine* engine);
48 
49  virtual ~CStaticObject();
50 
51  void Read(CLevelParserLine* line) override;
52  void Write(CLevelParserLine* line) override;
53 
54  void SetTransparency(float value) override;
55 
56 public:
57  static bool IsStaticObject(ObjectType type);
58 
59  static CStaticObjectUPtr Create(int id,
60  ObjectType type,
61  const Math::Vector& position,
62  float angleY,
63  float height,
64  Gfx::CEngine* engine,
65  Gfx::CModelManager* modelManager,
66  Gfx::CTerrain* terrain);
67 
68 protected:
69  void TransformCrashSphere(Math::Sphere& crashSphere) override;
70  void TransformCameraCollisionSphere(Math::Sphere& collisionSphere) override;
71 
72 private:
73  static Math::Matrix ComputeWorldMatrix(const Math::Vector& position,
74  float angleY);
75 
76 private:
77  Gfx::CEngine* m_engine;
78  int m_meshHandle;
79  static const std::unordered_map<ObjectType, std::string, ObjectTypeHash> m_staticModelNames;
80 };
void SetTransparency(CObject *obj, float value)
Changes the level of transparency of an object and objects transported (battery & cargo) ...
Definition: camera.cpp:56
3D model saved in model file
Definition: model.h:40
4x4 matrix
Definition: matrix.h:65
Definition: parserline.h:37
Definition: static_object.h:38
Terrain loader/generator and manager.
Definition: terrain.h:147
Namespace for (new) graphics code.
Definition: app.h:49
CObject - base class for all game objects.
Manager for models read from model files.
Definition: model_manager.h:34
The graphics engine.
Definition: engine.h:585
ObjectType
Type of game object.
Definition: object_type.h:33
3D (3x1) vector
Definition: vector.h:53
Base class for all 3D in-game objects.
Definition: object.h:63
Definition: sphere.h:27