]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - plugins/md3model/plugin.cpp
Merge remote-tracking branch 'github/master'
[xonotic/netradiant.git] / plugins / md3model / plugin.cpp
1 /*
2    Copyright (C) 2001-2006, William Joseph.
3    All Rights Reserved.
4
5    This file is part of GtkRadiant.
6
7    GtkRadiant is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
11
12    GtkRadiant is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with GtkRadiant; if not, write to the Free Software
19    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20  */
21
22 #include "plugin.h"
23
24 #include "iscenegraph.h"
25 #include "irender.h"
26 #include "iselection.h"
27 #include "iimage.h"
28 #include "imodel.h"
29 #include "igl.h"
30 #include "ifilesystem.h"
31 #include "iundo.h"
32 #include "ifiletypes.h"
33 #include "iscriplib.h"
34
35 #include "modulesystem/singletonmodule.h"
36 #include "typesystem.h"
37
38 #include "md3.h"
39 #include "mdl.h"
40 #include "md2.h"
41 #include "mdc.h"
42 #include "mdlimage.h"
43 #include "md5.h"
44
45
46 class MD3ModelLoader : public ModelLoader
47 {
48 public:
49 scene::Node& loadModel( ArchiveFile& file ){
50         return loadMD3Model( file );
51 }
52 };
53
54 class ModelDependencies :
55         public GlobalFileSystemModuleRef,
56         public GlobalOpenGLModuleRef,
57         public GlobalUndoModuleRef,
58         public GlobalSceneGraphModuleRef,
59         public GlobalShaderCacheModuleRef,
60         public GlobalSelectionModuleRef,
61         public GlobalFiletypesModuleRef
62 {
63 };
64
65 class ModelMD3API : public TypeSystemRef
66 {
67 MD3ModelLoader m_modelmd3;
68 public:
69 typedef ModelLoader Type;
70 STRING_CONSTANT( Name, "md3" );
71
72 ModelMD3API(){
73         GlobalFiletypesModule::getTable().addType( Type::Name(), Name(), filetype_t( "md3 models", "*.md3" ) );
74 }
75 ModelLoader* getTable(){
76         return &m_modelmd3;
77 }
78 };
79
80 typedef SingletonModule<ModelMD3API, ModelDependencies> ModelMD3Module;
81
82 ModelMD3Module g_ModelMD3Module;
83
84
85
86 class MD2ModelLoader : public ModelLoader
87 {
88 public:
89 scene::Node& loadModel( ArchiveFile& file ){
90         return loadMD2Model( file );
91 }
92 };
93
94 class ModelMD2API : public TypeSystemRef
95 {
96 MD2ModelLoader m_modelmd2;
97 public:
98 typedef ModelLoader Type;
99 STRING_CONSTANT( Name, "md2" );
100
101 ModelMD2API(){
102         GlobalFiletypesModule::getTable().addType( Type::Name(), Name(), filetype_t( "md2 models", "*.md2" ) );
103 }
104 ModelLoader* getTable(){
105         return &m_modelmd2;
106 }
107 };
108
109 typedef SingletonModule<ModelMD2API, ModelDependencies> ModelMD2Module;
110
111 ModelMD2Module g_ModelMD2Module;
112
113 class MDLModelLoader : public ModelLoader
114 {
115 public:
116 scene::Node& loadModel( ArchiveFile& file ){
117         return loadMDLModel( file );
118 }
119 };
120
121 class ModelMDLAPI : public TypeSystemRef
122 {
123 MDLModelLoader m_modelmdl;
124 public:
125 typedef ModelLoader Type;
126 STRING_CONSTANT( Name, "mdl" );
127
128 ModelMDLAPI(){
129         GlobalFiletypesModule::getTable().addType( Type::Name(), Name(), filetype_t( "mdl models", "*.mdl" ) );
130 }
131 ModelLoader* getTable(){
132         return &m_modelmdl;
133 }
134 };
135
136 typedef SingletonModule<ModelMDLAPI, ModelDependencies> ModelMDLModule;
137
138 ModelMDLModule g_ModelMDLModule;
139
140 class MDCModelLoader : public ModelLoader
141 {
142 public:
143 scene::Node& loadModel( ArchiveFile& file ){
144         return loadMDCModel( file );
145 }
146 };
147
148 class ModelMDCAPI : public TypeSystemRef
149 {
150 MDCModelLoader m_modelmdc;
151 public:
152 typedef ModelLoader Type;
153 STRING_CONSTANT( Name, "mdc" );
154
155 ModelMDCAPI(){
156         GlobalFiletypesModule::getTable().addType( Type::Name(), Name(), filetype_t( "mdc models", "*.mdc" ) );
157 }
158 ModelLoader* getTable(){
159         return &m_modelmdc;
160 }
161 };
162
163 typedef SingletonModule<ModelMDCAPI, ModelDependencies> ModelMDCModule;
164
165 ModelMDCModule g_ModelMDCModule;
166
167
168 class ImageMDLAPI
169 {
170 _QERPlugImageTable m_imagemdl;
171 public:
172 typedef _QERPlugImageTable Type;
173 STRING_CONSTANT( Name, "mdl" );
174
175 ImageMDLAPI(){
176         m_imagemdl.loadImage = &LoadMDLImage;
177 }
178 _QERPlugImageTable* getTable(){
179         return &m_imagemdl;
180 }
181 };
182
183 typedef SingletonModule<ImageMDLAPI, GlobalFileSystemModuleRef> ImageMDLModule;
184
185 ImageMDLModule g_ImageMDLModule;
186
187
188 class MD5ModelLoader : public ModelLoader
189 {
190 public:
191 scene::Node& loadModel( ArchiveFile& file ){
192         return loadMD5Model( file );
193 }
194 };
195
196 class ModelMD5Dependencies : public ModelDependencies, public GlobalScripLibModuleRef
197 {
198 };
199
200 class ModelMD5API : public TypeSystemRef
201 {
202 MD5ModelLoader m_modelmd5;
203 public:
204 typedef ModelLoader Type;
205 STRING_CONSTANT( Name, "md5mesh" );
206
207 ModelMD5API(){
208         GlobalFiletypesModule::getTable().addType( Type::Name(), Name(), filetype_t( "md5 meshes", "*.md5mesh" ) );
209 }
210 ModelLoader* getTable(){
211         return &m_modelmd5;
212 }
213 };
214
215 typedef SingletonModule<ModelMD5API, ModelMD5Dependencies> ModelMD5Module;
216
217 ModelMD5Module g_ModelMD5Module;
218
219
220 extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules( ModuleServer& server ){
221         initialiseModule( server );
222
223         g_ModelMD3Module.selfRegister();
224         g_ModelMD2Module.selfRegister();
225         g_ModelMDLModule.selfRegister();
226         g_ModelMDCModule.selfRegister();
227         g_ImageMDLModule.selfRegister();
228         g_ModelMD5Module.selfRegister();
229 }