Commit 25bb855ec5e9a2ca0f40dfdb6087b37862826c1d

Authored by Pavel Govyadinov
1 parent b606443d

Stable basic skeleton with spider movement, panning and rotation implemented and functioning

Showing 2 changed files with 46 additions and 14 deletions   Show diff stats
@@ -79,6 +79,8 @@ glInit() @@ -79,6 +79,8 @@ glInit()
79 glOrtho(-5.0, 2.0,-5.0, 2.0, -0.0, 1000.0); 79 glOrtho(-5.0, 2.0,-5.0, 2.0, -0.0, 1000.0);
80 glMatrixMode(GL_MODELVIEW); 80 glMatrixMode(GL_MODELVIEW);
81 spidey = stim::gl_spider<float>(0.5, 0.5, 0.5, -0.1, -0.1, -0.1, 0.1, 0.1); 81 spidey = stim::gl_spider<float>(0.5, 0.5, 0.5, -0.1, -0.1, -0.1, 0.1, 0.1);
  82 + Parker.setPosition(spidey.getPosition());
  83 + Parker.LookAt(spidey.getDirection());
82 CHECK_OPENGL_ERROR 84 CHECK_OPENGL_ERROR
83 } 85 }
84 86
@@ -336,11 +338,9 @@ void MouseMotion(int x, int y) @@ -336,11 +338,9 @@ void MouseMotion(int x, int y)
336 mousePos[1] = ((float)y - prevmousePos[1])*0.00001; 338 mousePos[1] = ((float)y - prevmousePos[1])*0.00001;
337 prevmousePos[0] = (float)x; 339 prevmousePos[0] = (float)x;
338 prevmousePos[1] = (float)y; 340 prevmousePos[1] = (float)y;
339 - Parker.setPosition(spidey.getPosition());  
340 - Parker.LookAt(spidey.getDirection());  
341 Parker.Pan(mousePos[0]*degtorad); 341 Parker.Pan(mousePos[0]*degtorad);
342 Parker.Tilt(mousePos[1]*degtorad); 342 Parker.Tilt(mousePos[1]*degtorad);
343 - spidey.setDirection(Parker.getLookAt()); 343 + spidey.setDirection(Parker.getDirection());
344 spidey.Update(); 344 spidey.Update();
345 std::cout << Parker.getLookAt() << std::endl; 345 std::cout << Parker.getLookAt() << std::endl;
346 } 346 }
@@ -365,13 +365,21 @@ switch(key) { @@ -365,13 +365,21 @@ switch(key) {
365 else{ 365 else{
366 oriDrw[2] = oriDrw[2] + adjustDrw; 366 oriDrw[2] = oriDrw[2] + adjustDrw;
367 } 367 }
368 - if (glutGetModifiers() == 1) 368 + if (glutGetModifiers() == GLUT_ACTIVE_SHIFT)
369 { 369 {
370 stim::vec<float> temp = spidey.getPosition(); 370 stim::vec<float> temp = spidey.getPosition();
371 - temp[1] += 0.0001; 371 + temp[1] += 0.001;
372 spidey.setPosition(temp); 372 spidey.setPosition(temp);
373 spidey.Update(); 373 spidey.Update();
374 } 374 }
  375 + if (glutGetModifiers() == GLUT_ACTIVE_CTRL)
  376 + {
  377 + //stim::vec<float> temp = Parker.getDirection();
  378 + //temp[1] += 0.001;
  379 + Parker.Pan(0.01);
  380 + spidey.setDirection(Parker.getDirection());
  381 + spidey.Update();
  382 + }
375 break; 383 break;
376 case GLUT_KEY_DOWN: 384 case GLUT_KEY_DOWN:
377 oriTex[2] = oriTex[2]-adjustTex; 385 oriTex[2] = oriTex[2]-adjustTex;
@@ -381,13 +389,21 @@ switch(key) { @@ -381,13 +389,21 @@ switch(key) {
381 else{ 389 else{
382 oriDrw[2] = oriDrw[2] - adjustDrw; 390 oriDrw[2] = oriDrw[2] - adjustDrw;
383 } 391 }
384 - if (glutGetModifiers() == 1) 392 + if (glutGetModifiers() == GLUT_ACTIVE_SHIFT)
385 { 393 {
386 stim::vec<float> temp = spidey.getPosition(); 394 stim::vec<float> temp = spidey.getPosition();
387 - temp[1] -= 0.0001; 395 + temp[1] -= 0.001;
388 spidey.setPosition(temp); 396 spidey.setPosition(temp);
389 spidey.Update(); 397 spidey.Update();
390 - } 398 + }
  399 + if (glutGetModifiers() == GLUT_ACTIVE_CTRL)
  400 + {
  401 + //stim::vec<float> temp = Parker.getDirection();
  402 + //temp[1] -= 0.001;
  403 + Parker.Pan(-0.01);
  404 + spidey.setDirection(Parker.getDirection());
  405 + spidey.Update();
  406 + }
391 break; 407 break;
392 case GLUT_KEY_LEFT: 408 case GLUT_KEY_LEFT:
393 oriTex[1] = oriTex[1]+adjustTex; 409 oriTex[1] = oriTex[1]+adjustTex;
@@ -397,13 +413,21 @@ switch(key) { @@ -397,13 +413,21 @@ switch(key) {
397 else{ 413 else{
398 oriDrw[1] = oriDrw[1] + adjustDrw; 414 oriDrw[1] = oriDrw[1] + adjustDrw;
399 } 415 }
400 - if (glutGetModifiers() == 1) 416 + if (glutGetModifiers() == GLUT_ACTIVE_SHIFT)
401 { 417 {
402 stim::vec<float> temp = spidey.getPosition(); 418 stim::vec<float> temp = spidey.getPosition();
403 - temp[0] += 0.0001; 419 + temp[0] += 0.001;
404 spidey.setPosition(temp); 420 spidey.setPosition(temp);
405 spidey.Update(); 421 spidey.Update();
406 } 422 }
  423 + if (glutGetModifiers() == GLUT_ACTIVE_CTRL)
  424 + {
  425 + //stim::vec<float> temp = Parker.getDirection();
  426 + //temp[0] += 0.001;
  427 + Parker.Tilt(0.01);
  428 + spidey.setDirection(Parker.getDirection());
  429 + spidey.Update();
  430 + }
407 break; 431 break;
408 case GLUT_KEY_RIGHT: 432 case GLUT_KEY_RIGHT:
409 oriTex[1] = oriTex[1]-adjustTex; 433 oriTex[1] = oriTex[1]-adjustTex;
@@ -413,14 +437,22 @@ switch(key) { @@ -413,14 +437,22 @@ switch(key) {
413 else{ 437 else{
414 oriDrw[1] = oriDrw[1] - adjustDrw; 438 oriDrw[1] = oriDrw[1] - adjustDrw;
415 } 439 }
416 - break;  
417 - if (glutGetModifiers() == 1) 440 + if (glutGetModifiers() == GLUT_ACTIVE_SHIFT)
418 { 441 {
419 stim::vec<float> temp = spidey.getPosition(); 442 stim::vec<float> temp = spidey.getPosition();
420 - temp[0] -= 0.0001; 443 + temp[0] -= 0.001;
421 spidey.setPosition(temp); 444 spidey.setPosition(temp);
422 spidey.Update(); 445 spidey.Update();
423 } 446 }
  447 + if (glutGetModifiers() == GLUT_ACTIVE_CTRL)
  448 + {
  449 + //stim::vec<float> temp = Parker.getDirection();
  450 + //temp[0] -= 0.001;
  451 + Parker.Tilt(-0.01);
  452 + spidey.setDirection(Parker.getDirection());
  453 + spidey.Update();
  454 + }
  455 + break;
424 } 456 }
425 glutPostRedisplay(); 457 glutPostRedisplay();
426 } 458 }
1 -Subproject commit 879321c4a5e974144996aae02c44c6583e4a2fbd 1 +Subproject commit a39577bf6661bcb962a7329abbebc66e501b1dac