3dphotoshoot
diff src/game.cc @ 24:2712c5da2e00
getting sensor input (hack)
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Tue, 16 Jun 2015 06:17:59 +0300 |
parents | d7fe157c402d |
children | ac80210d5fbe |
line diff
1.1 --- a/src/game.cc Sat Jun 13 05:35:43 2015 +0300 1.2 +++ b/src/game.cc Tue Jun 16 06:17:59 2015 +0300 1.3 @@ -9,6 +9,7 @@ 1.4 #include "texture.h" 1.5 #include "shader.h" 1.6 #include "text.h" 1.7 +#include "vmath/vmath.h" 1.8 1.9 static void draw_quad(float hsz, float vsz); 1.10 1.11 @@ -21,6 +22,9 @@ 1.12 1.13 static SdrProg *sdr_cam, *sdr_tex; 1.14 1.15 +static Quaternion qrot; 1.16 +static Vector3 trans; 1.17 + 1.18 extern "C" int game_init(void) 1.19 { 1.20 //glEnable(GL_DEPTH_TEST); 1.21 @@ -109,12 +113,12 @@ 1.22 gl_load_identity(); 1.23 1.24 1.25 - // draw some text 1.26 + // print the rotation quaternion 1.27 text_color(1, 1, 1, 1); 1.28 - for(int i=0; i<25; i++) { 1.29 - text_position(0, i); 1.30 - text_printf("%d%s line of text", i, i == 1 ? "st" : (i == 2 ? "nd" : (i == 3 ? "rd" : "th"))); 1.31 - } 1.32 + text_position(0, 0); 1.33 + text_printf("translation (% .3f, % .3f, % .3f)", trans.x, trans.y, trans.z); 1.34 + text_position(0, 1); 1.35 + text_printf("Rotation quat ([% 1.3f, % 1.3f, % 1.3f], % 1.3f)", qrot.v.x, qrot.v.y, qrot.v.z, qrot.s); 1.36 } 1.37 1.38 static void draw_quad(float hsz, float vsz) 1.39 @@ -217,3 +221,17 @@ 1.40 */ 1.41 } 1.42 1.43 +void game_6dof_translation(float dx, float dy, float dz) 1.44 +{ 1.45 + trans.x = dx; 1.46 + trans.y = dy; 1.47 + trans.z = dz; 1.48 +} 1.49 + 1.50 +void game_6dof_rotation(float qx, float qy, float qz, float qw) 1.51 +{ 1.52 + qrot.v.x = qx; 1.53 + qrot.v.y = qy; 1.54 + qrot.v.z = qz; 1.55 + qrot.s = qw; 1.56 +}