Guest User

Untitled

a guest
Feb 15th, 2013
31
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. static void makeFastFace(TileSpec tile, u16 li0, u16 li1, u16 li2, u16 li3,
  2. v3f p, v3s16 dir, v3f scale, u8 light_source, core::array<FastFace> &dest)
  3. {
  4. FastFace face;
  5.  
  6. // Position is at the center of the cube.
  7. v3f pos = p * BS;
  8.  
  9. v3f vertex_pos[4];
  10. v3s16 vertex_dirs[4];
  11. getNodeVertexDirs(dir, vertex_dirs);
  12. v3s16 t;
  13. switch (tile.rotation)
  14. {
  15. case 0:
  16. break;
  17. case 1: //R90
  18. t = vertex_dirs[0];
  19. vertex_dirs[0] = vertex_dirs[3];
  20. vertex_dirs[3] = vertex_dirs[2];
  21. vertex_dirs[2] = vertex_dirs[1];
  22. vertex_dirs[1] = t;
  23. break;
  24. case 2:
  25. break;
  26. case 3: //R270
  27. t = vertex_dirs[0];
  28. vertex_dirs[0] = vertex_dirs[1];
  29. vertex_dirs[1] = vertex_dirs[2];
  30. vertex_dirs[2] = vertex_dirs[3];
  31. vertex_dirs[3] = t;
  32. break;
  33. case 4:
  34. break;
  35. case 5:
  36. break;
  37. case 6:
  38. break;
  39. case 7:
  40. break;
  41. case 8:
  42. break;
  43.  
  44. default:
  45. break;
  46. }
  47. for(u16 i=0; i<4; i++)
  48. {
  49. vertex_pos[i] = v3f(
  50. BS/2*vertex_dirs[i].X,
  51. BS/2*vertex_dirs[i].Y,
  52. BS/2*vertex_dirs[i].Z
  53. );
  54. }
  55.  
  56. for(u16 i=0; i<4; i++)
  57. {
  58. vertex_pos[i].X *= scale.X;
  59. vertex_pos[i].Y *= scale.Y;
  60. vertex_pos[i].Z *= scale.Z;
  61. vertex_pos[i] += pos;
  62. }
  63.  
  64. f32 abs_scale = 1.;
  65. if (scale.X < 0.999 || scale.X > 1.001) abs_scale = scale.X;
  66. else if(scale.Y < 0.999 || scale.Y > 1.001) abs_scale = scale.Y;
  67. else if(scale.Z < 0.999 || scale.Z > 1.001) abs_scale = scale.Z;
  68.  
  69. v3f normal(dir.X, dir.Y, dir.Z);
  70.  
  71. u8 alpha = tile.alpha;
  72.  
  73. float x0 = tile.texture.pos.X;
  74. float y0 = tile.texture.pos.Y;
  75. float w = tile.texture.size.X;
  76. float h = tile.texture.size.Y;
  77.  
  78. face.vertices[0] = video::S3DVertex(vertex_pos[0], normal,
  79. MapBlock_LightColor(alpha, li0, light_source),
  80. core::vector2d<f32>(x0+w*abs_scale, y0+h));
  81. face.vertices[1] = video::S3DVertex(vertex_pos[1], normal,
  82. MapBlock_LightColor(alpha, li1, light_source),
  83. core::vector2d<f32>(x0, y0+h));
  84. face.vertices[2] = video::S3DVertex(vertex_pos[2], normal,
  85. MapBlock_LightColor(alpha, li2, light_source),
  86. core::vector2d<f32>(x0, y0));
  87. face.vertices[3] = video::S3DVertex(vertex_pos[3], normal,
  88. MapBlock_LightColor(alpha, li3, light_source),
  89. core::vector2d<f32>(x0+w*abs_scale, y0));
  90.  
  91. face.tile = tile;
  92.  
  93. dest.push_back(face);
  94. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×