Load.cpp 18 KB

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