4 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
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
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.
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.
23 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
24 * All rights reserved.
26 * The Original Code is: all of this file.
28 * Contributor(s): none yet.
30 * ***** END GPL/BL DUAL LICENSE BLOCK *****
42 #include "IMB_imbuf_types.h"
43 #include "IMB_imbuf.h"
45 #include "MEM_guardedalloc.h"
47 #include "DNA_curve_types.h"
48 #include "DNA_image_types.h"
49 #include "DNA_lamp_types.h"
50 #include "DNA_material_types.h"
51 #include "DNA_object_types.h"
52 #include "DNA_node_types.h"
53 #include "DNA_packedFile_types.h"
54 #include "DNA_radio_types.h"
55 #include "DNA_screen_types.h"
56 #include "DNA_space_types.h"
57 #include "DNA_scene_types.h"
58 #include "DNA_texture_types.h"
59 #include "DNA_userdef_types.h"
60 #include "DNA_view3d_types.h"
61 #include "DNA_world_types.h"
63 #include "BKE_displist.h"
64 #include "BKE_effect.h"
65 #include "BKE_global.h"
66 #include "BKE_library.h"
69 #include "BKE_material.h"
70 #include "BKE_utildefines.h"
71 #include "BKE_texture.h"
73 #include "BKE_packedFile.h"
74 #include "BKE_plugin_types.h"
75 #include "BKE_image.h"
77 #include "BLI_blenlib.h"
80 #include "BSE_filesel.h"
81 #include "BSE_headerbuttons.h"
85 #include "BIF_graphics.h"
86 #include "BIF_keyval.h"
87 #include "BIF_mainqueue.h"
88 #include "BIF_resources.h"
89 #include "BIF_screen.h"
90 #include "BIF_mywindow.h"
91 #include "BIF_space.h"
92 #include "BIF_glutil.h"
93 #include "BIF_interface.h"
94 #include "BIF_toolbox.h"
95 #include "BIF_space.h"
96 #include "BIF_previewrender.h"
97 #include "BIF_butspace.h"
98 #include "BIF_writeimage.h"
99 #include "BIF_toets.h"
101 #include "mydevice.h"
105 /* -----includes for this file specific----- */
107 #include "butspace.h" // own module
109 /* ---------function prototypes ------------- */
110 void load_tex_image(char *);
111 void load_plugin_tex(char *);
113 void save_env(char *);
115 static MTex emptytex;
116 static int packdummy = 0;
118 static char *mapto_blendtype_pup(void)
120 static char formatstr[] = "|%s %%x%d";
121 static char string[1024];
124 str += sprintf(str, formatstr, "Mix", MTEX_BLEND);
126 str += sprintf(str, formatstr, "Add", MTEX_ADD);
127 str += sprintf(str, formatstr, "Subtract", MTEX_SUB);
129 str += sprintf(str, formatstr, "Multiply", MTEX_MUL);
130 str += sprintf(str, formatstr, "Screen", MTEX_SCREEN);
131 str += sprintf(str, formatstr, "Overlay", MTEX_OVERLAY);
133 str += sprintf(str, formatstr, "Difference", MTEX_DIFF);
134 str += sprintf(str, formatstr, "Divide", MTEX_DIV);
136 str += sprintf(str, formatstr, "Darken", MTEX_DARK);
137 str += sprintf(str, formatstr, "Lighten", MTEX_LIGHT);
142 void shade_buttons_change_3d(void)
149 for(sa= G.curscreen->areabase.first; sa; sa= sa->next) {
150 if(sa->spacetype==SPACE_VIEW3D) {
151 View3D *v3d= sa->spacedata.first;
153 if(v3d->drawtype >= OB_SOLID) addqueue(sa->win, REDRAW, 0);
154 if(v3d->drawtype == OB_SHADED) {
155 if(ob->type==OB_LAMP) reshadeall_displist();
157 /* all objects using material */
158 Base *base= FIRSTBASE;
159 Material *ma= give_current_material(ob, ob->actcol);
163 if(base->lay & G.vd->lay) {
164 for(a=1; a<=ob->totcol; a++) {
165 if(ma == give_current_material(base->object, a)) {
166 freedisplist(&(base->object->disp));
179 /* *************************** TEXTURE ******************************** */
184 void load_tex_image(char *str) /* called from fileselect */
190 if(tex->type==TEX_IMAGE || tex->type==TEX_ENVMAP) {
199 free_image_buffers(ima); /* force reading again */
203 BIF_undo_push("Load image");
204 allqueue(REDRAWBUTSSHADING, 0);
206 BIF_preview_changed(ID_TE);
210 void load_plugin_tex(char *str) /* called from fileselect */
215 if(tex->type!=TEX_PLUGIN) return;
217 if(tex->plugin) free_plugin_tex(tex->plugin);
220 tex->plugin= add_plugin_tex(str);
222 allqueue(REDRAWBUTSSHADING, 0);
223 BIF_preview_changed(ID_TE);
226 void save_env(char *name)
229 char str[FILE_MAXDIR+FILE_MAXFILE];
232 BLI_convertstringcode(str, G.sce, G.scene->r.cfra);
233 tex= G.buts->lockpoin;
235 if(tex && GS(tex->id.name)==ID_TE) {
236 if(tex->env && tex->env->ok && saveover(str)) {
238 BIF_save_envmap(tex->env, str);
246 static int vergcband(const void *a1, const void *a2)
248 const CBData *x1=a1, *x2=a2;
250 if( x1->pos > x2->pos ) return 1;
251 else if( x1->pos < x2->pos) return -1;
255 void do_texbuts(unsigned short event)
262 char *name, str[FILE_MAXDIR+FILE_MAXFILE];
264 tex= G.buts->lockpoin;
268 BIF_preview_changed(ID_TE);
269 allqueue(REDRAWBUTSSHADING, 0);
271 if(tex && G.scene->nodetree) {
272 NodeTagIDChanged(G.scene->nodetree, &tex->id);
273 allqueue(RECALC_COMPOSITE, 0);
277 scrarea_queue_headredraw(curarea);
278 BIF_preview_changed(ID_TE);
279 allqueue(REDRAWBUTSSHADING, 0);
284 allqueue(REDRAWBUTSSHADING, 0);
285 BIF_preview_changed(ID_TE);
287 if(tex && G.scene->nodetree) {
288 NodeTagIDChanged(G.scene->nodetree, &tex->id);
289 allqueue(RECALC_COMPOSITE, 0);
295 BIF_undo_push("Default texture vars");
296 allqueue(REDRAWBUTSSHADING, 0);
297 BIF_preview_changed(ID_TE);
301 /* globals: temporal store them: we make another area a fileselect */
303 prv_win= curarea->win;
305 sa= closest_bigger_area();
307 if(tex->ima) name= tex->ima->name;
310 if (strcmp (U.textudir, "/") == 0)
316 else name = U.textudir;
319 if(G.qual==LR_CTRLKEY)
320 activate_imageselect(FILE_SPECIAL, "SELECT IMAGE", name, load_tex_image);
322 activate_fileselect(FILE_SPECIAL, "SELECT IMAGE", name, load_tex_image);
329 prv_win= curarea->win;
331 /* name in tex->ima has been changed by button! */
332 strcpy(str, tex->ima->name);
333 if(tex->ima->ibuf) strcpy(tex->ima->name, tex->ima->ibuf->name);
339 allqueue(REDRAWBUTSSHADING, 0);
340 BIF_preview_changed(ID_TE);
341 shade_buttons_change_3d();
347 if(G.buts->menunr== -2) {
348 activate_databrowse(id, ID_IM, 0, B_TEXIMABROWSE, &G.buts->menunr, do_texbuts);
349 } else if (G.buts->menunr>0) {
350 Image *newima= (Image*) BLI_findlink(&G.main->image, G.buts->menunr-1);
352 if (newima && newima!=(Image*) id) {
354 id_us_plus((ID*) newima);
357 BIF_undo_push("Browse image");
358 allqueue(REDRAWBUTSSHADING, 0);
359 BIF_preview_changed(ID_TE);
366 if( (tex->imaflag & (TEX_FIELDS+TEX_MIPMAP))== TEX_FIELDS+TEX_MIPMAP ) {
367 error("Cannot combine fields and mipmap");
368 tex->imaflag -= TEX_MIPMAP;
369 allqueue(REDRAWBUTSSHADING, 0);
372 if(tex->ima && tex->ima->ibuf) {
373 ibuf= tex->ima->ibuf;
375 if( !(tex->imaflag & TEX_FIELDS) && (ibuf->flags & IB_fields) ) nr= 1;
376 if( (tex->imaflag & TEX_FIELDS) && !(ibuf->flags & IB_fields) ) nr= 1;
381 BIF_preview_changed(ID_TE);
387 if(tex && tex->ima) {
388 // check if there is a newer packedfile
390 if (tex->ima->packedfile) {
392 pf = newPackedFile(tex->ima->name);
394 freePackedFile(tex->ima->packedfile);
395 tex->ima->packedfile = pf;
397 error("Image not available. Keeping packed image.");
401 IMB_freeImBuf(tex->ima->ibuf);
402 tex->ima->ibuf= NULL;
406 BKE_free_envmapdata(tex->env);
408 allqueue(REDRAWVIEW3D, 0);
409 allqueue(REDRAWIMAGE, 0);
410 BIF_preview_changed(ID_TE);
412 allqueue(REDRAWBUTSSHADING, 0); // redraw buttons
416 if(tex && tex->ima) {
419 allqueue(REDRAWBUTSSHADING, 0); // redraw buttons
420 BIF_preview_changed(ID_TE);
424 if(tex->ima->anim) tex->frames = IMB_anim_get_duration(tex->ima->anim);
425 allqueue(REDRAWBUTSSHADING, 0);
429 if(tex && tex->ima) {
430 if (tex->ima->packedfile) {
431 if (G.fileflags & G_AUTOPACK) {
432 if (okee("Disable AutoPack ?")) {
433 G.fileflags &= ~G_AUTOPACK;
437 if ((G.fileflags & G_AUTOPACK) == 0) {
438 unpackImage(tex->ima, PF_ASK);
441 if (tex->ima->ibuf && (tex->ima->ibuf->userflags & IB_BITMAPDIRTY)) {
442 error("Can't pack painted image. Save image from Image window first.");
444 tex->ima->packedfile = newPackedFile(tex->ima->name);
447 allqueue(REDRAWBUTSSHADING, 0);
448 allqueue(REDRAWHEADERS, 0);
454 /* globals: store temporal: we make another area a fileselect */
456 prv_win= curarea->win;
458 sa= closest_bigger_area();
460 if(tex->plugin) strcpy(str, tex->plugin->name);
462 strcpy(str, U.plugtexdir);
464 activate_fileselect(FILE_SPECIAL, "SELECT PLUGIN", str, load_plugin_tex);
469 if(tex==0 || tex->plugin==0) return;
470 strcpy(str, tex->plugin->name);
471 free_plugin_tex(tex->plugin);
473 tex->plugin= add_plugin_tex(str);
474 allqueue(REDRAWBUTSSHADING, 0);
475 BIF_preview_changed(ID_TE);
480 if(tex->coba==0) tex->coba= add_colorband(0);
481 allqueue(REDRAWBUTSSHADING, 0);
482 BIF_preview_changed(ID_TE); // also ramps, so we do this
487 BKE_free_envmap(tex->env);
489 allqueue(REDRAWBUTSSHADING, 0);
490 BIF_preview_changed(ID_TE);
495 BKE_free_envmapdata(tex->env);
496 allqueue(REDRAWBUTSSHADING, 0);
497 BIF_preview_changed(ID_TE);
501 tex= G.main->tex.first;
503 if(tex->id.us && tex->type==TEX_ENVMAP) {
505 if(tex->env->stype!=ENV_LOAD) BKE_free_envmapdata(tex->env);
510 allqueue(REDRAWBUTSSHADING, 0);
511 BIF_preview_changed(ID_TE);
514 if(tex->env && tex->env->ok) {
515 sa= closest_bigger_area();
517 save_image_filesel_str(str);
518 activate_fileselect(FILE_SPECIAL, str, G.ima, save_env);
522 if(tex->env && tex->env->object) {
523 BIF_preview_changed(ID_TE);
524 if ELEM(tex->env->object->type, OB_CAMERA, OB_LAMP) {
525 error("Camera or Lamp not allowed");
526 tex->env->object= NULL;
532 if(event>=B_PLUGBUT && event<=B_PLUGBUT+23) {
533 PluginTex *pit= tex->plugin;
534 if(pit && pit->callback) {
535 pit->callback(event - B_PLUGBUT);
536 BIF_preview_changed(ID_TE);
537 allqueue(REDRAWBUTSSHADING, 0);
543 static void texture_panel_plugin(Tex *tex)
550 block= uiNewBlock(&curarea->uiblocks, "texture_panel_plugin", UI_EMBOSS, UI_HELV, curarea->win);
551 if(uiNewPanel(curarea, block, "Plugin", "Texture", 640, 0, 318, 204)==0) return;
552 uiSetButLock(tex->id.lib!=0, "Can't edit library data");
554 if(tex->plugin && tex->plugin->doit) {
558 for(a=0; a<pit->stypes; a++) {
559 uiDefButS(block, ROW, B_TEXREDR_PRV, pit->stnames+16*a, (76*a), 152, 75, 20, &tex->stype, 2.0, (float)a, 0, 0, "");
564 for(a=0; a<pit->vars; a++, varstr++) {
566 yco= 125 - 20*(a % 6)+1;
567 uiDefBut(block, varstr->type, B_PLUGBUT+a, varstr->name, xco,yco,137,19, &(pit->data[a]), varstr->min, varstr->max, 100, 0, varstr->tip);
570 uiDefBut(block, TEX, B_NAMEPLUGIN, "", 0,180,318,24, pit->name, 0.0, 159.0, 0, 0, "");
573 uiDefBut(block, BUT, B_LOADPLUGIN, "Load Plugin", 0,204,137,24, 0, 0, 0, 0, 0, "");
578 static void texture_panel_magic(Tex *tex)
582 block= uiNewBlock(&curarea->uiblocks, "texture_panel_magic", UI_EMBOSS, UI_HELV, curarea->win);
583 if(uiNewPanel(curarea, block, "Magic", "Texture", 640, 0, 318, 204)==0) return;
584 uiSetButLock(tex->id.lib!=0, "Can't edit library data");
586 uiBlockBeginAlign(block);
587 uiDefButS(block, NUM, B_TEXPRV, "Depth:", 10, 90, 150, 19, &tex->noisedepth, 0.0, 10.0, 0, 0, "Sets the depth of the pattern");
588 uiDefButF(block, NUM, B_TEXPRV, "Turbulence:", 10, 70, 150, 19, &tex->turbul, 0.0, 200.0, 10, 0, "Sets the strength of the pattern");
591 static void texture_panel_blend(Tex *tex)
595 block= uiNewBlock(&curarea->uiblocks, "texture_panel_blend", UI_EMBOSS, UI_HELV, curarea->win);
596 if(uiNewPanel(curarea, block, "Blend", "Texture", 640, 0, 318, 204)==0) return;
597 uiSetButLock(tex->id.lib!=0, "Can't edit library data");
599 uiBlockBeginAlign(block);
600 uiDefButS(block, ROW, B_TEXPRV, "Lin", 10, 180, 75, 19, &tex->stype, 2.0, 0.0, 0, 0, "Creates a linear progresion");
601 uiDefButS(block, ROW, B_TEXPRV, "Quad", 85, 180, 75, 19, &tex->stype, 2.0, 1.0, 0, 0, "Creates a quadratic progression");
602 uiDefButS(block, ROW, B_TEXPRV, "Ease", 160, 180, 75, 19, &tex->stype, 2.0, 2.0, 0, 0, "Creates a progression easing from one step to the next");
603 uiDefButBitS(block, TOG, TEX_FLIPBLEND, B_TEXPRV, "Flip XY", 235, 180, 75, 19, &tex->flag, 0, 0, 0, 0, "Flips the direction of the progression 90 degrees");
605 uiDefButS(block, ROW, B_TEXPRV, "Diag", 10, 160, 75, 19, &tex->stype, 2.0, 3.0, 0, 0, "Use a diagonal progression");
606 uiDefButS(block, ROW, B_TEXPRV, "Sphere", 85, 160, 75, 19, &tex->stype, 2.0, 4.0, 0, 0, "Use progression with the shape of a sphere");
607 uiDefButS(block, ROW, B_TEXPRV, "Halo", 160, 160, 75, 19, &tex->stype, 2.0, 5.0, 0, 0, "Use a quadratic progression with the shape of a sphere");
608 uiDefButS(block, ROW, B_TEXPRV, "Radial", 235, 160, 75, 19, &tex->stype, 2.0, 6.0, 0, 0, "Use a polar progression");
612 /* newnoise: noisebasis menu string */
613 static char* noisebasis_menu()
615 static char nbmenu[256];
616 sprintf(nbmenu, "Noise Basis %%t|Blender Original %%x%d|Original Perlin %%x%d|Improved Perlin %%x%d|Voronoi F1 %%x%d|Voronoi F2 %%x%d|Voronoi F3 %%x%d|Voronoi F4 %%x%d|Voronoi F2-F1 %%x%d|Voronoi Crackle %%x%d|CellNoise %%x%d", TEX_BLENDER, TEX_STDPERLIN, TEX_NEWPERLIN, TEX_VORONOI_F1, TEX_VORONOI_F2, TEX_VORONOI_F3, TEX_VORONOI_F4, TEX_VORONOI_F2F1, TEX_VORONOI_CRACKLE, TEX_CELLNOISE);
620 static void texture_panel_wood(Tex *tex)
624 block= uiNewBlock(&curarea->uiblocks, "texture_panel_wood", UI_EMBOSS, UI_HELV, curarea->win);
625 if(uiNewPanel(curarea, block, "Wood", "Texture", 640, 0, 318, 204)==0) return;
626 uiSetButLock(tex->id.lib!=0, "Can't edit library data");
628 uiBlockBeginAlign(block);
629 uiDefButS(block, ROW, B_TEXPRV, "Bands", 10, 180, 75, 18, &tex->stype, 2.0, 0.0, 0, 0, "Uses standard wood texture in bands");
630 uiDefButS(block, ROW, B_TEXPRV, "Rings", 85, 180, 75, 18, &tex->stype, 2.0, 1.0, 0, 0, "Uses wood texture in rings");
631 uiDefButS(block, ROW, B_TEXPRV, "BandNoise", 160, 180, 75, 18, &tex->stype, 2.0, 2.0, 0, 0, "Adds noise to standard wood");
632 uiDefButS(block, ROW, B_TEXPRV, "RingNoise", 235, 180, 75, 18, &tex->stype, 2.0, 3.0, 0, 0, "Adds noise to rings");
634 uiDefButS(block, ROW, B_TEXPRV, "Sin", 10, 160, 50, 19, &tex->noisebasis2, 8.0, 0.0, 0, 0, "Uses a sine wave to produce bands");
635 uiDefButS(block, ROW, B_TEXPRV, "Saw", 60, 160, 50, 19, &tex->noisebasis2, 8.0, 1.0, 0, 0, "Uses a saw wave to produce bands");
636 uiDefButS(block, ROW, B_TEXPRV, "Tri", 110, 160, 50, 19, &tex->noisebasis2, 8.0, 2.0, 0, 0, "Uses a triangle wave to produce bands");
637 uiDefButS(block, ROW, B_TEXPRV, "Soft noise", 160, 160, 75, 19, &tex->noisetype, 12.0, 0.0, 0, 0, "Generates soft noise");
638 uiDefButS(block, ROW, B_TEXPRV, "Hard noise", 235, 160, 75, 19, &tex->noisetype, 12.0, 1.0, 0, 0, "Generates hard noise");
640 uiBlockBeginAlign(block);
641 uiDefButF(block, NUM, B_TEXPRV, "NoiseSize :", 10, 130, 150, 19, &tex->noisesize, 0.0001, 2.0, 10, 0, "Sets scaling for noise input");
642 uiDefButF(block, NUM, B_TEXPRV, "Turbulence:", 160, 130, 150, 19, &tex->turbul, 0.0, 200.0, 10, 0, "Sets the turbulence of the bandnoise and ringnoise types");
643 uiBlockEndAlign(block);
645 /* newnoise: noisebasis menu */
646 uiDefBut(block, LABEL, 0, "Noise Basis", 10, 30, 150, 19, 0, 0.0, 0.0, 0, 0, "");
647 uiDefButS(block, MENU, B_TEXPRV, noisebasis_menu(), 10, 10, 150, 19, &tex->noisebasis, 0,0,0,0, "Sets the noise basis used for turbulence");
648 uiDefButF(block, NUM, B_NOP, "Nabla: ", 160, 10, 150, 19, &tex->nabla, 0.001, 0.1, 1, 0, "Defines size of derivative offset used for calculating normal");
652 static void texture_panel_stucci(Tex *tex)
656 block= uiNewBlock(&curarea->uiblocks, "texture_panel_stucci", UI_EMBOSS, UI_HELV, curarea->win);
657 if(uiNewPanel(curarea, block, "Stucci", "Texture", 640, 0, 318, 204)==0) return;
658 uiSetButLock(tex->id.lib!=0, "Can't edit library data");
660 uiBlockBeginAlign(block);
661 uiDefButS(block, ROW, B_TEXPRV, "Plastic", 10, 180, 100, 19, &tex->stype, 2.0, 0.0, 0, 0, "Uses standard stucci");
662 uiDefButS(block, ROW, B_TEXPRV, "Wall In", 110, 180, 100, 19, &tex->stype, 2.0, 1.0, 0, 0, "Creates Dimples");
663 uiDefButS(block, ROW, B_TEXPRV, "Wall Out", 210, 180, 100, 19, &tex->stype, 2.0, 2.0, 0, 0, "Creates Ridges");
665 uiDefButS(block, ROW, B_TEXPRV, "Soft noise", 10, 160, 150, 19, &tex->noisetype, 12.0, 0.0, 0, 0, "Generates soft noise");
666 uiDefButS(block, ROW, B_TEXPRV, "Hard noise", 160, 160, 150, 19, &tex->noisetype, 12.0, 1.0, 0, 0, "Generates hard noise");
668 uiBlockBeginAlign(block);
669 uiDefButF(block, NUM, B_TEXPRV, "NoiseSize :", 10, 110, 150, 19, &tex->noisesize, 0.0001, 2.0, 10, 0, "Sets scaling for noise input");
670 uiDefButF(block, NUM, B_TEXPRV, "Turbulence:", 10, 90, 150, 19, &tex->turbul, 0.0, 200.0, 10, 0, "Sets the depth of the stucci");
671 uiBlockEndAlign(block);
673 /* newnoise: noisebasis menu */
674 uiDefBut(block, LABEL, 0, "Noise Basis", 10, 30, 150, 19, 0, 0.0, 0.0, 0, 0, "");
675 uiDefButS(block, MENU, B_TEXPRV, noisebasis_menu(), 10, 10, 150, 19, &tex->noisebasis, 0,0,0,0, "Sets the noise basis used for turbulence");
676 // note, nabla not supported here!
677 // uiDefButF(block, NUM, B_NOP, "Nabla: ", 160, 10, 150, 19, &tex->nabla, 0.001, 0.1, 1, 0, "Defines size of derivative offset used for calculating normal");
681 static void texture_panel_marble(Tex *tex)
685 block= uiNewBlock(&curarea->uiblocks, "texture_panel_marble", UI_EMBOSS, UI_HELV, curarea->win);
686 if(uiNewPanel(curarea, block, "Marble", "Texture", 640, 0, 318, 204)==0) return;
687 uiSetButLock(tex->id.lib!=0, "Can't edit library data");
689 uiBlockBeginAlign(block);
690 uiDefButS(block, ROW, B_TEXPRV, "Soft", 10, 180, 100, 18, &tex->stype, 2.0, 0.0, 0, 0, "Uses soft marble");
691 uiDefButS(block, ROW, B_TEXPRV, "Sharp", 110, 180, 100, 18, &tex->stype, 2.0, 1.0, 0, 0, "Uses more clearly defined marble");
692 uiDefButS(block, ROW, B_TEXPRV, "Sharper", 210, 180, 100, 18, &tex->stype, 2.0, 2.0, 0, 0, "Uses very clearly defined marble");
694 uiDefButS(block, ROW, B_TEXPRV, "Soft noise", 10, 160, 150, 19, &tex->noisetype, 12.0, 0.0, 0, 0, "Generates soft noise");
695 uiDefButS(block, ROW, B_TEXPRV, "Hard noise", 160, 160, 150, 19, &tex->noisetype, 12.0, 1.0, 0, 0, "Generates hard noise");
697 uiDefButS(block, ROW, B_TEXPRV, "Sin", 10, 140, 100, 18, &tex->noisebasis2, 8.0, 0.0, 0, 0, "Uses a sine wave to produce bands.");
698 uiDefButS(block, ROW, B_TEXPRV, "Saw", 110, 140, 100, 18, &tex->noisebasis2, 8.0, 1.0, 0, 0, "Uses a saw wave to produce bands");
699 uiDefButS(block, ROW, B_TEXPRV, "Tri", 210, 140, 100, 18, &tex->noisebasis2, 8.0, 2.0, 0, 0, "Uses a triangle wave to produce bands");
701 uiBlockBeginAlign(block);
702 uiDefButF(block, NUM, B_TEXPRV, "NoiseSize :", 10, 110, 150, 19, &tex->noisesize, 0.0001, 2.0, 10, 0, "Sets scaling for noise input");
703 uiDefButS(block, NUM, B_TEXPRV, "NoiseDepth:", 10, 90, 150, 19, &tex->noisedepth, 0.0, 6.0, 0, 0, "Sets the depth of the marble calculation");
704 uiDefButF(block, NUM, B_TEXPRV, "Turbulence:", 10, 70, 150, 19, &tex->turbul, 0.0, 200.0, 10, 0, "Sets the turbulence of the sine bands");
705 uiBlockEndAlign(block);
707 /* newnoise: noisebasis menu */
708 uiDefBut(block, LABEL, 0, "Noise Basis", 10, 30, 150, 19, 0, 0.0, 0.0, 0, 0, "");
709 uiDefButS(block, MENU, B_TEXPRV, noisebasis_menu(), 10, 10, 150, 19, &tex->noisebasis, 0,0,0,0, "Sets the noise basis used for turbulence");
710 uiDefButF(block, NUM, B_NOP, "Nabla: ", 160, 10, 150, 19, &tex->nabla, 0.001, 0.1, 1, 0, "Defines size of derivative offset used for calculating normal");
714 static void texture_panel_clouds(Tex *tex)
718 block= uiNewBlock(&curarea->uiblocks, "texture_panel_clouds", UI_EMBOSS, UI_HELV, curarea->win);
719 if(uiNewPanel(curarea, block, "Clouds", "Texture", 640, 0, 318, 204)==0) return;
720 uiSetButLock(tex->id.lib!=0, "Can't edit library data");
722 uiBlockBeginAlign(block);
723 uiDefButS(block, ROW, B_TEXPRV, "Default", 10, 180, 70, 18, &tex->stype, 2.0, 0.0, 0, 0, "Uses standard noise");
724 uiDefButS(block, ROW, B_TEXPRV, "Color", 80, 180, 70, 18, &tex->stype, 2.0, 1.0, 0, 0, "Lets Noise return RGB value");
725 uiDefButS(block, ROW, B_TEXPRV, "Soft noise", 155, 180, 75, 19, &tex->noisetype, 12.0, 0.0, 0, 0, "Generates soft noise");
726 uiDefButS(block, ROW, B_TEXPRV, "Hard noise", 230, 180, 80, 19, &tex->noisetype, 12.0, 1.0, 0, 0, "Generates hard noise");
727 uiBlockBeginAlign(block);
728 uiDefButF(block, NUM, B_TEXPRV, "NoiseSize :", 10, 130, 150, 19, &tex->noisesize, 0.0001, 2.0, 10, 0, "Sets scaling for noise input");
729 uiDefButS(block, NUM, B_TEXPRV, "NoiseDepth:", 160, 130, 150, 19, &tex->noisedepth, 0.0, 6.0, 0, 0, "Sets the depth of the cloud calculation");
730 uiBlockEndAlign(block);
732 /* newnoise: noisebasis menu */
733 uiDefBut(block, LABEL, 0, "Noise Basis", 10, 30, 150, 19, 0, 0.0, 0.0, 0, 0, "");
734 uiDefButS(block, MENU, B_TEXPRV, noisebasis_menu(), 10, 10, 150, 19, &tex->noisebasis, 0,0,0,0, "Sets the noise basis used for turbulence");
735 uiDefButF(block, NUM, B_NOP, "Nabla: ", 160, 10, 150, 19, &tex->nabla, 0.001, 0.1, 1, 0, "Defines size of derivative offset used for calculating normal");
739 /*****************************************/
740 /* newnoise: panel(s) for musgrave types */
741 /*****************************************/
743 static void texture_panel_musgrave(Tex *tex)
748 block= uiNewBlock(&curarea->uiblocks, "texture_panel_musgrave", UI_EMBOSS, UI_HELV, curarea->win);
749 if(uiNewPanel(curarea, block, "Musgrave", "Texture", 640, 0, 318, 204)==0) return;
750 uiSetButLock(tex->id.lib!=0, "Can't edit library data");
752 str= "Multifractal %x0|Ridged Multifractal %x1|Hybrid Multifractal %x2|Hetero Terrain %x4|fBm %x3";
753 uiDefButS(block, MENU, B_TEXREDR_PRV, str, 10, 160, 150, 19, &tex->stype, 0.0, 0.0, 0, 0, "Sets Musgrave type");
755 uiBlockBeginAlign(block);
756 uiDefButF(block, NUMSLI, B_TEXPRV, "H: ", 10, 130, 150, 19, &tex->mg_H, 0.0001, 2.0, 10, 0, "Sets the highest fractal dimension");
757 uiDefButF(block, NUMSLI, B_TEXPRV, "Lacu: ", 160, 130, 150, 19, &tex->mg_lacunarity, 0.0, 6.0, 10, 0, "Sets the gap between succesive frequencies");
758 uiDefButF(block, NUMSLI, B_TEXPRV, "Octs: ", 10, 110, 150, 19, &tex->mg_octaves, 0.0, 8.0, 10, 0, "Sets the number of frequencies used");
759 if ((tex->stype==TEX_RIDGEDMF) || (tex->stype==TEX_HYBRIDMF) || (tex->stype==TEX_HTERRAIN)) {
760 uiDefButF(block, NUMSLI, B_TEXPRV, "Ofst: ", 160, 110, 150, 19, &tex->mg_offset, 0.0, 6.0, 10, 0, "Sets the fractal offset");
761 if ((tex->stype==TEX_RIDGEDMF) || (tex->stype==TEX_HYBRIDMF))
762 uiDefButF(block, NUMSLI, B_TEXPRV, "Gain: ", 10, 90, 150, 19, &tex->mg_gain, 0.0, 6.0, 10, 0, "Sets the gain multiplier");
765 uiBlockBeginAlign(block);
766 /* noise output scale */
767 uiDefButF(block, NUM, B_TEXPRV, "iScale: ", 10, 60, 150, 19, &tex->ns_outscale, 0.0, 10.0, 10, 0, "Scales intensity output");
768 /* frequency scale */
769 uiDefButF(block, NUM, B_TEXPRV, "NoiseSize: ", 160, 60, 150, 19, &tex->noisesize, 0.0001, 2.0, 10, 0, "Sets scaling for noise input");
770 uiBlockEndAlign(block);
772 /* noisebasis menu */
773 uiDefBut(block, LABEL, 0, "Noise Basis", 10, 30, 150, 19, 0, 0.0, 0.0, 0, 0, "");
774 uiDefButS(block, MENU, B_TEXPRV, noisebasis_menu(), 10, 10, 150, 19, &tex->noisebasis, 0,0,0,0, "Sets the noise basis used for turbulence");
775 uiDefButF(block, NUM, B_NOP, "Nabla: ", 160, 10, 150, 19, &tex->nabla, 0.001, 0.1, 1, 0, "Defines size of derivative offset used for calculating normal");
780 static void texture_panel_distnoise(Tex *tex)
783 block= uiNewBlock(&curarea->uiblocks, "texture_panel_distnoise", UI_EMBOSS, UI_HELV, curarea->win);
784 if(uiNewPanel(curarea, block, "Distorted Noise", "Texture", 640, 0, 318, 204)==0) return;
785 uiSetButLock(tex->id.lib!=0, "Can't edit library data");
787 uiBlockBeginAlign(block);
788 /* distortion amount */
789 uiDefButF(block, NUM, B_TEXPRV, "DistAmnt: ", 10, 130, 150, 19, &tex->dist_amount, 0.0, 10.0, 10, 0, "Sets amount of distortion");
790 /* frequency scale */
791 uiDefButF(block, NUM, B_TEXPRV, "NoiseSize: ", 160, 130, 150, 19, &tex->noisesize, 0.0001, 2.0, 10, 0, "Sets scaling for noise input");
792 uiBlockEndAlign(block);
794 uiDefBut(block, LABEL, 0, "Distortion Noise", 10, 100, 150, 19, 0, 0.0, 0.0, 0, 0, "");
795 uiDefBut(block, LABEL, 0, "Noise Basis", 160, 100, 150, 19, 0, 0.0, 0.0, 0, 0, "");
797 uiBlockBeginAlign(block);
798 /* noisebasis used for the distortion */
799 uiDefButS(block, MENU, B_TEXPRV, noisebasis_menu(), 10, 80, 150, 19, &tex->noisebasis, 0,0,0,0, "Sets the noise basis which does the distortion");
800 /* noisebasis to distort */
801 uiDefButS(block, MENU, B_TEXPRV, noisebasis_menu(), 160, 80, 150, 19, &tex->noisebasis2, 0,0,0,0, "Sets the noise basis to distort");
802 uiBlockEndAlign(block);
804 uiDefButF(block, NUM, B_NOP, "Nabla: ", 10, 50, 150, 19, &tex->nabla, 0.001, 0.1, 1, 0, "Defines size of derivative offset used for calculating normal");
808 static void texture_panel_voronoi(Tex *tex)
812 block= uiNewBlock(&curarea->uiblocks, "texture_panel_voronoi", UI_EMBOSS, UI_HELV, curarea->win);
813 if(uiNewPanel(curarea, block, "Voronoi", "Texture", 640, 0, 318, 204)==0) return;
814 uiSetButLock(tex->id.lib!=0, "Can't edit library data");
817 uiBlockBeginAlign(block);
818 uiDefButS(block, ROW, B_TEXPRV, "Int", 10, 180, 75, 18, &tex->vn_coltype, 1.0, 0.0, 0, 0, "Only calculate intensity");
819 uiDefButS(block, ROW, B_TEXPRV, "Col1", 85, 180, 75, 18, &tex->vn_coltype, 1.0, 1.0, 0, 0, "Color cells by position");
820 uiDefButS(block, ROW, B_TEXPRV, "Col2", 160, 180, 75, 18, &tex->vn_coltype, 1.0, 2.0, 0, 0, "Same as Col1 + outline based on F2-F1");
821 uiDefButS(block, ROW, B_TEXPRV, "Col3", 235, 180, 75, 18, &tex->vn_coltype, 1.0, 3.0, 0, 0, "Same as Col2 * intensity");
822 uiBlockEndAlign(block);
824 /* distance metric */
825 sprintf(dm_menu, "Distance Metric %%t|Actual Distance %%x%d|Distance Squared %%x%d|Manhattan %%x%d|Chebychev %%x%d|Minkovsky 1/2 %%x%d|Minkovsky 4 %%x%d|Minkovsky %%x%d", TEX_DISTANCE, TEX_DISTANCE_SQUARED, TEX_MANHATTAN, TEX_CHEBYCHEV, TEX_MINKOVSKY_HALF, TEX_MINKOVSKY_FOUR, TEX_MINKOVSKY);
826 uiDefBut(block, LABEL, B_TEXPRV, "Distance Metric", 10, 160, 150, 19, 0, 0, 0, 0, 0, "");
827 uiDefButS(block, MENU, B_TEXPRV, dm_menu, 10, 140, 150, 19, &tex->vn_distm, 0,0,0,0, "Sets the distance metric to be used");
829 if (tex->vn_distm==TEX_MINKOVSKY)
830 uiDefButF(block, NUMSLI, B_TEXPRV, "Exp: ", 10, 120, 150, 19, &tex->vn_mexp, 0.01, 10.0, 10, 0, "Sets minkovsky exponent");
832 uiBlockBeginAlign(block);
833 uiDefButF(block, NUM, B_TEXPRV, "iScale: ", 160, 140, 150, 19, &tex->ns_outscale, 0.01, 10.0, 10, 0, "Scales intensity output");
834 uiDefButF(block, NUM, B_TEXPRV, "Size: ", 160, 120, 150, 19, &tex->noisesize, 0.0001, 2.0, 10, 0, "Sets scaling for noise input");
835 uiBlockBeginAlign(block);
836 uiDefButF(block, NUM, B_NOP, "Nabla: ", 160, 70, 150, 19, &tex->nabla, 0.001, 0.1, 1, 0, "Defines size of derivative offset used for calculating normal");
839 uiBlockBeginAlign(block);
840 uiDefButF(block, NUMSLI, B_TEXPRV, "W1: ", 10, 70, 150, 19, &tex->vn_w1, -2.0, 2.0, 10, 0, "Sets feature weight 1");
841 uiDefButF(block, NUMSLI, B_TEXPRV, "W2: ", 10, 50, 150, 19, &tex->vn_w2, -2.0, 2.0, 10, 0, "Sets feature weight 2");
842 uiDefButF(block, NUMSLI, B_TEXPRV, "W3: ", 10, 30, 150, 19, &tex->vn_w3, -2.0, 2.0, 10, 0, "Sets feature weight 3");
843 uiDefButF(block, NUMSLI, B_TEXPRV, "W4: ", 10, 10, 150, 19, &tex->vn_w4, -2.0, 2.0, 10, 0, "Sets feature weight 4");
847 /***************************************/
849 static void texture_panel_envmap(Tex *tex)
854 short a, xco, yco, dx, dy;
857 block= uiNewBlock(&curarea->uiblocks, "texture_panel_envmap", UI_EMBOSS, UI_HELV, curarea->win);
858 if(uiNewPanel(curarea, block, "Envmap", "Texture", 640, 0, 318, 204)==0) return;
859 uiSetButLock(tex->id.lib!=0, "Can't edit library data");
862 tex->env= BKE_add_envmap();
863 tex->env->object= OBACT;
868 uiBlockBeginAlign(block);
869 uiDefButS(block, ROW, B_REDR, "Static", 10, 180, 100, 19, &env->stype, 2.0, 0.0, 0, 0, "Calculates environment map only once");
870 uiDefButS(block, ROW, B_REDR, "Anim", 110, 180, 100, 19, &env->stype, 2.0, 1.0, 0, 0, "Calculates environment map at each rendering");
871 uiDefButS(block, ROW, B_ENV_FREE, "Load", 210, 180, 100, 19, &env->stype, 2.0, 2.0, 0, 0, "Loads saved environment map from disk");
872 uiBlockEndAlign(block);
874 if(env->stype==ENV_LOAD) {
877 IDnames_to_pupstring(&strp, NULL, NULL, &(G.main->image), id, &(G.buts->menunr));
879 uiBlockBeginAlign(block);
880 uiDefButS(block, MENU, B_TEXIMABROWSE, strp, 10,145,23,20, &(G.buts->menunr), 0, 0, 0, 0, "Selects an existing environment map or creates new");
883 uiDefBut(block, TEX, B_NAMEIMA, "", 35,145,255,20, tex->ima->name, 0.0, 79.0, 0, 0, "Displays environment map name: click to change");
884 sprintf(str, "%d", tex->ima->id.us);
885 uiDefBut(block, BUT, 0, str, 290,145,20,20, 0, 0, 0, 0, 0, "Displays number of users of environment map: click to make single user");
886 uiBlockEndAlign(block);
888 uiDefBut(block, BUT, B_RELOADIMA, "Reload", 230,125,80,20, 0, 0, 0, 0, 0, "Reloads saved environment map");
890 if (tex->ima->packedfile) packdummy = 1;
892 uiDefIconButBitI(block, TOG, 1, B_PACKIMA, ICON_PACKAGE, 205,125,24,20, &packdummy, 0, 0, 0, 0, "Toggles Packed status of this environment map");
894 else uiBlockEndAlign(block);
898 uiDefBut(block, BUT, B_LOADTEXIMA, "Load Image", 10,125,150,20, 0, 0, 0, 0, 0, "Loads saved environment map - file select");
901 uiBlockBeginAlign(block);
902 uiDefBut(block, BUT, B_ENV_FREE, "Free Data", 10,145,100,20, 0, 0, 0, 0, 0, "Releases all images associated with this environment map");
903 uiDefBut(block, BUT, B_ENV_SAVE, "Save EnvMap", 110,145,100,20, 0, 0, 0, 0, 0, "Saves current environment map");
904 uiDefBut(block, BUT, B_ENV_FREE_ALL, "Free all EnvMaps", 210,145,100,20, 0, 0, 0, 0, 0, "Frees all rendered environment maps for all materials");
906 uiBlockBeginAlign(block);
907 uiDefButS(block, ROW, B_NOP, "Cube", 10,120,100,20, &env->type, 3.0f, 0.0f, 0, 0, "Use environment map with six cube sides");
908 uiDefButS(block, ROW, B_NOP, "Plane", 110,120,100,20, &env->type, 3.0f, 1.0f, 0, 0, "Only one side is rendered, with Z axis pointing in direction of image");
909 uiDefButF(block, NUM, B_NOP, "Zoom: ", 210,120,100,20, &env->viewscale, 0.5f, 5.0f, 100, 2, "Zoom factor for planar environment map");
910 uiBlockEndAlign(block);
913 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_ENV_OB, "Ob:", 10,90,150,20, &(env->object), "Displays object to use as viewpoint for environment map: click to change");
914 if(env->stype!=ENV_LOAD)
915 uiDefButS(block, NUM, B_ENV_FREE, "CubeRes", 160,90,150,20, &env->cuberes, 50, 4096.0, 0, 0, "Sets the pixel resolution of the rendered environment map");
917 uiBlockBeginAlign(block);
918 uiDefButF(block, NUM, B_TEXPRV, "Filter :", 10,65,150,20, &tex->filtersize, 0.1, 25.0, 0, 3, "Adjusts sharpness or blurriness of the reflection"),
919 uiDefButS(block, NUM, B_ENV_FREE, "Depth:", 160,65,150,20, &env->depth, 0, 5.0, 0, 0, "Sets the number of times a map will be rendered recursively mirror effects"),
920 uiDefButF(block, NUM, REDRAWVIEW3D, "ClipSta", 10,40,150,20, &env->clipsta, 0.01, 50.0, 100, 0, "Sets start value for clipping: objects nearer than this are not visible to map");
921 uiDefButF(block, NUM, B_NOP, "ClipEnd", 160,40,150,20, &env->clipend, 0.1, 5000.0, 1000, 0, "Sets end value for clipping beyond which objects are not visible to map");
922 uiBlockEndAlign(block);
924 uiDefBut(block, LABEL, 0, "Don't render layer:", 10,10,140,22, 0, 0.0, 0.0, 0, 0, "");
930 uiBlockBeginAlign(block);
932 uiDefButBitI(block, TOG, 1<<a, 0, "", (xco+a*(dx/2)), (yco+dy/2), (dx/2), (1+dy/2), &env->notlay, 0, 0, 0, 0, "Toggles layer visibility to environment map");
934 uiDefButBitI(block, TOG, 1<<(a+10), 0, "",(xco+a*(dx/2)), yco, (dx/2), (dy/2), &env->notlay, 0, 0, 0, 0, "Toggles layer visibility to environment map");
936 uiBlockBeginAlign(block);
939 uiDefButBitI(block, TOG, 1<<a, 0, "", (xco+a*(dx/2)), (yco+dy/2), (dx/2), (1+dy/2), &env->notlay, 0, 0, 0, 0, "Toggles layer visibility to environment map");
941 uiDefButBitI(block, TOG, 1<<(a+10), 0, "",(xco+a*(dx/2)), yco, (dx/2), (dy/2), &env->notlay, 0, 0, 0, 0, "Toggles layer visibility to environment map");
947 static void texture_panel_image1(Tex *tex)
952 block= uiNewBlock(&curarea->uiblocks, "texture_panel1", UI_EMBOSS, UI_HELV, curarea->win);
953 if(uiNewPanel(curarea, block, "Anim and Movie", "Texture", 960, 0, 318, 204)==0) return;
954 uiSetButLock(tex->id.lib!=0, "Can't edit library data");
956 /* print amount of frames anim */
957 if(tex->ima && tex->ima->anim) {
958 uiDefBut(block, BUT, B_TEXSETFRAMES, "<", 802, 110, 20, 18, 0, 0, 0, 0, 0, "Copies number of frames in movie file to Frames: button");
959 sprintf(str, "%d frs ", IMB_anim_get_duration(tex->ima->anim));
960 uiDefBut(block, LABEL, 0, str, 834, 110, 90, 18, 0, 0, 0, 0, 0, "Number of frames in movie file");
961 sprintf(str, "%d cur ", tex->ima->lastframe);
962 uiDefBut(block, LABEL, 0, str, 834, 90, 90, 18, 0, 0, 0, 0, 0, "");
964 else uiDefBut(block, LABEL, 0, "<", 802, 110, 20, 18, 0, 0, 0, 0, 0, "");
966 uiDefButS(block, NUM, B_TEXPRV, "Frames :", 642,110,150,19, &tex->frames, 0.0, MAXFRAMEF, 0, 0, "Sets the number of frames of a movie to use and activates animation options");
967 uiDefButS(block, NUM, B_TEXPRV, "Offset :", 642,90,150,19, &tex->offset, -MAXFRAMEF, MAXFRAMEF, 0, 0, "Offsets the number of the first movie frame to use in the animation");
968 uiDefButS(block, NUM, B_TEXPRV, "Fie/Ima:", 642,60,98,19, &tex->fie_ima, 1.0, 200.0, 0, 0, "Sets the number of fields per rendered frame");
969 uiDefButS(block, NUM, B_TEXPRV, "StartFr:", 642,30,150,19, &tex->sfra, 1.0, MAXFRAMEF, 0, 0, "Sets the starting frame of the movie to use in animation");
970 uiDefButS(block, NUM, B_TEXPRV, "Len:", 642,10,150,19, &tex->len, 0.0, MAXFRAMEF, 0, 0, "Sets the number of movie frames to use in animation: 0=all");
972 uiBlockBeginAlign(block);
973 uiDefButS(block, NUM, B_TEXPRV, "Fra:", 802,70,73,19, &(tex->fradur[0][0]), 0.0, MAXFRAMEF, 0, 0, "Montage mode: frame start");
974 uiDefButS(block, NUM, B_TEXPRV, "Fra:", 802,50,73,19, &(tex->fradur[1][0]), 0.0, MAXFRAMEF, 0, 0, "Montage mode: frame start");
975 uiDefButS(block, NUM, B_TEXPRV, "Fra:", 802,30,73,19, &(tex->fradur[2][0]), 0.0, MAXFRAMEF, 0, 0, "Montage mode: frame start");
976 uiDefButS(block, NUM, B_TEXPRV, "Fra:", 802,10,73,19, &(tex->fradur[3][0]), 0.0, MAXFRAMEF, 0, 0, "Montage mode: frame start");
977 uiBlockBeginAlign(block);
978 uiDefButS(block, NUM, B_TEXPRV, "", 879,70,37,19, &(tex->fradur[0][1]), 0.0, 250.0, 0, 0, "Montage mode: amount of displayed frames");
979 uiDefButS(block, NUM, B_TEXPRV, "", 879,50,37,19, &(tex->fradur[1][1]), 0.0, 250.0, 0, 0, "Montage mode: amount of displayed frames");
980 uiDefButS(block, NUM, B_TEXPRV, "", 879,30,37,19, &(tex->fradur[2][1]), 0.0, 250.0, 0, 0, "Montage mode: amount of displayed frames");
981 uiDefButS(block, NUM, B_TEXPRV, "", 879,10,37,19, &(tex->fradur[3][1]), 0.0, 250.0, 0, 0, "Montage mode: amount of displayed frames");
982 uiBlockEndAlign(block);
983 uiDefButBitS(block, TOG, TEX_ANIMCYCLIC, B_TEXPRV, "Cyclic", 743,60,48,19, &tex->imaflag, 0, 0, 0, 0, "Toggles looping of animated frames");
987 static void texture_panel_image(Tex *tex)
993 block= uiNewBlock(&curarea->uiblocks, "texture_panel_image", UI_EMBOSS, UI_HELV, curarea->win);
994 if(uiNewPanel(curarea, block, "Image", "Texture", 640, 0, 318, 204)==0) return;
995 uiSetButLock(tex->id.lib!=0, "Can't edit library data");
998 uiBlockBeginAlign(block);
999 uiDefButBitS(block, TOG, TEX_MIPMAP, B_IMAPTEST, "MipMap", 10, 180, 60, 18, &tex->imaflag, 0, 0, 0, 0, "Generates and uses mipmaps");
1000 uiDefButBitS(block, TOG, TEX_GAUSS_MIP, 0, "Gauss", 70, 180, 50, 18, &tex->imaflag, 0, 0, 0, 0, "Enable Gauss filter to sample down mipmaps");
1001 uiDefButBitS(block, TOG, TEX_INTERPOL, 0, "Interpol", 120, 180, 60, 18, &tex->imaflag, 0, 0, 0, 0, "Interpolates pixels using Area filter");
1002 uiDefButBitS(block, TOG, TEX_IMAROT, B_TEXPRV, "Rot90", 180, 180, 40, 18, &tex->imaflag, 0, 0, 0, 0, "Actually flips X and Y for rendering, rotates and mirrors");
1003 uiDefButBitS(block, TOG, TEX_ANTIALI, 0, "Anti", 220, 180, 40, 18, &tex->imaflag, 0, 0, 0, 0, "Toggles Image anti-aliasing");
1004 uiDefButBitS(block, TOG, TEX_ANIM5, B_RELOADIMA, "Movie", 260, 180, 50, 18, &tex->imaflag, 0, 0, 0, 0, "Click to enable movie frames as Images");
1006 uiDefButBitS(block, TOG, TEX_USEALPHA, B_TEXPRV, "UseAlpha", 10, 160, 70, 18, &tex->imaflag, 0, 0, 0, 0, "Click to use Image's alpha channel");
1007 uiDefButBitS(block, TOG, TEX_CALCALPHA, B_TEXPRV, "CalcAlpha", 80, 160, 70, 18, &tex->imaflag, 0, 0, 0, 0, "Click to calculate an alpha channel based on Image RGB values");
1008 uiDefButBitS(block, TOG, TEX_NEGALPHA, B_TEXPRV, "NegAlpha", 150, 160, 60, 18, &tex->flag, 0, 0, 0, 0, "Click to invert the alpha values");
1009 uiDefButBitS(block, TOG, TEX_FIELDS, B_IMAPTEST, "Fields", 210, 160, 60, 18, &tex->imaflag, 0, 0, 0, 0, "Click to enable use of fields in Image");
1010 uiDefButBitS(block, TOG, TEX_STD_FIELD, 0, "Odd", 270, 160, 40, 18, &tex->imaflag, 0, 0, 0, 0, "Standard Field Toggle");
1011 uiBlockEndAlign(block);
1015 IDnames_to_pupstring(&strp, NULL, NULL, &(G.main->image), id, &(G.buts->menunr));
1017 uiBlockBeginAlign(block);
1018 uiDefButS(block, MENU, B_TEXIMABROWSE, strp, 10,135,23,20, &(G.buts->menunr), 0, 0, 0, 0, "Selects an existing texture or creates new");
1021 uiDefBut(block, TEX, B_NAMEIMA, "", 35,135,235,20, tex->ima->name, 0.0, 79.0, 0, 0, "Displays name of the Image file: click to change");
1022 uiDefIconBut(block, BUT, B_UNLINKIMA, ICON_X, 270,135,20,20, 0, 0, 0, 0, 0, "Unlink Image block from Texture");
1024 sprintf(str, "%d", tex->ima->id.us);
1025 uiDefBut(block, BUT, 0, str, 290,135,20,20, 0, 0, 0, 0, 0, "Displays number of users of texture");
1026 uiBlockEndAlign(block);
1028 uiDefBut(block, BUT, B_RELOADIMA, "Reload", 230,115,80,19, 0, 0, 0, 0, 0, "Reloads Image");
1030 if (tex->ima->packedfile) packdummy = 1;
1033 uiDefIconButBitI(block, TOG, 1, B_PACKIMA, ICON_PACKAGE, 205,115,24,19, &packdummy, 0, 0, 0, 0, "Toggles Packed status of this Image");
1035 else uiBlockEndAlign(block);
1039 uiDefBut(block, BUT, B_LOADTEXIMA, "Load Image", 10,115,150,19, 0, 0, 0, 0, 0, "Click to load an Image");
1041 /* crop extend clip */
1043 uiDefButF(block, NUM, B_TEXPRV, "Filter :", 10,92,150,19, &tex->filtersize, 0.1, 25.0, 0, 3, "Sets the filter size used by mipmap and interpol");
1044 uiDefButBitS(block, TOG, TEX_NORMALMAP, B_NOP, "Normal Map", 160,92,150,19, &tex->imaflag, 0.1, 25.0, 0, 0, "Use image RGB values for normal mapping");
1046 uiBlockBeginAlign(block);
1047 uiDefButS(block, ROW, B_TEXREDR_PRV, "Extend", 10,70,63,19, &tex->extend, 4.0, 1.0, 0, 0, "Extends the colour of the edge pixels");
1048 uiDefButS(block, ROW, B_TEXREDR_PRV, "Clip", 73,70,48,19, &tex->extend, 4.0, 2.0, 0, 0, "Sets alpha 0.0 outside Image edges");
1049 uiDefButS(block, ROW, B_TEXREDR_PRV, "ClipCube", 121,70,63,19, &tex->extend, 4.0, 4.0, 0, 0, "Sets alpha to 0.0 outside cubeshaped area around Image");
1050 uiDefButS(block, ROW, B_TEXREDR_PRV, "Repeat", 184,70,63,19, &tex->extend, 4.0, 3.0, 0, 0, "Causes Image to repeat horizontally and vertically");
1051 uiDefButS(block, ROW, B_TEXREDR_PRV, "Checker", 247,70,63,19, &tex->extend, 4.0, 5.0, 0, 0, "Causes Image to repeat in checker pattern");
1053 if(tex->extend==TEX_REPEAT) {
1054 uiBlockBeginAlign(block);
1055 uiDefButS(block, NUM, B_TEXPRV, "Xrepeat:", 10,50,150,19, &tex->xrepeat, 1.0, 512.0, 0, 0, "Sets a repetition multiplier in the X direction");
1056 uiDefButS(block, NUM, B_TEXPRV, "Yrepeat:", 160,50,150,19, &tex->yrepeat, 1.0, 512.0, 0, 0, "Sets a repetition multiplier in the Y direction");
1058 else if(tex->extend==TEX_CHECKER) {
1059 uiBlockBeginAlign(block);
1060 uiDefButBitS(block, TOG, TEX_CHECKER_ODD, B_TEXPRV, "Odd", 10,50,100,19, &tex->flag, 0.0, 0.0, 0, 0, "Sets odd checker tiles");
1061 uiDefButBitS(block, TOG, TEX_CHECKER_EVEN, B_TEXPRV, "Even", 110,50,100,19, &tex->flag, 0.0, 0.0, 0, 0, "Sets even checker tiles");
1062 uiDefButF(block, NUM, B_TEXPRV, "Mortar:", 210,50,100,19, &tex->checkerdist, 0.0, 0.99, 0, 0, "Set checkers distance (like mortar)");
1064 uiBlockBeginAlign(block);
1065 uiDefButF(block, NUM, B_REDR, "MinX ", 10,28,150,19, &tex->cropxmin, -10.0, 10.0, 10, 0, "Sets minimum X value to crop Image");
1066 uiDefButF(block, NUM, B_REDR, "MinY ", 10,8,150,19, &tex->cropymin, -10.0, 10.0, 10, 0, "Sets minimum Y value to crop Image");
1068 uiBlockBeginAlign(block);
1069 uiDefButF(block, NUM, B_REDR, "MaxX ", 160,28,150,19, &tex->cropxmax, -10.0, 10.0, 10, 0, "Sets maximum X value to crop Image");
1070 uiDefButF(block, NUM, B_REDR, "MaxY ", 160,8,150,19, &tex->cropymax, -10.0, 10.0, 10, 0, "Sets maximum Y value to crop Image");
1071 uiBlockEndAlign(block);
1075 static void colorband_pos_cb(void *coba_v, void *unused_v)
1077 ColorBand *coba= coba_v;
1080 if(coba->tot<2) return;
1082 for(a=0; a<coba->tot; a++) coba->data[a].cur= a;
1083 qsort(coba->data, coba->tot, sizeof(CBData), vergcband);
1084 for(a=0; a<coba->tot; a++) {
1085 if(coba->data[a].cur==coba->cur) {
1086 if(coba->cur!=a) addqueue(curarea->win, REDRAW, 0); /* button cur */
1093 static void colorband_add_cb(void *coba_v, void *unused_v)
1095 ColorBand *coba= coba_v;
1097 if(coba->tot < MAXCOLORBAND-1) coba->tot++;
1098 coba->cur= coba->tot-1;
1100 colorband_pos_cb(coba, NULL);
1101 BIF_undo_push("Add colorband");
1105 static void colorband_del_cb(void *coba_v, void *unused_v)
1107 ColorBand *coba= coba_v;
1110 if(coba->tot<2) return;
1112 for(a=coba->cur; a<coba->tot; a++) {
1113 coba->data[a]= coba->data[a+1];
1115 if(coba->cur) coba->cur--;
1118 BIF_undo_push("Delete colorband");
1119 BIF_preview_changed(ID_TE);
1123 /* offset aligns from bottom, standard width 300, height 115 */
1124 static void draw_colorband_buts(uiBlock *block, ColorBand *coba, int xoffs, int yoffs, int redraw)
1129 if(coba==NULL) return;
1131 bt= uiDefBut(block, BUT, redraw, "Add", 80+xoffs,95+yoffs,37,20, 0, 0, 0, 0, 0, "Adds a new colour position to the colorband");
1132 uiButSetFunc(bt, colorband_add_cb, coba, NULL);
1133 uiDefButS(block, NUM, redraw, "Cur:", 117+xoffs,95+yoffs,81,20, &coba->cur, 0.0, (float)(coba->tot-1), 0, 0, "Displays the active colour from the colorband");
1134 bt= uiDefBut(block, BUT, redraw, "Del", 199+xoffs,95+yoffs,37,20, 0, 0, 0, 0, 0, "Deletes the active position");
1135 uiButSetFunc(bt, colorband_del_cb, coba, NULL);
1136 uiDefButS(block, ROW, redraw, "E", 236+xoffs,95+yoffs,16,20, &coba->ipotype, 5.0, 1.0, 0, 0, "Sets interpolation type 'Ease' (quadratic) ");
1137 uiDefButS(block, ROW, redraw, "C", 252+xoffs,95+yoffs,16,20, &coba->ipotype, 5.0, 3.0, 0, 0, "Sets interpolation type Cardinal");
1138 uiDefButS(block, ROW, redraw, "L", 268+xoffs,95+yoffs,16,20, &coba->ipotype, 5.0, 0.0, 0, 0, "Sets interpolation type Linear");
1139 uiDefButS(block, ROW, redraw, "S", 284+xoffs,95+yoffs,16,20, &coba->ipotype, 5.0, 2.0, 0, 0, "Sets interpolation type B-Spline");
1141 uiDefBut(block, BUT_COLORBAND, redraw, "", xoffs,65+yoffs,300,30, coba, 0, 0, 0, 0, "");
1143 cbd= coba->data + coba->cur;
1145 uiBlockBeginAlign(block);
1146 bt= uiDefButF(block, NUM, redraw, "Pos", xoffs,40+yoffs,110,20, &cbd->pos, 0.0, 1.0, 10, 0, "Sets the position of the active colour");
1147 uiButSetFunc(bt, colorband_pos_cb, coba, NULL);
1148 uiDefButF(block, COL, redraw, "", xoffs,20+yoffs,110,20, &(cbd->r), 0, 0, 0, B_BANDCOL, "");
1149 uiDefButF(block, NUMSLI, redraw, "A ", xoffs,yoffs,110,20, &cbd->a, 0.0, 1.0, 10, 0, "Sets the alpha value for this position");
1151 uiBlockBeginAlign(block);
1152 uiDefButF(block, NUMSLI, redraw, "R ", 115+xoffs,40+yoffs,185,20, &cbd->r, 0.0, 1.0, B_BANDCOL, 0, "Sets the red value for the active colour");
1153 uiDefButF(block, NUMSLI, redraw, "G ", 115+xoffs,20+yoffs,185,20, &cbd->g, 0.0, 1.0, B_BANDCOL, 0, "Sets the green value for the active colour");
1154 uiDefButF(block, NUMSLI, redraw, "B ", 115+xoffs,yoffs,185,20, &cbd->b, 0.0, 1.0, B_BANDCOL, 0, "Sets the blue value for the active colour");
1155 uiBlockEndAlign(block);
1158 void draw_colorband_buts_small(uiBlock *block, ColorBand *coba, rctf *butr, int event)
1162 float unit= (butr->xmax-butr->xmin)/12.0f;
1163 float xs= butr->xmin;
1165 cbd= coba->data + coba->cur;
1167 uiBlockBeginAlign(block);
1168 uiDefButF(block, COL, event, "", xs,butr->ymin+20.0f,2.0f*unit,20, &(cbd->r), 0, 0, 0, B_BANDCOL, "");
1169 uiDefButF(block, NUM, event, "A:", xs+2.0f*unit,butr->ymin+20.0f,4.0f*unit,20, &(cbd->a), 0.0f, 1.0f, 10, 2, "");
1170 bt= uiDefBut(block, BUT, event, "Del", xs+6.0f*unit,butr->ymin+20.0f,2.0f*unit,20, NULL, 0, 0, 0, 0, "Deletes the active position");
1171 uiButSetFunc(bt, colorband_del_cb, coba, NULL);
1172 uiDefButS(block, ROW, event, "E", xs+8.0f*unit,butr->ymin+20.0f,unit,20, &coba->ipotype, 5.0, 1.0, 0, 0, "Sets interpolation type 'Ease' (quadratic) ");
1173 uiDefButS(block, ROW, event, "C", xs+9.0f*unit,butr->ymin+20.0f,unit,20, &coba->ipotype, 5.0, 3.0, 0, 0, "Sets interpolation type Cardinal");
1174 uiDefButS(block, ROW, event, "L", xs+10.0f*unit,butr->ymin+20.0f,unit,20, &coba->ipotype, 5.0, 0.0, 0, 0, "Sets interpolation type Linear");
1175 uiDefButS(block, ROW, event, "S", xs+11.0f*unit,butr->ymin+20.0f,unit,20, &coba->ipotype, 5.0, 2.0, 0, 0, "Sets interpolation type B-Spline");
1177 uiDefBut(block, BUT_COLORBAND, event, "", xs,butr->ymin,butr->xmax-butr->xmin,20.0f, coba, 0, 0, 0, 0, "");
1178 uiBlockEndAlign(block);
1182 static void texture_panel_colors(Tex *tex)
1186 block= uiNewBlock(&curarea->uiblocks, "texture_panel_colors", UI_EMBOSS, UI_HELV, curarea->win);
1187 uiNewPanelTabbed("Texture", "Texture");
1188 if(uiNewPanel(curarea, block, "Colors", "Texture", 1280, 0, 318, 204)==0) return;
1192 uiBlockBeginAlign(block);
1193 uiDefButBitS(block, TOG, TEX_COLORBAND, B_COLORBAND, "Colorband",10,180,80,20, &tex->flag, 0, 0, 0, 0, "Toggles colorband operations");
1195 if(tex->flag & TEX_COLORBAND) {
1196 draw_colorband_buts(block, tex->coba, 10, 85, B_TEXREDR_PRV);
1200 if((tex->flag & TEX_COLORBAND)==0) {
1201 uiBlockBeginAlign(block);
1202 uiDefButF(block, NUMSLI, B_TEXPRV, "R ", 60,80,200,20, &tex->rfac, 0.0, 2.0, 0, 0, "Changes the red value of the texture");
1203 uiDefButF(block, NUMSLI, B_TEXPRV, "G ", 60,60,200,20, &tex->gfac, 0.0, 2.0, 0, 0, "Changes the green value of the texture");
1204 uiDefButF(block, NUMSLI, B_TEXPRV, "B ", 60,40,200,20, &tex->bfac, 0.0, 2.0, 0, 0, "Changes the blue value of the texture");
1207 uiBlockBeginAlign(block);
1208 uiDefButF(block, NUMSLI, B_TEXPRV, "Bright", 10,10,150,20, &tex->bright, 0.0, 2.0, 0, 0, "Changes the brightness of the colour or intensity of a texture");
1209 uiDefButF(block, NUMSLI, B_TEXPRV, "Contr", 160,10,150,20, &tex->contrast, 0.01, 5.0, 0, 0, "Changes the contrast of the colour or intensity of a texture");
1213 static void texture_panel_texture(MTex *mtex, Material *ma, World *wrld, Lamp *la, bNode *node)
1217 ID *id=NULL, *idfrom;
1222 block= uiNewBlock(&curarea->uiblocks, "texture_panel_texture", UI_EMBOSS, UI_HELV, curarea->win);
1223 if(uiNewPanel(curarea, block, "Texture", "Texture", 320, 0, 318, 204)==0) return;
1225 /* first do the browse but */
1227 id= (ID *)mtex->tex;
1231 if(ma) idfrom= &ma->id;
1232 else if(wrld) idfrom= &wrld->id;
1233 else if(la) idfrom= &la->id;
1236 uiBlockSetCol(block, TH_BUT_SETTING2);
1238 std_libbuttons(block, 10, 180, 0, NULL, B_TEXBROWSE, ID_TE, 0, id, idfrom, &(G.buts->texnr), B_TEXALONE, B_TEXLOCAL, B_TEXDELETE, B_AUTOTEXNAME, B_KEEPDATA);
1241 std_libbuttons(block, 10, 180, 0, NULL, B_WTEXBROWSE, ID_TE, 0, id, idfrom, &(G.buts->texnr), B_TEXALONE, B_TEXLOCAL, B_TEXDELETE, B_AUTOTEXNAME, B_KEEPDATA);
1244 std_libbuttons(block, 10, 180, 0, NULL, B_LTEXBROWSE, ID_TE, 0, id, idfrom, &(G.buts->texnr), B_TEXALONE, B_TEXLOCAL, B_TEXDELETE, B_AUTOTEXNAME, B_KEEPDATA);
1249 uiBlockSetCol(block, TH_BUT_NEUTRAL);
1251 /* From button: removed */
1255 uiBlockBeginAlign(block);
1257 for(a= 0; a<MAX_MTEX; a++) {
1259 if(ma) mt= ma->mtex[a];
1260 else if(wrld) mt= wrld->mtex[a];
1261 else if(la) mt= la->mtex[a];
1263 if(mt && mt->tex) splitIDname(mt->tex->id.name+2, str, &loos);
1264 else strcpy(str, "");
1268 uiDefButC(block, ROW, B_TEXCHANNEL, str, 10,yco,140,19, &(ma->texact), 0.0, (float)a, 0, 0, "Click to select texture channel");
1272 uiDefButS(block, ROW, B_TEXCHANNEL, str, 10,yco,140,19, &(wrld->texact), 0.0, (float)a, 0, 0, "");
1276 uiDefButS(block, ROW, B_TEXCHANNEL, str, 10,yco,140,19, &(la->texact), 0.0, (float)a, 0, 0, "");
1280 uiBlockEndAlign(block);
1282 uiBlockSetCol(block, TH_AUTO);
1287 Tex *tex= (Tex *)id;
1289 uiSetButLock(tex->id.lib!=0, "Can't edit library data");
1291 /* newnoise: all texture types as menu, not enough room for more buttons.
1292 * Can widen panel, but looks ugly when other panels overlap it */
1294 sprintf(textypes, "Texture Type %%t|None %%x%d|Image %%x%d|EnvMap %%x%d|Clouds %%x%d|Marble %%x%d|Stucci %%x%d|Wood %%x%d|Magic %%x%d|Blend %%x%d|Noise %%x%d|Plugin %%x%d|Musgrave %%x%d|Voronoi %%x%d|DistortedNoise %%x%d", 0, TEX_IMAGE, TEX_ENVMAP, TEX_CLOUDS, TEX_MARBLE, TEX_STUCCI, TEX_WOOD, TEX_MAGIC, TEX_BLEND, TEX_NOISE, TEX_PLUGIN, TEX_MUSGRAVE, TEX_VORONOI, TEX_DISTNOISE);
1295 uiDefBut(block, LABEL, 0, "Texture Type", 160, 150, 140, 20, 0, 0.0, 0.0, 0, 0, "");
1296 uiDefButS(block, MENU, B_TEXTYPE, textypes, 160, 125, 140, 25, &tex->type, 0,0,0,0, "Select texture type");
1300 // label to avoid centering
1301 uiDefBut(block, LABEL, 0, " ", 160, 10, 140, 20, 0, 0, 0, 0, 0, "");
1305 static void texture_panel_preview(MTex *mtex, int preview)
1309 block= uiNewBlock(&curarea->uiblocks, "texture_panel_preview", UI_EMBOSS, UI_HELV, curarea->win);
1310 if(uiNewPanel(curarea, block, "Preview", "Texture", 0, 0, 318, 204)==0) return;
1312 if(preview) uiBlockSetDrawExtraFunc(block, BIF_previewdraw);
1314 // label to force a boundbox for buttons not to be centered
1315 uiDefBut(block, LABEL, 0, " ", 20,20,10,10, 0, 0, 0, 0, 0, "");
1317 uiBlockBeginAlign(block);
1318 uiDefButC(block, ROW, B_TEXREDR_PRV, "Mat", 200,175,80,25, &G.buts->texfrom, 3.0, 0.0, 0, 0, "Displays the textures of the active material");
1319 uiDefButC(block, ROW, B_TEXREDR_PRV, "World", 200,150,80,25, &G.buts->texfrom, 3.0, 1.0, 0, 0, "Displays the textures of the world block");
1320 uiDefButC(block, ROW, B_TEXREDR_PRV, "Lamp", 200,125,80,25, &G.buts->texfrom, 3.0, 2.0, 0, 0, "Displays the textures of the selected lamp");
1321 uiBlockEndAlign(block);
1323 if(mtex && mtex->tex)
1324 uiDefButBitS(block, TOG, TEX_PRV_ALPHA, B_TEXREDR_PRV, "Alpha", 200,60,80,20, &mtex->tex->flag, 0, 0, 0, 0, "Show alpha in preview");
1326 uiDefBut(block, BUT, B_DEFTEXVAR, "Default Vars",200,10,80,20, 0, 0, 0, 0, 0, "Sets all values to defaults");
1332 /* *************************** RADIO ******************************** */
1334 void do_radiobuts(unsigned short event)
1340 rad= G.scene->radio;
1345 BIF_undo_push("Add radiosity");
1346 allqueue(REDRAWBUTSSHADING, 0);
1347 allqueue(REDRAWVIEW3D, 0);
1351 BIF_undo_push("Delete radiosity");
1352 allqueue(REDRAWBUTSSHADING, 0);
1353 allqueue(REDRAWVIEW3D, 0);
1357 allqueue(REDRAWBUTSSHADING, 0);
1358 allqueue(REDRAWVIEW3D, 0);
1361 rad_collect_meshes();
1362 allqueue(REDRAWBUTSSHADING, 0);
1363 allqueue(REDRAWVIEW3D, 0);
1366 if(phase==RAD_PHASE_PATCHES) {
1367 rad_limit_subdivide();
1368 allqueue(REDRAWBUTSSHADING, 0);
1369 allqueue(REDRAWVIEW3D, 0);
1373 if(phase==RAD_PHASE_PATCHES) {
1375 rad_subdivshootpatch();
1376 allqueue(REDRAWBUTSSHADING, 0);
1377 allqueue(REDRAWVIEW3D, 0);
1382 if(phase==RAD_PHASE_PATCHES) {
1384 rad_subdivshootelem();
1385 allqueue(REDRAWBUTSSHADING, 0);
1386 allqueue(REDRAWVIEW3D, 0);
1391 if(phase==RAD_PHASE_PATCHES) {
1395 allqueue(REDRAWBUTSSHADING, 0);
1396 allqueue(REDRAWVIEW3D, 0);
1401 allqueue(REDRAWVIEW3D, 0);
1402 allqueue(REDRAWBUTSSHADING, 0);
1406 if(phase & RAD_PHASE_FACES) make_face_tab();
1407 else make_node_display(); /* radio solver also uses nodes, different ones :) */
1408 allqueue(REDRAWVIEW3D, 0);
1411 if(phase & RAD_PHASE_FACES) {
1413 removeEqualNodes(rad->nodelim);
1415 allqueue(REDRAWVIEW3D, 0);
1416 allqueue(REDRAWBUTSSHADING, 0);
1419 case B_RAD_NODEFILT:
1420 if(phase & RAD_PHASE_FACES) {
1424 allqueue(REDRAWVIEW3D, 0);
1427 case B_RAD_FACEFILT:
1428 if(phase & RAD_PHASE_FACES) {
1430 allqueue(REDRAWVIEW3D, 0);
1435 allqueue(REDRAWVIEW3D, 0);
1438 if(phase & RAD_PHASE_FACES) rad_addmesh();
1439 BIF_undo_push("Radiosity add mesh");
1440 allqueue(REDRAWVIEW3D, 0);
1443 if(phase & RAD_PHASE_FACES) rad_replacemesh();
1444 BIF_undo_push("Radiosity replace mesh");
1445 allqueue(REDRAWVIEW3D, 0);
1452 static void radio_panel_calculation(Radio *rad, int flag)
1456 block= uiNewBlock(&curarea->uiblocks, "radio_panel_calculation", UI_EMBOSS, UI_HELV, curarea->win);
1457 if(uiNewPanel(curarea, block, "Calculation", "Radio", 640, 0, 318, 204)==0) return;
1458 uiAutoBlock(block, 10, 10, 300, 200, UI_BLOCK_ROWS);
1460 if(flag != RAD_PHASE_PATCHES) uiBlockSetCol(block, TH_BUT_NEUTRAL);
1461 uiDefBut(block, BUT, B_RAD_GO, "GO", 0, 0, 10, 15, NULL, 0, 0, 0, 0, "Starts the radiosity simulation");
1463 uiBlockSetCol(block, TH_AUTO);
1464 uiDefButS(block, NUM, B_NOP, "SubSh Patch:", 1, 0, 10, 10, &rad->subshootp, 0.0, 10.0, 0, 0, "Sets the number of times the environment is tested to detect pathes");
1465 uiDefButS(block, NUM, B_NOP, "SubSh Element:", 1, 0, 10, 10, &rad->subshoote, 0.0, 10.0, 0, 0, "Sets the number of times the environment is tested to detect elements");
1467 if(flag != RAD_PHASE_PATCHES) uiBlockSetCol(block, TH_BUT_NEUTRAL);
1468 uiDefBut(block, BUT, B_RAD_SHOOTE, "Subdiv Shoot Element", 2, 0, 10, 10, NULL, 0, 0, 0, 0, "For pre-subdivision, Detects high energy changes and subdivide Elements");
1469 uiDefBut(block, BUT, B_RAD_SHOOTP, "Subdiv Shoot Patch", 2, 0, 10, 10, NULL, 0, 0, 0, 0, "For pre-subdivision, Detects high energy changes and subdivide Patches");
1471 uiBlockSetCol(block, TH_AUTO);
1472 uiDefButI(block, NUM, B_NOP, "MaxEl:", 3, 0, 10, 10, &rad->maxnode, 1.0, 250000.0, 0, 0, "Sets the maximum allowed number of elements");
1473 uiDefButS(block, NUM, B_NOP, "Max Subdiv Shoot:", 3, 0, 10, 10, &rad->maxsublamp, 1.0, 250.0, 0, 0, "Sets the maximum number of initial shoot patches that are evaluated");
1475 if(flag & RAD_PHASE_FACES);
1476 else uiBlockSetCol(block, TH_BUT_NEUTRAL);
1477 uiDefBut(block, BUT, B_RAD_FACEFILT, "FaceFilter", 4, 0, 10, 10, NULL, 0, 0, 0, 0, "Forces an extra smoothing");
1478 uiDefBut(block, BUT, B_RAD_NODEFILT, "Element Filter", 4, 0, 10, 10, NULL, 0, 0, 0, 0, "Filters elements to remove aliasing artefacts");
1480 uiDefBut(block, BUT, B_RAD_NODELIM, "RemoveDoubles", 5, 0, 30, 10, NULL, 0.0, 50.0, 0, 0, "Joins elements which differ less than 'Lim'");
1481 uiBlockSetCol(block, TH_AUTO);
1482 uiDefButS(block, NUM, B_NOP, "Lim:", 5, 0, 10, 10, &rad->nodelim, 0.0, 50.0, 0, 0, "Sets the range for removing doubles");
1487 static void radio_panel_tool(Radio *rad, int flag)
1491 block= uiNewBlock(&curarea->uiblocks, "radio_panel_tool", UI_EMBOSS, UI_HELV, curarea->win);
1492 if(uiNewPanel(curarea, block, "Radio Tool", "Radio", 320, 0, 318, 204)==0) return;
1493 uiAutoBlock(block, 10, 10, 300, 200, UI_BLOCK_ROWS);
1495 if(flag & RAD_PHASE_PATCHES) uiBlockSetCol(block, TH_BUT_SETTING1);
1496 uiDefBut(block, BUT, B_RAD_COLLECT, "Collect Meshes", 0, 0, 10, 15, NULL, 0, 0, 0, 0, "Converts selected visible meshes to patches");
1498 if(flag & RAD_PHASE_PATCHES)uiBlockSetCol(block, TH_AUTO);
1499 else uiBlockSetCol(block, TH_BUT_NEUTRAL);
1500 uiDefBut(block, BUT, B_RAD_FREE, "Free Radio Data", 0, 0, 10, 15, NULL, 0, 0, 0, 0, "Releases all memory used by Radiosity");
1502 if(flag & RAD_PHASE_FACES) uiBlockSetCol(block, TH_AUTO);
1503 else uiBlockSetCol(block, TH_BUT_NEUTRAL);
1504 uiDefBut(block, BUT, B_RAD_REPLACE, "Replace Meshes", 1, 0, 10, 12, NULL, 0, 0, 0, 0, "Converts meshes to Mesh objects with vertex colours, changing input-meshes");
1505 uiDefBut(block, BUT, B_RAD_ADDMESH, "Add new Meshes", 1, 0, 10, 12, NULL, 0, 0, 0, 0, "Converts meshes to Mesh objects with vertex colours, unchanging input-meshes");
1507 uiBlockSetCol(block, TH_AUTO);
1508 uiDefButS(block, ROW, B_RAD_DRAW, "Wire", 2, 0, 10, 10, &rad->drawtype, 0.0, 0.0, 0, 0, "Enables wireframe drawmode");
1509 uiDefButS(block, ROW, B_RAD_DRAW, "Solid", 2, 0, 10, 10, &rad->drawtype, 0.0, 1.0, 0, 0, "Enables solid drawmode");
1510 uiDefButS(block, ROW, B_RAD_DRAW, "Gour", 2, 0, 10, 10, &rad->drawtype, 0.0, 2.0, 0, 0, "Enables Gourad drawmode");
1511 uiDefButBitS(block, TOG, 1, B_RAD_DRAW, "ShowLim", 2, 0, 10, 10, &rad->flag, 0, 0, 0, 0, "Draws patch and element limits");
1512 uiDefButBitS(block, TOG, 2, B_RAD_DRAW, "Z", 2, 0, 3, 10, &rad->flag, 0, 0, 0, 0, "Draws limits differently");
1514 uiDefButS(block, NUM, B_RAD_LIMITS, "ElMax:", 3, 0, 10, 10, &rad->elma, 1.0, 500.0, 0, 0, "Sets maximum size of an element");
1515 uiDefButS(block, NUM, B_RAD_LIMITS, "ElMin:", 3, 0, 10, 10, &rad->elmi, 1.0, 100.0, 0, 0, "Sets minimum size of an element");
1516 uiDefButS(block, NUM, B_RAD_LIMITS, "PaMax:", 3, 0, 10, 10, &rad->pama, 10.0, 1000.0, 0, 0, "Sets maximum size of a patch");
1517 uiDefButS(block, NUM, B_RAD_LIMITS, "PaMin:", 3, 0, 10, 10, &rad->pami, 10.0, 1000.0, 0, 0, "Sets minimum size of a patch");
1519 uiDefBut(block, BUT, B_RAD_INIT, "Limit Subdivide", 5, 0, 10, 10, NULL, 0, 0, 0, 0, "Subdivides patches");
1523 static void radio_panel_render(Radio *rad)
1527 block= uiNewBlock(&curarea->uiblocks, "radio_panel_render", UI_EMBOSS, UI_HELV, curarea->win);
1528 if(uiNewPanel(curarea, block, "Radio Render", "Radio", 0, 0, 318, 204)==0) return;
1529 uiAutoBlock(block, 210, 30, 230, 150, UI_BLOCK_ROWS);
1531 uiDefButS(block, NUMSLI, B_RAD_LIMITS, "Hemires:", 0, 0, 10, 10, &rad->hemires, 100.0, 1000.0, 100, 0, "Sets the size of a hemicube");
1532 uiDefButS(block, NUM, B_NOP, "Max Iterations:", 2, 0, 10, 15, &rad->maxiter, 0.0, 10000.0, 0, 0, "Limits the maximum number of radiosity rounds");
1533 uiDefButF(block, NUM, B_RAD_FAC, "Mult:", 3, 0, 10, 15, &rad->radfac, 0.001, 250.0, 100, 0, "Mulitplies the energy values");
1534 uiDefButF(block, NUM, B_RAD_FAC, "Gamma:", 3, 0, 10, 15, &rad->gamma, 0.2, 10.0, 10, 0, "Changes the contrast of the energy values");
1535 uiDefButF(block, NUMSLI, B_NOP, "Convergence:", 5, 0, 10, 10, &rad->convergence, 0.0, 1.0, 10, 0, "Sets the lower threshold of unshot energy");
1539 /* ***************************** WORLD ************************** */
1541 void do_worldbuts(unsigned short event)
1543 static short mtexcopied=0;
1544 static MTex mtexcopybuf;
1549 case B_TEXCLEARWORLD:
1550 wrld= G.buts->lockpoin;
1551 mtex= wrld->mtex[ wrld->texact ];
1553 if(mtex->tex) mtex->tex->id.us--;
1555 wrld->mtex[ wrld->texact ]= 0;
1556 allqueue(REDRAWBUTSSHADING, 0);
1557 allqueue(REDRAWOOPS, 0);
1558 BIF_undo_push("Unlink world texture");
1559 BIF_preview_changed(ID_WO);
1563 wrld= G.buts->lockpoin;
1564 if(wrld && wrld->mtex[(int)wrld->texact] ) {
1565 mtex= wrld->mtex[(int)wrld->texact];
1567 error("No texture available");
1570 memcpy(&mtexcopybuf, wrld->mtex[(int)wrld->texact], sizeof(MTex));
1576 wrld= G.buts->lockpoin;
1577 if(wrld && mtexcopied && mtexcopybuf.tex) {
1578 if(wrld->mtex[(int)wrld->texact]==0 )
1579 wrld->mtex[(int)wrld->texact]= MEM_mallocN(sizeof(MTex), "mtex");
1580 else if(wrld->mtex[(int)wrld->texact]->tex)
1581 wrld->mtex[(int)wrld->texact]->tex->id.us--;
1583 memcpy(wrld->mtex[(int)wrld->texact], &mtexcopybuf, sizeof(MTex));
1585 id_us_plus((ID *)mtexcopybuf.tex);
1586 BIF_undo_push("Paste mapping settings");
1587 BIF_preview_changed(ID_WO);
1588 scrarea_queue_winredraw(curarea);
1594 static void world_panel_mapto(World *wrld)
1599 block= uiNewBlock(&curarea->uiblocks, "world_panel_mapto", UI_EMBOSS, UI_HELV, curarea->win);
1600 uiNewPanelTabbed("Texture and Input", "World");
1601 if(uiNewPanel(curarea, block, "Map To", "World", 1280, 0, 318, 204)==0) return;
1603 uiSetButLock(wrld->id.lib!=0, "Can't edit library data");
1605 mtex= wrld->mtex[ wrld->texact ];
1609 mtex->texco= TEXCO_VIEW;
1612 /* TEXTURE OUTPUT */
1613 uiBlockBeginAlign(block);
1614 uiDefButBitS(block, TOG, MTEX_STENCIL, B_WORLDPRV, "Stencil", 10,125,45,19, &(mtex->texflag), 0, 0, 0, 0, "Sets the texture mapping to stencil mode");
1615 uiDefButBitS(block, TOG, MTEX_NEGATIVE, B_WORLDPRV, "Neg", 55,125,30,19, &(mtex->texflag), 0, 0, 0, 0, "Inverts the values of the texture to reverse its effect");
1616 uiDefButBitS(block, TOG, MTEX_RGBTOINT, B_WORLDPRV, "No RGB", 85,125,60,19, &(mtex->texflag), 0, 0, 0, 0, "Converts texture RGB values to intensity (gray) values");
1617 uiBlockEndAlign(block);
1619 uiBlockBeginAlign(block);
1620 uiDefButF(block, COL, B_WORLDPRV, "", 10,100,135,19, &(mtex->r), 0, 0, 0, B_MTEXCOL, "");
1621 uiDefButF(block, NUMSLI, B_WORLDPRV, "R ", 10,80,135,19, &(mtex->r), 0.0, 1.0, B_MTEXCOL, 0, "The default color for textures that don't return RGB");
1622 uiDefButF(block, NUMSLI, B_WORLDPRV, "G ", 10,60,135,19, &(mtex->g), 0.0, 1.0, B_MTEXCOL, 0, "The default color for textures that don't return RGB");
1623 uiDefButF(block, NUMSLI, B_WORLDPRV, "B ", 10,40,135,19, &(mtex->b), 0.0, 1.0, B_MTEXCOL, 0, "The default color for textures that don't return RGB");
1624 uiBlockEndAlign(block);
1625 uiDefButF(block, NUMSLI, B_WORLDPRV, "DVar ", 10,10,135,19, &(mtex->def_var), 0.0, 1.0, 0, 0, "The default value for textures to mix with values (not RGB)");
1628 uiBlockBeginAlign(block);
1629 uiDefButBitS(block, TOG, WOMAP_BLEND, B_WORLDPRV, "Blend", 10,180,75,19, &(mtex->mapto), 0, 0, 0, 0, "Causes the texture to affect the colour progression of the background");
1630 uiDefButBitS(block, TOG, WOMAP_HORIZ, B_WORLDPRV, "Hori", 85,180,75,19, &(mtex->mapto), 0, 0, 0, 0, "Causes the texture to affect the colour of the horizon");
1631 uiDefButBitS(block, TOG, WOMAP_ZENUP, B_WORLDPRV, "ZenUp", 160,180,75,19, &(mtex->mapto), 0, 0, 0, 0, "Causes the texture to affect the colour of the zenith above");
1632 uiDefButBitS(block, TOG, WOMAP_ZENDOWN, B_WORLDPRV, "ZenDo", 235,180,75,19, &(mtex->mapto), 0, 0, 0, 0, "Causes the texture to affect the colour of the zenith below");
1633 uiBlockEndAlign(block);
1635 uiBlockBeginAlign(block);
1636 uiDefButS(block, MENU, B_WORLDPRV, mapto_blendtype_pup(),155,125,155,19, &(mtex->blendtype), 0, 0, 0, 0, "Texture blending mode");
1637 uiBlockEndAlign(block);
1639 uiBlockBeginAlign(block);
1640 uiDefButF(block, NUMSLI, B_WORLDPRV, "Col ", 155,100,155,19, &(mtex->colfac), 0.0, 1.0, 0, 0, "Sets the amount the texture affects colour values");
1641 uiDefButF(block, NUMSLI, B_WORLDPRV, "Nor ", 155,80,155,19, &(mtex->norfac), 0.0, 1.0, 0, 0, "Sets the amount the texture affects normal values");
1642 uiDefButF(block, NUMSLI, B_WORLDPRV, "Var ", 155,60,155,19, &(mtex->varfac), 0.0, 1.0, 0, 0, "Sets the amount the texture affects other values");
1646 static void world_panel_texture(World *wrld)
1652 char str[64], *strp;
1654 block= uiNewBlock(&curarea->uiblocks, "world_panel_texture", UI_EMBOSS, UI_HELV, curarea->win);
1655 if(uiNewPanel(curarea, block, "Texture and Input", "World", 960, 0, 318, 204)==0) return;
1657 uiSetButLock(wrld->id.lib!=0, "Can't edit library data");
1660 uiBlockSetCol(block, TH_BUT_NEUTRAL);
1661 uiBlockBeginAlign(block);
1662 for(a= 0; a<MAX_MTEX; a++) {
1663 mtex= wrld->mtex[a];
1664 if(mtex && mtex->tex) splitIDname(mtex->tex->id.name+2, str, &loos);
1665 else strcpy(str, "");
1667 uiDefButS(block, ROW, REDRAWBUTSSHADING, str,10, 160-18*a, 80, 20, &(wrld->texact), 3.0, (float)a, 0, 0, "Texture channel");
1669 uiBlockEndAlign(block);
1671 mtex= wrld->mtex[ wrld->texact ];
1675 mtex->texco= TEXCO_VIEW;
1678 /* TEXTUREBLOCK SELECT */
1679 uiBlockSetCol(block, TH_BUT_SETTING2);
1680 id= (ID *)mtex->tex;
1681 IDnames_to_pupstring(&strp, NULL, "ADD NEW %x 32767", &(G.main->tex), id, &(G.buts->texnr));
1682 uiDefButS(block, MENU, B_WTEXBROWSE, strp, 100,140,20,19, &(G.buts->texnr), 0, 0, 0, 0, "Selects an existing texture or creates new");
1686 uiDefBut(block, TEX, B_IDNAME, "TE:", 100,160,200,19, id->name+2, 0.0, 18.0, 0, 0, "Displays name of the texture block: click to change");
1687 sprintf(str, "%d", id->us);
1688 uiDefBut(block, BUT, 0, str, 196,140,21,19, 0, 0, 0, 0, 0, "Displays number of users of texture: click to make single user");
1689 uiDefIconBut(block, BUT, B_AUTOTEXNAME, ICON_AUTO, 220,140,21,19, 0, 0, 0, 0, 0, "Auto-assigns name to texture");
1691 if(wrld->id.lib) uiDefIconBut(block, BUT, 0, ICON_DATALIB, 219,140,21,19, 0, 0, 0, 0, 0, "");
1692 else uiDefIconBut(block, BUT, 0, ICON_PARLIB, 219,140,21,19, 0, 0, 0, 0, 0, "");
1694 uiBlockSetCol(block, TH_AUTO);
1695 uiDefBut(block, BUT, B_TEXCLEARWORLD, "Clear", 122, 140, 72, 19, 0, 0, 0, 0, 0, "Erases link to texture");
1698 uiDefButS(block, TOG, B_WTEXBROWSE, "Add New" ,100, 160, 200, 19, &(G.buts->texnr), -1.0, 32767.0, 0, 0, "Adds a new texture datablock");
1700 uiBlockSetCol(block, TH_AUTO);
1703 uiBlockBeginAlign(block);
1704 uiDefIconBut(block, BUT, B_WMTEXCOPY, ICON_COPYUP, 250,140,25,19, 0, 0, 0, 0, 0, "Copies the mapping settings to the buffer");
1705 uiDefIconBut(block, BUT, B_WMTEXPASTE, ICON_PASTEUP,275,140,25,19, 0, 0, 0, 0, 0, "Pastes the mapping settings from the buffer");
1708 uiBlockBeginAlign(block);
1709 uiDefButS(block, ROW, B_WORLDPRV, "View", 100,110,100,20, &(mtex->texco), 4.0, (float)TEXCO_VIEW, 0, 0, "Uses view vector for the texture coordinates");
1710 uiDefButS(block, ROW, B_WORLDPRV, "Global", 200,110,100,20, &(mtex->texco), 4.0, (float)TEXCO_GLOB, 0, 0, "Uses global coordinates for the texture coordinates (interior mist)");
1712 uiDefButS(block, ROW, B_WORLDPRV, "AngMap", 100,90,70,20, &(mtex->texco), 4.0, (float)TEXCO_ANGMAP, 0, 0, "Uses 360 degree angular coordinates, e.g. for spherical light probes");
1713 uiDefButS(block, ROW, B_WORLDPRV, "Sphere", 170,90,65,20, &(mtex->texco), 4.0, (float)TEXCO_H_SPHEREMAP, 0, 0, "For 360 degree panorama sky, spherical mapped, only top half");
1714 uiDefButS(block, ROW, B_WORLDPRV, "Tube", 235,90,65,20, &(mtex->texco), 4.0, (float)TEXCO_H_TUBEMAP, 0, 0, "For 360 degree panorama sky, cylindrical mapped, only top half");
1716 uiDefButS(block, ROW, B_WORLDPRV, "Object", 100,70,70,20, &(mtex->texco), 4.0, (float)TEXCO_OBJECT, 0, 0, "Uses linked object's coordinates for texture coordinates");
1717 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_WORLDPRV, "", 170,70,130,20, &(mtex->object), "");
1719 uiBlockBeginAlign(block);
1720 uiDefButF(block, NUM, B_WORLDPRV, "dX", 100,40,100,19, mtex->ofs, -20.0, 20.0, 10, 0, "Fine tunes texture mapping X coordinate");
1721 uiDefButF(block, NUM, B_WORLDPRV, "dY", 100,20,100,19, mtex->ofs+1, -20.0, 20.0, 10, 0, "Fine tunes texture mapping Y coordinate");
1722 uiDefButF(block, NUM, B_WORLDPRV, "dZ", 100, 0,100,19, mtex->ofs+2, -20.0, 20.0, 10, 0, "Fine tunes texture mapping Z coordinate");
1723 uiBlockBeginAlign(block);
1724 uiDefButF(block, NUM, B_WORLDPRV, "sizeX", 200,40,100,19, mtex->size, -10.0, 10.0, 10, 0, "Sets scaling for the texture's X size");
1725 uiDefButF(block, NUM, B_WORLDPRV, "sizeY", 200,20,100,19, mtex->size+1, -10.0, 10.0, 10, 0, "Sets scaling for the texture's Y size");
1726 uiDefButF(block, NUM, B_WORLDPRV, "sizeZ", 200, 0,100,19, mtex->size+2, -10.0, 10.0, 10, 0, "Sets scaling for the texture's Z size");
1730 static void world_panel_mistaph(World *wrld)
1734 block= uiNewBlock(&curarea->uiblocks, "world_panel_mistaph", UI_EMBOSS, UI_HELV, curarea->win);
1735 if(uiNewPanel(curarea, block, "Mist / Stars / Physics", "World", 640, 0, 318, 204)==0) return;
1737 uiSetButLock(wrld->id.lib!=0, "Can't edit library data");
1739 #if GAMEBLENDER == 1
1740 uiDefButI(block, MENU, 1,
1742 "Physics %t|None %x0|Sumo %x2|Ode %x4 |Bullet %x5",
1744 "Physics %t|None %x0|Sumo %x2|Bullet %x5",
1746 10,180,140,19, &wrld->physicsEngine, 0, 0, 0, 0,
1749 /* Gravitation for the game worlds */
1750 uiDefButF(block, NUMSLI,0, "Grav ", 150,180,150,19, &(wrld->gravity), 0.0, 25.0, 0, 0, "Sets the gravitation constant of the game world");
1753 uiBlockSetCol(block, TH_BUT_SETTING1);
1754 uiDefButBitS(block, TOG, WO_MIST, REDRAWVIEW3D,"Mist", 10,120,140,19, &wrld->mode, 0, 0, 0, 0, "Toggles mist simulation");
1755 uiBlockSetCol(block, TH_AUTO);
1757 uiBlockBeginAlign(block);
1758 uiDefButS(block, ROW, B_DIFF, "Qua", 10, 90, 40, 19, &wrld->mistype, 1.0, 0.0, 0, 0, "Mist uses quadratic progression");
1759 uiDefButS(block, ROW, B_DIFF, "Lin", 50, 90, 50, 19, &wrld->mistype, 1.0, 1.0, 0, 0, "Mist uses linear progression");
1760 uiDefButS(block, ROW, B_DIFF, "Sqr", 100, 90, 50, 19, &wrld->mistype, 1.0, 2.0, 0, 0, "Mist uses inverse quadratic progression");
1761 uiBlockBeginAlign(block);
1762 uiDefButF(block, NUM,REDRAWVIEW3D, "Sta:",10,70,140,19, &wrld->miststa, 0.0, 1000.0, 10, 0, "Specifies the starting distance of the mist");
1763 uiDefButF(block, NUM,REDRAWVIEW3D, "Di:",10,50,140,19, &wrld->mistdist, 0.0,1000.0, 10, 00, "Specifies the depth of the mist");
1764 uiDefButF(block, NUM,B_DIFF,"Hi:", 10,30,140,19, &wrld->misthi,0.0,100.0, 10, 0, "Specifies the factor for a less dense mist with increasing height");
1765 uiDefButF(block, NUMSLI, B_DIFF, "Misi ", 10,10,140,19, &(wrld->misi), 0., 1.0, 0, 0, "Sets the mist intensity");
1766 uiBlockEndAlign(block);
1768 uiBlockSetCol(block, TH_BUT_SETTING1);
1769 uiDefButBitS(block, TOG, WO_STARS, REDRAWVIEW3D, "Stars",160,120,140,19, &wrld->mode, 0, 0, 0, 0, "Toggles starfield generation");
1770 uiBlockSetCol(block, TH_AUTO);
1772 uiBlockBeginAlign(block);
1773 uiDefButF(block, NUM,B_DIFF,"StarDist:", 160,70,140,19, &(wrld->stardist), 2.0, 1000.0, 100, 0, "Specifies the average distance between any two stars");
1774 uiDefButF(block, NUM,B_DIFF,"MinDist:", 160,50,140,19, &(wrld->starmindist), 0.0, 1000.0, 100, 0, "Specifies the minimum distance to the camera for stars");
1775 uiDefButF(block, NUMSLI,B_DIFF,"Size:", 160,30,140,19, &(wrld->starsize), 0.0, 10.0, 10, 0, "Specifies the average screen dimension of stars");
1776 uiDefButF(block, NUMSLI,B_DIFF,"Colnoise:", 160,10,140,19, &(wrld->starcolnoise), 0.0, 1.0, 100, 0, "Randomizes starcolour");
1777 uiBlockEndAlign(block);
1781 static void world_panel_amb_occ(World *wrld)
1785 block= uiNewBlock(&curarea->uiblocks, "world_panel_amb_oc", UI_EMBOSS, UI_HELV, curarea->win);
1786 uiNewPanelTabbed("Mist / Stars / Physics", "World");
1787 if(uiNewPanel(curarea, block, "Amb Occ", "World", 320, 0, 318, 204)==0) return;
1789 uiBlockSetCol(block, TH_BUT_SETTING1);
1790 uiDefButBitS(block, TOG, WO_AMB_OCC, B_REDR, "Ambient Occlusion",10,150,300,19, &wrld->mode, 0, 0, 0, 0, "Toggles ambient occlusion");
1791 uiBlockSetCol(block, TH_AUTO);
1793 if(wrld->mode & WO_AMB_OCC) {
1795 /* aolight: samples */
1796 uiBlockBeginAlign(block);
1797 uiDefButS(block, NUM, B_REDR, "Samples:", 10, 120, 150, 19, &wrld->aosamp, 1.0, 16.0, 100, 0, "Sets the number of samples used for AO (actual number: squared)");
1798 /* enable/disable total random sampling */
1799 uiDefButBitS(block, TOG, WO_AORNDSMP, 0, "Random Sampling", 160, 120, 150, 19, &wrld->aomode, 0, 0, 0, 0, "When enabled, total random sampling will be used for an even noisier effect");
1800 uiBlockEndAlign(block);
1802 uiDefButF(block, NUM, B_REDR, "Dist:", 10, 95, 150, 19, &wrld->aodist, 0.001, 5000.0, 100, 0, "Sets length of AO rays, defines how far away other faces give occlusion effect");
1804 uiBlockBeginAlign(block);
1805 uiDefButBitS(block, TOG, WO_AODIST, B_REDR, "Use Distances", 10, 70, 150, 19, &wrld->aomode, 0, 0, 0, 0, "When enabled, distances to objects will be used to attenuate shadows");
1806 /* distance attenuation factor */
1807 if (wrld->aomode & WO_AODIST)
1808 uiDefButF(block, NUM, B_REDR, "DistF:", 160, 70, 150, 19, &wrld->aodistfac, 0.00001, 10.0, 100, 0, "Distance factor, the higher, the 'shorter' the shadows");
1810 /* result mix modes */
1811 uiBlockBeginAlign(block);
1812 uiDefButS(block, ROW, B_REDR, "Add", 10, 45, 100, 20, &wrld->aomix, 1.0, (float)WO_AOADD, 0, 0, "adds light/shadows");
1813 uiDefButS(block, ROW, B_REDR, "Sub", 110, 45, 100, 20, &wrld->aomix, 1.0, (float)WO_AOSUB, 0, 0, "subtracts light/shadows (needs at least one normal light to make anything visible)");
1814 uiDefButS(block, ROW, B_REDR, "Both", 210, 45, 100, 20, &wrld->aomix, 1.0, (float)WO_AOADDSUB, 0, 0, "both lightens & darkens");
1816 /* color treatment */
1817 uiBlockBeginAlign(block);
1818 uiDefButS(block, ROW, B_REDR, "Plain", 10, 25, 100, 20, &wrld->aocolor, 2.0, (float)WO_AOPLAIN, 0, 0, "Plain diffuse energy (white)");
1819 uiDefButS(block, ROW, B_REDR, "Sky Color", 110, 25, 100, 20, &wrld->aocolor, 2.0, (float)WO_AOSKYCOL, 0, 0, "Use horizon and zenith color for diffuse energy");
1820 uiDefButS(block, ROW, B_REDR, "Sky Texture", 210, 25, 100, 20, &wrld->aocolor, 2.0, (float)WO_AOSKYTEX, 0, 0, "Does full Sky texture render for diffuse energy");
1822 uiBlockBeginAlign(block);
1823 uiDefButF(block, NUMSLI, B_REDR, "Energy:", 10, 0, 150, 19, &wrld->aoenergy, 0.01, 3.0, 100, 0, "Sets global energy scale for AO");
1824 uiDefButF(block, NUMSLI, B_REDR, "Bias:", 160, 0, 150, 19, &wrld->aobias, 0.0, 0.5, 10, 0, "Sets bias to prevent smoothed faces to show banding (in radians)");
1829 static void world_panel_world(World *wrld)
1833 block= uiNewBlock(&curarea->uiblocks, "world_panel_world", UI_EMBOSS, UI_HELV, curarea->win);
1834 if(uiNewPanel(curarea, block, "World", "World", 320, 0, 318, 204)==0) return;
1836 uiBlockSetCol(block, TH_BUT_SETTING2);
1837 std_libbuttons(block, 10, 180, 0, NULL, B_WORLDBROWSE, ID_WO, 0, (ID *)wrld, (ID *)G.scene, &(G.buts->menunr), B_WORLDALONE, B_WORLDLOCAL, B_WORLDDELETE, 0, B_KEEPDATA);
1839 if(wrld==NULL) return;
1841 uiSetButLock(wrld->id.lib!=0, "Can't edit library data");
1842 uiBlockSetCol(block, TH_AUTO);
1844 uiDefButF(block, COL, B_WORLDPRV, "", 10,150,145,19, &wrld->horr, 0, 0, 0, B_COLHOR, "");
1845 uiDefButF(block, COL, B_WORLDPRV, "", 160,150,145,19, &wrld->zenr, 0, 0, 0, B_COLZEN, "");
1847 uiBlockBeginAlign(block);
1848 uiDefButF(block, NUMSLI,B_WORLDPRV,"HoR ", 10,130,145,19, &(wrld->horr), 0.0, 1.0, B_COLHOR,0, "Sets the amount of red colour at the horizon");
1849 uiDefButF(block, NUMSLI,B_WORLDPRV,"HoG ", 10,110,145,19, &(wrld->horg), 0.0, 1.0, B_COLHOR,0, "Sets the amount of green colour at the horizon");
1850 uiDefButF(block, NUMSLI,B_WORLDPRV,"HoB ", 10,90,145,19, &(wrld->horb), 0.0, 1.0, B_COLHOR,0, "Sets the amount of blue colour at the horizon");
1852 uiBlockBeginAlign(block);
1853 uiDefButF(block, NUMSLI,B_WORLDPRV,"ZeR ", 160,130,145,19, &(wrld->zenr), 0.0, 1.0, B_COLZEN,0, "Sets the amount of red colour at the zenith");
1854 uiDefButF(block, NUMSLI,B_WORLDPRV,"ZeG ", 160,110,145,19, &(wrld->zeng), 0.0, 1.0, B_COLZEN,0, "Sets the amount of green colour at the zenith");
1855 uiDefButF(block, NUMSLI,B_WORLDPRV,"ZeB ", 160,90,145,19, &(wrld->zenb), 0.0, 1.0, B_COLZEN,0, "Sets the amount of blue colour at the zenith");
1857 uiBlockBeginAlign(block);
1858 uiDefButF(block, NUMSLI,B_WORLDPRV,"AmbR ", 10,50,145,19, &(wrld->ambr), 0.0, 1.0 ,0,0, "Sets the amount of red ambient colour");
1859 uiDefButF(block, NUMSLI,B_WORLDPRV,"AmbG ", 10,30,145,19, &(wrld->ambg), 0.0, 1.0 ,0,0, "Sets the amount of green ambient colour");
1860 uiDefButF(block, NUMSLI,B_WORLDPRV,"AmbB ", 10,10,145,19, &(wrld->ambb), 0.0, 1.0 ,0,0, "Sets the amount of blue ambient colour");
1862 uiBlockBeginAlign(block);
1863 uiBlockSetCol(block, TH_BUT_SETTING1);
1864 uiDefButF(block, NUMSLI,B_WORLDPRV, "Exp ", 160,30,145,19, &(wrld->exp), 0.0, 1.0, 0, 2, "Sets amount of exponential color correction for light");
1865 uiDefButF(block, NUMSLI,B_WORLDPRV, "Range ", 160,10,145,19, &(wrld->range), 0.2, 5.0, 0, 2, "Sets the color amount that will be mapped on color 1.0");
1870 static void world_panel_preview(World *wrld)
1874 /* name "Preview" is abused to detect previewrender offset panel */
1875 block= uiNewBlock(&curarea->uiblocks, "world_panel_preview", UI_EMBOSS, UI_HELV, curarea->win);
1876 if(uiNewPanel(curarea, block, "Preview", "World", 0, 0, 318, 204)==0) return;
1878 if(wrld==NULL) return;
1880 uiSetButLock(wrld->id.lib!=0, "Can't edit library data");
1882 uiBlockSetDrawExtraFunc(block, BIF_previewdraw);
1884 // label to force a boundbox for buttons not to be centered
1885 uiDefBut(block, LABEL, 0, " ", 20,20,10,10, 0, 0, 0, 0, 0, "");
1887 uiBlockBeginAlign(block);
1888 uiDefButBitS(block, TOG, WO_SKYREAL, B_WORLDPRV,"Real", 200,175,80,25, &wrld->skytype, 0, 0, 0, 0, "Renders background with a real horizon");
1889 uiDefButBitS(block, TOG, WO_SKYBLEND, B_WORLDPRV,"Blend",200,150,80,25, &wrld->skytype, 0, 0, 0, 0, "Renders background with natural progression from horizon to zenith");
1890 uiDefButBitS(block, TOG,WO_SKYPAPER, B_WORLDPRV,"Paper",200,125,80,25, &wrld->skytype, 0, 0, 0, 0, "Flattens blend or texture coordinates");
1891 uiBlockEndAlign(block);
1895 /* ************************ LAMP *************************** */
1897 void do_lampbuts(unsigned short event)
1899 static short mtexcopied=0;
1900 static MTex mtexcopybuf;
1906 BIF_preview_changed(ID_LA);
1907 allqueue(REDRAWVIEW3D, 0);
1908 allqueue(REDRAWBUTSSHADING, 0);
1910 case B_TEXCLEARLAMP:
1911 la= G.buts->lockpoin;
1912 mtex= la->mtex[ la->texact ];
1914 if(mtex->tex) mtex->tex->id.us--;
1916 la->mtex[ la->texact ]= 0;
1917 BIF_undo_push("Unlink world texture");
1918 allqueue(REDRAWBUTSSHADING, 0);
1919 allqueue(REDRAWOOPS, 0);
1920 BIF_preview_changed(ID_LA);
1924 la= G.buts->lockpoin;
1925 la->bufsize = la->bufsize&=(~15);
1926 allqueue(REDRAWBUTSSHADING, 0);
1927 allqueue(REDRAWOOPS, 0);
1930 la= G.buts->lockpoin;
1931 la->mode &= ~LA_SHAD_RAY;
1932 allqueue(REDRAWBUTSSHADING, 0);
1933 allqueue(REDRAWVIEW3D, 0);
1936 la= G.buts->lockpoin;
1937 la->mode &= ~LA_SHAD;
1938 /* yafray: 'softlight' uses it's own shadbuf. flag.
1939 Must be cleared here too when switching from ray shadow */
1940 la->mode &= ~LA_YF_SOFT;
1941 allqueue(REDRAWBUTSSHADING, 0);
1942 allqueue(REDRAWVIEW3D, 0);
1945 la= G.buts->lockpoin;
1946 if(la && la->mtex[(int)la->texact] ) {
1947 mtex= la->mtex[(int)la->texact];
1949 error("No texture available");
1952 memcpy(&mtexcopybuf, la->mtex[(int)la->texact], sizeof(MTex));
1958 la= G.buts->lockpoin;
1959 if(la && mtexcopied && mtexcopybuf.tex) {
1960 if(la->mtex[(int)la->texact]==0 )
1961 la->mtex[(int)la->texact]= MEM_mallocN(sizeof(MTex), "mtex");
1962 else if(la->mtex[(int)la->texact]->tex)
1963 la->mtex[(int)la->texact]->tex->id.us--;
1965 memcpy(la->mtex[(int)la->texact], &mtexcopybuf, sizeof(MTex));
1967 id_us_plus((ID *)mtexcopybuf.tex);
1968 BIF_undo_push("Paste mapping settings");
1969 BIF_preview_changed(ID_LA);
1970 scrarea_queue_winredraw(curarea);
1976 if(event) freefastshade();
1980 static void lamp_panel_mapto(Object *ob, Lamp *la)
1985 block= uiNewBlock(&curarea->uiblocks, "lamp_panel_mapto", UI_EMBOSS, UI_HELV, curarea->win);
1986 uiNewPanelTabbed("Texture and Input", "Lamp");
1987 if(uiNewPanel(curarea, block, "Map To", "Lamp", 1280, 0, 318, 204)==0) return;
1989 uiSetButLock(la->id.lib!=0, "Can't edit library data");
1991 mtex= la->mtex[ la->texact ];
1995 mtex->texco= TEXCO_VIEW;
1998 /* TEXTURE OUTPUT */
1999 uiBlockBeginAlign(block);
2000 uiDefButBitS(block, TOG, MTEX_STENCIL, B_LAMPPRV, "Stencil", 10,125,45,19, &(mtex->texflag), 0, 0, 0, 0, "Sets the texture mapping to stencil mode");
2001 uiDefButBitS(block, TOG, MTEX_NEGATIVE, B_LAMPPRV, "Neg", 55,125,30,19, &(mtex->texflag), 0, 0, 0, 0, "Inverts the values of the texture to reverse its effect");
2002 uiDefButBitS(block, TOG, MTEX_RGBTOINT, B_LAMPPRV, "No RGB", 85,125,60,19, &(mtex->texflag), 0, 0, 0, 0, "Converts texture RGB values to intensity (gray) values");
2003 uiBlockEndAlign(block);
2005 uiBlockBeginAlign(block);
2006 uiDefButF(block, COL, B_LAMPPRV, "", 10,100,135,19, &(mtex->r), 0, 0, 0, B_MTEXCOL, "");
2007 uiDefButF(block, NUMSLI, B_LAMPPRV, "R ", 10,80,135,19, &(mtex->r), 0.0, 1.0, B_MTEXCOL, 0, "The default color for textures that don't return RGB");
2008 uiDefButF(block, NUMSLI, B_LAMPPRV, "G ", 10,60,135,19, &(mtex->g), 0.0, 1.0, B_MTEXCOL, 0, "The default color for textures that don't return RGB");
2009 uiDefButF(block, NUMSLI, B_LAMPPRV, "B ", 10,40,135,19, &(mtex->b), 0.0, 1.0, B_MTEXCOL, 0, "The default color for textures that don't return RGB");
2010 uiBlockEndAlign(block);
2011 uiDefButF(block, NUMSLI, B_LAMPPRV, "DVar ", 10,10,135,19, &(mtex->def_var), 0.0, 1.0, 0, 0, "The default value the textures uses to mix with");
2014 uiDefButBitS(block, TOG, MAP_COL, B_LAMPPRV, "Col", 10,180,135,19, &(mtex->mapto), 0, 0, 0, 0, "Lets the texture affect the basic colour of the lamp");
2016 uiBlockBeginAlign(block);
2017 uiDefButS(block, MENU, B_LAMPPRV, mapto_blendtype_pup(),155,125,155,19, &(mtex->blendtype), 0, 0, 0, 0, "Texture blending mode");
2018 uiBlockEndAlign(block);
2020 uiDefButF(block, NUMSLI, B_LAMPPRV, "Col ", 155,100,155,19, &(mtex->colfac), 0.0, 1.0, 0, 0, "Sets the amount the texture affects colour values");
2025 static void lamp_panel_texture(Object *ob, Lamp *la)
2031 char *strp, str[64];
2033 block= uiNewBlock(&curarea->uiblocks, "lamp_panel_texture", UI_EMBOSS, UI_HELV, curarea->win);
2034 if(uiNewPanel(curarea, block, "Texture and Input", "Lamp", 960, 0, 318, 204)==0) return;
2036 uiSetButLock(la->id.lib!=0, "Can't edit library data");
2039 uiBlockSetCol(block, TH_BUT_NEUTRAL);
2040 uiBlockBeginAlign(block);
2041 for(a= 0; a<MAX_MTEX; a++) {
2043 if(mtex && mtex->tex) splitIDname(mtex->tex->id.name+2, str, &loos);
2044 else strcpy(str, "");
2046 uiDefButS(block, ROW, B_REDR, str, 10, 160-18*a, 80, 20, &(la->texact), 3.0, (float)a, 0, 0, "");
2048 uiBlockEndAlign(block);
2050 mtex= la->mtex[ la->texact ];
2054 mtex->texco= TEXCO_VIEW;
2057 /* TEXTUREBLOK SELECT */
2058 uiBlockSetCol(block, TH_BUT_SETTING2);
2059 id= (ID *)mtex->tex;
2060 IDnames_to_pupstring(&strp, NULL, "ADD NEW %x 32767", &(G.main->tex), id, &(G.buts->texnr));
2062 /* doesnt work, because lockpoin points to lamp, not to texture */
2063 uiDefButS(block, MENU, B_LTEXBROWSE, strp, 100,140,20,19, &(G.buts->texnr), 0, 0, 0, 0, "Selects an existing texture or creates new");
2067 uiDefBut(block, TEX, B_IDNAME, "TE:", 100,160,200,19, id->name+2, 0.0, 18.0, 0, 0, "Displays name of the texture block: click to change");
2068 sprintf(str, "%d", id->us);
2069 uiDefBut(block, BUT, 0, str, 196,140,21,19, 0, 0, 0, 0, 0, "Displays number of users of texture: click to make single user");
2070 uiDefIconBut(block, BUT, B_AUTOTEXNAME, ICON_AUTO, 221,140,21,19, 0, 0, 0, 0, 0, "Auto-assigns name to texture");
2072 if(la->id.lib) uiDefIconBut(block, BUT, 0, ICON_DATALIB, 219,140,21,19, 0, 0, 0, 0, 0, "");
2073 else uiDefIconBut(block, BUT, 0, ICON_PARLIB, 219,140,21,19, 0, 0, 0, 0, 0, "");
2075 uiBlockSetCol(block, TH_AUTO);
2076 uiDefBut(block, BUT, B_TEXCLEARLAMP, "Clear", 122, 140, 72, 19, 0, 0, 0, 0, 0, "Erases link to texture");
2079 uiDefButS(block, TOG, B_LTEXBROWSE, "Add New" ,100, 160, 200, 19, &(G.buts->texnr), -1.0, 32767.0, 0, 0, "Adds a new texture datablock");
2082 uiBlockBeginAlign(block);
2083 uiDefIconBut(block, BUT, B_LMTEXCOPY, ICON_COPYUP, 250,140,25,19, 0, 0, 0, 0, 0, "Copies the mapping settings to the buffer");
2084 uiDefIconBut(block, BUT, B_LMTEXPASTE, ICON_PASTEUP, 275,140,25,19, 0, 0, 0, 0, 0, "Pastes the mapping settings from the buffer");
2087 uiBlockSetCol(block, TH_AUTO);
2088 uiBlockBeginAlign(block);
2089 uiDefButS(block, ROW, B_LAMPPRV, "Glob", 100,110,60,20, &(mtex->texco), 4.0, (float)TEXCO_GLOB, 0, 0, "Uses global coordinates for the texture coordinates");
2090 uiDefButS(block, ROW, B_LAMPPRV, "View", 160,110,70,20, &(mtex->texco), 4.0, (float)TEXCO_VIEW, 0, 0, "Uses view coordinates for the texture coordinates");
2091 uiDefButS(block, ROW, B_LAMPPRV, "Object", 230,110,70,20, &(mtex->texco), 4.0, (float)TEXCO_OBJECT, 0, 0, "Uses linked object's coordinates for texture coordinates");
2092 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_LAMPPRV, "", 100,90,200,20, &(mtex->object), "");
2094 uiBlockBeginAlign(block);
2095 uiDefButF(block, NUM, B_LAMPPRV, "dX", 100,50,100,18, mtex->ofs, -20.0, 20.0, 10, 0, "Fine tunes texture mapping X coordinate");
2096 uiDefButF(block, NUM, B_LAMPPRV, "dY", 100,30,100,18, mtex->ofs+1, -20.0, 20.0, 10, 0, "Fine tunes texture mapping Y coordinate");
2097 uiDefButF(block, NUM, B_LAMPPRV, "dZ", 100,10,100,18, mtex->ofs+2, -20.0, 20.0, 10, 0, "Fine tunes texture mapping Z coordinate");
2098 uiBlockBeginAlign(block);
2099 uiDefButF(block, NUM, B_LAMPPRV, "sizeX", 200,50,100,18, mtex->size, -10.0, 10.0, 10, 0, "Sets scaling for the texture's X size");
2100 uiDefButF(block, NUM, B_LAMPPRV, "sizeY", 200,30,100,18, mtex->size+1, -10.0, 10.0, 10, 0, "Sets scaling for the texture's Y size");
2101 uiDefButF(block, NUM, B_LAMPPRV, "sizeZ", 200,10,100,18, mtex->size+2, -10.0, 10.0, 10, 0, "Sets scaling for the texture's Z size");
2102 uiBlockEndAlign(block);
2105 static void lamp_panel_spot(Object *ob, Lamp *la)
2110 block= uiNewBlock(&curarea->uiblocks, "lamp_panel_spot", UI_EMBOSS, UI_HELV, curarea->win);
2111 if(uiNewPanel(curarea, block, "Shadow and Spot", "Lamp", 640, 0, 318, 204)==0) return;
2113 /* hemis and ray shadow dont work at all... */
2114 /* yafray: ignore photonlight as well */
2115 if ((la->type==LA_HEMI) || (la->type==LA_YF_PHOTON)) return;
2117 if(G.vd) grid= G.vd->grid;
2118 if(grid<1.0) grid= 1.0;
2120 uiSetButLock(la->id.lib!=0, "Can't edit library data");
2122 uiBlockSetCol(block, TH_BUT_SETTING1);
2123 uiBlockBeginAlign(block);
2124 uiDefButBitS(block, TOG, LA_SHAD_RAY, B_SHADRAY,"Ray Shadow",10,180,80,19,&la->mode, 0, 0, 0, 0, "Use ray tracing for shadow");
2125 if(la->type==LA_SPOT)
2126 uiDefButBitS(block, TOG, LA_SHAD, B_SHADBUF, "Buf.Shadow",10,160,80,19,&la->mode, 0, 0, 0, 0, "Lets spotlight produce shadows using shadow buffer");
2127 uiBlockEndAlign(block);
2129 uiDefButBitS(block, TOG, LA_ONLYSHADOW, B_NOP,"OnlyShadow", 10,110,80,19,&la->mode, 0, 0, 0, 0, "Causes light to cast shadows only without illuminating objects");
2131 if(la->type==LA_SPOT) {
2132 uiDefButBitS(block, TOG, LA_SQUARE, B_LAMPREDRAW,"Square", 10,70,80,19,&la->mode, 0, 0, 0, 0, "Sets square spotbundles");
2133 uiDefButBitS(block, TOG, LA_HALO, B_LAMPREDRAW,"Halo", 10,50,80,19,&la->mode, 0, 0, 0, 0, "Renders spotlight with a volumetric halo");
2135 uiBlockSetCol(block, TH_AUTO);
2136 uiBlockBeginAlign(block);
2137 uiDefButF(block, NUMSLI,B_LAMPREDRAW,"SpotSi ", 100,180,200,19,&la->spotsize, 1.0, 180.0, 0, 0, "Sets the angle of the spotlight beam in degrees");
2138 uiDefButF(block, NUMSLI,B_LAMPREDRAW,"SpotBl ", 100,160,200,19,&la->spotblend, 0.0, 1.0, 0, 0, "Sets the softness of the spotlight edge");
2139 uiBlockEndAlign(block);
2141 uiDefButF(block, NUMSLI,B_LAMPREDRAW,"HaloInt ", 100,135,200,19,&la->haint, 0.0, 5.0, 0, 0, "Sets the intensity of the spotlight halo");
2143 if(la->mode & LA_SHAD) {
2144 uiBlockBeginAlign(block);
2145 uiDefButS(block, NUM,B_SBUFF,"ShadowBufferSize:", 100,110,200,19, &la->bufsize,512,10240, 0, 0, "Sets the size of the shadow buffer to nearest multiple of 16");
2146 uiDefButS(block, ROW,B_NOP, "Box", 100,90,65,19, &la->filtertype, 0.0, LA_SHADBUF_BOX, 0, 0, "Apply Box filter for shadowbuffer");
2147 uiDefButS(block, ROW,B_NOP, "Tent", 165,90,65,19, &la->filtertype, 0.0, LA_SHADBUF_TENT, 0, 0, "Apply Tent filter for shadowbuffer");
2148 uiDefButS(block, ROW,B_NOP, "Gauss", 230,90,70,19, &la->filtertype, 0.0, LA_SHADBUF_GAUSS, 0, 0, "Apply Gauss filter for shadowbuffer");
2150 // uiDefButS(block, ROW,B_NOP,"SubSamples: 1", 100,90,140,19, &la->buffers, 1.0, 1.0, 0, 0, "Amount of lampbuffer subsamples, a value of larger than 1 halves the shadowbuffer size");
2151 // uiDefButS(block, ROW,B_NOP,"4", 240,90,30,19, &la->buffers, 1.0, 4.0, 0, 0, "Amount of lampbuffer subsamples, this halves the actual shadowbuffer size");
2152 // uiDefButS(block, ROW,B_NOP,"9", 270,90,30,19, &la->buffers, 1.0, 9.0, 0, 0, "Amount of lampbuffer subsamples, this halves the shadowbuffer size");
2154 uiBlockBeginAlign(block);
2155 uiDefButF(block, NUM,REDRAWVIEW3D,"ClipSta:", 100,60,100,19, &la->clipsta, 0.1*grid,1000.0*grid, 10, 0, "Sets the shadow map clip start: objects closer will not generate shadows");
2156 uiDefButF(block, NUM,REDRAWVIEW3D,"ClipEnd:", 200,60,100,19,&la->clipend, 1.0, 5000.0*grid, 100, 0, "Sets the shadow map clip end beyond which objects will not generate shadows");
2157 uiBlockEndAlign(block);
2159 uiDefButS(block, NUM,B_LAMPREDRAW,"Samples:", 100,30,100,19, &la->samp,1.0,16.0, 0, 0, "Sets the number of shadow map samples");
2160 uiDefButS(block, NUM,B_NOP,"Halo step:", 200,30,100,19, &la->shadhalostep, 0.0, 12.0, 0, 0, "Sets the volumetric halo sampling frequency");
2161 uiDefButF(block, NUM,B_LAMPREDRAW,"Bias:", 100,10,100,19, &la->bias, 0.01, 5.0, 1, 0, "Sets the shadow map sampling bias");
2162 uiDefButF(block, NUM,B_LAMPREDRAW,"Soft:", 200,10,100,19, &la->soft,1.0,100.0, 100, 0, "Sets the size of the shadow sample area");
2165 else if(la->type==LA_AREA && (la->mode & LA_SHAD_RAY)) {
2166 uiBlockBeginAlign(block);
2167 uiBlockSetCol(block, TH_AUTO);
2168 if(la->area_shape==LA_AREA_SQUARE)
2169 uiDefButS(block, NUM,0,"Samples:", 100,180,200,19, &la->ray_samp, 1.0, 16.0, 100, 0, "Sets the amount of samples taken extra (samp x samp)");
2170 if(la->area_shape==LA_AREA_CUBE)
2171 uiDefButS(block, NUM,0,"Samples:", 100,160,200,19, &la->ray_samp, 1.0, 16.0, 100, 0, "Sets the amount of samples taken extra (samp x samp x samp)");
2173 if ELEM(la->area_shape, LA_AREA_RECT, LA_AREA_BOX) {
2174 uiDefButS(block, NUM,0,"SamplesX:", 100,180,200,19, &la->ray_samp, 1.0, 16.0, 100, 0, "Sets the amount of X samples taken extra");
2175 uiDefButS(block, NUM,0,"SamplesY:", 100,160,200,19, &la->ray_sampy, 1.0, 16.0, 100, 0, "Sets the amount of Y samples taken extra");
2176 if(la->area_shape==LA_AREA_BOX)
2177 uiDefButS(block, NUM,0,"SamplesZ:", 100,140,200,19, &la->ray_sampz, 1.0, 8.0, 100, 0, "Sets the amount of Z samples taken extra");
2180 uiBlockBeginAlign(block);
2181 uiDefButBitS(block, TOG, LA_SAMP_UMBRA, 0,"Umbra", 100,110,200,19,&la->ray_samp_type, 0, 0, 0, 0, "Emphasis parts that are fully shadowed");
2182 uiDefButBitS(block, TOG, LA_SAMP_DITHER, 0,"Dither", 100,90,100,19,&la->ray_samp_type, 0, 0, 0, 0, "Use 2x2 dithering for sampling");
2183 uiDefButBitS(block, TOG, LA_SAMP_JITTER, 0,"Noise", 200,90,100,19,&la->ray_samp_type, 0, 0, 0, 0, "Use noise for sampling");
2185 else uiDefBut(block, LABEL,0," ", 100,180,200,19,NULL, 0, 0, 0, 0, "");
2189 /* yafray: adaptation of lamp_panel_spot above with yafray specific parameters */
2190 static void lamp_panel_yafray(Object *ob, Lamp *la)
2194 block= uiNewBlock(&curarea->uiblocks, "lamp_panel_yafray", UI_EMBOSS, UI_HELV, curarea->win);
2195 if(uiNewPanel(curarea, block, "Yafray: Shadow and Photons", "Lamp", 640, 0, 318, 204)==0) return;
2197 /* hemis not used in yafray */
2198 if(la->type==LA_HEMI) return;
2200 uiSetButLock(la->id.lib!=0, "Can't edit library data");
2202 /* photonlight params */
2203 if (la->type==LA_YF_PHOTON) {
2204 uiBlockSetCol(block, TH_BUT_SETTING1);
2205 uiDefButBitS(block, TOG, 1, B_DIFF,"Use QMC",10,180,80,19,&la->YF_useqmc, 0, 0, 0, 0, "Use QMC sampling (sometimes visible patterns)");
2206 uiBlockSetCol(block, TH_AUTO);
2207 uiDefButF(block, NUMSLI,B_LAMPREDRAW,"Angle ", 100,180,200,19,&la->spotsize, 1.0, 180.0, 0, 0, "Sets the angle of the photonlight beam in degrees");
2208 uiDefButI(block, NUM,B_DIFF,"photons:", 10,150,290,19, &la->YF_numphotons, 10000, 100000000, 0, 0, "Maximum number of photons to shoot");
2209 uiDefButI(block, NUM,B_DIFF,"search:", 10,130,290,19, &la->YF_numsearch, 100, 1000, 0, 0, "Number of photons to mix (blur)");
2210 uiDefButS(block, NUM,B_DIFF,"depth:", 10,100,290,19, &la->YF_phdepth, 1, 100, 0, 0, "Maximum caustic bounce depth");
2211 uiDefButF(block, NUM,B_DIFF,"Blur:", 10,70,290,19, &la->YF_causticblur, 0.01, 1.0, 1, 0, "Amount of caustics blurring (also depends on search)");
2215 uiBlockSetCol(block, TH_BUT_SETTING1);
2217 /* in yafray arealights always cast shadows, so ray shadow flag not needed */
2218 /* ray shadow also not used when halo for spot enabled */
2219 if ((la->type!=LA_AREA) && (!((la->type==LA_SPOT) && (la->mode & LA_HALO))))
2220 uiDefButBitS(block, TOG, LA_SHAD_RAY, B_SHADRAY,"Ray Shadow",10,180,80,19,&la->mode, 0, 0, 0, 0, "Use ray tracing for shadow");
2222 /* in yafray the regular lamp can use shadowbuffers (softlight), used by spot with halo as well */
2223 /* to prevent clash with blender shadowbuf flag, a special flag is used for yafray */
2224 if (la->type==LA_LOCAL) {
2225 uiDefButBitS(block, TOG, LA_YF_SOFT, B_SHADBUF, "Buf.Shadow",10,160,80,19,&la->mode, 0, 0, 0, 0, "Lets light produce shadows using shadow buffer");
2226 uiDefButF(block, NUM, B_DIFF, "GloInt:", 100,155,200,19, &la->YF_glowint, 0.0, 1.0, 1, 0, "Sets light glow intensity, 0 is off");
2227 uiDefButF(block, NUM, B_DIFF, "GloOfs:", 100,135,100,19, &la->YF_glowofs, 0.0, 2.0, 1, 0, "Sets light glow offset, the higher, the less 'peaked' the glow");
2228 uiDefButS(block, NUM, B_DIFF, "GlowType:", 200,135,100,19, &la->YF_glowtype, 0, 1, 1, 0, "Sets light glow type");
2231 /* shadowbuffers used only for 'softlight' & spotlight with halo */
2232 if (((la->type==LA_LOCAL) && (la->mode & LA_YF_SOFT)) || ((la->type==LA_SPOT) && (la->mode & LA_HALO))) {
2233 /* Shadow buffer size can be anything in yafray, but reasonable minimum is 128 */
2234 /* Maximum is 1024, since zbuf in yafray is float, no multiple of 16 restriction */
2235 uiDefButS(block, NUM,B_DIFF,"ShadowBufferSize:", 100,110,200,19, &la->YF_bufsize, 128, 1024, 0, 0, "Sets the size of the shadow buffer");
2237 /* samples & halostep params only used for spotlight with halo */
2238 if ((la->type==LA_SPOT) && (la->mode & LA_HALO)) {
2239 uiDefButS(block, NUM,B_DIFF,"Samples:", 100,30,100,19, &la->samp,1.0,16.0, 0, 0, "Sets the number of shadow map samples");
2240 uiDefButS(block, NUM,B_DIFF,"Halo step:", 200,30,100,19, &la->shadhalostep, 0.0, 12.0, 0, 0, "Sets the volumetric halo sampling frequency");
2242 uiDefButF(block, NUM,B_DIFF,"Bias:", 100,10,100,19, &la->bias, 0.01, 5.0, 1, 0, "Sets the shadow map sampling bias");
2243 /* here can use the Blender soft param, since for yafray it has the same function as in Blender */
2244 uiDefButF(block, NUM,B_DIFF,"Soft:", 200,10,100,19, &la->soft,1.0,100.0, 100, 0, "Sets the size of the shadow sample area");
2246 else if ((la->type==LA_LOCAL) && (la->mode & LA_SHAD_RAY)) {
2247 /* for spherelight, light radius */
2248 uiDefButF(block, NUM,B_DIFF,"Radius:", 200,10,100,19, &la->YF_ltradius, 0.0,100.0, 100, 0, "Sets the radius of the lightsource, 0 is same as pointlight");
2251 if (la->type==LA_SPOT) {
2253 uiDefButBitS(block, TOG, LA_HALO, B_LAMPREDRAW,"Halo", 10,50,80,19,&la->mode, 0, 0, 0, 0, "Renders spotlight with a volumetric halo");
2255 uiBlockSetCol(block, TH_AUTO);
2256 uiBlockBeginAlign(block);
2257 uiDefButF(block, NUMSLI,B_LAMPREDRAW,"SpotSi ", 100,180,200,19,&la->spotsize, 1.0, 180.0, 0, 0, "Sets the angle of the spotlight beam in degrees");
2258 uiDefButF(block, NUMSLI,B_LAMPREDRAW,"SpotBl ", 100,160,200,19,&la->spotblend, 0.0, 1.0, 0, 0, "Sets the softness of the spotlight edge");
2259 uiBlockEndAlign(block);
2261 if (la->mode & LA_HALO) uiDefButF(block, NUMSLI,0,"HaloInt ", 100,135,200,19,&la->haint, 0.0, 5.0, 0, 0, "Sets the intensity of the spotlight halo");
2263 else if ((la->type==LA_AREA) || ((la->type==LA_LOCAL) && (la->mode & LA_SHAD_RAY))) {
2264 /* area samples param also used for 'spherelight' */
2265 uiBlockBeginAlign(block);
2266 uiBlockSetCol(block, TH_AUTO);
2268 uiDefButS(block, NUM,B_DIFF,"Samples:", 100,180,200,19, &la->ray_samp, 1.0, 16.0, 100, 0, "Sets the amount of samples taken extra (samp x samp)");
2270 /* shadow sampling types not used in yafray, removed */
2272 else uiDefBut(block, LABEL,0," ", 100,180,200,19,NULL, 0, 0, 0, 0, "");
2276 static void lamp_panel_lamp(Object *ob, Lamp *la)
2282 block= uiNewBlock(&curarea->uiblocks, "lamp_panel_lamp", UI_EMBOSS, UI_HELV, curarea->win);
2283 if(uiNewPanel(curarea, block, "Lamp", "Lamp", 320, 0, 318, 204)==0) return;
2285 if(G.vd) grid= G.vd->grid;
2286 if(grid<1.0) grid= 1.0;
2288 uiSetButLock(la->id.lib!=0, "Can't edit library data");
2290 uiBlockSetCol(block, TH_BUT_SETTING2);
2291 xco= std_libbuttons(block, 8, 180, 0, NULL, B_LAMPBROWSE, ID_LA, 0, (ID *)la, (ID *)ob, &(G.buts->menunr), B_LAMPALONE, B_LAMPLOCAL, 0, 0, 0);
2293 uiBlockSetCol(block, TH_AUTO);
2294 uiDefButF(block, NUM,B_LAMPREDRAW,"Dist:", xco,180,300-xco,20,&la->dist, 0.01, 5000.0*grid, 100, 0, "Sets the distance value at which light intensity is half");
2296 uiBlockBeginAlign(block);
2297 if(la->type==LA_AREA) {
2298 //uiDefButS(block, MENU, B_LAMPREDRAW, "Shape %t|Square %x0|Rect %x1|Cube %x2|Box %x3",
2299 uiDefButS(block, MENU, B_LAMPREDRAW, "Shape %t|Square %x0|Rect %x1",
2300 10, 150, 100, 19, &la->area_shape, 0,0,0,0, "Sets area light shape");
2301 if ELEM(la->area_shape, LA_AREA_RECT, LA_AREA_BOX){
2302 uiDefButF(block, NUM,B_LAMPREDRAW,"SizeX ", 10,130,100,19, &la->area_size, 0.01, 100.0, 10, 0, "Area light size X, doesn't affect energy amount");
2303 uiDefButF(block, NUM,B_LAMPREDRAW,"SizeY ", 10,110,100,19, &la->area_sizey, 0.01, 100.0, 10, 0, "Area light size Y, doesn't affect energy amount");
2305 if(la->area_shape==LA_AREA_BOX)
2306 uiDefButF(block, NUM,B_LAMPREDRAW,"SizeZ ", 10,90,100,19, &la->area_sizez, 0.01, 100.0, 10, 0, "Area light size Z, doesn't affect energy amount");
2307 if ELEM(la->area_shape, LA_AREA_SQUARE, LA_AREA_CUBE)
2308 uiDefButF(block, NUM,B_LAMPREDRAW,"Size ", 10,130,100,19, &la->area_size, 0.01, 100.0, 10, 0, "Area light size, doesn't affect energy amount");
2310 else if ELEM(la->type, LA_LOCAL, LA_SPOT) {
2311 uiBlockSetCol(block, TH_BUT_SETTING1);
2312 uiDefButBitS(block, TOG, LA_QUAD, B_LAMPPRV,"Quad", 10,150,100,19,&la->mode, 0, 0, 0, 0, "Uses inverse quadratic proportion for light attenuation");
2313 uiDefButBitS(block, TOG, LA_SPHERE, REDRAWVIEW3D,"Sphere", 10,130,100,19,&la->mode, 0, 0, 0, 0, "Sets light intensity to zero for objects beyond the distance value");
2316 uiBlockBeginAlign(block);
2317 uiBlockSetCol(block, TH_BUT_SETTING1);
2318 uiDefButBitS(block, TOG, LA_LAYER, 0,"Layer", 10,70,100,19,&la->mode, 0, 0, 0, 0, "Illuminates objects in the same layer as the lamp only");
2319 uiDefButBitS(block, TOG, LA_NEG, B_LAMPPRV,"Negative", 10,50,100,19,&la->mode, 0, 0, 0, 0, "Sets lamp to cast negative light");
2320 uiDefButBitS(block, TOG, LA_NO_DIFF, 0,"No Diffuse", 10,30,100,19,&la->mode, 0, 0, 0, 0, "Disables diffuse shading of material illuminated by this lamp");
2321 uiDefButBitS(block, TOG, LA_NO_SPEC, 0,"No Specular", 10,10,100,19,&la->mode, 0, 0, 0, 0, "Disables specular shading of material illuminated by this lamp");
2322 uiBlockEndAlign(block);
2324 uiBlockSetCol(block, TH_AUTO);
2325 uiDefButF(block, NUMSLI,B_LAMPPRV,"Energy ", 120,150,180,20, &(la->energy), 0.0, 10.0, 0, 0, "Sets the intensity of the light");
2327 uiBlockBeginAlign(block);
2328 uiDefButF(block, NUMSLI,B_LAMPPRV,"R ", 120,120,180,20,&la->r, 0.0, 1.0, B_COLLAMP, 0, "Sets the red component of the light");
2329 uiDefButF(block, NUMSLI,B_LAMPPRV,"G ", 120,100,180,20,&la->g, 0.0, 1.0, B_COLLAMP, 0, "Sets the green component of the light");
2330 uiDefButF(block, NUMSLI,B_LAMPPRV,"B ", 120,80,180,20,&la->b, 0.0, 1.0, B_COLLAMP, 0, "Sets the blue component of the light");
2331 uiBlockEndAlign(block);
2333 uiDefButF(block, COL, B_LAMPPRV, "", 120,52,180,24, &la->r, 0, 0, 0, B_COLLAMP, "");
2335 uiBlockBeginAlign(block);
2336 if ELEM(la->type, LA_LOCAL, LA_SPOT) {
2337 uiDefButF(block, NUMSLI,B_LAMPPRV,"Quad1 ", 120,30,180,19,&la->att1, 0.0, 1.0, 0, 0, "Set the linear distance attenuatation for a quad lamp");
2338 uiDefButF(block, NUMSLI,B_LAMPPRV,"Quad2 ", 120,10,180,19,&la->att2, 0.0, 1.0, 0, 0, "Set the quadratic distance attenuatation for a quad lamp");
2340 else if(la->type==LA_AREA) {
2341 if(la->k==0.0) la->k= 1.0;
2342 uiDefButF(block, NUMSLI,0,"Gamma ", 120,10,180,19,&la->k, 0.001, 2.0, 100, 0, "Set the light gamma correction value");
2347 static void lamp_panel_preview(Object *ob, Lamp *la)
2351 /* name "Preview" is abused to detect previewrender offset panel */
2352 block= uiNewBlock(&curarea->uiblocks, "lamp_panel_preview", UI_EMBOSS, UI_HELV, curarea->win);
2353 if(uiNewPanel(curarea, block, "Preview", "Lamp", 0, 0, 318, 204)==0) return;
2355 uiSetButLock(la->id.lib!=0, "Can't edit library data");
2357 uiBlockSetDrawExtraFunc(block, BIF_previewdraw);
2359 // label to force a boundbox for buttons not to be centered
2360 uiDefBut(block, LABEL, 0, " ", 20,20,10,10, 0, 0, 0, 0, 0, "");
2361 uiBlockBeginAlign(block);
2362 uiDefButS(block, ROW,B_LAMPREDRAW,"Lamp", 200,175,80,25,&la->type,1.0,(float)LA_LOCAL, 0, 0, "Creates an omnidirectional point light source");
2363 uiDefButS(block, ROW,B_LAMPREDRAW,"Area", 200,150,80,25,&la->type,1.0,(float)LA_AREA, 0, 0, "Creates a directional area light source");
2364 uiDefButS(block, ROW,B_LAMPREDRAW,"Spot", 200,125,80,25,&la->type,1.0,(float)LA_SPOT, 0, 0, "Creates a directional cone light source");
2365 uiDefButS(block, ROW,B_LAMPREDRAW,"Sun", 200,100,80,25,&la->type,1.0,(float)LA_SUN, 0, 0, "Creates a constant direction parallel ray light source");
2366 uiDefButS(block, ROW,B_LAMPREDRAW,"Hemi", 200,75,80,25,&la->type,1.0,(float)LA_HEMI, 0, 0, "Creates a 180 degree constant light source");
2367 /* yafray: extra type, photonlight */
2368 if (G.scene->r.renderer==R_YAFRAY)
2369 uiDefButS(block, ROW,B_LAMPREDRAW,"Photon", 200,50,80,25,&la->type,1.0,(float)LA_YF_PHOTON, 0, 0, "Creates a special caustics photon 'light', not a real lightsource, use with other lights");
2373 /* ****************** MATERIAL ***************** */
2376 void do_matbuts(unsigned short event)
2378 static short mtexcopied=0;
2379 static MTex mtexcopybuf;
2383 /* all operations default on active material layer here */
2384 /* but this also gets called for lamp and world... */
2385 ma= G.buts->lockpoin;
2386 if(ma && GS(ma->id.name)==ID_MA)
2387 ma = editnode_get_active_material(ma);
2392 case B_MAT_YF_PRESET: {
2393 switch (ma->YF_preset) {
2395 /* normal mode, no reflection/refraction */
2397 ma->mode &= ~(MA_RAYMIRROR+MA_RAYTRANSP+MA_ZTRA);
2403 ma->fresnel_mir_i = 5;
2404 ma->mode |= (MA_RAYMIRROR+MA_RAYTRANSP);
2405 ma->mode &= ~MA_ZTRA;
2414 ma->fresnel_mir_i = 5;
2415 ma->mode |= (MA_RAYMIRROR+MA_RAYTRANSP);
2416 ma->mode &= ~MA_ZTRA;
2422 /* uniform reflect */
2425 ma->fresnel_mir_i = 1;
2426 ma->mode |= MA_RAYMIRROR;
2427 ma->mode &= ~(MA_RAYTRANSP+MA_ZTRA);
2431 /* fresnel reflect */
2434 ma->fresnel_mir_i = 5;
2435 ma->mode |= MA_RAYMIRROR;
2436 ma->mode &= ~(MA_RAYTRANSP+MA_ZTRA);
2441 BIF_preview_changed(ID_MA);
2442 allqueue(REDRAWBUTSSHADING, 0);
2443 shade_buttons_change_3d();
2447 scrarea_queue_headredraw(curarea);
2448 allqueue(REDRAWBUTSSHADING, 0);
2449 allqueue(REDRAWIPO, 0);
2450 allqueue(REDRAWOOPS, 0);
2451 BIF_preview_changed(ID_MA);
2454 scrarea_queue_headredraw(curarea);
2455 allqueue(REDRAWBUTSSHADING, 0);
2456 allqueue(REDRAWOOPS, 0);
2457 // BIF_previewdraw(); push/pop!
2460 if(ma) end_render_material(ma); /// temporal... 3d preview
2461 BIF_preview_changed(ID_MA);
2462 allqueue(REDRAWBUTSSHADING, 0);
2463 shade_buttons_change_3d();
2466 BIF_preview_changed(ID_LA);
2467 allqueue(REDRAWBUTSSHADING, 0);
2470 BIF_preview_changed(ID_WO);
2471 allqueue(REDRAWBUTSSHADING, 0);
2474 /* when halo is disabled, clear star flag, this is the same as MA_FACETEXTURE <blush> */
2475 /* same for 'xtreme alpha' which is 'only shadow' */
2476 if((ma->mode & MA_HALO)==0) {
2477 ma->mode &= ~(MA_STAR|MA_HALO_XALPHA|MA_ZINV|MA_ENV);
2479 BIF_preview_changed(ID_MA);
2480 allqueue(REDRAWBUTSSHADING, 0);
2481 shade_buttons_change_3d();
2484 mtex= ma->mtex[(int) ma->texact ];
2486 if(mtex->tex) mtex->tex->id.us--;
2488 ma->mtex[ (int) ma->texact ]= 0;
2489 BIF_undo_push("Unlink material texture");
2490 if(ma) end_render_material(ma); /// temporal... 3d preview
2491 allqueue(REDRAWBUTSSHADING, 0);
2492 allqueue(REDRAWOOPS, 0);
2493 BIF_preview_changed(ID_MA);
2497 if(ma && ma->mtex[(int)ma->texact] ) {
2498 mtex= ma->mtex[(int)ma->texact];
2500 error("No texture available");
2503 memcpy(&mtexcopybuf, ma->mtex[(int)ma->texact], sizeof(MTex));
2509 if(ma && mtexcopied && mtexcopybuf.tex) {
2510 if(ma->mtex[(int)ma->texact]==0 )
2511 ma->mtex[(int)ma->texact]= MEM_mallocN(sizeof(MTex), "mtex");
2512 else if(ma->mtex[(int)ma->texact]->tex)
2513 ma->mtex[(int)ma->texact]->tex->id.us--;
2515 memcpy(ma->mtex[(int)ma->texact], &mtexcopybuf, sizeof(MTex));
2517 id_us_plus((ID *)mtexcopybuf.tex);
2518 BIF_undo_push("Paste mapping settings");
2519 BIF_preview_changed(ID_MA);
2520 scrarea_queue_winredraw(curarea);
2524 if(ma && ma->lay==0) {
2526 scrarea_queue_winredraw(curarea);
2531 ma->mode &= ~MA_RAYTRANSP;
2532 //BIF_view3d_previewrender_signal(curarea, PR_DBASE|PR_DISPRECT); /// temporal... 3d preview
2533 allqueue(REDRAWBUTSSHADING, 0);
2534 BIF_preview_changed(ID_MA);
2537 case B_MATRAYTRANSP:
2539 ma->mode &= ~MA_ZTRA;
2540 if(ma) end_render_material(ma); /// temporal... 3d preview
2541 allqueue(REDRAWBUTSSHADING, 0);
2542 BIF_preview_changed(ID_MA);
2545 case B_MATCOLORBAND:
2547 if(ma->mode & MA_RAMP_COL)
2548 if(ma->ramp_col==NULL) ma->ramp_col= add_colorband(0);
2549 if(ma->mode & MA_RAMP_SPEC)
2550 if(ma->ramp_spec==NULL) ma->ramp_spec= add_colorband(0);
2552 if(ma) end_render_material(ma); /// temporal... 3d preview
2553 allqueue(REDRAWBUTSSHADING, 0);
2554 BIF_preview_changed(ID_MA);
2555 shade_buttons_change_3d();
2558 case B_MAT_USENODES:
2559 ma= G.buts->lockpoin; /* use base material instead */
2561 if(ma->use_nodes && ma->nodetree==NULL) {
2562 node_shader_default(ma);
2564 if(ma) end_render_material(ma); /// temporal... 3d preview
2565 BIF_preview_changed(ID_MA);
2566 allqueue(REDRAWNODE, 0);
2567 allqueue(REDRAWBUTSSHADING, 0);
2575 static void material_panel_map_to(Material *ma)
2580 block= uiNewBlock(&curarea->uiblocks, "material_panel_map_to", UI_EMBOSS, UI_HELV, curarea->win);
2581 uiNewPanelTabbed("Texture", "Material");
2582 if(uiNewPanel(curarea, block, "Map To", "Material", 1600, 0, 318, 204)==0) return;
2584 mtex= ma->mtex[ ma->texact ];
2590 /* TEXTURE OUTPUT */
2591 uiBlockBeginAlign(block);
2592 uiDefButBitS(block, TOG, MTEX_STENCIL, B_MATPRV, "Stencil", 10,125,45,19, &(mtex->texflag), 0, 0, 0, 0, "Sets the texture mapping to stencil mode");
2593 uiDefButBitS(block, TOG, MTEX_NEGATIVE, B_MATPRV, "Neg", 55,125,30,19, &(mtex->texflag), 0, 0, 0, 0, "Inverts the values of the texture to reverse its effect");
2594 uiDefButBitS(block, TOG,MTEX_RGBTOINT, B_MATPRV, "No RGB", 85,125,60,19, &(mtex->texflag), 0, 0, 0, 0, "Converts texture RGB values to intensity (gray) values");
2595 uiBlockEndAlign(block);
2597 uiBlockBeginAlign(block);
2598 uiDefButF(block, COL, B_MATPRV, "", 10,100,135,19, &(mtex->r), 0, 0, 0, B_MTEXCOL, "");
2600 if(ma->colormodel==MA_HSV) {
2601 uiBlockSetCol(block, TH_BUT_SETTING1);
2602 uiDefButF(block, HSVSLI, B_MATPRV, "H ", 10,80,135,19, &(mtex->r), 0.0, 0.9999, B_MTEXCOL, 0, "");
2603 uiDefButF(block, HSVSLI, B_MATPRV, "S ", 10,60,135,19, &(mtex->r), 0.0001, 1.0, B_MTEXCOL, 0, "");
2604 uiDefButF(block, HSVSLI, B_MATPRV, "V ", 10,40,135,19, &(mtex->r), 0.0001, 1.0, B_MTEXCOL, 0, "");
2605 uiBlockSetCol(block, TH_AUTO);
2608 uiDefButF(block, NUMSLI, B_MATPRV, "R ", 10,80,135,19, &(mtex->r), 0.0, 1.0, B_MTEXCOL, 0, "The default color for textures that don't return RGB");
2609 uiDefButF(block, NUMSLI, B_MATPRV, "G ", 10,60,135,19, &(mtex->g), 0.0, 1.0, B_MTEXCOL, 0, "The default color for textures that don't return RGB");
2610 uiDefButF(block, NUMSLI, B_MATPRV, "B ", 10,40,135,19, &(mtex->b), 0.0, 1.0, B_MTEXCOL, 0, "The default color for textures that don't return RGB");
2612 uiBlockEndAlign(block);
2614 uiDefButF(block, NUMSLI, B_MATPRV, "DVar ", 10,10,135,19, &(mtex->def_var), 0.0, 1.0, 0, 0, "The default value the texture uses to mix with (not RGB)");
2617 uiBlockBeginAlign(block);
2618 uiDefButBitS(block, TOG, MAP_COL, B_MATPRV, "Col", 10,180,40,19, &(mtex->mapto), 0, 0, 0, 0, "Causes the texture to affect basic colour of the material");
2619 uiDefButBitS(block, TOG3, MAP_NORM, B_MATPRV, "Nor", 50,180,40,19, &(mtex->mapto), 0, 0, 0, 0, "Causes the texture to affect the rendered normal");
2620 uiDefButBitS(block, TOG, MAP_COLSPEC, B_MATPRV, "Csp", 90,180,40,19, &(mtex->mapto), 0, 0, 0, 0, "Causes the texture to affect the specularity colour");
2621 uiDefButBitS(block, TOG, MAP_COLMIR, B_MATPRV, "Cmir", 130,180,50,19, &(mtex->mapto), 0, 0, 0, 0, "Causes the texture to affect the mirror colour");
2622 uiDefButBitS(block, TOG3, MAP_REF, B_MATPRV, "Ref", 180,180,40,19, &(mtex->mapto), 0, 0, 0, 0, "Causes the texture to affect the value of the materials reflectivity");
2623 uiDefButBitS(block, TOG3, MAP_SPEC, B_MATPRV, "Spec", 220,180,50,19, &(mtex->mapto), 0, 0, 0, 0, "Causes the texture to affect the value of specularity");
2624 uiDefButBitS(block, TOG3, MAP_AMB, B_MATPRV, "Amb", 270,180,40,19, &(mtex->mapto), 0, 0, 0, 0, "Causes the texture to affect the value of ambient");
2626 uiDefButBitS(block, TOG3, MAP_HAR, B_MATPRV, "Hard", 10,160,50,19, &(mtex->mapto), 0, 0, 0, 0, "Causes the texture to affect the hardness value");
2627 uiDefButBitS(block, TOG3, MAP_RAYMIRR, B_MATPRV, "RayMir", 60,160,50,19, &(mtex->mapto), 0, 0, 0, 0, "Causes the texture to affect the ray-mirror value");
2628 uiDefButBitS(block, TOG3, MAP_ALPHA, B_MATPRV, "Alpha", 110,160,50,19, &(mtex->mapto), 0, 0, 0, 0, "Causes the texture to affect the alpha value");
2629 uiDefButBitS(block, TOG3, MAP_EMIT, B_MATPRV, "Emit", 160,160,45,19, &(mtex->mapto), 0, 0, 0, 0, "Causes the texture to affect the emit value");
2630 uiDefButBitS(block, TOG3, MAP_TRANSLU, B_MATPRV, "TransLu", 205,160,60,19, &(mtex->mapto), 0, 0, 0, 0, "Causes the texture to affect the layer blending value");
2631 uiDefButBitS(block, TOG3, MAP_DISPLACE, B_MATPRV, "Disp", 265,160,45,19, &(mtex->mapto), 0, 0, 0, 0, "Let the texture displace the surface");
2632 uiBlockEndAlign(block);
2634 uiBlockBeginAlign(block);
2635 uiDefButS(block, MENU, B_MATPRV, mapto_blendtype_pup(),155,125,155,19, &(mtex->blendtype), 0, 0, 0, 0, "Texture blending mode");
2636 uiBlockEndAlign(block);
2638 uiBlockBeginAlign(block);
2639 uiDefButF(block, NUMSLI, B_MATPRV, "Col ", 155,100,155,19, &(mtex->colfac), 0.0, 1.0, 0, 0, "Sets the amount the texture affects colour values");
2640 /* newnoise: increased range to 25, the constant offset for bumpmapping quite often needs a higher nor setting */
2641 uiDefButF(block, NUMSLI, B_MATPRV, "Nor ", 155,80,155,19, &(mtex->norfac), 0.0, 25.0, 0, 0, "Sets the amount the texture affects normal values");
2642 uiDefButF(block, NUMSLI, B_MATPRV, "Var ", 155,60,155,19, &(mtex->varfac), 0.0, 1.0, 0, 0, "Sets the amount the texture affects other values");
2643 uiDefButF(block, NUMSLI, B_MATPRV, "Disp ", 155,40,155,19, &(mtex->dispfac), 0.0, 1.0, 0, 0, "Sets the amount the texture displaces the surface");
2645 uiBlockBeginAlign(block);
2646 uiDefButBitS(block, TOG, MAP_WARP, B_MATPRV, "Warp", 155,10,40,19, &(mtex->mapto), 0, 0, 0, 0, "Let the texture warp texture coordinates of next channels");
2647 uiDefButF(block, NUMSLI, B_MATPRV, "fac ", 195,10,115,19, &(mtex->warpfac), 0.0, 1.0, 0, 0, "Sets the amount the texture affects texture coordinates of next channels");
2651 static void material_panel_map_input(Object *ob, Material *ma)
2657 block= uiNewBlock(&curarea->uiblocks, "material_panel_map_input", UI_EMBOSS, UI_HELV, curarea->win);
2658 uiNewPanelTabbed("Texture", "Material");
2659 if(uiNewPanel(curarea, block, "Map Input", "Material", 1280, 0, 318, 204)==0) return;
2661 mtex= ma->mtex[ ma->texact ];
2668 uiBlockBeginAlign(block);
2669 uiDefButS(block, ROW, B_MATPRV, "Glob", 630,180,45,18, &(mtex->texco), 4.0, (float)TEXCO_GLOB, 0, 0, "Uses global coordinates for the texture coordinates");
2670 uiDefButS(block, ROW, B_MATPRV, "Object", 675,180,75,18, &(mtex->texco), 4.0, (float)TEXCO_OBJECT, 0, 0, "Uses linked object's coordinates for texture coordinates");
2671 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_MATPRV, "",750,180,158,18, &(mtex->object), "");
2673 uiDefButS(block, ROW, B_MATPRV, "UV", 630,160,40,18, &(mtex->texco), 4.0, (float)TEXCO_UV, 0, 0, "Uses UV coordinates for texture coordinates");
2674 uiDefButS(block, ROW, B_MATPRV, "Orco", 670,160,55,18, &(mtex->texco), 4.0, (float)TEXCO_ORCO, 0, 0, "Uses the original undeformed coordinates of the object");
2675 if( give_parteff(ob) )
2676 uiDefButS(block, ROW, B_MATPRV, "Strand", 725,160,50,18, &(mtex->texco), 4.0, (float)TEXCO_STRAND, 0, 0, "Uses normalized strand texture coordinate (1D)");
2678 uiDefButS(block, ROW, B_MATPRV, "Stick", 725,160,50,18, &(mtex->texco), 4.0, (float)TEXCO_STICKY, 0, 0, "Uses mesh's sticky coordinates for the texture coordinates");
2679 uiDefButS(block, ROW, B_MATPRV, "Win", 775,160,45,18, &(mtex->texco), 4.0, (float)TEXCO_WINDOW, 0, 0, "Uses screen coordinates as texture coordinates");
2680 uiDefButS(block, ROW, B_MATPRV, "Nor", 820,160,44,18, &(mtex->texco), 4.0, (float)TEXCO_NORM, 0, 0, "Uses normal vector as texture coordinates");
2681 uiDefButS(block, ROW, B_MATPRV, "Refl", 864,160,44,18, &(mtex->texco), 4.0, (float)TEXCO_REFL, 0, 0, "Uses reflection vector as texture coordinates");
2683 uiDefButS(block, ROW, B_MATPRV, "Stress", 630,140,70,18, &(mtex->texco), 4.0, (float)TEXCO_STRESS, 0, 0, "Uses the difference of edge lengths compared to original coordinates of the mesh");
2684 uiDefButS(block, ROW, B_MATPRV, "Tangent", 700,140,70,18, &(mtex->texco), 4.0, (float)TEXCO_TANGENT, 0, 0, "Uses the optional tangent vector as texture coordinates");
2687 uiBlockBeginAlign(block);
2688 uiDefButC(block, ROW, B_MATPRV, "Flat", 630,115,48,19, &(mtex->mapping), 5.0, (float)MTEX_FLAT, 0, 0, "Maps X and Y coordinates directly");
2689 uiDefButC(block, ROW, B_MATPRV, "Cube", 681,115,50,19, &(mtex->mapping), 5.0, (float)MTEX_CUBE, 0, 0, "Maps using the normal vector");
2690 uiDefButC(block, ROW, B_MATPRV, "Tube", 630,95,48,19, &(mtex->mapping), 5.0, (float)MTEX_TUBE, 0, 0, "Maps with Z as central axis (tube-like)");
2691 uiDefButC(block, ROW, B_MATPRV, "Sphe", 681,95,50,19, &(mtex->mapping), 5.0, (float)MTEX_SPHERE, 0, 0, "Maps with Z as central axis (sphere-like)");
2693 uiBlockBeginAlign(block);
2694 for(b=0; b<3; b++) {
2696 if(b==0) cp= &(mtex->projx);
2697 else if(b==1) cp= &(mtex->projy);
2698 else cp= &(mtex->projz);
2700 uiDefButC(block, ROW, B_MATPRV, "", 630, 50-20*b, 24, 18, cp, 6.0+b, 0.0, 0, 0, "");
2701 uiDefButC(block, ROW, B_MATPRV, "X", 656, 50-20*b, 24, 18, cp, 6.0+b, 1.0, 0, 0, "");
2702 uiDefButC(block, ROW, B_MATPRV, "Y", 682, 50-20*b, 24, 18, cp, 6.0+b, 2.0, 0, 0, "");
2703 uiDefButC(block, ROW, B_MATPRV, "Z", 708, 50-20*b, 24, 18, cp, 6.0+b, 3.0, 0, 0, "");
2706 uiBlockBeginAlign(block);
2707 uiDefButF(block, NUM, B_MATPRV, "ofsX", 778,115,130,19, mtex->ofs, -10.0, 10.0, 10, 0, "Fine tunes texture mapping X coordinate");
2708 uiDefButF(block, NUM, B_MATPRV, "ofsY", 778,95,130,19, mtex->ofs+1, -10.0, 10.0, 10, 0, "Fine tunes texture mapping Y coordinate");
2709 uiDefButF(block, NUM, B_MATPRV, "ofsZ", 778,75,130,19, mtex->ofs+2, -10.0, 10.0, 10, 0, "Fine tunes texture mapping Z coordinate");
2710 uiBlockBeginAlign(block);
2711 uiDefButF(block, NUM, B_MATPRV, "sizeX", 778,50,130,19, mtex->size, -100.0, 100.0, 10, 0, "Sets scaling for the texture's X size");
2712 uiDefButF(block, NUM, B_MATPRV, "sizeY", 778,30,130,19, mtex->size+1, -100.0, 100.0, 10, 0, "Sets scaling for the texture's Y size");
2713 uiDefButF(block, NUM, B_MATPRV, "sizeZ", 778,10,130,19, mtex->size+2, -100.0, 100.0, 10, 0, "Sets scaling for the texture's Z size");
2714 uiBlockEndAlign(block);
2719 static void material_panel_texture(Material *ma)
2726 char str[64], *strp;
2728 block= uiNewBlock(&curarea->uiblocks, "material_panel_texture", UI_EMBOSS, UI_HELV, curarea->win);
2729 if(uiNewPanel(curarea, block, "Texture", "Material", 960, 0, 318, 204)==0) return;
2732 uiBlockSetCol(block, TH_BUT_NEUTRAL);
2734 uiBlockBeginAlign(block);
2735 for(a= 0; a<MAX_MTEX; a++) {
2737 if(mtex && mtex->tex) splitIDname(mtex->tex->id.name+2, str, &loos);
2738 else strcpy(str, "");
2740 uiDefButC(block, ROW, B_MATPRV, str, 10, 180-18*a, 70, 20, &(ma->texact), 3.0, (float)a, 0, 0, "");
2742 uiBlockEndAlign(block);
2745 uiBlockSetCol(block, TH_AUTO);
2747 for(a= 0; a<MAX_MTEX; a++) {
2749 if(mtex && mtex->tex) {
2750 if(ma->septex & (1<<a))
2751 uiDefButBitS(block, TOG, 1<<a, B_MATPRV, " ", -20, 180-18*a, 28, 20, &ma->septex, 0.0, 0.0, 0, 0, "Click to disable or enable this texture channel");
2752 else uiDefIconButBitS(block, TOG, 1<<a, B_MATPRV, ICON_CHECKBOX_HLT, -20, 180-18*a, 28, 20, &ma->septex, 0.0, 0.0, 0, 0, "Click to disable or enable this texture channel");
2755 uiBlockBeginAlign(block);
2756 uiDefIconBut(block, BUT, B_MTEXCOPY, ICON_COPYUP, 100,180,23,21, 0, 0, 0, 0, 0, "Copies the mapping settings to the buffer");
2757 uiDefIconBut(block, BUT, B_MTEXPASTE, ICON_PASTEUP, 125,180,23,21, 0, 0, 0, 0, 0, "Pastes the mapping settings from the buffer");
2758 uiBlockEndAlign(block);
2759 uiBlockSetCol(block, TH_AUTO);
2761 mtex= ma->mtex[ ma->texact ];
2767 /* TEXTUREBLOK SELECT */
2768 uiBlockSetCol(block, TH_BUT_SETTING2);
2769 if(G.main->tex.first==0)
2772 id= (ID*) mtex->tex;
2773 IDnames_to_pupstring(&strp, NULL, "ADD NEW %x32767", &(G.main->tex), id, &(G.buts->texnr));
2774 uiDefButS(block, MENU, B_EXTEXBROWSE, strp, 100,130,20,20, &(G.buts->texnr), 0, 0, 0, 0, "Selects an existing texture or creates new");
2778 uiDefBut(block, TEX, B_IDNAME, "TE:", 100,150,163,20, id->name+2, 0.0, 18.0, 0, 0, "Displays name of the texture block: click to change");
2779 sprintf(str, "%d", id->us);
2780 uiDefBut(block, BUT, 0, str, 196,130,21,20, 0, 0, 0, 0, 0, "Displays number of users of texture");
2781 uiDefIconBut(block, BUT, B_AUTOTEXNAME, ICON_AUTO, 241,130,21,20, 0, 0, 0, 0, 0, "Auto-assigns name to texture");
2783 if(ma->id.lib) uiDefIconBut(block, BUT, 0, ICON_DATALIB, 219,130,21,20, 0, 0, 0, 0, 0, "");
2784 else uiDefIconBut(block, BUT, 0, ICON_PARLIB, 219,130,21,20, 0, 0, 0, 0, 0, "");
2786 uiBlockSetCol(block, TH_AUTO);
2787 uiDefBut(block, BUT, B_TEXCLEAR, "Clear", 122, 130, 72, 20, 0, 0, 0, 0, 0, "Erases link to texture");
2791 uiDefButS(block, TOG, B_EXTEXBROWSE, "Add New" ,100, 150, 163, 20, &(G.buts->texnr), -1.0, 32767.0, 0, 0, "Adds a new texture datablock");
2793 // force no centering
2794 uiDefBut(block, LABEL, 0, " ", 250, 10, 25, 20, 0, 0, 0, 0, 0, "");
2796 uiBlockSetCol(block, TH_AUTO);
2799 static void material_panel_tramir(Material *ma)
2803 block= uiNewBlock(&curarea->uiblocks, "material_panel_tramir", UI_EMBOSS, UI_HELV, curarea->win);
2804 uiNewPanelTabbed("Shaders", "Material");
2805 if(uiNewPanel(curarea, block, "Mirror Transp", "Material", 640, 0, 318, 204)==0) return;
2807 uiDefButBitI(block, TOG, MA_RAYMIRROR, B_MATPRV,"Ray Mirror",210,180,100,20, &(ma->mode), 0, 0, 0, 0, "Enables raytracing for mirror reflection rendering");
2809 uiBlockBeginAlign(block);
2810 uiDefButF(block, NUMSLI, B_MATPRV, "RayMir ", 10,160,200,20, &(ma->ray_mirror), 0.0, 1.0, 100, 2, "Sets the amount mirror reflection for raytrace");
2811 uiDefButS(block, NUM, B_MATPRV, "Depth:", 210,160,100,20, &(ma->ray_depth), 0.0, 10.0, 100, 0, "Amount of inter-reflections calculated maximal ");
2813 uiDefButF(block, NUMSLI, B_MATPRV, "Fresnel ", 10,140,160,20, &(ma->fresnel_mir), 0.0, 5.0, 10, 2, "Power of Fresnel for mirror reflection");
2814 uiDefButF(block, NUMSLI, B_MATPRV, "Fac ", 170,140,140,20, &(ma->fresnel_mir_i), 1.0, 5.0, 10, 2, "Blending factor for Fresnel");
2816 uiBlockBeginAlign(block);
2817 uiDefButF(block, NUM, B_MATPRV, "Filt:", 10,110,150,20, &(ma->filter), 0.0, 1.0, 10, 0, "Amount of filtering for transparent raytrace");
2818 uiDefButBitI(block, TOG, MA_RAYTRANSP, B_MATRAYTRANSP,"Ray Transp",160,110,150,20, &(ma->mode), 0, 0, 0, 0, "Enables raytracing for transparency rendering");
2820 uiBlockBeginAlign(block);
2821 uiDefButF(block, NUMSLI, B_MATPRV, "IOR ", 10,90,200,20, &(ma->ang), 1.0, 3.0, 100, 2, "Sets the angular index of refraction for raytrace");
2822 uiDefButS(block, NUM, B_MATPRV, "Depth:", 210,90,100,20, &(ma->ray_depth_tra), 0.0, 10.0, 100, 0, "Amount of refractions calculated maximal ");
2824 uiDefButF(block, NUMSLI, B_MATPRV, "Fresnel ", 10,70,160,20, &(ma->fresnel_tra), 0.0, 5.0, 10, 2, "Power of Fresnel for transparency");
2825 uiDefButF(block, NUMSLI, B_MATPRV, "Fac ", 170,70,140,20, &(ma->fresnel_tra_i), 1.0, 5.0, 10, 2, "Blending factor for Fresnel");
2827 uiBlockBeginAlign(block);
2828 uiDefButF(block, NUMSLI, B_MATPRV, "SpecTra ", 10,40,150,20, &(ma->spectra), 0.0, 1.0, 0, 0, "Makes specular areas opaque on transparent materials");
2829 uiDefButF(block, NUMSLI, B_MATPRV, "Add ", 160,40,150,20, &(ma->add), 0.0, 1.0, 0, 0, "Sets a glow factor for transparant materials");
2831 uiBlockBeginAlign(block);
2832 uiDefButBitI(block, TOG, MA_NOMIST, 0, "No Mist", 10,10,150,20, &(ma->mode), 0, 0, 0, 0, "Sets the material to ignore mist values");
2833 uiDefButBitI(block, TOG, MA_ENV, 0, "Env", 160,10,150,20, &(ma->mode), 0, 0, 0, 0, "Causes faces to render with alpha zero: allows sky/backdrop to show through");
2834 uiBlockEndAlign(block);
2840 /* yafray: adapted version of Blender's tramir panel.
2841 * Only removed the buttons not needed, so only the ones that are important for yafray are left.
2842 * Also re-arranged buttons for more room for extra parameters.
2843 * With the exception of the material preset menu and the new parameters,
2844 * most of blender's parameters are re-used without interfering with them.
2846 static void material_panel_tramir_yafray(Material *ma)
2849 char *mstr = "Material presets %t|No Reflect/Transmit %x0|Clear Glass %x1|Color Glass %x2|Uniform Reflect %x3|Fresnel Reflect %x4";
2851 /* better to use same name as original panel */
2852 block= uiNewBlock(&curarea->uiblocks, "material_panel_tramir", UI_EMBOSS, UI_HELV, curarea->win);
2853 uiNewPanelTabbed("Shaders", "Material");
2854 if(uiNewPanel(curarea, block, "Mirror Transp", "Material", 640, 0, 318, 204)==0) return;
2856 /* material preset menu */
2857 uiDefBut(block, LABEL, 0, "Mat.Preset", 20, 182, 100, 20, 0, 0.0, 0.0, 0, 0, "");
2858 uiDefButI(block, MENU, B_MAT_YF_PRESET, mstr, 110, 182, 200, 20, &ma->YF_preset, 0.0, 0.0, 0, 0, "Basic material presets to start with");
2860 uiDefButBitI(block, TOG, MA_RAYMIRROR, B_MATPRV,"Ray Mirror", 10,160,100,20, &(ma->mode), 0, 0, 0, 0, "Enables raytracing for mirror reflection rendering");
2861 uiDefButBitI(block, TOG, MA_RAYTRANSP, B_MATRAYTRANSP,"Ray Transp", 110,160,100,20, &(ma->mode), 0, 0, 0, 0, "Enables raytracing for transparency rendering");
2862 uiDefButBitI(block, TOG, MA_ZTRA, B_MATZTRANSP,"ZTransp", 210,160,100,20, &(ma->mode), 0, 0, 0, 0, "Use for objects with alphamap textures");
2864 uiDefButF(block, NUMSLI, B_MATPRV, "rayMir ", 10,140,150,20, &(ma->ray_mirror), 0.0, 1.0, 100, 2, "Sets the amount mirror reflection for raytrace");
2865 uiDefButF(block, NUMSLI, B_MATPRV, "frsOfs ", 160,140,150,20, &(ma->fresnel_mir_i), 1.0, 5.0, 10, 2, "Fresnel offset, 1 is uniform mirror, 5 is fresnel mirror (IOR>1)");
2867 /* ior has extended range up to 30, for use with total fresnel reflection */
2868 uiDefButF(block, NUMSLI, B_MATPRV, "IOR ", 10,115,150,20, &(ma->ang), 1.0, 30.0, 100, 2, "Sets the angular index of refraction for raytrace");
2870 // parameters only used in ray_transp mode
2871 if(ma->mode & MA_RAYTRANSP) {
2873 uiDefButF(block, NUM, B_MATPRV, "Filt:", 160,115,150,20, &(ma->filter), 0.0, 1.0, 10, 0, "Amount of filtering for transparent raytrace");
2875 /* absorption color */
2876 uiDefBut(block, LABEL, 0, "Absorption Color", 10, 98, 150, 18, 0, 0.0, 0.0, 0, 0, "");
2877 uiDefButF(block, COL, B_MATPRV, "", 10, 38, 30, 58, &ma->YF_ar, 0, 0, 0, B_MATCOL, "transmit absorption color, white is no absorption");
2878 uiDefButF(block, NUMSLI, B_MATPRV, "aR ", 40, 78, 120, 18, &ma->YF_ar, 1e-7f, 1.0, B_MATCOL, 0, "");
2879 uiDefButF(block, NUMSLI, B_MATPRV, "aG ", 40, 58, 120, 18, &ma->YF_ag, 1e-7f, 1.0, B_MATCOL, 0, "");
2880 uiDefButF(block, NUMSLI, B_MATPRV, "aB ", 40, 38, 120, 18, &ma->YF_ab, 1e-7f, 1.0, B_MATCOL, 0, "");
2881 uiDefButF(block, NUM, B_MATPRV, "Ds", 10, 18, 150, 18, &ma->YF_dscale, 1e-7f, 100.0, 10.0, 0, "absorption distance scale, 1 is one blender (world) unit of distance");
2883 /* disperions parameters */
2884 uiDefBut(block, LABEL, 0, "Dispersion", 160, 98, 150, 18, 0, 0.0, 0.0, 0, 0, "");
2885 uiDefButF(block, NUM, B_MATPRV, "Pwr ", 160, 78, 150, 18, &ma->YF_dpwr, 0.0, 1.0, 0.25, 0, "Dispersion power, the higher, the more dispersion, 0 is no dispersion");
2886 uiDefButI(block, NUM, B_MATPRV, "Samples ", 160, 58, 150, 18, &ma->YF_dsmp, 1.0, 100.0, 0, 0, "Dispersion samples, minimum&nb