Colobot
model.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 "graphics/model/model_crash_sphere.h"
23 #include "graphics/model/model_mesh.h"
24 #include "graphics/model/model_shadow_spot.h"
25 
26 #include "math/sphere.h"
27 
28 #include <map>
29 #include <string>
30 #include <vector>
31 #include <boost/optional.hpp>
32 
33 namespace Gfx
34 {
35 
40 class CModel
41 {
42 public:
44  int GetMeshCount() const;
46  CModelMesh* GetMesh(const std::string& name);
48  const CModelMesh* GetMesh(const std::string& name) const;
50  void AddMesh(const std::string& name, CModelMesh&& mesh);
52  std::vector<std::string> GetMeshNames() const;
53 
55  const std::vector<ModelCrashSphere>& GetCrashSpheres() const;
57  void AddCrashSphere(const ModelCrashSphere& crashSphere);
59  int GetCrashSphereCount() const;
60 
62  const ModelShadowSpot& GetShadowSpot() const;
64  void SetShadowSpot(const ModelShadowSpot& shadowSpot);
66  bool HasShadowSpot() const;
67 
71  void SetCameraCollisionSphere(const Math::Sphere& sphere);
73  bool HasCameraCollisionSphere() const;
74 
75 private:
76  std::map<std::string, CModelMesh> m_meshes;
77  std::vector<ModelCrashSphere> m_crashSpheres;
78  boost::optional<ModelShadowSpot> m_shadowSpot;
79  boost::optional<Math::Sphere> m_cameraCollisionSphere;
80 };
81 
82 } // namespace Gfx
const ModelShadowSpot & GetShadowSpot() const
Returns the shadow spot associated with model (assumes it is present)
Definition: model.cpp:70
3D model saved in model file
Definition: model.h:40
void SetShadowSpot(const ModelShadowSpot &shadowSpot)
Sets the shadow spot associated with model.
Definition: model.cpp:75
void SetCameraCollisionSphere(const Math::Sphere &sphere)
Sets the shadow spot associated with model.
Definition: model.cpp:105
int GetMeshCount() const
Returns mesh count.
Definition: model.cpp:28
void AddCrashSphere(const ModelCrashSphere &crashSphere)
Adds a new crash sphere.
Definition: model.cpp:90
bool HasCameraCollisionSphere() const
Returns whether there is camera collision sphere.
Definition: model.cpp:110
Crash sphere data as saved in model file.
Definition: model_crash_sphere.h:31
const std::vector< ModelCrashSphere > & GetCrashSpheres() const
Returns the model&#39;s crash spheres.
Definition: model.cpp:85
Mesh data saved in model file.
Definition: model_mesh.h:35
void AddMesh(const std::string &name, CModelMesh &&mesh)
Add new mesh with given name.
Definition: model.cpp:55
bool HasShadowSpot() const
Returns whether there is shadow spot.
Definition: model.cpp:80
Namespace for (new) graphics code.
Definition: app.h:49
int GetCrashSphereCount() const
Returns number of crash spheres.
Definition: model.cpp:95
CModelMesh * GetMesh(const std::string &name)
Return a mesh with given name.
Definition: model.cpp:33
const Math::Sphere & GetCameraCollisionSphere() const
Returns the optional shadow spot associated with model (assumes it is present)
Definition: model.cpp:100
Shadow spot data as saved in model file.
Definition: model_shadow_spot.h:29
std::vector< std::string > GetMeshNames() const
Returns list of mesh names.
Definition: model.cpp:60
Definition: sphere.h:27