Mesh Overlay.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /******************************************************************************
  2. Use 'MeshOverlay' for rendering semi transparent images on solid surfaces (like bullet holes).
  3. /******************************************************************************/
  4. struct MeshOverlay // Mesh Overlay - used for rendering semi transparent images on solid surfaces (like bullet holes), this is an alternative to 'Decal' which affects also nearby objects
  5. {
  6. Bool createStatic (C Mesh &mesh, C MaterialPtr &material, C Matrix &overlay_matrix, C Matrix *mesh_matrix=null); // create from source 'mesh', 'material'=overlay material, 'overlay_matrix'=matrix of the overlay in world space (with 'overlay_matrix.x overlay_matrix.y' being the surface vectors and 'overlay_matrix.z' being the direction vector, length of all the vectors determines overlay size), 'mesh_matrix'=source mesh matrix at the moment of applying the overlay (if null 'MatrixIdentity' will be used), returns false when no mesh has been created
  7. Bool createAnimated(C Mesh &mesh, C MaterialPtr &material, C Matrix &overlay_matrix, C Matrix *mesh_matrix=null); // create from source 'mesh', 'material'=overlay material, 'overlay_matrix'=matrix of the overlay in world space (with 'overlay_matrix.x overlay_matrix.y' being the surface vectors and 'overlay_matrix.z' being the direction vector, length of all the vectors determines overlay size), 'mesh_matrix'=source mesh matrix at the moment of applying the overlay (if null 'MatrixIdentity' will be used), returns false when no mesh has been created
  8. #if EE_PRIVATE
  9. void zero ();
  10. void setShader();
  11. void setParams(Flt alpha)C;
  12. #endif
  13. // get / set
  14. MeshOverlay& material(C MaterialPtr &material); C MaterialPtr& material()C {return _material;} // set/get material
  15. // draw, 'MeshOverlay' should be drawn in each frame with the same 'Matrix' or 'AnimatedSkeleton' as the source 'mesh' from which 'MeshOverlay' has been created, drawing should be called only in RM_OVERLAY rendering mode, doesn't use automatic Frustum culling
  16. void draw( Flt alpha=1)C; // draw with current matrix , 'alpha'=opacity
  17. void draw(C MatrixM &matrix , Flt alpha=1)C; // draw with 'matrix' matrix , 'alpha'=opacity
  18. void draw(C AnimatedSkeleton &anim_skel, Flt alpha=1)C; // draw with 'anim_skel' matrixes, 'alpha'=opacity
  19. // io
  20. Bool save(File &f, CChar *path=null)C; // save, 'path'=path at which resource is located (this is needed so that the sub-resources can be accessed with relative path), false on fail
  21. Bool load(File &f, CChar *path=null) ; // load, 'path'=path at which resource is located (this is needed so that the sub-resources can be accessed with relative path), false on fail
  22. MeshOverlay& del(); // delete manually
  23. MeshOverlay();
  24. #if !EE_PRIVATE
  25. private:
  26. #endif
  27. struct Lod
  28. {
  29. Flt dist2;
  30. MeshRender mshr;
  31. };
  32. Vec _lod_center;
  33. Extent _ext;
  34. Matrix _matrix;
  35. Mems<Lod> _lods;
  36. MaterialPtr _material;
  37. Shader *_shader;
  38. #if EE_PRIVATE
  39. C MeshRender& getDrawLod(C Matrix &matrix)C;
  40. C MeshRender& getDrawLod(C MatrixM &matrix)C;
  41. #endif
  42. };
  43. /******************************************************************************/