Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.96 KB | None | 0 0
  1. package zx.opengles.meshes;
  2.  
  3. /**
  4. * Created by student on 23.11.2017.
  5. */
  6.  
  7. public class TexturedPyramidMesh extends BaseMesh {
  8.  
  9. public TexturedPyramidMesh(){
  10. final float[] positionData = {
  11. // Przednia ściana
  12. -1.0f, -1.0f, 1.0f,
  13. 1.0f, -1.0f, 1.0f,
  14. 0.0f, 1.0f, 0.0f,
  15.  
  16. // Prawa ściana
  17. 1.0f, -1.0f, 1.0f,
  18. 1.0f, -1.0f, -1.0f,
  19. 0.0f, 1.0f, 0.0f,
  20.  
  21. // Tylna ściana
  22. 1.0f, -1.0f, -1.0f,
  23. -1.0f, -1.0f, -1.0f,
  24. 0.0f, 1.0f, 0.0f,
  25.  
  26. // Lewa ściana
  27. -1.0f, -1.0f, -1.0f,
  28. -1.0f, -1.0f, 1.0f,
  29. 0.0f, 1.0f, 0.0f,
  30.  
  31. // Dolna ściana
  32. 1.0f, -1.0f, -1.0f,
  33. 1.0f, -1.0f, 1.0f,
  34. -1.0f, -1.0f, -1.0f,
  35. 1.0f, -1.0f, 1.0f,
  36. -1.0f, -1.0f, 1.0f,
  37. -1.0f, -1.0f, -1.0f
  38. };
  39.  
  40.  
  41. // Współrzędne tekstury są takie same dla wszystkich ścian.
  42. final float[] texCoordData = {
  43. 0.0f, 0.0f,
  44. 1.0f, 0.0f,
  45. 0.5f, 1.0f,
  46.  
  47. 0.0f, 0.0f,
  48. 1.0f, 0.0f,
  49. 0.5f, 1.0f,
  50.  
  51. 0.0f, 0.0f,
  52. 1.0f, 0.0f,
  53. 0.5f, 1.0f,
  54.  
  55. 0.0f, 0.0f,
  56. 1.0f, 0.0f,
  57. 0.5f, 1.0f,
  58.  
  59. 0.0f, 0.0f,
  60. 1.0f, 0.0f,
  61. 0.5f, 1.0f,
  62.  
  63. 0.0f, 0.0f,
  64. 0.0f, 1.0f,
  65. 1.0f, 0.0f,
  66. 0.0f, 1.0f,
  67. 1.0f, 1.0f,
  68. 1.0f, 0.0f
  69. };
  70.  
  71. final float[] normalData = {
  72. // Przednia ściana
  73. 0.0f, 0.0f, 1.0f,
  74. 0.0f, 0.0f, 1.0f,
  75. 0.0f, 0.0f, 1.0f,
  76.  
  77. // Prawa ściana
  78. 0.0f, 0.0f, -1.0f,
  79. 0.0f, 0.0f, -1.0f,
  80. 0.0f, 0.0f, -1.0f,
  81.  
  82. // Tylna ściana
  83. 0.0f, 0.0f, -1.0f,
  84. 0.0f, 0.0f, -1.0f,
  85. 0.0f, 0.0f, -1.0f,
  86.  
  87. // Lewa ściana
  88. -1.0f, 0.0f, 0.0f,
  89. -1.0f, 0.0f, 0.0f,
  90. -1.0f, 0.0f, 0.0f,
  91.  
  92. // Górna ściana
  93. 0.0f, 1.0f, 0.0f,
  94. 0.0f, 1.0f, 0.0f,
  95. 0.0f, 1.0f, 0.0f,
  96.  
  97. // Dolna ściana
  98. 0.0f, -1.0f, 0.0f,
  99. 0.0f, -1.0f, 0.0f,
  100. 0.0f, -1.0f, 0.0f,
  101. 0.0f, -1.0f, 0.0f,
  102. 0.0f, -1.0f, 0.0f,
  103. 0.0f, -1.0f, 0.0f
  104. };
  105.  
  106.  
  107. numberOfVertices = 18;
  108.  
  109. positionBuffer = createBuffer(positionData);
  110. texCoordsBuffer = createBuffer(texCoordData);
  111. normalBuffer = createBuffer(normalData);
  112. }
  113. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement