Main.cpp 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. #include <Bildschirm.h>
  2. #include <Datei.h>
  3. #include <DateiSystem.h>
  4. #include <Fenster.h>
  5. #include <GraphicsApi.h>
  6. #include <HttpRequest.h>
  7. #include <JSON.h>
  8. #include <main.h>
  9. #include <Network.h>
  10. #include <RenderThread.h>
  11. #include <Schrift.h>
  12. #include <Textur.h>
  13. #include "CustomDX11API.h"
  14. #include "Globals.h"
  15. #include "Initialisierung.h"
  16. void createModels(Bildschirm* zScreen);
  17. /* Test rendering of specific block types
  18. int KSGStart Framework::Start(Framework::Startparam p)
  19. {
  20. Network::Start(20);
  21. initVariables();
  22. setDebugDX(1);
  23. Datei d;
  24. d.setDatei("data/schriften");
  25. auto list = d.getDateiListe();
  26. for (Text* fontFile : *list)
  27. {
  28. LTDSDatei dat;
  29. dat.setPfad(
  30. new Text(Text("data/schriften/").operator+(fontFile->getText())));
  31. dat.leseDaten();
  32. Text* name = fontFile->getTeilText(0, fontFile->getLength() - 5);
  33. fontRegister->put(*name, RCPointer<Schrift>::of(dat.ladeSchrift()));
  34. name->release();
  35. }
  36. list->release();
  37. WFenster window;
  38. ::window = &window;
  39. WNDCLASS wc = Framework::F_Normal(p.hinst);
  40. wc.lpszClassName = "Factory Craft";
  41. window.erstellen(WS_POPUPWINDOW, wc);
  42. Monitor m = Framework::getMonitor(0);
  43. window.setBounds(Punkt(m.x, m.y), Punkt(m.breite, m.height));
  44. window.setAnzeigeModus(SW_SHOWNORMAL);
  45. window.setVSchließAktion([&window](void* p, void* f) {
  46. StopNachrichtenSchleife(window.getFensterHandle());
  47. });
  48. window.setMausAktion(_ret1ME);
  49. window.setTastaturAktion(_ret1TE);
  50. Bildschirm3D screen(
  51. dynamic_cast<WFenster*>(window.getThis()), new CustomDX11API());
  52. screen.setHandleUserInputsOnTick(1);
  53. window.setBildschirm(dynamic_cast<Bildschirm*>(screen.getThis()));
  54. screen.setFillFarbe(0);
  55. uiFactory = Framework::defaultUI(fontRegister->get("normal"), &screen);
  56. createModels(&screen);
  57. // loading textures
  58. Datei texturF;
  59. texturF.setDatei("data/textures");
  60. RCArray<Text>* files = texturF.getDateiListe();
  61. if (files)
  62. {
  63. int count = 0;
  64. for (Text* fileName : *files)
  65. {
  66. LTDBDatei dat;
  67. dat.setDatei(new Text(Text("data/textures/") + *fileName));
  68. dat.leseDaten(0);
  69. count += dat.getBildAnzahl();
  70. }
  71. for (Text* fileName : *files)
  72. {
  73. LTDBDatei dat;
  74. dat.setDatei(new Text(Text("data/textures/") + *fileName));
  75. dat.leseDaten(0);
  76. for (Text* name : *dat.zBildListe())
  77. {
  78. Bild* b = dat.laden(0, new Text(*name));
  79. screen.zGraphicsApi()
  80. ->createOrGetTextur(*fileName + "/" + *name, b)
  81. ->release();
  82. }
  83. }
  84. files->release();
  85. }
  86. BlockType* type = new BlockType(
  87. 26, 1, ModelInfo("cube", "fluids.ltdb/water.png", 0, 6), 10, 1); // block type to render
  88. Block* b = type->createBlock(Vec3<float>(0, 0, 0));
  89. unsigned char light[] = {255, 255, 255, 255, 255, 255};
  90. b->setLightData(TOP, light);
  91. b->setLightData(NORTH, light);
  92. b->setLightData(EAST, light);
  93. b->setLightData(SOUTH, light);
  94. b->setLightData(WEST, light);
  95. b->setLightData(BOTTOM, light);
  96. Chunk *c = new Chunk(Punkt(0, 0));
  97. c->setBlock(b);
  98. Welt3D* w = new Welt3D();
  99. w->addCollection(c);
  100. Kam3D* kam = new Kam3D();
  101. kam->setStyle(
  102. Kam3D::Style::Movable | Kam3D::Style::Rotatable | Kam3D::Style::Tick);
  103. kam->setPosition(Vec3<float>(10, 0, 0));
  104. kam->setAusrichtung(Vec3<float>(0, 0, 0));
  105. kam->setWelt(w);
  106. screen.addKamera(kam);
  107. RenderTh rTh;
  108. rTh.setMaxFps(60);
  109. rTh.setQuiet(1);
  110. rTh.setBildschirm(dynamic_cast<Bildschirm*>(screen.getThis()));
  111. rTh.beginn();
  112. StartNachrichtenSchleife();
  113. rTh.beenden();
  114. releaseVariables();
  115. Network::Exit();
  116. return 0;
  117. }
  118. */
  119. int KSGStart Framework::Start(Framework::Startparam p)
  120. {
  121. Network::Start(20);
  122. initVariables();
  123. setDebugDX(1);
  124. Datei d;
  125. d.setDatei("data/schriften");
  126. auto list = d.getDateiListe();
  127. for (Text* fontFile : *list)
  128. {
  129. LTDSDatei dat;
  130. dat.setPfad(
  131. new Text(Text("data/schriften/").operator+(fontFile->getText())));
  132. dat.leseDaten();
  133. Text* name = fontFile->getTeilText(0, fontFile->getLength() - 5);
  134. fontRegister->put(*name, RCPointer<Schrift>::of(dat.ladeSchrift()));
  135. name->release();
  136. }
  137. list->release();
  138. WFenster window;
  139. ::window = &window;
  140. WNDCLASS wc = Framework::F_Normal(p.hinst);
  141. wc.lpszClassName = "Factory Craft";
  142. window.erstellen(WS_POPUPWINDOW, wc);
  143. Monitor m = Framework::getMonitor(0);
  144. window.setBounds(Punkt(m.x, m.y), Punkt(m.breite, m.height));
  145. window.setAnzeigeModus(SW_SHOWNORMAL);
  146. window.setVSchließAktion([&window](void* p, void* f) {
  147. StopNachrichtenSchleife(window.getFensterHandle());
  148. });
  149. window.setMausAktion(_ret1ME);
  150. window.setTastaturAktion(_ret1TE);
  151. Bildschirm3D screen(
  152. dynamic_cast<WFenster*>(window.getThis()), new CustomDX11API());
  153. screen.setHandleUserInputsOnTick(1);
  154. window.setBildschirm(dynamic_cast<Bildschirm*>(screen.getThis()));
  155. screen.setFillFarbe(0);
  156. screen.setTestRend(0);
  157. uiFactory = Framework::defaultUI(fontRegister->get("normal"), &screen);
  158. uiFactory.createKnopf = createKnopf;
  159. uiFactory.createTextFeld = createTextFeld;
  160. uiFactory.createKontrollKnopf = createKontrollKnopf;
  161. uiFactory.createObjTabelle = createObjTabelle;
  162. uiFactory.createFenster = createFenster;
  163. initMenus();
  164. RenderTh rTh;
  165. rTh.setMaxFps(-1);
  166. rTh.setQuiet(1);
  167. rTh.setBildschirm(dynamic_cast<Bildschirm*>(screen.getThis()));
  168. rTh.setTickFunktion([](void* p, void* o, double time) {
  169. if (World::INSTANCE)
  170. {
  171. World::INSTANCE->onTick(time);
  172. }
  173. });
  174. rTh.beginn();
  175. StartNachrichtenSchleife();
  176. rTh.beenden();
  177. releaseVariables();
  178. Network::Exit();
  179. return 0;
  180. }