Advertisement
Guest User

Untitled

a guest
Jan 21st, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. void drawSpring(float x, float y, float z) {
  2. glPushMatrix();
  3. glTranslatef(x, y, z);
  4. glRotatef(90, 1, 0, 0);
  5. glBegin(GL_QUADS);
  6. glColor3f(1.0, 0, 0);
  7.  
  8. for (int t = 0; t < 8 * 180; t += 10) {
  9. for (int u = 0; u < 2 * 180; u += 10) {
  10. float x = cos(t*3.14 / 180)*(3 + cos(u * 3.14 / 180));
  11. float y = sin(t * 3.14 / 180)*(3 + cos(u * 3.14 / 180));
  12. float z = (0.45 + 0.15 * DEIKS)*t * 3.14 / 180 + sin(u * 3.14 / 180);
  13. glVertex3f(x, y, z);
  14. u += 10;
  15. x = cos(t*3.14 / 180)*(3 + cos(u * 3.14 / 180));
  16. y = sin(t * 3.14 / 180)*(3 + cos(u * 3.14 / 180));
  17. z = (0.45 + 0.15 * DEIKS)*t * 3.14 / 180 + sin(u * 3.14 / 180);
  18. glVertex3f(x, y, z);
  19. t += 10;
  20. x = cos(t*3.14 / 180)*(3 + cos(u * 3.14 / 180));
  21. y = sin(t * 3.14 / 180)*(3 + cos(u * 3.14 / 180));
  22. z = (0.45 + 0.15 * DEIKS)*t * 3.14 / 180 + sin(u * 3.14 / 180);
  23. glVertex3f(x, y, z);
  24. u -= 10;
  25. x = cos(t*3.14 / 180)*(3 + cos(u * 3.14 / 180));
  26. y = sin(t * 3.14 / 180)*(3 + cos(u * 3.14 / 180));
  27. z = (0.45 + 0.15 * DEIKS)*t * 3.14 / 180 + sin(u * 3.14 / 180);
  28. glVertex3f(x, y, z);
  29. t -= 10;
  30. }
  31. }
  32. glEnd();
  33. glPopMatrix();
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement