World Terrain.cpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /******************************************************************************/
  2. #include "stdafx.h"
  3. namespace EE{
  4. namespace Game{
  5. /******************************************************************************/
  6. struct Overlay
  7. {
  8. Flt time ;
  9. Extent ext ;
  10. C MaterialPtr *material;
  11. Matrix matrix ;
  12. };
  13. static void AddOverlay(Cell<Area> &cell, Overlay &overlay)
  14. {
  15. C Area &area=cell(); if(area.loaded() && area._data)
  16. {
  17. C MeshGroup &mshg=area._data->mesh; FREPA(mshg)
  18. {
  19. C Mesh &mesh=mshg.meshes[i]; if(Cuts(overlay.ext, mesh.ext))
  20. {
  21. MeshOverlay mo; if(mo.createStatic(mesh, *overlay.material, overlay.matrix))
  22. {
  23. WorldManager::MeshOverlay2 &mo2 =area.world()->_mesh_overlays.New(); mo2.time=overlay.time;
  24. MeshOverlay &mo2_=mo2; Swap(mo2_, mo);
  25. }
  26. }
  27. }
  28. }
  29. }
  30. WorldManager& WorldManager::terrainAddOverlay(C MaterialPtr &material, C Matrix &overlay_matrix, Flt time_to_fade_out)
  31. {
  32. if(material)
  33. {
  34. Overlay overlay;
  35. overlay.time = time_to_fade_out;
  36. overlay.material=&material;
  37. overlay.ext.set(1)*=overlay_matrix;
  38. overlay.matrix=overlay_matrix;
  39. _grid.func(worldToArea(overlay.ext.rectXZ()), AddOverlay, overlay);
  40. }
  41. return T;
  42. }
  43. /******************************************************************************/
  44. WorldManager& WorldManager::terrainAddDecal(C Color &color, C MaterialPtr &material, C Matrix &decal_matrix, Flt time_to_fade_out)
  45. {
  46. if(material)
  47. {
  48. Decal2 &decal=_decals.New();
  49. decal.time =time_to_fade_out;
  50. decal.terrain_only=true;
  51. decal.color =color.asVec4();
  52. decal.matrix =decal_matrix;
  53. decal.material (material);
  54. }
  55. return T;
  56. }
  57. /******************************************************************************/
  58. }}
  59. /******************************************************************************/