Advertisement
Guest User

Untitled

a guest
Oct 24th, 2019
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.96 KB | None | 0 0
  1. nclude "Laborator4.h"
  2.  
  3. #include <vector>
  4. #include <string>
  5. #include <iostream>
  6.  
  7. #include <Core/Engine.h>
  8. #include "Transform3D.h"
  9.  
  10. using namespace std;
  11.  
  12. Laborator4::Laborator4()
  13. {
  14. }
  15.  
  16. Laborator4::~Laborator4()
  17. {
  18. }
  19.  
  20. void Laborator4::Init()
  21. {
  22. polygonMode = GL_FILL;
  23.  
  24. Mesh* mesh = new Mesh("box");
  25. mesh->LoadMesh(RESOURCE_PATH::MODELS + "Primitives", "box.obj");
  26. meshes[mesh->GetMeshID()] = mesh;
  27.  
  28. // initialize tx, ty and tz (the translation steps)
  29. translateX = 0;
  30. translateY = 0;
  31. translateZ = 0;
  32.  
  33. // initialize sx, sy and sz (the scale factors)
  34. scaleX = 1;
  35. scaleY = 1;
  36. scaleZ = 1;
  37.  
  38. // initialize angularSteps
  39. angularStepOX = 0;
  40. angularStepOY = 0;
  41. angularStepOZ = 0;
  42. }
  43.  
  44. void Laborator4::FrameStart()
  45. {
  46. // clears the color buffer (using the previously set color) and depth buffer
  47. glClearColor(0, 0, 0, 1);
  48. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  49.  
  50. glm::ivec2 resolution = window->GetResolution();
  51. // sets the screen area where to draw
  52. glViewport(0, 0, resolution.x, resolution.y);
  53. }
  54.  
  55. void Laborator4::Update(float deltaTimeSeconds)
  56. {
  57. glLineWidth(3);
  58. glPointSize(5);
  59. glPolygonMode(GL_FRONT_AND_BACK, polygonMode);
  60.  
  61. modelMatrix = glm::mat4(1);
  62. modelMatrix *= Transform3D::Translate(-2.5f, 0.5f,-1.5f);
  63. modelMatrix *= Transform3D::Translate(translateX, translateY, translateZ);
  64. RenderMesh(meshes["box"], shaders["VertexNormal"], modelMatrix);
  65.  
  66. modelMatrix = glm::mat4(1);
  67. modelMatrix *= Transform3D::Translate(0.0f, 0.5f, -1.5f);
  68. modelMatrix *= Transform3D::Scale(scaleX, scaleY, scaleZ);
  69. RenderMesh(meshes["box"], shaders["Simple"], modelMatrix);
  70.  
  71. modelMatrix = glm::mat4(1);
  72. modelMatrix *= Transform3D::Translate(2.5f, 0.5f, -1.5f);
  73. modelMatrix *= Transform3D::RotateOX(angularStepOX);
  74. modelMatrix *= Transform3D::RotateOY(angularStepOY);
  75. modelMatrix *= Transform3D::RotateOZ(angularStepOZ);
  76. RenderMesh(meshes["box"], shaders["VertexNormal"], modelMatrix);
  77. }
  78.  
  79. void Laborator4::FrameEnd()
  80. {
  81. DrawCoordinatSystem();
  82. }
  83.  
  84. void Laborator4::OnInputUpdate(float deltaTime, int mods)
  85. {
  86. // TODO
  87. }
  88.  
  89. void Laborator4::OnKeyPress(int key, int mods)
  90. {
  91. // add key press event
  92. if (key == GLFW_KEY_SPACE)
  93. {
  94. switch (polygonMode)
  95. {
  96. case GL_POINT:
  97. polygonMode = GL_FILL;
  98. break;
  99. case GL_LINE:
  100. polygonMode = GL_POINT;
  101. break;
  102. default:
  103. polygonMode = GL_LINE;
  104. break;
  105. }
  106. }
  107. }
  108.  
  109. void Laborator4::OnKeyRelease(int key, int mods)
  110. {
  111. // add key release event
  112. }
  113.  
  114. void Laborator4::OnMouseMove(int mouseX, int mouseY, int deltaX, int deltaY)
  115. {
  116. // add mouse move event
  117. }
  118.  
  119. void Laborator4::OnMouseBtnPress(int mouseX, int mouseY, int button, int mods)
  120. {
  121. // add mouse button press event
  122. }
  123.  
  124. void Laborator4::OnMouseBtnRelease(int mouseX, int mouseY, int button, int mods)
  125. {
  126. // add mouse button release event
  127. }
  128.  
  129. void Laborator4::OnMouseScroll(int mouseX, int mouseY, int offsetX, int offsetY)
  130. {
  131. }
  132.  
  133. void Laborator4::OnWindowResize(int width, int height)
  134. {
  135. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement