mElite  1.0
An Elite clone based on TextElite by Jan-Philipp Kappmeier and Melanie Schmidt.
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
FileAccess.cpp
Go to the documentation of this file.
1 
6 #include "GlobalParameters.h"
7 #include "FileAccess.h"
8 #include "Textures.h"
9 #include "Objects.h"
10 
11 using namespace std;
12 
13 static const TextureQuality TEXTURE_QUALITY = medium;// set quality
14 
22 TextureSlot FileAccess::getPlanetSlot( unsigned int index ) {
23  if( index > planetSlotCount-1)
24  return TextureSlot();
25  return planetSlots[index];
26 }
27 
37  TextureAccess ta = getTextureInfo( texture );
38  if( ta.hasQualities ) {
39  switch( TEXTURE_QUALITY ) {
40 case extraLow:
41  return ta.name + "_xs." + ta.type;
42  break;
43 case low:
44  return ta.name + "_s." + ta.type;
45  break;
46 case medium:
47  return ta.name + "_m." + ta.type;
48  break;
49 case high:
50  return ta.name + "_l" + ta.type;
51  break;
52 case extraHigh:
53  return ta.name + "_xl." + ta.type;
54  break;
55 default: // assume medium
56  return ta.name + "_m." + ta.type;
57  }
58  } else
59  return ta.name + "." + ta.type;
60 }
61 
70  return textureInfos[texture];
71 }
72 
82  TextureAccess ta = getTextureInfo(texture);
83  Textures::getTextures()->loadTexture( slot, getTextureFile( texture ) );
84 }
85 
91  return getObjectInfo( object ).name;
92 }
93 
100  return objectInfos[object];
101 }
102 
108  return getObjectInfo( object ).view;
109 }
110 
116  return getObjectInfo( object ).factor;
117 }
118 
127  Objects::getObjects()->loadObject( object, getObjectFile( object ), getObjectFactor( object ) );
128 }
129 
130 const TextureSlot FileAccess::planetSlots[] = {
131  planet1,
132  planet2,
133  planet3,
134  planet4,
135  planet5,
136  planet6,
137  planet7,
138  planet8,
139  planet9,
140  planet10
141 };
142 
150 const TextureAccess FileAccess::textureInfos[] = {
151  TextureAccess("./textures/stars_sun_korona", false,"bmp"),
152  TextureAccess("./textures/bar_green_red",false,"bmp"),
153  TextureAccess("./textures/radar", false,"bmp"),
154  TextureAccess("./textures/sight1",false,"bmp"),
155  TextureAccess("./textures/font2", false,"bmp"),// font 1 does not exist ;)
156  TextureAccess("./textures/font2", false,"bmp"),
157  TextureAccess("./textures/font3", false,"bmp"),
158  TextureAccess("./textures/laser1",false,"tga"),
159  TextureAccess("./textures/missile", false,"tga"),
160  TextureAccess("./textures/dirt",false,"bmp"),
161  TextureAccess("./textures/metall",false,"bmp"),
162  // now we start with the planets and stuff in different qualities
163  TextureAccess("./textures/planets_01",true, "bmp"),
164  TextureAccess("./textures/planets_02",true, "bmp"),
165  TextureAccess("./textures/planets_03",true, "bmp"),
166  TextureAccess("./textures/planets_04",true, "bmp"),
167  TextureAccess("./textures/planets_05",true, "bmp"),
168  TextureAccess("./textures/planets_06",true, "bmp"),
169  TextureAccess("./textures/planets_07",true, "bmp"),
170  TextureAccess("./textures/planets_08",true, "bmp"),
171  TextureAccess("./textures/planets_09",true, "bmp"),
172  TextureAccess("./textures/planets_red",true, "bmp"),
173  TextureAccess("./textures/planets_ss_earth", true, "bmp"),
174  TextureAccess("./textures/planets_ss_moon",true, "bmp"),
175  TextureAccess("./textures/planets_ss_jupiter", true, "bmp"),
176  TextureAccess("./textures/planets_ss_mars",true, "bmp"),
177  TextureAccess("./textures/planets_ss_mercury", true, "bmp"),
178  TextureAccess("./textures/planets_ss_neptune", true, "bmp"),
179  TextureAccess("./textures/planets_ss_pluto", true, "bmp"),
180  TextureAccess("./textures/planets_ss_saturn",true, "bmp"),
181  TextureAccess("./textures/planets_ss_uranus",true, "bmp"),
182  TextureAccess("./textures/planets_ss_venus", true, "bmp"),
183  TextureAccess("./textures/sun001",true, "bmp"),
184  TextureAccess("./textures/sun002",true, "bmp"),
185  TextureAccess("./textures/sun003",true, "bmp"),
186  TextureAccess("./textures/sun004",true, "bmp"),
187  TextureAccess("./textures/sun005",true, "bmp"),
188  TextureAccess("./textures/sun006",true, "bmp"),
189  TextureAccess("./textures/sun010",true, "bmp"),
190  TextureAccess("./textures/sun011",true, "bmp"),
191  TextureAccess("./textures/sun012",true, "bmp"),
192  TextureAccess("./textures/sun013",true, "bmp"),
193  TextureAccess("./textures/sun014",true, "bmp"),
194  TextureAccess("./textures/stars_sun", true, "bmp"),
195  TextureAccess("./textures/universe_galactic_center",true, "bmp"),
196  TextureAccess("./textures/universe_cirrus_8_micron",true, "bmp"),
197  TextureAccess("./textures/universe_iras-100um",true, "bmp"),
198  TextureAccess("./textures/universe_iras",true, "bmp"),
199 };
200 
206 const ObjectAccess FileAccess::objectInfos[] = {
207  ObjectAccess( "./objects/myAdder.3ds",Vector3( 0, 0, 1 ), 0.02 ),
208  ObjectAccess( "./objects/myAnaconda.3ds", Vector3( 0, 0, 1 ), 0.01 ),
209  ObjectAccess( "./objects/ball.3ds",Vector3( 0, 0, 1 ), 1 ),
210  ObjectAccess( "./objects/myCoriolis.3ds", Vector3( 0, 0, 1 ), 0.01 ),
211  ObjectAccess( "./objects/myMissile.3ds",Vector3( 0, 0, 1 ), 0.01 ),
212  ObjectAccess( "./objects/myThargoid.3ds", Vector3( 0, 0, 1 ), 0.05 ),
213  ObjectAccess( "./objects/tieDroid.3ds",Vector3( 0,-1, 0 ), 0.01 )
214 };