clouds.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. Minetest
  3. Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU Lesser General Public License as published by
  6. the Free Software Foundation; either version 2.1 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public License along
  13. with this program; if not, write to the Free Software Foundation, Inc.,
  14. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  15. */
  16. #ifndef CLOUDS_HEADER
  17. #define CLOUDS_HEADER
  18. #include "irrlichttypes_extrabloated.h"
  19. #include <iostream>
  20. #include "constants.h"
  21. class Clouds : public scene::ISceneNode
  22. {
  23. public:
  24. Clouds(
  25. scene::ISceneNode* parent,
  26. scene::ISceneManager* mgr,
  27. s32 id,
  28. u32 seed,
  29. s16 cloudheight=0
  30. );
  31. ~Clouds();
  32. /*
  33. ISceneNode methods
  34. */
  35. virtual void OnRegisterSceneNode();
  36. virtual void render();
  37. virtual const core::aabbox3d<f32>& getBoundingBox() const
  38. {
  39. return m_box;
  40. }
  41. virtual u32 getMaterialCount() const
  42. {
  43. return 1;
  44. }
  45. virtual video::SMaterial& getMaterial(u32 i)
  46. {
  47. return m_material;
  48. }
  49. /*
  50. Other stuff
  51. */
  52. void step(float dtime);
  53. void update(v2f camera_p, video::SColorf color);
  54. void updateCameraOffset(v3s16 camera_offset)
  55. {
  56. m_camera_offset = camera_offset;
  57. m_box = core::aabbox3d<f32>(-BS * 1000000, m_cloud_y - BS - BS * camera_offset.Y, -BS * 1000000,
  58. BS * 1000000, m_cloud_y + BS - BS * camera_offset.Y, BS * 1000000);
  59. }
  60. private:
  61. video::SMaterial m_material;
  62. core::aabbox3d<f32> m_box;
  63. float m_cloud_y;
  64. video::SColorf m_color;
  65. u32 m_seed;
  66. v2f m_camera_pos;
  67. float m_time;
  68. v3s16 m_camera_offset;
  69. };
  70. #endif