Lotsa undo stuff added;
[blender.git] / source / blender / src / buttons_scene.c
1 /**
2  * $Id: 
3  *
4  * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version. The Blender
10  * Foundation also sells licenses for use in proprietary software under
11  * the Blender License.  See http://www.blender.org/BL/ for information
12  * about this.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software Foundation,
21  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22  *
23  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
24  * All rights reserved.
25  *
26  * The Original Code is: all of this file.
27  *
28  * Contributor(s): none yet.
29  *
30  * ***** END GPL/BL DUAL LICENSE BLOCK *****
31  */
32
33 #include <time.h>
34 #include <math.h>
35 #include <stdlib.h>
36 #include <string.h>
37
38 #ifdef HAVE_CONFIG_H
39 #include <config.h>
40 #endif
41
42 #ifdef WIN32
43 #include "BLI_winstuff.h"
44 #endif
45
46 #include "MEM_guardedalloc.h"
47 #include "DNA_screen_types.h"
48 #include "DNA_space_types.h"
49 #include "DNA_scene_types.h"
50 #include "DNA_sound_types.h"
51 #include "DNA_userdef_types.h"
52 #include "DNA_packedFile_types.h"
53
54 #include "BKE_global.h"
55 #include "BKE_main.h"
56 #include "BKE_library.h"
57 #include "BKE_sound.h"
58 #include "BKE_packedFile.h"
59 #include "BKE_utildefines.h"
60
61 #include "BLI_blenlib.h"
62
63 #include "BSE_filesel.h"
64
65 #include "BIF_gl.h"
66 #include "BIF_graphics.h"
67 #include "BIF_keyval.h"
68 #include "BIF_mainqueue.h"
69 #include "BIF_resources.h"
70 #include "BIF_screen.h"
71 #include "BIF_mywindow.h"
72 #include "BIF_space.h"
73 #include "BIF_glutil.h"
74 #include "BIF_interface.h"
75 #include "BIF_toolbox.h"
76
77 #include "BIF_butspace.h"
78
79 #include "mydevice.h"
80 #include "blendef.h"
81
82 /* -----includes for this file specific----- */
83
84 #include "render.h"
85 #include "DNA_image_types.h"
86 #include "BKE_writeavi.h"
87 #include "BKE_image.h"
88 #include "BIF_renderwin.h"
89 #include "BIF_writeimage.h"
90 #include "BIF_writeavicodec.h"
91 #include "BIF_editsound.h"
92 #include "BSE_seqaudio.h"
93 #include "BSE_headerbuttons.h"
94 #include "butspace.h" // own module
95
96 #ifdef WITH_QUICKTIME
97 #include "quicktime_export.h"
98 #endif
99
100
101 /* here the calls for scene buttons
102    - render
103    - world
104    - anim settings, audio
105 */
106
107
108 /* ************************ SOUND *************************** */
109 static void load_new_sample(char *str)  /* called from fileselect */
110 {
111         char name[FILE_MAXDIR+FILE_MAXFILE];
112         bSound *sound;
113         bSample *sample, *newsample;
114
115         sound = G.buts->lockpoin;
116
117         if (sound) {
118                 // save values
119                 sample = sound->sample;
120                 strcpy(name, sound->sample->name);
121
122                 strcpy(sound->name, str);
123                 sound_set_sample(sound, NULL);
124                 sound_initialize_sample(sound);
125
126                 if (sound->sample->type == SAMPLE_INVALID) {
127                         error("Not a valid sample: %s", str);
128
129                         newsample = sound->sample;
130
131                         // restore values
132                         strcpy(sound->name, name);
133                         sound_set_sample(sound, sample);
134
135                         // remove invalid sample
136
137                         sound_free_sample(newsample);
138                         BLI_remlink(samples, newsample);
139                         MEM_freeN(newsample);
140                 }
141         }
142
143         BIF_undo_push("Load new audio file");
144         allqueue(REDRAWBUTSSCENE, 0);
145
146 }
147
148
149 void do_soundbuts(unsigned short event)
150 {
151         char name[FILE_MAXDIR+FILE_MAXFILE];
152         bSound *sound;
153         bSample *sample;
154         bSound* tempsound;
155         ID *id;
156         
157         sound = G.buts->lockpoin;
158         
159         switch(event) {
160         case B_SOUND_REDRAW:
161                 allqueue(REDRAWBUTSSCENE, 0);
162                 break;
163
164         case B_SOUND_LOAD_SAMPLE:
165                 if (sound) strcpy(name, sound->name);
166                 else strcpy(name, U.sounddir);
167                         
168                 activate_fileselect(FILE_SPECIAL, "SELECT WAV FILE", name, load_new_sample);
169                 break;
170
171         case B_SOUND_PLAY_SAMPLE:
172                 if (sound) {
173                         if (sound->sample->type != SAMPLE_INVALID) {
174                                 sound_play_sound(sound);
175                                 allqueue(REDRAWBUTSSCENE, 0);
176                         }
177                 }
178                 break;
179
180         case B_SOUND_MENU_SAMPLE:
181                 if (G.buts->menunr == -2) {
182                         if (sound) {
183                                 activate_databrowse((ID *)sound->sample, ID_SAMPLE, 0, B_SOUND_MENU_SAMPLE, &G.buts->menunr, do_soundbuts);
184                         }
185                 } else if (G.buts->menunr > 0) {
186                         sample = BLI_findlink(samples, G.buts->menunr - 1);
187                         if (sample && sound) {
188                                 BLI_strncpy(sound->name, sample->name, sizeof(sound->name));
189                                 sound_set_sample(sound, sample);
190                                 do_soundbuts(B_SOUND_REDRAW);
191                         }
192                 }
193                         
194                 break;
195         case B_SOUND_NAME_SAMPLE:
196                 load_new_sample(sound->name);
197                 break;
198         
199         case B_SOUND_UNPACK_SAMPLE:
200                 if(sound && sound->sample) {
201                         sample = sound->sample;
202                         
203                         if (sample->packedfile) {
204                                 if (G.fileflags & G_AUTOPACK) {
205                                         if (okee("Disable AutoPack ?")) {
206                                                 G.fileflags &= ~G_AUTOPACK;
207                                         }
208                                 }
209                                 
210                                 if ((G.fileflags & G_AUTOPACK) == 0) {
211                                         unpackSample(sample, PF_ASK);
212                                 }
213                         } else {
214                                 sound_set_packedfile(sample, newPackedFile(sample->name));
215                         }
216                         allqueue(REDRAWHEADERS, 0);
217                         do_soundbuts(B_SOUND_REDRAW);
218                 }
219                 break;
220
221         case B_SOUND_COPY_SOUND:
222                 if (sound) {
223                         tempsound = sound_make_copy(sound);
224                         sound = tempsound;
225                         id = &sound->id;
226                         G.buts->lockpoin = (bSound*)id;
227                         BIF_undo_push("Copy sound");
228                         do_soundbuts(B_SOUND_REDRAW);
229                 }
230                 break;
231
232         case B_SOUND_RECALC:
233                 waitcursor(1);
234                 sound = G.main->sound.first;
235                 while (sound) {
236                         MEM_freeN(sound->stream);
237                         sound->stream = 0;
238                         audio_makestream(sound);
239                         sound = (bSound *) sound->id.next;
240                 }
241                 waitcursor(0);
242                 allqueue(REDRAWSEQ, 0);
243                 break;
244
245         case B_SOUND_RATECHANGED:
246
247                 allqueue(REDRAWBUTSSCENE, 0);
248                 allqueue(REDRAWSEQ, 0);
249                 break;
250
251         case B_SOUND_MIXDOWN:
252                 audio_mixdown();
253                 break;
254
255         default: 
256                 if (G.f & G_DEBUG) {
257                         printf("do_soundbuts: unhandled event %d\n", event);
258                 }
259         }
260 }
261
262
263 static void sound_panel_listener(void)
264 {
265         uiBlock *block;
266         int xco= 100, yco=100, mixrate;
267         char mixrateinfo[256];
268         
269         block= uiNewBlock(&curarea->uiblocks, "sound_panel_listener", UI_EMBOSS, UI_HELV, curarea->win);
270         if(uiNewPanel(curarea, block, "Listener", "Sound", 320, 0, 318, 204)==0) return;
271
272         mixrate = sound_get_mixrate();
273         sprintf(mixrateinfo, "Game Mixrate: %d Hz", mixrate);
274         uiDefBut(block, LABEL, 0, mixrateinfo, xco,yco,295,20, 0, 0, 0, 0, 0, "");
275
276         yco -= 30;
277         uiDefBut(block, LABEL, 0, "Game listener settings:",xco,yco,195,20, 0, 0, 0, 0, 0, "");
278
279         yco -= 30;
280         uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Volume: ",
281                 xco,yco,195,24,&G.listener->gain, 0.0, 1.0, 1.0, 0, "Sets the maximum volume for the overall sound");
282         
283         yco -= 30;
284         uiDefBut(block, LABEL, 0, "Game Doppler effect settings:",xco,yco,195,20, 0, 0, 0, 0, 0, "");
285
286         yco -= 30;
287         uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Doppler: ",
288         xco,yco,195,24,&G.listener->dopplervelocity, 0.0, 10.0, 1.0, 0, "Use this for scaling the doppler effect");
289
290         
291 }
292
293 static void sound_panel_sequencer(void)
294 {
295         uiBlock *block;
296         short xco, yco;
297         char mixrateinfo[256];
298         
299         block= uiNewBlock(&curarea->uiblocks, "sound_panel_sequencer", UI_EMBOSS, UI_HELV, curarea->win);
300         if(uiNewPanel(curarea, block, "Sequencer", "Sound", 640, 0, 318, 204)==0) return;
301
302         /* audio sequence engine settings ------------------------------------------------------------------ */
303
304         xco = 1010;
305         yco = 195;
306
307         uiDefBut(block, LABEL, 0, "Audio sequencer settings", xco,yco,295,20, 0, 0, 0, 0, 0, "");
308
309         yco -= 25;
310         sprintf(mixrateinfo, "Mixing/Sync (latency: %d ms)", (int)( (((float)U.mixbufsize)/(float)G.scene->audio.mixrate)*1000.0 ) );
311         uiDefBut(block, LABEL, 0, mixrateinfo, xco,yco,295,20, 0, 0, 0, 0, 0, "");
312
313         yco -= 25;              
314         uiDefButI(block, ROW, B_SOUND_RATECHANGED, "44.1 kHz",  xco,yco,75,20, &G.scene->audio.mixrate, 2.0, 44100.0, 0, 0, "Mix at 44.1 kHz");
315         uiDefButI(block, ROW, B_SOUND_RATECHANGED, "48.0 kHz",          xco+80,yco,75,20, &G.scene->audio.mixrate, 2.0, 48000.0, 0, 0, "Mix at 48 kHz");
316         uiDefBut(block, BUT, B_SOUND_RECALC, "Recalc",          xco+160,yco,75,20, 0, 0, 0, 0, 0, "Recalculate samples");
317
318         yco -= 25;
319         uiDefButS(block, TOG|BIT|1, B_SOUND_CHANGED, "Sync",    xco,yco,115,20, &G.scene->audio.flag, 0, 0, 0, 0, "Use sample clock for syncing animation to audio");
320         uiDefButS(block, TOG|BIT|2, B_SOUND_CHANGED, "Scrub",           xco+120,yco,115,20, &G.scene->audio.flag, 0, 0, 0, 0, "Scrub when changing frames");
321
322         yco -= 25;
323         uiDefBut(block, LABEL, 0, "Main mix", xco,yco,295,20, 0, 0, 0, 0, 0, "");
324
325         yco -= 25;              
326         uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Main (dB): ",
327                 xco,yco,235,24,&G.scene->audio.main, -24.0, 6.0, 0, 0, "Set the audio master gain/attenuation in dB");
328
329         yco -= 25;
330         uiDefButS(block, TOG|BIT|0, 0, "Mute",  xco,yco,235,24, &G.scene->audio.flag, 0, 0, 0, 0, "Mute audio from sequencer");         
331         
332         yco -= 35;
333         uiDefBut(block, BUT, B_SOUND_MIXDOWN, "MIXDOWN",        xco,yco,235,24, 0, 0, 0, 0, 0, "Create WAV file from sequenced audio");
334         
335 }
336
337 static void sound_panel_sound(bSound *sound)
338 {
339         static int packdummy=0;
340         ID *id, *idfrom;
341         uiBlock *block;
342         bSample *sample;
343         char *strp, str[32], ch[256];
344
345         block= uiNewBlock(&curarea->uiblocks, "sound_panel_sound", UI_EMBOSS, UI_HELV, curarea->win);
346         if(uiNewPanel(curarea, block, "Sound", "Sound", 0, 0, 318, 204)==0) return;
347         
348         uiDefBut(block, LABEL, 0, "Blender Sound block",10,180,195,20, 0, 0, 0, 0, 0, "");
349         
350         // warning: abuse of texnr here! (ton didnt code!)
351         buttons_active_id(&id, &idfrom);
352         std_libbuttons(block, 10, 160, 0, NULL, B_SOUNDBROWSE2, id, idfrom, &(G.buts->texnr), 1, 0, 0, 0, 0);
353
354         if (sound) {
355         
356                 uiDefBut(block, BUT, B_SOUND_COPY_SOUND, "Copy sound", 220,160,90,20, 0, 0, 0, 0, 0, "Make another copy (duplicate) of the current sound");
357
358                 uiSetButLock(sound->id.lib!=0, "Can't edit library data");
359                 sound_initialize_sample(sound);
360                 sample = sound->sample;
361
362                 /* info string */
363                 if (sound->sample && sound->sample->len) {
364                         char *tmp;
365                         if (sound->sample->channels == 1) tmp= "Mono";
366                         else if (sound->sample->channels == 2) tmp= "Stereo";
367                         else tmp= "Unknown";
368                         
369                         sprintf(ch, "Sample: %s, %d bit, %d Hz, %d samples", tmp, sound->sample->bits, sound->sample->rate, (sound->sample->len/(sound->sample->bits/8)/sound->sample->channels));
370                         uiDefBut(block, LABEL, 0, ch,                   35,140,225,20, 0, 0, 0, 0, 0, "");
371                 }
372                 else {
373                         uiDefBut(block, LABEL, 0, "Sample: No sample info available.",35,140,225,20, 0, 0, 0, 0, 0, "");
374                 }
375
376                 /* sample browse buttons */
377
378                 id= (ID *)sound->sample;
379                 IDnames_to_pupstring(&strp, NULL, NULL, samples, id, &(G.buts->menunr));
380                 if (strp[0]) uiDefButS(block, MENU, B_SOUND_MENU_SAMPLE, strp, 10,120,23,20, &(G.buts->menunr), 0, 0, 0, 0, "Select another loaded sample");
381                 MEM_freeN(strp);
382                 
383                 uiDefBut(block, TEX, B_SOUND_NAME_SAMPLE, "",           35,120,225,20, sound->name, 0.0, 79.0, 0, 0, "The sample file used by this Sound");
384                 
385                 sprintf(str, "%d", sample->id.us);
386                 uiDefBut(block, BUT, B_SOUND_UNLINK_SAMPLE, str,        260,120,25,20, 0, 0, 0, 0, 0, "The number of users");
387                 
388                 if (sound->sample->packedfile) packdummy = 1;
389                 else packdummy = 0;
390                 
391                 uiDefIconButI(block, TOG|BIT|0, B_SOUND_UNPACK_SAMPLE, ICON_PACKAGE,
392                         285, 120,25,24, &packdummy, 0, 0, 0, 0,"Pack/Unpack this sample");
393                 
394                 uiDefBut(block, BUT, B_SOUND_LOAD_SAMPLE, "Load sample", 10, 95,150,24, 0, 0, 0, 0, 0, "Load a different sample file");
395
396                 uiDefBut(block, BUT, B_SOUND_PLAY_SAMPLE, "Play",       160, 95, 150, 24, 0, 0.0, 0, 0, 0, "Playback sample using settings below");
397                 
398                 uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Volume: ",
399                         10,70,150,20, &sound->volume, 0.0, 1.0, 0, 0, "Game engine only: Set the volume of this sound");
400
401                 uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Pitch: ",
402                         160,70,150,20, &sound->pitch, -12.0, 12.0, 0, 0, "Game engine only: Set the pitch of this sound");
403
404                 /* looping */
405                 uiDefButI(block, TOG|BIT|SOUND_FLAGS_LOOP_BIT, B_SOUND_REDRAW, "Loop",
406                         10, 50, 95, 20, &sound->flags, 0.0, 0.0, 0, 0, "Game engine only: Toggle between looping on/off");
407
408                 if (sound->flags & SOUND_FLAGS_LOOP) {
409                         uiDefButI(block, TOG|BIT|SOUND_FLAGS_BIDIRECTIONAL_LOOP_BIT, B_SOUND_REDRAW, "Ping Pong",
410                                 105, 50, 95, 20, &sound->flags, 0.0, 0.0, 0, 0, "Game engine only: Toggle between A->B and A->B->A looping");
411                         
412                 }
413         
414
415                 /* 3D settings ------------------------------------------------------------------ */
416
417                 if (sound->sample->channels == 1) {
418                         uiDefButI(block, TOG|BIT|SOUND_FLAGS_3D_BIT, B_SOUND_REDRAW, "3D Sound",
419                                 10, 10, 90, 20, &sound->flags, 0, 0, 0, 0, "Game engine only: Turns 3D sound on");
420                         
421                         if (sound->flags & SOUND_FLAGS_3D) {
422                                 uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Scale: ",
423                                         100,10,210,20, &sound->attenuation, 0.0, 5.0, 1.0, 0, "Game engine only: Sets the surround scaling factor for this sound");
424                                 
425                         }
426                 }
427         }
428 }
429
430
431 /* ************************* SCENE *********************** */
432
433
434 static void output_pic(char *name)
435 {
436         strcpy(G.scene->r.pic, name);
437         allqueue(REDRAWBUTSSCENE, 0);
438 }
439
440 static void backbuf_pic(char *name)
441 {
442         Image *ima;
443         
444         strcpy(G.scene->r.backbuf, name);
445         allqueue(REDRAWBUTSSCENE, 0);
446
447         ima= add_image(name);
448         if(ima) {
449                 free_image_buffers(ima);        /* force read again */
450                 ima->ok= 1;
451         }
452 }
453
454 static void ftype_pic(char *name)
455 {
456         strcpy(G.scene->r.ftype, name);
457         allqueue(REDRAWBUTSSCENE, 0);
458 }
459
460
461 static void scene_change_set(Scene *sc, Scene *set) {
462         if (sc->set!=set) {
463                 sc->set= set;
464                 
465                 allqueue(REDRAWBUTSSCENE, 0);
466                 allqueue(REDRAWVIEW3D, 0);
467         }
468 }
469
470 static void run_playanim(char *file) {
471         extern char bprogname[];        /* usiblender.c */
472         char str[FILE_MAXDIR+FILE_MAXFILE];
473         int pos[2], size[2];
474
475         calc_renderwin_rectangle(R.winpos, pos, size);
476
477         sprintf(str, "%s -a -p %d %d \"%s\"", bprogname, pos[0], pos[1], file);
478         system(str);
479 }
480
481 void do_render_panels(unsigned short event)
482 {
483         ScrArea *sa;
484         ID *id;
485         char file[FILE_MAXDIR+FILE_MAXFILE];
486
487         switch(event) {
488
489         case B_DORENDER:
490                 BIF_do_render(0);
491                 break;
492         case B_RTCHANGED:
493                 allqueue(REDRAWALL, 0);
494                 break;
495         case B_PLAYANIM:
496 #ifdef WITH_QUICKTIME
497                 if(G.scene->r.imtype == R_QUICKTIME)
498                         makeqtstring(file);
499                 else
500 #endif
501                         makeavistring(file);
502                 if(BLI_exist(file)) {
503                         run_playanim(file);
504                 }
505                 else {
506                         makepicstring(file, G.scene->r.sfra);
507                         if(BLI_exist(file)) {
508                                 run_playanim(file);
509                         }
510                         else error("Can't find image: %s", file);
511                 }
512                 break;
513                 
514         case B_DOANIM:
515                 BIF_do_render(1);
516                 break;
517         
518         case B_FS_PIC:
519                 sa= closest_bigger_area();
520                 areawinset(sa->win);
521                 if(G.qual == LR_CTRLKEY)
522                         activate_imageselect(FILE_SPECIAL, "SELECT OUTPUT PICTURES", G.scene->r.pic, output_pic);
523                 else
524                         activate_fileselect(FILE_SPECIAL, "SELECT OUTPUT PICTURES", G.scene->r.pic, output_pic);
525                 break;
526
527         case B_FS_BACKBUF:
528                 sa= closest_bigger_area();
529                 areawinset(sa->win);
530                 if(G.qual == LR_CTRLKEY)
531                         activate_imageselect(FILE_SPECIAL, "SELECT BACKBUF PICTURE", G.scene->r.backbuf, backbuf_pic);
532                 else
533                         activate_fileselect(FILE_SPECIAL, "SELECT BACKBUF PICTURE", G.scene->r.backbuf, backbuf_pic);
534                 break;
535
536         case B_FS_FTYPE:
537                 sa= closest_bigger_area();
538                 areawinset(sa->win);
539                 if(G.qual == LR_CTRLKEY)
540                         activate_imageselect(FILE_SPECIAL, "SELECT FTYPE", G.scene->r.ftype, ftype_pic);
541                 else
542                         activate_fileselect(FILE_SPECIAL, "SELECT FTYPE", G.scene->r.ftype, ftype_pic);
543                 break;
544         
545         case B_PR_PAL:
546                 G.scene->r.xsch= 720;
547                 G.scene->r.ysch= 576;
548                 G.scene->r.xasp= 54;
549                 G.scene->r.yasp= 51;
550                 G.scene->r.size= 100;
551                 G.scene->r.frs_sec= 25;
552                 G.scene->r.mode &= ~R_PANORAMA;
553                 G.scene->r.xparts=  G.scene->r.yparts= 1;
554                 
555                 BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9);
556                 BIF_undo_push("Set PAL");
557                 allqueue(REDRAWBUTSSCENE, 0);
558                 allqueue(REDRAWVIEWCAM, 0);
559                 break;
560
561 #ifdef WITH_QUICKTIME
562         case B_FILETYPEMENU:
563                 allqueue(REDRAWBUTSSCENE, 0);
564 #if defined (_WIN32) || defined (__APPLE__)
565                 // fall through to codec settings if this is the first
566                 // time R_AVICODEC is selected for this scene.
567                 if (((G.scene->r.imtype == R_AVICODEC) 
568                          && (G.scene->r.avicodecdata == NULL)) ||
569                         ((G.scene->r.imtype == R_QUICKTIME) 
570                          && (G.scene->r.qtcodecdata == NULL))) {
571                 } else {
572                   break;
573                 }
574 #else /* libquicktime */
575                 if(G.scene->r.imtype == R_QUICKTIME) {
576                         /* i'm not sure if this should be here... */
577                         /* set default quicktime codec */
578                         if (!G.scene->r.qtcodecdata) {
579                                 G.scene->r.qtcodecdata = MEM_callocN(sizeof(QtCodecData),   "QtCodecData");
580                                 qtcodec_idx = 1;
581                         }
582                         
583                         qt_init_codecs();
584                         if (qtcodec_idx < 1) qtcodec_idx = 1;   
585                         
586                         G.scene->r.qtcodecdata->fourcc =  qtcodecidx_to_fcc(qtcodec_idx-1);
587                         qt_init_codecdata(G.scene->r.qtcodecdata);
588 /* I'm not sure if this is really needed, so don't remove it yet */
589 #if 0
590                         /* get index of codec that can handle a given fourcc */
591                         if (qtcodec_idx < 1)
592                                 qtcodec_idx = get_qtcodec_idx(G.scene->r.qtcodecdata->fourcc)+1;
593
594                         /* no suitable codec found, alert user */
595                         if (qtcodec_idx < -1) {
596                                 error("no suitable codec found!");
597                                 qtcodec_idx = 1;
598                         }
599 #endif /* 0 */
600                 }
601 #endif /*_WIN32 || __APPLE__ */
602
603         case B_SELECTCODEC:
604 #if defined (_WIN32) || defined (__APPLE__)
605                 if ((G.scene->r.imtype == R_QUICKTIME)) { /* || (G.scene->r.qtcodecdata)) */
606                         get_qtcodec_settings();
607                 }
608 #ifdef _WIN32
609                 else
610                         get_avicodec_settings();
611 #endif /* _WIN32 */
612 #else /* libquicktime */
613                 if (!G.scene->r.qtcodecdata) {
614                         G.scene->r.qtcodecdata = MEM_callocN(sizeof(QtCodecData),  "QtCodecData");
615                         qtcodec_idx = 1;
616                 }
617                 if (qtcodec_idx < 1) {
618                         qtcodec_idx = 1;
619                         qt_init_codecs();
620                 }
621
622                 G.scene->r.qtcodecdata->fourcc = qtcodecidx_to_fcc(qtcodec_idx-1);
623                 /* if the selected codec differs from the previous one, reinit it */
624                 qt_init_codecdata(G.scene->r.qtcodecdata);      
625                 allqueue(REDRAWBUTSSCENE, 0);
626 #endif /* _WIN32 || __APPLE__ */
627                 break;
628 #endif /* WITH_QUICKTIME */
629
630         case B_PR_FULL:
631                 G.scene->r.xsch= 1280;
632                 G.scene->r.ysch= 1024;
633                 G.scene->r.xasp= 1;
634                 G.scene->r.yasp= 1;
635                 G.scene->r.size= 100;
636                 G.scene->r.mode &= ~R_PANORAMA;
637                 G.scene->r.xparts=  G.scene->r.yparts= 1;
638
639                 BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9);
640                 BIF_undo_push("Set FULL");
641                 allqueue(REDRAWBUTSSCENE, 0);
642                 allqueue(REDRAWVIEWCAM, 0);
643                 break;
644         case B_PR_PRV:
645                 G.scene->r.xsch= 640;
646                 G.scene->r.ysch= 512;
647                 G.scene->r.xasp= 1;
648                 G.scene->r.yasp= 1;
649                 G.scene->r.size= 50;
650                 G.scene->r.mode &= ~R_PANORAMA;
651                 G.scene->r.xparts=  G.scene->r.yparts= 1;
652
653                 BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9);
654                 allqueue(REDRAWVIEWCAM, 0);
655                 allqueue(REDRAWBUTSSCENE, 0);
656                 break;
657         case B_PR_CDI:
658                 G.scene->r.xsch= 384;
659                 G.scene->r.ysch= 280;
660                 G.scene->r.xasp= 1;
661                 G.scene->r.yasp= 1;
662                 G.scene->r.size= 100;
663                 G.scene->r.mode &= ~R_PANORAMA;
664                 G.scene->r.xparts=  G.scene->r.yparts= 1;
665
666                 BLI_init_rctf(&G.scene->r.safety, 0.15, 0.85, 0.15, 0.85);
667                 allqueue(REDRAWVIEWCAM, 0);
668                 allqueue(REDRAWBUTSSCENE, 0);
669                 break;
670         case B_PR_PAL169:
671                 G.scene->r.xsch= 720;
672                 G.scene->r.ysch= 576;
673                 G.scene->r.xasp= 64;
674                 G.scene->r.yasp= 45;
675                 G.scene->r.size= 100;
676                 G.scene->r.frs_sec= 25;
677                 G.scene->r.mode &= ~R_PANORAMA;
678                 G.scene->r.xparts=  G.scene->r.yparts= 1;
679
680                 BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9);
681                 BIF_undo_push("Set PAL 16/9");
682                 allqueue(REDRAWVIEWCAM, 0);
683                 allqueue(REDRAWBUTSSCENE, 0);
684                 break;
685         case B_PR_D2MAC:
686                 G.scene->r.xsch= 1024;
687                 G.scene->r.ysch= 576;
688                 G.scene->r.xasp= 1;
689                 G.scene->r.yasp= 1;
690                 G.scene->r.size= 50;
691                 G.scene->r.mode &= ~R_PANORAMA;
692                 G.scene->r.xparts=  G.scene->r.yparts= 1;
693
694                 BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9);
695                 allqueue(REDRAWVIEWCAM, 0);
696                 allqueue(REDRAWBUTSSCENE, 0);
697                 break;
698         case B_PR_MPEG:
699                 G.scene->r.xsch= 368;
700                 G.scene->r.ysch= 272;
701                 G.scene->r.xasp= 105;
702                 G.scene->r.yasp= 100;
703                 G.scene->r.size= 100;
704                 G.scene->r.mode &= ~R_PANORAMA;
705                 G.scene->r.xparts=  G.scene->r.yparts= 1;
706
707                 BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9);
708                 allqueue(REDRAWVIEWCAM, 0);
709                 allqueue(REDRAWBUTSSCENE, 0);
710                 break;
711         case B_PR_PC:
712                 G.scene->r.xsch= 640;
713                 G.scene->r.ysch= 480;
714                 G.scene->r.xasp= 100;
715                 G.scene->r.yasp= 100;
716                 G.scene->r.size= 100;
717                 G.scene->r.mode &= ~R_PANORAMA;
718                 G.scene->r.xparts=  G.scene->r.yparts= 1;
719
720                 BLI_init_rctf(&G.scene->r.safety, 0.0, 1.0, 0.0, 1.0);
721                 BIF_undo_push("Set PC");
722                 allqueue(REDRAWVIEWCAM, 0);
723                 allqueue(REDRAWBUTSSCENE, 0);
724                 break;
725         case B_PR_PRESET:
726                 G.scene->r.xsch= 720;
727                 G.scene->r.ysch= 576;
728                 G.scene->r.xasp= 54;
729                 G.scene->r.yasp= 51;
730                 G.scene->r.size= 100;
731                 G.scene->r.mode= R_OSA+R_SHADOW+R_FIELDS;
732                 G.scene->r.imtype= R_TARGA;
733                 G.scene->r.xparts=  G.scene->r.yparts= 1;
734
735                 BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9);
736                 BIF_undo_push("Set Default");
737                 allqueue(REDRAWVIEWCAM, 0);
738                 allqueue(REDRAWBUTSSCENE, 0);
739                 break;
740         case B_PR_PANO:
741                 G.scene->r.xsch= 36;
742                 G.scene->r.ysch= 176;
743                 G.scene->r.xasp= 115;
744                 G.scene->r.yasp= 100;
745                 G.scene->r.size= 100;
746                 G.scene->r.mode |= R_PANORAMA;
747                 G.scene->r.xparts=  16;
748                 G.scene->r.yparts= 1;
749
750                 BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9);
751                 BIF_undo_push("Set Panorama");
752                 allqueue(REDRAWVIEWCAM, 0);
753                 allqueue(REDRAWBUTSSCENE, 0);
754                 break;
755         case B_PR_NTSC:
756                 G.scene->r.xsch= 720;
757                 G.scene->r.ysch= 480;
758                 G.scene->r.xasp= 10;
759                 G.scene->r.yasp= 11;
760                 G.scene->r.size= 100;
761                 G.scene->r.frs_sec= 30;
762                 G.scene->r.mode &= ~R_PANORAMA;
763                 G.scene->r.xparts=  G.scene->r.yparts= 1;
764                 
765                 BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9);
766                 BIF_undo_push("Set NTSC");
767                 allqueue(REDRAWBUTSSCENE, 0);
768                 allqueue(REDRAWVIEWCAM, 0);
769                 break;
770
771         case B_SETBROWSE:
772                 id= (ID*) G.scene->set;
773                 
774                 if (G.buts->menunr==-2) {
775                          activate_databrowse(id, ID_SCE, 0, B_SETBROWSE, &G.buts->menunr, do_render_panels);
776                 } else if (G.buts->menunr>0) {
777                         Scene *newset= (Scene*) BLI_findlink(&G.main->scene, G.buts->menunr-1);
778                         
779                         if (newset==G.scene)
780                                 error("Not allowed");
781                         else if (newset)
782                                 scene_change_set(G.scene, newset);
783                 }  
784                 break;
785         case B_CLEARSET:
786                 scene_change_set(G.scene, NULL);
787                 BIF_undo_push("Clear set");
788                 break;
789         }
790 }
791
792 static uiBlock *edge_render_menu(void *arg_unused)
793 {
794         uiBlock *block;
795         
796         block= uiNewBlock(&curarea->uiblocks, "edge render", UI_EMBOSS, UI_HELV, curarea->win);
797                 
798         /* use this for a fake extra empy space around the buttons */
799         uiDefBut(block, LABEL, 0, "",  285, -20, 230, 125, NULL,  0, 0, 0, 0, "");
800         
801         uiBlockBeginAlign(block);
802         uiDefButS(block, NUM, 0,"Eint:",        370,75,135,19,  &G.scene->r.edgeint, 0.0, 255.0, 0, 0,
803                   "Sets edge intensity for Toon shading");
804         uiDefButS(block, NUM, 0,"AntiShift",370,55,135,19,  &(G.scene->r.same_mat_redux), 0, 255.0, 0, 0,
805                   "For unified renderer: reduce intensity on boundaries "
806                   "with identical materials with this number.");
807
808         uiBlockBeginAlign(block);
809         uiDefButI(block, TOG, 0,"Shift",        295,75,70,19,  &G.compat, 0, 0, 0, 0,
810                   "For unified renderer: use old offsets for edges");
811         uiDefButI(block, TOG, 0,"All",          295,55,70,19,  &G.notonlysolid, 0, 0, 0, 0,
812                   "For unified renderer: also consider transparent faces for toon shading");
813         uiBlockEndAlign(block);
814         
815         /* colour settings for the toon shading */
816         uiDefButF(block, COL, 0, "",            295,-10,30,60,  &(G.scene->r.edgeR), 0, 0, 0, B_EDGECOLSLI, "");
817         
818         uiBlockBeginAlign(block);
819         uiDefButF(block, NUMSLI, 0, "R ",   330, 30, 175,19,   &G.scene->r.edgeR, 0.0, 1.0, B_EDGECOLSLI, 0,
820                   "For unified renderer: Colour for edges in toon shading mode.");
821         uiDefButF(block, NUMSLI, 0, "G ",       330, 10, 175,19,  &G.scene->r.edgeG, 0.0, 1.0, B_EDGECOLSLI, 0,
822                   "For unified renderer: Colour for edges in toon shading mode.");
823         uiDefButF(block, NUMSLI, 0, "B ",       330, -10, 175,19,  &G.scene->r.edgeB, 0.0, 1.0, B_EDGECOLSLI, 0,
824                   "For unified renderer: Colour for edges in toon shading mode.");
825
826         
827         uiBlockSetDirection(block, UI_TOP);
828         
829         return block;
830 }
831
832 static uiBlock *post_render_menu(void *arg_unused)
833 {
834         uiBlock *block;
835         
836         block= uiNewBlock(&curarea->uiblocks, "post render", UI_EMBOSS, UI_HELV, curarea->win);
837                 
838         /* use this for a fake extra empy space around the buttons */
839         uiDefBut(block, LABEL, 0, "",                   -10, 10, 200, 80, NULL, 0, 0, 0, 0, "");
840         
841         uiDefButF(block, NUMSLI, 0,"Add:",              0,60,180,19,  &G.scene->r.postadd, -1.0, 1.0, 0, 0, "");
842         uiDefButF(block, NUMSLI, 0,"Mul:",              0,40,180,19,  &G.scene->r.postmul, 0.01, 4.0, 0, 0, "");
843         uiDefButF(block, NUMSLI, 0,"Gamma:",            0,20,180,19,  &G.scene->r.postgamma, 0.2, 2.0, 0, 0, "");
844
845         uiBlockSetDirection(block, UI_TOP);
846         
847         return block;
848 }
849
850
851 static uiBlock *framing_render_menu(void *arg_unused)
852 {
853         uiBlock *block;
854         short yco = 190, xco = 0;
855         int randomcolorindex = 1234;
856
857         block= uiNewBlock(&curarea->uiblocks, "framing_options", UI_EMBOSS, UI_HELV, curarea->win);
858
859         /* use this for a fake extra empy space around the buttons */
860         uiDefBut(block, LABEL, 0, "",                   -10, -10, 300, 229, NULL, 0, 0, 0, 0, "");
861
862         uiDefBut(block, LABEL, B_NOP, "Framing:", xco, yco, 68,19, 0, 0, 0, 0, 0, "");
863         uiBlockBeginAlign(block);
864         uiDefButC(block, ROW, 0, "Stretch",     xco += 70, yco, 68, 19, &G.scene->framing.type, 1.0, SCE_GAMEFRAMING_SCALE , 0, 0, "Stretch or squeeze the viewport to fill the display window");
865         uiDefButC(block, ROW, 0, "Expose",      xco += 70, yco, 68, 19, &G.scene->framing.type, 1.0, SCE_GAMEFRAMING_EXTEND, 0, 0, "Show the entire viewport in the display window, viewing more horizontally or vertically");
866         uiDefButC(block, ROW, 0, "Letterbox",       xco += 70, yco, 68, 19, &G.scene->framing.type, 1.0, SCE_GAMEFRAMING_BARS  , 0, 0, "Show the entire viewport in the display window, using bar horizontally or vertically");
867         uiBlockEndAlign(block);
868
869         yco -= 25;
870         xco = 40;
871
872         uiDefButF(block, COL, 0, "",                0, yco - 58 + 18, 33, 58, &G.scene->framing.col[0], 0, 0, 0, randomcolorindex, "");
873
874         uiBlockBeginAlign(block);
875         uiDefButF(block, NUMSLI, 0, "R ", xco,yco,243,18, &G.scene->framing.col[0], 0.0, 1.0, randomcolorindex, 0, "Set the red component of the bars");
876         yco -= 20;
877         uiDefButF(block, NUMSLI, 0, "G ", xco,yco,243,18, &G.scene->framing.col[1], 0.0, 1.0, randomcolorindex, 0, "Set the green component of the bars");
878         yco -= 20;
879         uiDefButF(block, NUMSLI, 0, "B ", xco,yco,243,18, &G.scene->framing.col[2], 0.0, 1.0, randomcolorindex, 0, "Set the blue component of the bars");
880         uiBlockEndAlign(block);
881         
882         xco = 0;
883         uiDefBut(block, LABEL, 0, "Fullscreen:",                xco, yco-=30, 100, 19, 0, 0.0, 0.0, 0, 0, "");
884         uiDefButS(block, TOG, 0, "Fullscreen", xco+70, yco, 68, 19, &G.scene->r.fullscreen, 0.0, 0.0, 0, 0, "Starts player in a new fullscreen display");
885         uiBlockBeginAlign(block);
886         uiDefButS(block, NUM, 0, "X:",          xco+40, yco-=27, 100, 19,               &G.scene->r.xplay, 10.0, 2000.0, 0, 0, "Displays current X screen/window resolution. Click to change.");
887         uiDefButS(block, NUM, 0, "Freq:",       xco+140, yco, 100, 19, &G.scene->r.freqplay, 10.0, 120.0, 0, 0, "Displays clock frequency of fullscreen display. Click to change.");
888         uiDefButS(block, NUM, 0, "Y:",          xco+40, yco-=21, 100, 19, &G.scene->r.yplay, 10.0, 2000.0, 0, 0, "Displays current Y screen/window resolution. Click to change.");
889         uiDefButS(block, NUM, 0, "Bits:",       xco+140, yco, 100, 19, &G.scene->r.depth, 8.0, 32.0, 800.0, 0, "Displays bit depth of full screen display. Click to change.");
890         uiBlockEndAlign(block);
891
892         /* stereo settings */
893         /* can't use any definition from the game engine here so hardcode it. Change it here when it changes there!
894          * RAS_IRasterizer has definitions:
895          * RAS_STEREO_NOSTEREO           1
896          * RAS_STEREO_QUADBUFFERED 2
897          * RAS_STEREO_ABOVEBELOW         3
898          * RAS_STEREO_INTERLACED         4       future
899          * RAS_STEREO_ANAGLYPH          5
900          * RAS_STEREO_SIDEBYSIDE        6
901          * RAS_STEREO_VINTERLACE        7
902          */
903         uiBlockBeginAlign(block);
904         uiDefButS(block, ROW, 0, "No Stereo", xco, yco-=30, 88, 19, &(G.scene->r.stereomode), 7.0, 1.0, 0, 0, "Disables stereo");
905         uiDefButS(block, ROW, 0, "Pageflip", xco+=90, yco, 88, 19, &(G.scene->r.stereomode), 7.0, 2.0, 0, 0, "Enables hardware pageflip stereo method");
906         uiDefButS(block, ROW, 0, "Syncdouble", xco+=90, yco, 88, 19, &(G.scene->r.stereomode), 7.0, 3.0, 0, 0, "Enables syncdoubling stereo method");
907         uiDefButS(block, ROW, 0, "Anaglyph", xco-=180, yco-=21, 88, 19, &(G.scene->r.stereomode), 7.0, 5.0, 0, 0, "Enables anaglyph (Red-Blue) stereo method");
908         uiDefButS(block, ROW, 0, "Side by Side", xco+=90, yco, 88, 19, &(G.scene->r.stereomode), 7.0, 6.0, 0, 0, "Enables side by side left and right images");
909         uiDefButS(block, ROW, 0, "V Interlace", xco+=90, yco, 88, 19, &(G.scene->r.stereomode), 7.0, 7.0, 0, 0, "Enables interlaced vertical strips for autostereo display");
910         
911         uiBlockEndAlign(block);
912
913         uiBlockSetDirection(block, UI_TOP);
914
915         return block;
916 }
917
918
919 static char *imagetype_pup(void)
920 {
921         static char string[1024];
922         char formatstring[1024];
923
924         strcpy(formatstring, "Save image as: %%t|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d");
925
926 #ifdef __sgi
927         strcat(formatstring, "|%s %%x%d");      // add space for Movie
928 #endif
929
930         strcat(formatstring, "|%s %%x%d");      // add space for PNG
931         strcat(formatstring, "|%s %%x%d");      // add space for BMP
932
933 #ifdef _WIN32
934         strcat(formatstring, "|%s %%x%d");      // add space for AVI Codec
935 #endif
936
937 #ifdef WITH_QUICKTIME
938         if(G.have_quicktime)
939                 strcat(formatstring, "|%s %%x%d");      // add space for Quicktime
940 #endif
941
942         if(G.have_quicktime) {
943                 sprintf(string, formatstring,
944                         "AVI Raw",        R_AVIRAW,
945                         "AVI Jpeg",       R_AVIJPEG,
946 #ifdef _WIN32
947                         "AVI Codec",      R_AVICODEC,
948 #endif
949 #ifdef WITH_QUICKTIME
950                         "QuickTime",      R_QUICKTIME,
951 #endif
952                         "Targa",          R_TARGA,
953                         "Targa Raw",      R_RAWTGA,
954                         "PNG",            R_PNG,
955                         "BMP",            R_BMP,
956                         "Jpeg",           R_JPEG90,
957                         "HamX",           R_HAMX,
958                         "Iris",           R_IRIS,
959                         "Iris + Zbuffer", R_IRIZ,
960                         "Ftype",          R_FTYPE,
961                         "Movie",          R_MOVIE
962                 );
963         } else {
964                 sprintf(string, formatstring,
965                         "AVI Raw",        R_AVIRAW,
966                         "AVI Jpeg",       R_AVIJPEG,
967 #ifdef _WIN32
968                         "AVI Codec",      R_AVICODEC,
969 #endif
970                         "Targa",          R_TARGA,
971                         "Targa Raw",      R_RAWTGA,
972                         "PNG",            R_PNG,
973                         "BMP",            R_BMP,
974                         "Jpeg",           R_JPEG90,
975                         "HamX",           R_HAMX,
976                         "Iris",           R_IRIS,
977                         "Iris + Zbuffer", R_IRIZ,
978                         "Ftype",          R_FTYPE,
979                         "Movie",          R_MOVIE
980                 );
981         }
982
983         return (string);
984 }
985
986 #ifdef _WIN32
987 static char *avicodec_str(void)
988 {
989         static char string[1024];
990
991         sprintf(string, "Codec: %s", G.scene->r.avicodecdata->avicodecname);
992
993         return string;
994 }
995 #endif
996
997 static void render_panel_output(void)
998 {
999         ID *id;
1000         int a,b;
1001         uiBlock *block;
1002         char *strp;
1003
1004
1005         block= uiNewBlock(&curarea->uiblocks, "render_panel_output", UI_EMBOSS, UI_HELV, curarea->win);
1006         if(uiNewPanel(curarea, block, "Output", "Render", 0, 0, 318, 204)==0) return;
1007         
1008         uiBlockBeginAlign(block);
1009         uiDefIconBut(block, BUT, B_FS_PIC, ICON_FILESEL,        10, 190, 20, 20, 0, 0, 0, 0, 0, "Open Fileselect to get Pics dir/name");
1010         uiDefBut(block, TEX,0,"",                                                       31, 190, 279, 20,G.scene->r.pic, 0.0,79.0, 0, 0, "Directory/name to save rendered Pics to");
1011         uiDefIconBut(block, BUT,B_FS_BACKBUF, ICON_FILESEL, 10, 168, 20, 20, 0, 0, 0, 0, 0, "Open Fileselect to get Backbuf image");
1012         uiDefBut(block, TEX,0,"",                                                       31, 168, 279, 20,G.scene->r.backbuf, 0.0,79.0, 0, 0, "Image to use as background for rendering");
1013         uiDefIconBut(block, BUT,B_FS_FTYPE, ICON_FILESEL,       10, 146, 20, 20, 0, 0, 0, 0, 0, "Open Fileselect to get Ftype image");
1014         uiDefBut(block, TEX,0,"",                                                       31, 146, 279, 20,G.scene->r.ftype,0.0,79.0, 0, 0, "Image to use with FTYPE Image type");
1015         uiBlockEndAlign(block);
1016         
1017         
1018         /* SET BUTTON */
1019         uiBlockBeginAlign(block);
1020         id= (ID *)G.scene->set;
1021         IDnames_to_pupstring(&strp, NULL, NULL, &(G.main->scene), id, &(G.buts->menunr));
1022         if(strp[0])
1023                 uiDefButS(block, MENU, B_SETBROWSE, strp, 10, 120, 20, 20, &(G.buts->menunr), 0, 0, 0, 0, "Scene to link as a Set");
1024         MEM_freeN(strp);
1025
1026         if(G.scene->set) {
1027                 uiSetButLock(1, NULL);
1028                 uiDefIDPoinBut(block, test_scenepoin_but, 0, "",        31, 120, 100, 20, &(G.scene->set), "Name of the Set");
1029                 uiClearButLock();
1030                 uiDefIconBut(block, BUT, B_CLEARSET, ICON_X,            132, 120, 20, 20, 0, 0, 0, 0, 0, "Remove Set link");
1031         }
1032         uiBlockEndAlign(block);
1033
1034         uiBlockSetCol(block, TH_BUT_SETTING1);
1035         uiDefButS(block, TOG|BIT|0, 0,"Backbuf",        10, 94, 60, 20, &G.scene->r.bufflag, 0, 0, 0, 0, "Enable/Disable use of Backbuf image");        
1036         uiBlockSetCol(block, TH_AUTO);
1037                 
1038         uiBlockBeginAlign(block);
1039         for(b=2; b>=0; b--)
1040                 for(a=0; a<3; a++)
1041                         uiDefButS(block, TOG|BIT|(3*b+a), 800,"",       (short)(10+18*a),(short)(10+14*b),16,12, &R.winpos, 0, 0, 0, 0, "Render window placement on screen");
1042         uiBlockEndAlign(block);
1043
1044         uiBlockBeginAlign(block);
1045         uiDefButS(block, TOG|BIT|2, REDRAWVIEW3D, "Passepartout", 72, 30, 122, 20, &G.scene->r.scemode, 0.0, 0.0, 0, 0, "Draws darkened passepartout in camera view");
1046         uiDefButS(block, ROW, B_REDR, "DispWin",        72, 10, 60, 20, &R.displaymode, 0.0, (float)R_DISPLAYWIN, 0, 0, "Sets render output to display in a seperate window");
1047         uiDefButS(block, ROW, B_REDR, "DispView",       134, 10, 60, 20, &R.displaymode, 0.0, (float)R_DISPLAYVIEW, 0, 0, "Sets render output to display in 3D view");
1048         uiBlockEndAlign(block);
1049
1050         uiDefButS(block, TOG|BIT|4, 0, "Extensions",    250, 10, 60, 20, &G.scene->r.scemode, 0.0, 0.0, 0, 0, "Adds extensions to the output when rendering animations");
1051
1052         /* Dither control */
1053         uiDefButF(block, NUM,B_DIFF, "Dither:",         205,31,105,19, &G.scene->r.dither_intensity, 0.0, 2.0, 0, 0, "The amount of dithering noise present in the output image (0.0 = no dithering)");
1054
1055         /* Toon shading buttons */
1056         uiBlockBeginAlign(block);
1057         uiDefButI(block, TOG|BIT|5, 0,"Edge",   155, 94, 44, 20, &G.scene->r.mode, 0, 0, 0, 0, "Enable Toon shading");
1058         uiDefBlockBut(block, edge_render_menu, NULL, "Edge Settings", 200, 94, 110, 20, "Display edge settings");
1059         uiBlockEndAlign(block);
1060
1061         /* unified render buttons */
1062         if(G.scene->r.mode & R_UNIFIED) {
1063                 uiDefBlockBut(block, post_render_menu, NULL, "Post process", 200, 68, 110, 20, "Only for unified render");
1064                 if (G.scene->r.mode & R_GAMMA) {
1065                         uiDefButF(block, NUMSLI, 0,"Gamma:",            10, 68, 142, 20,
1066                                          &(G.scene->r.gamma), 0.2, 5.0, B_GAMMASLI, 0,
1067                                          "The gamma value for blending oversampled images (1.0 = no correction).");
1068                 }
1069         }
1070 }
1071
1072 static void render_panel_render(void)
1073 {
1074         uiBlock *block;
1075
1076
1077         block= uiNewBlock(&curarea->uiblocks, "render_panel_render", UI_EMBOSS, UI_HELV, curarea->win);
1078         if(uiNewPanel(curarea, block, "Render", "Render", 320, 0, 318, 204)==0) return;
1079
1080         uiBlockBeginAlign(block);
1081         uiDefBut(block, BUT,B_DORENDER,"RENDER",        369, 164, 191,37, 0, 0, 0, 0, 0, "Start the rendering");
1082         /* yafray: on request, render engine menu is back again, and moved to Render panel */
1083         uiDefButS(block, MENU, B_REDR, "Rendering Engine %t|Blender Internal %x0|YafRay %x1", 
1084                                                                                                 369, 142, 191, 20, &G.scene->r.renderer, 0, 0, 0, 0, "Choose rendering engine");        
1085
1086         uiBlockBeginAlign(block);
1087         uiDefButI(block, TOG|BIT|0, 0, "OSA",           369,109,122,20,&G.scene->r.mode, 0, 0, 0, 0, "Enables Oversampling (Anti-aliasing)");
1088         uiDefButS(block, ROW,B_DIFF,"5",                        369,88,29,20,&G.scene->r.osa,2.0,5.0, 0, 0, "Sets oversample level to 5");
1089         uiDefButS(block, ROW,B_DIFF,"8",                        400,88,29,20,&G.scene->r.osa,2.0,8.0, 0, 0, "Sets oversample level to 8 (Recommended)");
1090         uiDefButS(block, ROW,B_DIFF,"11",                       431,88,29,20,&G.scene->r.osa,2.0,11.0, 0, 0, "Sets oversample level to 11");
1091         uiDefButS(block, ROW,B_DIFF,"16",                       462,88,29,20,&G.scene->r.osa,2.0,16.0, 0, 0, "Sets oversample level to 16");
1092         uiBlockEndAlign(block);
1093
1094         uiBlockBeginAlign(block);
1095         uiDefButI(block, TOG|BIT|14, 0, "MBLUR",        496,109,64,20,&G.scene->r.mode, 0, 0, 0, 0, "Enables Motion Blur calculation");
1096         uiDefButF(block, NUM,B_DIFF,"Bf:",                      496,88,64,20,&G.scene->r.blurfac, 0.01, 5.0, 10, 2, "Sets motion blur factor");
1097         uiBlockEndAlign(block);
1098
1099         uiBlockBeginAlign(block);
1100         uiDefButS(block, NUM,B_DIFF,"Xparts:",          369,46,95,29,&G.scene->r.xparts,1.0, 64.0, 0, 0, "Sets the number of horizontal parts to render image in (For panorama sets number of camera slices)");
1101         uiDefButS(block, NUM,B_DIFF,"Yparts:",          465,46,95,29,&G.scene->r.yparts,1.0, 64.0, 0, 0, "Sets the number of vertical parts to render image in");
1102         uiBlockEndAlign(block);
1103
1104         uiBlockBeginAlign(block);
1105         uiDefButS(block, ROW,800,"Sky",         369,13,35,20,&G.scene->r.alphamode,3.0,0.0, 0, 0, "Fill background with sky");
1106         uiDefButS(block, ROW,800,"Premul",      405,13,50,20,&G.scene->r.alphamode,3.0,1.0, 0, 0, "Multiply alpha in advance");
1107         uiDefButS(block, ROW,800,"Key",         456,13,35,20,&G.scene->r.alphamode,3.0,2.0, 0, 0, "Alpha and colour values remain unchanged");
1108         uiBlockEndAlign(block);
1109         
1110         if(G.scene->r.mode & R_RAYTRACE)
1111                 uiDefButS(block, MENU, B_DIFF,"Octree resolution %t|64 %x64|128 %x128|256 %x256|512 %x512",     496,13,64,20,&G.scene->r.ocres,0.0,0.0, 0, 0, "Octree resolution for ray tracing");
1112
1113         uiBlockBeginAlign(block);
1114         uiDefButI(block, TOG|BIT|1,0,"Shadow",  565,172,60,29, &G.scene->r.mode, 0, 0, 0, 0, "Enable shadow calculation");
1115         uiDefButI(block, TOG|BIT|4,0,"EnvMap",  627,172,60,29, &G.scene->r.mode, 0, 0, 0, 0, "Enable environment map rendering");
1116         uiDefButI(block, TOG|BIT|10,0,"Pano",   565,142,40,29, &G.scene->r.mode, 0, 0, 0, 0, "Enable panorama rendering (output width is multiplied by Xparts)");
1117         uiDefButI(block, TOG|BIT|16,B_REDR,"Ray",606,142,40,29, &G.scene->r.mode, 0, 0, 0, 0, "Enable ray tracing");
1118         uiDefButI(block, TOG|BIT|8,0,"Radio",   647,142,40,29, &G.scene->r.mode, 0, 0, 0, 0, "Enable radiosity rendering");
1119         uiBlockEndAlign(block);
1120         
1121         uiBlockBeginAlign(block);
1122         uiDefButS(block, ROW,B_DIFF,"100%",                     565,109,122,20,&G.scene->r.size,1.0,100.0, 0, 0, "Set render size to defined size");
1123         uiDefButS(block, ROW,B_DIFF,"75%",                      565,88,40,20,&G.scene->r.size,1.0,75.0, 0, 0, "Set render size to 3/4 of defined size");
1124         uiDefButS(block, ROW,B_DIFF,"50%",                      606,88,40,20,&G.scene->r.size,1.0,50.0, 0, 0, "Set render size to 1/2 of defined size");
1125         uiDefButS(block, ROW,B_DIFF,"25%",                      647,88,40,20,&G.scene->r.size,1.0,25.0, 0, 0, "Set render size to 1/4 of defined size");
1126         uiBlockEndAlign(block);
1127
1128         uiBlockBeginAlign(block);
1129         uiDefButI(block, TOG|BIT|6,0,"Fields",  565,55,60,20,&G.scene->r.mode, 0, 0, 0, 0, "Enables field rendering");
1130         uiDefButI(block, TOG|BIT|13,0,"Odd",    627,55,39,20,&G.scene->r.mode, 0, 0, 0, 0, "Enables Odd field first rendering (Default: Even field)");
1131         uiDefButI(block, TOG|BIT|7,0,"X",               668,55,19,20,&G.scene->r.mode, 0, 0, 0, 0, "Disables time difference in field calculations");
1132         
1133         if(G.scene->r.mode & R_UNIFIED) uiBlockBeginAlign(block);
1134         else {
1135                 uiDefButI(block, TOG|BIT|17,0,"Gauss",  565,34,60,20, &G.scene->r.mode, 0, 0, 0, 0, "Enable Gaussian sampling filter for antialiasing");
1136                 uiDefButF(block, NUM,B_DIFF,"",                 627,34,60,20,&G.scene->r.gauss,0.5, 1.5, 100, 2, "Sets the Gaussian filter size");
1137         }
1138         
1139         uiDefButI(block, TOG|BIT|9,REDRAWVIEWCAM, "Border",     565,13,60,20, &G.scene->r.mode, 0, 0, 0, 0, "Render a small cut-out of the image");
1140         uiDefButI(block, TOG|BIT|2, B_REDR, "Gamma",    627,13,60,20, &G.scene->r.mode, 0, 0, 0, 0, "Enable gamma correction");
1141         uiBlockEndAlign(block);
1142
1143 }
1144
1145 static void render_panel_anim(void)
1146 {
1147         uiBlock *block;
1148
1149
1150         block= uiNewBlock(&curarea->uiblocks, "render_panel_anim", UI_EMBOSS, UI_HELV, curarea->win);
1151         if(uiNewPanel(curarea, block, "Anim", "Render", 640, 0, 318, 204)==0) return;
1152
1153
1154         uiDefBut(block, BUT,B_DOANIM,"ANIM",            692,142,192,47, 0, 0, 0, 0, 0, "Start rendering a sequence");
1155
1156         uiBlockSetCol(block, TH_BUT_SETTING1);
1157         uiBlockBeginAlign(block);
1158         uiDefButS(block, TOG|BIT|0, 0, "Do Sequence",692,114,192,20, &G.scene->r.scemode, 0, 0, 0, 0, "Enables sequence output rendering (Default: 3D rendering)");
1159         uiDefButS(block, TOG|BIT|1, 0, "Render Daemon",692,90,192,20, &G.scene->r.scemode, 0, 0, 0, 0, "Let external network render current scene");
1160         uiBlockEndAlign(block);
1161
1162         uiBlockSetCol(block, TH_AUTO);
1163         uiDefBut(block, BUT,B_PLAYANIM, "PLAY",692,40,94,33, 0, 0, 0, 0, 0, "Play animation of rendered images/avi (searches Pics: field)");
1164         uiDefButS(block, NUM, B_RTCHANGED, "rt:",789,40,95,33, &G.rt, -1000.0, 1000.0, 0, 0, "General testing/debug button");
1165
1166         uiBlockBeginAlign(block);
1167         uiDefButS(block, NUM,REDRAWSEQ,"Sta:",692,10,94,24, &G.scene->r.sfra,1.0,18000.0, 0, 0, "The start frame of the animation");
1168         uiDefButS(block, NUM,REDRAWSEQ,"End:",789,10,95,24, &G.scene->r.efra,1.0,18000.0, 0, 0, "The end  frame of the animation");
1169         uiBlockEndAlign(block);
1170 }
1171
1172 static void render_panel_format(void)
1173 {
1174         uiBlock *block;
1175         int yofs;
1176
1177
1178         block= uiNewBlock(&curarea->uiblocks, "render_panel_format", UI_EMBOSS, UI_HELV, curarea->win);
1179         if(uiNewPanel(curarea, block, "Format", "Render", 960, 0, 318, 204)==0) return;
1180         uiDefBlockBut(block, framing_render_menu, NULL, 
1181                                   "Game framing settings", 
1182                                   892, 169, 227, 20, "Display game framing settings");
1183         /* uiDefIconTextBlockBut(block, framing_render_menu, NULL, 
1184                                                    ICON_BLOCKBUT_CORNER, 
1185                                                    "Game framing settings", 
1186                                                    892, 169, 227, 20, 
1187                                                    "Display game framing settings"); */
1188
1189         uiBlockBeginAlign(block);
1190         uiDefButS(block, NUM,REDRAWVIEWCAM,"SizeX:",    892 ,136,112,27, &G.scene->r.xsch, 4.0, 10000.0, 0, 0, "The image width in pixels");
1191         uiDefButS(block, NUM,REDRAWVIEWCAM,"SizeY:",    1007,136,112,27, &G.scene->r.ysch, 4.0,10000.0, 0, 0, "The image height in scanlines");
1192         uiDefButS(block, NUM,REDRAWVIEWCAM,"AspX:",     892 ,114,112,20, &G.scene->r.xasp, 1.0,200.0, 0, 0, "The horizontal aspect ratio");
1193         uiDefButS(block, NUM,REDRAWVIEWCAM,"AspY:",     1007,114,112,20, &G.scene->r.yasp, 1.0,200.0, 0, 0, "The vertical aspect ratio");
1194         uiBlockEndAlign(block);
1195
1196         yofs = 54;
1197
1198 #ifdef __sgi
1199         yofs = 76;
1200         uiDefButS(block, NUM,B_DIFF,"MaxSize:", 892,32,165,20, &G.scene->r.maximsize, 0.0, 500.0, 0, 0, "Maximum size per frame to save in an SGI movie");
1201         uiDefButI(block, TOG|BIT|12,0,"Cosmo", 1059,32,60,20, &G.scene->r.mode, 0, 0, 0, 0, "Attempt to save SGI movies using Cosmo hardware");
1202 #endif
1203
1204         uiDefButS(block, MENU,B_FILETYPEMENU,imagetype_pup(),   892,yofs,174,20, &G.scene->r.imtype, 0, 0, 0, 0, "Images are saved in this file format");
1205         uiDefButI(block, TOG|BIT|11,B_DIFF, "Crop",          1068,yofs,51,20, &G.scene->r.mode, 0, 0, 0, 0, "Exclude border rendering from total image");
1206
1207         yofs -= 22;
1208
1209         if(G.scene->r.quality==0) G.scene->r.quality= 90;
1210
1211 #ifdef WITH_QUICKTIME
1212         if (G.scene->r.imtype == R_AVICODEC || G.scene->r.imtype == R_QUICKTIME) {
1213 #else /* WITH_QUICKTIME */
1214         if (0) {
1215 #endif
1216                 if(G.scene->r.imtype == R_QUICKTIME) {
1217 #ifdef WITH_QUICKTIME
1218 #if defined (_WIN32) || defined (__APPLE__)
1219                         //glColor3f(0.65, 0.65, 0.7);
1220                         //glRecti(892,yofs+46,892+225,yofs+45+20);
1221                         if(G.scene->r.qtcodecdata == NULL)
1222                                 uiDefBut(block, LABEL, 0, "Codec: not set",  892,yofs+44,225,20, 0, 0, 0, 0, 0, "");
1223                         else
1224                                 uiDefBut(block, LABEL, 0, G.scene->r.qtcodecdata->qtcodecname,  892,yofs+44,225,20, 0, 0, 0, 0, 0, "");
1225                         uiDefBut(block, BUT,B_SELECTCODEC, "Set codec",  892,yofs,112,20, 0, 0, 0, 0, 0, "Set codec settings for Quicktime");
1226 #else /* libquicktime */
1227                         if (!G.scene->r.qtcodecdata) G.scene->r.qtcodecdata = MEM_callocN(sizeof(QtCodecData), "QtCodecData");
1228                         uiDefButI(block, MENU, B_SELECTCODEC, qtcodecs_pup(), 892,yofs, 112, 20, &qtcodec_idx, 0, 0, 0, 0, "Codec");
1229                         /* make sure the codec stored in G.scene->r.qtcodecdata matches the selected
1230                          * one, especially if it's not set.. */
1231                         if (!G.scene->r.qtcodecdata->fourcc) {
1232                                 G.scene->r.qtcodecdata->fourcc = qtcodecidx_to_fcc(qtcodec_idx-1);
1233                                 qt_init_codecdata(G.scene->r.qtcodecdata);      
1234                         }
1235
1236                         yofs -= 22;
1237                         uiDefBlockBut(block, qtcodec_menu, NULL, "Codec Settings", 892,yofs, 227, 20, "Edit Codec settings for QuickTime");
1238                         yofs +=22;
1239
1240 #endif /* libquicktime */
1241 #endif /* WITH_QUICKTIME */
1242                 } else {
1243 #ifdef _WIN32
1244                         //glColor3f(0.65, 0.65, 0.7);
1245                         //glRecti(892,yofs+46,892+225,yofs+45+20);
1246                         if(G.scene->r.avicodecdata == NULL)
1247                                 uiDefBut(block, LABEL, 0, "Codec: not set.",  892,yofs+43,225,20, 0, 0, 0, 0, 0, "");
1248                         else
1249                                 uiDefBut(block, LABEL, 0, avicodec_str(),  892,yofs+43,225,20, 0, 0, 0, 0, 0, "");
1250 #endif
1251                         uiDefBut(block, BUT,B_SELECTCODEC, "Set codec",  892,yofs,112,20, 0, 0, 0, 0, 0, "Set codec settings for AVI");
1252                 }
1253         } else {
1254                 uiDefButS(block, NUM,B_DIFF, "Quality:",           892,yofs,112,20, &G.scene->r.quality, 10.0, 100.0, 0, 0, "Quality setting for JPEG images, AVI Jpeg and SGI movies");
1255         }
1256         uiDefButS(block, NUM,REDRAWALL,"Frs/sec:",   1006,yofs,113,20, &G.scene->r.frs_sec, 1.0, 120.0, 100.0, 0, "Frames per second");
1257
1258
1259         uiBlockBeginAlign(block);
1260         uiDefButS(block, ROW,B_DIFF,"BW",                       892, 10,74,19, &G.scene->r.planes, 5.0,(float)R_PLANESBW, 0, 0, "Images are saved with BW (grayscale) data");
1261         uiDefButS(block, ROW,B_DIFF,"RGB",                  968, 10,74,19, &G.scene->r.planes, 5.0,(float)R_PLANES24, 0, 0, "Images are saved with RGB (color) data");
1262         uiDefButS(block, ROW,B_DIFF,"RGBA",                1044, 10,75,19, &G.scene->r.planes, 5.0,(float)R_PLANES32, 0, 0, "Images are saved with RGB and Alpha data (if supported)");
1263
1264         uiBlockBeginAlign(block);
1265         uiDefBut(block, BUT,B_PR_PAL, "PAL",            1146,170,100,18, 0, 0, 0, 0, 0, "Size preset: Image size - 720x576, Aspect ratio - 54x51, 25 fps");
1266         uiDefBut(block, BUT,B_PR_NTSC, "NTSC",          1146,150,100,18, 0, 0, 0, 0, 0, "Size preset: Image size - 720x480, Aspect ratio - 10x11, 30 fps");
1267         uiDefBut(block, BUT,B_PR_PRESET, "Default",     1146,130,100,18, 0, 0, 0, 0, 0, "Same as PAL, with render settings (OSA, Shadows, Fields)");
1268         uiDefBut(block, BUT,B_PR_PRV, "Preview",        1146,110,100,18, 0, 0, 0, 0, 0, "Size preset: Image size - 640x512, Render size 50%");
1269         uiDefBut(block, BUT,B_PR_PC, "PC",                      1146,90,100,18, 0, 0, 0, 0, 0, "Size preset: Image size - 640x480, Aspect ratio - 100x100");
1270         uiDefBut(block, BUT,B_PR_PAL169, "PAL 16:9",1146,70,100,18, 0, 0, 0, 0, 0, "Size preset: Image size - 720x576, Aspect ratio - 64x45");
1271         uiDefBut(block, BUT,B_PR_PANO, "PANO",          1146,50,100,18, 0, 0, 0, 0, 0, "Standard panorama settings");
1272         uiDefBut(block, BUT,B_PR_FULL, "FULL",          1146,30,100,18, 0, 0, 0, 0, 0, "Size preset: Image size - 1280x1024, Aspect ratio - 1x1");
1273         uiDefButI(block, TOG|BIT|15, B_REDR, "Unified Renderer", 1146,10,100,18,  &G.scene->r.mode, 0, 0, 0, 0, "Use the unified renderer.");
1274         uiBlockEndAlign(block);
1275 }
1276
1277
1278 /* yafray: global illumination options panel */
1279 static void render_panel_yafrayGI()
1280 {
1281         uiBlock *block;
1282
1283         block= uiNewBlock(&curarea->uiblocks, "render_panel_yafrayGI", UI_EMBOSS, UI_HELV, curarea->win);
1284         uiNewPanelTabbed("Render", "Render");
1285         if(uiNewPanel(curarea, block, "YafRay GI", "Render", 320, 0, 318, 204)==0) return;
1286
1287         // label to force a boundbox for buttons not to be centered
1288         uiDefBut(block, LABEL, 0, " ", 305,180,10,10, 0, 0, 0, 0, 0, "");
1289
1290         uiDefBut(block, LABEL, 0, "Method", 5,175,70,20, 0, 1.0, 0, 0, 0, "");
1291         uiDefButS(block, MENU, B_REDR, "GiMethod %t|None %x0|SkyDome %x1|Full %x2 |", 70,175,89,20, &G.scene->r.GImethod, 0, 0, 0, 0, "Global Illumination Method");
1292         uiDefBut(block, LABEL, 0, "Quality", 5,150,70,20, 0, 1.0, 0, 0, 0, "");
1293         uiDefButS(block, MENU, B_REDR, "GiQuality %t|None %x0|Low %x1|Medium %x2 |High %x3|Higher %x4|Best %x5|", 
1294                         70,150,89,20, &G.scene->r.GIquality, 0, 0, 0, 0, "Global Illumination Quality");
1295
1296         if (G.scene->r.GImethod>0) {
1297                 uiDefButF(block, NUM, B_DIFF, "EmitPwr:", 5,35,154,20, &G.scene->r.GIpower, 0.01, 100.0, 10, 0, "arealight, material emit and background intensity scaling, 1 is normal");
1298                 if (G.scene->r.GImethod==2) uiDefButF(block, NUM, B_DIFF, "GI Pwr:", 5,10,154,20, &G.scene->r.GIindirpower, 0.01, 100.0, 10, 0, "GI indirect lighting intensity scaling, 1 is normal");
1299         }
1300
1301         if (G.scene->r.GImethod==2) 
1302         {
1303                 if (G.scene->r.GIdepth==0) G.scene->r.GIdepth=2;
1304                 uiDefButI(block, NUM, B_DIFF, "Depth:", 180,175,110,20, &G.scene->r.GIdepth, 1.0, 100.0, 10, 10, "Number of bounces of the indirect light");
1305                 uiDefButI(block, NUM, B_DIFF, "CDepth:", 180,150,110,20, &G.scene->r.GIcausdepth, 1.0, 100.0, 10, 10, "Number of bounces inside objects (for caustics)");
1306                 uiDefButS(block,TOG|BIT|0, B_REDR, "Cache",70,125,89,20, &G.scene->r.GIcache, 0, 0, 0, 0, "Cache irradiance samples (faster)");
1307                 uiDefButS(block,TOG|BIT|0, B_REDR, "Photons",180,125,89,20, &G.scene->r.GIphotons, 0, 0, 0, 0, "Use global photons to help in GI");
1308                 if (G.scene->r.GIcache) 
1309                 {
1310                         uiDefBut(block, LABEL, 0, "Cache parameters:", 5,105,130,20, 0, 1.0, 0, 0, 0, "");
1311                         if (G.scene->r.GIshadowquality==0.0) G.scene->r.GIshadowquality=0.9;
1312                         uiDefButF(block, NUM, B_DIFF,"ShadQu:", 5,85,154,20,    &(G.scene->r.GIshadowquality), 0.01, 1.0 ,1,0, "Sets the shadow quality, keep it under 0.95 :-) ");
1313                         if (G.scene->r.GIpixelspersample==0) G.scene->r.GIpixelspersample=10;
1314                         uiDefButI(block, NUM, B_DIFF, "Prec:",  5,60,75,20, &G.scene->r.GIpixelspersample, 1, 50, 10, 10, "Maximum number of pixels without samples, the lower the better and slower");
1315                         if (G.scene->r.GIrefinement==0) G.scene->r.GIrefinement=1.0;
1316                         uiDefButF(block, NUM, B_DIFF, "Ref:", 80,60,75,20, &G.scene->r.GIrefinement, 0.001, 1.0, 1, 0, "Threshold to refine shadows EXPERIMENTAL. 1 = no refinement");
1317                 }
1318                 if (G.scene->r.GIphotons) 
1319                 {
1320                         uiDefBut(block, LABEL, 0, "Photon parameters:", 170,105,130,20, 0, 1.0, 0, 0, 0, "");
1321                         if(G.scene->r.GIphotoncount==0) G.scene->r.GIphotoncount=100000;
1322                         uiDefButI(block, NUM, B_DIFF, "Count:", 170,85,140,20, &G.scene->r.GIphotoncount, 
1323                                         0, 10000000, 10, 10, "Number of photons to shoot");
1324                         if(G.scene->r.GIphotonradius==0.0) G.scene->r.GIphotonradius=1.0;
1325                         uiDefButF(block, NUMSLI, B_DIFF,"Radius:", 170,60,140,20,       &(G.scene->r.GIphotonradius), 
1326                                         0.00001, 100.0 ,0,0, "Radius to search for photons to mix (blur)");
1327                         if(G.scene->r.GImixphotons==0) G.scene->r.GImixphotons=100;
1328                         uiDefButI(block, NUM, B_DIFF, "MixCount:", 170,35,140,20, &G.scene->r.GImixphotons, 
1329                                         0, 1000, 10, 10, "Number of photons to mix");
1330                         uiDefButS(block,TOG|BIT|0, B_REDR, "Tune Photons",170,10,140,20, &G.scene->r.GIdirect, 
1331                                         0, 0, 0, 0, "Show the photonmap directly in the render for tuning");
1332                 }
1333         }
1334 }
1335
1336 /* yafray: global  options panel */
1337 static void render_panel_yafrayGlobal()
1338 {
1339         uiBlock *block;
1340
1341         block= uiNewBlock(&curarea->uiblocks, "render_panel_yafrayGlobal", UI_EMBOSS, UI_HELV, curarea->win);
1342         uiNewPanelTabbed("Render", "Render");
1343         if(uiNewPanel(curarea, block, "YafRay", "Render", 320, 0, 318, 204)==0) return;
1344
1345         // label to force a boundbox for buttons not to be centered
1346         uiDefBut(block, LABEL, 0, " ", 305,180,10,10, 0, 0, 0, 0, 0, "");
1347
1348         uiDefButF(block, NUMSLI, B_DIFF,"Bi ", 5,35,150,20,     &(G.scene->r.YF_raybias), 
1349                                 0.0, 10.0 ,0,0, "Shadow ray bias to avoid self shadowing");
1350   uiDefButI(block, NUM, B_DIFF, "Raydepth ", 5,60,150,20,
1351                                 &G.scene->r.YF_raydepth, 1.0, 80.0, 10, 10, "Maximum render ray depth from the camera");
1352         uiDefButF(block, NUMSLI, B_DIFF, "Gam ", 5,10,150,20, &G.scene->r.YF_gamma, 0.001, 5.0, 0, 0, "Gamma correction, 1 is off");
1353         uiDefButF(block, NUMSLI, B_DIFF, "Exp ", 160,10,150,20,&G.scene->r.YF_exposure, 0.0, 10.0, 0, 0, "Exposure adjustment, 0 is off");
1354         
1355   uiDefButI(block, NUM, B_DIFF, "Processors:", 160,35,150,20,
1356                                 &G.scene->r.YF_numprocs, 1.0, 8.0, 10, 10, "Number of processors to use");
1357
1358         /*AA Settings*/
1359
1360         uiDefButS(block,TOGN|BIT|0, B_REDR, "Auto AA", 5,140,150,20, &G.scene->r.YF_AA, 
1361                                         0, 0, 0, 0, "Set AA using OSA and GI quality, disable for manual control");
1362         uiDefButS(block,TOGN|BIT|0, B_REDR, "xml", 175,140,75,20, &G.scene->r.YFexportxml,
1363                                         0, 0, 0, 0, "Export to an xml file and call yafray instead of plugin");
1364         if(G.scene->r.YF_AA){
1365                 uiDefButI(block, NUM, B_DIFF, "AA Passes ", 5,115,150,20, &G.scene->r.YF_AApasses, 0, 64, 10, 10, "Number of AA passes (0 is no AA)");
1366                 uiDefButI(block, NUM, B_DIFF, "AA Samples ", 160,115,150,20, &G.scene->r.YF_AAsamples, 0, 2048, 10, 10, "Number of samples per pass");
1367                 uiDefButF(block, NUMSLI, B_DIFF, "Psz ", 5,90,150,20, &G.scene->r.YF_AApixelsize, 1.0, 2.0, 0, 0, "AA pixel filter size");
1368                 uiDefButF(block, NUMSLI, B_DIFF, "Thr ", 160,90,150,20, &G.scene->r.YF_AAthreshold, 0.000001, 1.0, 0, 0, "AA threshold");
1369         }
1370 }
1371
1372
1373 void render_panels()
1374 {
1375
1376         render_panel_output();
1377         render_panel_render();
1378         render_panel_anim();
1379         render_panel_format();
1380         /* yafray: GI & Global panel, only available when yafray enabled for rendering */
1381         if (G.scene->r.renderer==R_YAFRAY) {
1382                 if (G.scene->r.YF_gamma==0.0) G.scene->r.YF_gamma=1.0;
1383                 if (G.scene->r.YF_raybias==0.0) G.scene->r.YF_raybias=0.001;
1384                 if (G.scene->r.YF_raydepth==0) G.scene->r.YF_raydepth=5;
1385                 if (G.scene->r.YF_AApixelsize==0.0) G.scene->r.YF_AApixelsize=1.5;
1386                 if (G.scene->r.YF_AAthreshold==0.0) G.scene->r.YF_AAthreshold=0.05;
1387                 if (G.scene->r.GIpower==0.0) G.scene->r.GIpower=1.0;
1388                 if (G.scene->r.GIindirpower==0.0) G.scene->r.GIindirpower=1.0;
1389                 render_panel_yafrayGlobal();
1390                 render_panel_yafrayGI();
1391         }
1392
1393 }
1394
1395 /* --------------------------------------------- */
1396
1397 void anim_panels()
1398 {
1399         uiBlock *block;
1400
1401         block= uiNewBlock(&curarea->uiblocks, "anim_panel", UI_EMBOSS, UI_HELV, curarea->win);
1402         if(uiNewPanel(curarea, block, "Anim", "Anim", 0, 0, 318, 204)==0) return;
1403
1404         uiDefButS(block, NUM,REDRAWSEQ,"Sta:",  320,17,93,27,&G.scene->r.sfra,1.0,18000.0, 0, 0, "Specify the start frame of the animation");
1405         uiDefButS(block, NUM,REDRAWSEQ,"End:",  416,17,95,27,&G.scene->r.efra,1.0,18000.0, 0, 0, "Specify the end frame of the animation");
1406
1407         uiDefButS(block, NUM,B_FRAMEMAP,"Map Old:",     320,69,93,22,&G.scene->r.framapto,1.0,900.0, 0, 0, "Specify old map value in frames");
1408         uiDefButS(block, NUM,B_FRAMEMAP,"Map New:",     416,69,95,22,&G.scene->r.images,1.0,900.0, 0, 0, "Specify new map value in frames");
1409
1410         uiDefButS(block, NUM,REDRAWSEQ,"Frs/sec:",   320,47,93,19, &G.scene->r.frs_sec, 1.0, 120.0, 100.0, 0, "Frames per second");
1411
1412         uiDefButS(block, TOG|BIT|1, B_SOUND_CHANGED, "Sync",    416,47,95,19, &G.scene->audio.flag, 0, 0, 0, 0, "Use sample clock for syncing animation to audio");
1413
1414
1415 }
1416
1417 /* --------------------------------------------- */
1418
1419 void sound_panels()
1420 {
1421         bSound *sound;
1422
1423         sound = G.buts->lockpoin;
1424
1425         sound_panel_sound(sound);
1426         sound_panel_listener();
1427         sound_panel_sequencer();
1428 }
1429
1430
1431