Changeset 1444
 Timestamp:
 Jun 7, 2012, 4:15:01 PM (9 years ago)
 Location:
 trunk/orbital
 Files:

 3 edited
Legend:
 Unmodified
 Added
 Removed

trunk/orbital/mesh.cpp
r1442 r1444 37 37 { 38 38 orbital::MeshCompiler mc(*this); 39 mc.ParseString(command);39 return mc.ParseString(command); 40 40 } 41 41 
trunk/orbital/orbital.cpp
r1442 r1444 42 42 #include "orbital.h" 43 43 44 Orbital::Orbital() 44 Orbital::Orbital(bool editor) 45 : m_model(1.f), 46 m_stick(0), 47 m_angle(0.f), 48 m_zoom(5.f), 49 m_editor(editor) 45 50 { 46 51 #if 0 … … 62 67 #endif 63 68 64 /* Grey/red bonus */65 m.Compile("[sc#9ac afcb7 4 7 0.6 sc#f04 afcb4 7 4 0.6 t40 20 30]");66 67 69 #if 0 68 70 /* Yellow sphere */ … … 107 109 Ticker::Ref(m_camera); 108 110 109 /* Add tanks */ 110 for (int j = 0; j < 2; j++) 111 for (int i = 0; i < 2; i++) 112 { 113 m_tanks << new Tank(); 114 m_tanks.Last()>m_position = vec3(i * 80.f, 0, j * 80.f + 120.f); 115 m_tanks.Last()>SetTarget(vec3(i * 160.f  200.f, 0, j * 160.f  130.f)); 116 Ticker::Ref(m_tanks.Last()); 117 } 118 119 //m_snakes.Push(new Snake(3)); 120 //Ticker::Ref(m_snakes.Last()); 121 //m_snakes.Push(new Snake(8)); 122 //Ticker::Ref(m_snakes.Last()); 123 m_snakes.Push(new Snake(33)); 124 Ticker::Ref(m_snakes.Last()); 125 126 /* Add player */ 127 for (int i = 0; i < 2; i++) 128 { 129 m_players << new Player(i); 130 Ticker::Ref(m_players.Last()); 131 } 132 133 m_auto_cam_timer = 0.0f; 134 135 m_angle = vec3(0.f); 136 m_angular_velocity = vec3(0.f); 111 if (m_editor) 112 { 113 /* Grey/red bonus */ 114 //m.Compile("[sc#9ac afcb7 4 7 0.6 sc#f04 afcb4 7 4 0.6]"); 115 m.Compile("sc#d91" 116 "[afcb30 3 3 .8]" 117 "sc#cca" 118 "[afcb10 10 10 1]" 119 "[afcb.4 .4 12 .4 tz3 tx8 mx]" 120 "[afcb.4 .4 12 .4 tz3 tx12 mx]" 121 "sc#69c9" 122 "[afcb5 8 8 1 ty3 tz3]"); 123 } 124 else 125 { 126 /* Add tanks */ 127 for (int j = 0; j < 2; j++) 128 for (int i = 0; i < 2; i++) 129 { 130 m_tanks << new Tank(); 131 m_tanks.Last()>m_position = vec3(i * 80.f, 0, j * 80.f + 120.f); 132 m_tanks.Last()>SetTarget(vec3(i * 160.f  200.f, 0, j * 160.f  130.f)); 133 Ticker::Ref(m_tanks.Last()); 134 } 135 136 //m_snakes.Push(new Snake(3)); 137 //Ticker::Ref(m_snakes.Last()); 138 //m_snakes.Push(new Snake(8)); 139 //Ticker::Ref(m_snakes.Last()); 140 m_snakes.Push(new Snake(33)); 141 Ticker::Ref(m_snakes.Last()); 142 143 /* Add players */ 144 for (int i = 0; i < 2; i++) 145 { 146 m_players << new Player(i); 147 Ticker::Ref(m_players.Last()); 148 } 149 } 137 150 138 151 m_ready = false; … … 206 219 #endif 207 220 208 m_model = mat4(1.f); 221 if (m_editor) 222 { 223 float rightleft = 0.f, updown = 0.f, inout = 0.f; 224 225 if (!m_stick) 226 m_stick = Input::TrackStick(); 227 if (m_stick && m_stick>GetAxisCount() >= 4) 228 { 229 rightleft += 1.f * m_stick>GetAxis(2); 230 updown += 1.f * m_stick>GetAxis(3); 231 inout += 1.f * m_stick>GetAxis(1); 232 } 233 234 if (rightleft * rightleft + updown * updown > 0.2f) 235 { 236 float angle = atan2(updown, rightleft); 237 angle = (int)(angle / (M_PI / 4.f) + 8.5f) * (M_PI / 4.f); 238 rightleft = cos(angle); 239 updown = sin(angle); 240 } 241 else 242 { 243 rightleft = updown = 0.f; 244 } 245 246 m_model = mat4::fromeuler_zyx(0.f, 5.f * rightleft, 5.f * updown) 247 * m_model; 248 m_zoom *= 1.f + seconds * 0.8f * inout; 249 m_angle += 50.f * seconds; 250 } 251 else 252 { 253 } 209 254 } 210 255 … … 223 268 Video::SetClearColor(vec4(0.0f, 0.0f, 0.12f, 1.0f)); 224 269 225 m.Render(m_model); 270 if (m_editor) 271 { 272 mat4 anim1 = mat4::rotate(m_angle, vec3(1.f, 0.f, 0.f)); 273 mat4 anim2 = mat4::rotate(m_angle, vec3(0.f, 1.f, 0.f)); 274 mat4 anim3 = mat4::rotate(m_angle, vec3(0.f, 0.f, 1.f)); 275 276 m.Render(mat4::scale(vec3(m_zoom)) 277 * mat4::translate(0.f, 10.f, 10.f) 278 * m_model); 279 280 m.Render(mat4::translate(150.f, 350.f, 0.f) * anim1); 281 m.Render(mat4::translate(150.f, 200.f, 0.f) * anim2); 282 m.Render(mat4::translate(150.f, 50.f, 0.f) * anim3); 283 m.Render(mat4::translate(150.f, 100.f, 0.f)); 284 } 226 285 } 227 286 … … 234 293 for (int i = 0; i < m_snakes.Count(); i++) 235 294 Ticker::Unref(m_snakes[i]); 295 if (m_stick) 296 Input::UntrackStick(m_stick); 236 297 //Ticker::Unref(m_particlesystem); 237 298 Ticker::Unref(m_small_stars); … … 252 313 253 314 //new DebugFps(5, 5); 254 new Orbital( );315 new Orbital(argc > 1); 255 316 app.ShowPointer(false); 256 317 
trunk/orbital/orbital.h
r1423 r1444 21 21 { 22 22 public: 23 Orbital( );23 Orbital(bool editor = false); 24 24 virtual ~Orbital(); 25 25 … … 33 33 Mesh m; 34 34 float m_auto_cam_timer; 35 vec3 m_angle, m_angular_velocity; 36 mat4 m_model; 35 vec3 m_angular_velocity; 37 36 38 37 ParticleSystem *m_particlesystem; … … 43 42 Array<Snake *> m_snakes; 44 43 45 bool m_ready; 44 /* Editor stuff */ 45 mat4 m_model; 46 Stick *m_stick; 47 float m_angle, m_zoom; 48 49 bool m_ready, m_editor; 46 50 }; 47 51
Note: See TracChangeset
for help on using the changeset viewer.