void render_objs(void) { int i,j; int mode=GL_FRONT; double pos[3],angle; glMaterialfv(mode,GL_AMBIENT,ambient_ir); glPushMatrix(); if (d_position) { p5glove_get_position(glove, pos); glTranslated(pos[0]*WORLD_SCALE,pos[1]*WORLD_SCALE,pos[2]*WORLD_SCALE); } if (d_rotation) { p5glove_get_rotation(glove,&angle,pos); glRotated(angle, pos[0], pos[1], pos[2]); } if (d_ref_axes) render_axes(); if (d_ref_hand) render_hand(); glPopMatrix(); }
static void dump_cooked(P5Glove glove,uint32_t mask) { if (mask & P5GLOVE_DELTA_BUTTONS) { uint32_t buttons; p5glove_get_buttons(glove,&buttons); /* Buttons */ printf("%c%c%c ", (buttons & P5GLOVE_BUTTON_A) ? 'A' : '.', (buttons & P5GLOVE_BUTTON_B) ? 'B' : '.', (buttons & P5GLOVE_BUTTON_C) ? 'C' : '.'); } if (mask & P5GLOVE_DELTA_FINGERS) { double clench; int i; for (i=0; i < 5; i++) { /* Fingers */ p5glove_get_finger(glove,i,&clench); printf("%.4lf%c",clench,i==4 ? ' ' : ','); } } if (mask & P5GLOVE_DELTA_POSITION) { double pos[3]; p5glove_get_position(glove, pos); printf("[%.4f, %.4f, %.4f] ", pos[0], pos[1], pos[2]); } if (mask & P5GLOVE_DELTA_ROTATION) { double axis[3],angle; p5glove_get_rotation(glove, &angle, axis); printf("(%.4f, %.4f, %.4f, %.4f deg) ", axis[0], axis[1], axis[2], angle); } }
bool P5GloveStandalone::readRecordsFromHardware(Record& rec) { const int mask = p5glove_sample(mGlove, -1); if ( mask < 0 ) { return false; } if ( mask & P5GLOVE_DELTA_BUTTONS ) { uint32_t buttons; p5glove_get_buttons(mGlove, &buttons); /* Buttons */ rec.buttonA = buttons & P5GLOVE_BUTTON_A; rec.buttonB = buttons & P5GLOVE_BUTTON_B; rec.buttonC = buttons & P5GLOVE_BUTTON_C; } if ( mask & P5GLOVE_DELTA_FINGERS ) { p5glove_get_finger(mGlove, P5GLOVE_FINGER_THUMB, &rec.thumb); p5glove_get_finger(mGlove, P5GLOVE_FINGER_INDEX, &rec.index); p5glove_get_finger(mGlove, P5GLOVE_FINGER_MIDDLE, &rec.middle); p5glove_get_finger(mGlove, P5GLOVE_FINGER_RING, &rec.ring); p5glove_get_finger(mGlove, P5GLOVE_FINGER_PINKY, &rec.pinky); } if ( mask & P5GLOVE_DELTA_POSITION ) { p5glove_get_position(mGlove, &rec.position[0]); } if ( mask & P5GLOVE_DELTA_ROTATION ) { p5glove_get_rotation(mGlove, &rec.rotationAngle, &rec.rotationAxis[0]); } return true; }
void p5_read(t_p5 *p5){ if(p5 == NULL) return; int err = p5glove_sample(p5->glove, -1); if (err < 0 && errno == EAGAIN){ return; } if (err < 0) { error("*** p5 glove failure"); return; } /* Output button data */ uint32_t buttons; p5glove_get_buttons(p5->glove, &buttons); if(err & P5GLOVE_DELTA_BUTTONS){ if(buttons & P5GLOVE_BUTTON_A) outlet_float(p5->btn_a_out, 1); else outlet_float(p5->btn_a_out, 0); if(buttons & P5GLOVE_BUTTON_B) outlet_float(p5->btn_b_out, 1); else outlet_float(p5->btn_b_out, 0); if(buttons & P5GLOVE_BUTTON_C) outlet_float(p5->btn_c_out, 1); else outlet_float(p5->btn_c_out, 0); } /* Output finger data */ if(err & P5GLOVE_DELTA_FINGERS){ double clench; p5glove_get_finger(p5->glove, P5GLOVE_FINGER_THUMB, &clench); outlet_float(p5->thumb_out, clench); p5glove_get_finger(p5->glove, P5GLOVE_FINGER_INDEX ,&clench); outlet_float(p5->index_out, clench); p5glove_get_finger(p5->glove, P5GLOVE_FINGER_MIDDLE ,&clench); outlet_float(p5->middle_out, clench); p5glove_get_finger(p5->glove, P5GLOVE_FINGER_RING ,&clench); outlet_float(p5->ring_out, clench); p5glove_get_finger(p5->glove, P5GLOVE_FINGER_PINKY ,&clench); outlet_float(p5->pinky_out, clench); } if(err & P5GLOVE_DELTA_POSITION){ double pos[3]; p5glove_get_position(p5->glove, pos); outlet_float(p5->xpos_out, pos[0]); outlet_float(p5->ypos_out, pos[1]); outlet_float(p5->zpos_out, pos[2]); } if(err & P5GLOVE_DELTA_ROTATION){ //TODO: Get/send rotation } clock_delay(p5->clock, p5->delaytime); }//p5_read