Load.cpp 20 KB

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