#include "cc_interface.h" //this will be the width of all heads #define HEAD_HEIGHT 2.5 //same for now, this will actually vary from head GLfloat ambient[] = {1.0, 1.0, 1.0, 1.0}; GLfloat diffuse[] = {.7, .7, .7, 1}; GLfloat specular[] = {1, 1, 1, 1}; GLfloat lightpos[] = {0.0, 0.0, 20, 1}; GLfloat specref[] = {1.0, 1, 1, 1,}; GLfloat xrot, yrot, zrot; GLfloat x, y, z, mouth_open; GLint left_eye_frame, right_eye_frame; //between 0 - 8 BOOL left_open, right_open; FACE remote_shark_face, remote_dog_face, local_shark_face, local_dog_face; int curr_materials[DOG_SHARK_CHANGE]; //these are the materials from output_instance static void destroy_cb(GtkWidget *widget, struct output_instance *data); void Interpolate(struct output_instance* instance){ GLfloat rangeX, rangeY, minZ, adj, angle, temp; left_open = right_open = TRUE; mouth_open = (float)(count%10)/10; //find z plane from percentage of face if(instance->features->head_size==0){ temp = (GLfloat)instance->features->head_size/40.0; //printf("head size %d\n", instance->features->head_size); z = ROOT_3*(PERSONS_HEAD/temp); //these calculations are based on a 90 degree viewing angle rangeY = window_aspect*rangeX; temp = (GLfloat)instance->features->x; if(temp>50) { //then its on the left temp = (temp - 50.0)/50.0; temp = (GLfloat)instance->features->y; temp = (GLfloat)instance->features->head_y_rot; temp = (GLfloat)instance->features->head_z_rot; if(y-instance->past_y < -MOVEMENT) else if(y-instance->past_y > MOVEMENT) mouth_open = (float)instance->features->mouth_open/105; //mouth_open = (count%10)/(10); if(instance->features->left_eye_open==0){ if(instance->features->right_eye_open==0) //right_open =1 - (count%5)/4; curr_materials[APPENDAGE]=instance->features->appendage_color; curr_materials[HEAD]=instance->features->head_color; curr_materials[LIDS]=instance->features->lid_color; curr_materials[LEFT_IRIS]=instance->features->left_iris_color; curr_materials[RIGHT_IRIS]=instance->features->right_iris_color; // we don't get an x rotation curr_mode=instance->features->mode; if(instance->features->kind==0) gboolean configure(GtkWidget *widget, GdkEventConfigure *event, void *data) GdkGLContext *glcontext = gtk_widget_get_gl_context(widget); GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable(widget); GLfloat w = widget->allocation.width; GLfloat h = widget->allocation.height; if (!gdk_gl_drawable_gl_begin(gldrawable, glcontext)) glMatrixMode(GL_PROJECTION); //glOrtho(-10, 10, -10,10, 0.0001, 1000); gluPerspective(90.0, window_aspect, 0.0001, 1000.0); glMatrixMode(GL_MODELVIEW); gdk_gl_drawable_gl_end(gldrawable); gboolean draw(GtkWidget *widget, GdkEventExpose *event, struct output_instance *instance = (struct output_instance*)data; fprintf(stderr,"null\n"); GdkGLContext *glcontext = gtk_widget_get_gl_context (widget); GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable (widget); assert(gtk_widget_is_gl_capable(widget)); if (!gdk_gl_drawable_gl_begin (gldrawable, glcontext)) { fprintf(stderr, "We're fucked this time.\n"); glClearColor(1.0, 1.0, 1.0, 0.0); //glDisable(GL_CULL_FACE); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glColor3f(1.0, 1.0, 1.0); glMatrixMode(GL_MODELVIEW); if(instance->my_output==LOCAL){ change_materials(local_dog_face, curr_materials, DOG_SHARK_CHANGE); draw_face(local_dog_face, zrot, yrot, left_open, right_open, mouth_open, dir, curr_mode); change_materials(local_shark_face, curr_materials, DOG_SHARK_CHANGE); draw_face(local_shark_face, zrot, yrot, left_open, right_open, mouth_open, dir, curr_mode); change_materials(remote_dog_face, curr_materials, DOG_SHARK_CHANGE); draw_face(remote_dog_face, zrot, yrot, left_open, right_open, mouth_open, dir, curr_mode); change_materials(remote_shark_face, curr_materials, DOG_SHARK_CHANGE); draw_face(remote_shark_face, zrot, yrot, left_open, right_open, mouth_open, dir, curr_mode); if (gdk_gl_drawable_is_double_buffered (gldrawable)) gdk_gl_drawable_swap_buffers (gldrawable); void init (GtkWidget *widget, void *data) void setupDrawlists(OUTPUT output) remote_shark_face = init_face(SHARK); remote_dog_face = init_face(DOG); local_shark_face = init_face(SHARK); local_dog_face = init_face(DOG); void setupLighting(GtkWidget *widget) GLfloat w = widget->allocation.width; GLfloat h = widget->allocation.height; glClearColor(1.0f, 1.0f, 1.0f, 1.0f); //glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse); glLightfv(GL_LIGHT0, GL_SPECULAR, specular); glLightfv(GL_LIGHT0, GL_POSITION, lightpos); //glEnable(GL_COLOR_MATERIAL); //glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE); glMaterialfv(GL_FRONT, GL_DIFFUSE, diffuse); glMateriali(GL_FRONT, GL_SHININESS, 128); //glEnable(GL_CULL_FACE); glClear(GL_COLOR_BUFFER_BIT); glMatrixMode(GL_PROJECTION); //glOrtho(-2, 2, -2, 2, 0.0001, 1000); gluPerspective(90.0, window_aspect, 0.0001, 1000.0); //glFrustum(-100.0, 100.0, -100.0, 100.0, 0, 10); glMatrixMode(GL_MODELVIEW); //gluLookAt(0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); struct output_instance *init_output(struct cc_features *features, struct cc_session *session) struct output_instance *instance; instance = (struct output_instance*)malloc(sizeof(*instance)); memset(instance, 0, sizeof(*instance)); instance->features = features; instance->session = session; info = (struct draw_info*)malloc(sizeof(*info)); memset(info, 0, sizeof(*info)); cc_new_gl_window(init, configure, draw, info, &ret); g_signal_connect(GTK_OBJECT(ret.window), "destroy", G_CALLBACK(destroy_cb), instance); gtk_window_set_default_size(ret.window,640,480); gtk_window_set_title(ret.window, session->name); gtk_widget_show(ret.window); instance->widget = ret.window; instance->box = ret.vbox; static void destroy_cb(GtkWidget *widget, struct output_instance *data) Debug("Closing output window\n"); cc_remove_session(data->session->cc, data->session); close(data->session->tcp_sock); close(data->session->udp_sock); Filter_Destroy(data->session->filter); destroy_output(data->session->output); void destroy_output(struct output_instance *instance)