nucLeaRsc2

Untitled

Jan 19th, 2015
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.83 KB | None | 0 0
  1. void createShape(){
  2.  
  3. double height = this->height + this->length;
  4. // piciorul 1
  5. this->colors = glm::vec3(0.1, 0.1, 0.9);
  6. this->addVertex(0.0, 0.0, 0.0);
  7. this->colors = glm::vec3(0.6, 0.1, 0.2);
  8. this->addVertex(0.0, 0.0, length);
  9. this->colors = glm::vec3(0.1, 0.1, 0.9);
  10. this->addVertex(0.0f, this->height + 2 * length / TAN(angle), (double)length);
  11. this->colors = glm::vec3(0.6, 0.1, 0.2);
  12. this->addVertex(0.0, this->height + length / TAN(angle), 0.0);
  13.  
  14. // piciorul 2
  15. this->colors = glm::vec3(0.1, 0.1, 0.9);
  16. this->addVertex(length, 0.0, 0.0);
  17. this->colors = glm::vec3(0.6, 0.1, 0.2);
  18. this->addVertex(length, 0.0, length);
  19. this->colors = glm::vec3(0.1, 0.1, 0.9);
  20. this->addVertex((double)length, this->height + 2 * length / TAN(angle), (double)length);
  21. this->colors = glm::vec3(0.6, 0.1, 0.2);
  22. this->addVertex(length, this->height + length / TAN(angle), 0.0);
  23.  
  24. this->addIndex(0, 1, 2);
  25. this->addIndex(0, 2, 3);
  26. this->addIndex(4, 5, 6);
  27. this->addIndex(4, 6, 7);
  28.  
  29. this->colors = glm::vec3(1, 0.3, 0.1);
  30. double startHeight, newHeight;
  31. double startZ = this->height - height, newZ;
  32.  
  33. startHeight = this->height;
  34. int size;
  35. while (startZ < 100){
  36. size = this->vertices.size();
  37.  
  38. this->addVertex(0.0f, startHeight, startZ);
  39. this->addVertex((float)length, startHeight, startZ);
  40.  
  41. newZ = startZ + 1;
  42. newHeight = startHeight + abs(newZ-startZ) * COS(angle) / SIN(angle);
  43. this->addVertex((float)length, newHeight, newZ);
  44. this->addVertex(0.0f, newHeight, newZ);
  45.  
  46. startHeight = newHeight;
  47. startZ = newZ;
  48.  
  49. this->addIndex(size, size+1, size+2);
  50. this->addIndex(size, size+2, size+3);
  51.  
  52. }
  53.  
  54. size = this->vertices.size();
  55.  
  56. //piciorul 3
  57. this->colors = glm::vec3(0.1, 0.1, 0.9);
  58. this->addVertex(0.0, 0.0, startZ-length);
  59. this->colors = glm::vec3(0.6, 0.1, 0.2);
  60. this->addVertex(0.0, 0.0, startZ);
  61. this->colors = glm::vec3(0.1, 0.1, 0.9);
  62. this->addVertex(0.0f, startHeight, (double)startZ);
  63. this->colors = glm::vec3(0.6, 0.1, 0.2);
  64. this->addVertex(0.0, startHeight - length * COS(angle) / SIN(angle), startZ - length);
  65.  
  66. // piciorul 4
  67. this->colors = glm::vec3(0.1, 0.1, 0.9);
  68. this->addVertex(length, 0.0, startZ-length);
  69. this->colors = glm::vec3(0.6, 0.1, 0.2);
  70. this->addVertex(length, 0.0, startZ);
  71. this->colors = glm::vec3(0.1, 0.1, 0.9);
  72. this->addVertex((double)length, startHeight, (double)startZ);
  73. this->colors = glm::vec3(0.6, 0.1, 0.2);
  74. this->addVertex(length, startHeight - length * COS(angle) / SIN(angle), startZ - length);
  75.  
  76. this->addIndex(size, size+1, size+2);
  77. this->addIndex(size, size+2, size+3);
  78. this->addIndex(size+4, size+5, size+6);
  79. this->addIndex(size+4, size+6, size+7);
  80.  
  81.  
  82. this->endPosition = glm::vec3( startPosition.x, startHeight + startPosition.y, startZ + startPosition.z);
  83. }
Advertisement
Add Comment
Please, Sign In to add comment