void rig_paint_camera_entity (RutEntity *camera, RigPaintContext *paint_ctx) { RutPaintContext *rut_paint_ctx = &paint_ctx->_parent; RutCamera *save_camera = rut_paint_ctx->camera; RutCamera *camera_component = rut_entity_get_component (camera, RUT_COMPONENT_TYPE_CAMERA); rut_paint_ctx->camera = camera_component; rut_camera_flush (camera_component); paint_scene (paint_ctx); rut_camera_end_frame (camera_component); rut_paint_ctx->camera = save_camera; }
/* Use script to produce jpeg frames */ void script_animate (int iw) { char buf[SCRIPT_LINE_SIZE],output[SCRIPT_LINE_SIZE],*ptr; int i,hascontent,quality,frames; FILE *fp; glob_t globbuf; strcpy(buf, "scr_anim"); if (!(fp=ropen(buf))) { printf ("\nAnimation script \"%s\" does not exist,\n", buf); xterm_get_focus(iw); clear_stdin_buffer(); if (!strcasecmp("y", readline_gets ("Do you want a default one created (y/n)?","y"))) { numerically_sorted_glob (config_fname, &globbuf); fp=wopen(buf); fprintf (fp, "%d\n", AX_JPG_DEF_QUALITY); for (i=0; i<globbuf.gl_pathc; i++) fprintf (fp, "%s Jpg/%05d.jpg\n", globbuf.gl_pathv[i], i); globfree (&globbuf); fclose(fp); fp = ropen(buf); } else { xterm_release_focus(iw); return; } } if (!(ptr=fgets(buf,SCRIPT_LINE_SIZE,fp))) { printf ("\nThere is nothing in animation script \"%s\".\n", buf); fclose (fp); return; } for (hascontent=i=0; (buf[i]!=EOS) && (ISDIGIT(buf[i]) || ISBLANK(buf[i]) || (buf[i]=='\n')); i++) if (ISALNUM(buf[i])) hascontent=1; if (!hascontent) { printf ("\nThere is no content in animation script \"%s\".\n", buf); fclose (fp); return; } if (buf[i] == EOS) { sscanf (buf, "%d", &quality); if ((quality<0) || (quality>100)) { printf ("\nquality = %d is out of valid range ([0,100]).\n", quality); return; } else printf ("\nquality = %d\n", quality); ptr = fgets(buf,SCRIPT_LINE_SIZE,fp); } else quality = AX_JPG_DEF_QUALITY; frames = 0; /* If bonds are not on now, there is no need to refresh */ temporary_disable_bond = !n[iw].bond_mode; /* cylinder data structure during the rendering. */ while (ptr) { buf[SCRIPT_LINE_CHAR] = EOS; sscanf (buf, "%s %s", config_fname, output); reload_config (iw, FALSE); paint_scene(iw); AX_dump(iw); AX_show(iw); if (str_caseend_with(output,".png")) AX_save_pixmap_as_png (iw,AX_JPG_QUALITY_TO_PNG_LEVEL(quality),output); else if (str_caseend_with(output,".eps")) AX_save_pixmap_as_eps(iw,quality,output); else AX_save_pixmap_as_jpg(iw,quality,output); frames++; ptr = fgets(buf,SCRIPT_LINE_SIZE,fp); } fclose(fp); printf ("%d frames saved.\n\n", frames); if (temporary_disable_bond) { Config_to_3D_Bonds (n[iw].bond_radius); if (n[iw].bond_mode) { bond_xtal_origin_update (iw); bond_atom_color_update(iw); } else { n[iw].bond_xtal_origin_need_update = TRUE; n[iw].bond_atom_color_need_update = TRUE; } temporary_disable_bond = 0; } return; } /* end script_animate() */