Start.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601
  1. #include <Bild.h>
  2. #include <Bildschirm.h>
  3. #include <Cube.h>
  4. #include <DateiSystem.h>
  5. #include <DXBuffer.h>
  6. #include <Fenster.h>
  7. #include <GraphicsApi.h>
  8. #include <Kam3D.h>
  9. #include <M3Datei.h>
  10. #include <main.h>
  11. #include <Mat4.h>
  12. #include <Model3D.h>
  13. #include <Model3DList.h>
  14. #include <ObjFile.h>
  15. #include <Rahmen.h>
  16. #include <RenderThread.h>
  17. #include <TextFeld.h>
  18. #include <Textur.h>
  19. #include <Vec3.h>
  20. #include <Welt3D.h>
  21. #define ambient 0.4f
  22. #define diffus 0.3f
  23. #define specular 0.3f
  24. using namespace Framework;
  25. void makeQuader(Vertex3D* vertecies,
  26. int startIndex,
  27. Vec3<float> lft,
  28. Vec3<float> rft,
  29. Vec3<float> lfb,
  30. Vec3<float> rfb,
  31. Vec3<float> lbt,
  32. Vec3<float> rbt,
  33. Vec3<float> lbb,
  34. Vec3<float> rbb,
  35. Model3DData* zModel)
  36. {
  37. // front
  38. vertecies[startIndex].pos = lft;
  39. vertecies[startIndex].tPos = Vec2<float>(0.f, 0.f);
  40. vertecies[startIndex + 1].pos = rft;
  41. vertecies[startIndex + 1].tPos = Vec2<float>(1.f, 0.f);
  42. vertecies[startIndex + 2].pos = lfb;
  43. vertecies[startIndex + 2].tPos = Vec2<float>(0.f, 1.f);
  44. vertecies[startIndex + 3].pos = rfb;
  45. vertecies[startIndex + 3].tPos = Vec2<float>(1.f, 1.f);
  46. // back
  47. vertecies[startIndex + 4].pos = rbt;
  48. vertecies[startIndex + 4].tPos = Vec2<float>(0.0f, 0.0f);
  49. vertecies[startIndex + 5].pos = lbt;
  50. vertecies[startIndex + 5].tPos = Vec2<float>(1.0f, 0.0f);
  51. vertecies[startIndex + 6].pos = rbb;
  52. vertecies[startIndex + 6].tPos = Vec2<float>(0.0f, 1.0f);
  53. vertecies[startIndex + 7].pos = lbb;
  54. vertecies[startIndex + 7].tPos = Vec2<float>(1.0f, 1.0f);
  55. // left
  56. vertecies[startIndex + 8].pos = lbt;
  57. vertecies[startIndex + 8].tPos = Vec2<float>(1.f, 0.f);
  58. vertecies[startIndex + 9].pos = lft;
  59. vertecies[startIndex + 9].tPos = Vec2<float>(0.f, 0.f);
  60. vertecies[startIndex + 10].pos = lbb;
  61. vertecies[startIndex + 10].tPos = Vec2<float>(1.f, 1.f);
  62. vertecies[startIndex + 11].pos = lfb;
  63. vertecies[startIndex + 11].tPos = Vec2<float>(0.f, 1.f);
  64. // right
  65. vertecies[startIndex + 12].pos = rft;
  66. vertecies[startIndex + 12].tPos = Vec2<float>(0.0f, 0.0f);
  67. vertecies[startIndex + 13].pos = rbt;
  68. vertecies[startIndex + 13].tPos = Vec2<float>(1.0f, 0.0f);
  69. vertecies[startIndex + 14].pos = rfb;
  70. vertecies[startIndex + 14].tPos = Vec2<float>(0.0f, 1.0f);
  71. vertecies[startIndex + 15].pos = rbb;
  72. vertecies[startIndex + 15].tPos = Vec2<float>(1.0f, 1.0f);
  73. // top
  74. vertecies[startIndex + 16].pos = lbt;
  75. vertecies[startIndex + 16].tPos = Vec2<float>(0.f, 0.f);
  76. vertecies[startIndex + 17].pos = rbt;
  77. vertecies[startIndex + 17].tPos = Vec2<float>(1.f, 0.f);
  78. vertecies[startIndex + 18].pos = lft;
  79. vertecies[startIndex + 18].tPos = Vec2<float>(0.f, 1.f);
  80. vertecies[startIndex + 19].pos = rft;
  81. vertecies[startIndex + 19].tPos = Vec2<float>(1.f, 1.f);
  82. // botom
  83. vertecies[startIndex + 20].pos = lfb;
  84. vertecies[startIndex + 20].tPos = Vec2<float>(0.0f, 0.0f);
  85. vertecies[startIndex + 21].pos = rfb;
  86. vertecies[startIndex + 21].tPos = Vec2<float>(1.0f, 0.0f);
  87. vertecies[startIndex + 22].pos = lbb;
  88. vertecies[startIndex + 22].tPos = Vec2<float>(0.0f, 1.0f);
  89. vertecies[startIndex + 23].pos = rbb;
  90. vertecies[startIndex + 23].tPos = Vec2<float>(1.0f, 1.0f);
  91. // front side
  92. Polygon3D* p = new Polygon3D();
  93. p->indexAnz = 6;
  94. p->indexList = new int[p->indexAnz];
  95. p->indexList[0] = startIndex + 0;
  96. p->indexList[1] = startIndex + 1;
  97. p->indexList[2] = startIndex + 2;
  98. p->indexList[3] = startIndex + 1;
  99. p->indexList[4] = startIndex + 3;
  100. p->indexList[5] = startIndex + 2;
  101. zModel->addPolygon(p);
  102. // left side
  103. p = new Polygon3D();
  104. p->indexAnz = 6;
  105. p->indexList = new int[p->indexAnz];
  106. p->indexList[0] = startIndex + 0 + 8;
  107. p->indexList[1] = startIndex + 1 + 8;
  108. p->indexList[2] = startIndex + 2 + 8;
  109. p->indexList[3] = startIndex + 1 + 8;
  110. p->indexList[4] = startIndex + 3 + 8;
  111. p->indexList[5] = startIndex + 2 + 8;
  112. zModel->addPolygon(p);
  113. // back side
  114. p = new Polygon3D();
  115. p->indexAnz = 6;
  116. p->indexList = new int[p->indexAnz];
  117. p->indexList[0] = startIndex + 0 + 4;
  118. p->indexList[1] = startIndex + 1 + 4;
  119. p->indexList[2] = startIndex + 2 + 4;
  120. p->indexList[3] = startIndex + 1 + 4;
  121. p->indexList[4] = startIndex + 3 + 4;
  122. p->indexList[5] = startIndex + 2 + 4;
  123. zModel->addPolygon(p);
  124. // right side
  125. p = new Polygon3D();
  126. p->indexAnz = 6;
  127. p->indexList = new int[p->indexAnz];
  128. p->indexList[0] = startIndex + 0 + 12;
  129. p->indexList[1] = startIndex + 1 + 12;
  130. p->indexList[2] = startIndex + 2 + 12;
  131. p->indexList[3] = startIndex + 1 + 12;
  132. p->indexList[4] = startIndex + 3 + 12;
  133. p->indexList[5] = startIndex + 2 + 12;
  134. zModel->addPolygon(p);
  135. // top side
  136. p = new Polygon3D();
  137. p->indexAnz = 6;
  138. p->indexList = new int[p->indexAnz];
  139. p->indexList[0] = startIndex + 0 + 16;
  140. p->indexList[1] = startIndex + 1 + 16;
  141. p->indexList[2] = startIndex + 2 + 16;
  142. p->indexList[3] = startIndex + 1 + 16;
  143. p->indexList[4] = startIndex + 3 + 16;
  144. p->indexList[5] = startIndex + 2 + 16;
  145. zModel->addPolygon(p);
  146. // bottom side
  147. p = new Polygon3D();
  148. p->indexAnz = 6;
  149. p->indexList = new int[p->indexAnz];
  150. p->indexList[0] = startIndex + 0 + 20;
  151. p->indexList[1] = startIndex + 1 + 20;
  152. p->indexList[2] = startIndex + 2 + 20;
  153. p->indexList[3] = startIndex + 1 + 20;
  154. p->indexList[4] = startIndex + 3 + 20;
  155. p->indexList[5] = startIndex + 2 + 20;
  156. zModel->addPolygon(p);
  157. }
  158. void makeQuader(Vertex3D* vertecies,
  159. int startIndex,
  160. Vec3<float> pos,
  161. Vec3<float> size,
  162. Model3DData* zModel)
  163. {
  164. float left, right, top, bottom;
  165. // Calculate the screen coordinates of the left side of the bitmap.
  166. left = pos.x + size.x;
  167. // Calculate the screen coordinates of the right side of the bitmap.
  168. right = pos.x;
  169. // Calculate the screen coordinates of the top of the bitmap.
  170. top = pos.z + size.z;
  171. // Calculate the screen coordinates of the bottom of the bitmap.
  172. bottom = pos.z;
  173. float front = pos.y;
  174. float back = pos.y + size.y;
  175. makeQuader(vertecies,
  176. startIndex,
  177. Vec3<float>(left, front, top),
  178. Vec3<float>(right, front, top),
  179. Vec3<float>(left, front, bottom),
  180. Vec3<float>(right, front, bottom),
  181. Vec3<float>(left, back, top),
  182. Vec3<float>(right, back, top),
  183. Vec3<float>(left, back, bottom),
  184. Vec3<float>(right, back, bottom),
  185. zModel);
  186. }
  187. class Block : public Model3D
  188. {
  189. public:
  190. // Konstruktor
  191. // size: Die Größe des Würfels
  192. Block(GraphicsApi* zApi)
  193. {
  194. model = zApi->createModel("block");
  195. model->setAmbientFactor(ambient);
  196. model->setDiffusFactor(diffus);
  197. model->setSpecularFactor(specular);
  198. Vertex3D* vertecies = new Vertex3D[24];
  199. for (int i = 0; i < 24; i++)
  200. vertecies[i].knochenId = 0;
  201. makeQuader(vertecies,
  202. 0,
  203. Vec3<float>(-0.5, -0.5, -0.5),
  204. Vec3<float>(1, 1, 1),
  205. model);
  206. model->setVertecies(vertecies, 24);
  207. model->calculateNormals();
  208. textur = new Model3DTextur();
  209. Bild* b = new Bild();
  210. b->neuBild(10, 10, 0xFFFF5050);
  211. textur->setPolygonTextur(
  212. 0, zApi->createOrGetTextur("blockA", b)); // front
  213. b = new Bild();
  214. b->neuBild(10, 10, 0xFF5050FF);
  215. textur->setPolygonTextur(
  216. 1, zApi->createOrGetTextur("blockC", b)); // left
  217. b = new Bild();
  218. b->neuBild(10, 10, 0xFFA02020);
  219. textur->setPolygonTextur(
  220. 2, zApi->createOrGetTextur("blockB", b)); // back
  221. b = new Bild();
  222. b->neuBild(10, 10, 0xFF2020A0);
  223. textur->setPolygonTextur(
  224. 3, zApi->createOrGetTextur("blockD", b)); // right
  225. b = new Bild();
  226. b->neuBild(10, 10, 0xFF50FF50);
  227. textur->setPolygonTextur(
  228. 4, zApi->createOrGetTextur("blockE", b)); // top
  229. b = new Bild();
  230. b->neuBild(10, 10, 0xFF20A020);
  231. textur->setPolygonTextur(
  232. 5, zApi->createOrGetTextur("blockF", b)); // botom
  233. rend = 1;
  234. }
  235. };
  236. class ObjModel : public Model3D
  237. {
  238. private:
  239. Text modelName;
  240. public:
  241. ObjModel(GraphicsApi* zApi, Text path, Text textur, Text modelName)
  242. : Model3D()
  243. {
  244. M3Datei d("m3/blocks.m3");
  245. Model3DData* data = 0;
  246. d.leseDaten();
  247. Text* p = path.getTeilText(
  248. 0, path.positionVon(".obj/", path.anzahlVon(".obj/") - 1) + 4);
  249. if (d.hatModel(modelName))
  250. {
  251. data = d.ladeModel(modelName, zApi, *p);
  252. }
  253. else
  254. {
  255. ObjFile file(p->getText());
  256. data = zApi->createModel(path);
  257. file.loadModel(path.getText() + p->getLength() + 1, data);
  258. }
  259. p->release();
  260. data->setAmbientFactor(ambient);
  261. data->setDiffusFactor(diffus);
  262. data->setSpecularFactor(specular);
  263. setModelDaten(data);
  264. p = textur.getTeilText(0,
  265. textur.positionVon(".ltdb/", textur.anzahlVon(".ltdb/") - 1) + 5);
  266. LTDBDatei dat;
  267. dat.setDatei(p);
  268. dat.leseDaten(0);
  269. Bild* t = dat.laden(0,
  270. textur.getTeilText(
  271. textur.positionVon(".ltdb/", textur.anzahlVon(".ltdb/") - 1)
  272. + 6));
  273. Model3DTextur* tex = new Model3DTextur();
  274. tex->setPolygonTextur(0, zApi->createOrGetTextur(textur, t));
  275. this->textur = tex;
  276. adjustCenter();
  277. rend = 1;
  278. this->modelName = modelName;
  279. }
  280. void adjustCenter()
  281. {
  282. Vec3<float> maxPos = {-INFINITY, -INFINITY, -INFINITY};
  283. Vec3<float> minPos = {INFINITY, INFINITY, INFINITY};
  284. for (int i = 0; i < model->getVertexAnzahl(); i++)
  285. {
  286. if (model->zVertexBuffer()[i].pos.x < minPos.x)
  287. minPos.x = model->zVertexBuffer()[i].pos.x;
  288. if (model->zVertexBuffer()[i].pos.y < minPos.y)
  289. minPos.y = model->zVertexBuffer()[i].pos.y;
  290. if (model->zVertexBuffer()[i].pos.z < minPos.z)
  291. minPos.z = model->zVertexBuffer()[i].pos.z;
  292. if (model->zVertexBuffer()[i].pos.x > maxPos.x)
  293. maxPos.x = model->zVertexBuffer()[i].pos.x;
  294. if (model->zVertexBuffer()[i].pos.y > maxPos.y)
  295. maxPos.y = model->zVertexBuffer()[i].pos.y;
  296. if (model->zVertexBuffer()[i].pos.z > maxPos.z)
  297. maxPos.z = model->zVertexBuffer()[i].pos.z;
  298. }
  299. Vec3<float> center = minPos + (maxPos - minPos) / 2;
  300. if (center != Vec3<float>(0.f, 0.f, 0.f))
  301. {
  302. for (int i = 0; i < model->getVertexAnzahl(); i++)
  303. {
  304. // !! update of vertex data is not supported by the framework
  305. // and does not update some stored information on the model like
  306. // bounding box and radius
  307. ((Vertex3D*)model->zVertexBuffer())[i].pos -= center;
  308. }
  309. model->zDXVertexBuffer()->setChanged();
  310. model->updateGPUMemory();
  311. }
  312. }
  313. bool tick(double time) override
  314. {
  315. if (getTastenStand(VK_OEM_MINUS))
  316. {
  317. setSize(size - (size - (size * 0.995)) * (time * 3));
  318. }
  319. if (getTastenStand(VK_OEM_PLUS))
  320. {
  321. setSize(size + (size * 1.005 - size) * (time * 3));
  322. }
  323. if (getTastenStand(VK_NUMPAD1))
  324. {
  325. setDrehungX(getDrehung().x + time * 0.1);
  326. }
  327. if (getTastenStand(VK_NUMPAD4))
  328. {
  329. setDrehungX(getDrehung().x - time * 0.1);
  330. }
  331. if (getTastenStand(VK_NUMPAD2))
  332. {
  333. setDrehungY(getDrehung().y + time * 0.1);
  334. }
  335. if (getTastenStand(VK_NUMPAD5))
  336. {
  337. setDrehungY(getDrehung().y - time * 0.1);
  338. }
  339. if (getTastenStand(VK_NUMPAD3))
  340. {
  341. setDrehungZ(getDrehung().z + time * 0.1);
  342. }
  343. if (getTastenStand(VK_NUMPAD6))
  344. {
  345. setDrehungZ(getDrehung().z - time * 0.1);
  346. }
  347. if (getTastenStand(T_Enter))
  348. {
  349. if (size != 1.f || getDrehung() != Vec3<float>(0.f, 0.f, 0.f))
  350. {
  351. // aply scale and rotation on model verticies
  352. Mat4<float> matrix = Mat4<float>::identity()
  353. * Mat4<float>::rotationZ(angle.z)
  354. * Mat4<float>::rotationX(angle.x)
  355. * Mat4<float>::rotationY(angle.y)
  356. * Mat4<float>::scaling(size);
  357. for (int i = 0; i < model->getVertexAnzahl(); i++)
  358. {
  359. // !! update of vertex data is not supported by the
  360. // framework and does not update some stored information on
  361. // the model like bounding box and radius
  362. ((Vertex3D*)model->zVertexBuffer())[i].pos
  363. = matrix * model->zVertexBuffer()[i].pos;
  364. ((Vertex3D*)model->zVertexBuffer())[i].normal
  365. = (matrix * model->zVertexBuffer()[i].normal)
  366. .normalize();
  367. }
  368. model->zDXVertexBuffer()->setChanged();
  369. model->updateGPUMemory();
  370. size = 1.f;
  371. setDrehung(0.f, 0.f, 0.f);
  372. adjustCenter();
  373. }
  374. }
  375. if (getTastenStand(T_Ende))
  376. {
  377. // save model
  378. M3Datei dat("m3/blocks.m3");
  379. dat.leseDaten();
  380. dat.removeModel(modelName);
  381. if (dat.saveModel(model, modelName))
  382. {
  383. std::cout << "erfolgreich gespeichert\n";
  384. }
  385. else
  386. {
  387. std::cout << "fehler beim speichern\n";
  388. }
  389. }
  390. return Model3D::tick(time);
  391. }
  392. };
  393. // Aktion beim schließen des Fensters
  394. void schließen(void* p, void* f)
  395. {
  396. // Stoppe Nachrichten Loop
  397. StopNachrichtenSchleife(((WFenster*)f)->getFensterHandle());
  398. }
  399. int __stdcall Framework::Start(Startparam p)
  400. {
  401. // Fenster erstellen
  402. WNDCLASS wc = F_Normal(p.hinst);
  403. wc.lpszClassName = "3D Creator";
  404. WFenster* f = new WFenster();
  405. f->erstellen(WS_OVERLAPPEDWINDOW, wc);
  406. f->setVSchließAktion(schließen);
  407. f->setAnzeigeModus(SW_SHOWNORMAL);
  408. f->setSize(1300, 820);
  409. f->setPosition(Punkt(100, 100));
  410. // 3D Umgebung erstellen
  411. Bildschirm3D* b
  412. = new Bildschirm3D(dynamic_cast<WFenster*>(f->getThis()), DIRECTX11);
  413. f->setBildschirm(dynamic_cast<Bildschirm*>(b->getThis()));
  414. b->setFillFarbe(0);
  415. b->setTestRend(0);
  416. Welt3D* welt = new Welt3D();
  417. ObjModel* mdl = new ObjModel(b->zGraphicsApi(),
  418. "obj/sebling.obj/Cube",
  419. "tex/blocks.ltdb/torch.png",
  420. "torch");
  421. mdl->setPosition(0, 0, 0);
  422. welt->addZeichnung(mdl);
  423. Block* blk = new Block(b->zGraphicsApi());
  424. blk->setPosition(0, 0, -1);
  425. welt->addZeichnung(blk);
  426. welt->addDiffuseLight(
  427. {Vec3<float>(-0.5f, -0.5f, -0.5f), Vec3<float>(1.f, 1.f, 1.f)});
  428. Kam3D* kamA = new Kam3D(); // look at front
  429. kamA->setBildschirmPosition(10, 10);
  430. kamA->setBildschirmSize(385, 385);
  431. kamA->setPosition(Vec3<float>(0, -10, 0));
  432. kamA->setRotation({-(float)PI / 2.f, -(float)PI, 0});
  433. kamA->setWelt(dynamic_cast<Welt3D*>(welt->getThis()));
  434. b->addKamera(kamA);
  435. Kam3D* kamB = new Kam3D(); // look at left
  436. kamB->setMovementSpeed(1);
  437. kamB->setBildschirmPosition(10, 405);
  438. kamB->setBildschirmSize(385, 385);
  439. kamB->setPosition(Vec3<float>(10, 0, 0));
  440. kamB->setRotation({-PI / 2, (float)PI, (float)PI / 2.f});
  441. kamB->setWelt(dynamic_cast<Welt3D*>(welt->getThis()));
  442. b->addKamera(kamB);
  443. Kam3D* kamC = new Kam3D();
  444. kamC->setBildschirmPosition(405, 10);
  445. kamC->setBildschirmSize(385, 385);
  446. kamC->setPosition(Vec3<float>(0, 0, 10));
  447. kamC->setRotation({-(float)PI, 0, 0});
  448. kamC->setWelt(dynamic_cast<Welt3D*>(welt->getThis()));
  449. b->addKamera(kamC);
  450. Kam3D* kamD = new Kam3D();
  451. kamD->setStyle(
  452. Kam3D::Style::Movable | Kam3D::Style::Rotatable | Kam3D::Style::Tick);
  453. kamD->setBildschirmPosition(405, 405);
  454. kamD->setBildschirmSize(385, 385);
  455. kamD->setPosition(Vec3<float>(0, -10, 0));
  456. kamD->setRotation({-(float)PI / 2.f, -(float)PI, 0});
  457. kamD->setWelt(dynamic_cast<Welt3D*>(welt->getThis()));
  458. b->addKamera(kamD);
  459. LTDSDatei dat;
  460. dat.setPfad(new Text("normal.ltds"));
  461. dat.leseDaten();
  462. Schrift* schrift = dat.ladeSchrift();
  463. TextFeld* kamPos = new TextFeld();
  464. kamPos->setSchriftZ(schrift);
  465. kamPos->setPosition(810, 10);
  466. kamPos->setSize(200, 200);
  467. kamPos->setText("Kamera Position");
  468. kamPos->setStyle(TextFeld::Style::Text);
  469. b->addMember(kamPos);
  470. LRahmen* kamAR = new LRahmen();
  471. kamAR->setPosition(10, 10);
  472. kamAR->setFarbe(0xFFFFFFFF);
  473. kamAR->setRamenBreite(1);
  474. kamAR->setSize(385, 385);
  475. b->addMember(kamAR);
  476. LRahmen* kamBR = new LRahmen();
  477. kamBR->setPosition(404, 10);
  478. kamBR->setFarbe(0xFFFFFFFF);
  479. kamBR->setRamenBreite(1);
  480. kamBR->setSize(385, 385);
  481. b->addMember(kamBR);
  482. LRahmen* kamCR = new LRahmen();
  483. kamCR->setPosition(10, 405);
  484. kamCR->setFarbe(0xFFFFFFFF);
  485. kamCR->setRamenBreite(1);
  486. kamCR->setSize(385, 385);
  487. b->addMember(kamCR);
  488. LRahmen* kamDR = new LRahmen();
  489. kamDR->setPosition(405, 405);
  490. kamDR->setFarbe(0xFFFFFFFF);
  491. kamDR->setRamenBreite(1);
  492. kamDR->setSize(385, 385);
  493. b->addMember(kamDR);
  494. // Render Loop starten
  495. RenderTh* r = new RenderTh();
  496. r->setMaxFps(10000);
  497. r->setBildschirm(dynamic_cast<Bildschirm*>(b->getThis()));
  498. r->setTickFunktion([b, kamD, kamA, kamB, kamC, kamPos](
  499. void*, void*, double t) {
  500. if (Framework::getTastenStand('1'))
  501. {
  502. kamA->setStyle(Kam3D::Style::Movable | Kam3D::Style::Rotatable
  503. | Kam3D::Style::Tick);
  504. kamB->removeStyle(Kam3D::Style::Movable | Kam3D::Style::Rotatable
  505. | Kam3D::Style::Tick);
  506. kamC->removeStyle(Kam3D::Style::Movable | Kam3D::Style::Rotatable
  507. | Kam3D::Style::Tick);
  508. kamD->removeStyle(Kam3D::Style::Movable | Kam3D::Style::Rotatable
  509. | Kam3D::Style::Tick);
  510. }
  511. if (Framework::getTastenStand('2'))
  512. {
  513. kamA->removeStyle(Kam3D::Style::Movable | Kam3D::Style::Rotatable
  514. | Kam3D::Style::Tick);
  515. kamB->setStyle(Kam3D::Style::Movable | Kam3D::Style::Rotatable
  516. | Kam3D::Style::Tick);
  517. kamC->removeStyle(Kam3D::Style::Movable | Kam3D::Style::Rotatable
  518. | Kam3D::Style::Tick);
  519. kamD->removeStyle(Kam3D::Style::Movable | Kam3D::Style::Rotatable
  520. | Kam3D::Style::Tick);
  521. }
  522. if (Framework::getTastenStand('3'))
  523. {
  524. kamA->removeStyle(Kam3D::Style::Movable | Kam3D::Style::Rotatable
  525. | Kam3D::Style::Tick);
  526. kamB->removeStyle(Kam3D::Style::Movable | Kam3D::Style::Rotatable
  527. | Kam3D::Style::Tick);
  528. kamC->setStyle(Kam3D::Style::Movable | Kam3D::Style::Rotatable
  529. | Kam3D::Style::Tick);
  530. kamD->removeStyle(Kam3D::Style::Movable | Kam3D::Style::Rotatable
  531. | Kam3D::Style::Tick);
  532. }
  533. if (Framework::getTastenStand('4'))
  534. {
  535. kamA->removeStyle(Kam3D::Style::Movable | Kam3D::Style::Rotatable
  536. | Kam3D::Style::Tick);
  537. kamB->removeStyle(Kam3D::Style::Movable | Kam3D::Style::Rotatable
  538. | Kam3D::Style::Tick);
  539. kamC->removeStyle(Kam3D::Style::Movable | Kam3D::Style::Rotatable
  540. | Kam3D::Style::Tick);
  541. kamD->setStyle(Kam3D::Style::Movable | Kam3D::Style::Rotatable
  542. | Kam3D::Style::Tick);
  543. }
  544. Text txt = Text("A: ") + kamA->getWorldPosition().x + ", "
  545. + kamA->getWorldPosition().y + ", "
  546. + kamA->getWorldPosition().z + "\n";
  547. txt += Text("B: ") + kamB->getWorldPosition().x + ", "
  548. + kamB->getWorldPosition().y + ", " + kamB->getWorldPosition().z
  549. + "\n";
  550. txt += Text("C: ") + kamC->getWorldPosition().x + ", "
  551. + kamC->getWorldPosition().y + ", " + kamC->getWorldPosition().z
  552. + "\n";
  553. txt += Text("D: ") + kamD->getWorldPosition().x + ", "
  554. + kamD->getWorldPosition().y + ", " + kamD->getWorldPosition().z
  555. + "\n";
  556. kamPos->setText(txt);
  557. });
  558. r->beginn();
  559. // Nachrichten Loop starten und warten
  560. StartNachrichtenSchleife();
  561. // Speicher Freigeben
  562. r->beenden();
  563. r->release();
  564. b->release();
  565. f->setBildschirm(0);
  566. f->zerstören();
  567. f->release();
  568. welt->release();
  569. return 0;
  570. }