Colobot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
modelfile.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 "graphics/core/vertex.h"
27 #include "graphics/core/material.h"
28 
29 #include "math/vector.h"
30 
31 #include <string>
32 #include <vector>
33 #include <iostream>
34 
35 
36 
37 // Graphics module namespace
38 namespace Gfx {
39 
40 
48 {
49  LOD_Constant = -1,
50  LOD_Low = 1,
51  LOD_Medium = 2,
52  LOD_High = 4
53 };
54 
60 {
70  std::string tex1Name;
72  std::string tex2Name;
78  int state;
79 
81  {
82  variableTex2 = true;
84  state = 0;
85  }
86 };
87 
88 
96 {
97 public:
98  CModelFile();
99  ~CModelFile();
100 
102  bool ReadTextModel(const std::string &fileName);
104  bool ReadTextModel(std::istream &stream);
105 
107  bool WriteTextModel(const std::string &fileName);
109  bool WriteTextModel(std::ostream &stream);
110 
112  bool ReadBinaryModel(const std::string &fileName);
114  bool ReadBinaryModel(std::istream &stream);
115 
117  bool WriteBinaryModel(const std::string &fileName);
119  bool WriteBinaryModel(std::ostream &stream);
120 
123  bool ReadModel(const std::string &fileName);
126  bool ReadModel(std::istream &stream);
129  bool WriteModel(const std::string &fileName);
132  bool WriteModel(std::ostream &stream);
133 
135  int GetTriangleCount();
136 
138  const std::vector<ModelTriangle>& GetTriangles();
139 
141  void SetPrintDebugInfo(bool printDebugInfo);
142 
143 protected:
145 
146  LODLevel MinMaxToLodLevel(float min, float max);
147  void LODLevelToMinMax(LODLevel lodLevel, float& min, float& max);
149 
150 protected:
152  std::vector<ModelTriangle> m_triangles;
153  bool m_printDebugInfo;
154 };
155 
156 }; // namespace Gfx
157