Load.cpp 21 KB

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