Changeset 1368
 Timestamp:
 May 12, 2012, 11:36:39 AM (9 years ago)
 Location:
 trunk/orbital
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

trunk/orbital/orbital.cpp
r1367 r1368 115 115 m_snakes.Push(new Snake(3)); 116 116 Ticker::Ref(m_snakes.Last()); 117 m_snakes.Push(new Snake(15)); 117 m_snakes.Push(new Snake(8)); 118 Ticker::Ref(m_snakes.Last()); 119 m_snakes.Push(new Snake(25)); 118 120 Ticker::Ref(m_snakes.Last()); 119 121 
trunk/orbital/snake.h
r1367 r1368 26 26 m_body.SendCommand("sc1,1,1,1,afcb.4,.4,7,.4,tx8,mx,fl"); 27 27 28 m_position = vec3(RandF(250.f, 350.f), 20.f, RandF(250.f, 350.f)); 28 m_tail.SendCommand("sc1,1,1,1,afcb6,6,10,1,tz1,fl"); 29 m_tail.SendCommand("sc.9,.6,.1,1,afcb3,15,3,.8,ty8,fl"); 30 m_tail.SendCommand("sc1,1,1,1,afcb.4,.4,8,.4,tz1,ty8,fl"); 31 m_tail.SendCommand("sc1,1,1,1,afcb.4,.4,8,.4,tz1,ty12,fl"); 32 m_tail.SendCommand("sc.9,.6,.1,1,afcb15,3,3,.8,tx8,fl"); 33 m_tail.SendCommand("sc1,1,1,1,afcb.4,.4,8,.4,tz1,tx8,fl"); 34 m_tail.SendCommand("sc1,1,1,1,afcb.4,.4,8,.4,tz1,tx12,fl"); 35 36 m_position = vec3(RandF(0.f, 100.f), 20.f, RandF(150.f, 250.f)); 29 37 m_rotation = quat::rotate(RandF(30.f, 70.f), 0.f, 1.f, 0.f);; 30 38 39 /* The last node is actually the tail */ 31 40 for (int i = 0; i < nodes; i++) 32 41 m_nodes.Push(vec3(0.f, 0.f, 0.f), 0.f); 42 m_nodes.Push(vec3(0.f, 0.f, 0.f), 45.f); 33 43 } 34 44 … … 45 55 46 56 m_steer += 2.f * seconds; 47 float test = sinf(m_steer) * 1 20.f;57 float test = sinf(m_steer) * 100.f + 20.f; 48 58 m_rotation *= quat::rotate(seconds * test, vec3(0, 1, 0)); 49 59 … … 54 64 for (int i = 0; i < m_nodes.Count(); i++) 55 65 { 66 /* The current node is dragged by the previous one */ 56 67 vec3 newdelta = m_nodes[i].m1  deltapos; 57 68 if (dot(newdelta, newdelta) > 12.f * 12.f) … … 59 70 deltapos = newdelta + deltapos  m_nodes[i].m1; 60 71 m_nodes[i].m1 = newdelta; 61 m_nodes[i].m2 += seconds * ((i & 1) ? 200.f : 200.f); 72 73 /* If the current node is not the tail, rotate */ 74 if (i != m_nodes.Count()  1) 75 m_nodes[i].m2 += seconds * ((i & 1) ? 200.f : 200.f); 62 76 } 63 77 } … … 71 85 m_head.SendCommand("irb"); 72 86 m_body.SendCommand("irb"); 87 m_tail.SendCommand("irb"); 73 88 m_ready = true; 74 89 } … … 76 91 vec3 pos = m_position; 77 92 quat rot = m_rotation; 93 float y_angle = 0.f; 78 94 mat4 model = mat4::translate(pos) * mat4(rot); 79 95 m_head.Render(model); … … 82 98 { 83 99 pos += m_nodes[i].m1; 84 floatangle = (180.f / M_PI) * atan2(m_nodes[i].m1.x, m_nodes[i].m1.z);85 rot = quat::rotate( angle, 0.f, 1.f, 0.f)100 y_angle = (180.f / M_PI) * atan2(m_nodes[i].m1.x, m_nodes[i].m1.z); 101 rot = quat::rotate(y_angle, 0.f, 1.f, 0.f) 86 102 * quat::rotate(m_nodes[i].m2, 0.f, 0.f, 1.f); 87 103 model = mat4::translate(pos) * mat4(rot); 88 m_body.Render(model); 104 if (i != m_nodes.Count()  1) 105 m_body.Render(model); 106 else 107 m_tail.Render(model); 89 108 } 90 109 } 91 110 92 111 private: 93 Mesh m_head, m_body ;112 Mesh m_head, m_body, m_tail; 94 113 float m_steer; 95 114 /* List of nodes (position, selfrotation angle) */
Note: See TracChangeset
for help on using the changeset viewer.