Load.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506
  1. #include "Load.h"
  2. #include "Initialisierung.h"
  3. #include <AsynchronCall.h>
  4. #include <Datei.h>
  5. #include <Array.h>
  6. #include <DateiSystem.h>
  7. #include <Text.h>
  8. #include "Globals.h"
  9. #include <Textur.h>
  10. void createDefaultCube( Bildschirm* zScreen )
  11. {
  12. Model3DData* data = zScreen->zGraphicsApi()->createModel( "cube" );
  13. data->setAmbientFactor( 0.8f );
  14. data->setDiffusFactor( 0.1f );
  15. data->setSpecularFactor( 0.1f );
  16. float size = 1;
  17. float left, right, top, bottom;
  18. // Calculate the screen coordinates of the left side of the bitmap.
  19. left = (float)((size / 2.0) * -1);
  20. // Calculate the screen coordinates of the right side of the bitmap.
  21. right = left + (float)size;
  22. // Calculate the screen coordinates of the top of the bitmap.
  23. top = (float)(size / 2.0);
  24. // Calculate the screen coordinates of the bottom of the bitmap.
  25. bottom = top - (float)size;
  26. float front = -size / 2;
  27. float back = front + size;
  28. Vertex3D* vertecies = new Vertex3D[ 24 ];
  29. for( int i = 0; i < 24; i++ )
  30. vertecies[ i ].knochenId = 0;
  31. vertecies[ 0 ].pos = Vec3<float >( left, top, front );
  32. vertecies[ 0 ].tPos = Vec2< float >( 0.f, 0.f );
  33. vertecies[ 1 ].pos = Vec3<float >( right, top, front );
  34. vertecies[ 1 ].tPos = Vec2< float >( 1.f, 0.f );
  35. vertecies[ 2 ].pos = Vec3<float >( left, bottom, front );
  36. vertecies[ 2 ].tPos = Vec2< float >( 0.f, 1.f );
  37. vertecies[ 3 ].pos = Vec3<float >( right, bottom, front );
  38. vertecies[ 3 ].tPos = Vec2< float >( 1.f, 1.f );
  39. vertecies[ 4 ].pos = Vec3<float >( left, top, back );
  40. vertecies[ 4 ].tPos = Vec2< float >( 0.0f, 0.0f );
  41. vertecies[ 5 ].pos = Vec3<float >( right, top, back );
  42. vertecies[ 5 ].tPos = Vec2< float >( 1.0f, 0.0f );
  43. vertecies[ 6 ].pos = Vec3<float >( left, bottom, back );
  44. vertecies[ 6 ].tPos = Vec2< float >( 0.0f, 1.0f );
  45. vertecies[ 7 ].pos = Vec3<float >( right, bottom, back );
  46. vertecies[ 7 ].tPos = Vec2< float >( 1.0f, 1.0f );
  47. vertecies[ 8 ].pos = Vec3<float >( left, top, front );
  48. vertecies[ 8 ].tPos = Vec2< float >( 1.f, 0.f );
  49. vertecies[ 9 ].pos = Vec3<float >( right, top, front );
  50. vertecies[ 9 ].tPos = Vec2< float >( 0.f, 0.f );
  51. vertecies[ 10 ].pos = Vec3<float >( left, bottom, front );
  52. vertecies[ 10 ].tPos = Vec2< float >( 1.f, 1.f );
  53. vertecies[ 11 ].pos = Vec3<float >( right, bottom, front );
  54. vertecies[ 11 ].tPos = Vec2< float >( 0.f, 1.f );
  55. vertecies[ 12 ].pos = Vec3<float >( left, top, back );
  56. vertecies[ 12 ].tPos = Vec2< float >( 0.0f, 0.0f );
  57. vertecies[ 13 ].pos = Vec3<float >( right, top, back );
  58. vertecies[ 13 ].tPos = Vec2< float >( 1.0f, 0.0f );
  59. vertecies[ 14 ].pos = Vec3<float >( left, bottom, back );
  60. vertecies[ 14 ].tPos = Vec2< float >( 0.0f, 1.0f );
  61. vertecies[ 15 ].pos = Vec3<float >( right, bottom, back );
  62. vertecies[ 15 ].tPos = Vec2< float >( 1.0f, 1.0f );
  63. vertecies[ 16 ].pos = Vec3<float >( left, top, front );
  64. vertecies[ 16 ].tPos = Vec2< float >( 0.f, 1.f );
  65. vertecies[ 17 ].pos = Vec3<float >( right, top, front );
  66. vertecies[ 17 ].tPos = Vec2< float >( 1.f, 1.f );
  67. vertecies[ 18 ].pos = Vec3<float >( left, bottom, front );
  68. vertecies[ 18 ].tPos = Vec2< float >( 0.f, 0.f );
  69. vertecies[ 19 ].pos = Vec3<float >( right, bottom, front );
  70. vertecies[ 19 ].tPos = Vec2< float >( 1.f, 0.f );
  71. vertecies[ 20 ].pos = Vec3<float >( left, top, back );
  72. vertecies[ 20 ].tPos = Vec2< float >( 0.0f, 0.0f );
  73. vertecies[ 21 ].pos = Vec3<float >( right, top, back );
  74. vertecies[ 21 ].tPos = Vec2< float >( 1.0f, 0.0f );
  75. vertecies[ 22 ].pos = Vec3<float >( left, bottom, back );
  76. vertecies[ 22 ].tPos = Vec2< float >( 0.0f, 1.0f );
  77. vertecies[ 23 ].pos = Vec3<float >( right, bottom, back );
  78. vertecies[ 23 ].tPos = Vec2< float >( 1.0f, 1.0f );
  79. data->setVertecies( vertecies, 24 );
  80. // the order of the polygons has to be NORTH, EAST, SOUTH, WEST, TOP, BOTTOM according to the Area definition
  81. // down side
  82. Polygon3D* p = new Polygon3D();
  83. p->indexAnz = 6;
  84. p->indexList = new int[ p->indexAnz ];
  85. p->indexList[ 0 ] = 6 + 16;
  86. p->indexList[ 1 ] = 2 + 16;
  87. p->indexList[ 2 ] = 3 + 16;
  88. p->indexList[ 3 ] = 6 + 16;
  89. p->indexList[ 4 ] = 3 + 16;
  90. p->indexList[ 5 ] = 7 + 16;
  91. data->addPolygon( p );
  92. // right side
  93. p = new Polygon3D();
  94. p->indexAnz = 6;
  95. p->indexList = new int[ p->indexAnz ];
  96. p->indexList[ 0 ] = 1 + 8;
  97. p->indexList[ 1 ] = 7 + 8;
  98. p->indexList[ 2 ] = 3 + 8;
  99. p->indexList[ 3 ] = 1 + 8;
  100. p->indexList[ 4 ] = 5 + 8;
  101. p->indexList[ 5 ] = 7 + 8;
  102. data->addPolygon( p );
  103. // top side
  104. p = new Polygon3D();
  105. p->indexAnz = 6;
  106. p->indexList = new int[ p->indexAnz ];
  107. p->indexList[ 0 ] = 4 + 16;
  108. p->indexList[ 1 ] = 1 + 16;
  109. p->indexList[ 2 ] = 0 + 16;
  110. p->indexList[ 3 ] = 4 + 16;
  111. p->indexList[ 4 ] = 5 + 16;
  112. p->indexList[ 5 ] = 1 + 16;
  113. data->addPolygon( p );
  114. // left side
  115. p = new Polygon3D();
  116. p->indexAnz = 6;
  117. p->indexList = new int[ p->indexAnz ];
  118. p->indexList[ 0 ] = 0 + 8;
  119. p->indexList[ 1 ] = 2 + 8;
  120. p->indexList[ 2 ] = 6 + 8;
  121. p->indexList[ 3 ] = 0 + 8;
  122. p->indexList[ 4 ] = 6 + 8;
  123. p->indexList[ 5 ] = 4 + 8;
  124. data->addPolygon( p );
  125. // back side
  126. p = new Polygon3D();
  127. p->indexAnz = 6;
  128. p->indexList = new int[ p->indexAnz ];
  129. p->indexList[ 0 ] = 4;
  130. p->indexList[ 1 ] = 6;
  131. p->indexList[ 2 ] = 7;
  132. p->indexList[ 3 ] = 4;
  133. p->indexList[ 4 ] = 7;
  134. p->indexList[ 5 ] = 5;
  135. data->addPolygon( p );
  136. // front side
  137. p = new Polygon3D();
  138. p->indexAnz = 6;
  139. p->indexList = new int[ p->indexAnz ];
  140. p->indexList[ 0 ] = 0;
  141. p->indexList[ 1 ] = 3;
  142. p->indexList[ 2 ] = 2;
  143. p->indexList[ 3 ] = 0;
  144. p->indexList[ 4 ] = 1;
  145. p->indexList[ 5 ] = 3;
  146. data->addPolygon( p );
  147. data->calculateNormals();
  148. data->release();
  149. }
  150. void createCubeItem( Bildschirm* zScreen )
  151. {
  152. Framework::Model3DData* data = window->zBildschirm()->zGraphicsApi()->createModel( "itemCube" );
  153. data->setAmbientFactor( 0.8f );
  154. data->setDiffusFactor( 0.1f );
  155. data->setSpecularFactor( 0.1f );
  156. float size = 0.2f;
  157. float left, right, top, bottom;
  158. // Calculate the screen coordinates of the left side of the bitmap.
  159. left = (float)((size / 2.0) * -1);
  160. // Calculate the screen coordinates of the right side of the bitmap.
  161. right = left + (float)size;
  162. // Calculate the screen coordinates of the top of the bitmap.
  163. top = (float)(size / 2.0);
  164. // Calculate the screen coordinates of the bottom of the bitmap.
  165. bottom = top - (float)size;
  166. float front = -size / 2;
  167. float back = front + size;
  168. Vertex3D* vertecies = new Vertex3D[ 24 ];
  169. for( int i = 0; i < 24; i++ )
  170. vertecies[ i ].knochenId = 0;
  171. vertecies[ 0 ].pos = Vec3<float >( left, top, front );
  172. vertecies[ 0 ].tPos = Vec2< float >( 0.f, 0.f );
  173. vertecies[ 1 ].pos = Vec3<float >( right, top, front );
  174. vertecies[ 1 ].tPos = Vec2< float >( 1.f, 0.f );
  175. vertecies[ 2 ].pos = Vec3<float >( left, bottom, front );
  176. vertecies[ 2 ].tPos = Vec2< float >( 0.f, 1.f );
  177. vertecies[ 3 ].pos = Vec3<float >( right, bottom, front );
  178. vertecies[ 3 ].tPos = Vec2< float >( 1.f, 1.f );
  179. vertecies[ 4 ].pos = Vec3<float >( left, top, back );
  180. vertecies[ 4 ].tPos = Vec2< float >( 0.0f, 0.0f );
  181. vertecies[ 5 ].pos = Vec3<float >( right, top, back );
  182. vertecies[ 5 ].tPos = Vec2< float >( 1.0f, 0.0f );
  183. vertecies[ 6 ].pos = Vec3<float >( left, bottom, back );
  184. vertecies[ 6 ].tPos = Vec2< float >( 0.0f, 1.0f );
  185. vertecies[ 7 ].pos = Vec3<float >( right, bottom, back );
  186. vertecies[ 7 ].tPos = Vec2< float >( 1.0f, 1.0f );
  187. vertecies[ 8 ].pos = Vec3<float >( left, top, front );
  188. vertecies[ 8 ].tPos = Vec2< float >( 1.f, 0.f );
  189. vertecies[ 9 ].pos = Vec3<float >( right, top, front );
  190. vertecies[ 9 ].tPos = Vec2< float >( 0.f, 0.f );
  191. vertecies[ 10 ].pos = Vec3<float >( left, bottom, front );
  192. vertecies[ 10 ].tPos = Vec2< float >( 1.f, 1.f );
  193. vertecies[ 11 ].pos = Vec3<float >( right, bottom, front );
  194. vertecies[ 11 ].tPos = Vec2< float >( 0.f, 1.f );
  195. vertecies[ 12 ].pos = Vec3<float >( left, top, back );
  196. vertecies[ 12 ].tPos = Vec2< float >( 0.0f, 0.0f );
  197. vertecies[ 13 ].pos = Vec3<float >( right, top, back );
  198. vertecies[ 13 ].tPos = Vec2< float >( 1.0f, 0.0f );
  199. vertecies[ 14 ].pos = Vec3<float >( left, bottom, back );
  200. vertecies[ 14 ].tPos = Vec2< float >( 0.0f, 1.0f );
  201. vertecies[ 15 ].pos = Vec3<float >( right, bottom, back );
  202. vertecies[ 15 ].tPos = Vec2< float >( 1.0f, 1.0f );
  203. vertecies[ 16 ].pos = Vec3<float >( left, top, front );
  204. vertecies[ 16 ].tPos = Vec2< float >( 0.f, 1.f );
  205. vertecies[ 17 ].pos = Vec3<float >( right, top, front );
  206. vertecies[ 17 ].tPos = Vec2< float >( 1.f, 1.f );
  207. vertecies[ 18 ].pos = Vec3<float >( left, bottom, front );
  208. vertecies[ 18 ].tPos = Vec2< float >( 0.f, 0.f );
  209. vertecies[ 19 ].pos = Vec3<float >( right, bottom, front );
  210. vertecies[ 19 ].tPos = Vec2< float >( 1.f, 0.f );
  211. vertecies[ 20 ].pos = Vec3<float >( left, top, back );
  212. vertecies[ 20 ].tPos = Vec2< float >( 0.0f, 0.0f );
  213. vertecies[ 21 ].pos = Vec3<float >( right, top, back );
  214. vertecies[ 21 ].tPos = Vec2< float >( 1.0f, 0.0f );
  215. vertecies[ 22 ].pos = Vec3<float >( left, bottom, back );
  216. vertecies[ 22 ].tPos = Vec2< float >( 0.0f, 1.0f );
  217. vertecies[ 23 ].pos = Vec3<float >( right, bottom, back );
  218. vertecies[ 23 ].tPos = Vec2< float >( 1.0f, 1.0f );
  219. data->setVertecies( vertecies, 24 );
  220. // the order of the polygons has to be NORTH, EAST, SOUTH, WEST, TOP, BOTTOM according to the Area definition
  221. // down side
  222. Polygon3D* p = new Polygon3D();
  223. p->indexAnz = 6;
  224. p->indexList = new int[ p->indexAnz ];
  225. p->indexList[ 0 ] = 6 + 16;
  226. p->indexList[ 1 ] = 2 + 16;
  227. p->indexList[ 2 ] = 3 + 16;
  228. p->indexList[ 3 ] = 6 + 16;
  229. p->indexList[ 4 ] = 3 + 16;
  230. p->indexList[ 5 ] = 7 + 16;
  231. data->addPolygon( p );
  232. // right side
  233. p = new Polygon3D();
  234. p->indexAnz = 6;
  235. p->indexList = new int[ p->indexAnz ];
  236. p->indexList[ 0 ] = 1 + 8;
  237. p->indexList[ 1 ] = 7 + 8;
  238. p->indexList[ 2 ] = 3 + 8;
  239. p->indexList[ 3 ] = 1 + 8;
  240. p->indexList[ 4 ] = 5 + 8;
  241. p->indexList[ 5 ] = 7 + 8;
  242. data->addPolygon( p );
  243. // top side
  244. p = new Polygon3D();
  245. p->indexAnz = 6;
  246. p->indexList = new int[ p->indexAnz ];
  247. p->indexList[ 0 ] = 4 + 16;
  248. p->indexList[ 1 ] = 1 + 16;
  249. p->indexList[ 2 ] = 0 + 16;
  250. p->indexList[ 3 ] = 4 + 16;
  251. p->indexList[ 4 ] = 5 + 16;
  252. p->indexList[ 5 ] = 1 + 16;
  253. data->addPolygon( p );
  254. // left side
  255. p = new Polygon3D();
  256. p->indexAnz = 6;
  257. p->indexList = new int[ p->indexAnz ];
  258. p->indexList[ 0 ] = 0 + 8;
  259. p->indexList[ 1 ] = 2 + 8;
  260. p->indexList[ 2 ] = 6 + 8;
  261. p->indexList[ 3 ] = 0 + 8;
  262. p->indexList[ 4 ] = 6 + 8;
  263. p->indexList[ 5 ] = 4 + 8;
  264. data->addPolygon( p );
  265. // back side
  266. p = new Polygon3D();
  267. p->indexAnz = 6;
  268. p->indexList = new int[ p->indexAnz ];
  269. p->indexList[ 0 ] = 4;
  270. p->indexList[ 1 ] = 6;
  271. p->indexList[ 2 ] = 7;
  272. p->indexList[ 3 ] = 4;
  273. p->indexList[ 4 ] = 7;
  274. p->indexList[ 5 ] = 5;
  275. data->addPolygon( p );
  276. // front side
  277. p = new Polygon3D();
  278. p->indexAnz = 6;
  279. p->indexList = new int[ p->indexAnz ];
  280. p->indexList[ 0 ] = 0;
  281. p->indexList[ 1 ] = 3;
  282. p->indexList[ 2 ] = 2;
  283. p->indexList[ 3 ] = 0;
  284. p->indexList[ 4 ] = 1;
  285. p->indexList[ 5 ] = 3;
  286. data->addPolygon( p );
  287. data->calculateNormals();
  288. data->release();
  289. }
  290. void createPlayer( Bildschirm* zScreen )
  291. {
  292. Framework::Model3DData* data = window->zBildschirm()->zGraphicsApi()->createModel( "player" );
  293. data->setAmbientFactor( 0.8f );
  294. data->setDiffusFactor( 0.1f );
  295. data->setSpecularFactor( 0.1f );
  296. float size = 0.8f;
  297. float left, right, top, bottom;
  298. // Calculate the screen coordinates of the left side of the bitmap.
  299. left = (float)((size / 2.0) * -1);
  300. // Calculate the screen coordinates of the right side of the bitmap.
  301. right = left + (float)size;
  302. // Calculate the screen coordinates of the top of the bitmap.
  303. top = (float)(size / 2.0);
  304. // Calculate the screen coordinates of the bottom of the bitmap.
  305. bottom = top - (float)size;
  306. float front = -1.5f / 2;
  307. float back = front + 1.5f;
  308. Vertex3D* vertecies = new Vertex3D[ 24 ];
  309. for( int i = 0; i < 24; i++ )
  310. vertecies[ i ].knochenId = 0;
  311. vertecies[ 0 ].pos = Vec3<float >( left, top, front );
  312. vertecies[ 0 ].tPos = Vec2< float >( 0.f, 0.f );
  313. vertecies[ 1 ].pos = Vec3<float >( right, top, front );
  314. vertecies[ 1 ].tPos = Vec2< float >( 1.f, 0.f );
  315. vertecies[ 2 ].pos = Vec3<float >( left, bottom, front );
  316. vertecies[ 2 ].tPos = Vec2< float >( 0.f, 1.f );
  317. vertecies[ 3 ].pos = Vec3<float >( right, bottom, front );
  318. vertecies[ 3 ].tPos = Vec2< float >( 1.f, 1.f );
  319. vertecies[ 4 ].pos = Vec3<float >( left, top, back );
  320. vertecies[ 4 ].tPos = Vec2< float >( 0.0f, 0.0f );
  321. vertecies[ 5 ].pos = Vec3<float >( right, top, back );
  322. vertecies[ 5 ].tPos = Vec2< float >( 1.0f, 0.0f );
  323. vertecies[ 6 ].pos = Vec3<float >( left, bottom, back );
  324. vertecies[ 6 ].tPos = Vec2< float >( 0.0f, 1.0f );
  325. vertecies[ 7 ].pos = Vec3<float >( right, bottom, back );
  326. vertecies[ 7 ].tPos = Vec2< float >( 1.0f, 1.0f );
  327. vertecies[ 8 ].pos = Vec3<float >( left, top, front );
  328. vertecies[ 8 ].tPos = Vec2< float >( 1.f, 0.f );
  329. vertecies[ 9 ].pos = Vec3<float >( right, top, front );
  330. vertecies[ 9 ].tPos = Vec2< float >( 0.f, 0.f );
  331. vertecies[ 10 ].pos = Vec3<float >( left, bottom, front );
  332. vertecies[ 10 ].tPos = Vec2< float >( 1.f, 1.f );
  333. vertecies[ 11 ].pos = Vec3<float >( right, bottom, front );
  334. vertecies[ 11 ].tPos = Vec2< float >( 0.f, 1.f );
  335. vertecies[ 12 ].pos = Vec3<float >( left, top, back );
  336. vertecies[ 12 ].tPos = Vec2< float >( 0.0f, 0.0f );
  337. vertecies[ 13 ].pos = Vec3<float >( right, top, back );
  338. vertecies[ 13 ].tPos = Vec2< float >( 1.0f, 0.0f );
  339. vertecies[ 14 ].pos = Vec3<float >( left, bottom, back );
  340. vertecies[ 14 ].tPos = Vec2< float >( 0.0f, 1.0f );
  341. vertecies[ 15 ].pos = Vec3<float >( right, bottom, back );
  342. vertecies[ 15 ].tPos = Vec2< float >( 1.0f, 1.0f );
  343. vertecies[ 16 ].pos = Vec3<float >( left, top, front );
  344. vertecies[ 16 ].tPos = Vec2< float >( 0.f, 1.f );
  345. vertecies[ 17 ].pos = Vec3<float >( right, top, front );
  346. vertecies[ 17 ].tPos = Vec2< float >( 1.f, 1.f );
  347. vertecies[ 18 ].pos = Vec3<float >( left, bottom, front );
  348. vertecies[ 18 ].tPos = Vec2< float >( 0.f, 0.f );
  349. vertecies[ 19 ].pos = Vec3<float >( right, bottom, front );
  350. vertecies[ 19 ].tPos = Vec2< float >( 1.f, 0.f );
  351. vertecies[ 20 ].pos = Vec3<float >( left, top, back );
  352. vertecies[ 20 ].tPos = Vec2< float >( 0.0f, 0.0f );
  353. vertecies[ 21 ].pos = Vec3<float >( right, top, back );
  354. vertecies[ 21 ].tPos = Vec2< float >( 1.0f, 0.0f );
  355. vertecies[ 22 ].pos = Vec3<float >( left, bottom, back );
  356. vertecies[ 22 ].tPos = Vec2< float >( 0.0f, 1.0f );
  357. vertecies[ 23 ].pos = Vec3<float >( right, bottom, back );
  358. vertecies[ 23 ].tPos = Vec2< float >( 1.0f, 1.0f );
  359. data->setVertecies( vertecies, 24 );
  360. // the order of the polygons has to be NORTH, EAST, SOUTH, WEST, TOP, BOTTOM according to the Area definition
  361. // down side
  362. Polygon3D* p = new Polygon3D();
  363. p->indexAnz = 6;
  364. p->indexList = new int[ p->indexAnz ];
  365. p->indexList[ 0 ] = 6 + 16;
  366. p->indexList[ 1 ] = 2 + 16;
  367. p->indexList[ 2 ] = 3 + 16;
  368. p->indexList[ 3 ] = 6 + 16;
  369. p->indexList[ 4 ] = 3 + 16;
  370. p->indexList[ 5 ] = 7 + 16;
  371. data->addPolygon( p );
  372. // right side
  373. p = new Polygon3D();
  374. p->indexAnz = 6;
  375. p->indexList = new int[ p->indexAnz ];
  376. p->indexList[ 0 ] = 1 + 8;
  377. p->indexList[ 1 ] = 7 + 8;
  378. p->indexList[ 2 ] = 3 + 8;
  379. p->indexList[ 3 ] = 1 + 8;
  380. p->indexList[ 4 ] = 5 + 8;
  381. p->indexList[ 5 ] = 7 + 8;
  382. data->addPolygon( p );
  383. // top side
  384. p = new Polygon3D();
  385. p->indexAnz = 6;
  386. p->indexList = new int[ p->indexAnz ];
  387. p->indexList[ 0 ] = 4 + 16;
  388. p->indexList[ 1 ] = 1 + 16;
  389. p->indexList[ 2 ] = 0 + 16;
  390. p->indexList[ 3 ] = 4 + 16;
  391. p->indexList[ 4 ] = 5 + 16;
  392. p->indexList[ 5 ] = 1 + 16;
  393. data->addPolygon( p );
  394. // left side
  395. p = new Polygon3D();
  396. p->indexAnz = 6;
  397. p->indexList = new int[ p->indexAnz ];
  398. p->indexList[ 0 ] = 0 + 8;
  399. p->indexList[ 1 ] = 2 + 8;
  400. p->indexList[ 2 ] = 6 + 8;
  401. p->indexList[ 3 ] = 0 + 8;
  402. p->indexList[ 4 ] = 6 + 8;
  403. p->indexList[ 5 ] = 4 + 8;
  404. data->addPolygon( p );
  405. // back side
  406. p = new Polygon3D();
  407. p->indexAnz = 6;
  408. p->indexList = new int[ p->indexAnz ];
  409. p->indexList[ 0 ] = 4;
  410. p->indexList[ 1 ] = 6;
  411. p->indexList[ 2 ] = 7;
  412. p->indexList[ 3 ] = 4;
  413. p->indexList[ 4 ] = 7;
  414. p->indexList[ 5 ] = 5;
  415. data->addPolygon( p );
  416. // front side
  417. p = new Polygon3D();
  418. p->indexAnz = 6;
  419. p->indexList = new int[ p->indexAnz ];
  420. p->indexList[ 0 ] = 0;
  421. p->indexList[ 1 ] = 3;
  422. p->indexList[ 2 ] = 2;
  423. p->indexList[ 3 ] = 0;
  424. p->indexList[ 4 ] = 1;
  425. p->indexList[ 5 ] = 3;
  426. data->addPolygon( p );
  427. data->calculateNormals();
  428. data->release();
  429. }
  430. void createModels( Bildschirm* zScreen )
  431. {
  432. createDefaultCube( zScreen );
  433. createCubeItem( zScreen );
  434. createPlayer( zScreen );
  435. }
  436. LoadMenu::LoadMenu( Bildschirm* zScreen )
  437. : Menu( zScreen )
  438. {
  439. step = initFBalken( 10, 90, 200, 30, FBalken::Style::normal );
  440. stage = initFBalken( 10, 50, 200, 30, FBalken::Style::normal );
  441. all = initFBalken( 10, 10, 200, 30, FBalken::Style::normal );
  442. elements.add( step );
  443. elements.add( stage );
  444. elements.add( all );
  445. new AsynchronCall( "Load Menu", [this, zScreen]() {
  446. Sleep( 1000 );
  447. all->setAktionAnzahl( 1 );
  448. all->reset();
  449. // loading textures
  450. Datei texturF;
  451. texturF.setDatei( "data/textures" );
  452. RCArray<Text>* files = texturF.getDateiListe();
  453. if( files )
  454. {
  455. int count = 0;
  456. for( Text* fileName : *files )
  457. {
  458. LTDBDatei dat;
  459. dat.setDatei( new Text( Text( "data/textures/" ) + *fileName ) );
  460. dat.leseDaten( 0 );
  461. count += dat.getBildAnzahl();
  462. }
  463. stage->setAktionAnzahl( count );
  464. stage->reset();
  465. for( Text* fileName : *files )
  466. {
  467. LTDBDatei dat;
  468. dat.setDatei( new Text( Text( "data/textures/" ) + *fileName ) );
  469. dat.leseDaten( 0 );
  470. for( Text* name : *dat.zBildListe() )
  471. {
  472. step->reset();
  473. Bild* b = dat.laden( step, new Text( *name ) );
  474. zScreen->zGraphicsApi()->createOrGetTextur( *fileName + "/" + *name, b )->release();
  475. stage->aktionPlus();
  476. }
  477. }
  478. files->release();
  479. }
  480. createModels( zScreen );
  481. all->aktionPlus();
  482. zScreen->lock();
  483. hide();
  484. menuRegister->get( "login" )->show();
  485. zScreen->unlock();
  486. } );
  487. }