1 | // |
---|

2 | // Orbital |
---|

3 | // |
---|

4 | // Copyright: (c) 2012 Various People |
---|

5 | // |
---|

6 | |
---|

7 | /* FIXME: this file is pure crap; it's only a test. */ |
---|

8 | |
---|

9 | #if !defined __STARFIELD_H__ |
---|

10 | #define __STARFIELD_H__ |
---|

11 | |
---|

12 | class StarField : public WorldEntity |
---|

13 | { |
---|

14 | public: |
---|

15 | StarField(int count3, int count4, float z3, float z4, float speed3, float speed4) |
---|

16 | : m_ready(false) |
---|

17 | { |
---|

18 | m_star3_mesh.SendCommand("sc1,1,1,1,scb1,1,1,0,ad4,1.8,1"); |
---|

19 | m_star4_mesh.SendCommand("sc1,1,1,1,scb1,1,1,0,ad3,0.8,1"); |
---|

20 | |
---|

21 | for (int i = 0; i < count3; i++) |
---|

22 | m_star3.Push(vec3(RandF(800.f) - 400.f, z3, RandF(600.f) - 300.f), |
---|

23 | vec3(0.f, 0.f, speed3), |
---|

24 | RandF(0.f, 10.f)); |
---|

25 | |
---|

26 | for (int i = 0; i < count4; i++) |
---|

27 | m_star4.Push(vec3(RandF(800.f) - 400.f, z4, RandF(600.f) - 300.f), |
---|

28 | vec3(0.f, 0.f, speed4), |
---|

29 | RandF(0.f, 10.f)); |
---|

30 | } |
---|

31 | |
---|

32 | ~StarField() |
---|

33 | { |
---|

34 | } |
---|

35 | |
---|

36 | char const *GetName() { return "<particlesystem>"; } |
---|

37 | |
---|

38 | protected: |
---|

39 | virtual void TickGame(float seconds) |
---|

40 | { |
---|

41 | WorldEntity::TickGame(seconds); |
---|

42 | |
---|

43 | for (int i = 0; i < m_star3.Count(); i++) |
---|

44 | { |
---|

45 | m_star3[i].m3 += 10.f * seconds; |
---|

46 | m_star3[i].m1 += seconds * m_star3[i].m2; |
---|

47 | if (m_star3[i].m1.z > 300.f) |
---|

48 | m_star3[i].m1.z = -300.f; |
---|

49 | } |
---|

50 | |
---|

51 | for (int i = 0; i < m_star4.Count(); i++) |
---|

52 | { |
---|

53 | m_star4[i].m3 += 10.f * seconds; |
---|

54 | m_star4[i].m1 += seconds * m_star4[i].m2; |
---|

55 | if (m_star4[i].m1.z > 300.f) |
---|

56 | m_star4[i].m1.z = -300.f; |
---|

57 | } |
---|

58 | } |
---|

59 | |
---|

60 | virtual void TickDraw(float seconds) |
---|

61 | { |
---|

62 | WorldEntity::TickDraw(seconds); |
---|

63 | |
---|

64 | if (!m_ready) |
---|

65 | { |
---|

66 | m_star3_mesh.SendCommand("irb"); |
---|

67 | m_star4_mesh.SendCommand("irb"); |
---|

68 | m_ready = true; |
---|

69 | } |
---|

70 | |
---|

71 | for (int i = 0; i < m_star3.Count(); i++) |
---|

72 | { |
---|

73 | mat4 model = mat4::translate(m_star3[i].m1) |
---|

74 | * mat4::rotate(m_star3[i].m3, 0.f, 1.f, 0.f); |
---|

75 | |
---|

76 | m_star3_mesh.Render(model); |
---|

77 | } |
---|

78 | |
---|

79 | for (int i = 0; i < m_star4.Count(); i++) |
---|

80 | { |
---|

81 | mat4 model = mat4::translate(m_star4[i].m1) |
---|

82 | * mat4::rotate(m_star4[i].m3, 0.f, 1.f, 0.f); |
---|

83 | |
---|

84 | m_star4_mesh.Render(model); |
---|

85 | } |
---|

86 | } |
---|

87 | |
---|

88 | private: |
---|

89 | Mesh m_star3_mesh, m_star4_mesh; |
---|

90 | Array<vec3, vec3, float> m_star3, m_star4; |
---|

91 | bool m_ready; |
---|

92 | }; |
---|

93 | |
---|

94 | #endif /* __STARFIELD_H__ */ |
---|

95 | |
---|