samples/tracker-demo.c
/** Draw a object at the location and orientation of the tracked vrpn object */
Draw a object at the location and orientation of the tracked vrpn object
Draw a object at the location and orientation of the tracked vrpn object
void drawObject(const int objectIndex, float viewMat[16])
{
	const char *vrpnObject = global_argv[objectIndex];
	const float scaleFactor = .5;
	float pos[4], orient[16];
	vrpn_get(vrpnObject, NULL, pos, orient);
	float modelMat[16],translate[16],scale[16];
	mat4f_scale_new(scale, scaleFactor, scaleFactor, scaleFactor);
	mat4f_translateVec_new(translate, pos);
	mat4f_mult_mat4f_many(modelMat, translate, orient, scale, NULL);
	float modelview[16];
	mat4f_mult_mat4f_new(modelview, viewMat, modelMat); 
	glUniformMatrix4fv(kuhl_get_uniform("ModelView"),
	                   1, 
	                   0, 
	                   modelview); 
	glUniform1i(kuhl_get_uniform("renderStyle"), 2);
	kuhl_errorcheck();
	kuhl_geometry_draw(modelgeom); 
	kuhl_errorcheck();
	float labelScale[16];
	mat4f_scale_new(labelScale, 1, 1/labelAspectRatio[objectIndex-1], 1);
	mat4f_mult_mat4f_new(modelview, modelview, labelScale);
	glUniformMatrix4fv(kuhl_get_uniform("ModelView"), 1, 0, modelview);
	glUniform1i(kuhl_get_uniform("renderStyle"), 1);
	kuhl_geometry_texture(&quad, label[objectIndex-1], "tex", 1);
	kuhl_geometry_draw(&quad);
#if 0
	printf("%s is at\n", vrpnObject);
	vec3f_print(pos);
	mat4f_print(orient);
#endif
}
void drawObject ( const int objectIndex , float viewMat [ 16 ] ) { const char * vrpnObject = global_argv [ objectIndex ] ; const float scaleFactor = .5 ; float pos [ 4 ] , orient [ 16 ] ; vrpn_get ( vrpnObject , NULL , pos , orient ) ; float modelMat [ 16 ] , translate [ 16 ] , scale [ 16 ] ; mat4f_scale_new ( scale , scaleFactor , scaleFactor , scaleFactor ) ; mat4f_translateVec_new ( translate , pos ) ; mat4f_mult_mat4f_many ( modelMat , translate , orient , scale , NULL ) ; float modelview [ 16 ] ; mat4f_mult_mat4f_new ( modelview , viewMat , modelMat ) ; glUniformMatrix4fv ( kuhl_get_uniform ( " " ) , 1 , 0 , modelview ) ; glUniform1i ( kuhl_get_uniform ( " " ) , 2 ) ; kuhl_errorcheck ( ) ; kuhl_geometry_draw ( modelgeom ) ; kuhl_errorcheck ( ) ; float labelScale [ 16 ] ; mat4f_scale_new ( labelScale , 1 , 1 / labelAspectRatio [ objectIndex - 1 ] , 1 ) ; mat4f_mult_mat4f_new ( modelview , modelview , labelScale ) ; glUniformMatrix4fv ( kuhl_get_uniform ( " " ) , 1 , 0 , modelview ) ; glUniform1i ( kuhl_get_uniform ( " " ) , 1 ) ; kuhl_geometry_texture ( & quad , label [ objectIndex - 1 ] , " " , 1 ) ; kuhl_geometry_draw ( & quad ) ; #if 0 printf ( " \n " , vrpnObject ) ; vec3f_print ( pos ) ; mat4f_print ( orient ) ; #endif }
Draw a object at the location and orientation of the tracked vrpn object
Draw a object at the location and orientation of the tracked vrpn object
// modelview = view * model /* Send the modelview matrix to the vertex program. */ // number of 4x4 float matrices // transpose // value /* Draw the model */ /* Transparency of labels may not appear right because we aren't
	 * sorting them by depth. */