static void gl_reset_callb (GtkWidget *wdg, gpointer data) { // Callback for the reset button gl_preview_struct *gl_preview = (gl_preview_struct *) data; camera_struct *camera; camera = gl_preview->cameras[gl_preview->current_camera_id]; copy_camera (camera, &camera_def); set_camera (gl_preview, camera); }
void make_local_camera(Camera *cam) { Main *bmain= G.main; Object *ob; int is_local= FALSE, is_lib= FALSE; /* - only lib users: do nothing * - only local users: set flag * - mixed: make copy */ if (cam->id.lib==NULL) return; if (cam->id.us==1) { id_clear_lib_data(bmain, &cam->id); return; } for (ob= bmain->object.first; ob && ELEM(0, is_lib, is_local); ob= ob->id.next) { if (ob->data==cam) { if (ob->id.lib) is_lib= TRUE; else is_local= TRUE; } } if (is_local && is_lib == FALSE) { id_clear_lib_data(bmain, &cam->id); } else if (is_local && is_lib) { Camera *cam_new= copy_camera(cam); cam_new->id.us= 0; /* Remap paths of new ID using old library as base. */ BKE_id_lib_local_paths(bmain, cam->id.lib, &cam_new->id); for (ob= bmain->object.first; ob; ob= ob->id.next) { if (ob->data == cam) { if (ob->id.lib==NULL) { ob->data= cam_new; cam_new->id.us++; cam->id.us--; } } } } }
gl_preview_struct *gl_preview_new (gl_defaults_struct *gl_def) { gl_preview_struct *gl_preview; gint i; gl_preview = (gl_preview_struct *) x_malloc(sizeof(gl_preview_struct), "gl_preview_struct"); gl_preview->defaults = gl_def; gl_preview->mouse_dragging1 = FALSE; gl_preview->mouse_dragging2 = FALSE; gl_preview->mouse_dragging3 = FALSE; gl_preview->last_x = 0; gl_preview->last_y = 0; gl_preview->mesh_size = gl_def->mesh_size; gl_preview->mesh_size_backup = gl_def->mesh_size ; gl_preview->drawing_mesh_size = gl_def->drawing_mesh_size ; for (i=0; i<NBCAMERAS; i++) { gl_preview->cameras[i] = (camera_struct *) x_malloc(sizeof(camera_struct), "camera_struct"); copy_camera(gl_preview->cameras[i], gl_def->cameras[i]); } gl_preview->current_camera_id = 0; gl_preview->hf_list = 0; gl_preview->hf = NULL; gl_preview->view_size = gl_def->view_size; gl_preview->gl_area = NULL; gl_preview->refresh_on_mouse_down = TRUE; gl_preview->grid = NULL; gl_preview->max_x = 0; gl_preview->max_y = 0; gl_preview->data_type = HF_TYPE_ID; gl_preview->if_water_chkbox = NULL; gl_preview->adj_water_level = NULL; gl_preview->use_water = NULL; gl_preview->water_level = NULL; return (gl_preview); }
gint glarea_draw (GtkWidget* widget, GdkEventExpose* event, gpointer data) { // Rotates, translate, etc. the scene but does not refresh the mesh gint i; camera_struct *camera; gl_preview_struct *gl_hf = (gl_preview_struct *) data; camera = gl_hf->cameras[gl_hf->current_camera_id]; /* Draw only on the last expose event. */ // printf("************* GL DRAWING 1 *************\n"); if (event->count > 0) { return(TRUE); } // printf("************* GL DRAWING 2 **************\n"); GdkGLContext *glcontext = gtk_widget_get_gl_context (widget); GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable (widget); /*** OpenGL BEGIN ***/ if (!gdk_gl_drawable_gl_begin (gldrawable, glcontext)) return FALSE; /* Clear the drawing color buffer and depth buffers */ /* before drawing. */ glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Drawing instructions glLoadIdentity(); gluLookAt(0.0,0.0,camera->distance + BASE_DISTANCE,0.0,0.0,0.0,0.0,1.0,0.0); glLightfv(GL_LIGHT0,GL_POSITION,l0pos); glLightfv(GL_LIGHT1,GL_POSITION,l1pos); // glCallList(lights_list); glTranslatef(camera->translate_x, camera->translate_y+BASE_TRANSLATE_Y,0.0); glRotatef(camera->rot_x+ROT_X_BASE,1.0,0.0,0.0); glRotatef(camera->rot_y+ROT_Y_BASE,0.0,0.0,1.0); glCallList(gl_hf->hf_list); // A very simple water plane if (gl_hf->use_water && *gl_hf->use_water) { glColor4fv(water_colour); glBegin(GL_POLYGON); glVertex3f(1.5,-1.5,*gl_hf->water_level*HEIGHT_SCALE); glVertex3f(1.5,1.5,*gl_hf->water_level*HEIGHT_SCALE); glVertex3f(-1.5,1.5,*gl_hf->water_level*HEIGHT_SCALE); glVertex3f(-1.5,-1.5,*gl_hf->water_level*HEIGHT_SCALE); glEnd(); } // glCallList(normals_list); // Back up the cameras if (FLAG_CAMERA_CHANGE) { for(i=0; i<NBCAMERAS; i++) { copy_camera(&cameras[i],gl_hf->cameras[i]); } FLAG_CAMERA_CHANGE = FALSE; } if (gdk_gl_drawable_is_double_buffered (gldrawable)) gdk_gl_drawable_swap_buffers (gldrawable); else glFlush (); gdk_gl_drawable_gl_end (gldrawable); /*** OpenGL END ***/ return (TRUE); }
int id_copy(ID *id, ID **newid, int test) { if(!test) *newid= NULL; /* conventions: * - make shallow copy, only this ID block * - id.us of the new ID is set to 1 */ switch(GS(id->name)) { case ID_SCE: return 0; /* can't be copied from here */ case ID_LI: return 0; /* can't be copied from here */ case ID_OB: if(!test) *newid= (ID*)copy_object((Object*)id); return 1; case ID_ME: if(!test) *newid= (ID*)copy_mesh((Mesh*)id); return 1; case ID_CU: if(!test) *newid= (ID*)copy_curve((Curve*)id); return 1; case ID_MB: if(!test) *newid= (ID*)copy_mball((MetaBall*)id); return 1; case ID_MA: if(!test) *newid= (ID*)copy_material((Material*)id); return 1; case ID_TE: if(!test) *newid= (ID*)copy_texture((Tex*)id); return 1; case ID_IM: if(!test) *newid= (ID*)copy_image((Image*)id); return 1; case ID_LT: if(!test) *newid= (ID*)copy_lattice((Lattice*)id); return 1; case ID_LA: if(!test) *newid= (ID*)copy_lamp((Lamp*)id); return 1; case ID_SPK: if(!test) *newid= (ID*)copy_speaker((Speaker*)id); return 1; case ID_CA: if(!test) *newid= (ID*)copy_camera((Camera*)id); return 1; case ID_IP: return 0; /* deprecated */ case ID_KE: if(!test) *newid= (ID*)copy_key((Key*)id); return 1; case ID_WO: if(!test) *newid= (ID*)copy_world((World*)id); return 1; case ID_SCR: return 0; /* can't be copied from here */ case ID_VF: return 0; /* not implemented */ case ID_TXT: if(!test) *newid= (ID*)copy_text((Text*)id); return 1; case ID_SCRIPT: return 0; /* deprecated */ case ID_SO: return 0; /* not implemented */ case ID_GR: if(!test) *newid= (ID*)copy_group((Group*)id); return 1; case ID_AR: if(!test) *newid= (ID*)copy_armature((bArmature*)id); return 1; case ID_AC: if(!test) *newid= (ID*)copy_action((bAction*)id); return 1; case ID_NT: if(!test) *newid= (ID*)ntreeCopyTree((bNodeTree*)id); return 1; case ID_BR: if(!test) *newid= (ID*)copy_brush((Brush*)id); return 1; case ID_PA: if(!test) *newid= (ID*)psys_copy_settings((ParticleSettings*)id); return 1; case ID_WM: return 0; /* can't be copied from here */ case ID_GD: return 0; /* not implemented */ } return 0; }
void Init(void){ int i; FREEMEMORY(plotiso); NewMemory((void **)&plotiso,mxplot3dvars*sizeof(int)); for(i=0;i<16;i++){ if(i%5==0){ modelview_identity[i]=1.0; } else{ modelview_identity[i]=0.0; } } for(i=0;i<mxplot3dvars;i++){ plotiso[i]=nrgb/2; } for(i=0;i<16;i++){ modelview_setup[i]=0.0; } for(i=0;i<4;i++){ modelview_setup[i+4*i]=1.0; } for(i=0;i<nmeshes;i++){ mesh *meshi; meshi=meshinfo+i; initcontour(&meshi->plot3dcontour1,rgb_plot3d_contour,nrgb); initcontour(&meshi->plot3dcontour2,rgb_plot3d_contour,nrgb); initcontour(&meshi->plot3dcontour3,rgb_plot3d_contour,nrgb); } for(i=0;i<nmeshes;i++){ mesh *meshi; meshi=meshinfo+i; meshi->currentsurf.defined=0; meshi->currentsurf2.defined=0; } /* initialize box sizes, lighting parameters */ xyzbox = MAX(MAX(xbar,ybar),zbar); { char name_external[32]; strcpy(name_external,"external"); init_camera(camera_external,name_external); camera_external->view_id=EXTERNAL_LIST_ID; } if(camera_ini->defined==1){ copy_camera(camera_current,camera_ini); } else{ camera_external->zoom=zoom; copy_camera(camera_current,camera_external); } strcpy(camera_label,camera_current->name); update_camera_label(); { char name_internal[32]; strcpy(name_internal,"internal"); init_camera(camera_internal,name_internal); } camera_internal->eye[0]=0.5*xbar; camera_internal->eye[1]=0.5*ybar; camera_internal->eye[2]=0.5*zbar; camera_internal->view_id=0; copy_camera(camera_save,camera_current); copy_camera(camera_last,camera_current); init_camera_list(); add_default_views(); copy_camera(camera_external_save,camera_external); update_view_gluilist(); //reset_glui_view(i_view_list); glEnable(GL_DEPTH_TEST); glEnable(GL_NORMALIZE); if(cullfaces==1)glEnable(GL_CULL_FACE); glClearColor(backgroundcolor[0],backgroundcolor[1],backgroundcolor[2], 0.0f); glShadeModel(GL_SMOOTH); glDisable(GL_DITHER); thistime=0; lasttime=0; /* define color bar */ UpdateRGBColors(COLORBAR_INDEX_NONE); block_ambient2[3] = 1.0; mat_ambient2[3] = 1.0; mat_specular2[3] = 1.0; reset_glui_view(startup_view_ini); Update_Show(); }