1 /*
2  Copyright (c) 2013 yvt
3 
4  This file is part of OpenSpades.
5 
6  OpenSpades 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  OpenSpades 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.  See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with OpenSpades.  If not, see <http://www.gnu.org/licenses/>.
18 
19  */
20 
21 #pragma once
22 
23 #include <map>
24 #include <vector>
25 
26 #include <Client/IModel.h>
27 #include <Core/VoxelModel.h>
28 
29 namespace spades {
30 	namespace draw {
31 		class SWModelRenderer;
32 
33 		class SWModel : public client::IModel {
34 			friend class SWModelRenderer;
35 
36 			Handle<VoxelModel> rawModel;
37 			float radius;
38 			Vector3 center;
39 
40 			std::vector<uint32_t> renderData;
41 			std::vector<uint32_t> renderDataAddr;
42 
43 		protected:
44 			~SWModel();
45 
46 		public:
47 			SWModel(VoxelModel *model);
48 
GetRadius()49 			float GetRadius() { return radius; }
GetCenter()50 			Vector3 GetCenter() { return center; }
GetRawModel()51 			VoxelModel *GetRawModel() { return rawModel; }
52 
53 			AABB3 GetBoundingBox();
54 		};
55 
56 		class SWModelManager {
57 			// unordered_map is preferred, but not supported by MSVC2010
58 			std::map<std::string, SWModel *> models;
59 
60 		public:
SWModelManager()61 			SWModelManager() {}
62 			~SWModelManager();
63 
64 			SWModel *RegisterModel(const std::string &);
65 			SWModel *CreateModel(VoxelModel *);
66 		};
67 	}
68 }
69