Changeset 1390
 Timestamp:
 May 14, 2012, 2:14:43 PM (9 years ago)
 Location:
 trunk/orbital
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

trunk/orbital/shiny.lolfx
r1389 r1390 95 95 float4 real_color = in_Color; 96 96 #endif 97 real_color = in_Damage * float4(1.2, 0.2, 0.2, 1.0)97 real_color = in_Damage * float4(1.2, 1.2, 1.2, 1.0) 98 98 + (1.0  in_Damage) * real_color; 99 99 pass_Color = real_color * float4(light, 1.0); 
trunk/orbital/snake.h
r1379 r1390 39 39 /* The last node is actually the tail */ 40 40 for (int i = 0; i < nodes; i++) 41 m_nodes.Push(m_rotation.transform(vec3(12.f, 0.f, 0.f)), 0.f); 42 m_nodes.Push(vec3(0.f, 0.f, 0.f), 45.f); 41 m_nodes.Push(m_rotation.transform(vec3(12.f, 0.f, 0.f)), 42 0.f, 100.f, 0.f); 43 m_nodes.Push(vec3(0.f, 0.f, 0.f), 45.f, 100.f, 0.f); 43 44 } 44 45 … … 49 50 char const *GetName() { return "<snake>"; } 50 51 51 52 53 54 55 56 52 vec3 GetBarycenter() 53 { 54 vec3 new_camera_pos = m_position; 55 for (int i = 0; i < m_nodes.Count(); i++) 56 new_camera_pos += m_nodes[i].m1; 57 new_camera_pos /= (float)(m_nodes.Count() + 1); 57 58 58 59 59 return new_camera_pos; 60 } 60 61 61 62 protected: … … 70 71 && (int)m_steer / 6 != (int)(m_steer  2.f * seconds) / 6) 71 72 { 72 int todelete = (int)RandF(m_nodes.Count()  2); 73 m_nodes[todelete + 1].m1 += m_nodes[todelete].m1; 74 m_nodes.Remove(todelete); 75 m_nodes[todelete + 1].m1 += m_nodes[todelete].m1; 76 m_nodes.Remove(todelete); 73 int tohit = (int)RandF(m_nodes.Count()  2); 74 m_nodes[tohit + 1].m4 += 150.f; 75 m_nodes[tohit + 2].m4 += 150.f; 77 76 } 78 77 … … 83 82 vec3 deltapos = seconds * m_velocity; 84 83 m_position += deltapos; 84 85 /* Remove dead nodes */ 86 for (int i = m_nodes.Count(); i; ) 87 { 88 if (m_nodes[i].m3 < 0.f) 89 { 90 m_nodes[i + 1].m1 += m_nodes[i].m1; 91 m_nodes.Remove(i); 92 } 93 } 94 95 /* Regrow! FIXME: just a test */ 96 if (m_nodes.Count() < 5) 97 { 98 m_nodes.Empty(); 99 for (int i = 0; i < 35; i++) 100 m_nodes.Push(m_rotation.transform(vec3(12.f, 0.f, 0.f)), 101 0.f, 100.f, 0.f); 102 m_nodes.Push(vec3(0.f, 0.f, 0.f), 45.f, 100.f, 0.f); 103 } 85 104 86 105 for (int i = 0; i < m_nodes.Count(); i++) … … 101 120 if (i != m_nodes.Count()  1) 102 121 m_nodes[i].m2 += seconds * ((i & 1) ? 200.f : 200.f); 122 123 /* Apply damage */ 124 float damage = std::min(m_nodes[i].m4, 30.f * seconds); 125 m_nodes[i].m3 = damage; 126 m_nodes[i].m4 = damage; 103 127 } 104 128 } … … 129 153 * quat::rotate(m_nodes[i].m2, 0.f, 0.f, 1.f); 130 154 model = mat4::translate(pos) * mat4(rot); 131 if (i != m_nodes.Count()  1) 155 if (i != m_nodes.Count()  1 && m_nodes[i].m4) 156 m_body.Render(model, sin(2.f * m_nodes[i].m3) * .5f + .5f); 157 else if (i != m_nodes.Count()  1) 132 158 m_body.Render(model); 133 159 else … … 139 165 Mesh m_head, m_body, m_tail; 140 166 float m_steer; 141 /* List of nodes (position, selfrotation angle ) */142 Array<vec3, float > m_nodes;167 /* List of nodes (position, selfrotation angle, life, damage) */ 168 Array<vec3, float, float, float> m_nodes; 143 169 bool m_ready; 144 170 };
Note: See TracChangeset
for help on using the changeset viewer.