From 0d03929b9b2cb05936a62e84fecfff18fca2fa7b Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Fri, 10 Oct 2003 17:29:01 +0000 Subject: Another huge commit!!! First, check on the new files, which are listed below. The new butspace.h is a local include, only to be used for the buttons drawn in the buttonswindow. - editbuts, animbuts, gamebuts, displaybuts, paintbuts, work now - i quite completely reorganized it, it's now nicely telling you what context it is in - sorting error in panel align fixed (tabs were flipping) - align works correctly automatic when you click around in Blender - editsca.c renamed to buttons_logic.h - button names are truncated from the right for allmost all buttons (except text buttons and number buttons) - while dragging panels, you cannot move them outside window anymore And of course fixed loads of little bugs I encountered while testing it all. This is a version I really need good test & feedback for. Next step: restoring material/lamp/texture/world --- source/blender/src/butspace.c | 199 +- source/blender/src/buttons.txt | 8435 ++++++++++---------------------- source/blender/src/buttons_editing.c | 2057 ++++++++ source/blender/src/buttons_logic.c | 2618 ++++++++++ source/blender/src/buttons_object.c | 903 ++++ source/blender/src/buttons_scene.c | 62 +- source/blender/src/buttons_script.c | 82 + source/blender/src/buttons_shading.c | 85 + source/blender/src/editarmature.c | 255 +- source/blender/src/editconstraint.c | 1 + source/blender/src/editface.c | 1 + source/blender/src/editipo.c | 2 +- source/blender/src/editsca.c | 2635 ---------- source/blender/src/editscreen.c | 8 +- source/blender/src/ghostwinlay.c | 6 +- source/blender/src/header_buttonswin.c | 38 +- source/blender/src/headerbuttons.c | 1 + source/blender/src/interface.c | 490 +- source/blender/src/previewrender.c | 1 + source/blender/src/space.c | 41 +- 20 files changed, 8710 insertions(+), 9210 deletions(-) create mode 100644 source/blender/src/buttons_editing.c create mode 100644 source/blender/src/buttons_logic.c create mode 100644 source/blender/src/buttons_object.c create mode 100644 source/blender/src/buttons_script.c create mode 100644 source/blender/src/buttons_shading.c delete mode 100644 source/blender/src/editsca.c (limited to 'source/blender/src') diff --git a/source/blender/src/butspace.c b/source/blender/src/butspace.c index b2b3cc4e064..730da7bc186 100644 --- a/source/blender/src/butspace.c +++ b/source/blender/src/butspace.c @@ -44,89 +44,41 @@ #endif #include "MEM_guardedalloc.h" -#include "DNA_action_types.h" -#include "DNA_armature_types.h" -#include "DNA_camera_types.h" -#include "DNA_constraint_types.h" -#include "DNA_curve_types.h" -#include "DNA_effect_types.h" -#include "DNA_group_types.h" -#include "DNA_ika_types.h" -#include "DNA_image_types.h" -#include "DNA_key_types.h" -#include "DNA_lamp_types.h" -#include "DNA_lattice_types.h" -#include "DNA_material_types.h" -#include "DNA_meta_types.h" -#include "DNA_mesh_types.h" + #include "DNA_object_types.h" -#include "DNA_packedFile_types.h" -#include "DNA_radio_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" -#include "DNA_sound_types.h" +#include "DNA_view3d_types.h" #include "DNA_space_types.h" #include "DNA_texture_types.h" -#include "DNA_userdef_types.h" -#include "DNA_vfont_types.h" -#include "DNA_view3d_types.h" -#include "DNA_world_types.h" - -#include "BKE_anim.h" -#include "BKE_armature.h" -#include "BKE_constraint.h" -#include "BKE_curve.h" -#include "BKE_displist.h" -#include "BKE_effect.h" -#include "BKE_font.h" + #include "BKE_global.h" -#include "BKE_ika.h" -#include "BKE_image.h" -#include "BKE_ipo.h" -#include "BKE_lattice.h" -#include "BKE_library.h" #include "BKE_main.h" -#include "BKE_material.h" -#include "BKE_mball.h" -#include "BKE_mesh.h" -#include "BKE_object.h" -#include "BKE_packedFile.h" -#include "BKE_plugin_types.h" -#include "BKE_sound.h" -#include "BKE_texture.h" +#include "BKE_library.h" #include "BKE_utildefines.h" -#include "BKE_writeavi.h" #include "BLI_blenlib.h" #include "BIF_gl.h" #include "BIF_graphics.h" #include "BIF_keyval.h" -#include "BIF_mainqueue.h" -#include "BIF_resources.h" -#include "BIF_screen.h" -#include "BIF_mywindow.h" -#include "BIF_space.h" -#include "BIF_glutil.h" #include "BIF_interface.h" -#include "BIF_editsca.h" -#include "BIF_butspace.h" -#include "BIF_previewrender.h" #include "BIF_toolbox.h" - +#include "BIF_space.h" +#include "BIF_screen.h" +#include "BIF_butspace.h" #include "BSE_headerbuttons.h" +#include "BIF_previewrender.h" +#include "BIF_mywindow.h" +#include "BIF_glutil.h" +#include "BIF_resources.h" #include "mydevice.h" +#include "butspace.h" // own module /* Local vars ---------------------------------------------------------- */ short bgpicmode=0, near=1000, far=1000; -short degr= 90, step= 9, turn= 1, editbutflag= 1; -float hspeed=0.1f, prspeed=0.0f, prlen=0.0f, doublimit= 0.001f; -int decim_faces=0; - -float editbutvweight=1; -float extr_offs= 1.0, editbutweight=1.0, editbutsize=0.1, cumapsize= 1.0; MTex emptytex; MTex mtexcopybuf; @@ -281,7 +233,6 @@ void do_butspace(unsigned short event) buts= curarea->spacedata.first; if(buts->mainb==CONTEXT_SCENE) allqueue(REDRAWBUTSSCENE, curarea->win); if(buts->mainb==CONTEXT_OBJECT) allqueue(REDRAWBUTSOBJECT, curarea->win); - if(buts->mainb==CONTEXT_TYPES) allqueue(REDRAWBUTSTYPES, curarea->win); if(buts->mainb==CONTEXT_SHADING) allqueue(REDRAWBUTSSHADING, curarea->win); if(buts->mainb==CONTEXT_EDITING) allqueue(REDRAWBUTSEDIT, curarea->win); if(buts->mainb==CONTEXT_SCRIPT) allqueue(REDRAWBUTSSCRIPT, curarea->win); @@ -303,7 +254,7 @@ void do_butspace(unsigned short event) //do_texbuts(event); } else if(event<=B_ANIMBUTS) { - //do_animbuts(event); + do_object_panels(event); } else if(event<=B_WORLDBUTS) { //do_worldbuts(event); @@ -312,34 +263,31 @@ void do_butspace(unsigned short event) do_render_panels(event); // buttons_scene.c } else if(event<=B_COMMONEDITBUTS) { - //do_common_editbuts(event); + do_common_editbuts(event); } else if(event<=B_MESHBUTS) { - //do_meshbuts(event); + do_meshbuts(event); } else if(event<=B_CURVEBUTS) { - //do_curvebuts(event); + do_curvebuts(event); } else if(event<=B_FONTBUTS) { - //do_fontbuts(event); - } - else if(event<=B_IKABUTS) { - //do_ikabuts(event); + do_fontbuts(event); } else if(event<=B_CAMBUTS) { ; } else if(event<=B_MBALLBUTS) { - //do_mballbuts(event); + do_mballbuts(event); } else if(event<=B_LATTBUTS) { - //do_latticebuts(event); + do_latticebuts(event); } else if(event<=B_GAMEBUTS) { - do_gamebuts(event); // editsca.c + do_logic_buts(event); // buttons_logic.c } else if(event<=B_FPAINTBUTS) { - //do_fpaintbuts(event); + do_fpaintbuts(event); } else if(event<=B_RADIOBUTS) { //do_radiobuts(event); @@ -367,13 +315,15 @@ void redraw_test_buttons(Base *new) if(sa->spacetype==SPACE_BUTS) { buts= sa->spacedata.first; - if(ELEM5(buts->mainb, CONTEXT_OBJECT, CONTEXT_TYPES, CONTEXT_EDITING, CONTEXT_SHADING, CONTEXT_LOGIC)) { + if(ELEM4(buts->mainb, CONTEXT_OBJECT, CONTEXT_EDITING, CONTEXT_SHADING, CONTEXT_LOGIC)) { addqueue(sa->win, REDRAW, 1); + buts->re_align= 1; } if(buts->mainb==CONTEXT_SHADING) { - // change type automatically + buts->re_align= 1; + // change type automatically if(new) { if(buts->tab[CONTEXT_SHADING] == TAB_SHADING_WORLD); else if(buts->tab[CONTEXT_SHADING] == TAB_SHADING_TEX); @@ -395,68 +345,13 @@ void redraw_test_buttons(Base *new) } - -/* here the calls for building the button main/tabs tree */ - - -static void context_scene_buttons(ScrArea *sa, SpaceButs *sbuts) -{ - - /* select tabs */ - if(sbuts->tab[CONTEXT_SCENE] == TAB_SCENE_RENDER) - render_panels(); - -} - -static void context_object_buttons(ScrArea *sa, SpaceButs *sbuts) -{ - - /* select tabs */ - -} - -static void context_types_buttons(ScrArea *sa, SpaceButs *sbuts) -{ - - /* select tabs */ - -} - -static void context_shading_buttons(ScrArea *sa, SpaceButs *sbuts) -{ - - /* select tabs */ - -} - -static void context_editing_buttons(ScrArea *sa, SpaceButs *sbuts) -{ - - /* select tabs */ - -} - -static void context_logic_buttons(ScrArea *sa, SpaceButs *sbuts) -{ - - /* no tabs */ - gamebuts(); /* (editsca.c) */ - -} - -static void context_script_buttons(ScrArea *sa, SpaceButs *sbuts) -{ - - /* select tabs */ - -} - /* callback */ void drawbutspace(ScrArea *sa, void *spacedata) { SpaceButs *sbuts= sa->spacedata.first; View2D *v2d= &sbuts->v2d; - + int align=0; + myortho2(v2d->cur.xmin, v2d->cur.xmax, v2d->cur.ymin, v2d->cur.ymax); glClearColor(0.73, 0.73, 0.73, 0.0); @@ -468,30 +363,54 @@ void drawbutspace(ScrArea *sa, void *spacedata) /* select the context to be drawn, per contex/tab the actual context is tested */ switch(sbuts->mainb) { case CONTEXT_SCENE: - context_scene_buttons(sa, sbuts); + /* select tabs */ + if(sbuts->tab[CONTEXT_SCENE] == TAB_SCENE_RENDER) + render_panels(); + else if(sbuts->tab[CONTEXT_SCENE] == TAB_SCENE_ANIM) + anim_panels(); + else if(sbuts->tab[CONTEXT_SCENE] == TAB_SCENE_SOUND) + sound_panels(); + break; case CONTEXT_OBJECT: - context_object_buttons(sa, sbuts); + /* no tabs */ + object_panels(); break; - case CONTEXT_TYPES: - context_types_buttons(sa, sbuts); + break; case CONTEXT_SHADING: - context_shading_buttons(sa, sbuts); + break; case CONTEXT_EDITING: - context_editing_buttons(sa, sbuts); + /* no tabs */ + editing_panels(); + break; case CONTEXT_SCRIPT: - context_script_buttons(sa, sbuts); + break; case CONTEXT_LOGIC: - context_logic_buttons(sa, sbuts); + /* no tabs */ + logic_buts(); break; } uiClearButLock(); + + /* when align changes, also do this for new panels */ + /* don't always align, this function is called during AnmatePanels too */ + if(sbuts->align) + if(sbuts->re_align || sbuts->mainbo!=sbuts->mainb) + align= 1; + + uiDrawBlocksPanels(sa, align); + + sbuts->re_align= 0; + // also for memory for finding which texture you'd like to see + sbuts->mainbo= sbuts->mainb; + sbuts->tabo= sbuts->tab[sbuts->mainb]; + myortho2(-0.5, (float)(sa->winx)-.05, -0.5, (float)(sa->winy)-0.5); draw_area_emboss(sa); myortho2(v2d->cur.xmin, v2d->cur.xmax, v2d->cur.ymin, v2d->cur.ymax); diff --git a/source/blender/src/buttons.txt b/source/blender/src/buttons.txt index b32ad5ea201..1b209c3515e 100644 --- a/source/blender/src/buttons.txt +++ b/source/blender/src/buttons.txt @@ -593,2825 +593,2028 @@ static void draw_buttons_edge(int win, float x1) static int packdummy = 0; -void test_scriptpoin_but(char *name, ID **idpp) -{ - ID *id; - - id= G.main->text.first; - while(id) { - if( strcmp(name, id->name+2)==0 ) { - *idpp= id; - return; - } - id= id->next; - } - *idpp= 0; -} -#ifdef __NLA -void test_actionpoin_but(char *name, ID **idpp) -{ - ID *id; - - id= G.main->action.first; - while(id) { - if( strcmp(name, id->name+2)==0 ) { - *idpp= id; - return; - } - id= id->next; - } - *idpp= 0; -} -#endif - -void test_obpoin_but(char *name, ID **idpp) -{ - ID *id; - - if(idpp == (ID **)&(emptytex.object)) { - error("You must add a Texture first!"); - *idpp= 0; - return; - } - - id= G.main->object.first; - while(id) { - if( strcmp(name, id->name+2)==0 ) { - *idpp= id; - return; - } - id= id->next; - } - *idpp= 0; -} - -void test_obcurpoin_but(char *name, ID **idpp) -{ - ID *id; - - if(idpp == (ID **)&(emptytex.object)) { - error("You must add a Texture first!"); - *idpp= 0; - return; - } - - id= G.main->object.first; - while(id) { - if( strcmp(name, id->name+2)==0 ) { - if (((Object *)id)->type != OB_CURVE) { - error ("Bevel object must be a Curve."); - break; - } - *idpp= id; - return; - } - id= id->next; - } - *idpp= 0; -} - -void test_meshpoin_but(char *name, ID **idpp) -{ - ID *id; - if( *idpp ) (*idpp)->us--; - - id= G.main->mesh.first; - while(id) { - if( strcmp(name, id->name+2)==0 ) { - *idpp= id; - id_us_plus(id); - return; - } - id= id->next; - } - *idpp= 0; -} +// Bish made it to here. (reviewing tooltips) -void test_matpoin_but(char *name, ID **idpp) -{ - ID *id; - if( *idpp ) (*idpp)->us--; - - id= G.main->mat.first; - while(id) { - if( strcmp(name, id->name+2)==0 ) { - *idpp= id; - id_us_plus(id); - return; - } - id= id->next; - } - *idpp= 0; -} +/* *************************** RADIO ******************************** */ -void test_scenepoin_but(char *name, ID **idpp) +void do_radiobuts(short event) { - ID *id; + Radio *rad; + int phase; - if( *idpp ) (*idpp)->us--; + phase= rad_phase(); + rad= G.scene->radio; - id= G.main->scene.first; - while(id) { - if( strcmp(name, id->name+2)==0 ) { - *idpp= id; - id_us_plus(id); - return; - } - id= id->next; - } - *idpp= 0; -} - - - -/* ************************************* */ - -static void do_common_editbuts(unsigned short event) -{ - EditVlak *evl; - Base *base; - Object *ob; - Mesh *me; - Nurb *nu; - Curve *cu; - MFace *mface; - BezTriple *bezt; - BPoint *bp; - unsigned int local; - int a, bit, index= -1; - switch(event) { - - case B_MATWICH: - if(G.obedit && G.obedit->actcol>0) { - if(G.obedit->type == OB_MESH) { - evl= G.edvl.first; - while(evl) { - if( vlakselectedAND(evl, 1) ) { - if(index== -1) index= evl->mat_nr; - else if(index!=evl->mat_nr) { - error("Mixed colors"); - return; - } - } - evl= evl->next; - } - } - else if ELEM(G.obedit->type, OB_CURVE, OB_SURF) { - nu= editNurb.first; - while(nu) { - if( isNurbsel(nu) ) { - if(index== -1) index= nu->mat_nr; - else if(index!=nu->mat_nr) { - error("Mixed colors"); - return; - } - } - nu= nu->next; - } - } - if(index>=0) { - G.obedit->actcol= index+1; - scrarea_queue_winredraw(curarea); - } - } - break; - case B_MATNEW: - new_material_to_objectdata((G.scene->basact) ? (G.scene->basact->object) : 0); - scrarea_queue_winredraw(curarea); - allqueue(REDRAWVIEW3D_Z, 0); + case B_RAD_ADD: + add_radio(); + allqueue(REDRAWBUTSRADIO, 0); + allqueue(REDRAWVIEW3D, 0); break; - case B_MATDEL: - delete_material_index(); - scrarea_queue_winredraw(curarea); - allqueue(REDRAWVIEW3D_Z, 0); + case B_RAD_DELETE: + delete_radio(); + allqueue(REDRAWBUTSRADIO, 0); + allqueue(REDRAWVIEW3D, 0); break; - case B_MATASS: - if(G.obedit && G.obedit->actcol>0) { - if(G.obedit->type == OB_MESH) { - evl= G.edvl.first; - while(evl) { - if( vlakselectedAND(evl, 1) ) - evl->mat_nr= G.obedit->actcol-1; - evl= evl->next; - } - allqueue(REDRAWVIEW3D_Z, 0); - makeDispList(G.obedit); - } - else if ELEM(G.obedit->type, OB_CURVE, OB_SURF) { - nu= editNurb.first; - while(nu) { - if( isNurbsel(nu) ) - nu->mat_nr= G.obedit->actcol-1; - nu= nu->next; - } - } - } + case B_RAD_FREE: + freeAllRad(); + allqueue(REDRAWBUTSRADIO, 0); + allqueue(REDRAWVIEW3D, 0); break; - case B_MATSEL: - case B_MATDESEL: - if(G.obedit) { - if(G.obedit->type == OB_MESH) { - evl= G.edvl.first; - while(evl) { - if(evl->mat_nr== G.obedit->actcol-1) { - if(event==B_MATSEL) { - if(evl->v1->h==0) evl->v1->f |= 1; - if(evl->v2->h==0) evl->v2->f |= 1; - if(evl->v3->h==0) evl->v3->f |= 1; - if(evl->v4 && evl->v4->h==0) evl->v4->f |= 1; - } - else { - if(evl->v1->h==0) evl->v1->f &= ~1; - if(evl->v2->h==0) evl->v2->f &= ~1; - if(evl->v3->h==0) evl->v3->f &= ~1; - if(evl->v4 && evl->v4->h==0) evl->v4->f &= ~1; - } - } - evl= evl->next; - } - tekenvertices_ext( event==B_MATSEL ); - } - else if ELEM(G.obedit->type, OB_CURVE, OB_SURF) { - nu= editNurb.first; - while(nu) { - if(nu->mat_nr==G.obedit->actcol-1) { - if(nu->bezt) { - a= nu->pntsu; - bezt= nu->bezt; - while(a--) { - if(bezt->hide==0) { - if(event==B_MATSEL) { - bezt->f1 |= 1; - bezt->f2 |= 1; - bezt->f3 |= 1; - } - else { - bezt->f1 &= ~1; - bezt->f2 &= ~1; - bezt->f3 &= ~1; - } - } - bezt++; - } - } - else if(nu->bp) { - a= nu->pntsu*nu->pntsv; - bp= nu->bp; - while(a--) { - if(bp->hide==0) { - if(event==B_MATSEL) bp->f1 |= 1; - else bp->f1 &= ~1; - } - bp++; - } - } - } - nu= nu->next; - } - allqueue(REDRAWVIEW3D, 0); - } - } + case B_RAD_COLLECT: + rad_collect_meshes(); + allqueue(REDRAWBUTSRADIO, 0); + allqueue(REDRAWVIEW3D, 0); break; - case B_HIDE: - if(G.obedit) { - if(G.obedit->type == OB_MESH) hide_mesh(0); - else if ELEM(G.obedit->type, OB_CURVE, OB_SURF) hideNurb(0); + case B_RAD_INIT: + if(phase==RAD_PHASE_PATCHES) { + rad_limit_subdivide(); + allqueue(REDRAWBUTSRADIO, 0); + allqueue(REDRAWVIEW3D, 0); } break; - case B_REVEAL: - if(G.obedit) { - if(G.obedit->type == OB_MESH) reveal_mesh(); - else if ELEM(G.obedit->type, OB_CURVE, OB_SURF) revealNurb(); + case B_RAD_SHOOTP: + if(phase==RAD_PHASE_PATCHES) { + waitcursor(1); + rad_subdivshootpatch(); + allqueue(REDRAWBUTSRADIO, 0); + allqueue(REDRAWVIEW3D, 0); + waitcursor(0); } - else if(G.f & G_FACESELECT) reveal_tface(); - break; - case B_SELSWAP: - if(G.obedit) { - if(G.obedit->type == OB_MESH) selectswap_mesh(); - else if ELEM(G.obedit->type, OB_CURVE, OB_SURF) selectswapNurb(); + case B_RAD_SHOOTE: + if(phase==RAD_PHASE_PATCHES) { + waitcursor(1); + rad_subdivshootelem(); + allqueue(REDRAWBUTSRADIO, 0); + allqueue(REDRAWVIEW3D, 0); + waitcursor(0); } break; - case B_AUTOTEX: - ob= OBACT; - if(ob && G.obedit==0) { - if(ob->type==OB_MESH) tex_space_mesh(ob->data); - else if(ob->type==OB_MBALL) ; - else tex_space_curve(ob->data); + case B_RAD_GO: + if(phase==RAD_PHASE_PATCHES) { + waitcursor(1); + rad_go(); + waitcursor(0); + allqueue(REDRAWBUTSRADIO, 0); + allqueue(REDRAWVIEW3D, 0); } break; - case B_DOCENTRE: - docentre(); - break; - case B_DOCENTRENEW: - docentre_new(); + case B_RAD_LIMITS: + rad_setlimits(); + allqueue(REDRAWVIEW3D, 0); + allqueue(REDRAWBUTSRADIO, 0); break; - case B_DOCENTRECURSOR: - docentre_cursor(); + case B_RAD_FAC: + set_radglobal(); + if(phase & RAD_PHASE_FACES) make_face_tab(); + else make_node_display(); + allqueue(REDRAWVIEW3D, 0); break; - case B_SETSMOOTH: - case B_SETSOLID: - if(G.obedit) { - if(G.obedit->type == OB_MESH) { - evl= G.edvl.first; - while(evl) { - if( vlakselectedAND(evl, 1) ) { - if(event==B_SETSMOOTH) evl->flag |= ME_SMOOTH; - else evl->flag &= ~ME_SMOOTH; - } - evl= evl->next; - } - - makeDispList(G.obedit); - allqueue(REDRAWVIEW3D, 0); - } - else { - nu= editNurb.first; - while(nu) { - if(isNurbsel(nu)) { - if(event==B_SETSMOOTH) nu->flag |= ME_SMOOTH; - else nu->flag &= ~ME_SMOOTH; - } - nu= nu->next; - } - - } + case B_RAD_NODELIM: + if(phase & RAD_PHASE_FACES) { + set_radglobal(); + removeEqualNodes(rad->nodelim); + make_face_tab(); + allqueue(REDRAWVIEW3D, 0); + allqueue(REDRAWBUTSRADIO, 0); } - else { - base= FIRSTBASE; - while(base) { - if(TESTBASELIB(base)) { - if(base->object->type==OB_MESH) { - me= base->object->data; - mface= me->mface; - for(a=0; atotface; a++, mface++) { - if(event==B_SETSMOOTH) mface->flag |= ME_SMOOTH; - else mface->flag &= ~ME_SMOOTH; - } - - makeDispList(base->object); - } - else if ELEM(base->object->type, OB_SURF, OB_CURVE) { - cu= base->object->data; - nu= cu->nurb.first; - while(nu) { - if(event==B_SETSMOOTH) nu->flag |= ME_SMOOTH; - else nu->flag &= ~ME_SMOOTH; - nu= nu->next; - } - } - } - base= base->next; - } + break; + case B_RAD_NODEFILT: + if(phase & RAD_PHASE_FACES) { + set_radglobal(); + filterNodes(); + make_face_tab(); allqueue(REDRAWVIEW3D, 0); } break; - - default: - if(event>=B_OBLAY && event<=B_OBLAY+31) { - local= BASACT->lay & 0xFF000000; - BASACT->lay -= local; - if(BASACT->lay==0 || (G.qual & LR_SHIFTKEY)==0) { - bit= event-B_OBLAY; - BASACT->lay= 1<lay += local; - /* optimal redraw */ - if( (OBACT->lay & G.vd->lay) && (BASACT->lay & G.vd->lay) ); - else if( (OBACT->lay & G.vd->lay)==0 && (BASACT->lay & G.vd->lay)==0 ); - else allqueue(REDRAWVIEW3D, 0); - - OBACT->lay= BASACT->lay; + case B_RAD_FACEFILT: + if(phase & RAD_PHASE_FACES) { + filterFaces(); + allqueue(REDRAWVIEW3D, 0); } + break; + case B_RAD_DRAW: + set_radglobal(); + allqueue(REDRAWVIEW3D, 0); + break; + case B_RAD_ADDMESH: + if(phase & RAD_PHASE_FACES) rad_addmesh(); + allqueue(REDRAWVIEW3D, 0); + break; + case B_RAD_REPLACE: + if(phase & RAD_PHASE_FACES) rad_replacemesh(); + allqueue(REDRAWVIEW3D, 0); + break; } } -void common_editbuts(void) + +void radiobuts(void) { - Object *ob; - ID *id; - Material *ma; + Radio *rad; uiBlock *block; - void *poin; - float min; - int xco, a, dx, dy; - char str[32]; - - ob= OBACT; - if(ob==0) return; + int flag; + char str[128]; + + rad= G.scene->radio; + if(rad==0) { + add_radio(); + rad= G.scene->radio; + } sprintf(str, "buttonswin %d", curarea->win); block= uiNewBlock(&curarea->uiblocks, str, UI_EMBOSSX, UI_HELV, curarea->win); - /* LAYERS */ - xco= 291; - dx= 32; - dy= 30; - for(a=0; a<10; a++) { - /* the (a+10) evaluates correctly because of - precedence... brackets aren't a bad idea though */ - uiDefButI(block, TOG|BIT|(a+10), B_OBLAY+a+10, "", (short)(xco+a*(dx/2)), 180, (short)(dx/2), (short)(dy/2), &(BASACT->lay), 0, 0, 0, 0, ""); - uiDefButI(block, TOG|BIT|a, B_OBLAY+a, "",(short)(xco+a*(dx/2)), (short)(180+dy/2), (short)(dx/2), (short)(1+dy/2), &(BASACT->lay), 0, 0, 0, 0, ""); - if(a==4) xco+= 5; - } - - id= ob->data; - if(id && id->lib) uiSetButLock(1, "Can't edit library data"); - - uiBlockSetCol(block, BUTGREY); - uiDefBut(block, LABEL, 0, "Drawtype", 28,200,100,18, 0, 0, 0, 0, 0, ""); - uiDefButC(block, MENU, REDRAWVIEW3D, "Drawtype%t|Bounds %x1|Wire %x2|Solid %x3|Shaded %x4", - 28,180,100,18, &ob->dt, 0, 0, 0, 0, "Sets the drawing type of the active object"); - uiDefBut(block, LABEL, 0, "Draw Extra", 28,160,100,18, 0, 0, 0, 0, 0, ""); - uiDefButC(block, TOG|BIT|0, REDRAWVIEW3D, "Bounds", 28, 140, 100, 18, &ob->dtx, 0, 0, 0, 0, "Displays the active object's bounds"); - uiDefButS(block, MENU, REDRAWVIEW3D, "Boundary Display%t|Box%x0|Sphere%x1|Cylinder%x2|Cone%x3|Polyheder", - 28, 120, 100, 18, &ob->boundtype, 0, 0, 0, 0, "Selects the boundary display type"); - uiDefButC(block, TOG|BIT|5, REDRAWVIEW3D, "Wire", 28, 100, 100, 18, &ob->dtx, 0, 0, 0, 0, "Displays the active object's wireframe in shaded drawing modes"); - uiDefButC(block, TOG|BIT|1, REDRAWVIEW3D, "Axis", 28, 80, 100, 18, &ob->dtx, 0, 0, 0, 0, "Displays the active object's centre and axis"); - uiDefButC(block, TOG|BIT|2, REDRAWVIEW3D, "TexSpace", 28, 60, 100, 18, &ob->dtx, 0, 0, 0, 0, "Displays the active object's texture space"); - uiDefButC(block, TOG|BIT|3, REDRAWVIEW3D, "Name", 28, 40, 100, 18, &ob->dtx, 0, 0, 0, 0, "Displays the active object's name"); - - uiBlockSetCol(block, BUTGREY); - - /* material and select swap and hide */ - if ELEM5(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL) { - - if(ob->type==OB_MESH) poin= &( ((Mesh *)ob->data)->texflag ); - else if(ob->type==OB_MBALL) poin= &( ((MetaBall *)ob->data)->texflag ); - else poin= &( ((Curve *)ob->data)->texflag ); - uiDefButI(block, TOG|BIT|0, B_AUTOTEX, "AutoTexSpace", 143,180,130,19, poin, 0, 0, 0, 0, "Adjusts active object's texture space automatically when transforming object"); + flag= rad_phase(); - sprintf(str,"%d Mat:", ob->totcol); - if(ob->totcol) min= 1.0; else min= 0.0; - ma= give_current_material(ob, ob->actcol); - - if(ma) { - uiDefButF(block, COL, 0, "", 291,123,24,30, &(ma->r), 0, 0, 0, 0, ""); - uiDefBut(block, LABEL, 0, ma->id.name+2, 318,146, 103, 30, 0, 0, 0, 0, 0, ""); - } - uiDefButC(block, NUM, B_REDR, str, 318,123,103,30, &ob->actcol, min, (float)(ob->totcol), 0, 0, "Displays total number of material indices and the current index"); - uiDefBut(block, BUT,B_MATWICH, "?", 423,123,31,30, 0, 0, 0, 0, 0, "In EditMode, sets the active material index from selected faces"); - + if(flag & RAD_PHASE_PATCHES) { uiBlockSetCol(block, BUTSALMON); - uiDefBut(block, BUT,B_MATNEW, "New", 292,101,80,21, 0, 0, 0, 0, 0, "Adds a new Material index"); - uiDefBut(block, BUT,B_MATDEL, "Delete", 374,101,80,21, 0, 0, 0, 0, 0, "Deletes this Material index"); - uiDefBut(block, BUT,B_MATASS, "Assign", 291,47,162,26, 0, 0, 0, 0, 0, "In EditMode, assigns the active index to selected faces"); + uiDefBut(block, BUT, B_RAD_INIT, "Limit Subdivide", 10, 70, 190, 40, NULL, 0, 0, 0, 0, "Subdivide patches"); + } + if(flag & RAD_PHASE_PATCHES) uiBlockSetCol(block, BUTPURPLE); + else uiBlockSetCol(block, BUTSALMON); + uiDefBut(block, BUT, B_RAD_COLLECT, "Collect Meshes", 10, 30, 190, 40, NULL, 0, 0, 0, 0, "Convert selected and visible meshes to patches"); + uiDrawBlock(block); + if(flag==0) { + + sprintf(str, "buttonswin1 %d", curarea->win); + block= uiNewBlock(&curarea->uiblocks, str, UI_EMBOSSX, UI_HELV, curarea->win); + uiAutoBlock(block, 210, 30, 230, 150, UI_BLOCK_ROWS); uiBlockSetCol(block, BUTGREY); - uiDefBut(block, BUT,B_MATSEL, "Select", 292,76,79,22, 0, 0, 0, 0, 0, "In EditMode, selects faces that have the active index"); - uiDefBut(block, BUT,B_MATDESEL, "Deselect", 373,76,79,21, 0, 0, 0, 0, 0, "Deselects everything with current indexnumber"); - - if(ob->type!=OB_FONT) { - uiDefBut(block, BUT,B_HIDE, "Hide", 1091,152,77,18, 0, 0, 0, 0, 0, "Hides selected faces"); - uiDefBut(block, BUT,B_REVEAL, "Reveal", 1171,152,86,18, 0, 0, 0, 0, 0, "Reveals selected faces"); - uiDefBut(block, BUT,B_SELSWAP, "Select Swap", 1091,129,166,18, 0, 0, 0, 0, 0, "Selects unselected faces, and deselects selected faces"); - } - uiDefBut(block, BUT,B_SETSMOOTH, "Set Smooth", 291,15,80,20, 0, 0, 0, 0, 0, "In EditMode, sets 'smooth' rendering of selected faces"); - uiDefBut(block, BUT,B_SETSOLID, "Set Solid", 373,15,80,20, 0, 0, 0, 0, 0, "In EditMode, sets 'solid' rendering of selected faces"); - + uiDefButS(block, NUM, B_RAD_LIMITS, "Hemires:", 0, 0, 10, 10, &rad->hemires, 100.0, 1000.0, 100, 0, "Set the size of a hemicube"); + uiDefButS(block, NUM, 0, "Max Iterations:", 1, 0, 10, 10, &rad->maxiter, 0.0, 10000.0, 0, 0, "Maximum number of radiosity rounds"); + uiDefButF(block, NUM, B_RAD_FAC, "Mult:", 2, 0, 50, 10, &rad->radfac, 0.001, 250.0, 100, 0, "Mulitply the energy values"); + uiDefButF(block, NUM, B_RAD_FAC, "Gamma:", 2, 0, 50, 10, &rad->gamma, 0.2, 10.0, 10, 0, "Change the contrast of the energy values"); + uiDefButF(block, NUM, 0, "Convergence:", 3, 0, 10, 10, &rad->convergence, 0.0, 1.0, 10, 0, "Set the lower threshold of unshot energy"); + uiDrawBlock(block); } + else { - if ELEM3(ob->type, OB_MESH, OB_SURF, OB_CURVE) { - uiBlockSetCol(block, BUTSALMON); - uiDefBut(block, BUT,B_DOCENTRE, "Centre", 961, 115, 100, 19, 0, 0, 0, 0, 0, "Shifts object data to be centered about object's origin"); - uiDefBut(block, BUT,B_DOCENTRENEW, "Centre New", 961, 95, 100, 19, 0, 0, 0, 0, 0, "Shifts object's origin to center of object data"); - uiDefBut(block, BUT,B_DOCENTRECURSOR, "Centre Cursor", 961, 75, 100, 19, 0, 0, 0, 0, 0, "Shifts object's origin to cursor location"); - } - - uiDrawBlock(block); + sprintf(str, "buttonswin1 %d", curarea->win); + block= uiNewBlock(&curarea->uiblocks, str, UI_EMBOSSX, UI_HELV, curarea->win); + uiAutoBlock(block, 210, 30, 230, 150, UI_BLOCK_ROWS); + + uiBlockSetCol(block, BUTGREEN); + uiDefButS(block, ROW, B_RAD_DRAW, "Wire", 0, 0, 10, 10, &rad->drawtype, 0.0, 0.0, 0, 0, "Enable wireframe drawmode"); + uiDefButS(block, ROW, B_RAD_DRAW, "Solid", 0, 0, 10, 10, &rad->drawtype, 0.0, 1.0, 0, 0, "Enable solid drawmode"); + uiDefButS(block, ROW, B_RAD_DRAW, "Gour", 0, 0, 10, 10, &rad->drawtype, 0.0, 2.0, 0, 0, "Enable Gourad drawmode"); + uiBlockSetCol(block, BUTGREY); + uiDefButS(block, TOG|BIT|0, B_RAD_DRAW, "ShowLim", 1, 0, 10, 10, &rad->flag, 0, 0, 0, 0, "Visualize patch and element limits"); + uiDefButS(block, TOG|BIT|1, B_RAD_DRAW, "Z", 1, 0, 3, 10, &rad->flag, 0, 0, 0, 0, "Draw limits different"); + uiBlockSetCol(block, BUTGREY); + uiDefButS(block, NUM, B_RAD_LIMITS, "ElMax:", 2, 0, 10, 10, &rad->elma, 1.0, 500.0, 0, 0, "Set maximum size of an element"); + uiDefButS(block, NUM, B_RAD_LIMITS, "ElMin:", 2, 0, 10, 10, &rad->elmi, 1.0, 100.0, 0, 0, "Set minimum size of an element"); + uiDefButS(block, NUM, B_RAD_LIMITS, "PaMax:", 3, 0, 10, 10, &rad->pama, 10.0, 1000.0, 0, 0, "Set maximum size of a patch"); + uiDefButS(block, NUM, B_RAD_LIMITS, "PaMin:", 3, 0, 10, 10, &rad->pami, 10.0, 1000.0, 0, 0, "Set minimum size of a patch"); + uiDrawBlock(block); + + sprintf(str, "buttonswin2 %d", curarea->win); + block= uiNewBlock(&curarea->uiblocks, str, UI_EMBOSSX, UI_HELV, curarea->win); + uiAutoBlock(block, 450, 30, 180, 150, UI_BLOCK_ROWS); + + if(flag == RAD_PHASE_PATCHES) uiBlockSetCol(block, BUTSALMON); + else uiBlockSetCol(block, BUTGREY); + uiDefBut(block, BUT, B_RAD_SHOOTE, "Subdiv Shoot Element", 0, 0, 12, 10, NULL, 0, 0, 0, 0, ""); + uiDefBut(block, BUT, B_RAD_SHOOTP, "Subdiv Shoot Patch", 1, 0, 12, 10, NULL, 0, 0, 0, 0, "Detect high energy changes"); + uiBlockSetCol(block, BUTGREY); + uiDefButS(block, NUM, 0, "Max Subdiv Shoot:", 2, 0, 10, 10, &rad->maxsublamp, 1.0, 250.0, 0, 0, "Set the maximum number of shoot patches that are evaluated"); + uiDefButI(block, NUM, 0, "MaxEl:", 3, 0, 10, 10, &rad->maxnode, 1.0, 250000.0, 0, 0, "Set the maximum allowed number of elements"); + uiDefButS(block, NUM, B_RAD_LIMITS, "Hemires:", 4, 0, 10, 10, &rad->hemires, 100.0, 1000.0, 100, 0, "Set the size of a hemicube"); + uiDrawBlock(block); + + sprintf(str, "buttonswin3 %d", curarea->win); + block= uiNewBlock(&curarea->uiblocks, str, UI_EMBOSSX, UI_HELV, curarea->win); + uiAutoBlock(block, 640, 30, 200, 150, UI_BLOCK_ROWS); + + uiBlockSetCol(block, BUTGREY); + uiDefButS(block, NUM, 0, "Max Iterations:", 0, 0, 10, 10, &rad->maxiter, 0.0, 10000.0, 0, 0, "Maximum number of radiosity rounds"); + uiDefButF(block, NUM, 0, "Convergence:", 1, 0, 10, 10, &rad->convergence, 0.0, 1.0, 10, 0, "Set the lower threshold of unshot energy"); + uiDefButS(block, NUM, 0, "SubSh P:", 2, 0, 10, 10, &rad->subshootp, 0.0, 10.0, 0, 0, "Set the number of times the environment is tested to detect pathes"); + uiDefButS(block, NUM, 0, "SubSh E:", 2, 0, 10, 10, &rad->subshoote, 0.0, 10.0, 0, 0, "Set the number of times the environment is tested to detect elements"); + if(flag == RAD_PHASE_PATCHES) uiBlockSetCol(block, BUTSALMON); + uiDefBut(block, BUT, B_RAD_GO, "GO", 3, 0, 10, 15, NULL, 0, 0, 0, 0, "Start the radiosity simulation"); + uiDrawBlock(block); + + sprintf(str, "buttonswin4 %d", curarea->win); + block= uiNewBlock(&curarea->uiblocks, str, UI_EMBOSSX, UI_HELV, curarea->win); + uiAutoBlock(block, 850, 30, 200, 150, UI_BLOCK_ROWS); + + uiBlockSetCol(block, BUTGREY); + uiDefButF(block, NUM, B_RAD_FAC, "Mult:", 0, 0, 50, 17, &rad->radfac, 0.001, 250.0, 100, 0, "Mulitply the energy values"); + uiDefButF(block, NUM, B_RAD_FAC, "Gamma:", 0, 0, 50, 17, &rad->gamma, 0.2, 10.0, 10, 0, "Change the contrast of the energy values"); + if(flag & RAD_PHASE_FACES) uiBlockSetCol(block, BUTSALMON); + else uiBlockSetCol(block, BUTGREY); + uiDefBut(block, BUT, B_RAD_FACEFILT, "FaceFilter", 1, 0, 10, 10, NULL, 0, 0, 0, 0, "Force an extra smoothing"); + if(flag & RAD_PHASE_FACES) uiBlockSetCol(block, BUTSALMON); + else uiBlockSetCol(block, BUTGREY); + uiDefBut(block, BUT, B_RAD_NODELIM, "RemoveDoubles", 2, 0, 30, 10, NULL, 0.0, 50.0, 0, 0, "Join elements which differ less than 'Lim'"); + uiBlockSetCol(block, BUTGREY); + uiDefButS(block, NUM, 0, "Lim:", 2, 0, 10, 10, &rad->nodelim, 0.0, 50.0, 0, 0, "Set the range for removing doubles"); + if(flag & RAD_PHASE_FACES) uiBlockSetCol(block, BUTSALMON); + else uiBlockSetCol(block, BUTGREY); + uiDefBut(block, BUT, B_RAD_NODEFILT, "Element Filter", 3, 0, 10, 10, NULL, 0, 0, 0, 0, "Filter elements to remove aliasing artefacts"); + uiDrawBlock(block); + sprintf(str, "buttonswin5 %d", curarea->win); + block= uiNewBlock(&curarea->uiblocks, str, UI_EMBOSSX, UI_HELV, curarea->win); + uiAutoBlock(block, 1060, 30, 190, 150, UI_BLOCK_ROWS); + + if(flag & RAD_PHASE_PATCHES) uiBlockSetCol(block, BUTSALMON); + else uiBlockSetCol(block, BUTGREY); + uiDefBut(block, BUT, B_RAD_FREE, "Free Radio Data", 0, 0, 10, 10, NULL, 0, 0, 0, 0, "Release all memory used by Radiosity"); + if(flag & RAD_PHASE_FACES) uiBlockSetCol(block, BUTSALMON); + else uiBlockSetCol(block, BUTGREY); + uiDefBut(block, BUT, B_RAD_REPLACE, "Replace Meshes", 1, 0, 10, 10, NULL, 0, 0, 0, 0, "Convert meshes to Mesh objects with vertex colours, changing input-meshes"); + uiDefBut(block, BUT, B_RAD_ADDMESH, "Add new Meshes", 2, 0, 10, 10, NULL, 0, 0, 0, 0, "Convert meshes to Mesh objects with vertex colours, unchanging input-meshes"); + uiDrawBlock(block); + + rad_status_str(str); + cpack(0); + glRasterPos2i(210, 189); + BMF_DrawString(uiBlockGetCurFont(block), str); + } } -/* *************************** MESH ******************************** */ - -#ifdef NAN_DECIMATION +/* *************************** SCRIPT ******************************** */ -static int decimate_count_tria(Object *ob) +static void extend_scriptlink(ScriptLink *slink) { - int tottria; - MFace *mface; - Mesh *me; - int a; + void *stmp, *ftmp; + + if (!slink) return; + + stmp= slink->scripts; + slink->scripts= MEM_mallocN(sizeof(ID*)*(slink->totscript+1), "scriptlistL"); - me= ob->data; + ftmp= slink->flag; + slink->flag= MEM_mallocN(sizeof(short*)*(slink->totscript+1), "scriptlistF"); - /* count number of trias, since decimator doesnt allow quads */ - tottria= 0; - mface= me->mface; - for(a=0; atotface; a++, mface++) { - if(mface->v4) tottria++; - if(mface->v3) tottria++; + if (slink->totscript) { + memcpy(slink->scripts, stmp, sizeof(ID*)*(slink->totscript)); + MEM_freeN(stmp); + + memcpy(slink->flag, ftmp, sizeof(short)*(slink->totscript)); + MEM_freeN(ftmp); } - - return tottria; + + slink->scripts[slink->totscript]= NULL; + slink->flag[slink->totscript]= SCRIPT_FRAMECHANGED; + + slink->totscript++; + + if(slink->actscript<1) slink->actscript=1; } -static void decimate_faces(void) +static void delete_scriptlink(ScriptLink *slink) { - Object *ob; - Mesh *me; - MVert *mvert; - MFace *mface; - LOD_Decimation_Info lod; - float *vb=NULL; - float *vnb=NULL; - int *tib=NULL; - int a, tottria; - - /* we assume the active object being decimated */ - ob= OBACT; - if(ob==NULL || ob->type!=OB_MESH) return; - me= ob->data; - - /* add warning for vertex col and tfaces */ - if(me->tface || me->mcol) { - if(okee("This will remove UV coordinates and vertexcolors")==0) return; - if(me->tface) MEM_freeN(me->tface); - if(me->mcol) MEM_freeN(me->mcol); - me->tface= NULL; - me->mcol= NULL; - } + int i; - /* count number of trias, since decimator doesnt allow quads */ - tottria= decimate_count_tria(ob); - - if(tottria<3) { - error("You must have more than 3 input faces selected."); - return; + if (!slink) return; + + if (slink->totscript>0) { + for (i=slink->actscript-1; itotscript-1; i++) { + slink->flag[i]= slink->flag[i+1]; + slink->scripts[i]= slink->scripts[i+1]; + } + + slink->totscript--; } - /* allocate and init */ - lod.vertex_buffer= MEM_mallocN(3*sizeof(float)*me->totvert, "vertices"); - lod.vertex_normal_buffer= MEM_mallocN(3*sizeof(float)*me->totvert, "normals"); - lod.triangle_index_buffer= MEM_mallocN(3*sizeof(int)*tottria, "trias"); - lod.vertex_num= me->totvert; - lod.face_num= tottria; - - /* fill vertex buffer */ - vb= lod.vertex_buffer; - vnb= lod.vertex_normal_buffer; - mvert= me->mvert; - for(a=0; atotvert; a++, mvert++, vb+=3, vnb+=3) { - VECCOPY(vb, mvert->co); - VECCOPY(vnb, mvert->no); - Normalise(vnb); + + CLAMP(slink->actscript, 1, slink->totscript); + + if (slink->totscript==0) { + if (slink->scripts) MEM_freeN(slink->scripts); + if (slink->flag) MEM_freeN(slink->flag); + + slink->scripts= NULL; + slink->flag= NULL; + slink->totscript= slink->actscript= 0; } +} + +void do_scriptbuts(short event) +{ + Object *ob=NULL; + ScriptLink *script=NULL; + Material *ma; - /* fill index buffer */ - mface= me->mface; - tib= lod.triangle_index_buffer; - for(a=0; atotface; a++, mface++) { - if(mface->v4) { - tib[0]= mface->v1; - tib[1]= mface->v3; - tib[2]= mface->v4; - tib+= 3; - } - if(mface->v3) { - tib[0]= mface->v1; - tib[1]= mface->v2; - tib[2]= mface->v3; - tib+= 3; + switch (event) { + case B_SSCRIPT_ADD: + extend_scriptlink(&G.scene->scriptlink); + break; + case B_SSCRIPT_DEL: + delete_scriptlink(&G.scene->scriptlink); + break; + + case B_SCRIPT_ADD: + case B_SCRIPT_DEL: + ob= OBACT; + + if (ob && G.buts->scriptblock==ID_OB) { + script= &ob->scriptlink; + + } else if (ob && G.buts->scriptblock==ID_MA) { + ma= give_current_material(ob, ob->actcol); + if (ma) script= &ma->scriptlink; + + } else if (ob && G.buts->scriptblock==ID_CA) { + if (ob->type==OB_CAMERA) + script= &((Camera *)ob->data)->scriptlink; + + } else if (ob && G.buts->scriptblock==ID_LA) { + if (ob->type==OB_LAMP) + script= &((Lamp *)ob->data)->scriptlink; + + } else if (G.buts->scriptblock==ID_WO) { + if (G.scene->world) + script= &(G.scene->world->scriptlink); } + + if (event==B_SCRIPT_ADD) extend_scriptlink(script); + else delete_scriptlink(script); + + break; + default: + break; } - if(LOD_LoadMesh(&lod) ) { - if( LOD_PreprocessMesh(&lod) ) { - DispList *dl; - DispListMesh *dlm; - MFaceInt *mfaceint; - - /* we assume the decim_faces tells how much to reduce */ - - while(lod.face_num > decim_faces) { - if( LOD_CollapseEdge(&lod)==0) break; - } + allqueue(REDRAWBUTSSCRIPT, 0); +} - /* ok, put back the stuff in a displist */ - freedisplist(&(ob->disp)); - dl= MEM_callocN(sizeof(DispList), "disp"); - BLI_addtail(&ob->disp, dl); - dl->type= DL_MESH; - dlm=dl->mesh= MEM_callocN(sizeof(DispListMesh), "dispmesh"); - dlm->mvert= MEM_callocN(lod.vertex_num*sizeof(MVert), "mvert"); - dlm->mface= MEM_callocN(lod.face_num*sizeof(MFaceInt), "mface"); - dlm->totvert= lod.vertex_num; - dlm->totface= lod.face_num; - - mvert= dlm->mvert; - vb= lod.vertex_buffer; - for(a=0; aco, vb); - } - - mfaceint= dlm->mface; - tib= lod.triangle_index_buffer; - for(a=0; av1= tib[0]; - mfaceint->v2= tib[1]; - mfaceint->v3= tib[2]; - } +void draw_scriptlink(uiBlock *block, ScriptLink *script, int sx, int sy, int scene) +{ + char str[256]; + + uiBlockSetCol(block, BUTGREY); + + if (script->totscript) { + strcpy(str, "FrameChanged%x 1|"); + strcat(str, "Redraw%x 4|"); + if (scene) { + strcat(str, "OnLoad%x 2"); } - else error("No memory"); - LOD_FreeDecimationData(&lod); + uiDefButS(block, MENU, 1, str, (short)sx, (short)sy, 148, 19, &script->flag[script->actscript-1], 0, 0, 0, 0, "Script links for the Frame changed event"); + + uiDefIDPoinBut(block, test_scriptpoin_but, 1, "", (short)(sx+150),(short)sy, 98, 19, &script->scripts[script->actscript-1], "Name of Script to link"); } - else error("No manifold Mesh"); - - MEM_freeN(lod.vertex_buffer); - MEM_freeN(lod.vertex_normal_buffer); - MEM_freeN(lod.triangle_index_buffer); - - allqueue(REDRAWVIEW3D, 0); -} + sprintf(str,"%d Scr:", script->totscript); + uiDefButS(block, NUM, REDRAWBUTSSCRIPT, str, (short)(sx+250), (short)sy,98,19, &script->actscript, 1, script->totscript, 0, 0, "Total / Active Script link (LeftMouse + Drag to change)"); + uiBlockSetCol(block, BUTSALMON); -static void decimate_cancel(void) -{ - Object *ob; - - ob= OBACT; - if(ob) { - freedisplist(&ob->disp); - makeDispList(ob); - } - allqueue(REDRAWVIEW3D, 0); + if (scene) { + if (script->totscript<32767) + uiDefBut(block, BUT, B_SSCRIPT_ADD, "New", (short)(sx+350), (short)sy, 38, 19, 0, 0, 0, 0, 0, "Add a new Script link"); + if (script->totscript) + uiDefBut(block, BUT, B_SSCRIPT_DEL, "Del", (short)(sx+390), (short)sy, 38, 19, 0, 0, 0, 0, 0, "Delete the current Script link"); + } else { + if (script->totscript<32767) + uiDefBut(block, BUT, B_SCRIPT_ADD, "New", (short)(sx+350), (short)sy, 38, 19, 0, 0, 0, 0, 0, "Add a new Script link"); + if (script->totscript) + uiDefBut(block, BUT, B_SCRIPT_DEL, "Del", (short)(sx+390), (short)sy, 38, 19, 0, 0, 0, 0, 0, "Delete the current Script link"); + } } -static void decimate_apply(void) +void scriptbuts(void) { - Object *ob; - DispList *dl; - DispListMesh *dlm; - Mesh *me; - MFace *mface; - MFaceInt *mfaceint; - int a; - - if(G.obedit) return; + Object *ob=NULL; + ScriptLink *script=NULL; + Material *ma; + uiBlock *block; + char str[64]; ob= OBACT; - if(ob) { - dl= ob->disp.first; - if(dl && dl->mesh) { - dlm= dl->mesh; - me= ob->data; - - // vertices - if(me->mvert) MEM_freeN(me->mvert); - me->mvert= dlm->mvert; - dlm->mvert= NULL; - me->totvert= dlm->totvert; - - // faces - if(me->mface) MEM_freeN(me->mface); - me->mface= MEM_callocN(dlm->totface*sizeof(MFace), "mface"); - me->totface= dlm->totface; - mface= me->mface; - mfaceint= dlm->mface; - for(a=0; atotface; a++, mface++, mfaceint++) { - mface->v1= mfaceint->v1; - mface->v2= mfaceint->v2; - mface->v3= mfaceint->v3; - test_index_mface(mface, 3); - } - - freedisplist(&ob->disp); - - G.obedit= ob; - make_editMesh(); - load_editMesh(); - free_editMesh(); - G.obedit= NULL; - tex_space_mesh(me); - } - else error("Not a decimated Mesh"); - } -} - -#endif -void do_meshbuts(unsigned short event) -{ - Object *ob; - Mesh *me; - float fac; - short randfac; + sprintf(str, "buttonswin %d", curarea->win); + block= uiNewBlock(&curarea->uiblocks, str, UI_EMBOSSX, UI_HELV, curarea->win); - ob= OBACT; - if(ob && ob->type==OB_MESH) { + if (ob && G.buts->scriptblock==ID_OB) { + script= &ob->scriptlink; - me= get_mesh(ob); - if(me==0) return; + } else if (ob && G.buts->scriptblock==ID_MA) { + ma= give_current_material(ob, ob->actcol); + if (ma) script= &ma->scriptlink; - switch(event) { -#ifdef __NLA - case B_AUTOVGROUP: - if (!get_armature(ob->parent)){ - error ("Mesh must be the child of an armature"); - break; - } - /* Verify that there are vertex groups for bones in armature */ - /* Remove selected vertices from all defgroups */ - /* Perform assignment for selected vertices */ + } else if (ob && G.buts->scriptblock==ID_CA) { + if (ob->type==OB_CAMERA) + script= &((Camera *)ob->data)->scriptlink; + + } else if (ob && G.buts->scriptblock==ID_LA) { + if (ob->type==OB_LAMP) + script= &((Lamp *)ob->data)->scriptlink; - allqueue (REDRAWVIEW3D, 1); - break; - case B_NEWVGROUP: - add_defgroup (G.obedit); - scrarea_queue_winredraw(curarea); - break; - case B_DELVGROUP: - del_defgroup (G.obedit); - allqueue (REDRAWVIEW3D, 1); - break; - case B_ASSIGNVGROUP: - assign_verts_defgroup (); - allqueue (REDRAWVIEW3D, 1); - break; - case B_REMOVEVGROUP: - remove_verts_defgroup (0); - allqueue (REDRAWVIEW3D, 1); - break; - case B_SELVGROUP: - sel_verts_defgroup(1); - allqueue (REDRAWVIEW3D, 1); - break; - case B_DESELVGROUP: - sel_verts_defgroup(0); - allqueue (REDRAWVIEW3D, 1); - break; -#endif - case B_DELSTICKY: - - if(me->msticky) MEM_freeN(me->msticky); - me->msticky= 0; - allqueue(REDRAWBUTSEDIT, 0); - break; - case B_MAKESTICKY: - make_sticky(); - break; - case B_MAKEVERTCOL: - make_vertexcol(); - break; - case B_DELVERTCOL: - if(me->mcol) MEM_freeN(me->mcol); - me->mcol= 0; - G.f &= ~G_VERTEXPAINT; - freedisplist(&(ob->disp)); - allqueue(REDRAWBUTSEDIT, 0); - allqueue(REDRAWVIEW3D, 0); - break; + } else if (G.buts->scriptblock==ID_WO) { + if (G.scene->world) + script= &(G.scene->world->scriptlink); + } - case B_MAKE_TFACES: - make_tfaces(me); - allqueue(REDRAWBUTSEDIT, 0); - break; + if (script) draw_scriptlink(block, script, 25, 180, 0); + + /* EVENTS */ + draw_buttons_edge(curarea->win, 540); - case B_DEL_TFACES: - if(me->tface) MEM_freeN(me->tface); - me->tface= 0; - G.f &= ~G_FACESELECT; - allqueue(REDRAWBUTSEDIT, 0); - allqueue(REDRAWVIEW3D, 0); - allqueue(REDRAWIMAGE, 0); - break; - - case B_FLIPNORM: - if(G.obedit) { - flip_editnormals(); - } - else flipnorm_mesh( get_mesh(ob) ); - - allqueue(REDRAWVIEW3D, 0); - break; + draw_scriptlink(block, &G.scene->scriptlink, 600, 180, 1); - case B_DECIM_FACES: - decimate_faces(); - break; - case B_DECIM_CANCEL: - decimate_cancel(); - break; - case B_DECIM_APPLY: - decimate_apply(); - break; + uiDrawBlock(block); +} - case B_SLOWERDRAW: - slowerdraw(); - break; - case B_FASTERDRAW: - fasterdraw(); - break; - } - } +/* *************************** IKA ******************************** */ +/* is this number used elsewhere? */ +/* static int ika_del_number; */ +void do_ikabuts(unsigned short event) +{ + Base *base; + Object *ob; - if(G.obedit==0 || (G.obedit->type!=OB_MESH)) return; + ob= OBACT; switch(event) { - case B_SPIN: - if( select_area(SPACE_VIEW3D)) spin_mesh(step, degr, 0, 0); - break; - case B_SPINDUP: - if( select_area(SPACE_VIEW3D)) spin_mesh(step, degr, 0, 1); - break; - case B_EXTR: - G.f |= G_DISABLE_OK; - if( select_area(SPACE_VIEW3D)) extrude_mesh(); - G.f -= G_DISABLE_OK; - break; - case B_SCREW: - if( select_area(SPACE_VIEW3D)) screw_mesh(step, turn); - break; - case B_EXTREP: - if( select_area(SPACE_VIEW3D)) extrude_repeat_mesh(step, extr_offs); - break; - case B_SPLIT: - G.f |= G_DISABLE_OK; - split_mesh(); - G.f -= G_DISABLE_OK; - break; - case B_REMDOUB: - notice("Removed: %d", removedoublesflag(1, doublimit)); - allqueue(REDRAWVIEW3D, 0); - break; - case B_SUBDIV: - waitcursor(1); - subdivideflag(1, 0.0, editbutflag & B_BEAUTY); - countall(); - waitcursor(0); - allqueue(REDRAWVIEW3D, 0); - break; - case B_FRACSUBDIV: - randfac= 10; - if(button(&randfac, 1, 100, "Rand fac:")==0) return; - waitcursor(1); - fac= -( (float)randfac )/100; - subdivideflag(1, fac, editbutflag & B_BEAUTY); - countall(); - waitcursor(0); - allqueue(REDRAWVIEW3D, 0); - break; - case B_XSORT: - if( select_area(SPACE_VIEW3D)) xsortvert_flag(1); - break; - case B_HASH: - hashvert_flag(1); - break; - case B_TOSPHERE: - vertices_to_sphere(); - break; - case B_VERTEXNOISE: - vertexnoise(); - break; - case B_VERTEXSMOOTH: - vertexsmooth(); + case B_IKASETREF: + base= FIRSTBASE; + while(base) { + if TESTBASELIB(base) { + if(base->object->type==OB_IKA) init_defstate_ika(base->object); + } + base= base->next; + } + break; + case B_IKARECALC: + itterate_ika(ob); break; } - /* WATCH IT: previous events only in editmode! */ -} - -static void verify_vertexgroup_name_func(void *datav, void *data2_unused) -{ - unique_vertexgroup_name((bDeformGroup*)datav, OBACT); } -void meshbuts(void) +void ikabuts(void) { + Ika *ika; Object *ob; - Mesh *me; + Limb *li; + Deform *def; uiBlock *block; - uiBut *but; - float val; - char str[64]; -#ifdef __NLA - int by; - float min; - int defCount; - bDeformGroup *defGroup; -#endif - + int nr, cury, nlimbs; + char str[32]; + ob= OBACT; if(ob==0) return; - + sprintf(str, "editbuttonswin %d", curarea->win); block= uiNewBlock(&curarea->uiblocks, str, UI_EMBOSSX, UI_HELV, curarea->win); - me= get_mesh(ob); - - if(me) { - uiDefButS(block, TOG|BIT|1, REDRAWVIEW3D, "No V.Normal Flip", 143,160,130,18, &me->flag, 0, 0, 0, 0, "Disables flipping of vertexnormals during render"); - uiBlockSetCol(block, BUTGREEN); - uiDefButS(block, TOG|BIT|5, REDRAWVIEW3D, "Auto Smooth", 143,140,130,18, &me->flag, 0, 0, 0, 0, "Treats all faces with angles less than Degr: as 'smooth' during render"); - uiBlockSetCol(block, BUTGREY); - uiDefButS(block, NUM, B_DIFF, "Degr:", 143, 120, 130, 18, &me->smoothresh, 1, 80, 0, 0, "Defines maximum angle between face normals that 'Auto Smooth' will operate on"); - uiBlockSetCol(block, BUTGREEN); - uiDefButS(block, TOG|BIT|7, B_MAKEDISP, "SubSurf", 143,100,130,18, &me->flag, 0, 0, 0, 0, "Treats the active object as a Catmull-Clark Subdivision Surface"); - uiBlockSetCol(block, BUTGREY); - uiDefButS(block, NUM, B_MAKEDISP, "Subdiv:", 143, 80, 100, 18, &me->subdiv, 0, 12, 0, 0, "Defines the level of subdivision to display in real time interactively"); - uiDefButS(block, NUM, B_MAKEDISP, "", 243, 80, 30, 18, &me->subdivr, 0, 12, 0, 0, "Defines the level of subdivision to apply during rendering"); - uiDefButS(block, TOG|BIT|2, REDRAWVIEW3D, "Double Sided", 1090,184,164,19, &me->flag, 0, 0, 0, 0, "Toggles selected faces as doublesided or single-sided"); - - uiBlockSetCol(block, BUTSALMON); - - if(me->msticky) val= 1.0; else val= 0.0; - uiDefBut(block, LABEL, 0, "Sticky", 137,55,70,20, 0, val, 0, 0, 0, ""); - if(me->msticky==0) { - uiDefBut(block, BUT, B_MAKESTICKY, "Make", 210,58,63,19, 0, 0, 0, 0, 0, "Creates Sticky coordinates for the active object from the current camera view background picture"); - } - else uiDefBut(block, BUT, B_DELSTICKY, "Delete", 210,58,63,19, 0, 0, 0, 0, 0, "Deletes Sticky texture coordinates"); - - if(me->mcol) val= 1.0; else val= 0.0; - uiDefBut(block, LABEL, 0, "VertCol", 140,33,70,20, 0, val, 0, 0, 0, ""); - if(me->mcol==0) { - uiDefBut(block, BUT, B_MAKEVERTCOL, "Make", 209,36,64,19, 0, 0, 0, 0, 0, "Enables vertex colour painting on active object"); - } - else uiDefBut(block, BUT, B_DELVERTCOL, "Delete", 209,36,64,19, 0, 0, 0, 0, 0, "Deletes vertex colours on active object"); - - if(me->tface) val= 1.0; else val= 0.0; - uiDefBut(block, LABEL, 0, "TexFace", 142,13,70,20, 0, val, 0, 0, 0, ""); - if(me->tface==0) { - uiDefBut(block, BUT, B_MAKE_TFACES, "Make", 209,14,64,20, 0, 0, 0, 0, 0, "Enables the active object's faces for UV coordinate mapping"); - } - else uiDefBut(block, BUT, B_DEL_TFACES, "Delete", 209,14,64,20, 0, 0, 0, 0, 0, "Deletes UV coordinates for active object's faces"); - - uiBlockSetCol(block, BUTGREY); - - uiDefIDPoinBut(block, test_meshpoin_but, 0, "TexMesh: ", 477,185,249,19, &me->texcomesh, "Enter the name of a Meshblock"); - } - - - /* EDIT */ - - if(me) { -#ifdef NAN_DECIMATION - int tottria= decimate_count_tria(ob); - DispList *dl; - - // wacko, wait for new displist system (ton) - if( (dl=ob->disp.first) && dl->mesh); - else decim_faces= tottria; - - uiBlockSetCol(block, BUTPURPLE); - uiDefButI(block, NUMSLI,B_DECIM_FACES, "Decimator: ", 477,155,249,20, &decim_faces, 4.0, tottria, 10, 10, "Defines the number of triangular faces to decimate the active Mesh object to"); - uiBlockSetCol(block, BUTSALMON); - uiDefBut(block, BUT,B_DECIM_CANCEL, "Cancel", 477,135,124,19, 0, 0, 0, 0, 0, "Restores the Mesh to its original number of faces"); - uiDefBut(block, BUT,B_DECIM_APPLY, "Apply", 602,135,124,19, 0, 0, 0, 0, 0, "Applies the decimation to the active Mesh object"); -#endif - - uiBlockSetCol(block, BUTSALMON); - uiDefBut(block, BUT,B_EXTR,"Extrude", 477,100,249,24, 0, 0, 0, 0, 0, "Converts selected edges to faces and selects the new vertices"); - uiDefBut(block, BUT,B_SPINDUP,"Spin Dupe", 639,75,87,24, 0, 0, 0, 0, 0, "Creates copies of the selected vertices in a circle around the cursor in the indicated viewport"); - uiDefBut(block, BUT,B_SPIN, "Spin", 558,75,78,24, 0, 0, 0, 0, 0, "Extrudes the selected vertices in a circle around the cursor in the indicated viewport"); - uiDefBut(block, BUT,B_SCREW,"Screw", 477,75,79,24, 0, 0, 0, 0, 0, "Activates the screw tool"); // Bish - This could use some more definition - uiDefBut(block, BUT,B_EXTREP, "Extrude Dupe",477,15,128,19, 0, 0, 0, 0, 0, "Creates copies of the selected vertices in a straight line away from the current viewport"); + ika= ob->data; - uiBlockSetCol(block, BUTGREY); - uiDefButS(block, NUM, B_DIFF, "Degr:", 477,55,78,19, °r,10.0,360.0, 0, 0, "Specifies the number of degrees 'Spin' revolves"); - uiDefButS(block, NUM, B_DIFF, "Steps:", 558,55,78,19, &step,1.0,180.0, 0, 0, "Specifies the total number of 'Spin' slices"); - uiDefButS(block, NUM, B_DIFF, "Turns:", 639,55,86,19, &turn,1.0,360.0, 0, 0, "Specifies the number of revolutions the screw turns"); - uiDefButS(block, TOG|BIT|0, B_DIFF, "Clockwise", 639,35,86,19, &editbutflag, 0, 0, 0, 0, "Specifies the direction for 'Screw' and 'Spin'"); - uiDefButS(block, TOG|BIT|1, B_DIFF, "Keep Original", 477,35,156,19, &editbutflag, 0, 0, 0, 0, "Keeps a copy of the original vertices and faces after executing tools"); - uiDefButF(block, NUM, B_DIFF, "Offset:", 608,15,117,19, &extr_offs, 0.01, 10.0, 100, 0, "Sets the distance between each copy for 'Extrude Dupe'"); - } - - by=206; - - uiBlockSetCol(block, BUTGREEN); - uiDefButS(block, TOG|BIT|2, 0, "Beauty", 847,by-=20,94,19, &editbutflag, 0, 0, 0, 0, "Causes 'Subdivide' to split faces in halves instead of quarters"); uiBlockSetCol(block, BUTSALMON); + uiDefBut(block, BUT, B_IKASETREF, "Set Reference",470,180,200,20, 0, 0, 0, 0, 0, ""); - uiDefBut(block, BUT,B_SPLIT,"Split", 847,by-=19,94,18, 0, 0, 0, 0, 0, "Separates selected faces from unselected faces"); - uiDefBut(block, BUT,B_TOSPHERE,"To Sphere", 847,by-=19,94,18, 0, 0, 0, 0, 0, "Moves selected vertices outwards into a spherical shape"); - uiDefBut(block, BUT,B_SUBDIV,"Subdivide", 847,by-=19,94,18, 0, 0, 0, 0, 0, "Splits selected faces into halves or quarters"); - uiDefBut(block, BUT,B_FRACSUBDIV, "Fract Subd",847,by-=19,94,18, 0, 0, 0, 0, 0, "Subdivides selected faces with a random factor"); - - uiDefBut(block, BUT,B_VERTEXNOISE,"Noise", 847,by-=19,94,18, 0, 0, 0, 0, 0, "Use vertex coordinate as texture coordinate"); - uiDefBut(block, BUT,B_VERTEXSMOOTH,"Smooth", 847,by-=19,94,18, 0, 0, 0, 0, 0, "Flattens angles of selected faces"); - uiDefBut(block, BUT,B_XSORT,"Xsort", 847,by-=19,94,18, 0, 0, 0, 0, 0, "Sorts selected vertice data in the X direction"); - uiDefBut(block, BUT,B_HASH,"Hash", 847,by-=19,94,18, 0, 0, 0, 0, 0, "Randomizes selected vertice sequence data"); - + uiBlockSetCol(block, BUTGREEN); + uiDefButS(block, TOG|BIT|1, B_DIFF, "Lock XY Plane", 470,140,200,20, &ika->flag, 0.0, 1.0, 0, 0, "New IK option: allows both X and Y axes to rotate"); uiBlockSetCol(block, BUTGREY); - uiDefButF(block, NUM, B_DIFF, "Limit:", 959,151,100,19, &doublimit, 0.0001, 1.0, 10, 0, "Specifies the max distance 'Rem Doubles' will consider vertices as 'doubled'"); + uiDefButF(block, NUM, B_DIFF, "XY constraint ", 470,120,200,20, &ika->xyconstraint, 0.0, 1.0, 100, 0, "Constrain in radians"); - uiBlockSetCol(block, BUTSALMON); - - uiDefBut(block, BUT,B_REMDOUB,"Rem Doubles", 958,173,101,32, 0, 0, 0, 0, 0, "Removes duplicates from selected vertices"); + uiDefButF(block, NUMSLI, B_DIFF, "Mem ", 470,80,200,20, &ika->mem, 0.0, 1.0, 0, 0, ""); + uiDefButS(block, NUM, B_DIFF, "Iter: ", 470,60,200,20, &ika->iter, 2.0, 16.0, 0, 0, ""); - uiDefBut(block, BUT,B_FLIPNORM,"Flip Normals", 961,55,100,19, 0, 0, 0, 0, 0, "Toggles the direction of the selected face's normals"); - uiDefBut(block, BUT, B_SLOWERDRAW,"SlowerDraw", 961,35,100,19, 0, 0, 0, 0, 0, "Displays the active object with all possible edges shown"); - uiDefBut(block, BUT, B_FASTERDRAW,"FasterDraw", 961,15,100,19, 0, 0, 0, 0, 0, "Displays the active object faster by omitting some edges when drawing"); + uiBlockSetCol(block, BUTGREY); -#ifdef __NLA - - /* Draw Vertex grouping buttons if we're in editmode*/ - if (ob){ - char *s, *menustr; - bDeformGroup *dg; - int index; - - by = 210; - uiBlockSetCol(block, BUTGREY); - uiDefBut(block, LABEL,0,"Vertex Groups", 740,by-=19,93,18, 0, 0, 0, 0, 0, ""); + uiDefBut(block, LABEL, 0, "Limb Weight", 680, 200, 150, 19, 0, 0, 0, 0, 0, ""); + cury= 180; + li= ika->limbbase.first; - defCount=BLI_countlist(&ob->defbase); + nlimbs= BLI_countlist(&ika->limbbase); - if (!defCount) - min=0; - else - min=1; - -#if 0 - sprintf (str, "%d Group:", defCount); - uiDefButS(block, NUM, REDRAWBUTSEDIT, str, 740, by-=22,93,18, &ob->actdef, min, defCount, 0, 0, ""); -#else - s= menustr = MEM_callocN((32 * defCount)+20, "menustr"); + for (nr = 0; nr < nlimbs; nr++) { + sprintf(str, "Limb %d:", nr); + uiDefButF(block, NUM, B_DIFF, str, 680, (short)cury, 150, 19, &li->fac, 0.01, 1.0, 10, 0, ""); + cury-= 20; + li= li->next; + } - for (index = 1, dg = ob->defbase.first; dg; index++, dg=dg->next){ - int cnt= sprintf (s, "%s%%x%d|", dg->name, index); - - if (cnt>0) - s+= cnt; + + + uiDefBut(block, LABEL, 0, "Deform Max Dist", 955, 200, 140, 19, 0, 0, 0, 0, 0, ""); + uiDefBut(block, LABEL, 0, "Deform Weight", 1095, 200, 140, 19, 0, 0, 0, 0, 0, ""); + + + cury= 180; + def= ika->def; + for (nr = 0; nr < ika->totdef; nr++) { + def = ika->def+nr; + if(def->ob) { + if(def->ob->type!=OB_IKA) sprintf(str, "%s :", def->ob->id.name+2); + else sprintf(str, "%s (%d):", def->ob->id.name+2, def->par1); } - by-=22; - if (defCount) - uiDefButS(block, MENU, REDRAWBUTSEDIT, menustr, 740, by,18,18, &ob->actdef, min, defCount, 0, 0, "Browses available vertex groups"); - MEM_freeN (menustr); -#endif - if (ob->actdef){ - defGroup = BLI_findlink(&ob->defbase, ob->actdef-1); - but= uiDefBut(block, TEX,REDRAWBUTSEDIT,"", 758,by,93-18,18, defGroup->name, 0, 32, 0, 0, "Displays current vertex group name. Click to change. (Match bone name for deformation.)"); - uiButSetFunc(but, verify_vertexgroup_name_func, defGroup, NULL); - } - uiDefButF(block, NUM, REDRAWVIEW3D, "Weight:", 740, by-=22, 93, 18, &editbutvweight, 0, 1, 10, 0, "Sets the current vertex group's bone deformation strength"); + uiDefBut(block, LABEL, 0, str, 855, (short)cury, 100, 19, 0, 0.01, 0.0, 0, 0, ""); + uiDefButF(block, NUM, B_DIFF, "", 955, (short)cury, 140, 19, &def->dist, 0.0, 40.0, 100, 0, "Beyond this distance the Limb doesn't influence deformation. '0.0' is global influence."); + uiDefButF(block, NUM, B_DIFF, "", 1095,(short)cury, 140, 19, &def->fac, 0.01, 10.0, 10, 0, ""); + cury-= 20; } - - if (G.obedit && G.obedit==ob){ - - uiBlockSetCol(block, BUTSALMON); -/* uiDefBut(block, BUT,B_AUTOVGROUP,"Auto Weight", 740,by-=22,93,18, 0, 0, 0, 0, 0, "Automatically assigns deformation groups"); */ - uiDefBut(block, BUT,B_NEWVGROUP,"New", 740,by-=22,45,18, 0, 0, 0, 0, 0, "Creates a new vertex group"); - uiDefBut(block, BUT,B_DELVGROUP,"Delete", 788,by,45,18, 0, 0, 0, 0, 0, "Removes the current vertex group"); - - uiBlockSetCol(block, BUTSALMON); - uiDefBut(block, BUT,B_ASSIGNVGROUP,"Assign", 740,by-=22,93,18, 0, 0, 0, 0, 0, "Assigns selected vertices to the current vertex group"); - uiDefBut(block, BUT,B_REMOVEVGROUP,"Remove", 740,by-=22,93,18, 0, 0, 0, 0, 0, "Removes selected vertices from the current vertex group"); - - uiBlockSetCol(block, BUTGREY); - uiDefBut(block, BUT,B_SELVGROUP,"Select", 740,by-=22,93,18, 0, 0, 0, 0, 0, "Selects vertices belonging to the current vertex group"); - uiDefBut(block, BUT,B_DESELVGROUP,"Deselect", 740,by-=22,93,18, 0, 0, 0, 0, 0, "Deselects vertices belonging to the current vertex group"); - + uiDrawBlock(block); } -#endif - uiBlockSetCol(block, BUTGREY); - uiDefButF(block, NUM, REDRAWVIEW3D, "NSize:", 1090, 90, 164, 19, &editbutsize, 0.001, 2.0, 10, 0, "Sets the length to use when displaying face normals"); - uiDefButI(block, TOG|BIT|6, REDRAWVIEW3D, "Draw Normals", 1090,70,164,19, &G.f, 0, 0, 0, 0, "Displays face normals as lines"); - uiDefButI(block, TOG|BIT|7, REDRAWVIEW3D, "Draw Faces", 1090,50,164,19, &G.f, 0, 0, 0, 0, "Displays all faces as shades"); - uiDefButI(block, TOG|BIT|18, REDRAWVIEW3D, "Draw Edges", 1090,30,164,19, &G.f, 0, 0, 0, 0, "Displays selected edges using hilights"); - uiDefButI(block, TOG|BIT|11, 0, "All edges", 1090,10,164,19, &G.f, 0, 0, 0, 0, "Displays all edges in object mode without optimization"); +/* *************************** TEXTURE ******************************** */ - uiDrawBlock(block); -} +Tex *cur_imatex=0; +int prv_win= 0; -// Bish made it to here. (reviewing tooltips) +void load_tex_image(char *str) /* called from fileselect */ +{ + Image *ima=0; + Tex *tex; + + tex= cur_imatex; + if(tex->type==TEX_IMAGE || tex->type==TEX_ENVMAP) { + ima= add_image(str); + if(ima) { + if(tex->ima) { + tex->ima->id.us--; + } + tex->ima= ima; + + free_image_buffers(ima); /* force reading again */ + ima->ok= 1; + } -/* *************************** FONT ******************************** */ + allqueue(REDRAWBUTSTEX, 0); -short give_vfontnr(VFont *vfont) -{ - VFont *vf; - short nr= 1; - - vf= G.main->vfont.first; - while(vf) { - if(vf==vfont) return nr; - nr++; - vf= vf->id.next; + BIF_preview_changed(G.buts); } - return -1; } -VFont *give_vfontpointer(int nr) /* nr= button */ +void load_plugin_tex(char *str) /* called from fileselect */ { - VFont *vf; - short tel= 1; - - vf= G.main->vfont.first; - while(vf) { - if(tel==nr) return vf; - tel++; - vf= vf->id.next; - } - return G.main->vfont.first; + Tex *tex; + + tex= cur_imatex; + if(tex->type!=TEX_PLUGIN) return; + + if(tex->plugin) free_plugin_tex(tex->plugin); + + tex->stype= 0; + tex->plugin= add_plugin_tex(str); + + allqueue(REDRAWBUTSTEX, 0); + BIF_preview_changed(G.buts); } -VFont *exist_vfont(char *str) +int vergcband(const void *a1, const void *a2) { - VFont *vf; + const CBData *x1=a1, *x2=a2; - vf= G.main->vfont.first; - while(vf) { - if(strcmp(vf->name, str)==0) return vf; - vf= vf->id.next; - } + if( x1->pos > x2->pos ) return 1; + else if( x1->pos < x2->pos) return -1; return 0; } -static char *give_vfontbutstr(void) -{ - VFont *vf; - int len= 0; - char *str, di[FILE_MAXDIR], fi[FILE_MAXFILE]; - - vf= G.main->vfont.first; - while(vf) { - strcpy(di, vf->name); - BLI_splitdirstring(di, fi); - len+= strlen(fi)+4; - vf= vf->id.next; - } - - str= MEM_callocN(len+21, "vfontbutstr"); - strcpy(str, "FONTS %t"); - vf= G.main->vfont.first; - while(vf) { - - if(vf->id.us==0) strcat(str, "|0 "); - else strcat(str, "| "); - - strcpy(di, vf->name); - BLI_splitdirstring(di, fi); - - strcat(str, fi); - vf= vf->id.next; - } - return str; -} -void load_buts_vfont(char *name) + +void save_env(char *name) { - VFont *vf; - Curve *cu; + Tex *tex; + char str[FILE_MAXFILE]; - if(OBACT && OBACT->type==OB_FONT) cu= OBACT->data; - else return; + strcpy(str, name); + BLI_convertstringcode(str, G.sce, G.scene->r.cfra); + tex= G.buts->lockpoin; - vf= exist_vfont(name); - if(vf==0) { - vf= load_vfont(name); - if(vf==0) return; - } - else id_us_plus((ID *)vf); - - if(cu->vfont) cu->vfont->id.us--; - cu->vfont= vf; - - text_to_curve(OBACT, 0); - makeDispList(OBACT); - allqueue(REDRAWVIEW3D, 0); - allqueue(REDRAWBUTSEDIT, 0); -} - -void do_fontbuts(unsigned short event) -{ - Curve *cu; - VFont *vf; - Object *ob; - ScrArea *sa; - char str[80]; - - ob= OBACT; - - switch(event) { - case B_MAKEFONT: - text_to_curve(ob, 0); - makeDispList(ob); - allqueue(REDRAWVIEW3D, 0); - break; - case B_TOUPPER: - to_upper(); - break; - case B_LOADFONT: - vf= give_vfontpointer(G.buts->texnr); - if(vf && vf->id.prev!=vf->id.next) strcpy(str, vf->name); - else strcpy(str, U.fontdir); - - sa= closest_bigger_area(); - areawinset(sa->win); - - activate_fileselect(FILE_SPECIAL, "SELECT FONT", str, load_buts_vfont); - - break; - case B_PACKFONT: - if (ob) { - cu= ob->data; - if(cu && cu->vfont) { - if (cu->vfont->packedfile) { - if (G.fileflags & G_AUTOPACK) { - if (okee("Disable AutoPack ?")) { - G.fileflags &= ~G_AUTOPACK; - } - } - - if ((G.fileflags & G_AUTOPACK) == 0) { - if (unpackVFont(cu->vfont, PF_ASK) == RET_OK) { - text_to_curve(ob, 0); - makeDispList(ob); - allqueue(REDRAWVIEW3D, 0); - } - } - } else { - cu->vfont->packedfile = newPackedFile(cu->vfont->name); - } - } - } - allqueue(REDRAWHEADERS, 0); - allqueue(REDRAWBUTSEDIT, 0); - break; - - case B_SETFONT: - if(ob) { - cu= ob->data; - - vf= give_vfontpointer(G.buts->texnr); - if(vf) { - id_us_plus((ID *)vf); - cu->vfont->id.us--; - cu->vfont= vf; - text_to_curve(ob, 0); - makeDispList(ob); - allqueue(REDRAWVIEW3D, 0); - allqueue(REDRAWBUTSEDIT, 0); - } - } - break; - case B_TEXTONCURVE: - if(ob) { - cu= ob->data; - if(cu->textoncurve && cu->textoncurve->type!=OB_CURVE) { - error("Only Curve Objects"); - cu->textoncurve= 0; - allqueue(REDRAWBUTSEDIT, 0); - } - text_to_curve(ob, 0); - makeDispList(ob); + if(tex && GS(tex->id.name)==ID_TE) { + if(tex->env && tex->env->ok && saveover(str)) { + waitcursor(1); + BIF_save_envmap(tex->env, str); + strcpy(G.ima, name); + waitcursor(0); } } + } - - -void fontbuts(void) +void drawcolorband(ColorBand *coba, float x1, float y1, float sizex, float sizey) { - Curve *cu; - uiBlock *block; - char *strp, str[64]; + CBData *cbd; + float v3[2], v1[2], v2[2]; + int a; - if(OBACT==0) return; - - sprintf(str, "editbuttonswin1 %d", curarea->win); - block= uiNewBlock(&curarea->uiblocks, str, UI_EMBOSSX, UI_HELV, curarea->win); - - cu= OBACT->data; - - uiBlockSetCol(block, BUTGREEN); - uiDefButS(block, ROW,B_MAKEFONT, "Left", 484,139,53,18, &cu->spacemode, 0.0,0.0, 0, 0, ""); - uiDefButS(block, ROW,B_MAKEFONT, "Middle", 604,139,61,18, &cu->spacemode, 0.0,1.0, 0, 0, ""); - uiDefButS(block, ROW,B_MAKEFONT, "Right", 540,139,62,18, &cu->spacemode, 0.0,2.0, 0, 0, ""); - uiDefButS(block, ROW,B_MAKEFONT, "Flush", 665,139,61,18, &cu->spacemode, 0.0,3.0, 0, 0, ""); - - uiBlockSetCol(block, BUTGREY); - - uiDefIDPoinBut(block, test_obpoin_but, B_TEXTONCURVE, "TextOnCurve:", 484,115,243,19, &cu->textoncurve, ""); - - uiDefButF(block, NUM,B_MAKEFONT, "Size:", 482,56,121,19, &cu->fsize, 0.1,10.0, 10, 0, ""); - uiDefButF(block, NUM,B_MAKEFONT, "Linedist:", 605,56,121,19, &cu->linedist, 0.0,10.0, 10, 0, ""); - uiDefButF(block, NUM,B_MAKEFONT, "Spacing:", 482,34,121,19, &cu->spacing, 0.0,10.0, 10, 0, ""); - uiDefButF(block, NUM,B_MAKEFONT, "Y offset:", 605,34,121,19, &cu->yof, -50.0,50.0, 10, 0, ""); - uiDefButF(block, NUM,B_MAKEFONT, "Shear:", 482,12,121,19, &cu->shear, -1.0,1.0, 10, 0, ""); - uiDefButF(block, NUM,B_MAKEFONT, "X offset:", 605,12,121,19, &cu->xof, -50.0,50.0, 10, 0, ""); + if(coba==0) return; + + /* outline */ + v1[0]= x1; v1[1]= y1; + glLineWidth((GLfloat)(3)); + cpack(0x0); + glBegin(GL_LINE_LOOP); + glVertex2fv(v1); + v1[0]+= sizex; + glVertex2fv(v1); + v1[1]+= sizey; + glVertex2fv(v1); + v1[0]-= sizex; + glVertex2fv(v1); + glEnd(); + glLineWidth((GLfloat)(1)); - uiDefBut(block, TEX,REDRAWVIEW3D, "Ob Family:", 752,192,164,19, cu->family, 0.0, 20.0, 0, 0, ""); - uiBlockSetCol(block, BUTSALMON); - uiDefBut(block, BUT, B_TOUPPER, "ToUpper", 623,163,103,23, 0, 0, 0, 0, 0, ""); + glShadeModel(GL_SMOOTH); + cbd= coba->data; - uiBlockSetCol(block, BUTGREY); - - G.buts->texnr= give_vfontnr(cu->vfont); + v1[0]= v2[0]= x1; + v1[1]= y1; + v2[1]= y1+sizey; - strp= give_vfontbutstr(); + glBegin(GL_QUAD_STRIP); - uiDefButS(block, MENU, B_SETFONT, strp, 484,191,220,20, &G.buts->texnr, 0, 0, 0, 0, ""); + glColor3fv( &cbd->r ); + glVertex2fv(v1); glVertex2fv(v2); - if (cu->vfont->packedfile) { - packdummy = 1; - } else { - packdummy = 0; + for(a=0; atot; a++, cbd++) { + + v1[0]=v2[0]= x1+ cbd->pos*sizex; + + glColor3fv( &cbd->r ); + glVertex2fv(v1); glVertex2fv(v2); } - uiBlockSetCol(block, BUTYELLOW); - uiDefIconButI(block, TOG|BIT|0, B_PACKFONT, ICON_PACKAGE, 706,191,20,20, &packdummy, 0, 0, 0, 0, "Pack/Unpack this Vectorfont"); + v1[0]=v2[0]= x1+ sizex; + glVertex2fv(v1); glVertex2fv(v2); + + glEnd(); + glShadeModel(GL_FLAT); - MEM_freeN(strp); + /* help lines */ - uiBlockSetCol(block, BUTSALMON); - uiDefBut(block, BUT,B_LOADFONT, "Load Font", 484,163,103,23, 0, 0, 0, 0, 0, ""); + v1[0]= v2[0]=v3[0]= x1; + v1[1]= y1; + v2[1]= y1+0.5*sizey; + v3[1]= y1+sizey; - uiDrawBlock(block); + cbd= coba->data; + glBegin(GL_LINES); + for(a=0; atot; a++, cbd++) { + v1[0]=v2[0]=v3[0]= x1+ cbd->pos*sizex; + + glColor3ub(0, 0, 0); + glVertex2fv(v1); + glVertex2fv(v2); + + if(a==coba->cur) { + glVertex2f(v1[0]-1, v1[1]); + glVertex2f(v2[0]-1, v2[1]); + glVertex2f(v1[0]+1, v1[1]); + glVertex2f(v2[0]+1, v2[1]); + } + + glColor3ub(255, 255, 255); + glVertex2fv(v2); + glVertex2fv(v3); + + if(a==coba->cur) { + glVertex2f(v2[0]-1, v2[1]); + glVertex2f(v3[0]-1, v3[1]); + glVertex2f(v2[0]+1, v2[1]); + glVertex2f(v3[0]+1, v3[1]); + } + } + glEnd(); + + glFlush(); } -/* *************************** CURVE ******************************** */ -void do_curvebuts(unsigned short event) +void do_texbuts(unsigned short event) { - extern Nurb *lastnu; - Object *ob; - Curve *cu; - Nurb *nu; + Tex *tex; + ImBuf *ibuf; + ScrArea *sa; + ID *id; + CBData *cbd; + float dx; + int a, nr; + short mvalo[2], mval[2]; + char *name, str[80]; - ob= OBACT; - if(ob==0) return; + tex= G.buts->lockpoin; - switch(event) { - - case B_CONVERTPOLY: - case B_CONVERTBEZ: - case B_CONVERTBSPL: - case B_CONVERTCARD: - case B_CONVERTNURB: - if(G.obedit) { - setsplinetype(event-B_CONVERTPOLY); - makeDispList(G.obedit); - allqueue(REDRAWVIEW3D, 0); - } - break; - case B_UNIFU: - case B_ENDPU: - case B_BEZU: - case B_UNIFV: - case B_ENDPV: - case B_BEZV: - if(G.obedit) { - nu= editNurb.first; - while(nu) { - if(isNurbsel(nu)) { - if((nu->type & 7)==CU_NURBS) { - if(eventflagu &= 1; - nu->flagu += ((event-B_UNIFU)<<1); - makeknots(nu, 1, nu->flagu>>1); - } - else if(nu->pntsv>1) { - nu->flagv &= 1; - nu->flagv += ((event-B_UNIFV)<<1); - makeknots(nu, 2, nu->flagv>>1); - } - } - } - nu= nu->next; - } - makeDispList(G.obedit); - allqueue(REDRAWVIEW3D, 0); - } + switch(event) { + case B_TEXCHANNEL: + scrarea_queue_headredraw(curarea); + BIF_preview_changed(G.buts); + allqueue(REDRAWBUTSTEX, 0); break; - case B_SETWEIGHT: - if(G.obedit) { - weightflagNurb(1, editbutweight, 0); - makeDispList(G.obedit); - allqueue(REDRAWVIEW3D, 0); - } + case B_TEXTYPE: + if(tex==0) return; + tex->stype= 0; + allqueue(REDRAWBUTSTEX, 0); + BIF_preview_changed(G.buts); break; - case B_SETW1: - editbutweight= 1.0; - scrarea_queue_winredraw(curarea); + case B_DEFTEXVAR: + if(tex==0) return; + default_tex(tex); + allqueue(REDRAWBUTSTEX, 0); + BIF_preview_changed(G.buts); break; - case B_SETW2: - editbutweight= sqrt(2.0)/4.0; - scrarea_queue_winredraw(curarea); + case B_LOADTEXIMA: + case B_LOADTEXIMA1: + if(tex==0) return; + /* globals: temporal store them: we make another area a fileselect */ + cur_imatex= tex; + prv_win= curarea->win; + + sa= closest_bigger_area(); + areawinset(sa->win); + if(tex->ima) name= tex->ima->name; +#ifdef _WIN32 + else { + if (strcmp (U.textudir, "/") == 0) + name= G.sce; + else + name= U.textudir; + } +#else + else name = U.textudir; +#endif + + if(event==B_LOADTEXIMA) + activate_imageselect(FILE_SPECIAL, "SELECT IMAGE", name, load_tex_image); + else + activate_fileselect(FILE_SPECIAL, "SELECT IMAGE", name, load_tex_image); + break; - case B_SETW3: - editbutweight= 0.25; - scrarea_queue_winredraw(curarea); + case B_NAMEIMA: + if(tex==0) return; + if(tex->ima) { + cur_imatex= tex; + prv_win= curarea->win; + + /* name in tex->ima has been changed by button! */ + strcpy(str, tex->ima->name); + if(tex->ima->ibuf) strcpy(tex->ima->name, tex->ima->ibuf->name); + + load_tex_image(str); + } break; - case B_SETW4: - editbutweight= sqrt(0.5); - scrarea_queue_winredraw(curarea); + case B_TEXREDR_PRV: + allqueue(REDRAWBUTSTEX, 0); + BIF_preview_changed(G.buts); break; - case B_SETORDER: - if(G.obedit) { - nu= lastnu; - if(nu && (nu->type & 7)==CU_NURBS ) { - if(nu->orderu>nu->pntsu) { - nu->orderu= nu->pntsu; - scrarea_queue_winredraw(curarea); - } - makeknots(nu, 1, nu->flagu>>1); - if(nu->orderv>nu->pntsv) { - nu->orderv= nu->pntsv; - scrarea_queue_winredraw(curarea); + case B_TEXIMABROWSE: + if(tex) { + id= (ID*) tex->ima; + + if(G.buts->menunr== -2) { + activate_databrowse(id, ID_IM, 0, B_TEXIMABROWSE, &G.buts->menunr, do_texbuts); + } else if (G.buts->menunr>0) { + Image *newima= (Image*) BLI_findlink(&G.main->image, G.buts->menunr-1); + + if (newima && newima!=(Image*) id) { + tex->ima= newima; + id_us_plus((ID*) newima); + if(id) id->us--; + + allqueue(REDRAWBUTSTEX, 0); + BIF_preview_changed(G.buts); } - makeknots(nu, 2, nu->flagv>>1); } - makeDispList(G.obedit); - allqueue(REDRAWVIEW3D, 0); } break; - case B_MAKEDISP: - if(ob->type==OB_FONT) text_to_curve(ob, 0); - makeDispList(ob); - allqueue(REDRAWVIEW3D, 0); - allqueue(REDRAWINFO, 1); /* 1, because header->win==0! */ - break; - - case B_SUBDIVCURVE: - subdivideNurb(); - break; - case B_SPINNURB: - /* bad bad bad!!! use brackets!!! In case you wondered: - {==,!=} goes before & goes before || */ - if( (G.obedit==0) || - (G.obedit->type!=OB_SURF) || - ((G.obedit->lay & G.vd->lay) == 0) ) return; - spinNurb(0, 0); - countall(); - makeDispList(G.obedit); - allqueue(REDRAWVIEW3D, 0); - break; - case B_CU3D: /* allow 3D curve */ - if(G.obedit) { - cu= G.obedit->data; - nu= editNurb.first; - while(nu) { - nu->type &= ~CU_2D; - if((cu->flag & CU_3D)==0) nu->type |= CU_2D; - test2DNurb(nu); - nu= nu->next; - } - } - if(ob->type==OB_CURVE) { - cu= ob->data; - nu= cu->nurb.first; - while(nu) { - nu->type &= ~CU_2D; - if((cu->flag & CU_3D)==0) nu->type |= CU_2D; - test2DNurb(nu); - nu= nu->next; + case B_IMAPTEST: + if(tex) { + if( (tex->imaflag & (TEX_FIELDS+TEX_MIPMAP))== TEX_FIELDS+TEX_MIPMAP ) { + error("Cannot combine fields and mipmap"); + tex->imaflag -= TEX_MIPMAP; + allqueue(REDRAWBUTSTEX, 0); } - } - break; - case B_SETRESOLU: - if(ob->type==OB_CURVE) { - cu= ob->data; - if(ob==G.obedit) nu= editNurb.first; - else nu= cu->nurb.first; - while(nu) { - nu->resolu= cu->resolu; - nu= nu->next; - } - } - else if(ob->type==OB_FONT) text_to_curve(ob, 0); - - makeDispList(ob); - allqueue(REDRAWVIEW3D, 0); - + if(tex->ima && tex->ima->ibuf) { + ibuf= tex->ima->ibuf; + nr= 0; + if( !(tex->imaflag & TEX_FIELDS) && (ibuf->flags & IB_fields) ) nr= 1; + if( (tex->imaflag & TEX_FIELDS) && !(ibuf->flags & IB_fields) ) nr= 1; + if(nr) { + IMB_freeImBuf(ibuf); + tex->ima->ibuf= 0; + tex->ima->ok= 1; + BIF_preview_changed(G.buts); + } + } + } break; - } -} + case B_RELOADIMA: + if(tex && tex->ima) { + // check if there is a newer packedfile -void curvebuts(void) -{ - Object *ob; - Curve *cu; - Nurb *nu; - extern Nurb *lastnu; - uiBlock *block; - short *sp; - char str[64]; - - ob= OBACT; - if(ob==0) return; + if (tex->ima->packedfile) { + PackedFile *pf; + pf = newPackedFile(tex->ima->name); + if (pf) { + freePackedFile(tex->ima->packedfile); + tex->ima->packedfile = pf; + } else { + error("Image not available. Keeping packed image."); + } + } - sprintf(str, "editbuttonswin %d", curarea->win); - block= uiNewBlock(&curarea->uiblocks, str, UI_EMBOSSX, UI_HELV, curarea->win); + IMB_freeImBuf(tex->ima->ibuf); + tex->ima->ibuf= 0; + tex->ima->ok= 1; + allqueue(REDRAWBUTSTEX, 0); + allqueue(REDRAWVIEW3D, 0); + allqueue(REDRAWIMAGE, 0); + BIF_preview_changed(G.buts); + } + break; - cu= ob->data; + case B_TEXSETFRAMES: + if(tex->ima->anim) tex->frames = IMB_anim_get_duration(tex->ima->anim); + allqueue(REDRAWBUTSTEX, 0); + break; - if(ob->type==OB_CURVE || ob->type==OB_SURF) { - uiBlockSetCol(block, BUTSALMON); - uiDefBut(block, LABEL, 0, "Convert", 463,173,72, 18, 0, 0, 0, 0, 0, ""); - uiDefBut(block, BUT,B_CONVERTPOLY,"Poly", 467,152,72, 18, 0, 0, 0, 0, 0, ""); - uiDefBut(block, BUT,B_CONVERTBEZ,"Bezier", 467,132,72, 18, 0, 0, 0, 0, 0, ""); - uiDefBut(block, BUT,B_CONVERTBSPL,"Bspline", 467,112,72, 18, 0, 0, 0, 0, 0, ""); - uiDefBut(block, BUT,B_CONVERTCARD,"Cardinal", 467,92,72, 18, 0, 0, 0, 0, 0, ""); - uiDefBut(block, BUT,B_CONVERTNURB,"Nurb", 467,72,72, 18, 0, 0, 0, 0, 0, ""); - - uiDefBut(block, LABEL, 0, "Make Knots",562,173,102, 18, 0, 0, 0, 0, 0, ""); - uiDefBut(block, BUT,B_UNIFU,"Uniform U", 565,152,102, 18, 0, 0, 0, 0, 0, ""); - uiDefBut(block, BUT,B_ENDPU,"Endpoint U", 565,132,102, 18, 0, 0, 0, 0, 0, ""); - uiDefBut(block, BUT,B_BEZU,"Bezier U", 565,112,102, 18, 0, 0, 0, 0, 0, ""); - uiDefBut(block, BUT,B_UNIFV,"V", 670,152,50, 18, 0, 0, 0, 0, 0, ""); - uiDefBut(block, BUT,B_ENDPV,"V", 670,132,50, 18, 0, 0, 0, 0, 0, ""); - uiDefBut(block, BUT,B_BEZV,"V", 670,112,50, 18, 0, 0, 0, 0, 0, ""); - - uiDefBut(block, BUT,B_SETWEIGHT,"Set Weight", 465,11,95,49, 0, 0, 0, 0, 0, ""); - uiBlockSetCol(block, BUTGREY); - uiDefButF(block, NUM,0,"Weight:", 564,36,102,22, &editbutweight, 0.01, 10.0, 10, 0, ""); - uiDefBut(block, BUT,B_SETW1,"1.0", 669,36,50,22, 0, 0, 0, 0, 0, ""); - uiDefBut(block, BUT,B_SETW2,"sqrt(2)/4", 564,11,57,20, 0, 0, 0, 0, 0, ""); - uiDefBut(block, BUT,B_SETW3,"0.25", 621,11,43,20, 0, 0, 0, 0, 0, ""); - uiDefBut(block, BUT,B_SETW4,"sqrt(0.5)", 664,11,57,20, 0, 0, 0, 0, 0, ""); - - if(ob==G.obedit) { - nu= lastnu; - if(nu==NULL) nu= editNurb.first; - if(nu) { - sp= &(nu->orderu); - uiDefButS(block, NUM, B_SETORDER, "Order U:", 565,91,102, 18, sp, 2.0, 6.0, 0, 0, ""); - sp= &(nu->orderv); - uiDefButS(block, NUM, B_SETORDER, "V:", 670,91,50, 18, sp, 2.0, 6.0, 0, 0, ""); - sp= &(nu->resolu); - uiDefButS(block, NUM, B_MAKEDISP, "Resol U:", 565,70,102, 18, sp, 1.0, 128.0, 0, 0, ""); - sp= &(nu->resolv); - uiDefButS(block, NUM, B_MAKEDISP, "V:", 670,70,50, 18, sp, 1.0, 128.0, 0, 0, ""); + case B_PACKIMA: + if(tex && tex->ima) { + if (tex->ima->packedfile) { + if (G.fileflags & G_AUTOPACK) { + if (okee("Disable AutoPack ?")) { + G.fileflags &= ~G_AUTOPACK; + } + } + + if ((G.fileflags & G_AUTOPACK) == 0) { + unpackImage(tex->ima, PF_ASK); + } + } else { + if (tex->ima->ibuf && (tex->ima->ibuf->userflags & IB_BITMAPDIRTY)) { + error("Can't pack painted image. Save image from Image window first."); + } else { + tex->ima->packedfile = newPackedFile(tex->ima->name); + } } + allqueue(REDRAWBUTSTEX, 0); + allqueue(REDRAWHEADERS, 0); } + break; + case B_LOADPLUGIN: + if(tex==0) return; - uiBlockSetCol(block, BUTSALMON); - uiDefBut(block, BUT, B_SUBDIVCURVE, "Subdivide", 1092,105,165,20, 0, 0, 0, 0, 0, ""); - } - - if(ob->type==OB_SURF) { - uiDefBut(block, BUT, B_SPINNURB, "Spin", 808,92,101,36, 0, 0, 0, 0, 0, ""); - - uiBlockSetCol(block, BUTGREY); - uiDefButS(block, TOG|BIT|5, 0, "UV Orco", 143,160,130,18, &cu->flag, 0, 0, 0, 0, ""); - uiDefButS(block, TOG|BIT|6, REDRAWVIEW3D, "No Puno Flip", 143,140,130,18, &cu->flag, 0, 0, 0, 0, ""); - } - else { - - uiBlockSetCol(block, BUTGREY); - uiDefButS(block, TOG|BIT|5, 0, "UV Orco", 143,160,130,18, &cu->flag, 0, 0, 0, 0, ""); - - uiDefButS(block, NUM, B_MAKEDISP, "DefResolU:", 752,163,132,21, &cu->resolu, 1.0, 128.0, 0, 0, ""); - uiBlockSetCol(block, BUTSALMON); - uiDefBut(block, BUT, B_SETRESOLU, "Set", 887,163,29,21, 0, 0, 0, 0, 0, ""); - - uiBlockSetCol(block, BUTGREY); - uiDefButS(block, NUM, B_MAKEDISP, "BevResol:", 753,30,163,18, &cu->bevresol, 0.0, 10.0, 0, 0, ""); - - uiDefIDPoinBut(block, test_obcurpoin_but, B_MAKEDISP, "BevOb:", 753,10,163,18, &cu->bevobj, ""); - uiDefButF(block, NUM, B_MAKEDISP, "Width:", 753,90,163,18, &cu->width, 0.0, 2.0, 1, 0, ""); - uiDefButF(block, NUM, B_MAKEDISP, "Ext1:", 753,70,163,18, &cu->ext1, 0.0, 5.0, 10, 0, ""); - uiDefButF(block, NUM, B_MAKEDISP, "Ext2:", 753,50,163,18, &cu->ext2, 0.0, 2.0, 1, 0, ""); - uiBlockSetCol(block, BUTBLUE); - if(ob->type==OB_FONT) { - uiDefButS(block, TOG|BIT|1, B_MAKEDISP, "Front", 833,130,79,18, &cu->flag, 0, 0, 0, 0, ""); - uiDefButS(block, TOG|BIT|2, B_MAKEDISP, "Back", 753,130,76,18, &cu->flag, 0, 0, 0, 0, ""); - } + /* globals: store temporal: we make another area a fileselect */ + cur_imatex= tex; + prv_win= curarea->win; + + sa= closest_bigger_area(); + areawinset(sa->win); + if(tex->plugin) strcpy(str, tex->plugin->name); else { - uiDefButS(block, TOG|BIT|0, B_CU3D, "3D", 867,130,47,18, &cu->flag, 0, 0, 0, 0, ""); - uiDefButS(block, TOG|BIT|1, B_MAKEDISP, "Front", 810,130,55,18, &cu->flag, 0, 0, 0, 0, ""); - uiDefButS(block, TOG|BIT|2, B_MAKEDISP, "Back", 753,130,53,18, &cu->flag, 0, 0, 0, 0, ""); + strcpy(str, U.plugtexdir); } - uiBlockSetCol(block, BUTGREY); - } - - uiDefButF(block, NUM, REDRAWVIEW3D, "NSize:", 1090, 80, 164, 19, &editbutsize, 0.001, 1.0, 10, 0, ""); - - uiDrawBlock(block); -} - - -/* *************************** CAMERA ******************************** */ - - -void camerabuts(void) -{ - Camera *cam; - Object *ob; - uiBlock *block; - float grid=0.0; - char str[64]; - - if(G.vd) grid= G.vd->grid; - if(grid<1.0) grid= 1.0; - - ob= OBACT; - if(ob==0) return; + activate_fileselect(FILE_SPECIAL, "SELECT PLUGIN", str, load_plugin_tex); + + break; - sprintf(str, "editbuttonswin %d", curarea->win); - block= uiNewBlock(&curarea->uiblocks, str, UI_EMBOSSX, UI_HELV, curarea->win); + case B_NAMEPLUGIN: + if(tex==0 || tex->plugin==0) return; + strcpy(str, tex->plugin->name); + free_plugin_tex(tex->plugin); + tex->stype= 0; + tex->plugin= add_plugin_tex(str); + allqueue(REDRAWBUTSTEX, 0); + BIF_preview_changed(G.buts); + break; - cam= ob->data; - uiDefButF(block, NUM,REDRAWVIEW3D, "Lens:", 470,178,160,20, &cam->lens, 1.0, 250.0, 100, 0, "Specify the lens of the camera"); - uiDefButF(block, NUM,REDRAWVIEW3D, "ClipSta:", 470,147,160,20, &cam->clipsta, 0.001*grid, 100.0*grid, 10, 0, "Specify the startvalue of the the field of view"); - uiDefButF(block, NUM,REDRAWVIEW3D, "ClipEnd:", 470,125,160,20, &cam->clipend, 1.0, 5000.0*grid, 100, 0, "Specify the endvalue of the the field of view"); - uiDefButF(block, NUM,REDRAWVIEW3D, "DrawSize:", 470,90,160,20, &cam->drawsize, 0.1*grid, 10.0, 10, 0, "Specify the drawsize of the camera"); - - uiBlockSetCol(block, BUTGREEN); - uiDefButS(block, TOG, REDRAWVIEW3D, "Ortho", 470,49,61,40, &cam->type, 0, 0, 0, 0, "Render orthogonally"); - - uiDefButS(block, TOG|BIT|0,REDRAWVIEW3D, "ShowLimits", 533,69,97,20, &cam->flag, 0, 0, 0, 0, "Draw the field of view"); - uiDefButS(block, TOG|BIT|1,REDRAWVIEW3D, "Show Mist", 533,49,97,20, &cam->flag, 0, 0, 0, 0, "Draw a line that indicates the mist area"); + case B_COLORBAND: + if(tex==0) return; + if(tex->coba==0) tex->coba= add_colorband(); + allqueue(REDRAWBUTSTEX, 0); + BIF_preview_changed(G.buts); + break; - if(G.special1 & G_HOLO) { - uiBlockSetCol(block, BUTGREY); - if(cam->netend==0.0) cam->netend= EFRA; - uiDefButF(block, NUM, REDRAWVIEW3D, "Anim len", 670,80,100,20, &cam->netend, 1.0, 2500.0, 0, 0, ""); - uiDefButF(block, NUM, REDRAWVIEW3D, "Path len:", 670,160,100,20, &cam->hololen, 0.1, 25.0, 10, 0, ""); - uiDefButF(block, NUM, REDRAWVIEW3D, "Shear fac:", 670,140,100,20, &cam->hololen1, 0.1, 5.0, 10, 0, ""); - uiBlockSetCol(block, BUTGREEN); - uiDefButS(block, TOG|BIT|4, REDRAWVIEW3D, "Holo 1", 670,120,100,20, &cam->flag, 0.0, 0.0, 0, 0, ""); - uiDefButS(block, TOG|BIT|5, REDRAWVIEW3D, "Holo 2", 670,100,100,20, &cam->flag, 0.0, 0.0, 0, 0, ""); + case B_ADDCOLORBAND: + if(tex==0 || tex->coba==0) return; - } - uiDrawBlock(block); -} + if(tex->coba->tot < MAXCOLORBAND-1) tex->coba->tot++; + tex->coba->cur= tex->coba->tot-1; + + do_texbuts(B_CALCCBAND); + + break; -/* *************************** FACE/PAINT *************************** */ + case B_DELCOLORBAND: + if(tex==0 || tex->coba==0 || tex->coba->tot<2) return; + + for(a=tex->coba->cur; acoba->tot; a++) { + tex->coba->data[a]= tex->coba->data[a+1]; + } + if(tex->coba->cur) tex->coba->cur--; + tex->coba->tot--; -void do_fpaintbuts(unsigned short event) -{ - Mesh *me; - Object *ob; - extern TFace *lasttface; /* caches info on tface bookkeeping ?*/ - - ob= OBACT; - if(ob==0) return; + allqueue(REDRAWBUTSTEX, 0); + BIF_preview_changed(G.buts); + break; - switch(event) { + case B_CALCCBAND: + case B_CALCCBAND2: + if(tex==0 || tex->coba==0 || tex->coba->tot<2) return; + + for(a=0; acoba->tot; a++) tex->coba->data[a].cur= a; + qsort(tex->coba->data, tex->coba->tot, sizeof(CBData), vergcband); + for(a=0; acoba->tot; a++) { + if(tex->coba->data[a].cur==tex->coba->cur) { + if(tex->coba->cur!=a) addqueue(curarea->win, REDRAW, 0); /* button cur */ + tex->coba->cur= a; + break; + } + } + if(event==B_CALCCBAND2) return; + + allqueue(REDRAWBUTSTEX, 0); + BIF_preview_changed(G.buts); - case B_VPGAMMA: - vpaint_dogamma(); break; - case B_COPY_TF_MODE: - case B_COPY_TF_UV: - case B_COPY_TF_COL: - case B_COPY_TF_TEX: - me= get_mesh(ob); - if(me && me->tface) { -/* extern TFace *lasttface; */ - TFace *tface= me->tface; - int a= me->totface; - - set_lasttface(); - if(lasttface) { - - while(a--) { - if(tface!=lasttface && (tface->flag & TF_SELECT)) { - if(event==B_COPY_TF_MODE) { - tface->mode= lasttface->mode; - tface->transp= lasttface->transp; - } - else if(event==B_COPY_TF_UV) { - memcpy(tface->uv, lasttface->uv, sizeof(tface->uv)); - tface->tpage= lasttface->tpage; - tface->tile= lasttface->tile; - - if(lasttface->mode & TF_TILES) tface->mode |= TF_TILES; - else tface->mode &= ~TF_TILES; - - } - else if(event==B_COPY_TF_TEX) { - tface->tpage= lasttface->tpage; - tface->tile= lasttface->tile; + + case B_DOCOLORBAND: + if(tex==0 || tex->coba==0) return; + + cbd= tex->coba->data + tex->coba->cur; + uiGetMouse(mywinget(), mvalo); - if(lasttface->mode & TF_TILES) tface->mode |= TF_TILES; - else tface->mode &= ~TF_TILES; - } - else if(event==B_COPY_TF_COL) memcpy(tface->col, lasttface->col, sizeof(tface->col)); - } - tface++; - } + while(get_mbut() & L_MOUSE) { + uiGetMouse(mywinget(), mval); + if(mval[0]!=mvalo[0]) { + dx= mval[0]-mvalo[0]; + dx/= 345.0; + cbd->pos+= dx; + CLAMP(cbd->pos, 0.0, 1.0); + + glDrawBuffer(GL_FRONT); + drawcolorband(tex->coba, 923,81,345,20); + /* uiSetButs(B_CALCCBAND, B_CALCCBAND); */ + glDrawBuffer(GL_BACK); + + do_texbuts(B_CALCCBAND2); + cbd= tex->coba->data + tex->coba->cur; /* because qsort */ + + mvalo[0]= mval[0]; } - do_shared_vertexcol(me); - allqueue(REDRAWVIEW3D, 0); - allqueue(REDRAWIMAGE, 0); + BIF_wait_for_statechange(); } - break; - case B_SET_VCOL: - clear_vpaint_selectedfaces(); - break; - case B_REDR_3D_IMA: - allqueue(REDRAWVIEW3D, 0); - allqueue(REDRAWIMAGE, 0); - break; - case B_ASSIGNMESH: + allqueue(REDRAWBUTSTEX, 0); + BIF_preview_changed(G.buts); - test_object_materials(ob->data); - allqueue(REDRAWVIEW3D, 0); - allqueue(REDRAWBUTSGAME, 0); break; - - case B_TFACE_HALO: - set_lasttface(); - if(lasttface) { - lasttface->mode &= ~TF_BILLBOARD2; - allqueue(REDRAWBUTSGAME, 0); + + case B_REDRAWCBAND: + glDrawBuffer(GL_FRONT); + drawcolorband(tex->coba, 923,81,345,20); + glDrawBuffer(GL_BACK); + BIF_preview_changed(G.buts); + break; + + case B_ENV_DELETE: + if(tex->env) { + RE_free_envmap(tex->env); + tex->env= 0; + allqueue(REDRAWBUTSTEX, 0); + BIF_preview_changed(G.buts); } break; - - case B_TFACE_BILLB: - set_lasttface(); - if(lasttface) { - lasttface->mode &= ~TF_BILLBOARD; - allqueue(REDRAWBUTSGAME, 0); + case B_ENV_FREE: + if(tex->env) { + RE_free_envmapdata(tex->env); + allqueue(REDRAWBUTSTEX, 0); + BIF_preview_changed(G.buts); } break; - } -} + case B_ENV_FREE_ALL: + tex= G.main->tex.first; + while(tex) { + if(tex->id.us && tex->type==TEX_ENVMAP) { + if(tex->env) { + if(tex->env->stype!=ENV_LOAD) RE_free_envmapdata(tex->env); + } + } + tex= tex->id.next; + } + allqueue(REDRAWBUTSTEX, 0); + BIF_preview_changed(G.buts); + break; + case B_ENV_SAVE: + if(tex->env && tex->env->ok) { + sa= closest_bigger_area(); + areawinset(sa->win); + save_image_filesel_str(str); + activate_fileselect(FILE_SPECIAL, str, G.ima, save_env); + } + break; + case B_ENV_OB: + if(tex->env && tex->env->object) { + BIF_preview_changed(G.buts); + if ELEM(tex->env->object->type, OB_CAMERA, OB_LAMP) { + error("Camera or Lamp not allowed"); + tex->env->object= 0; + } + } + break; + + default: + if(event>=B_PLUGBUT && event<=B_PLUGBUT+23) { + PluginTex *pit= tex->plugin; + if(pit && pit->callback) { + pit->callback(event - B_PLUGBUT); + BIF_preview_changed(G.buts); + } + } + } +} + +static void test_idbutton_cb(void *namev, void *arg2_unused) +{ + char *name= namev; + test_idbutton(name+2); +} -void fpaintbuts(void) +void texbuts(void) { -/* extern VPaint Gvp; already in the top of the file */ Object *ob; + Material *ma=0; + World *wrld=0; + Lamp *la=0; + ID *id = NULL; + MTex *mtex = NULL; + Tex *tex; + VarStruct *varstr; + PluginTex *pit; + CBData *cbd; + EnvMap *env; uiBlock *block; - char str[32]; + uiBut *but; + int a, xco, yco, loos, dx, dy, ok; + char str[30], *strp; - ob= OBACT; - if(ob==0) return; - sprintf(str, "buttonswin %d", curarea->win); block= uiNewBlock(&curarea->uiblocks, str, UI_EMBOSSX, UI_HELV, curarea->win); - /* VPAINT BUTTONS */ - uiBlockSetCol(block, BUTGREY); - - if (G.f & G_VERTEXPAINT) { - uiDefBut(block, LABEL, 0, "Vertex Paint", 1037,180,194,18, 0, 0, 0, 0, 0, ""); - } else if (G.f & G_TEXTUREPAINT) { - uiDefBut(block, LABEL, 0, "Texture Paint", 1037,180,194,18, 0, 0, 0, 0, 0, ""); - } - - uiDefButF(block, NUMSLI, 0, "R ", 979,160,194,19, &Gvp.r, 0.0, 1.0, B_VPCOLSLI, 0, "The amount of red used for painting"); - uiDefButF(block, NUMSLI, 0, "G ", 979,140,194,19, &Gvp.g, 0.0, 1.0, B_VPCOLSLI, 0, "The amount of green used for painting"); - uiDefButF(block, NUMSLI, 0, "B ", 979,120,194,19, &Gvp.b, 0.0, 1.0, B_VPCOLSLI, 0, "The amount of blue used for painting"); - uiDefButF(block, NUMSLI, 0, "Opacity ", 979,100,194,19, &Gvp.a, 0.0, 1.0, 0, 0, "The amount of pressure on the brush"); - uiDefButF(block, NUMSLI, 0, "Size ", 979,80,194,19, &Gvp.size, 2.0, 64.0, 0, 0, "The size of the brush"); - - uiDefButF(block, COL, B_VPCOLSLI, "", 1176,100,28,80, &(Gvp.r), 0, 0, 0, 0, ""); - - uiDefButS(block, ROW, B_DIFF, "Mix", 1212,160,63,19, &Gvp.mode, 1.0, 0.0, 0, 0, "Mix the vertex colours"); - uiDefButS(block, ROW, B_DIFF, "Add", 1212,140,63,19, &Gvp.mode, 1.0, 1.0, 0, 0, "Add the vertex colour"); - uiDefButS(block, ROW, B_DIFF, "Sub", 1212, 120,63,19, &Gvp.mode, 1.0, 2.0, 0, 0, "Subtract from the vertex colour"); - uiDefButS(block, ROW, B_DIFF, "Mul", 1212, 100,63,19, &Gvp.mode, 1.0, 3.0, 0, 0, "Multiply the vertex colour"); - uiDefButS(block, ROW, B_DIFF, "Filter", 1212, 80,63,19, &Gvp.mode, 1.0, 4.0, 0, 0, "Mix the colours with an alpha factor"); - - uiBlockSetCol(block, BUTGREEN); - uiDefButS(block, TOG|BIT|1, 0, "Area", 980,50,80,19, &Gvp.flag, 0, 0, 0, 0, "Set the area the brush covers"); - uiDefButS(block, TOG|BIT|2, 0, "Soft", 1061,50,112,19, &Gvp.flag, 0, 0, 0, 0, "Use a soft brush"); - uiDefButS(block, TOG|BIT|3, 0, "Normals", 1174,50,102,19, &Gvp.flag, 0, 0, 0, 0, "Use vertex normal for painting"); - uiBlockSetCol(block, BUTSALMON); - uiDefBut(block, BUT, B_VPGAMMA, "Set", 980,30,80,19, 0, 0, 0, 0, 0, "Apply Mul and Gamma to vertex colours"); + + uiDefButC(block, ROW, B_TEXREDR_PRV, "Mat", 200,172,40,20, &G.buts->texfrom, 3.0, 0.0, 0, 0, "Display the texture of the active material"); + uiDefButC(block, ROW, B_TEXREDR_PRV, "World", 240,172,52,20, &G.buts->texfrom, 3.0, 1.0, 0, 0, "Display the texture of the world block"); + uiDefButC(block, ROW, B_TEXREDR_PRV, "Lamp", 292,172,46,20, &G.buts->texfrom, 3.0, 2.0, 0, 0, "Display the texture of the lamp"); uiBlockSetCol(block, BUTGREY); - uiDefButF(block, NUM, B_DIFF, "Mul:", 1061,30,112,19, &Gvp.mul, 0.1, 50.0, 10, 0, "Set the number to multiply vertex colours with"); - uiDefButF(block, NUM, B_DIFF, "Gamma:", 1174,30,102,19, &Gvp.gamma, 0.1, 5.0, 10, 0, "Change the clarity of the vertex colours"); - uiDefBut(block, LABEL, 0, "Face Select", 600,180,194,18, 0, 0, 0, 0, 0, ""); - if(G.f & G_FACESELECT) { - extern TFace *lasttface; + ok= 0; + + if(G.buts->texfrom==0) { + ob= OBACT; + if(ob) { + id= ob->data; + if(id) { + ma= give_current_material(ob, ob->actcol); + if(ma) ok= 1; + } + } - set_lasttface(); - if(lasttface) { - - uiBlockSetCol(block, BUTGREEN); - uiDefButS(block, TOG|BIT|2, B_REDR_3D_IMA, "Tex", 600,160,60,19, &lasttface->mode, 0, 0, 0, 0, "Render face with texture"); - uiDefButS(block, TOG|BIT|7, B_REDR_3D_IMA, "Tiles", 660,160,60,19, &lasttface->mode, 0, 0, 0, 0, "Use tilemode for face"); - uiDefButS(block, TOG|BIT|4, REDRAWVIEW3D, "Light", 720,160,60,19, &lasttface->mode, 0, 0, 0, 0, "Use light for face"); - uiDefButS(block, TOG|BIT|10, REDRAWVIEW3D, "Invisible",780,160,60,19, &lasttface->mode, 0, 0, 0, 0, "Make face invisible"); - uiDefButS(block, TOG|BIT|0, REDRAWVIEW3D, "Collision", 840,160,60,19, &lasttface->mode, 0, 0, 0, 0, "Use face for collision detection"); - - uiDefButS(block, TOG|BIT|6, REDRAWVIEW3D, "Shared", 600,140,60,19, &lasttface->mode, 0, 0, 0, 0, "Blend vertex colours across face when vertices are shared"); - uiDefButS(block, TOG|BIT|9, REDRAWVIEW3D, "Twoside", 660,140,60,19, &lasttface->mode, 0, 0, 0, 0, "Render face twosided"); - uiDefButS(block, TOG|BIT|11, REDRAWVIEW3D, "ObColor",720,140,60,19, &lasttface->mode, 0, 0, 0, 0, "Use ObColor instead of vertex colours"); - - uiDefButS(block, TOG|BIT|8, B_TFACE_HALO, "Halo", 600,120,60,19, &lasttface->mode, 0, 0, 0, 0, "Screen aligned billboard"); - uiDefButS(block, TOG|BIT|12, B_TFACE_BILLB, "Billboard",660,120,60,19, &lasttface->mode, 0, 0, 0, 0, "Billboard with Z-axis constraint"); - uiDefButS(block, TOG|BIT|13, REDRAWVIEW3D, "Shadow", 720,120,60,19, &lasttface->mode, 0, 0, 0, 0, "Face is used for shadow"); - uiDefButS(block, TOG|BIT|14, REDRAWVIEW3D, "Text", 780,120,60,19, &lasttface->mode, 0, 0, 0, 0, "Enable bitmap text on face"); - - uiBlockSetCol(block, BUTPURPLE); - uiDefButC(block, ROW, REDRAWVIEW3D, "Opaque", 600,100,60,19, &lasttface->transp, 2.0, 0.0, 0, 0, "Render colour of textured face as colour"); - uiDefButC(block, ROW, REDRAWVIEW3D, "Add", 660,100,60,19, &lasttface->transp, 2.0, 1.0, 0, 0, "Render face transparent and add colour of face"); - uiDefButC(block, ROW, REDRAWVIEW3D, "Alpha", 720,100,60,19, &lasttface->transp, 2.0, 2.0, 0, 0, "Render polygon transparent, depending on alpha channel of the texture"); - /* uiDefButC(block, ROW, REDRAWVIEW3D, "Sub", 780,100,60,19, &lasttface->transp, 2.0, 3.0, 0, 0); ,""*/ - + } + else if(G.buts->texfrom==1) { + wrld= G.scene->world; + if(wrld) { + id= (ID *)wrld; + ok= 1; } } - uiBlockSetCol(block, BUTSALMON); - if(G.f & G_FACESELECT) { - uiDefBut(block, BUT, B_SET_VCOL, "Set VertCol", 859,37,103,28, 0, 0, 0, 0, 0, "Set Vertex colour of selection to current (Shift+K)"); - + else if(G.buts->texfrom==2) { + ob= OBACT; + if(ob) { + if(ob->type==OB_LAMP) { + la= ob->data; + id= (ID *)la; + ok= 1; + } + } } - uiDefBut(block, BUT, B_COPY_TF_MODE, "Copy DrawMode", 650,7,117,28, 0, 0, 0, 0, 0, "Copy the drawmode"); - uiDefBut(block, BUT, B_COPY_TF_UV, "Copy UV+tex", 771,7,85,28, 0, 0, 0, 0, 0, "Copy UV information and textures"); - uiDefBut(block, BUT, B_COPY_TF_COL, "Copy VertCol", 859,7,103,28, 0, 0, 0, 0, 0, "Copy vertex colours"); - - uiDrawBlock(block); -} - -/* *************************** RADIO ******************************** */ - -void do_radiobuts(short event) -{ - Radio *rad; - int phase; - phase= rad_phase(); - rad= G.scene->radio; + if(ok==0) { + uiDrawBlock(block); + return; + } - switch(event) { - case B_RAD_ADD: - add_radio(); - allqueue(REDRAWBUTSRADIO, 0); - allqueue(REDRAWVIEW3D, 0); - break; - case B_RAD_DELETE: - delete_radio(); - allqueue(REDRAWBUTSRADIO, 0); - allqueue(REDRAWVIEW3D, 0); - break; - case B_RAD_FREE: - freeAllRad(); - allqueue(REDRAWBUTSRADIO, 0); - allqueue(REDRAWVIEW3D, 0); - break; - case B_RAD_COLLECT: - rad_collect_meshes(); - allqueue(REDRAWBUTSRADIO, 0); - allqueue(REDRAWVIEW3D, 0); - break; - case B_RAD_INIT: - if(phase==RAD_PHASE_PATCHES) { - rad_limit_subdivide(); - allqueue(REDRAWBUTSRADIO, 0); - allqueue(REDRAWVIEW3D, 0); - } - break; - case B_RAD_SHOOTP: - if(phase==RAD_PHASE_PATCHES) { - waitcursor(1); - rad_subdivshootpatch(); - allqueue(REDRAWBUTSRADIO, 0); - allqueue(REDRAWVIEW3D, 0); - waitcursor(0); - } - break; - case B_RAD_SHOOTE: - if(phase==RAD_PHASE_PATCHES) { - waitcursor(1); - rad_subdivshootelem(); - allqueue(REDRAWBUTSRADIO, 0); - allqueue(REDRAWVIEW3D, 0); - waitcursor(0); - } - break; - case B_RAD_GO: - if(phase==RAD_PHASE_PATCHES) { - waitcursor(1); - rad_go(); - waitcursor(0); - allqueue(REDRAWBUTSRADIO, 0); - allqueue(REDRAWVIEW3D, 0); - } - break; - case B_RAD_LIMITS: - rad_setlimits(); - allqueue(REDRAWVIEW3D, 0); - allqueue(REDRAWBUTSRADIO, 0); - break; - case B_RAD_FAC: - set_radglobal(); - if(phase & RAD_PHASE_FACES) make_face_tab(); - else make_node_display(); - allqueue(REDRAWVIEW3D, 0); - break; - case B_RAD_NODELIM: - if(phase & RAD_PHASE_FACES) { - set_radglobal(); - removeEqualNodes(rad->nodelim); - make_face_tab(); - allqueue(REDRAWVIEW3D, 0); - allqueue(REDRAWBUTSRADIO, 0); + uiSetButLock(id->lib!=0, "Can't edit library data"); + + /* CHANNELS */ + yco= 140; + for(a= 0; a<8; a++) { + if(G.buts->texfrom==0) mtex= ma->mtex[a]; + else if(G.buts->texfrom==1) mtex= wrld->mtex[a]; + else if(G.buts->texfrom==2) mtex= la->mtex[a]; + + if(mtex && mtex->tex) splitIDname(mtex->tex->id.name+2, str, &loos); + else strcpy(str, ""); + str[14]= 0; + if(G.buts->texfrom==0) { + uiDefButC(block, ROW, B_TEXCHANNEL, str, 200,(short)yco,140,18, &(ma->texact), 0.0, (float)a, 0, 0, "Linked channel"); } - break; - case B_RAD_NODEFILT: - if(phase & RAD_PHASE_FACES) { - set_radglobal(); - filterNodes(); - make_face_tab(); - allqueue(REDRAWVIEW3D, 0); + else if(G.buts->texfrom==1) { + uiDefButS(block, ROW, B_TEXCHANNEL, str, 200,(short)yco,140,18, &(wrld->texact), 0.0, (float)a, 0, 0, ""); + if(a==5) break; } - break; - case B_RAD_FACEFILT: - if(phase & RAD_PHASE_FACES) { - filterFaces(); - allqueue(REDRAWVIEW3D, 0); + else if(G.buts->texfrom==2) { + uiDefButS(block, ROW, B_TEXCHANNEL, str, 200,(short)yco,140,18, &(la->texact), 0.0, (float)a, 0, 0, ""); + if(a==5) break; } - break; - case B_RAD_DRAW: - set_radglobal(); - allqueue(REDRAWVIEW3D, 0); - break; - case B_RAD_ADDMESH: - if(phase & RAD_PHASE_FACES) rad_addmesh(); - allqueue(REDRAWVIEW3D, 0); - break; - case B_RAD_REPLACE: - if(phase & RAD_PHASE_FACES) rad_replacemesh(); - allqueue(REDRAWVIEW3D, 0); - break; - } - -} - - -void radiobuts(void) -{ - Radio *rad; - uiBlock *block; - int flag; - char str[128]; - - rad= G.scene->radio; - if(rad==0) { - add_radio(); - rad= G.scene->radio; + yco-= 19; } - sprintf(str, "buttonswin %d", curarea->win); - block= uiNewBlock(&curarea->uiblocks, str, UI_EMBOSSX, UI_HELV, curarea->win); - - flag= rad_phase(); - - if(flag & RAD_PHASE_PATCHES) { - uiBlockSetCol(block, BUTSALMON); - uiDefBut(block, BUT, B_RAD_INIT, "Limit Subdivide", 10, 70, 190, 40, NULL, 0, 0, 0, 0, "Subdivide patches"); + if(G.buts->texfrom==0) { + but= uiDefBut(block, TEX, B_IDNAME, "MA:", 200,195,140,20, ma->id.name+2, 0.0, 18.0, 0, 0, "Name of the datablock"); + uiButSetFunc(but, test_idbutton_cb, ma->id.name, NULL); + mtex= ma->mtex[ ma->texact ]; + } + else if(G.buts->texfrom==1) { + but= uiDefBut(block, TEX, B_IDNAME, "WO:", 200,195,140,20, wrld->id.name+2, 0.0, 18.0, 0, 0, "Name of the datablock"); + uiButSetFunc(but, test_idbutton_cb, wrld->id.name, NULL); + mtex= wrld->mtex[ wrld->texact ]; + } + else if(G.buts->texfrom==2) { + but= uiDefBut(block, TEX, B_IDNAME, "LA:", 200,195,140,20, la->id.name+2, 0.0, 18.0, 0, 0, "Name of the datablock"); + uiButSetFunc(but, test_idbutton_cb, la->id.name, NULL); + mtex= la->mtex[ la->texact ]; } - if(flag & RAD_PHASE_PATCHES) uiBlockSetCol(block, BUTPURPLE); - else uiBlockSetCol(block, BUTSALMON); - uiDefBut(block, BUT, B_RAD_COLLECT, "Collect Meshes", 10, 30, 190, 40, NULL, 0, 0, 0, 0, "Convert selected and visible meshes to patches"); - uiDrawBlock(block); - if(flag==0) { + if(mtex && mtex->tex) { + tex= mtex->tex; + + uiSetButLock(tex->id.lib!=0, "Can't edit library data"); + xco= 275; + uiDefButS(block, ROW, B_TEXTYPE, texstr[0], (short)(xco+=75), 195, 75, 20, &tex->type, 1.0, 0.0, 0, 0, "Default"); + uiDefButS(block, ROW, B_TEXTYPE, texstr[TEX_IMAGE],(short)(xco+=75), 195, 75, 20, &tex->type, 1.0, (float)TEX_IMAGE, 0, 0, "Use image texture"); + uiDefButS(block, ROW, B_TEXTYPE, texstr[TEX_ENVMAP], (short)(xco+=75), 195, 75, 20, &tex->type, 1.0, (float)TEX_ENVMAP, 0, 0, "Use environment maps"); + if(tex->plugin && tex->plugin->doit) strp= tex->plugin->pname; else strp= texstr[TEX_PLUGIN]; + uiDefButS(block, ROW, B_TEXTYPE, strp, (short)(xco+=75), 195, 75, 20, &tex->type, 1.0, (float)TEX_PLUGIN, 0, 0, "Use plugin"); + uiDefButS(block, ROW, B_TEXTYPE, texstr[TEX_CLOUDS], (short)(xco+=75), 195, 75, 20, &tex->type, 1.0, (float)TEX_CLOUDS, 0, 0, "Use clouds texture"); + uiDefButS(block, ROW, B_TEXTYPE, texstr[TEX_WOOD], (short)(xco+=75), 195, 75, 20, &tex->type, 1.0, (float)TEX_WOOD, 0, 0, "Use wood texture"); + uiDefButS(block, ROW, B_TEXTYPE, texstr[TEX_MARBLE], (short)(xco+=75), 195, 75, 20, &tex->type, 1.0, (float)TEX_MARBLE, 0, 0, "Use marble texture"); + uiDefButS(block, ROW, B_TEXTYPE, texstr[TEX_MAGIC], (short)(xco+=75), 195, 75, 20, &tex->type, 1.0, (float)TEX_MAGIC, 0, 0, "Use magic texture"); + uiDefButS(block, ROW, B_TEXTYPE, texstr[TEX_BLEND], (short)(xco+=75), 195, 75, 20, &tex->type, 1.0, (float)TEX_BLEND, 0, 0, "Use blend texture"); + uiDefButS(block, ROW, B_TEXTYPE, texstr[TEX_STUCCI], (short)(xco+=75), 195, 75, 20, &tex->type, 1.0, (float)TEX_STUCCI, 0, 0, "Use strucci texture"); + uiDefButS(block, ROW, B_TEXTYPE, texstr[TEX_NOISE], (short)(xco+=75), 195, 75, 20, &tex->type, 1.0, (float)TEX_NOISE, 0, 0, "Use noise texture"); + + /* TYPES */ + uiBlockSetCol(block, BUTGREEN); + switch(tex->type) { + case TEX_CLOUDS: + uiDefButS(block, ROW, B_MATPRV, "Default", 350, 170, 75, 18, &tex->stype, 2.0, 0.0, 0, 0, "Use standard noise"); + uiDefButS(block, ROW, B_MATPRV, "Color", 425, 170, 75, 18, &tex->stype, 2.0, 1.0, 0, 0, "Let Noise give RGB value"); + uiBlockSetCol(block, BUTGREY); + uiDefButF(block, NUM, B_MATPRV, "NoiseSize :", 350, 110, 150, 19, &tex->noisesize, 0.0001, 2.0, 10, 0, "Set the dimension of the noise table"); + uiDefButS(block, NUM, B_MATPRV, "NoiseDepth:", 350, 90, 150, 19, &tex->noisedepth, 0.0, 6.0, 0, 0, "Set the depth of the cloud calculation"); + uiBlockSetCol(block, BUTGREEN); + uiDefButS(block, ROW, B_MATPRV, "Soft noise", 350, 40, 100, 19, &tex->noisetype, 12.0, 0.0, 0, 0, "Use soft noise"); + uiDefButS(block, ROW, B_MATPRV, "Hard noise", 450, 40, 100, 19, &tex->noisetype, 12.0, 1.0, 0, 0, "Use hard noise"); + break; - sprintf(str, "buttonswin1 %d", curarea->win); - block= uiNewBlock(&curarea->uiblocks, str, UI_EMBOSSX, UI_HELV, curarea->win); - uiAutoBlock(block, 210, 30, 230, 150, UI_BLOCK_ROWS); - uiBlockSetCol(block, BUTGREY); - uiDefButS(block, NUM, B_RAD_LIMITS, "Hemires:", 0, 0, 10, 10, &rad->hemires, 100.0, 1000.0, 100, 0, "Set the size of a hemicube"); - uiDefButS(block, NUM, 0, "Max Iterations:", 1, 0, 10, 10, &rad->maxiter, 0.0, 10000.0, 0, 0, "Maximum number of radiosity rounds"); - uiDefButF(block, NUM, B_RAD_FAC, "Mult:", 2, 0, 50, 10, &rad->radfac, 0.001, 250.0, 100, 0, "Mulitply the energy values"); - uiDefButF(block, NUM, B_RAD_FAC, "Gamma:", 2, 0, 50, 10, &rad->gamma, 0.2, 10.0, 10, 0, "Change the contrast of the energy values"); - uiDefButF(block, NUM, 0, "Convergence:", 3, 0, 10, 10, &rad->convergence, 0.0, 1.0, 10, 0, "Set the lower threshold of unshot energy"); - uiDrawBlock(block); - } - else { + case TEX_WOOD: + uiDefButS(block, ROW, B_MATPRV, "Bands", 350, 170, 75, 18, &tex->stype, 2.0, 0.0, 0, 0, "Use standard wood texture"); + uiDefButS(block, ROW, B_MATPRV, "Rings", 425, 170, 75, 18, &tex->stype, 2.0, 1.0, 0, 0, "Use wood rings"); + uiDefButS(block, ROW, B_MATPRV, "BandNoise", 500, 170, 75, 18, &tex->stype, 2.0, 2.0, 0, 0, "Add noise to standard wood"); + uiDefButS(block, ROW, B_MATPRV, "RingNoise", 575, 170, 75, 18, &tex->stype, 2.0, 3.0, 0, 0, "Add noise to rings"); + uiBlockSetCol(block, BUTGREY); + uiDefButF(block, NUM, B_MATPRV, "NoiseSize :", 350, 110, 150, 19, &tex->noisesize, 0.0001, 2.0, 10, 0, "Set the dimension of the noise table"); + uiDefButF(block, NUM, B_MATPRV, "Turbulence:", 350, 90, 150, 19, &tex->turbul, 0.0, 200.0, 10, 0, "Set the turbulence of the bandnoise and ringnoise types"); + uiBlockSetCol(block, BUTGREEN); + uiDefButS(block, ROW, B_MATPRV, "Soft noise", 350, 40, 100, 19, &tex->noisetype, 12.0, 0.0, 0, 0, "Use soft noise"); + uiDefButS(block, ROW, B_MATPRV, "Hard noise", 450, 40, 100, 19, &tex->noisetype, 12.0, 1.0, 0, 0, "Use hard noise"); + break; + case TEX_MARBLE: + uiDefButS(block, ROW, B_MATPRV, "Soft", 350, 170, 75, 18, &tex->stype, 2.0, 0.0, 0, 0, "Use soft marble"); + uiDefButS(block, ROW, B_MATPRV, "Sharp", 425, 170, 75, 18, &tex->stype, 2.0, 1.0, 0, 0, "Use more clearly defined marble"); + uiDefButS(block, ROW, B_MATPRV, "Sharper", 500, 170, 75, 18, &tex->stype, 2.0, 2.0, 0, 0, "Use very clear defined marble"); + uiBlockSetCol(block, BUTGREY); + uiDefButF(block, NUM, B_MATPRV, "NoiseSize :", 350, 110, 150, 19, &tex->noisesize, 0.0001, 2.0, 10, 0, "Set the dimension of the noise table"); + uiDefButS(block, NUM, B_MATPRV, "NoiseDepth:", 350, 90, 150, 19, &tex->noisedepth, 0.0, 6.0, 0, 0, "Set the depth of the marble calculation"); + uiDefButF(block, NUM, B_MATPRV, "Turbulence:", 350, 70, 150, 19, &tex->turbul, 0.0, 200.0, 10, 0, "Set the turbulence of the sine bands"); + uiBlockSetCol(block, BUTGREEN); + uiDefButS(block, ROW, B_MATPRV, "Soft noise", 350, 40, 100, 19, &tex->noisetype, 12.0, 0.0, 0, 0, "Use soft noise"); + uiDefButS(block, ROW, B_MATPRV, "Hard noise", 450, 40, 100, 19, &tex->noisetype, 12.0, 1.0, 0, 0, "Use hard noise"); + break; - sprintf(str, "buttonswin1 %d", curarea->win); - block= uiNewBlock(&curarea->uiblocks, str, UI_EMBOSSX, UI_HELV, curarea->win); - uiAutoBlock(block, 210, 30, 230, 150, UI_BLOCK_ROWS); - - uiBlockSetCol(block, BUTGREEN); - uiDefButS(block, ROW, B_RAD_DRAW, "Wire", 0, 0, 10, 10, &rad->drawtype, 0.0, 0.0, 0, 0, "Enable wireframe drawmode"); - uiDefButS(block, ROW, B_RAD_DRAW, "Solid", 0, 0, 10, 10, &rad->drawtype, 0.0, 1.0, 0, 0, "Enable solid drawmode"); - uiDefButS(block, ROW, B_RAD_DRAW, "Gour", 0, 0, 10, 10, &rad->drawtype, 0.0, 2.0, 0, 0, "Enable Gourad drawmode"); - uiBlockSetCol(block, BUTGREY); - uiDefButS(block, TOG|BIT|0, B_RAD_DRAW, "ShowLim", 1, 0, 10, 10, &rad->flag, 0, 0, 0, 0, "Visualize patch and element limits"); - uiDefButS(block, TOG|BIT|1, B_RAD_DRAW, "Z", 1, 0, 3, 10, &rad->flag, 0, 0, 0, 0, "Draw limits different"); - uiBlockSetCol(block, BUTGREY); - uiDefButS(block, NUM, B_RAD_LIMITS, "ElMax:", 2, 0, 10, 10, &rad->elma, 1.0, 500.0, 0, 0, "Set maximum size of an element"); - uiDefButS(block, NUM, B_RAD_LIMITS, "ElMin:", 2, 0, 10, 10, &rad->elmi, 1.0, 100.0, 0, 0, "Set minimum size of an element"); - uiDefButS(block, NUM, B_RAD_LIMITS, "PaMax:", 3, 0, 10, 10, &rad->pama, 10.0, 1000.0, 0, 0, "Set maximum size of a patch"); - uiDefButS(block, NUM, B_RAD_LIMITS, "PaMin:", 3, 0, 10, 10, &rad->pami, 10.0, 1000.0, 0, 0, "Set minimum size of a patch"); - uiDrawBlock(block); - - sprintf(str, "buttonswin2 %d", curarea->win); - block= uiNewBlock(&curarea->uiblocks, str, UI_EMBOSSX, UI_HELV, curarea->win); - uiAutoBlock(block, 450, 30, 180, 150, UI_BLOCK_ROWS); - - if(flag == RAD_PHASE_PATCHES) uiBlockSetCol(block, BUTSALMON); - else uiBlockSetCol(block, BUTGREY); - uiDefBut(block, BUT, B_RAD_SHOOTE, "Subdiv Shoot Element", 0, 0, 12, 10, NULL, 0, 0, 0, 0, ""); - uiDefBut(block, BUT, B_RAD_SHOOTP, "Subdiv Shoot Patch", 1, 0, 12, 10, NULL, 0, 0, 0, 0, "Detect high energy changes"); - uiBlockSetCol(block, BUTGREY); - uiDefButS(block, NUM, 0, "Max Subdiv Shoot:", 2, 0, 10, 10, &rad->maxsublamp, 1.0, 250.0, 0, 0, "Set the maximum number of shoot patches that are evaluated"); - uiDefButI(block, NUM, 0, "MaxEl:", 3, 0, 10, 10, &rad->maxnode, 1.0, 250000.0, 0, 0, "Set the maximum allowed number of elements"); - uiDefButS(block, NUM, B_RAD_LIMITS, "Hemires:", 4, 0, 10, 10, &rad->hemires, 100.0, 1000.0, 100, 0, "Set the size of a hemicube"); - uiDrawBlock(block); + case TEX_MAGIC: + uiBlockSetCol(block, BUTGREY); + uiDefButF(block, NUM, B_MATPRV, "Size :", 350, 110, 150, 19, &tex->noisesize, 0.0001, 2.0, 10, 0, "Set the dimension of the pattern"); + uiDefButS(block, NUM, B_MATPRV, "Depth:", 350, 90, 150, 19, &tex->noisedepth, 0.0, 10.0, 0, 0, "Set the depth of the pattern"); + uiDefButF(block, NUM, B_MATPRV, "Turbulence:", 350, 70, 150, 19, &tex->turbul, 0.0, 200.0, 10, 0, "Set the strength of the pattern"); + break; + + case TEX_BLEND: + uiDefButS(block, ROW, B_MATPRV, "Lin", 350, 170, 75, 18, &tex->stype, 2.0, 0.0, 0, 0, "Use a linear progresion"); + uiDefButS(block, ROW, B_MATPRV, "Quad", 425, 170, 75, 18, &tex->stype, 2.0, 1.0, 0, 0, "Use a quadratic progression"); + uiDefButS(block, ROW, B_MATPRV, "Ease", 500, 170, 75, 18, &tex->stype, 2.0, 2.0, 0, 0, ""); + uiDefButS(block, ROW, B_MATPRV, "Diag", 575, 170, 75, 18, &tex->stype, 2.0, 3.0, 0, 0, "Use a diagonal progression"); + uiDefButS(block, ROW, B_MATPRV, "Sphere", 650, 170, 75, 18, &tex->stype, 2.0, 4.0, 0, 0, "Use progression with the shape of a sphere"); + uiDefButS(block, ROW, B_MATPRV, "Halo", 725, 170, 75, 18, &tex->stype, 2.0, 5.0, 0, 0, "Use a quadratic progression with the shape of a sphere"); + + uiDefButS(block, TOG|BIT|1, B_MATPRV, "Flip XY", 350, 130, 75, 18, &tex->flag, 0, 0, 0, 0, "Flip the direction of the progression a quarter turn"); + break; + + case TEX_STUCCI: + uiDefButS(block, ROW, B_MATPRV, "Plastic", 350, 170, 75, 18, &tex->stype, 2.0, 0.0, 0, 0, "Use standard stucci"); + uiDefButS(block, ROW, B_MATPRV, "Wall In", 425, 170, 75, 18, &tex->stype, 2.0, 1.0, 0, 0, "Set start value"); + uiDefButS(block, ROW, B_MATPRV, "Wall Out", 500, 170, 75, 18, &tex->stype, 2.0, 2.0, 0, 0, "Set end value"); + uiBlockSetCol(block, BUTGREY); + uiDefButF(block, NUM, B_MATPRV, "NoiseSize :", 350, 110, 150, 19, &tex->noisesize, 0.0001, 2.0, 10, 0, "Set the dimension of the noise table"); + uiDefButF(block, NUM, B_MATPRV, "Turbulence:", 350, 90, 150, 19, &tex->turbul, 0.0, 200.0, 10, 0, "Set the depth of the stucci"); + uiBlockSetCol(block, BUTGREEN); + uiDefButS(block, ROW, B_MATPRV, "Soft noise", 350, 40, 100, 19, &tex->noisetype, 12.0, 0.0, 0, 0, "Use soft noise"); + uiDefButS(block, ROW, B_MATPRV, "Hard noise", 450, 40, 100, 19, &tex->noisetype, 12.0, 1.0, 0, 0, "Use hard noise"); + + break; + + case TEX_NOISE: + break; + + case TEX_IMAGE: + + break; + } - sprintf(str, "buttonswin3 %d", curarea->win); - block= uiNewBlock(&curarea->uiblocks, str, UI_EMBOSSX, UI_HELV, curarea->win); - uiAutoBlock(block, 640, 30, 200, 150, UI_BLOCK_ROWS); + uiBlockSetCol(block, BUTSALMON); + uiDefBut(block, BUT, B_DEFTEXVAR, "Default Vars", 1180,169,93,47, 0, 0, 0, 0, 0, "Return to standard values"); uiBlockSetCol(block, BUTGREY); - uiDefButS(block, NUM, 0, "Max Iterations:", 0, 0, 10, 10, &rad->maxiter, 0.0, 10000.0, 0, 0, "Maximum number of radiosity rounds"); - uiDefButF(block, NUM, 0, "Convergence:", 1, 0, 10, 10, &rad->convergence, 0.0, 1.0, 10, 0, "Set the lower threshold of unshot energy"); - uiDefButS(block, NUM, 0, "SubSh P:", 2, 0, 10, 10, &rad->subshootp, 0.0, 10.0, 0, 0, "Set the number of times the environment is tested to detect pathes"); - uiDefButS(block, NUM, 0, "SubSh E:", 2, 0, 10, 10, &rad->subshoote, 0.0, 10.0, 0, 0, "Set the number of times the environment is tested to detect elements"); - if(flag == RAD_PHASE_PATCHES) uiBlockSetCol(block, BUTSALMON); - uiDefBut(block, BUT, B_RAD_GO, "GO", 3, 0, 10, 15, NULL, 0, 0, 0, 0, "Start the radiosity simulation"); - uiDrawBlock(block); - - sprintf(str, "buttonswin4 %d", curarea->win); - block= uiNewBlock(&curarea->uiblocks, str, UI_EMBOSSX, UI_HELV, curarea->win); - uiAutoBlock(block, 850, 30, 200, 150, UI_BLOCK_ROWS); + /* SPECIFIC */ + if(tex->type==TEX_IMAGE) { + uiDefButF(block, NUM, B_REDR, "MinX ", 350,30,140,19, &tex->cropxmin, -10.0, 10.0, 10, 0, "Set minimum X value for cropping"); + uiDefButF(block, NUM, B_REDR, "MaxX ", 350,10,140,19, &tex->cropxmax, -10.0, 10.0, 10, 0, "Set maximum X value for cropping"); + uiDefButF(block, NUM, B_REDR, "MinY ", 494,30,140,19, &tex->cropymin, -10.0, 10.0, 10, 0, "Set minimum Y value for cropping"); + uiDefButF(block, NUM, B_REDR, "MaxY ", 494,10,140,19, &tex->cropymax, -10.0, 10.0, 10, 0, "Set maximum Y value for cropping"); - uiBlockSetCol(block, BUTGREY); - uiDefButF(block, NUM, B_RAD_FAC, "Mult:", 0, 0, 50, 17, &rad->radfac, 0.001, 250.0, 100, 0, "Mulitply the energy values"); - uiDefButF(block, NUM, B_RAD_FAC, "Gamma:", 0, 0, 50, 17, &rad->gamma, 0.2, 10.0, 10, 0, "Change the contrast of the energy values"); - if(flag & RAD_PHASE_FACES) uiBlockSetCol(block, BUTSALMON); - else uiBlockSetCol(block, BUTGREY); - uiDefBut(block, BUT, B_RAD_FACEFILT, "FaceFilter", 1, 0, 10, 10, NULL, 0, 0, 0, 0, "Force an extra smoothing"); - if(flag & RAD_PHASE_FACES) uiBlockSetCol(block, BUTSALMON); - else uiBlockSetCol(block, BUTGREY); - uiDefBut(block, BUT, B_RAD_NODELIM, "RemoveDoubles", 2, 0, 30, 10, NULL, 0.0, 50.0, 0, 0, "Join elements which differ less than 'Lim'"); - uiBlockSetCol(block, BUTGREY); - uiDefButS(block, NUM, 0, "Lim:", 2, 0, 10, 10, &rad->nodelim, 0.0, 50.0, 0, 0, "Set the range for removing doubles"); - if(flag & RAD_PHASE_FACES) uiBlockSetCol(block, BUTSALMON); - else uiBlockSetCol(block, BUTGREY); - uiDefBut(block, BUT, B_RAD_NODEFILT, "Element Filter", 3, 0, 10, 10, NULL, 0, 0, 0, 0, "Filter elements to remove aliasing artefacts"); - uiDrawBlock(block); - sprintf(str, "buttonswin5 %d", curarea->win); - block= uiNewBlock(&curarea->uiblocks, str, UI_EMBOSSX, UI_HELV, curarea->win); - uiAutoBlock(block, 1060, 30, 190, 150, UI_BLOCK_ROWS); + uiDefButS(block, ROW, 0, "Extend", 350,85,69,19, &tex->extend, 4.0, 1.0, 0, 0, "Extend the colour of the edge"); + uiDefButS(block, ROW, 0, "Clip", 421,85,59,19, &tex->extend, 4.0, 2.0, 0, 0, "Return alpha 0.0 outside image"); + uiDefButS(block, ROW, 0, "Repeat", 565,85,68,19, &tex->extend, 4.0, 3.0, 0, 0, "Repeat image horizontally and vertically"); + uiDefButS(block, ROW, 0, "ClipCube", 482,85,82,19, &tex->extend, 4.0, 4.0, 0, 0, "Return alpha 0.0 outside cubeshaped area around image"); - if(flag & RAD_PHASE_PATCHES) uiBlockSetCol(block, BUTSALMON); - else uiBlockSetCol(block, BUTGREY); - uiDefBut(block, BUT, B_RAD_FREE, "Free Radio Data", 0, 0, 10, 10, NULL, 0, 0, 0, 0, "Release all memory used by Radiosity"); - if(flag & RAD_PHASE_FACES) uiBlockSetCol(block, BUTSALMON); - else uiBlockSetCol(block, BUTGREY); - uiDefBut(block, BUT, B_RAD_REPLACE, "Replace Meshes", 1, 0, 10, 10, NULL, 0, 0, 0, 0, "Convert meshes to Mesh objects with vertex colours, changing input-meshes"); - uiDefBut(block, BUT, B_RAD_ADDMESH, "Add new Meshes", 2, 0, 10, 10, NULL, 0, 0, 0, 0, "Convert meshes to Mesh objects with vertex colours, unchanging input-meshes"); - uiDrawBlock(block); - - rad_status_str(str); - cpack(0); - glRasterPos2i(210, 189); - BMF_DrawString(uiBlockGetCurFont(block), str); - } -} - - -/* *************************** MBALL ******************************** */ - -void do_mballbuts(unsigned short event) -{ - switch(event) { - case B_RECALCMBALL: - makeDispList(OBACT); - allqueue(REDRAWVIEW3D, 0); - break; - } -} - -void mballbuts(void) -{ - extern MetaElem *lastelem; - MetaBall *mb; - Object *ob; - uiBlock *block; - char str[64]; + uiDefButF(block, NUM, B_MATPRV, "Filter :", 352,109,135,19, &tex->filtersize, 0.1, 25.0, 0, 0, "Set the filter size used by mipmap and interpol"); + + uiDefButS(block, NUM, B_MATPRV, "Xrepeat:", 350,60,140,19, &tex->xrepeat, 1.0, 512.0, 0, 0, "Set the degree of repetition in the X direction"); + uiDefButS(block, NUM, B_MATPRV, "Yrepeat:", 494,60,140,19, &tex->yrepeat, 1.0, 512.0, 0, 0, "Set the degree of repetition in the Y direction"); + + uiDefButS(block, NUM, B_MATPRV, "Frames :", 642,110,150,19, &tex->frames, 0.0, 18000.0, 0, 0, "Activate animation option"); + uiDefButS(block, NUM, B_MATPRV, "Offset :", 642,90,150,19, &tex->offset, -9000.0, 9000.0, 0, 0, "Set the number of the first picture of the animation"); + uiDefButS(block, NUM, B_MATPRV, "Fie/Ima:", 642,60,98,19, &tex->fie_ima, 1.0, 200.0, 0, 0, "Set the number of fields per rendered frame"); + uiDefButS(block, NUM, B_MATPRV, "StartFr:", 642,30,150,19, &tex->sfra, 1.0, 9000.0, 0, 0, "Set the start frame of the animation"); + uiDefButS(block, NUM, B_MATPRV, "Len:", 642,10,150,19, &tex->len, 0.0, 9000.0, 0, 0, "Set the length of the animation"); - ob= OBACT; - if(ob==0) return; - - sprintf(str, "editbuttonswin %d", curarea->win); - block= uiNewBlock(&curarea->uiblocks, str, UI_EMBOSSX, UI_HELV, curarea->win); + uiDefButS(block, NUM, B_MATPRV, "Fra:", 802,70,73,19, &(tex->fradur[0][0]), 0.0, 18000.0, 0, 0, "Montage mode: frame start"); + uiDefButS(block, NUM, B_MATPRV, "", 879,70,37,19, &(tex->fradur[0][1]), 0.0, 250.0, 0, 0, "Montage mode: amount of displayed frames"); + uiDefButS(block, NUM, B_MATPRV, "Fra:", 802,50,73,19, &(tex->fradur[1][0]), 0.0, 18000.0, 0, 0, "Montage mode: frame start"); + uiDefButS(block, NUM, B_MATPRV, "", 879,50,37,19, &(tex->fradur[1][1]), 0.0, 250.0, 0, 0, "Montage mode: amount of displayed frames"); + uiDefButS(block, NUM, B_MATPRV, "Fra:", 802,30,73,19, &(tex->fradur[2][0]), 0.0, 18000.0, 0, 0, "Montage mode: frame start"); + uiDefButS(block, NUM, B_MATPRV, "", 879,30,37,19, &(tex->fradur[2][1]), 0.0, 250.0, 0, 0, "Montage mode: amount of displayed frames"); + uiDefButS(block, NUM, B_MATPRV, "Fra:", 802,10,73,19, &(tex->fradur[3][0]), 0.0, 18000.0, 0, 0, "Montage mode: frame start"); + uiDefButS(block, NUM, B_MATPRV, "", 879,10,37,19, &(tex->fradur[3][1]), 0.0, 250.0, 0, 0, "Montage mode: amount of displayed frames"); - mb= ob->data; - if (ob==find_basis_mball(ob)) { - uiDefButF(block, NUMSLI, B_RECALCMBALL, "Wiresize:", 470,178,250,19, &mb->wiresize, 0.05, 1.0, 0, 0, ""); - uiDefButF(block, NUMSLI, 0, "Rendersize:", 470,158,250,19, &mb->rendersize, 0.05, 1.0, 0, 0, ""); - uiDefButF(block, NUMSLI, B_RECALCMBALL, "Threshold:", 470,138,250,19, &mb->thresh, 0.0001, 5.0, 0, 0, ""); - - uiBlockSetCol(block, BUTBLUE); - uiDefBut(block, LABEL, 0, "Update:", 471,108,120,19, 0, 0, 0, 0, 0, ""); - uiDefButS(block, ROW, B_DIFF, "Always", 471, 85, 120, 19, &mb->flag, 0.0, 0.0, 0, 0, ""); - uiDefButS(block, ROW, B_DIFF, "Half Res", 471, 65, 120, 19, &mb->flag, 0.0, 1.0, 0, 0, ""); - uiDefButS(block, ROW, B_DIFF, "Fast", 471, 45, 120, 19, &mb->flag, 0.0, 2.0, 0, 0, ""); - uiBlockSetCol(block, BUTGREY); - } + uiBlockSetCol(block, BUTGREEN); + uiDefButS(block, TOG|BIT|6, 0, "Cyclic", 743,60,48,19, &tex->imaflag, 0, 0, 0, 0, "Repeat animation image"); + + uiBlockSetCol(block, BUTSALMON); + uiDefBut(block, BUT, B_LOADTEXIMA, "Load Image", 350,137,132,24, 0, 0, 0, 0, 0, "Load image - thumbnail view"); + uiBlockSetCol(block, BUTGREY); + uiDefBut(block, BUT, B_LOADTEXIMA1, "", 485,137,10,24, 0, 0, 0, 0, 0, "Load image - file view"); - if(ob==G.obedit && lastelem) { - uiDefButF(block, NUMSLI, B_RECALCMBALL, "Stiffness:", 750,178,250,19, &lastelem->s, 0.0, 10.0, 0, 0, ""); - if(lastelem->type!=MB_BALL) - uiDefButF(block, NUMSLI, B_RECALCMBALL, "dx:", 750,158,250,19, &lastelem->expx, 0.0, 20.0, 0, 0, ""); - if((lastelem->type!=MB_BALL)&&(lastelem->type!=MB_TUBE)) - uiDefButF(block, NUMSLI, B_RECALCMBALL, "dy:", 750,138,250,19, &lastelem->expy, 0.0, 20.0, 0, 0, ""); - - if((lastelem->type==MB_CUBE)||(lastelem->type==MB_ELIPSOID)) - uiDefButF(block, NUMSLI, B_RECALCMBALL, "dz:", 750,118,250,19, &lastelem->expz, 0.0, 20.0, 0, 0, ""); - - uiBlockSetCol(block, BUTGREEN); - uiDefButS(block, TOG|BIT|1, B_RECALCMBALL, "Negative",753,16,60,19, &lastelem->flag, 0, 0, 0, 0, ""); - - uiDefButS(block, ROW, B_RECALCMBALL, "Ball", 753,83,60,19, &lastelem->type, 1.0, 0.0, 0, 0, ""); - uiDefButS(block, ROW, B_RECALCMBALL, "Tube", 753,62,60,19, &lastelem->type, 1.0, 4.0, 0, 0, ""); - uiDefButS(block, ROW, B_RECALCMBALL, "Plane", 814,62,60,19, &lastelem->type, 1.0, 5.0, 0, 0, ""); - uiDefButS(block, ROW, B_RECALCMBALL, "Elipsoid", 876,62,60,19, &lastelem->type, 1.0, 6.0, 0, 0, ""); - uiDefButS(block, ROW, B_RECALCMBALL, "Cube", 938,62,60,19, &lastelem->type, 1.0, 7.0, 0, 0, ""); - } - uiDrawBlock(block); -} - -/* *************************** SCRIPT ******************************** */ - -static void extend_scriptlink(ScriptLink *slink) -{ - void *stmp, *ftmp; + id= (ID *)tex->ima; + IDnames_to_pupstring(&strp, NULL, NULL, &(G.main->image), id, &(G.buts->menunr)); + if(strp[0]) + uiDefButS(block, MENU, B_TEXIMABROWSE, strp, 496,137,23,24, &(G.buts->menunr), 0, 0, 0, 0, "Browse"); + MEM_freeN(strp); + + if(tex->ima) { + uiDefBut(block, TEX, B_NAMEIMA, "", 520,137,412,24, tex->ima->name, 0.0, 79.0, 0, 0, "Texture name"); + sprintf(str, "%d", tex->ima->id.us); + uiDefBut(block, BUT, 0, str, 934,137,23,24, 0, 0, 0, 0, 0, "Number of users"); + uiDefBut(block, BUT, B_RELOADIMA, "Reload", 986,137,68,24, 0, 0, 0, 0, 0, "Reload"); - if (!slink) return; - - stmp= slink->scripts; - slink->scripts= MEM_mallocN(sizeof(ID*)*(slink->totscript+1), "scriptlistL"); + if (tex->ima->packedfile) { + packdummy = 1; + } else { + packdummy = 0; + } + uiDefIconButI(block, TOG|BIT|0, B_PACKIMA, ICON_PACKAGE, 960,137,24,24, &packdummy, 0, 0, 0, 0, "Pack/Unpack this Image"); + } + + uiBlockSetCol(block, BUTGREEN); + + uiDefButS(block, TOG|BIT|0, 0, "InterPol", 350, 170, 75, 18, &tex->imaflag, 0, 0, 0, 0, "Interpolate pixels of the image"); + uiDefButS(block, TOG|BIT|1, B_MATPRV, "UseAlpha", 425, 170, 75, 18, &tex->imaflag, 0, 0, 0, 0, "Use the alpha layer"); + uiDefButS(block, TOG|BIT|5, B_MATPRV, "CalcAlpha", 500, 170, 75, 18, &tex->imaflag, 0, 0, 0, 0, "Calculate an alpha based on the RGB"); + uiDefButS(block, TOG|BIT|2, B_MATPRV, "NegAlpha", 575, 170, 75, 18, &tex->flag, 0, 0, 0, 0, "Reverse the alpha value"); + uiDefButS(block, TOG|BIT|2, B_IMAPTEST, "MipMap", 650, 170, 75, 18, &tex->imaflag, 0, 0, 0, 0, "Generate a series of pictures used for mipmapping"); + uiDefButS(block, TOG|BIT|3, B_IMAPTEST, "Fields", 725, 170, 75, 18, &tex->imaflag, 0, 0, 0, 0, "Work with field images"); + uiDefButS(block, TOG|BIT|4, B_MATPRV, "Rot90", 800, 170, 50, 18, &tex->imaflag, 0, 0, 0, 0, "Rotate image 90 degrees when rendered"); + uiDefButS(block, TOG|BIT|7, B_RELOADIMA, "Movie", 850, 170, 50, 18, &tex->imaflag, 0, 0, 0, 0, "Use a movie for an image"); + uiDefButS(block, TOG|BIT|8, 0, "Anti", 900, 170, 50, 18, &tex->imaflag, 0, 0, 0, 0, "Use anti-aliasing"); + uiDefButS(block, TOG|BIT|10, 0, "StField", 950, 170, 50, 18, &tex->imaflag, 0, 0, 0, 0, ""); + + uiBlockSetCol(block, BUTGREY); - ftmp= slink->flag; - slink->flag= MEM_mallocN(sizeof(short*)*(slink->totscript+1), "scriptlistF"); + /* print amount of frames anim */ + if(tex->ima && tex->ima->anim) { + uiDefBut(block, BUT, B_TEXSETFRAMES, "<", 802, 110, 20, 18, 0, 0, 0, 0, 0, "Paste number of frames in Frames: button"); + sprintf(str, "%d frs ", IMB_anim_get_duration(tex->ima->anim)); + uiDefBut(block, LABEL, 0, str, 834, 110, 90, 18, 0, 0, 0, 0, 0, ""); + sprintf(str, "%d cur ", tex->ima->lastframe); + uiDefBut(block, LABEL, 0, str, 834, 90, 90, 18, 0, 0, 0, 0, 0, ""); + } + + + } + else if(tex->type==TEX_PLUGIN) { + if(tex->plugin && tex->plugin->doit) { + + pit= tex->plugin; - if (slink->totscript) { - memcpy(slink->scripts, stmp, sizeof(ID*)*(slink->totscript)); - MEM_freeN(stmp); - - memcpy(slink->flag, ftmp, sizeof(short)*(slink->totscript)); - MEM_freeN(ftmp); - } - - slink->scripts[slink->totscript]= NULL; - slink->flag[slink->totscript]= SCRIPT_FRAMECHANGED; - - slink->totscript++; + uiBlockSetCol(block, BUTGREEN); + for(a=0; astypes; a++) { + uiDefButS(block, ROW, B_MATPRV, pit->stnames+16*a, (short)(350+75*a), 170, 75, 18, &tex->stype, 2.0, (float)a, 0, 0, ""); + } - if(slink->actscript<1) slink->actscript=1; -} + uiBlockSetCol(block, BUTGREY); + varstr= pit->varstr; + if(varstr) { + for(a=0; avars; a++, varstr++) { + xco= 350 + 140*(a/6); + yco= 110 - 20*(a % 6); + pit->data[a] = varstr->def; + uiDefBut(block, varstr->type, B_PLUGBUT+a, varstr->name, (short)xco,(short)yco,137,19, &(pit->data[a]), varstr->min, varstr->max, 100, 0, varstr->tip); + } + } + uiDefBut(block, TEX, B_NAMEPLUGIN, "", 520,137,412,24, pit->name, 0.0, 159.0, 0, 0, "Browse"); + } + + uiBlockSetCol(block, BUTSALMON); + uiDefBut(block, BUT, B_LOADPLUGIN, "Load Plugin", 350,137,137,24, 0, 0, 0, 0, 0, ""); + + } + else if(tex->type==TEX_ENVMAP) { + + if(tex->env==0) { + tex->env= RE_add_envmap(); + tex->env->object= OBACT; + } + if(tex->env) { + env= tex->env; + + uiBlockSetCol(block, BUTGREEN); + uiDefButS(block, ROW, B_REDR, "Static", 350, 170, 75, 18, &env->stype, 2.0, 0.0, 0, 0, "Calculate map only once"); + uiDefButS(block, ROW, B_REDR, "Anim", 425, 170, 75, 18, &env->stype, 2.0, 1.0, 0, 0, "Calculate map each rendering"); + uiDefButS(block, ROW, B_ENV_FREE, "Load", 500, 170, 75, 18, &env->stype, 2.0, 2.0, 0, 0, "Load map from disk"); + + if(env->stype==ENV_LOAD) { + uiBlockSetCol(block, BUTSALMON); + uiDefBut(block, BUT, B_LOADTEXIMA, "Load Image", 350,137,132,24, 0, 0, 0, 0, 0, "Load image - thumbnail view"); + uiBlockSetCol(block, BUTGREY); + uiDefBut(block, BUT, B_LOADTEXIMA1, "", 485,137,10,24, 0, 0, 0, 0, 0, "Load image - file view"); + + id= (ID *)tex->ima; + IDnames_to_pupstring(&strp, NULL, NULL, &(G.main->image), id, &(G.buts->menunr)); + if(strp[0]) + uiDefButS(block, MENU, B_TEXIMABROWSE, strp, 496,137,23,24, &(G.buts->menunr), 0, 0, 0, 0, ""); + MEM_freeN(strp); + + if(tex->ima) { + uiDefBut(block, TEX, B_NAMEIMA, "", 520,137,412,24, tex->ima->name, 0.0, 79.0, 0, 0, ""); + sprintf(str, "%d", tex->ima->id.us); + uiDefBut(block, BUT, 0, str, 934,137,23,24, 0, 0, 0, 0, 0, ""); + if (tex->ima->packedfile) { + packdummy = 1; + } else { + packdummy = 0; + } + uiDefIconButI(block, TOG|BIT|0, B_PACKIMA, ICON_PACKAGE, 960,137,24,24, &packdummy, 0, 0, 0, 0, "Pack/Unpack this Image"); + uiDefBut(block, BUT, B_RELOADIMA, "Reload", 986,137,68,24, 0, 0, 0, 0, 0, ""); + } + } + else { + uiBlockSetCol(block, BUTSALMON); + uiDefBut(block, BUT, B_ENV_FREE, "Free Data", 350,137,107,24, 0, 0, 0, 0, 0, "Release all images associated with environment map"); + uiBlockSetCol(block, BUTGREY); + uiDefBut(block, BUT, B_ENV_SAVE, "Save EnvMap", 461,137,115,24, 0, 0, 0, 0, 0, "Save environment map"); + uiBlockSetCol(block, BUTSALMON); + uiDefBut(block, BUT, B_ENV_FREE_ALL, "Free all EnvMaps", 600,137,160,24, 0, 0, 0, 0, 0, "Frees all rendered environment maps"); + } + uiBlockSetCol(block, BUTGREY); + uiDefIDPoinBut(block, test_obpoin_but, B_ENV_OB, "Ob:", 350,95,166,24, &(env->object), "Object name"); + uiDefButF(block, NUM, B_MATPRV, "Filter :", 518,95,120,24, &tex->filtersize, 0.1, 25.0, 0, 0, "Adjust sharpness or blurriness of the reflection"), + uiDefButS(block, NUM, B_ENV_FREE, "Depth:", 640,95,120,24, &env->depth, 0, 5.0, 0, 0, "Number of times a map gets rendered again, for recursive mirror effect"), -static void delete_scriptlink(ScriptLink *slink) -{ - int i; + uiDefButF(block, NUM, REDRAWVIEW3D, "ClipSta", 350,68,122,24, &env->clipsta, 0.01, 50.0, 100, 0, "Set start value for clipping"); + uiDefButF(block, NUM, 0, "ClipEnd", 475,68,142,24, &env->clipend, 0.1, 5000.0, 1000, 0, "Set end value for clipping"); + if(env->stype!=ENV_LOAD) uiDefButS(block, NUM, B_ENV_FREE, "CubeRes", 620,68,140,24, &env->cuberes, 50, 2048.0, 0, 0, "Set the resolution in pixels"); - if (!slink) return; + uiDefBut(block, LABEL, 0, "Don't render layer:", 772,100,140,22, 0, 0.0, 0.0, 0, 0, ""); + xco= 772; + dx= 28; + dy= 26; + for(a=0; a<10; a++) { + uiDefButI(block, TOG|BIT|(a+10), 0, "",(short)(xco+a*(dx/2)), 68, (short)(dx/2), (short)(dy/2), &env->notlay, 0, 0, 0, 0, "Render this layer"); + uiDefButI(block, TOG|BIT|a, 0, "", (short)(xco+a*(dx/2)), (short)(68+dy/2), (short)(dx/2), (short)(1+dy/2), &env->notlay, 0, 0, 0, 0, "Render this layer"); + if(a==4) xco+= 5; + } - if (slink->totscript>0) { - for (i=slink->actscript-1; itotscript-1; i++) { - slink->flag[i]= slink->flag[i+1]; - slink->scripts[i]= slink->scripts[i+1]; + } + } + + /* COLORBAND */ + uiBlockSetCol(block, BUTSALMON); + uiDefButS(block, TOG|BIT|0, B_COLORBAND, "Colorband", 923,103,102,20, &tex->flag, 0, 0, 0, 0, "Use colorband"); + if(tex->flag & TEX_COLORBAND) { + uiDefBut(block, BUT, B_ADDCOLORBAND, "Add", 1029,103,50,20, 0, 0, 0, 0, 0, "Add new colour to the colorband"); + uiDefBut(block, BUT, B_DELCOLORBAND, "Del", 1218,104,50,20, 0, 0, 0, 0, 0, "Delete the active colour"); + uiBlockSetCol(block, BUTPURPLE); + uiDefButS(block, NUM, B_REDR, "Cur:", 1082,104,132,20, &tex->coba->cur, 0.0, (float)(tex->coba->tot-1), 0, 0, "The active colour from the colorband"); + + uiDefBut(block, LABEL, B_DOCOLORBAND, "", 923,81,345,20, 0, 0, 0, 0, 0, "Colorband"); /* only for event! */ + + drawcolorband(tex->coba, 923,81,345,20); + cbd= tex->coba->data + tex->coba->cur; + + uiDefButF(block, NUM, B_CALCCBAND, "Pos", 923,59,89,20, &cbd->pos, 0.0, 1.0, 10, 0, "Set the position of the active colour"); + uiBlockSetCol(block, BUTGREEN); + uiDefButS(block, ROW, B_REDRAWCBAND, "E", 1013,59,20,20, &tex->coba->ipotype, 5.0, 1.0, 0, 0, "Interpolation type Ease"); + uiDefButS(block, ROW, B_REDRAWCBAND, "L", 1033,59,20,20, &tex->coba->ipotype, 5.0, 0.0, 0, 0, "Interpolation type Linear"); + uiDefButS(block, ROW, B_REDRAWCBAND, "S", 1053,59,20,20, &tex->coba->ipotype, 5.0, 2.0, 0, 0, "Interpolation type Spline"); + uiBlockSetCol(block, BUTPURPLE); + uiDefButF(block, COL, B_BANDCOL, "", 1076,59,28,20, &(cbd->r), 0, 0, 0, 0, ""); + uiDefButF(block, NUMSLI, B_REDRAWCBAND, "A ", 1107,58,163,20, &cbd->a, 0.0, 1.0, 0, 0, "Set the alpha value"); + + uiDefButF(block, NUMSLI, B_REDRAWCBAND, "R ", 923,37,116,20, &cbd->r, 0.0, 1.0, B_BANDCOL, 0, "Set the red value"); + uiDefButF(block, NUMSLI, B_REDRAWCBAND, "G ", 1042,37,111,20, &cbd->g, 0.0, 1.0, B_BANDCOL, 0, "Set the green value"); + uiDefButF(block, NUMSLI, B_REDRAWCBAND, "B ", 1156,36,115,20, &cbd->b, 0.0, 1.0, B_BANDCOL, 0, "Set the blue value"); + } + + + /* RGB-BRICON */ + uiBlockSetCol(block, BUTGREY); + uiDefButF(block, NUMSLI, B_MATPRV, "Bright", 923,11,166,20, &tex->bright, 0.0, 2.0, 0, 0, "Set the brightness of the colour or intensity of a texture"); - slink->totscript--; + uiDefButF(block, NUMSLI, B_MATPRV, "Contr", 1093,11,180,20, &tex->contrast, 0.01, 2.0, 0, 0, "Set the contrast of the colour or intensity of a texture"); + + if((tex->flag & TEX_COLORBAND)==0) { + uiDefButF(block, NUMSLI, B_MATPRV, "R ", 923,37,116,20, &tex->rfac, 0.0, 2.0, 0, 0, "Set the red value"); + uiDefButF(block, NUMSLI, B_MATPRV, "G ", 1042,37,111,20, &tex->gfac, 0.0, 2.0, 0, 0, "Set the green value"); + uiDefButF(block, NUMSLI, B_MATPRV, "B ", 1156,36,115,20, &tex->bfac, 0.0, 2.0, 0, 0, "Set the blue value"); + } } - - CLAMP(slink->actscript, 1, slink->totscript); - - if (slink->totscript==0) { - if (slink->scripts) MEM_freeN(slink->scripts); - if (slink->flag) MEM_freeN(slink->flag); + + /* PREVIEW RENDER */ + + BIF_previewdraw(G.buts); - slink->scripts= NULL; - slink->flag= NULL; - slink->totscript= slink->actscript= 0; - } + uiDrawBlock(block); } -void do_scriptbuts(short event) -{ - Object *ob=NULL; - ScriptLink *script=NULL; - Material *ma; - - switch (event) { - case B_SSCRIPT_ADD: - extend_scriptlink(&G.scene->scriptlink); - break; - case B_SSCRIPT_DEL: - delete_scriptlink(&G.scene->scriptlink); - break; - - case B_SCRIPT_ADD: - case B_SCRIPT_DEL: - ob= OBACT; - - if (ob && G.buts->scriptblock==ID_OB) { - script= &ob->scriptlink; +/* ****************************** MATERIAL ************************ */ +MTex mtexcopybuf; - } else if (ob && G.buts->scriptblock==ID_MA) { - ma= give_current_material(ob, ob->actcol); - if (ma) script= &ma->scriptlink; - } else if (ob && G.buts->scriptblock==ID_CA) { - if (ob->type==OB_CAMERA) - script= &((Camera *)ob->data)->scriptlink; +void do_matbuts(unsigned short event) +{ + static short mtexcopied=0; + Material *ma; + MTex *mtex; - } else if (ob && G.buts->scriptblock==ID_LA) { - if (ob->type==OB_LAMP) - script= &((Lamp *)ob->data)->scriptlink; + switch(event) { + case B_ACTCOL: + scrarea_queue_headredraw(curarea); + allqueue(REDRAWBUTSMAT, 0); + allqueue(REDRAWIPO, 0); + BIF_preview_changed(G.buts); + break; + case B_MATFROM: - } else if (G.buts->scriptblock==ID_WO) { - if (G.scene->world) - script= &(G.scene->world->scriptlink); + scrarea_queue_headredraw(curarea); + allqueue(REDRAWBUTSMAT, 0); + BIF_previewdraw(G.buts); + break; + case B_MATPRV: + /* this event also used by lamp, tex and sky */ + BIF_preview_changed(G.buts); + break; + case B_MATPRV_DRAW: + BIF_preview_changed(G.buts); + allqueue(REDRAWBUTSMAT, 0); + break; + case B_TEXCLEAR: + ma= G.buts->lockpoin; + mtex= ma->mtex[(int) ma->texact ]; + if(mtex) { + if(mtex->tex) mtex->tex->id.us--; + MEM_freeN(mtex); + ma->mtex[ (int) ma->texact ]= 0; + allqueue(REDRAWBUTSMAT, 0); + allqueue(REDRAWOOPS, 0); + BIF_preview_changed(G.buts); } - - if (event==B_SCRIPT_ADD) extend_scriptlink(script); - else delete_scriptlink(script); - break; - default: + case B_MTEXCOPY: + ma= G.buts->lockpoin; + if(ma && ma->mtex[(int)ma->texact] ) { + mtex= ma->mtex[(int)ma->texact]; + if(mtex->tex==0) { + error("No texture available"); + } + else { + memcpy(&mtexcopybuf, ma->mtex[(int)ma->texact], sizeof(MTex)); + notice("copied!"); + mtexcopied= 1; + } + } break; - } - - allqueue(REDRAWBUTSSCRIPT, 0); -} - -void draw_scriptlink(uiBlock *block, ScriptLink *script, int sx, int sy, int scene) -{ - char str[256]; - - uiBlockSetCol(block, BUTGREY); - - if (script->totscript) { - strcpy(str, "FrameChanged%x 1|"); - strcat(str, "Redraw%x 4|"); - if (scene) { - strcat(str, "OnLoad%x 2"); + case B_MTEXPASTE: + ma= G.buts->lockpoin; + if(ma && mtexcopied && mtexcopybuf.tex) { + if(ma->mtex[(int)ma->texact]==0 ) ma->mtex[(int)ma->texact]= MEM_mallocN(sizeof(MTex), "mtex"); + memcpy(ma->mtex[(int)ma->texact], &mtexcopybuf, sizeof(MTex)); + + id_us_plus((ID *)mtexcopybuf.tex); + notice("pasted!"); + BIF_preview_changed(G.buts); + scrarea_queue_winredraw(curarea); + } + break; + case B_MATLAY: + ma= G.buts->lockpoin; + if(ma && ma->lay==0) { + ma->lay= 1; + scrarea_queue_winredraw(curarea); } - - uiDefButS(block, MENU, 1, str, (short)sx, (short)sy, 148, 19, &script->flag[script->actscript-1], 0, 0, 0, 0, "Script links for the Frame changed event"); - - uiDefIDPoinBut(block, test_scriptpoin_but, 1, "", (short)(sx+150),(short)sy, 98, 19, &script->scripts[script->actscript-1], "Name of Script to link"); } - - sprintf(str,"%d Scr:", script->totscript); - uiDefButS(block, NUM, REDRAWBUTSSCRIPT, str, (short)(sx+250), (short)sy,98,19, &script->actscript, 1, script->totscript, 0, 0, "Total / Active Script link (LeftMouse + Drag to change)"); - - uiBlockSetCol(block, BUTSALMON); - - if (scene) { - if (script->totscript<32767) - uiDefBut(block, BUT, B_SSCRIPT_ADD, "New", (short)(sx+350), (short)sy, 38, 19, 0, 0, 0, 0, 0, "Add a new Script link"); - if (script->totscript) - uiDefBut(block, BUT, B_SSCRIPT_DEL, "Del", (short)(sx+390), (short)sy, 38, 19, 0, 0, 0, 0, 0, "Delete the current Script link"); - } else { - if (script->totscript<32767) - uiDefBut(block, BUT, B_SCRIPT_ADD, "New", (short)(sx+350), (short)sy, 38, 19, 0, 0, 0, 0, 0, "Add a new Script link"); - if (script->totscript) - uiDefBut(block, BUT, B_SCRIPT_DEL, "Del", (short)(sx+390), (short)sy, 38, 19, 0, 0, 0, 0, 0, "Delete the current Script link"); - } } -void scriptbuts(void) +void matbuts(void) { - Object *ob=NULL; - ScriptLink *script=NULL; + Object *ob; Material *ma; + ID *id, *idn; + MTex *mtex; uiBlock *block; - char str[64]; + uiBut *but; + float *colpoin = NULL, min; + int rgbsel = 0, a, loos; + char str[30], *strp; + short xco; ob= OBACT; + if(ob==0 || ob->data==0) return; sprintf(str, "buttonswin %d", curarea->win); block= uiNewBlock(&curarea->uiblocks, str, UI_EMBOSSX, UI_HELV, curarea->win); - if (ob && G.buts->scriptblock==ID_OB) { - script= &ob->scriptlink; - - } else if (ob && G.buts->scriptblock==ID_MA) { - ma= give_current_material(ob, ob->actcol); - if (ma) script= &ma->scriptlink; - - } else if (ob && G.buts->scriptblock==ID_CA) { - if (ob->type==OB_CAMERA) - script= &((Camera *)ob->data)->scriptlink; - - } else if (ob && G.buts->scriptblock==ID_LA) { - if (ob->type==OB_LAMP) - script= &((Lamp *)ob->data)->scriptlink; - - } else if (G.buts->scriptblock==ID_WO) { - if (G.scene->world) - script= &(G.scene->world->scriptlink); - } - - if (script) draw_scriptlink(block, script, 25, 180, 0); + if(ob->actcol==0) ob->actcol= 1; /* because of TOG|BIT button */ - /* EVENTS */ - draw_buttons_edge(curarea->win, 540); - - draw_scriptlink(block, &G.scene->scriptlink, 600, 180, 1); - - uiDrawBlock(block); -} + /* indicate which one is linking a material */ + uiBlockSetCol(block, BUTSALMON); + uiDefButS(block, TOG|BIT|(ob->actcol-1), B_MATFROM, "OB", 342, 195, 33, 20, &ob->colbits, 0, 0, 0, 0, "Link material to object"); + idn= ob->data; + strncpy(str, idn->name, 2); + str[2]= 0; + uiBlockSetCol(block, BUTGREEN); + uiDefButS(block, TOGN|BIT|(ob->actcol-1), B_MATFROM, str, 380, 195, 33, 20, &ob->colbits, 0, 0, 0, 0, "Show the block the material is linked to"); + uiBlockSetCol(block, BUTGREY); + + /* id is the block from which the material is used */ + if( BTST(ob->colbits, ob->actcol-1) ) id= (ID *)ob; + else id= ob->data; -/* *************************** IKA ******************************** */ -/* is this number used elsewhere? */ -/* static int ika_del_number; */ -void do_ikabuts(unsigned short event) -{ - Base *base; - Object *ob; + sprintf(str, "%d Mat", ob->totcol); + if(ob->totcol) min= 1.0; else min= 0.0; + uiDefButC(block, NUM, B_ACTCOL, str, 415,195,150,20, &(ob->actcol), min, (float)ob->totcol, 0, 0, "Number of materials on object / Active material"); - ob= OBACT; + uiSetButLock(id->lib!=0, "Can't edit library data"); - switch(event) { - case B_IKASETREF: - base= FIRSTBASE; - while(base) { - if TESTBASELIB(base) { - if(base->object->type==OB_IKA) init_defstate_ika(base->object); - } - base= base->next; - } - break; - case B_IKARECALC: - itterate_ika(ob); - break; - } -} + strncpy(str, id->name, 2); + str[2]= ':'; str[3]= 0; + but= uiDefBut(block, TEX, B_IDNAME, str, 200,195,140,20, id->name+2, 0.0, 18.0, 0, 0, "Show the block the material is linked to"); + uiButSetFunc(but, test_idbutton_cb, id->name, NULL); -void ikabuts(void) -{ - Ika *ika; - Object *ob; - Limb *li; - Deform *def; - uiBlock *block; - int nr, cury, nlimbs; - char str[32]; + if(ob->totcol==0) { + uiDrawBlock(block); + return; + } - ob= OBACT; - if(ob==0) return; - - sprintf(str, "editbuttonswin %d", curarea->win); - block= uiNewBlock(&curarea->uiblocks, str, UI_EMBOSSX, UI_HELV, curarea->win); - - ika= ob->data; + ma= give_current_material(ob, ob->actcol); + + if(ma==0) { + uiDrawBlock(block); + return; + } + uiSetButLock(ma->id.lib!=0, "Can't edit library data"); - uiBlockSetCol(block, BUTSALMON); - uiDefBut(block, BUT, B_IKASETREF, "Set Reference",470,180,200,20, 0, 0, 0, 0, 0, ""); - - uiBlockSetCol(block, BUTGREEN); - uiDefButS(block, TOG|BIT|1, B_DIFF, "Lock XY Plane", 470,140,200,20, &ika->flag, 0.0, 1.0, 0, 0, "New IK option: allows both X and Y axes to rotate"); uiBlockSetCol(block, BUTGREY); - uiDefButF(block, NUM, B_DIFF, "XY constraint ", 470,120,200,20, &ika->xyconstraint, 0.0, 1.0, 100, 0, "Constrain in radians"); - - uiDefButF(block, NUMSLI, B_DIFF, "Mem ", 470,80,200,20, &ika->mem, 0.0, 1.0, 0, 0, ""); - uiDefButS(block, NUM, B_DIFF, "Iter: ", 470,60,200,20, &ika->iter, 2.0, 16.0, 0, 0, ""); - - - uiBlockSetCol(block, BUTGREY); - - uiDefBut(block, LABEL, 0, "Limb Weight", 680, 200, 150, 19, 0, 0, 0, 0, 0, ""); - cury= 180; - li= ika->limbbase.first; - - nlimbs= BLI_countlist(&ika->limbbase); + uiDefButS(block, ROW, REDRAWBUTSMAT, "RGB", 200,166,35,22, &(ma->colormodel), 1.0, (float)MA_RGB, 0, 0, "Create colour by red, green and blue"); + uiDefButS(block, ROW, REDRAWBUTSMAT, "HSV", 200,143,35,22, &(ma->colormodel), 1.0, (float)MA_HSV, 0, 0, "Mix colour with hue, saturation and value"); + uiDefButS(block, TOG|BIT|0, REDRAWBUTSMAT, "DYN", 200,120,35,22, &(ma->dynamode), 0.0, 0.0, 0, 0, "Adjust parameters for dynamics options"); + + if(ma->dynamode & MA_DRAW_DYNABUTS) { + uiDefButF(block, NUMSLI, 0, "Restitut ", 390,168,175,21, &ma->reflect, 0.0, 1.0, 0, 0, "Elasticity of collisions"); + uiDefButF(block, NUMSLI, 0, "Friction ", 390,144,175,21, &ma->friction, 0.0, 100.0, 0, 0, "Coulomb friction coefficient"); - for (nr = 0; nr < nlimbs; nr++) { - sprintf(str, "Limb %d:", nr); - uiDefButF(block, NUM, B_DIFF, str, 680, (short)cury, 150, 19, &li->fac, 0.01, 1.0, 10, 0, ""); - cury-= 20; - li= li->next; + uiDefButF(block, NUMSLI, 0, "Fh Force ", 390,120,175,21, &ma->fh, 0.0, 1.0, 0, 0, "Upward spring force within the Fh area"); + uiDefButF(block, NUM, 0, "Fh Damp ", 260,144,120,21, &ma->xyfrict, 0.0, 1.0, 10, 0, "Damping of the Fh spring force"); + uiDefButF(block, NUM, 0, "Fh Dist ", 260,120,120,21, &ma->fhdist, 0.0, 20.0, 10, 0, "Height of the Fh area"); + uiBlockSetCol(block, BUTGREEN); + uiDefButS(block, TOG|BIT|1, 0, "Fh Norm", 260,168,120,21, &ma->dynamode, 0.0, 0.0, 0, 0, "Add a horizontal spring force on slopes"); + uiBlockSetCol(block, BUTGREY); } - - - - uiDefBut(block, LABEL, 0, "Deform Max Dist", 955, 200, 140, 19, 0, 0, 0, 0, 0, ""); - uiDefBut(block, LABEL, 0, "Deform Weight", 1095, 200, 140, 19, 0, 0, 0, 0, 0, ""); + else { + uiDefButF(block, COL, B_MIRCOL, "", 235,143,30,45, &(ma->mirr), 0, 0, 0, 0, ""); + uiDefButF(block, COL, B_SPECCOL, "", 265,143,39,45, &(ma->specr), 0, 0, 0, 0, ""); + uiDefButF(block, COL, B_MATCOL, "", 304,143,39,45, &(ma->r), 0, 0, 0, 0, ""); - - cury= 180; - def= ika->def; - for (nr = 0; nr < ika->totdef; nr++) { - def = ika->def+nr; - if(def->ob) { - if(def->ob->type!=OB_IKA) sprintf(str, "%s :", def->ob->id.name+2); - else sprintf(str, "%s (%d):", def->ob->id.name+2, def->par1); + if(ma->mode & MA_HALO) { + uiDefButC(block, ROW, REDRAWBUTSMAT, "Ring", 235,120,30,22, &(ma->rgbsel), 2.0, 2.0, 0, 0, "Mix the colour of the rings with the RGB sliders"); + uiDefButC(block, ROW, REDRAWBUTSMAT, "Line", 265,120,39,22, &(ma->rgbsel), 2.0, 1.0, 0, 0, "Mix the colour of the lines with the RGB sliders"); + uiDefButC(block, ROW, REDRAWBUTSMAT, "Halo", 304,120,39,22, &(ma->rgbsel), 2.0, 0.0, 0, 0, "Mix the colour of the halo with the RGB sliders"); + } + else { + uiDefButC(block, ROW, REDRAWBUTSMAT, "Mir", 235,120,30,22, &(ma->rgbsel), 2.0, 2.0, 0, 0, "Use mirror colour"); + uiDefButC(block, ROW, REDRAWBUTSMAT, "Spe", 265,120,39,22, &(ma->rgbsel), 2.0, 1.0, 0, 0, "Set the colour of the specularity"); + uiDefButC(block, ROW, REDRAWBUTSMAT, "Col", 304,120,39,22, &(ma->rgbsel), 2.0, 0.0, 0, 0, "Set the basic colour of the material"); } + if(ma->rgbsel==0) {colpoin= &(ma->r); rgbsel= B_MATCOL;} + else if(ma->rgbsel==1) {colpoin= &(ma->specr); rgbsel= B_SPECCOL;} + else if(ma->rgbsel==2) {colpoin= &(ma->mirr); rgbsel= B_MIRCOL;} - uiDefBut(block, LABEL, 0, str, 855, (short)cury, 100, 19, 0, 0.01, 0.0, 0, 0, ""); - uiDefButF(block, NUM, B_DIFF, "", 955, (short)cury, 140, 19, &def->dist, 0.0, 40.0, 100, 0, "Beyond this distance the Limb doesn't influence deformation. '0.0' is global influence."); - uiDefButF(block, NUM, B_DIFF, "", 1095,(short)cury, 140, 19, &def->fac, 0.01, 10.0, 10, 0, ""); - - cury-= 20; - } - uiDrawBlock(block); -} - -/* *************************** LATTICE ******************************** */ - -void do_latticebuts(unsigned short event) -{ - Object *ob; - Lattice *lt; - - ob= OBACT; - - switch(event) { - case B_RESIZELAT: - if(ob) { - if(ob==G.obedit) resizelattice(editLatt); - else resizelattice(ob->data); + if(ma->rgbsel==0 && (ma->mode & (MA_VERTEXCOLP|MA_FACETEXTURE) && !(ma->mode & MA_HALO))); + else if(ma->colormodel==MA_HSV) { + uiBlockSetCol(block, BUTPURPLE); + uiDefButF(block, HSVSLI, B_MATPRV, "H ", 350,168,150,21, colpoin, 0.0, 0.9999, rgbsel, 0, ""); + uiBlockSetCol(block, BUTPURPLE); + uiDefButF(block, HSVSLI, B_MATPRV, "S ", 350,144,150,21, colpoin, 0.0001, 1.0, rgbsel, 0, ""); + uiBlockSetCol(block, BUTPURPLE); + uiDefButF(block, HSVSLI, B_MATPRV, "V ", 350,120,150,21, colpoin, 0.0001, 1.0, rgbsel, 0, ""); + uiBlockSetCol(block, BUTGREY); } - allqueue(REDRAWVIEW3D, 0); - break; - case B_DRAWLAT: - if(ob==G.obedit) calc_lattverts_ext(); - allqueue(REDRAWVIEW3D, 0); - break; - case B_LATTCHANGED: + else { + uiDefButF(block, NUMSLI, B_MATPRV, "R ", 350,168,150,21, colpoin, 0.0, 1.0, rgbsel, 0, ""); + uiDefButF(block, NUMSLI, B_MATPRV, "G ", 350,144,150,21, colpoin+1, 0.0, 1.0, rgbsel, 0, ""); + uiDefButF(block, NUMSLI, B_MATPRV, "B ", 350,120,150,21, colpoin+2, 0.0, 1.0, rgbsel, 0, ""); + } + if(!(ma->mode & MA_HALO)) { + uiBlockSetCol(block, BUTBLUE); + uiDefButI(block, TOG|BIT|4, B_REDR, "VCol Light", 505, 168, 60, 21, &(ma->mode), 0, 0, 0, 0, "Add vertex colours as extra light"); + uiDefButI(block, TOG|BIT|7, B_REDR, "VCol Paint", 505, 144, 60, 21, &(ma->mode), 0, 0, 0, 0, "Replace basic colours with vertex colours"); + uiDefButI(block, TOG|BIT|11, B_REDR, "TexFace", 505, 120, 60, 21, &(ma->mode), 0, 0, 0, 0, "UV-Editor assigned texture gives color and texture info for the faces"); + } + } + if(ma->mode & MA_HALO) { + uiBlockSetCol(block, BUTGREY); + uiDefButF(block, NUM, B_MATPRV, "HaloSize: ", 200,90,175,18, &(ma->hasize), 0.0, 100.0, 10, 0, "Set the dimension of the halo"); + uiDefButF(block, NUMSLI, B_MATPRV, "Alpha ", 200,50,175,18, &(ma->alpha), 0.0, 1.0, 0, 0, "Set the degree of coverage"); + uiDefButS(block, NUMSLI, B_MATPRV, "Hard ", 200,30,175,18, &(ma->har), 1.0, 127.0, 0, 0, "Set the hardness of the halo"); + uiDefButF(block, NUMSLI, B_MATPRV, "Add ", 200,10,175,18, &(ma->add), 0.0, 1.0, 0, 0, "Strength of the add effect"); - lt= ob->data; - if(lt->flag & LT_OUTSIDE) outside_lattice(lt); + uiDefButS(block, NUM, B_MATPRV, "Rings: ", 380,90,85,18, &(ma->ringc), 0.0, 24.0, 0, 0, "Set the number of rings rendered over the basic halo"); + uiDefButS(block, NUM, B_MATPRV, "Lines: ", 465,90,90,18, &(ma->linec), 0.0, 250.0, 0, 0, "Set the number of star shaped lines rendered over the halo"); + uiDefButS(block, NUM, B_MATPRV, "Star: ", 380,70,85,18, &(ma->starc), 3.0, 50.0, 0, 0, "Set the number of points on the star shaped halo"); + uiDefButC(block, NUM, B_MATPRV, "Seed: ", 465,70,90,18, &(ma->seed1), 0.0, 255.0, 0, 0, "Use random values for ring dimension and line location"); - make_displists_by_parent(ob); + uiDefButF(block, NUM, B_MATPRV, "FlareSize: ", 380,50,85,18, &(ma->flaresize), 0.1, 25.0, 10, 0, "Set the factor the flare is larger than the halo"); + uiDefButF(block, NUM, B_MATPRV, "Sub Size: ", 465,50,90,18, &(ma->subsize), 0.1, 25.0, 10, 0, "Set the dimension of the subflares, dots and circles"); + uiDefButF(block, NUM, B_MATPRV, "FlareBoost: ", 380,30,175,18, &(ma->flareboost), 0.1, 10.0, 10, 0, "Give the flare extra strength"); + uiDefButC(block, NUM, B_MATPRV, "Fl.seed: ", 380,10,85,18, &(ma->seed2), 0.0, 255.0, 0, 0, "Specify an offset in the seed table"); + uiDefButS(block, NUM, B_MATPRV, "Flares: ", 465,10,90,18, &(ma->flarec), 1.0, 32.0, 0, 0, "Set the nuber of subflares"); - allqueue(REDRAWVIEW3D, 0); + uiBlockSetCol(block, BUTBLUE); - break; + uiDefButI(block, TOG|BIT|15, B_MATPRV, "Flare", 576, 181, 77, 36, &(ma->mode), 0, 0, 0, 0, "Render halo as a lensflare"); + uiDefButI(block, TOG|BIT|8, B_MATPRV, "Rings", 576, 143, 77, 18, &(ma->mode), 0, 0, 0, 0, "Render rings over basic halo"); + uiDefButI(block, TOG|BIT|9, B_MATPRV, "Lines", 576, 124, 77, 18, &(ma->mode), 0, 0, 0, 0, "Render star shaped lines over the basic halo"); + uiDefButI(block, TOG|BIT|11, B_MATPRV, "Star", 576, 105, 77, 18, &(ma->mode), 0, 0, 0, 0, "Render halo as a star"); + uiDefButI(block, TOG|BIT|5, B_MATPRV_DRAW, "Halo", 576, 86, 77, 18, &(ma->mode), 0, 0, 0, 0, "Render as a halo"); + + uiDefButI(block, TOG|BIT|12, B_MATPRV, "HaloTex", 576, 67, 77, 18, &(ma->mode), 0, 0, 0, 0, "Give halo a texture"); + uiDefButI(block, TOG|BIT|13, B_MATPRV, "HaloPuno", 576, 48, 77, 18, &(ma->mode), 0, 0, 0, 0, "Use the vertex normal to specify the dimension of the halo"); + uiDefButI(block, TOG|BIT|10, B_MATPRV, "X Alpha", 576, 28, 77, 18, &(ma->mode), 0, 0, 0, 0, "Use extreme alpha"); + uiDefButI(block, TOG|BIT|14, B_MATPRV, "Shaded", 576, 10, 77, 18, &(ma->mode), 0, 0, 0, 0, "Let halo receive light"); } -} + else { + char *str1= "Diffuse Shader%t|Lambert %x0|Oren-Nayar %x1|Toon %x2"; + char *str2= "Specular Shader%t|CookTorr %x0|Phong %x1|Blinn %x2|Toon %x3"; + + /* shader buttons */ + uiBlockSetCol(block, BUTGREY); + uiDefButS(block, MENU, B_MATPRV_DRAW, str1, 200,90,95,18, &(ma->diff_shader), 0.0, 0.0, 0, 0, "Set a diffuse shader"); + uiDefButS(block, MENU, B_MATPRV_DRAW, str2, 295,90,90,18, &(ma->spec_shader), 0.0, 0.0, 0, 0, "Set a specular shader"); -void latticebuts(void) -{ - Lattice *lt; - Object *ob; - uiBlock *block; - char str[64]; - - ob= OBACT; - if(ob==0) return; + if(ma->diff_shader==MA_DIFF_ORENNAYAR) + uiDefButF(block, NUM, B_MATPRV, "Rough:", 200, 70, 95,18, &(ma->roughness), 0.0, 3.14, 0, 0, "Oren Nayar Roughness"); + else if(ma->diff_shader==MA_DIFF_TOON) { + uiDefButF(block, NUM, B_MATPRV, "Size:", 200, 70, 95,18, &(ma->param[0]), 0.0, 3.14, 0, 0, "Size of diffuse toon area"); + uiDefButF(block, NUM, B_MATPRV, "Smooth:", 200, 50, 95,18, &(ma->param[1]), 0.0, 1.0, 0, 0, "Smoothness of diffuse toon area"); + } + + if ELEM3(ma->spec_shader, MA_SPEC_COOKTORR, MA_SPEC_PHONG, MA_SPEC_BLINN) { + uiDefButS(block, NUM, B_MATPRV, "Hard:", 295, 70, 90,18, &(ma->har), 1.0, 255, 0, 0, "Set the hardness of the specularity"); + } + if(ma->spec_shader==MA_SPEC_BLINN) + uiDefButF(block, NUM, B_MATPRV, "Refr:", 295, 50, 90,18, &(ma->refrac), 1.0, 10.0, 0, 0, "Refraction index"); + if(ma->spec_shader==MA_SPEC_TOON) { + uiDefButF(block, NUM, B_MATPRV, "Size:", 295, 70, 90,18, &(ma->param[2]), 0.0, 1.53, 0, 0, "Size of specular toon area"); + uiDefButF(block, NUM, B_MATPRV, "Smooth:", 295, 50, 90,18, &(ma->param[3]), 0.0, 1.0, 0, 0, "Smoothness of specular toon area"); + } - sprintf(str, "editbuttonswin %d", curarea->win); - block= uiNewBlock(&curarea->uiblocks, str, UI_EMBOSSX, UI_HELV, curarea->win); + uiDefButF(block, NUMSLI, B_MATPRV, "Ref ", 200,30,185,18, &(ma->ref), 0.0, 1.0, 0, 0, "Set the amount of reflection"); + uiDefButF(block, NUMSLI, B_MATPRV, "Spec ", 200,10,185,18, &(ma->spec), 0.0, 2.0, 0, 0, "Set the degree of specularity"); + + /* default shading variables */ + uiDefButF(block, NUMSLI, B_MATPRV, "Alpha ", 390,90,175,18, &(ma->alpha), 0.0, 1.0, 0, 0, "Set the amount of coverage, to make materials transparent"); + uiDefButF(block, NUMSLI, B_MATPRV, "SpecTra ", 390,70,175,18, &(ma->spectra), 0.0, 1.0, 0, 0, "Make specular areas opaque"); + uiDefButF(block, NUMSLI, B_MATPRV, "Add ", 390,50,175,18, &(ma->add), 0.0, 1.0, 0, 0, "Glow factor for transparant"); + uiDefButF(block, NUMSLI, B_MATPRV, "Emit ", 390,30,175,18, &(ma->emit), 0.0, 1.0, 0, 0, "Set the amount of emitting light"); + uiDefButF(block, NUMSLI, B_MATPRV, "Amb ", 390,10,175,18, &(ma->amb), 0.0, 1.0, 0, 0, "Set the amount of global ambient color"); + + uiBlockSetCol(block, BUTBLUE); + + uiDefButI(block, TOG|BIT|0, 0, "Traceable", 576,200,77,18, &(ma->mode), 0, 0, 0, 0, "Make material visible for shadow lamps"); + uiDefButI(block, TOG|BIT|1, 0, "Shadow", 576,181,77,18, &(ma->mode), 0, 0, 0, 0, "Enable material for shadows"); + uiDefButI(block, TOG|BIT|16, 0, "Radio", 576, 162, 77,18, &(ma->mode), 0, 0, 0, 0, "Set the material insensitive to mist"); + uiDefButI(block, TOG|BIT|2, B_MATPRV, "Shadeless", 576, 143, 77, 18, &(ma->mode), 0, 0, 0, 0, "Make material insensitive to light or shadow"); + uiDefButI(block, TOG|BIT|3, 0, "Wire", 576, 124, 77, 18, &(ma->mode), 0, 0, 0, 0, "Render only the edges of faces"); + uiDefButI(block, TOG|BIT|6, 0, "ZTransp", 576, 105, 77, 18, &(ma->mode), 0, 0, 0, 0, "Z-Buffer transparent faces"); + uiDefButI(block, TOG|BIT|5, B_MATPRV_DRAW, "Halo", 576, 86, 77, 18, &(ma->mode), 0, 0, 0, 0, "Render as a halo"); + uiDefButI(block, TOG|BIT|9, 0, "Env", 576, 67, 77, 18, &(ma->mode), 0, 0, 0, 0, "Do not render material"); + uiDefButI(block, TOG|BIT|10, 0, "OnlyShadow", 576, 48, 77, 18, &(ma->mode), 0, 0, 0, 0, "Let alpha be determined on the degree of shadow"); + uiDefButI(block, TOG|BIT|14, 0, "No Mist", 576, 29, 77,18, &(ma->mode), 0, 0, 0, 0, "Set the material insensitive to mist"); + uiDefButI(block, TOG|BIT|8, 0, "ZInvert", 576, 10, 77, 18, &(ma->mode), 0, 0, 0, 0, "Render with inverted Z Buffer"); + uiBlockSetCol(block, BUTGREY); + uiDefButF(block, NUM, 0, "Zoffs:", 576, -9, 77,18, &(ma->zoffs), 0.0, 10.0, 0, 0, "Give face an artificial offset"); + } + /* PREVIEW RENDER */ + + BIF_previewdraw(G.buts); - if(ob==G.obedit) lt= editLatt; - else lt= ob->data; + uiDefIconButC(block, ROW, B_MATPRV, ICON_MATPLANE, 10,195,25,20, &(ma->pr_type), 10, 0, 0, 0, ""); + uiDefIconButC(block, ROW, B_MATPRV, ICON_MATSPHERE, 35,195,25,20, &(ma->pr_type), 10, 1, 0, 0, ""); + uiDefIconButC(block, ROW, B_MATPRV, ICON_MATCUBE, 60,195,25,20, &(ma->pr_type), 10, 2, 0, 0, ""); - uiSetButLock(lt->key!=0, "Not with VertexKeys"); - uiSetButLock(ob==G.obedit, "Unable to perform function in EditMode"); - uiDefButS(block, NUM, B_RESIZELAT, "U:", 470,178,100,19, <->pntsu, 1.0, 64.0, 0, 0, ""); - uiDefButS(block, NUM, B_RESIZELAT, "V:", 470,158,100,19, <->pntsv, 1.0, 64.0, 0, 0, ""); - uiDefButS(block, NUM, B_RESIZELAT, "W:", 470,138,100,19, <->pntsw, 1.0, 64.0, 0, 0, ""); - uiClearButLock(); + uiDefIconButS(block, ICONTOG|BIT|0, B_MATPRV, ICON_TRANSP_HLT, 95,195,25,20, &(ma->pr_back), 0, 0, 0, 0, ""); - uiBlockSetCol(block, BUTGREEN); - uiDefButC(block, ROW, B_LATTCHANGED, "Lin", 572, 178, 40, 19, <->typeu, 1.0, (float)KEY_LINEAR, 0, 0, ""); - uiDefButC(block, ROW, B_LATTCHANGED, "Card", 612, 178, 40, 19, <->typeu, 1.0, (float)KEY_CARDINAL, 0, 0, ""); - uiDefButC(block, ROW, B_LATTCHANGED, "B", 652, 178, 40, 19, <->typeu, 1.0, (float)KEY_BSPLINE, 0, 0, ""); - - uiDefButC(block, ROW, B_LATTCHANGED, "Lin", 572, 158, 40, 19, <->typev, 2.0, (float)KEY_LINEAR, 0, 0, ""); - uiDefButC(block, ROW, B_LATTCHANGED, "Card", 612, 158, 40, 19, <->typev, 2.0, (float)KEY_CARDINAL, 0, 0, ""); - uiDefButC(block, ROW, B_LATTCHANGED, "B", 652, 158, 40, 19, <->typev, 2.0, (float)KEY_BSPLINE, 0, 0, ""); + uiDefIconBut(block, BUT, B_MATPRV, ICON_EYE, 159,195,30,20, 0, 0, 0, 0, 0, ""); - uiDefButC(block, ROW, B_LATTCHANGED, "Lin", 572, 138, 40, 19, <->typew, 3.0, (float)KEY_LINEAR, 0, 0, ""); - uiDefButC(block, ROW, B_LATTCHANGED, "Card", 612, 138, 40, 19, <->typew, 3.0, (float)KEY_CARDINAL, 0, 0, ""); - uiDefButC(block, ROW, B_LATTCHANGED, "B", 652, 138, 40, 19, <->typew, 3.0, (float)KEY_BSPLINE, 0, 0, ""); + /* TEX CHANNELS */ + uiBlockSetCol(block, BUTGREY); + xco= 665; + for(a= 0; a<8; a++) { + mtex= ma->mtex[a]; + if(mtex && mtex->tex) splitIDname(mtex->tex->id.name+2, str, &loos); + else strcpy(str, ""); + str[10]= 0; + uiDefButC(block, ROW, B_MATPRV_DRAW, str, xco, 195, 63, 20, &(ma->texact), 3.0, (float)a, 0, 0, ""); + xco+= 65; + } - uiBlockSetCol(block, BUTSALMON); - uiDefBut(block, BUT, B_RESIZELAT, "Make Regular", 470,101,99,32, 0, 0, 0, 0, 0, ""); + uiDefIconBut(block, BUT, B_MTEXCOPY, ICON_COPYUP, (short)xco,195,20,21, 0, 0, 0, 0, 0, "Copy the material settings to the buffer"); + uiDefIconBut(block, BUT, B_MTEXPASTE, ICON_PASTEUP, (short)(xco+20),195,20,21, 0, 0, 0, 0, 0, "Paste the material settings from the buffer"); + uiBlockSetCol(block, BUTGREEN); - uiDefButS(block, TOG|BIT|1, B_LATTCHANGED, "Outside", 571,101,120,31, <->flag, 0, 0, 0, 0, ""); - - uiDrawBlock(block); -} - - -/* *************************** TEXTURE ******************************** */ + uiDefButC(block, TOG, B_MATPRV, "SepT", (short)(xco+40), 195, 40, 20, &(ma->septex), 0, 0, 0, 0, "Render only use active texture channel"); + uiBlockSetCol(block, BUTGREY); -Tex *cur_imatex=0; -int prv_win= 0; + mtex= ma->mtex[ ma->texact ]; + if(mtex==0) { + mtex= &emptytex; + default_mtex(mtex); + } + + /* TEXCO */ + uiBlockSetCol(block, BUTGREEN); + uiDefButS(block, ROW, B_MATPRV, "Object", 694,166,49,18, &(mtex->texco), 4.0, (float)TEXCO_OBJECT, 0, 0, "Use linked object's coordinates for texture coordinates"); + uiDefIDPoinBut(block, test_obpoin_but, B_MATPRV, "", 745,166,133,18, &(mtex->object), ""); + uiDefButS(block, ROW, B_MATPRV, "UV", 664,166,29,18, &(mtex->texco), 4.0, (float)TEXCO_UV, 0, 0, "Use UV coordinates for texture coordinates"); -void load_tex_image(char *str) /* called from fileselect */ -{ - Image *ima=0; - Tex *tex; + uiDefButS(block, ROW, B_MATPRV, "Glob", 665,146,35,18, &(mtex->texco), 4.0, (float)TEXCO_GLOB, 0, 0, "Use global coordinates for the texture coordinates"); + uiDefButS(block, ROW, B_MATPRV, "Orco", 701,146,38,18, &(mtex->texco), 4.0, (float)TEXCO_ORCO, 0, 0, "Use the original coordinates of the mesh"); + uiDefButS(block, ROW, B_MATPRV, "Stick", 739,146,38,18, &(mtex->texco), 4.0, (float)TEXCO_STICKY, 0, 0, "Use mesh sticky coordaintes for the texture coordinates"); + uiDefButS(block, ROW, B_MATPRV, "Win", 779,146,31,18, &(mtex->texco), 4.0, (float)TEXCO_WINDOW, 0, 0, "Use screen coordinates as texture coordinates"); + uiDefButS(block, ROW, B_MATPRV, "Nor", 811,146,32,18, &(mtex->texco), 4.0, (float)TEXCO_NORM, 0, 0, "Use normal vector as texture coordinates"); + uiDefButS(block, ROW, B_MATPRV, "Refl", 844,146,33,18, &(mtex->texco), 4.0, (float)TEXCO_REFL, 0, 0, "Use reflection vector as texture coordinates"); - tex= cur_imatex; - if(tex->type==TEX_IMAGE || tex->type==TEX_ENVMAP) { + uiBlockSetCol(block, BUTGREY); + + /* COORDS */ + uiDefButC(block, ROW, B_MATPRV, "Flat", 666,114,48,18, &(mtex->mapping), 5.0, (float)MTEX_FLAT, 0, 0, "Map X and Y coordinates directly"); + uiDefButC(block, ROW, B_MATPRV, "Cube", 717,114,50,18, &(mtex->mapping), 5.0, (float)MTEX_CUBE, 0, 0, "Map using the normal vector"); + uiDefButC(block, ROW, B_MATPRV, "Tube", 666,94,48,18, &(mtex->mapping), 5.0, (float)MTEX_TUBE, 0, 0, "Map with Z as central axis (tube-like)"); + uiDefButC(block, ROW, B_MATPRV, "Sphe", 716,94,50,18, &(mtex->mapping), 5.0, (float)MTEX_SPHERE, 0, 0, "Map with Z as central axis (sphere-like)"); - ima= add_image(str); - if(ima) { - if(tex->ima) { - tex->ima->id.us--; - } - tex->ima= ima; + xco= 665; + for(a=0; a<4; a++) { + if(a==0) strcpy(str, ""); + else if(a==1) strcpy(str, "X"); + else if(a==2) strcpy(str, "Y"); + else strcpy(str, "Z"); + + uiDefButC(block, ROW, B_MATPRV, str, (short)xco, 50, 24, 18, &(mtex->projx), 6.0, (float)a, 0, 0, ""); + uiDefButC(block, ROW, B_MATPRV, str, (short)xco, 30, 24, 18, &(mtex->projy), 7.0, (float)a, 0, 0, ""); + uiDefButC(block, ROW, B_MATPRV, str, (short)xco, 10, 24, 18, &(mtex->projz), 8.0, (float)a, 0, 0, ""); + xco+= 26; + } + + uiDefButF(block, NUM, B_MATPRV, "ofsX", 778,114,100,18, mtex->ofs, -10.0, 10.0, 10, 0, "Fine tune X coordinate"); + uiDefButF(block, NUM, B_MATPRV, "ofsY", 778,94,100,18, mtex->ofs+1, -10.0, 10.0, 10, 0, "Fine tune Y coordinate"); + uiDefButF(block, NUM, B_MATPRV, "ofsZ", 778,74,100,18, mtex->ofs+2, -10.0, 10.0, 10, 0, "Fine tune Z coordinate"); + uiDefButF(block, NUM, B_MATPRV, "sizeX", 778,50,100,18, mtex->size, -100.0, 100.0, 10, 0, "Set an extra scaling for the texture coordinate"); + uiDefButF(block, NUM, B_MATPRV, "sizeY", 778,30,100,18, mtex->size+1, -100.0, 100.0, 10, 0, "Set an extra scaling for the texture coordinate"); + uiDefButF(block, NUM, B_MATPRV, "sizeZ", 778,10,100,18, mtex->size+2, -100.0, 100.0, 10, 0, "Set an extra scaling for the texture coordinate"); + + /* TEXTUREBLOK SELECT */ + if(G.main->tex.first==0) + id= NULL; + else + id= (ID*) mtex->tex; + IDnames_to_pupstring(&strp, NULL, "ADD NEW %x32767", &(G.main->tex), id, &(G.buts->texnr)); + uiDefButS(block, MENU, B_EXTEXBROWSE, strp, 900,146,20,19, &(G.buts->texnr), 0, 0, 0, 0, "The name of the texture"); + MEM_freeN(strp); - free_image_buffers(ima); /* force reading again */ - ima->ok= 1; + if(id) { + uiDefBut(block, TEX, B_IDNAME, "TE:", 900,166,163,19, id->name+2, 0.0, 18.0, 0, 0, "The name of the texture block"); + sprintf(str, "%d", id->us); + uiDefBut(block, BUT, 0, str, 996,146,21,19, 0, 0, 0, 0, 0, ""); + uiDefIconBut(block, BUT, B_AUTOTEXNAME, ICON_AUTO, 1041,146,21,19, 0, 0, 0, 0, 0, "Auto-assign name to texture"); + if(id->lib) { + if(ma->id.lib) uiDefIconBut(block, BUT, 0, ICON_DATALIB, 1019,146,21,19, 0, 0, 0, 0, 0, ""); + else uiDefIconBut(block, BUT, 0, ICON_PARLIB, 1019,146,21,19, 0, 0, 0, 0, 0, ""); } - - allqueue(REDRAWBUTSTEX, 0); - - BIF_preview_changed(G.buts); + uiBlockSetCol(block, BUTSALMON); + uiDefBut(block, BUT, B_TEXCLEAR, "Clear", 922, 146, 72, 19, 0, 0, 0, 0, 0, "Erase link to datablock"); + uiBlockSetCol(block, BUTGREY); } -} + + /* TEXTURE OUTPUT */ + uiDefButS(block, TOG|BIT|1, B_MATPRV, "Stencil", 900,114,52,18, &(mtex->texflag), 0, 0, 0, 0, "Set the mapping to stencil mode"); + uiDefButS(block, TOG|BIT|2, B_MATPRV, "Neg", 954,114,38,18, &(mtex->texflag), 0, 0, 0, 0, "Reverse the effect of the texture"); + uiDefButS(block, TOG|BIT|0, B_MATPRV, "No RGB", 994,114,69,18, &(mtex->texflag), 0, 0, 0, 0, "Use an RGB texture as an intensity texture"); + + uiDefButF(block, COL, B_MTEXCOL, "", 900,100,163,12, &(mtex->r), 0, 0, 0, 0, "Browse datablocks"); -void load_plugin_tex(char *str) /* called from fileselect */ -{ - Tex *tex; + if(ma->colormodel==MA_HSV) { + uiBlockSetCol(block, BUTPURPLE); + uiDefButF(block, HSVSLI, B_MATPRV, "H ", 900,80,163,18, &(mtex->r), 0.0, 0.9999, B_MTEXCOL, 0, ""); + uiBlockSetCol(block, BUTPURPLE); + uiDefButF(block, HSVSLI, B_MATPRV, "S ", 900,60,163,18, &(mtex->r), 0.0001, 1.0, B_MTEXCOL, 0, ""); + uiBlockSetCol(block, BUTPURPLE); + uiDefButF(block, HSVSLI, B_MATPRV, "V ", 900,40,163,18, &(mtex->r), 0.0001, 1.0, B_MTEXCOL, 0, ""); + uiBlockSetCol(block, BUTGREY); + } + else { + uiDefButF(block, NUMSLI, B_MATPRV, "R ", 900,80,163,18, &(mtex->r), 0.0, 1.0, B_MTEXCOL, 0, "Set the amount of red the intensity texture blends with"); + uiDefButF(block, NUMSLI, B_MATPRV, "G ", 900,60,163,18, &(mtex->g), 0.0, 1.0, B_MTEXCOL, 0, "Set the amount of green the intensity texture blends with"); + uiDefButF(block, NUMSLI, B_MATPRV, "B ", 900,40,163,18, &(mtex->b), 0.0, 1.0, B_MTEXCOL, 0, "Set the amount of blue the intensity texture blends with"); + } - tex= cur_imatex; - if(tex->type!=TEX_PLUGIN) return; + uiDefButF(block, NUMSLI, B_MATPRV, "DVar ", 900,10,163,18, &(mtex->def_var), 0.0, 1.0, 0, 0, "Set the value the texture blends with the current value"); - if(tex->plugin) free_plugin_tex(tex->plugin); + /* MAP TO */ + uiBlockSetCol(block, BUTGREEN); + uiDefButS(block, TOG|BIT|0, B_MATPRV, "Col", 1087,166,35,18, &(mtex->mapto), 0, 0, 0, 0, "Let the texture affect basic colour of the material"); + uiDefButS(block, TOG3|BIT|1, B_MATPRV, "Nor", 1126,166,31,18, &(mtex->mapto), 0, 0, 0, 0, "Let the texture affect the rendered normal"); + uiDefButS(block, TOG|BIT|2, B_MATPRV, "Csp", 1160,166,34,18, &(mtex->mapto), 0, 0, 0, 0, "Let the texture affect the specularity colour"); + uiDefButS(block, TOG|BIT|3, B_MATPRV, "Cmir", 1196,166,35,18, &(mtex->mapto), 0, 0, 0, 0, "Let the texture affext the mirror colour"); + uiDefButS(block, TOG3|BIT|4, B_MATPRV, "Ref", 1234,166,31,18, &(mtex->mapto), 0, 0, 0, 0, "Let the texture affect the value of the materials reflectivity"); + uiDefButS(block, TOG3|BIT|5, B_MATPRV, "Spec", 1087,146,36,18, &(mtex->mapto), 0, 0, 0, 0, "Let the texture affect the value of specularity"); + uiDefButS(block, TOG3|BIT|8, B_MATPRV, "Hard", 1126,146,44,18, &(mtex->mapto), 0, 0, 0, 0, "Let the texture affect the hardness value"); + uiDefButS(block, TOG3|BIT|7, B_MATPRV, "Alpha", 1172,146,45,18, &(mtex->mapto), 0, 0, 0, 0, "Let the texture affect the alpha value"); + uiDefButS(block, TOG3|BIT|6, B_MATPRV, "Emit", 1220,146,45,18, &(mtex->mapto), 0, 0, 0, 0, "Let the texture affect the emit value"); - tex->stype= 0; - tex->plugin= add_plugin_tex(str); +/* uiDefButS(block, TOG|BIT|3, B_MATPRV, "Alpha Mix",1087,114,100,18, &(mtex->texflag), 0, 0, 0, 0); ,""*/ - allqueue(REDRAWBUTSTEX, 0); - BIF_preview_changed(G.buts); + uiBlockSetCol(block, BUTGREY); + uiDefButS(block, ROW, B_MATPRV, "Mix", 1087,94,48,18, &(mtex->blendtype), 9.0, (float)MTEX_BLEND, 0, 0, "The texture blends the values or colour"); + uiDefButS(block, ROW, B_MATPRV, "Mul", 1136,94,44,18, &(mtex->blendtype), 9.0, (float)MTEX_MUL, 0, 0, "The texture multiplies the values or colour"); + uiDefButS(block, ROW, B_MATPRV, "Add", 1182,94,41,18, &(mtex->blendtype), 9.0, (float)MTEX_ADD, 0, 0, "The texture adds the values or colour"); + uiDefButS(block, ROW, B_MATPRV, "Sub", 1226,94,40,18, &(mtex->blendtype), 9.0, (float)MTEX_SUB, 0, 0, "The texture subtracts the values or colour"); + + uiDefButF(block, NUMSLI, B_MATPRV, "Col ", 1087,50,179,18, &(mtex->colfac), 0.0, 1.0, 0, 0, "Set the amount the texture affects colour"); + uiDefButF(block, NUMSLI, B_MATPRV, "Nor ", 1087,30,179,18, &(mtex->norfac), 0.0, 5.0, 0, 0, "Set the amount the texture affects the normal"); + uiDefButF(block, NUMSLI, B_MATPRV, "Var ", 1087,10,179,18, &(mtex->varfac), 0.0, 1.0, 0, 0, "Set the amount the texture affects a value"); + + uiDrawBlock(block); } -int vergcband(const void *a1, const void *a2) -{ - const CBData *x1=a1, *x2=a2; - if( x1->pos > x2->pos ) return 1; - else if( x1->pos < x2->pos) return -1; - return 0; -} +/* ************************ SOUND *************************** */ +static void load_new_sample(char *str) /* called from fileselect */ +{ + char name[FILE_MAXDIR+FILE_MAXFILE]; + bSound *sound; + bSample *sample, *newsample; + sound = G.buts->lockpoin; + if (sound) { + // save values + sample = sound->sample; + strcpy(name, sound->sample->name); -void save_env(char *name) -{ - Tex *tex; - char str[FILE_MAXFILE]; - - strcpy(str, name); - BLI_convertstringcode(str, G.sce, G.scene->r.cfra); - tex= G.buts->lockpoin; - - if(tex && GS(tex->id.name)==ID_TE) { - if(tex->env && tex->env->ok && saveover(str)) { - waitcursor(1); - BIF_save_envmap(tex->env, str); - strcpy(G.ima, name); - waitcursor(0); - } - } - -} + strcpy(sound->name, str); + sound_set_sample(sound, NULL); + sound_initialize_sample(sound); -void drawcolorband(ColorBand *coba, float x1, float y1, float sizex, float sizey) -{ - CBData *cbd; - float v3[2], v1[2], v2[2]; - int a; - - if(coba==0) return; - - /* outline */ - v1[0]= x1; v1[1]= y1; - glLineWidth((GLfloat)(3)); - cpack(0x0); - glBegin(GL_LINE_LOOP); - glVertex2fv(v1); - v1[0]+= sizex; - glVertex2fv(v1); - v1[1]+= sizey; - glVertex2fv(v1); - v1[0]-= sizex; - glVertex2fv(v1); - glEnd(); - glLineWidth((GLfloat)(1)); + if (sound->sample->type == SAMPLE_INVALID) { + error("Not a valid sample: %s", str); + newsample = sound->sample; - glShadeModel(GL_SMOOTH); - cbd= coba->data; - - v1[0]= v2[0]= x1; - v1[1]= y1; - v2[1]= y1+sizey; - - glBegin(GL_QUAD_STRIP); - - glColor3fv( &cbd->r ); - glVertex2fv(v1); glVertex2fv(v2); - - for(a=0; atot; a++, cbd++) { - - v1[0]=v2[0]= x1+ cbd->pos*sizex; + // restore values + strcpy(sound->name, name); + sound_set_sample(sound, sample); - glColor3fv( &cbd->r ); - glVertex2fv(v1); glVertex2fv(v2); - } - - v1[0]=v2[0]= x1+ sizex; - glVertex2fv(v1); glVertex2fv(v2); - - glEnd(); - glShadeModel(GL_FLAT); - - /* help lines */ - - v1[0]= v2[0]=v3[0]= x1; - v1[1]= y1; - v2[1]= y1+0.5*sizey; - v3[1]= y1+sizey; - - cbd= coba->data; - glBegin(GL_LINES); - for(a=0; atot; a++, cbd++) { - v1[0]=v2[0]=v3[0]= x1+ cbd->pos*sizex; - - glColor3ub(0, 0, 0); - glVertex2fv(v1); - glVertex2fv(v2); + // remove invalid sample - if(a==coba->cur) { - glVertex2f(v1[0]-1, v1[1]); - glVertex2f(v2[0]-1, v2[1]); - glVertex2f(v1[0]+1, v1[1]); - glVertex2f(v2[0]+1, v2[1]); - } - - glColor3ub(255, 255, 255); - glVertex2fv(v2); - glVertex2fv(v3); - - if(a==coba->cur) { - glVertex2f(v2[0]-1, v2[1]); - glVertex2f(v3[0]-1, v3[1]); - glVertex2f(v2[0]+1, v2[1]); - glVertex2f(v3[0]+1, v3[1]); + sound_free_sample(newsample); + BLI_remlink(samples, newsample); + MEM_freeN(newsample); } } - glEnd(); - - glFlush(); -} + allqueue(REDRAWBUTSSOUND, 0); + if (curarea) BIF_preview_changed(G.buts); +} -void do_texbuts(unsigned short event) +void do_soundbuts(unsigned short event) { - Tex *tex; - ImBuf *ibuf; - ScrArea *sa; + char name[FILE_MAXDIR+FILE_MAXFILE]; + bSound *sound; + bSample *sample; + bSound* tempsound; ID *id; - CBData *cbd; - float dx; - int a, nr; - short mvalo[2], mval[2]; - char *name, str[80]; - tex= G.buts->lockpoin; + sound = G.buts->lockpoin; - switch(event) { - case B_TEXCHANNEL: - scrarea_queue_headredraw(curarea); - BIF_preview_changed(G.buts); - allqueue(REDRAWBUTSTEX, 0); - break; - case B_TEXTYPE: - if(tex==0) return; - tex->stype= 0; - allqueue(REDRAWBUTSTEX, 0); - BIF_preview_changed(G.buts); - break; - case B_DEFTEXVAR: - if(tex==0) return; - default_tex(tex); - allqueue(REDRAWBUTSTEX, 0); - BIF_preview_changed(G.buts); - break; - case B_LOADTEXIMA: - case B_LOADTEXIMA1: - if(tex==0) return; - /* globals: temporal store them: we make another area a fileselect */ - cur_imatex= tex; - prv_win= curarea->win; - - sa= closest_bigger_area(); - areawinset(sa->win); - if(tex->ima) name= tex->ima->name; -#ifdef _WIN32 - else { - if (strcmp (U.textudir, "/") == 0) - name= G.sce; - else - name= U.textudir; + switch(event) + { + case B_SOUND_REDRAW: + { + allqueue(REDRAWBUTSSOUND, 0); + break; } -#else - else name = U.textudir; -#endif - - if(event==B_LOADTEXIMA) - activate_imageselect(FILE_SPECIAL, "SELECT IMAGE", name, load_tex_image); - else - activate_fileselect(FILE_SPECIAL, "SELECT IMAGE", name, load_tex_image); - - break; - case B_NAMEIMA: - if(tex==0) return; - if(tex->ima) { - cur_imatex= tex; - prv_win= curarea->win; + case B_SOUND_LOAD_SAMPLE: + { + if (sound) strcpy(name, sound->name); + else strcpy(name, U.sounddir); - /* name in tex->ima has been changed by button! */ - strcpy(str, tex->ima->name); - if(tex->ima->ibuf) strcpy(tex->ima->name, tex->ima->ibuf->name); - - load_tex_image(str); + activate_fileselect(FILE_SPECIAL, "SELECT WAV FILE", name, load_new_sample); + break; } - break; - case B_TEXREDR_PRV: - allqueue(REDRAWBUTSTEX, 0); - BIF_preview_changed(G.buts); - break; - case B_TEXIMABROWSE: - if(tex) { - id= (ID*) tex->ima; - - if(G.buts->menunr== -2) { - activate_databrowse(id, ID_IM, 0, B_TEXIMABROWSE, &G.buts->menunr, do_texbuts); - } else if (G.buts->menunr>0) { - Image *newima= (Image*) BLI_findlink(&G.main->image, G.buts->menunr-1); - - if (newima && newima!=(Image*) id) { - tex->ima= newima; - id_us_plus((ID*) newima); - if(id) id->us--; - - allqueue(REDRAWBUTSTEX, 0); - BIF_preview_changed(G.buts); + case B_SOUND_PLAY_SAMPLE: + { + if (sound) + { + if (sound->sample->type != SAMPLE_INVALID) + { + sound_play_sound(sound); + allqueue(REDRAWBUTSSOUND, 0); } } + break; } - break; - case B_IMAPTEST: - if(tex) { - if( (tex->imaflag & (TEX_FIELDS+TEX_MIPMAP))== TEX_FIELDS+TEX_MIPMAP ) { - error("Cannot combine fields and mipmap"); - tex->imaflag -= TEX_MIPMAP; - allqueue(REDRAWBUTSTEX, 0); - } - - if(tex->ima && tex->ima->ibuf) { - ibuf= tex->ima->ibuf; - nr= 0; - if( !(tex->imaflag & TEX_FIELDS) && (ibuf->flags & IB_fields) ) nr= 1; - if( (tex->imaflag & TEX_FIELDS) && !(ibuf->flags & IB_fields) ) nr= 1; - if(nr) { - IMB_freeImBuf(ibuf); - tex->ima->ibuf= 0; - tex->ima->ok= 1; - BIF_preview_changed(G.buts); + case B_SOUND_MENU_SAMPLE: + { + if (G.buts->menunr == -2) { + if (sound) { + activate_databrowse((ID *)sound->sample, ID_SAMPLE, 0, B_SOUND_MENU_SAMPLE, &G.buts->menunr, do_soundbuts); } - } - } - break; - case B_RELOADIMA: - if(tex && tex->ima) { - // check if there is a newer packedfile - - if (tex->ima->packedfile) { - PackedFile *pf; - pf = newPackedFile(tex->ima->name); - if (pf) { - freePackedFile(tex->ima->packedfile); - tex->ima->packedfile = pf; - } else { - error("Image not available. Keeping packed image."); + } else if (G.buts->menunr > 0) { + sample = BLI_findlink(samples, G.buts->menunr - 1); + if (sample && sound) { + BLI_strncpy(sound->name, sample->name, sizeof(sound->name)); + sound_set_sample(sound, sample); + do_soundbuts(B_SOUND_REDRAW); } } - - IMB_freeImBuf(tex->ima->ibuf); - tex->ima->ibuf= 0; - tex->ima->ok= 1; - allqueue(REDRAWBUTSTEX, 0); - allqueue(REDRAWVIEW3D, 0); - allqueue(REDRAWIMAGE, 0); - BIF_preview_changed(G.buts); + + break; } - break; - - case B_TEXSETFRAMES: - if(tex->ima->anim) tex->frames = IMB_anim_get_duration(tex->ima->anim); - allqueue(REDRAWBUTSTEX, 0); - break; - - case B_PACKIMA: - if(tex && tex->ima) { - if (tex->ima->packedfile) { + case B_SOUND_NAME_SAMPLE: + { + load_new_sample(sound->name); + break; + } + case B_SOUND_UNPACK_SAMPLE: + if(sound && sound->sample) { + sample = sound->sample; + + if (sample->packedfile) { if (G.fileflags & G_AUTOPACK) { if (okee("Disable AutoPack ?")) { G.fileflags &= ~G_AUTOPACK; @@ -3419,3393 +2622,985 @@ void do_texbuts(unsigned short event) } if ((G.fileflags & G_AUTOPACK) == 0) { - unpackImage(tex->ima, PF_ASK); + unpackSample(sample, PF_ASK); } } else { - if (tex->ima->ibuf && (tex->ima->ibuf->userflags & IB_BITMAPDIRTY)) { - error("Can't pack painted image. Save image from Image window first."); - } else { - tex->ima->packedfile = newPackedFile(tex->ima->name); - } + sound_set_packedfile(sample, newPackedFile(sample->name)); } - allqueue(REDRAWBUTSTEX, 0); allqueue(REDRAWHEADERS, 0); + do_soundbuts(B_SOUND_REDRAW); } break; - case B_LOADPLUGIN: - if(tex==0) return; - - /* globals: store temporal: we make another area a fileselect */ - cur_imatex= tex; - prv_win= curarea->win; - - sa= closest_bigger_area(); - areawinset(sa->win); - if(tex->plugin) strcpy(str, tex->plugin->name); - else { - strcpy(str, U.plugtexdir); + case B_SOUND_COPY_SOUND: + { + if (sound) + { + tempsound = sound_make_copy(sound); + sound = tempsound; + id = &sound->id; + G.buts->lockpoin = (bSound*)id; + do_soundbuts(B_SOUND_REDRAW); + } + break; } - activate_fileselect(FILE_SPECIAL, "SELECT PLUGIN", str, load_plugin_tex); - - break; - - case B_NAMEPLUGIN: - if(tex==0 || tex->plugin==0) return; - strcpy(str, tex->plugin->name); - free_plugin_tex(tex->plugin); - tex->stype= 0; - tex->plugin= add_plugin_tex(str); - allqueue(REDRAWBUTSTEX, 0); - BIF_preview_changed(G.buts); - break; - - case B_COLORBAND: - if(tex==0) return; - if(tex->coba==0) tex->coba= add_colorband(); - allqueue(REDRAWBUTSTEX, 0); - BIF_preview_changed(G.buts); - break; - - case B_ADDCOLORBAND: - if(tex==0 || tex->coba==0) return; - - if(tex->coba->tot < MAXCOLORBAND-1) tex->coba->tot++; - tex->coba->cur= tex->coba->tot-1; - - do_texbuts(B_CALCCBAND); - - break; - - case B_DELCOLORBAND: - if(tex==0 || tex->coba==0 || tex->coba->tot<2) return; - - for(a=tex->coba->cur; acoba->tot; a++) { - tex->coba->data[a]= tex->coba->data[a+1]; + case B_SOUND_RECALC: + { + waitcursor(1); + sound = G.main->sound.first; + while (sound) + { + MEM_freeN(sound->stream); + sound->stream = 0; + audio_makestream(sound); + sound = (bSound *) sound->id.next; + } + waitcursor(0); + allqueue(REDRAWSEQ, 0); + break; } - if(tex->coba->cur) tex->coba->cur--; - tex->coba->tot--; - - allqueue(REDRAWBUTSTEX, 0); - BIF_preview_changed(G.buts); - break; - - case B_CALCCBAND: - case B_CALCCBAND2: - if(tex==0 || tex->coba==0 || tex->coba->tot<2) return; - - for(a=0; acoba->tot; a++) tex->coba->data[a].cur= a; - qsort(tex->coba->data, tex->coba->tot, sizeof(CBData), vergcband); - for(a=0; acoba->tot; a++) { - if(tex->coba->data[a].cur==tex->coba->cur) { - if(tex->coba->cur!=a) addqueue(curarea->win, REDRAW, 0); /* button cur */ - tex->coba->cur= a; - break; - } - } - if(event==B_CALCCBAND2) return; - - allqueue(REDRAWBUTSTEX, 0); - BIF_preview_changed(G.buts); - - break; - - case B_DOCOLORBAND: - if(tex==0 || tex->coba==0) return; - - cbd= tex->coba->data + tex->coba->cur; - uiGetMouse(mywinget(), mvalo); - - while(get_mbut() & L_MOUSE) { - uiGetMouse(mywinget(), mval); - if(mval[0]!=mvalo[0]) { - dx= mval[0]-mvalo[0]; - dx/= 345.0; - cbd->pos+= dx; - CLAMP(cbd->pos, 0.0, 1.0); - - glDrawBuffer(GL_FRONT); - drawcolorband(tex->coba, 923,81,345,20); - /* uiSetButs(B_CALCCBAND, B_CALCCBAND); */ - glDrawBuffer(GL_BACK); - - do_texbuts(B_CALCCBAND2); - cbd= tex->coba->data + tex->coba->cur; /* because qsort */ - - mvalo[0]= mval[0]; - } - BIF_wait_for_statechange(); - } - allqueue(REDRAWBUTSTEX, 0); - BIF_preview_changed(G.buts); - - break; - - case B_REDRAWCBAND: - glDrawBuffer(GL_FRONT); - drawcolorband(tex->coba, 923,81,345,20); - glDrawBuffer(GL_BACK); - BIF_preview_changed(G.buts); - break; - - case B_ENV_DELETE: - if(tex->env) { - RE_free_envmap(tex->env); - tex->env= 0; - allqueue(REDRAWBUTSTEX, 0); - BIF_preview_changed(G.buts); - } - break; - case B_ENV_FREE: - if(tex->env) { - RE_free_envmapdata(tex->env); - allqueue(REDRAWBUTSTEX, 0); + case B_SOUND_RATECHANGED: + { + allqueue(REDRAWBUTSSOUND, 0); + allqueue(REDRAWSEQ, 0); + break; + } + case B_SOUND_MIXDOWN: + { + audio_mixdown(); + break; + } + case B_SOUND_LOOPSTART: + { +#ifdef SOUND_UNDER_DEVELOPMENT +/* if (sound->loopstart > sound->loopend) + sound->loopstart = sound->loopend;*/ +#endif + allqueue(REDRAWBUTSSOUND, 0); BIF_preview_changed(G.buts); + break; } - break; - case B_ENV_FREE_ALL: - tex= G.main->tex.first; - while(tex) { - if(tex->id.us && tex->type==TEX_ENVMAP) { - if(tex->env) { - if(tex->env->stype!=ENV_LOAD) RE_free_envmapdata(tex->env); - } - } - tex= tex->id.next; - } - allqueue(REDRAWBUTSTEX, 0); - BIF_preview_changed(G.buts); - break; - case B_ENV_SAVE: - if(tex->env && tex->env->ok) { - sa= closest_bigger_area(); - areawinset(sa->win); - save_image_filesel_str(str); - activate_fileselect(FILE_SPECIAL, str, G.ima, save_env); - } - break; - case B_ENV_OB: - if(tex->env && tex->env->object) { + case B_SOUND_LOOPEND: + { +#ifdef SOUND_UNDER_DEVELOPMENT +/* if (sound->loopend < sound->loopstart) + sound->loopend = sound->loopstart;*/ +#endif + allqueue(REDRAWBUTSSOUND, 0); BIF_preview_changed(G.buts); - if ELEM(tex->env->object->type, OB_CAMERA, OB_LAMP) { - error("Camera or Lamp not allowed"); - tex->env->object= 0; - } + break; } - break; - + default: - if(event>=B_PLUGBUT && event<=B_PLUGBUT+23) { - PluginTex *pit= tex->plugin; - if(pit && pit->callback) { - pit->callback(event - B_PLUGBUT); - BIF_preview_changed(G.buts); + { + if (G.f & G_DEBUG) + { + printf("do_soundbuts: unhandled event %d\n", event); } + break; } } } -static void test_idbutton_cb(void *namev, void *arg2_unused) -{ - char *name= namev; - test_idbutton(name+2); -} -void texbuts(void) +void soundbuts(void) { - Object *ob; - Material *ma=0; - World *wrld=0; - Lamp *la=0; - ID *id = NULL; - MTex *mtex = NULL; - Tex *tex; - VarStruct *varstr; - PluginTex *pit; - CBData *cbd; - EnvMap *env; + short xco, yco, xcostart = 20; + bSound *sound; + bSample *sample; uiBlock *block; - uiBut *but; - int a, xco, yco, loos, dx, dy, ok; - char str[30], *strp; + char *strp, str[32]; + ID *id; + char ch[20]; + char sampleinfo[200]; + char mixrateinfo[50]; + int mixrate; + sound = G.buts->lockpoin; + if ((sound) && (sound->flags & SOUND_FLAGS_SEQUENCE)) sound = 0; + yco = 195; + + xco = xcostart; sprintf(str, "buttonswin %d", curarea->win); block= uiNewBlock(&curarea->uiblocks, str, UI_EMBOSSX, UI_HELV, curarea->win); + + if (sound) + { + sound_initialize_sample(sound); - uiBlockSetCol(block, BUTSALMON); + sample = sound->sample; - uiDefButC(block, ROW, B_TEXREDR_PRV, "Mat", 200,172,40,20, &G.buts->texfrom, 3.0, 0.0, 0, 0, "Display the texture of the active material"); - uiDefButC(block, ROW, B_TEXREDR_PRV, "World", 240,172,52,20, &G.buts->texfrom, 3.0, 1.0, 0, 0, "Display the texture of the world block"); - uiDefButC(block, ROW, B_TEXREDR_PRV, "Lamp", 292,172,46,20, &G.buts->texfrom, 3.0, 2.0, 0, 0, "Display the texture of the lamp"); - uiBlockSetCol(block, BUTGREY); - - ok= 0; - - if(G.buts->texfrom==0) { - ob= OBACT; - if(ob) { - id= ob->data; - if(id) { - ma= give_current_material(ob, ob->actcol); - if(ma) ok= 1; - } - } + uiSetButLock(sound->id.lib!=0, "Can't edit library data"); + + /* sound settings ------------------------------------------------------------------ */ + + uiDefBut(block, LABEL, 0, "Game sounds",xco,yco,195,20, 0, 0, 0, 0, 0, ""); + + yco -= 30; + uiBlockSetCol(block, BUTGREEN); + uiDefBut(block, BUT, B_SOUND_PLAY_SAMPLE, "Play", xco, yco, 195, 24, 0, 0.0, 0, 0, 0, + "Playback sample using settings below"); - } - else if(G.buts->texfrom==1) { - wrld= G.scene->world; - if(wrld) { - id= (ID *)wrld; - ok= 1; + uiBlockSetCol(block, BUTGREY); + xco += 225; + + if (sound->sample && sound->sample->len) + { + if (sound->sample->channels == 1) + strcpy(ch, "Mono"); + else if (sound->sample->channels == 2) + strcpy(ch, "Stereo"); + else + strcpy(ch, "Unknown"); + + uiDefBut(block, LABEL, 0, "Sample: ",xco,yco,195,20, 0, 0, 0, 0, 0, ""); + xco +=55; + sprintf(sampleinfo, "%s, %d bit, %d Hz, %d samples", ch, sound->sample->bits, sound->sample->rate, (sound->sample->len/(sound->sample->bits/8)/sound->sample->channels)); + uiDefBut(block, LABEL, 0, sampleinfo,xco,yco,295,20, 0, 0, 0, 0, 0, ""); } - } - else if(G.buts->texfrom==2) { - ob= OBACT; - if(ob) { - if(ob->type==OB_LAMP) { - la= ob->data; - id= (ID *)la; - ok= 1; - } + else + { + uiDefBut(block, LABEL, 0, "No sample info available.",xco,yco,195,20, 0, 0, 0, 0, 0, ""); + xco +=55; } - } - - if(ok==0) { - uiDrawBlock(block); - return; - } - - uiSetButLock(id->lib!=0, "Can't edit library data"); - /* CHANNELS */ - yco= 140; - for(a= 0; a<8; a++) { - if(G.buts->texfrom==0) mtex= ma->mtex[a]; - else if(G.buts->texfrom==1) mtex= wrld->mtex[a]; - else if(G.buts->texfrom==2) mtex= la->mtex[a]; - - if(mtex && mtex->tex) splitIDname(mtex->tex->id.name+2, str, &loos); - else strcpy(str, ""); - str[14]= 0; - if(G.buts->texfrom==0) { - uiDefButC(block, ROW, B_TEXCHANNEL, str, 200,(short)yco,140,18, &(ma->texact), 0.0, (float)a, 0, 0, "Linked channel"); - } - else if(G.buts->texfrom==1) { - uiDefButS(block, ROW, B_TEXCHANNEL, str, 200,(short)yco,140,18, &(wrld->texact), 0.0, (float)a, 0, 0, ""); - if(a==5) break; - } - else if(G.buts->texfrom==2) { - uiDefButS(block, ROW, B_TEXCHANNEL, str, 200,(short)yco,140,18, &(la->texact), 0.0, (float)a, 0, 0, ""); - if(a==5) break; - } - yco-= 19; - } - - if(G.buts->texfrom==0) { - but= uiDefBut(block, TEX, B_IDNAME, "MA:", 200,195,140,20, ma->id.name+2, 0.0, 18.0, 0, 0, "Name of the datablock"); - uiButSetFunc(but, test_idbutton_cb, ma->id.name, NULL); - mtex= ma->mtex[ ma->texact ]; - } - else if(G.buts->texfrom==1) { - but= uiDefBut(block, TEX, B_IDNAME, "WO:", 200,195,140,20, wrld->id.name+2, 0.0, 18.0, 0, 0, "Name of the datablock"); - uiButSetFunc(but, test_idbutton_cb, wrld->id.name, NULL); - mtex= wrld->mtex[ wrld->texact ]; - } - else if(G.buts->texfrom==2) { - but= uiDefBut(block, TEX, B_IDNAME, "LA:", 200,195,140,20, la->id.name+2, 0.0, 18.0, 0, 0, "Name of the datablock"); - uiButSetFunc(but, test_idbutton_cb, la->id.name, NULL); - mtex= la->mtex[ la->texact ]; - } - - if(mtex && mtex->tex) { - tex= mtex->tex; - - uiSetButLock(tex->id.lib!=0, "Can't edit library data"); - xco= 275; - uiDefButS(block, ROW, B_TEXTYPE, texstr[0], (short)(xco+=75), 195, 75, 20, &tex->type, 1.0, 0.0, 0, 0, "Default"); - uiDefButS(block, ROW, B_TEXTYPE, texstr[TEX_IMAGE],(short)(xco+=75), 195, 75, 20, &tex->type, 1.0, (float)TEX_IMAGE, 0, 0, "Use image texture"); - uiDefButS(block, ROW, B_TEXTYPE, texstr[TEX_ENVMAP], (short)(xco+=75), 195, 75, 20, &tex->type, 1.0, (float)TEX_ENVMAP, 0, 0, "Use environment maps"); - if(tex->plugin && tex->plugin->doit) strp= tex->plugin->pname; else strp= texstr[TEX_PLUGIN]; - uiDefButS(block, ROW, B_TEXTYPE, strp, (short)(xco+=75), 195, 75, 20, &tex->type, 1.0, (float)TEX_PLUGIN, 0, 0, "Use plugin"); - uiDefButS(block, ROW, B_TEXTYPE, texstr[TEX_CLOUDS], (short)(xco+=75), 195, 75, 20, &tex->type, 1.0, (float)TEX_CLOUDS, 0, 0, "Use clouds texture"); - uiDefButS(block, ROW, B_TEXTYPE, texstr[TEX_WOOD], (short)(xco+=75), 195, 75, 20, &tex->type, 1.0, (float)TEX_WOOD, 0, 0, "Use wood texture"); - uiDefButS(block, ROW, B_TEXTYPE, texstr[TEX_MARBLE], (short)(xco+=75), 195, 75, 20, &tex->type, 1.0, (float)TEX_MARBLE, 0, 0, "Use marble texture"); - uiDefButS(block, ROW, B_TEXTYPE, texstr[TEX_MAGIC], (short)(xco+=75), 195, 75, 20, &tex->type, 1.0, (float)TEX_MAGIC, 0, 0, "Use magic texture"); - uiDefButS(block, ROW, B_TEXTYPE, texstr[TEX_BLEND], (short)(xco+=75), 195, 75, 20, &tex->type, 1.0, (float)TEX_BLEND, 0, 0, "Use blend texture"); - uiDefButS(block, ROW, B_TEXTYPE, texstr[TEX_STUCCI], (short)(xco+=75), 195, 75, 20, &tex->type, 1.0, (float)TEX_STUCCI, 0, 0, "Use strucci texture"); - uiDefButS(block, ROW, B_TEXTYPE, texstr[TEX_NOISE], (short)(xco+=75), 195, 75, 20, &tex->type, 1.0, (float)TEX_NOISE, 0, 0, "Use noise texture"); - - /* TYPES */ - uiBlockSetCol(block, BUTGREEN); - switch(tex->type) { - case TEX_CLOUDS: - uiDefButS(block, ROW, B_MATPRV, "Default", 350, 170, 75, 18, &tex->stype, 2.0, 0.0, 0, 0, "Use standard noise"); - uiDefButS(block, ROW, B_MATPRV, "Color", 425, 170, 75, 18, &tex->stype, 2.0, 1.0, 0, 0, "Let Noise give RGB value"); - uiBlockSetCol(block, BUTGREY); - uiDefButF(block, NUM, B_MATPRV, "NoiseSize :", 350, 110, 150, 19, &tex->noisesize, 0.0001, 2.0, 10, 0, "Set the dimension of the noise table"); - uiDefButS(block, NUM, B_MATPRV, "NoiseDepth:", 350, 90, 150, 19, &tex->noisedepth, 0.0, 6.0, 0, 0, "Set the depth of the cloud calculation"); - uiBlockSetCol(block, BUTGREEN); - uiDefButS(block, ROW, B_MATPRV, "Soft noise", 350, 40, 100, 19, &tex->noisetype, 12.0, 0.0, 0, 0, "Use soft noise"); - uiDefButS(block, ROW, B_MATPRV, "Hard noise", 450, 40, 100, 19, &tex->noisetype, 12.0, 1.0, 0, 0, "Use hard noise"); - break; - - case TEX_WOOD: - uiDefButS(block, ROW, B_MATPRV, "Bands", 350, 170, 75, 18, &tex->stype, 2.0, 0.0, 0, 0, "Use standard wood texture"); - uiDefButS(block, ROW, B_MATPRV, "Rings", 425, 170, 75, 18, &tex->stype, 2.0, 1.0, 0, 0, "Use wood rings"); - uiDefButS(block, ROW, B_MATPRV, "BandNoise", 500, 170, 75, 18, &tex->stype, 2.0, 2.0, 0, 0, "Add noise to standard wood"); - uiDefButS(block, ROW, B_MATPRV, "RingNoise", 575, 170, 75, 18, &tex->stype, 2.0, 3.0, 0, 0, "Add noise to rings"); - uiBlockSetCol(block, BUTGREY); - uiDefButF(block, NUM, B_MATPRV, "NoiseSize :", 350, 110, 150, 19, &tex->noisesize, 0.0001, 2.0, 10, 0, "Set the dimension of the noise table"); - uiDefButF(block, NUM, B_MATPRV, "Turbulence:", 350, 90, 150, 19, &tex->turbul, 0.0, 200.0, 10, 0, "Set the turbulence of the bandnoise and ringnoise types"); - uiBlockSetCol(block, BUTGREEN); - uiDefButS(block, ROW, B_MATPRV, "Soft noise", 350, 40, 100, 19, &tex->noisetype, 12.0, 0.0, 0, 0, "Use soft noise"); - uiDefButS(block, ROW, B_MATPRV, "Hard noise", 450, 40, 100, 19, &tex->noisetype, 12.0, 1.0, 0, 0, "Use hard noise"); - break; - - case TEX_MARBLE: - uiDefButS(block, ROW, B_MATPRV, "Soft", 350, 170, 75, 18, &tex->stype, 2.0, 0.0, 0, 0, "Use soft marble"); - uiDefButS(block, ROW, B_MATPRV, "Sharp", 425, 170, 75, 18, &tex->stype, 2.0, 1.0, 0, 0, "Use more clearly defined marble"); - uiDefButS(block, ROW, B_MATPRV, "Sharper", 500, 170, 75, 18, &tex->stype, 2.0, 2.0, 0, 0, "Use very clear defined marble"); - uiBlockSetCol(block, BUTGREY); - uiDefButF(block, NUM, B_MATPRV, "NoiseSize :", 350, 110, 150, 19, &tex->noisesize, 0.0001, 2.0, 10, 0, "Set the dimension of the noise table"); - uiDefButS(block, NUM, B_MATPRV, "NoiseDepth:", 350, 90, 150, 19, &tex->noisedepth, 0.0, 6.0, 0, 0, "Set the depth of the marble calculation"); - uiDefButF(block, NUM, B_MATPRV, "Turbulence:", 350, 70, 150, 19, &tex->turbul, 0.0, 200.0, 10, 0, "Set the turbulence of the sine bands"); - uiBlockSetCol(block, BUTGREEN); - uiDefButS(block, ROW, B_MATPRV, "Soft noise", 350, 40, 100, 19, &tex->noisetype, 12.0, 0.0, 0, 0, "Use soft noise"); - uiDefButS(block, ROW, B_MATPRV, "Hard noise", 450, 40, 100, 19, &tex->noisetype, 12.0, 1.0, 0, 0, "Use hard noise"); - break; - - case TEX_MAGIC: - uiBlockSetCol(block, BUTGREY); - uiDefButF(block, NUM, B_MATPRV, "Size :", 350, 110, 150, 19, &tex->noisesize, 0.0001, 2.0, 10, 0, "Set the dimension of the pattern"); - uiDefButS(block, NUM, B_MATPRV, "Depth:", 350, 90, 150, 19, &tex->noisedepth, 0.0, 10.0, 0, 0, "Set the depth of the pattern"); - uiDefButF(block, NUM, B_MATPRV, "Turbulence:", 350, 70, 150, 19, &tex->turbul, 0.0, 200.0, 10, 0, "Set the strength of the pattern"); - break; - - case TEX_BLEND: - uiDefButS(block, ROW, B_MATPRV, "Lin", 350, 170, 75, 18, &tex->stype, 2.0, 0.0, 0, 0, "Use a linear progresion"); - uiDefButS(block, ROW, B_MATPRV, "Quad", 425, 170, 75, 18, &tex->stype, 2.0, 1.0, 0, 0, "Use a quadratic progression"); - uiDefButS(block, ROW, B_MATPRV, "Ease", 500, 170, 75, 18, &tex->stype, 2.0, 2.0, 0, 0, ""); - uiDefButS(block, ROW, B_MATPRV, "Diag", 575, 170, 75, 18, &tex->stype, 2.0, 3.0, 0, 0, "Use a diagonal progression"); - uiDefButS(block, ROW, B_MATPRV, "Sphere", 650, 170, 75, 18, &tex->stype, 2.0, 4.0, 0, 0, "Use progression with the shape of a sphere"); - uiDefButS(block, ROW, B_MATPRV, "Halo", 725, 170, 75, 18, &tex->stype, 2.0, 5.0, 0, 0, "Use a quadratic progression with the shape of a sphere"); - - uiDefButS(block, TOG|BIT|1, B_MATPRV, "Flip XY", 350, 130, 75, 18, &tex->flag, 0, 0, 0, 0, "Flip the direction of the progression a quarter turn"); - break; - - case TEX_STUCCI: - uiDefButS(block, ROW, B_MATPRV, "Plastic", 350, 170, 75, 18, &tex->stype, 2.0, 0.0, 0, 0, "Use standard stucci"); - uiDefButS(block, ROW, B_MATPRV, "Wall In", 425, 170, 75, 18, &tex->stype, 2.0, 1.0, 0, 0, "Set start value"); - uiDefButS(block, ROW, B_MATPRV, "Wall Out", 500, 170, 75, 18, &tex->stype, 2.0, 2.0, 0, 0, "Set end value"); - uiBlockSetCol(block, BUTGREY); - uiDefButF(block, NUM, B_MATPRV, "NoiseSize :", 350, 110, 150, 19, &tex->noisesize, 0.0001, 2.0, 10, 0, "Set the dimension of the noise table"); - uiDefButF(block, NUM, B_MATPRV, "Turbulence:", 350, 90, 150, 19, &tex->turbul, 0.0, 200.0, 10, 0, "Set the depth of the stucci"); - uiBlockSetCol(block, BUTGREEN); - uiDefButS(block, ROW, B_MATPRV, "Soft noise", 350, 40, 100, 19, &tex->noisetype, 12.0, 0.0, 0, 0, "Use soft noise"); - uiDefButS(block, ROW, B_MATPRV, "Hard noise", 450, 40, 100, 19, &tex->noisetype, 12.0, 1.0, 0, 0, "Use hard noise"); - - break; - - case TEX_NOISE: - break; - - case TEX_IMAGE: - - break; - } - - uiBlockSetCol(block, BUTSALMON); - uiDefBut(block, BUT, B_DEFTEXVAR, "Default Vars", 1180,169,93,47, 0, 0, 0, 0, 0, "Return to standard values"); - - uiBlockSetCol(block, BUTGREY); - /* SPECIFIC */ - if(tex->type==TEX_IMAGE) { - uiDefButF(block, NUM, B_REDR, "MinX ", 350,30,140,19, &tex->cropxmin, -10.0, 10.0, 10, 0, "Set minimum X value for cropping"); - uiDefButF(block, NUM, B_REDR, "MaxX ", 350,10,140,19, &tex->cropxmax, -10.0, 10.0, 10, 0, "Set maximum X value for cropping"); - uiDefButF(block, NUM, B_REDR, "MinY ", 494,30,140,19, &tex->cropymin, -10.0, 10.0, 10, 0, "Set minimum Y value for cropping"); - uiDefButF(block, NUM, B_REDR, "MaxY ", 494,10,140,19, &tex->cropymax, -10.0, 10.0, 10, 0, "Set maximum Y value for cropping"); - - - uiDefButS(block, ROW, 0, "Extend", 350,85,69,19, &tex->extend, 4.0, 1.0, 0, 0, "Extend the colour of the edge"); - uiDefButS(block, ROW, 0, "Clip", 421,85,59,19, &tex->extend, 4.0, 2.0, 0, 0, "Return alpha 0.0 outside image"); - uiDefButS(block, ROW, 0, "Repeat", 565,85,68,19, &tex->extend, 4.0, 3.0, 0, 0, "Repeat image horizontally and vertically"); - uiDefButS(block, ROW, 0, "ClipCube", 482,85,82,19, &tex->extend, 4.0, 4.0, 0, 0, "Return alpha 0.0 outside cubeshaped area around image"); - - uiDefButF(block, NUM, B_MATPRV, "Filter :", 352,109,135,19, &tex->filtersize, 0.1, 25.0, 0, 0, "Set the filter size used by mipmap and interpol"); - - uiDefButS(block, NUM, B_MATPRV, "Xrepeat:", 350,60,140,19, &tex->xrepeat, 1.0, 512.0, 0, 0, "Set the degree of repetition in the X direction"); - uiDefButS(block, NUM, B_MATPRV, "Yrepeat:", 494,60,140,19, &tex->yrepeat, 1.0, 512.0, 0, 0, "Set the degree of repetition in the Y direction"); - - uiDefButS(block, NUM, B_MATPRV, "Frames :", 642,110,150,19, &tex->frames, 0.0, 18000.0, 0, 0, "Activate animation option"); - uiDefButS(block, NUM, B_MATPRV, "Offset :", 642,90,150,19, &tex->offset, -9000.0, 9000.0, 0, 0, "Set the number of the first picture of the animation"); - uiDefButS(block, NUM, B_MATPRV, "Fie/Ima:", 642,60,98,19, &tex->fie_ima, 1.0, 200.0, 0, 0, "Set the number of fields per rendered frame"); - uiDefButS(block, NUM, B_MATPRV, "StartFr:", 642,30,150,19, &tex->sfra, 1.0, 9000.0, 0, 0, "Set the start frame of the animation"); - uiDefButS(block, NUM, B_MATPRV, "Len:", 642,10,150,19, &tex->len, 0.0, 9000.0, 0, 0, "Set the length of the animation"); - - uiDefButS(block, NUM, B_MATPRV, "Fra:", 802,70,73,19, &(tex->fradur[0][0]), 0.0, 18000.0, 0, 0, "Montage mode: frame start"); - uiDefButS(block, NUM, B_MATPRV, "", 879,70,37,19, &(tex->fradur[0][1]), 0.0, 250.0, 0, 0, "Montage mode: amount of displayed frames"); - uiDefButS(block, NUM, B_MATPRV, "Fra:", 802,50,73,19, &(tex->fradur[1][0]), 0.0, 18000.0, 0, 0, "Montage mode: frame start"); - uiDefButS(block, NUM, B_MATPRV, "", 879,50,37,19, &(tex->fradur[1][1]), 0.0, 250.0, 0, 0, "Montage mode: amount of displayed frames"); - uiDefButS(block, NUM, B_MATPRV, "Fra:", 802,30,73,19, &(tex->fradur[2][0]), 0.0, 18000.0, 0, 0, "Montage mode: frame start"); - uiDefButS(block, NUM, B_MATPRV, "", 879,30,37,19, &(tex->fradur[2][1]), 0.0, 250.0, 0, 0, "Montage mode: amount of displayed frames"); - uiDefButS(block, NUM, B_MATPRV, "Fra:", 802,10,73,19, &(tex->fradur[3][0]), 0.0, 18000.0, 0, 0, "Montage mode: frame start"); - uiDefButS(block, NUM, B_MATPRV, "", 879,10,37,19, &(tex->fradur[3][1]), 0.0, 250.0, 0, 0, "Montage mode: amount of displayed frames"); - - uiBlockSetCol(block, BUTGREEN); - uiDefButS(block, TOG|BIT|6, 0, "Cyclic", 743,60,48,19, &tex->imaflag, 0, 0, 0, 0, "Repeat animation image"); - - uiBlockSetCol(block, BUTSALMON); - uiDefBut(block, BUT, B_LOADTEXIMA, "Load Image", 350,137,132,24, 0, 0, 0, 0, 0, "Load image - thumbnail view"); - uiBlockSetCol(block, BUTGREY); - uiDefBut(block, BUT, B_LOADTEXIMA1, "", 485,137,10,24, 0, 0, 0, 0, 0, "Load image - file view"); - - id= (ID *)tex->ima; - IDnames_to_pupstring(&strp, NULL, NULL, &(G.main->image), id, &(G.buts->menunr)); - if(strp[0]) - uiDefButS(block, MENU, B_TEXIMABROWSE, strp, 496,137,23,24, &(G.buts->menunr), 0, 0, 0, 0, "Browse"); - MEM_freeN(strp); - - if(tex->ima) { - uiDefBut(block, TEX, B_NAMEIMA, "", 520,137,412,24, tex->ima->name, 0.0, 79.0, 0, 0, "Texture name"); - sprintf(str, "%d", tex->ima->id.us); - uiDefBut(block, BUT, 0, str, 934,137,23,24, 0, 0, 0, 0, 0, "Number of users"); - uiDefBut(block, BUT, B_RELOADIMA, "Reload", 986,137,68,24, 0, 0, 0, 0, 0, "Reload"); - - if (tex->ima->packedfile) { - packdummy = 1; - } else { - packdummy = 0; - } - uiDefIconButI(block, TOG|BIT|0, B_PACKIMA, ICON_PACKAGE, 960,137,24,24, &packdummy, 0, 0, 0, 0, "Pack/Unpack this Image"); - } - - uiBlockSetCol(block, BUTGREEN); - - uiDefButS(block, TOG|BIT|0, 0, "InterPol", 350, 170, 75, 18, &tex->imaflag, 0, 0, 0, 0, "Interpolate pixels of the image"); - uiDefButS(block, TOG|BIT|1, B_MATPRV, "UseAlpha", 425, 170, 75, 18, &tex->imaflag, 0, 0, 0, 0, "Use the alpha layer"); - uiDefButS(block, TOG|BIT|5, B_MATPRV, "CalcAlpha", 500, 170, 75, 18, &tex->imaflag, 0, 0, 0, 0, "Calculate an alpha based on the RGB"); - uiDefButS(block, TOG|BIT|2, B_MATPRV, "NegAlpha", 575, 170, 75, 18, &tex->flag, 0, 0, 0, 0, "Reverse the alpha value"); - uiDefButS(block, TOG|BIT|2, B_IMAPTEST, "MipMap", 650, 170, 75, 18, &tex->imaflag, 0, 0, 0, 0, "Generate a series of pictures used for mipmapping"); - uiDefButS(block, TOG|BIT|3, B_IMAPTEST, "Fields", 725, 170, 75, 18, &tex->imaflag, 0, 0, 0, 0, "Work with field images"); - uiDefButS(block, TOG|BIT|4, B_MATPRV, "Rot90", 800, 170, 50, 18, &tex->imaflag, 0, 0, 0, 0, "Rotate image 90 degrees when rendered"); - uiDefButS(block, TOG|BIT|7, B_RELOADIMA, "Movie", 850, 170, 50, 18, &tex->imaflag, 0, 0, 0, 0, "Use a movie for an image"); - uiDefButS(block, TOG|BIT|8, 0, "Anti", 900, 170, 50, 18, &tex->imaflag, 0, 0, 0, 0, "Use anti-aliasing"); - uiDefButS(block, TOG|BIT|10, 0, "StField", 950, 170, 50, 18, &tex->imaflag, 0, 0, 0, 0, ""); - - uiBlockSetCol(block, BUTGREY); - - /* print amount of frames anim */ - if(tex->ima && tex->ima->anim) { - uiDefBut(block, BUT, B_TEXSETFRAMES, "<", 802, 110, 20, 18, 0, 0, 0, 0, 0, "Paste number of frames in Frames: button"); - sprintf(str, "%d frs ", IMB_anim_get_duration(tex->ima->anim)); - uiDefBut(block, LABEL, 0, str, 834, 110, 90, 18, 0, 0, 0, 0, 0, ""); - sprintf(str, "%d cur ", tex->ima->lastframe); - uiDefBut(block, LABEL, 0, str, 834, 90, 90, 18, 0, 0, 0, 0, 0, ""); - } - - - } - else if(tex->type==TEX_PLUGIN) { - if(tex->plugin && tex->plugin->doit) { - - pit= tex->plugin; - - uiBlockSetCol(block, BUTGREEN); - for(a=0; astypes; a++) { - uiDefButS(block, ROW, B_MATPRV, pit->stnames+16*a, (short)(350+75*a), 170, 75, 18, &tex->stype, 2.0, (float)a, 0, 0, ""); - } - - uiBlockSetCol(block, BUTGREY); - varstr= pit->varstr; - if(varstr) { - for(a=0; avars; a++, varstr++) { - xco= 350 + 140*(a/6); - yco= 110 - 20*(a % 6); - pit->data[a] = varstr->def; - uiDefBut(block, varstr->type, B_PLUGBUT+a, varstr->name, (short)xco,(short)yco,137,19, &(pit->data[a]), varstr->min, varstr->max, 100, 0, varstr->tip); - } - } - uiDefBut(block, TEX, B_NAMEPLUGIN, "", 520,137,412,24, pit->name, 0.0, 159.0, 0, 0, "Browse"); - } - - uiBlockSetCol(block, BUTSALMON); - uiDefBut(block, BUT, B_LOADPLUGIN, "Load Plugin", 350,137,137,24, 0, 0, 0, 0, 0, ""); - - } - else if(tex->type==TEX_ENVMAP) { - - if(tex->env==0) { - tex->env= RE_add_envmap(); - tex->env->object= OBACT; - } - if(tex->env) { - env= tex->env; - - uiBlockSetCol(block, BUTGREEN); - uiDefButS(block, ROW, B_REDR, "Static", 350, 170, 75, 18, &env->stype, 2.0, 0.0, 0, 0, "Calculate map only once"); - uiDefButS(block, ROW, B_REDR, "Anim", 425, 170, 75, 18, &env->stype, 2.0, 1.0, 0, 0, "Calculate map each rendering"); - uiDefButS(block, ROW, B_ENV_FREE, "Load", 500, 170, 75, 18, &env->stype, 2.0, 2.0, 0, 0, "Load map from disk"); - - if(env->stype==ENV_LOAD) { - uiBlockSetCol(block, BUTSALMON); - uiDefBut(block, BUT, B_LOADTEXIMA, "Load Image", 350,137,132,24, 0, 0, 0, 0, 0, "Load image - thumbnail view"); - uiBlockSetCol(block, BUTGREY); - uiDefBut(block, BUT, B_LOADTEXIMA1, "", 485,137,10,24, 0, 0, 0, 0, 0, "Load image - file view"); - - id= (ID *)tex->ima; - IDnames_to_pupstring(&strp, NULL, NULL, &(G.main->image), id, &(G.buts->menunr)); - if(strp[0]) - uiDefButS(block, MENU, B_TEXIMABROWSE, strp, 496,137,23,24, &(G.buts->menunr), 0, 0, 0, 0, ""); - MEM_freeN(strp); - - if(tex->ima) { - uiDefBut(block, TEX, B_NAMEIMA, "", 520,137,412,24, tex->ima->name, 0.0, 79.0, 0, 0, ""); - sprintf(str, "%d", tex->ima->id.us); - uiDefBut(block, BUT, 0, str, 934,137,23,24, 0, 0, 0, 0, 0, ""); - if (tex->ima->packedfile) { - packdummy = 1; - } else { - packdummy = 0; - } - uiDefIconButI(block, TOG|BIT|0, B_PACKIMA, ICON_PACKAGE, 960,137,24,24, &packdummy, 0, 0, 0, 0, "Pack/Unpack this Image"); - uiDefBut(block, BUT, B_RELOADIMA, "Reload", 986,137,68,24, 0, 0, 0, 0, 0, ""); - } - } - else { - uiBlockSetCol(block, BUTSALMON); - uiDefBut(block, BUT, B_ENV_FREE, "Free Data", 350,137,107,24, 0, 0, 0, 0, 0, "Release all images associated with environment map"); - uiBlockSetCol(block, BUTGREY); - uiDefBut(block, BUT, B_ENV_SAVE, "Save EnvMap", 461,137,115,24, 0, 0, 0, 0, 0, "Save environment map"); - uiBlockSetCol(block, BUTSALMON); - uiDefBut(block, BUT, B_ENV_FREE_ALL, "Free all EnvMaps", 600,137,160,24, 0, 0, 0, 0, 0, "Frees all rendered environment maps"); - } - uiBlockSetCol(block, BUTGREY); - uiDefIDPoinBut(block, test_obpoin_but, B_ENV_OB, "Ob:", 350,95,166,24, &(env->object), "Object name"); - uiDefButF(block, NUM, B_MATPRV, "Filter :", 518,95,120,24, &tex->filtersize, 0.1, 25.0, 0, 0, "Adjust sharpness or blurriness of the reflection"), - uiDefButS(block, NUM, B_ENV_FREE, "Depth:", 640,95,120,24, &env->depth, 0, 5.0, 0, 0, "Number of times a map gets rendered again, for recursive mirror effect"), - - uiDefButF(block, NUM, REDRAWVIEW3D, "ClipSta", 350,68,122,24, &env->clipsta, 0.01, 50.0, 100, 0, "Set start value for clipping"); - uiDefButF(block, NUM, 0, "ClipEnd", 475,68,142,24, &env->clipend, 0.1, 5000.0, 1000, 0, "Set end value for clipping"); - if(env->stype!=ENV_LOAD) uiDefButS(block, NUM, B_ENV_FREE, "CubeRes", 620,68,140,24, &env->cuberes, 50, 2048.0, 0, 0, "Set the resolution in pixels"); - - uiDefBut(block, LABEL, 0, "Don't render layer:", 772,100,140,22, 0, 0.0, 0.0, 0, 0, ""); - xco= 772; - dx= 28; - dy= 26; - for(a=0; a<10; a++) { - uiDefButI(block, TOG|BIT|(a+10), 0, "",(short)(xco+a*(dx/2)), 68, (short)(dx/2), (short)(dy/2), &env->notlay, 0, 0, 0, 0, "Render this layer"); - uiDefButI(block, TOG|BIT|a, 0, "", (short)(xco+a*(dx/2)), (short)(68+dy/2), (short)(dx/2), (short)(1+dy/2), &env->notlay, 0, 0, 0, 0, "Render this layer"); - if(a==4) xco+= 5; - } - - } - } - - /* COLORBAND */ - uiBlockSetCol(block, BUTSALMON); - uiDefButS(block, TOG|BIT|0, B_COLORBAND, "Colorband", 923,103,102,20, &tex->flag, 0, 0, 0, 0, "Use colorband"); - if(tex->flag & TEX_COLORBAND) { - uiDefBut(block, BUT, B_ADDCOLORBAND, "Add", 1029,103,50,20, 0, 0, 0, 0, 0, "Add new colour to the colorband"); - uiDefBut(block, BUT, B_DELCOLORBAND, "Del", 1218,104,50,20, 0, 0, 0, 0, 0, "Delete the active colour"); - uiBlockSetCol(block, BUTPURPLE); - uiDefButS(block, NUM, B_REDR, "Cur:", 1082,104,132,20, &tex->coba->cur, 0.0, (float)(tex->coba->tot-1), 0, 0, "The active colour from the colorband"); - - uiDefBut(block, LABEL, B_DOCOLORBAND, "", 923,81,345,20, 0, 0, 0, 0, 0, "Colorband"); /* only for event! */ - - drawcolorband(tex->coba, 923,81,345,20); - cbd= tex->coba->data + tex->coba->cur; - - uiDefButF(block, NUM, B_CALCCBAND, "Pos", 923,59,89,20, &cbd->pos, 0.0, 1.0, 10, 0, "Set the position of the active colour"); - uiBlockSetCol(block, BUTGREEN); - uiDefButS(block, ROW, B_REDRAWCBAND, "E", 1013,59,20,20, &tex->coba->ipotype, 5.0, 1.0, 0, 0, "Interpolation type Ease"); - uiDefButS(block, ROW, B_REDRAWCBAND, "L", 1033,59,20,20, &tex->coba->ipotype, 5.0, 0.0, 0, 0, "Interpolation type Linear"); - uiDefButS(block, ROW, B_REDRAWCBAND, "S", 1053,59,20,20, &tex->coba->ipotype, 5.0, 2.0, 0, 0, "Interpolation type Spline"); - uiBlockSetCol(block, BUTPURPLE); - uiDefButF(block, COL, B_BANDCOL, "", 1076,59,28,20, &(cbd->r), 0, 0, 0, 0, ""); - uiDefButF(block, NUMSLI, B_REDRAWCBAND, "A ", 1107,58,163,20, &cbd->a, 0.0, 1.0, 0, 0, "Set the alpha value"); - - uiDefButF(block, NUMSLI, B_REDRAWCBAND, "R ", 923,37,116,20, &cbd->r, 0.0, 1.0, B_BANDCOL, 0, "Set the red value"); - uiDefButF(block, NUMSLI, B_REDRAWCBAND, "G ", 1042,37,111,20, &cbd->g, 0.0, 1.0, B_BANDCOL, 0, "Set the green value"); - uiDefButF(block, NUMSLI, B_REDRAWCBAND, "B ", 1156,36,115,20, &cbd->b, 0.0, 1.0, B_BANDCOL, 0, "Set the blue value"); - - } - - - /* RGB-BRICON */ - uiBlockSetCol(block, BUTGREY); - uiDefButF(block, NUMSLI, B_MATPRV, "Bright", 923,11,166,20, &tex->bright, 0.0, 2.0, 0, 0, "Set the brightness of the colour or intensity of a texture"); - - uiDefButF(block, NUMSLI, B_MATPRV, "Contr", 1093,11,180,20, &tex->contrast, 0.01, 2.0, 0, 0, "Set the contrast of the colour or intensity of a texture"); - - if((tex->flag & TEX_COLORBAND)==0) { - uiDefButF(block, NUMSLI, B_MATPRV, "R ", 923,37,116,20, &tex->rfac, 0.0, 2.0, 0, 0, "Set the red value"); - uiDefButF(block, NUMSLI, B_MATPRV, "G ", 1042,37,111,20, &tex->gfac, 0.0, 2.0, 0, 0, "Set the green value"); - uiDefButF(block, NUMSLI, B_MATPRV, "B ", 1156,36,115,20, &tex->bfac, 0.0, 2.0, 0, 0, "Set the blue value"); - } - } - - /* PREVIEW RENDER */ - - BIF_previewdraw(G.buts); - - uiDrawBlock(block); -} - -/* ****************************** MATERIAL ************************ */ -MTex mtexcopybuf; - - -void do_matbuts(unsigned short event) -{ - static short mtexcopied=0; - Material *ma; - MTex *mtex; - - switch(event) { - case B_ACTCOL: - scrarea_queue_headredraw(curarea); - allqueue(REDRAWBUTSMAT, 0); - allqueue(REDRAWIPO, 0); - BIF_preview_changed(G.buts); - break; - case B_MATFROM: - - scrarea_queue_headredraw(curarea); - allqueue(REDRAWBUTSMAT, 0); - BIF_previewdraw(G.buts); - break; - case B_MATPRV: - /* this event also used by lamp, tex and sky */ - BIF_preview_changed(G.buts); - break; - case B_MATPRV_DRAW: - BIF_preview_changed(G.buts); - allqueue(REDRAWBUTSMAT, 0); - break; - case B_TEXCLEAR: - ma= G.buts->lockpoin; - mtex= ma->mtex[(int) ma->texact ]; - if(mtex) { - if(mtex->tex) mtex->tex->id.us--; - MEM_freeN(mtex); - ma->mtex[ (int) ma->texact ]= 0; - allqueue(REDRAWBUTSMAT, 0); - allqueue(REDRAWOOPS, 0); - BIF_preview_changed(G.buts); - } - break; - case B_MTEXCOPY: - ma= G.buts->lockpoin; - if(ma && ma->mtex[(int)ma->texact] ) { - mtex= ma->mtex[(int)ma->texact]; - if(mtex->tex==0) { - error("No texture available"); - } - else { - memcpy(&mtexcopybuf, ma->mtex[(int)ma->texact], sizeof(MTex)); - notice("copied!"); - mtexcopied= 1; - } - } - break; - case B_MTEXPASTE: - ma= G.buts->lockpoin; - if(ma && mtexcopied && mtexcopybuf.tex) { - if(ma->mtex[(int)ma->texact]==0 ) ma->mtex[(int)ma->texact]= MEM_mallocN(sizeof(MTex), "mtex"); - memcpy(ma->mtex[(int)ma->texact], &mtexcopybuf, sizeof(MTex)); - - id_us_plus((ID *)mtexcopybuf.tex); - notice("pasted!"); - BIF_preview_changed(G.buts); - scrarea_queue_winredraw(curarea); - } - break; - case B_MATLAY: - ma= G.buts->lockpoin; - if(ma && ma->lay==0) { - ma->lay= 1; - scrarea_queue_winredraw(curarea); - } - } -} - -void matbuts(void) -{ - Object *ob; - Material *ma; - ID *id, *idn; - MTex *mtex; - uiBlock *block; - uiBut *but; - float *colpoin = NULL, min; - int rgbsel = 0, a, loos; - char str[30], *strp; - short xco; - - ob= OBACT; - if(ob==0 || ob->data==0) return; - - sprintf(str, "buttonswin %d", curarea->win); - block= uiNewBlock(&curarea->uiblocks, str, UI_EMBOSSX, UI_HELV, curarea->win); - - if(ob->actcol==0) ob->actcol= 1; /* because of TOG|BIT button */ - - /* indicate which one is linking a material */ - uiBlockSetCol(block, BUTSALMON); - uiDefButS(block, TOG|BIT|(ob->actcol-1), B_MATFROM, "OB", 342, 195, 33, 20, &ob->colbits, 0, 0, 0, 0, "Link material to object"); - idn= ob->data; - strncpy(str, idn->name, 2); - str[2]= 0; - uiBlockSetCol(block, BUTGREEN); - uiDefButS(block, TOGN|BIT|(ob->actcol-1), B_MATFROM, str, 380, 195, 33, 20, &ob->colbits, 0, 0, 0, 0, "Show the block the material is linked to"); - uiBlockSetCol(block, BUTGREY); - - /* id is the block from which the material is used */ - if( BTST(ob->colbits, ob->actcol-1) ) id= (ID *)ob; - else id= ob->data; - - sprintf(str, "%d Mat", ob->totcol); - if(ob->totcol) min= 1.0; else min= 0.0; - uiDefButC(block, NUM, B_ACTCOL, str, 415,195,150,20, &(ob->actcol), min, (float)ob->totcol, 0, 0, "Number of materials on object / Active material"); - - uiSetButLock(id->lib!=0, "Can't edit library data"); - - strncpy(str, id->name, 2); - str[2]= ':'; str[3]= 0; - but= uiDefBut(block, TEX, B_IDNAME, str, 200,195,140,20, id->name+2, 0.0, 18.0, 0, 0, "Show the block the material is linked to"); - uiButSetFunc(but, test_idbutton_cb, id->name, NULL); - - if(ob->totcol==0) { - uiDrawBlock(block); - return; - } - - ma= give_current_material(ob, ob->actcol); - - if(ma==0) { - uiDrawBlock(block); - return; - } - uiSetButLock(ma->id.lib!=0, "Can't edit library data"); - - uiBlockSetCol(block, BUTGREY); - uiDefButS(block, ROW, REDRAWBUTSMAT, "RGB", 200,166,35,22, &(ma->colormodel), 1.0, (float)MA_RGB, 0, 0, "Create colour by red, green and blue"); - uiDefButS(block, ROW, REDRAWBUTSMAT, "HSV", 200,143,35,22, &(ma->colormodel), 1.0, (float)MA_HSV, 0, 0, "Mix colour with hue, saturation and value"); - uiDefButS(block, TOG|BIT|0, REDRAWBUTSMAT, "DYN", 200,120,35,22, &(ma->dynamode), 0.0, 0.0, 0, 0, "Adjust parameters for dynamics options"); - - if(ma->dynamode & MA_DRAW_DYNABUTS) { - uiDefButF(block, NUMSLI, 0, "Restitut ", 390,168,175,21, &ma->reflect, 0.0, 1.0, 0, 0, "Elasticity of collisions"); - uiDefButF(block, NUMSLI, 0, "Friction ", 390,144,175,21, &ma->friction, 0.0, 100.0, 0, 0, "Coulomb friction coefficient"); - - uiDefButF(block, NUMSLI, 0, "Fh Force ", 390,120,175,21, &ma->fh, 0.0, 1.0, 0, 0, "Upward spring force within the Fh area"); - uiDefButF(block, NUM, 0, "Fh Damp ", 260,144,120,21, &ma->xyfrict, 0.0, 1.0, 10, 0, "Damping of the Fh spring force"); - uiDefButF(block, NUM, 0, "Fh Dist ", 260,120,120,21, &ma->fhdist, 0.0, 20.0, 10, 0, "Height of the Fh area"); - uiBlockSetCol(block, BUTGREEN); - uiDefButS(block, TOG|BIT|1, 0, "Fh Norm", 260,168,120,21, &ma->dynamode, 0.0, 0.0, 0, 0, "Add a horizontal spring force on slopes"); - uiBlockSetCol(block, BUTGREY); - } - else { - uiDefButF(block, COL, B_MIRCOL, "", 235,143,30,45, &(ma->mirr), 0, 0, 0, 0, ""); - uiDefButF(block, COL, B_SPECCOL, "", 265,143,39,45, &(ma->specr), 0, 0, 0, 0, ""); - uiDefButF(block, COL, B_MATCOL, "", 304,143,39,45, &(ma->r), 0, 0, 0, 0, ""); - - if(ma->mode & MA_HALO) { - uiDefButC(block, ROW, REDRAWBUTSMAT, "Ring", 235,120,30,22, &(ma->rgbsel), 2.0, 2.0, 0, 0, "Mix the colour of the rings with the RGB sliders"); - uiDefButC(block, ROW, REDRAWBUTSMAT, "Line", 265,120,39,22, &(ma->rgbsel), 2.0, 1.0, 0, 0, "Mix the colour of the lines with the RGB sliders"); - uiDefButC(block, ROW, REDRAWBUTSMAT, "Halo", 304,120,39,22, &(ma->rgbsel), 2.0, 0.0, 0, 0, "Mix the colour of the halo with the RGB sliders"); - } - else { - uiDefButC(block, ROW, REDRAWBUTSMAT, "Mir", 235,120,30,22, &(ma->rgbsel), 2.0, 2.0, 0, 0, "Use mirror colour"); - uiDefButC(block, ROW, REDRAWBUTSMAT, "Spe", 265,120,39,22, &(ma->rgbsel), 2.0, 1.0, 0, 0, "Set the colour of the specularity"); - uiDefButC(block, ROW, REDRAWBUTSMAT, "Col", 304,120,39,22, &(ma->rgbsel), 2.0, 0.0, 0, 0, "Set the basic colour of the material"); - } - if(ma->rgbsel==0) {colpoin= &(ma->r); rgbsel= B_MATCOL;} - else if(ma->rgbsel==1) {colpoin= &(ma->specr); rgbsel= B_SPECCOL;} - else if(ma->rgbsel==2) {colpoin= &(ma->mirr); rgbsel= B_MIRCOL;} - - if(ma->rgbsel==0 && (ma->mode & (MA_VERTEXCOLP|MA_FACETEXTURE) && !(ma->mode & MA_HALO))); - else if(ma->colormodel==MA_HSV) { - uiBlockSetCol(block, BUTPURPLE); - uiDefButF(block, HSVSLI, B_MATPRV, "H ", 350,168,150,21, colpoin, 0.0, 0.9999, rgbsel, 0, ""); - uiBlockSetCol(block, BUTPURPLE); - uiDefButF(block, HSVSLI, B_MATPRV, "S ", 350,144,150,21, colpoin, 0.0001, 1.0, rgbsel, 0, ""); - uiBlockSetCol(block, BUTPURPLE); - uiDefButF(block, HSVSLI, B_MATPRV, "V ", 350,120,150,21, colpoin, 0.0001, 1.0, rgbsel, 0, ""); - uiBlockSetCol(block, BUTGREY); - } - else { - uiDefButF(block, NUMSLI, B_MATPRV, "R ", 350,168,150,21, colpoin, 0.0, 1.0, rgbsel, 0, ""); - uiDefButF(block, NUMSLI, B_MATPRV, "G ", 350,144,150,21, colpoin+1, 0.0, 1.0, rgbsel, 0, ""); - uiDefButF(block, NUMSLI, B_MATPRV, "B ", 350,120,150,21, colpoin+2, 0.0, 1.0, rgbsel, 0, ""); - } - if(!(ma->mode & MA_HALO)) { - uiBlockSetCol(block, BUTBLUE); - uiDefButI(block, TOG|BIT|4, B_REDR, "VCol Light", 505, 168, 60, 21, &(ma->mode), 0, 0, 0, 0, "Add vertex colours as extra light"); - uiDefButI(block, TOG|BIT|7, B_REDR, "VCol Paint", 505, 144, 60, 21, &(ma->mode), 0, 0, 0, 0, "Replace basic colours with vertex colours"); - uiDefButI(block, TOG|BIT|11, B_REDR, "TexFace", 505, 120, 60, 21, &(ma->mode), 0, 0, 0, 0, "UV-Editor assigned texture gives color and texture info for the faces"); - } - } - if(ma->mode & MA_HALO) { - uiBlockSetCol(block, BUTGREY); - uiDefButF(block, NUM, B_MATPRV, "HaloSize: ", 200,90,175,18, &(ma->hasize), 0.0, 100.0, 10, 0, "Set the dimension of the halo"); - uiDefButF(block, NUMSLI, B_MATPRV, "Alpha ", 200,50,175,18, &(ma->alpha), 0.0, 1.0, 0, 0, "Set the degree of coverage"); - uiDefButS(block, NUMSLI, B_MATPRV, "Hard ", 200,30,175,18, &(ma->har), 1.0, 127.0, 0, 0, "Set the hardness of the halo"); - uiDefButF(block, NUMSLI, B_MATPRV, "Add ", 200,10,175,18, &(ma->add), 0.0, 1.0, 0, 0, "Strength of the add effect"); - - uiDefButS(block, NUM, B_MATPRV, "Rings: ", 380,90,85,18, &(ma->ringc), 0.0, 24.0, 0, 0, "Set the number of rings rendered over the basic halo"); - uiDefButS(block, NUM, B_MATPRV, "Lines: ", 465,90,90,18, &(ma->linec), 0.0, 250.0, 0, 0, "Set the number of star shaped lines rendered over the halo"); - uiDefButS(block, NUM, B_MATPRV, "Star: ", 380,70,85,18, &(ma->starc), 3.0, 50.0, 0, 0, "Set the number of points on the star shaped halo"); - uiDefButC(block, NUM, B_MATPRV, "Seed: ", 465,70,90,18, &(ma->seed1), 0.0, 255.0, 0, 0, "Use random values for ring dimension and line location"); - - uiDefButF(block, NUM, B_MATPRV, "FlareSize: ", 380,50,85,18, &(ma->flaresize), 0.1, 25.0, 10, 0, "Set the factor the flare is larger than the halo"); - uiDefButF(block, NUM, B_MATPRV, "Sub Size: ", 465,50,90,18, &(ma->subsize), 0.1, 25.0, 10, 0, "Set the dimension of the subflares, dots and circles"); - uiDefButF(block, NUM, B_MATPRV, "FlareBoost: ", 380,30,175,18, &(ma->flareboost), 0.1, 10.0, 10, 0, "Give the flare extra strength"); - uiDefButC(block, NUM, B_MATPRV, "Fl.seed: ", 380,10,85,18, &(ma->seed2), 0.0, 255.0, 0, 0, "Specify an offset in the seed table"); - uiDefButS(block, NUM, B_MATPRV, "Flares: ", 465,10,90,18, &(ma->flarec), 1.0, 32.0, 0, 0, "Set the nuber of subflares"); - - uiBlockSetCol(block, BUTBLUE); - - uiDefButI(block, TOG|BIT|15, B_MATPRV, "Flare", 576, 181, 77, 36, &(ma->mode), 0, 0, 0, 0, "Render halo as a lensflare"); - uiDefButI(block, TOG|BIT|8, B_MATPRV, "Rings", 576, 143, 77, 18, &(ma->mode), 0, 0, 0, 0, "Render rings over basic halo"); - uiDefButI(block, TOG|BIT|9, B_MATPRV, "Lines", 576, 124, 77, 18, &(ma->mode), 0, 0, 0, 0, "Render star shaped lines over the basic halo"); - uiDefButI(block, TOG|BIT|11, B_MATPRV, "Star", 576, 105, 77, 18, &(ma->mode), 0, 0, 0, 0, "Render halo as a star"); - uiDefButI(block, TOG|BIT|5, B_MATPRV_DRAW, "Halo", 576, 86, 77, 18, &(ma->mode), 0, 0, 0, 0, "Render as a halo"); - - uiDefButI(block, TOG|BIT|12, B_MATPRV, "HaloTex", 576, 67, 77, 18, &(ma->mode), 0, 0, 0, 0, "Give halo a texture"); - uiDefButI(block, TOG|BIT|13, B_MATPRV, "HaloPuno", 576, 48, 77, 18, &(ma->mode), 0, 0, 0, 0, "Use the vertex normal to specify the dimension of the halo"); - uiDefButI(block, TOG|BIT|10, B_MATPRV, "X Alpha", 576, 28, 77, 18, &(ma->mode), 0, 0, 0, 0, "Use extreme alpha"); - uiDefButI(block, TOG|BIT|14, B_MATPRV, "Shaded", 576, 10, 77, 18, &(ma->mode), 0, 0, 0, 0, "Let halo receive light"); - } - else { - char *str1= "Diffuse Shader%t|Lambert %x0|Oren-Nayar %x1|Toon %x2"; - char *str2= "Specular Shader%t|CookTorr %x0|Phong %x1|Blinn %x2|Toon %x3"; - - /* shader buttons */ - uiBlockSetCol(block, BUTGREY); - uiDefButS(block, MENU, B_MATPRV_DRAW, str1, 200,90,95,18, &(ma->diff_shader), 0.0, 0.0, 0, 0, "Set a diffuse shader"); - uiDefButS(block, MENU, B_MATPRV_DRAW, str2, 295,90,90,18, &(ma->spec_shader), 0.0, 0.0, 0, 0, "Set a specular shader"); - - if(ma->diff_shader==MA_DIFF_ORENNAYAR) - uiDefButF(block, NUM, B_MATPRV, "Rough:", 200, 70, 95,18, &(ma->roughness), 0.0, 3.14, 0, 0, "Oren Nayar Roughness"); - else if(ma->diff_shader==MA_DIFF_TOON) { - uiDefButF(block, NUM, B_MATPRV, "Size:", 200, 70, 95,18, &(ma->param[0]), 0.0, 3.14, 0, 0, "Size of diffuse toon area"); - uiDefButF(block, NUM, B_MATPRV, "Smooth:", 200, 50, 95,18, &(ma->param[1]), 0.0, 1.0, 0, 0, "Smoothness of diffuse toon area"); - } - - if ELEM3(ma->spec_shader, MA_SPEC_COOKTORR, MA_SPEC_PHONG, MA_SPEC_BLINN) { - uiDefButS(block, NUM, B_MATPRV, "Hard:", 295, 70, 90,18, &(ma->har), 1.0, 255, 0, 0, "Set the hardness of the specularity"); - } - if(ma->spec_shader==MA_SPEC_BLINN) - uiDefButF(block, NUM, B_MATPRV, "Refr:", 295, 50, 90,18, &(ma->refrac), 1.0, 10.0, 0, 0, "Refraction index"); - if(ma->spec_shader==MA_SPEC_TOON) { - uiDefButF(block, NUM, B_MATPRV, "Size:", 295, 70, 90,18, &(ma->param[2]), 0.0, 1.53, 0, 0, "Size of specular toon area"); - uiDefButF(block, NUM, B_MATPRV, "Smooth:", 295, 50, 90,18, &(ma->param[3]), 0.0, 1.0, 0, 0, "Smoothness of specular toon area"); - } - - uiDefButF(block, NUMSLI, B_MATPRV, "Ref ", 200,30,185,18, &(ma->ref), 0.0, 1.0, 0, 0, "Set the amount of reflection"); - uiDefButF(block, NUMSLI, B_MATPRV, "Spec ", 200,10,185,18, &(ma->spec), 0.0, 2.0, 0, 0, "Set the degree of specularity"); - - /* default shading variables */ - uiDefButF(block, NUMSLI, B_MATPRV, "Alpha ", 390,90,175,18, &(ma->alpha), 0.0, 1.0, 0, 0, "Set the amount of coverage, to make materials transparent"); - uiDefButF(block, NUMSLI, B_MATPRV, "SpecTra ", 390,70,175,18, &(ma->spectra), 0.0, 1.0, 0, 0, "Make specular areas opaque"); - uiDefButF(block, NUMSLI, B_MATPRV, "Add ", 390,50,175,18, &(ma->add), 0.0, 1.0, 0, 0, "Glow factor for transparant"); - uiDefButF(block, NUMSLI, B_MATPRV, "Emit ", 390,30,175,18, &(ma->emit), 0.0, 1.0, 0, 0, "Set the amount of emitting light"); - uiDefButF(block, NUMSLI, B_MATPRV, "Amb ", 390,10,175,18, &(ma->amb), 0.0, 1.0, 0, 0, "Set the amount of global ambient color"); - - uiBlockSetCol(block, BUTBLUE); - - uiDefButI(block, TOG|BIT|0, 0, "Traceable", 576,200,77,18, &(ma->mode), 0, 0, 0, 0, "Make material visible for shadow lamps"); - uiDefButI(block, TOG|BIT|1, 0, "Shadow", 576,181,77,18, &(ma->mode), 0, 0, 0, 0, "Enable material for shadows"); - uiDefButI(block, TOG|BIT|16, 0, "Radio", 576, 162, 77,18, &(ma->mode), 0, 0, 0, 0, "Set the material insensitive to mist"); - uiDefButI(block, TOG|BIT|2, B_MATPRV, "Shadeless", 576, 143, 77, 18, &(ma->mode), 0, 0, 0, 0, "Make material insensitive to light or shadow"); - uiDefButI(block, TOG|BIT|3, 0, "Wire", 576, 124, 77, 18, &(ma->mode), 0, 0, 0, 0, "Render only the edges of faces"); - uiDefButI(block, TOG|BIT|6, 0, "ZTransp", 576, 105, 77, 18, &(ma->mode), 0, 0, 0, 0, "Z-Buffer transparent faces"); - uiDefButI(block, TOG|BIT|5, B_MATPRV_DRAW, "Halo", 576, 86, 77, 18, &(ma->mode), 0, 0, 0, 0, "Render as a halo"); - uiDefButI(block, TOG|BIT|9, 0, "Env", 576, 67, 77, 18, &(ma->mode), 0, 0, 0, 0, "Do not render material"); - uiDefButI(block, TOG|BIT|10, 0, "OnlyShadow", 576, 48, 77, 18, &(ma->mode), 0, 0, 0, 0, "Let alpha be determined on the degree of shadow"); - uiDefButI(block, TOG|BIT|14, 0, "No Mist", 576, 29, 77,18, &(ma->mode), 0, 0, 0, 0, "Set the material insensitive to mist"); - uiDefButI(block, TOG|BIT|8, 0, "ZInvert", 576, 10, 77, 18, &(ma->mode), 0, 0, 0, 0, "Render with inverted Z Buffer"); - uiBlockSetCol(block, BUTGREY); - uiDefButF(block, NUM, 0, "Zoffs:", 576, -9, 77,18, &(ma->zoffs), 0.0, 10.0, 0, 0, "Give face an artificial offset"); - } - /* PREVIEW RENDER */ - - BIF_previewdraw(G.buts); - - uiDefIconButC(block, ROW, B_MATPRV, ICON_MATPLANE, 10,195,25,20, &(ma->pr_type), 10, 0, 0, 0, ""); - uiDefIconButC(block, ROW, B_MATPRV, ICON_MATSPHERE, 35,195,25,20, &(ma->pr_type), 10, 1, 0, 0, ""); - uiDefIconButC(block, ROW, B_MATPRV, ICON_MATCUBE, 60,195,25,20, &(ma->pr_type), 10, 2, 0, 0, ""); - - uiDefIconButS(block, ICONTOG|BIT|0, B_MATPRV, ICON_TRANSP_HLT, 95,195,25,20, &(ma->pr_back), 0, 0, 0, 0, ""); - - uiDefIconBut(block, BUT, B_MATPRV, ICON_EYE, 159,195,30,20, 0, 0, 0, 0, 0, ""); - - /* TEX CHANNELS */ - uiBlockSetCol(block, BUTGREY); - xco= 665; - for(a= 0; a<8; a++) { - mtex= ma->mtex[a]; - if(mtex && mtex->tex) splitIDname(mtex->tex->id.name+2, str, &loos); - else strcpy(str, ""); - str[10]= 0; - uiDefButC(block, ROW, B_MATPRV_DRAW, str, xco, 195, 63, 20, &(ma->texact), 3.0, (float)a, 0, 0, ""); - xco+= 65; - } - - uiDefIconBut(block, BUT, B_MTEXCOPY, ICON_COPYUP, (short)xco,195,20,21, 0, 0, 0, 0, 0, "Copy the material settings to the buffer"); - uiDefIconBut(block, BUT, B_MTEXPASTE, ICON_PASTEUP, (short)(xco+20),195,20,21, 0, 0, 0, 0, 0, "Paste the material settings from the buffer"); - - - uiBlockSetCol(block, BUTGREEN); - uiDefButC(block, TOG, B_MATPRV, "SepT", (short)(xco+40), 195, 40, 20, &(ma->septex), 0, 0, 0, 0, "Render only use active texture channel"); - uiBlockSetCol(block, BUTGREY); - - mtex= ma->mtex[ ma->texact ]; - if(mtex==0) { - mtex= &emptytex; - default_mtex(mtex); - } - - /* TEXCO */ - uiBlockSetCol(block, BUTGREEN); - uiDefButS(block, ROW, B_MATPRV, "Object", 694,166,49,18, &(mtex->texco), 4.0, (float)TEXCO_OBJECT, 0, 0, "Use linked object's coordinates for texture coordinates"); - uiDefIDPoinBut(block, test_obpoin_but, B_MATPRV, "", 745,166,133,18, &(mtex->object), ""); - uiDefButS(block, ROW, B_MATPRV, "UV", 664,166,29,18, &(mtex->texco), 4.0, (float)TEXCO_UV, 0, 0, "Use UV coordinates for texture coordinates"); - - uiDefButS(block, ROW, B_MATPRV, "Glob", 665,146,35,18, &(mtex->texco), 4.0, (float)TEXCO_GLOB, 0, 0, "Use global coordinates for the texture coordinates"); - uiDefButS(block, ROW, B_MATPRV, "Orco", 701,146,38,18, &(mtex->texco), 4.0, (float)TEXCO_ORCO, 0, 0, "Use the original coordinates of the mesh"); - uiDefButS(block, ROW, B_MATPRV, "Stick", 739,146,38,18, &(mtex->texco), 4.0, (float)TEXCO_STICKY, 0, 0, "Use mesh sticky coordaintes for the texture coordinates"); - uiDefButS(block, ROW, B_MATPRV, "Win", 779,146,31,18, &(mtex->texco), 4.0, (float)TEXCO_WINDOW, 0, 0, "Use screen coordinates as texture coordinates"); - uiDefButS(block, ROW, B_MATPRV, "Nor", 811,146,32,18, &(mtex->texco), 4.0, (float)TEXCO_NORM, 0, 0, "Use normal vector as texture coordinates"); - uiDefButS(block, ROW, B_MATPRV, "Refl", 844,146,33,18, &(mtex->texco), 4.0, (float)TEXCO_REFL, 0, 0, "Use reflection vector as texture coordinates"); - - uiBlockSetCol(block, BUTGREY); - - /* COORDS */ - uiDefButC(block, ROW, B_MATPRV, "Flat", 666,114,48,18, &(mtex->mapping), 5.0, (float)MTEX_FLAT, 0, 0, "Map X and Y coordinates directly"); - uiDefButC(block, ROW, B_MATPRV, "Cube", 717,114,50,18, &(mtex->mapping), 5.0, (float)MTEX_CUBE, 0, 0, "Map using the normal vector"); - uiDefButC(block, ROW, B_MATPRV, "Tube", 666,94,48,18, &(mtex->mapping), 5.0, (float)MTEX_TUBE, 0, 0, "Map with Z as central axis (tube-like)"); - uiDefButC(block, ROW, B_MATPRV, "Sphe", 716,94,50,18, &(mtex->mapping), 5.0, (float)MTEX_SPHERE, 0, 0, "Map with Z as central axis (sphere-like)"); - - xco= 665; - for(a=0; a<4; a++) { - if(a==0) strcpy(str, ""); - else if(a==1) strcpy(str, "X"); - else if(a==2) strcpy(str, "Y"); - else strcpy(str, "Z"); - - uiDefButC(block, ROW, B_MATPRV, str, (short)xco, 50, 24, 18, &(mtex->projx), 6.0, (float)a, 0, 0, ""); - uiDefButC(block, ROW, B_MATPRV, str, (short)xco, 30, 24, 18, &(mtex->projy), 7.0, (float)a, 0, 0, ""); - uiDefButC(block, ROW, B_MATPRV, str, (short)xco, 10, 24, 18, &(mtex->projz), 8.0, (float)a, 0, 0, ""); - xco+= 26; - } - - uiDefButF(block, NUM, B_MATPRV, "ofsX", 778,114,100,18, mtex->ofs, -10.0, 10.0, 10, 0, "Fine tune X coordinate"); - uiDefButF(block, NUM, B_MATPRV, "ofsY", 778,94,100,18, mtex->ofs+1, -10.0, 10.0, 10, 0, "Fine tune Y coordinate"); - uiDefButF(block, NUM, B_MATPRV, "ofsZ", 778,74,100,18, mtex->ofs+2, -10.0, 10.0, 10, 0, "Fine tune Z coordinate"); - uiDefButF(block, NUM, B_MATPRV, "sizeX", 778,50,100,18, mtex->size, -100.0, 100.0, 10, 0, "Set an extra scaling for the texture coordinate"); - uiDefButF(block, NUM, B_MATPRV, "sizeY", 778,30,100,18, mtex->size+1, -100.0, 100.0, 10, 0, "Set an extra scaling for the texture coordinate"); - uiDefButF(block, NUM, B_MATPRV, "sizeZ", 778,10,100,18, mtex->size+2, -100.0, 100.0, 10, 0, "Set an extra scaling for the texture coordinate"); - - /* TEXTUREBLOK SELECT */ - if(G.main->tex.first==0) - id= NULL; - else - id= (ID*) mtex->tex; - IDnames_to_pupstring(&strp, NULL, "ADD NEW %x32767", &(G.main->tex), id, &(G.buts->texnr)); - uiDefButS(block, MENU, B_EXTEXBROWSE, strp, 900,146,20,19, &(G.buts->texnr), 0, 0, 0, 0, "The name of the texture"); - MEM_freeN(strp); - - if(id) { - uiDefBut(block, TEX, B_IDNAME, "TE:", 900,166,163,19, id->name+2, 0.0, 18.0, 0, 0, "The name of the texture block"); - sprintf(str, "%d", id->us); - uiDefBut(block, BUT, 0, str, 996,146,21,19, 0, 0, 0, 0, 0, ""); - uiDefIconBut(block, BUT, B_AUTOTEXNAME, ICON_AUTO, 1041,146,21,19, 0, 0, 0, 0, 0, "Auto-assign name to texture"); - if(id->lib) { - if(ma->id.lib) uiDefIconBut(block, BUT, 0, ICON_DATALIB, 1019,146,21,19, 0, 0, 0, 0, 0, ""); - else uiDefIconBut(block, BUT, 0, ICON_PARLIB, 1019,146,21,19, 0, 0, 0, 0, 0, ""); - } - uiBlockSetCol(block, BUTSALMON); - uiDefBut(block, BUT, B_TEXCLEAR, "Clear", 922, 146, 72, 19, 0, 0, 0, 0, 0, "Erase link to datablock"); - uiBlockSetCol(block, BUTGREY); - } - - /* TEXTURE OUTPUT */ - uiDefButS(block, TOG|BIT|1, B_MATPRV, "Stencil", 900,114,52,18, &(mtex->texflag), 0, 0, 0, 0, "Set the mapping to stencil mode"); - uiDefButS(block, TOG|BIT|2, B_MATPRV, "Neg", 954,114,38,18, &(mtex->texflag), 0, 0, 0, 0, "Reverse the effect of the texture"); - uiDefButS(block, TOG|BIT|0, B_MATPRV, "No RGB", 994,114,69,18, &(mtex->texflag), 0, 0, 0, 0, "Use an RGB texture as an intensity texture"); - - uiDefButF(block, COL, B_MTEXCOL, "", 900,100,163,12, &(mtex->r), 0, 0, 0, 0, "Browse datablocks"); - - if(ma->colormodel==MA_HSV) { - uiBlockSetCol(block, BUTPURPLE); - uiDefButF(block, HSVSLI, B_MATPRV, "H ", 900,80,163,18, &(mtex->r), 0.0, 0.9999, B_MTEXCOL, 0, ""); - uiBlockSetCol(block, BUTPURPLE); - uiDefButF(block, HSVSLI, B_MATPRV, "S ", 900,60,163,18, &(mtex->r), 0.0001, 1.0, B_MTEXCOL, 0, ""); - uiBlockSetCol(block, BUTPURPLE); - uiDefButF(block, HSVSLI, B_MATPRV, "V ", 900,40,163,18, &(mtex->r), 0.0001, 1.0, B_MTEXCOL, 0, ""); - uiBlockSetCol(block, BUTGREY); - } - else { - uiDefButF(block, NUMSLI, B_MATPRV, "R ", 900,80,163,18, &(mtex->r), 0.0, 1.0, B_MTEXCOL, 0, "Set the amount of red the intensity texture blends with"); - uiDefButF(block, NUMSLI, B_MATPRV, "G ", 900,60,163,18, &(mtex->g), 0.0, 1.0, B_MTEXCOL, 0, "Set the amount of green the intensity texture blends with"); - uiDefButF(block, NUMSLI, B_MATPRV, "B ", 900,40,163,18, &(mtex->b), 0.0, 1.0, B_MTEXCOL, 0, "Set the amount of blue the intensity texture blends with"); - } - - uiDefButF(block, NUMSLI, B_MATPRV, "DVar ", 900,10,163,18, &(mtex->def_var), 0.0, 1.0, 0, 0, "Set the value the texture blends with the current value"); - - /* MAP TO */ - uiBlockSetCol(block, BUTGREEN); - uiDefButS(block, TOG|BIT|0, B_MATPRV, "Col", 1087,166,35,18, &(mtex->mapto), 0, 0, 0, 0, "Let the texture affect basic colour of the material"); - uiDefButS(block, TOG3|BIT|1, B_MATPRV, "Nor", 1126,166,31,18, &(mtex->mapto), 0, 0, 0, 0, "Let the texture affect the rendered normal"); - uiDefButS(block, TOG|BIT|2, B_MATPRV, "Csp", 1160,166,34,18, &(mtex->mapto), 0, 0, 0, 0, "Let the texture affect the specularity colour"); - uiDefButS(block, TOG|BIT|3, B_MATPRV, "Cmir", 1196,166,35,18, &(mtex->mapto), 0, 0, 0, 0, "Let the texture affext the mirror colour"); - uiDefButS(block, TOG3|BIT|4, B_MATPRV, "Ref", 1234,166,31,18, &(mtex->mapto), 0, 0, 0, 0, "Let the texture affect the value of the materials reflectivity"); - uiDefButS(block, TOG3|BIT|5, B_MATPRV, "Spec", 1087,146,36,18, &(mtex->mapto), 0, 0, 0, 0, "Let the texture affect the value of specularity"); - uiDefButS(block, TOG3|BIT|8, B_MATPRV, "Hard", 1126,146,44,18, &(mtex->mapto), 0, 0, 0, 0, "Let the texture affect the hardness value"); - uiDefButS(block, TOG3|BIT|7, B_MATPRV, "Alpha", 1172,146,45,18, &(mtex->mapto), 0, 0, 0, 0, "Let the texture affect the alpha value"); - uiDefButS(block, TOG3|BIT|6, B_MATPRV, "Emit", 1220,146,45,18, &(mtex->mapto), 0, 0, 0, 0, "Let the texture affect the emit value"); - -/* uiDefButS(block, TOG|BIT|3, B_MATPRV, "Alpha Mix",1087,114,100,18, &(mtex->texflag), 0, 0, 0, 0); ,""*/ - - uiBlockSetCol(block, BUTGREY); - uiDefButS(block, ROW, B_MATPRV, "Mix", 1087,94,48,18, &(mtex->blendtype), 9.0, (float)MTEX_BLEND, 0, 0, "The texture blends the values or colour"); - uiDefButS(block, ROW, B_MATPRV, "Mul", 1136,94,44,18, &(mtex->blendtype), 9.0, (float)MTEX_MUL, 0, 0, "The texture multiplies the values or colour"); - uiDefButS(block, ROW, B_MATPRV, "Add", 1182,94,41,18, &(mtex->blendtype), 9.0, (float)MTEX_ADD, 0, 0, "The texture adds the values or colour"); - uiDefButS(block, ROW, B_MATPRV, "Sub", 1226,94,40,18, &(mtex->blendtype), 9.0, (float)MTEX_SUB, 0, 0, "The texture subtracts the values or colour"); - - uiDefButF(block, NUMSLI, B_MATPRV, "Col ", 1087,50,179,18, &(mtex->colfac), 0.0, 1.0, 0, 0, "Set the amount the texture affects colour"); - uiDefButF(block, NUMSLI, B_MATPRV, "Nor ", 1087,30,179,18, &(mtex->norfac), 0.0, 5.0, 0, 0, "Set the amount the texture affects the normal"); - uiDefButF(block, NUMSLI, B_MATPRV, "Var ", 1087,10,179,18, &(mtex->varfac), 0.0, 1.0, 0, 0, "Set the amount the texture affects a value"); - - uiDrawBlock(block); -} - - -/* ************************ SOUND *************************** */ -static void load_new_sample(char *str) /* called from fileselect */ -{ - char name[FILE_MAXDIR+FILE_MAXFILE]; - bSound *sound; - bSample *sample, *newsample; - - sound = G.buts->lockpoin; - - if (sound) { - // save values - sample = sound->sample; - strcpy(name, sound->sample->name); - - strcpy(sound->name, str); - sound_set_sample(sound, NULL); - sound_initialize_sample(sound); - - if (sound->sample->type == SAMPLE_INVALID) { - error("Not a valid sample: %s", str); - - newsample = sound->sample; - - // restore values - strcpy(sound->name, name); - sound_set_sample(sound, sample); - - // remove invalid sample - - sound_free_sample(newsample); - BLI_remlink(samples, newsample); - MEM_freeN(newsample); - } - } - - allqueue(REDRAWBUTSSOUND, 0); - if (curarea) BIF_preview_changed(G.buts); -} - - -void do_soundbuts(unsigned short event) -{ - char name[FILE_MAXDIR+FILE_MAXFILE]; - bSound *sound; - bSample *sample; - bSound* tempsound; - ID *id; - - sound = G.buts->lockpoin; - - switch(event) - { - case B_SOUND_REDRAW: - { - allqueue(REDRAWBUTSSOUND, 0); - break; - } - case B_SOUND_LOAD_SAMPLE: - { - if (sound) strcpy(name, sound->name); - else strcpy(name, U.sounddir); - - activate_fileselect(FILE_SPECIAL, "SELECT WAV FILE", name, load_new_sample); - break; - } - case B_SOUND_PLAY_SAMPLE: - { - if (sound) - { - if (sound->sample->type != SAMPLE_INVALID) - { - sound_play_sound(sound); - allqueue(REDRAWBUTSSOUND, 0); - } - } - break; - } - case B_SOUND_MENU_SAMPLE: - { - if (G.buts->menunr == -2) { - if (sound) { - activate_databrowse((ID *)sound->sample, ID_SAMPLE, 0, B_SOUND_MENU_SAMPLE, &G.buts->menunr, do_soundbuts); - } - } else if (G.buts->menunr > 0) { - sample = BLI_findlink(samples, G.buts->menunr - 1); - if (sample && sound) { - BLI_strncpy(sound->name, sample->name, sizeof(sound->name)); - sound_set_sample(sound, sample); - do_soundbuts(B_SOUND_REDRAW); - } - } - - break; - } - case B_SOUND_NAME_SAMPLE: - { - load_new_sample(sound->name); - break; - } - case B_SOUND_UNPACK_SAMPLE: - if(sound && sound->sample) { - sample = sound->sample; - - if (sample->packedfile) { - if (G.fileflags & G_AUTOPACK) { - if (okee("Disable AutoPack ?")) { - G.fileflags &= ~G_AUTOPACK; - } - } - - if ((G.fileflags & G_AUTOPACK) == 0) { - unpackSample(sample, PF_ASK); - } - } else { - sound_set_packedfile(sample, newPackedFile(sample->name)); - } - allqueue(REDRAWHEADERS, 0); - do_soundbuts(B_SOUND_REDRAW); - } - break; - case B_SOUND_COPY_SOUND: - { - if (sound) - { - tempsound = sound_make_copy(sound); - sound = tempsound; - id = &sound->id; - G.buts->lockpoin = (bSound*)id; - do_soundbuts(B_SOUND_REDRAW); - } - break; - } - case B_SOUND_RECALC: - { - waitcursor(1); - sound = G.main->sound.first; - while (sound) - { - MEM_freeN(sound->stream); - sound->stream = 0; - audio_makestream(sound); - sound = (bSound *) sound->id.next; - } - waitcursor(0); - allqueue(REDRAWSEQ, 0); - break; - } - case B_SOUND_RATECHANGED: - { - allqueue(REDRAWBUTSSOUND, 0); - allqueue(REDRAWSEQ, 0); - break; - } - case B_SOUND_MIXDOWN: - { - audio_mixdown(); - break; - } - case B_SOUND_LOOPSTART: - { -#ifdef SOUND_UNDER_DEVELOPMENT -/* if (sound->loopstart > sound->loopend) - sound->loopstart = sound->loopend;*/ -#endif - allqueue(REDRAWBUTSSOUND, 0); - BIF_preview_changed(G.buts); - break; - } - case B_SOUND_LOOPEND: - { -#ifdef SOUND_UNDER_DEVELOPMENT -/* if (sound->loopend < sound->loopstart) - sound->loopend = sound->loopstart;*/ -#endif - allqueue(REDRAWBUTSSOUND, 0); - BIF_preview_changed(G.buts); - break; - } - - default: - { - if (G.f & G_DEBUG) - { - printf("do_soundbuts: unhandled event %d\n", event); - } - break; - } - } -} - - -void soundbuts(void) -{ - short xco, yco, xcostart = 20; - bSound *sound; - bSample *sample; - uiBlock *block; - char *strp, str[32]; - ID *id; - char ch[20]; - char sampleinfo[200]; - char mixrateinfo[50]; - int mixrate; - - sound = G.buts->lockpoin; - if ((sound) && (sound->flags & SOUND_FLAGS_SEQUENCE)) sound = 0; - yco = 195; - - xco = xcostart; - sprintf(str, "buttonswin %d", curarea->win); - block= uiNewBlock(&curarea->uiblocks, str, UI_EMBOSSX, UI_HELV, curarea->win); - - if (sound) - { - sound_initialize_sample(sound); - - sample = sound->sample; - - uiSetButLock(sound->id.lib!=0, "Can't edit library data"); - - /* sound settings ------------------------------------------------------------------ */ - - uiDefBut(block, LABEL, 0, "Game sounds",xco,yco,195,20, 0, 0, 0, 0, 0, ""); - - yco -= 30; - uiBlockSetCol(block, BUTGREEN); - uiDefBut(block, BUT, B_SOUND_PLAY_SAMPLE, "Play", xco, yco, 195, 24, 0, 0.0, 0, 0, 0, - "Playback sample using settings below"); - - uiBlockSetCol(block, BUTGREY); - xco += 225; - - if (sound->sample && sound->sample->len) - { - if (sound->sample->channels == 1) - strcpy(ch, "Mono"); - else if (sound->sample->channels == 2) - strcpy(ch, "Stereo"); - else - strcpy(ch, "Unknown"); - - uiDefBut(block, LABEL, 0, "Sample: ",xco,yco,195,20, 0, 0, 0, 0, 0, ""); - xco +=55; - sprintf(sampleinfo, "%s, %d bit, %d Hz, %d samples", ch, sound->sample->bits, sound->sample->rate, (sound->sample->len/(sound->sample->bits/8)/sound->sample->channels)); - uiDefBut(block, LABEL, 0, sampleinfo,xco,yco,295,20, 0, 0, 0, 0, 0, ""); - } - else - { - uiDefBut(block, LABEL, 0, "No sample info available.",xco,yco,195,20, 0, 0, 0, 0, 0, ""); - xco +=55; - } - - xco += 314; - uiDefBut(block, BUT, B_SOUND_COPY_SOUND, "Copy sound", - xco,yco,95,24, 0, 0, 0, 0, 0, "Make a copy of the current sound"); - /* - xco += 25; - if (sample->channels > 1) - { - xco += 100; - uiDefButC(block, ROW, B_SOUND_REDRAW, "Left", xco, yco, 95, 20, &sound->channels, 1.0, (float)SOUND_CHANNELS_LEFT, 0, 0, ""); - xco += 100; - uiDefButC(block, ROW, B_SOUND_REDRAW, "Stereo", xco, yco, 95, 20, &sound->channels, 1.0, (float)SOUND_CHANNELS_STEREO, 0, 0, ""); - xco += 100; - uiDefButC(block, ROW, B_SOUND_REDRAW, "Right", xco, yco, 95, 20, &sound->channels, 1.0, (float)SOUND_CHANNELS_RIGHT, 0, 0, ""); - } - */ - - xco = xcostart; - yco -= 30; - uiDefBut(block, BUT, B_SOUND_LOAD_SAMPLE, "Load sample", - xco, yco,195,24, 0, 0, 0, 0, 0, "Load a different sample"); - - uiBlockSetCol(block, BUTGREY); - - id= (ID *)sound->sample; - IDnames_to_pupstring(&strp, NULL, NULL, samples, id, &(G.buts->menunr)); - if (strp[0]) { - xco += 200; - uiDefButS(block, MENU, B_SOUND_MENU_SAMPLE, strp,xco,yco,23,24, &(G.buts->menunr), 0, 0, 0, 0, "Select another loaded sample"); - } - MEM_freeN(strp); - - xco += 25; - uiDefBut(block, TEX, B_SOUND_NAME_SAMPLE, "",xco,yco,412,24, sound->name, 0.0, 79.0, 0, 0, "The sample used by this sound"); - - sprintf(str, "1"); - // sprintf(str, "%d", tex->ima->id.us); - xco += 415; - uiDefBut(block, BUT, B_SOUND_UNLINK_SAMPLE, str,xco,yco,23,24, 0, 0, 0, 0, 0, "The number of users"); - - if (sound->sample->packedfile) - packdummy = 1; - else - packdummy = 0; - - xco += 25; - uiDefIconButI(block, TOG|BIT|0, B_SOUND_UNPACK_SAMPLE, ICON_PACKAGE, - xco, yco,24,24, &packdummy, 0, 0, 0, 0,"Pack/Unpack this sample"); - /* - xco += 25; - uiDefBut(block, BUT, B_SOUND_RELOAD_SAMPLE, "Reload",xco, yco,68,24, 0, 0, 0, 0, 0, ""); - */ - /* parameters settings ------------------------------------------------------------------ */ - - xco = xcostart; - yco -= 45; - uiDefBut(block, LABEL, 0, "Game sound settings:",xco,yco,195,20, 0, 0, 0, 0, 0, ""); - - yco -= 30; - uiBlockSetCol(block, BUTGREY); - uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Volume: ", - xco,yco,195,24,&sound->volume, 0.0, 1.0, 0, 0, "Set the volume of this sound"); - - xco += 200; - uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Pitch: ", - xco,yco,195,24,&sound->pitch, -12.0, 12.0, 0, 0, "Set the pitch of this sound"); - - xco = xcostart; - yco -= 30; - uiBlockSetCol(block, BUTSALMON); - uiDefButI(block, TOG|BIT|SOUND_FLAGS_LOOP_BIT, B_SOUND_REDRAW, "Loop", - xco, yco, 95, 24, &sound->flags, 0.0, 0.0, 0, 0,"Toggle between looping on/off"); - - if (sound->flags & SOUND_FLAGS_LOOP) - { - xco += 100; - uiDefButI(block, TOG|BIT|SOUND_FLAGS_BIDIRECTIONAL_LOOP_BIT, B_SOUND_REDRAW, "Ping Pong", - xco, yco, 95, 24, &sound->flags, 0.0, 0.0, 0, 0,"Toggle between A->B and A->B->A looping"); - -#ifdef SOUND_UNDER_DEVELOPMENT -/* uiBlockSetCol(block, REDALERT); - xco += 100; - uiDefButI(block, NUM, B_SOUND_LOOPSTART, "loopstart: ", xco,yco,195,24, - &sound->loopstart, 0, sound->sample->len, 0, 0, "Set the startpoint for the loop of this sound"); - - xco += 200; - uiDefButI(block, NUM, B_SOUND_LOOPEND, "loopend: ",xco,yco,195,24, - &sound->loopend, 0, sound->sample->len, 0, 0, "Set the endpoint for the loop of this sound"); -*/ -#endif - } - -#ifdef SOUND_UNDER_DEVELOPMENT - xco = xcostart; - yco -= 30; - uiDefButI(block, TOG|BIT|SOUND_FLAGS_PRIORITY_BIT, B_SOUND_REDRAW, "Priority", - xco, yco, 95, 24, &sound->flags, 0.0, 0.0, 0, 0,"Toggle between high and low priority"); -#endif - - /* 2D & 3D settings ------------------------------------------------------------------ */ - - uiBlockSetCol(block, BUTGREY); - if (sound->sample->channels == 1) - { - xco = xcostart; - yco -= 30; - uiDefButI(block, TOG|BIT|SOUND_FLAGS_3D_BIT, B_SOUND_REDRAW, "3D Sound", - xco, yco, 95, 24, &sound->flags, 0, 0, 0, 0, "Turns 3D sound on"); - - if (sound->flags & SOUND_FLAGS_3D) - { - xco = xcostart; - yco -= 30; - uiBlockSetCol(block, BUTGREY); - uiDefBut(block, LABEL, 0, "3D surround settings:",xco,yco,195,20, 0, 0, 0, 0, 0, ""); - uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Scale: ", - xco,(short)(yco-=30),195,24,&sound->attenuation, 0.0, 5.0, 1.0, 0, "Sets the world-scaling factor for this sound"); - - /* - xco += 200; - uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Distance: ", - xco,yco,195,20,&sound->distance, 0.0, 100.0, 1.0, 0, "Reference distance: sets the distance at which the listener will experience gain"); - xco -= 200; - yco -= 30; - uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Minvol: ", - xco,yco,195,20,&sound->min_gain, 0.0, 1.0, 1.0, 0, "Minimal volume: sets the lower threshold for the gain of this sound"); - xco += 200; - uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Maxvol: ", - xco,yco,195,20,&sound->max_gain, 0.0, 10.0, 1.0, 0, "Maximal volume: sets the upper threshold for the gain of this sound"); - */ - } - } - - /* listener settings ------------------------------------------------------------------ */ - - draw_buttons_edge(curarea->win, 740); - - xco = xcostart + 750; - yco = 195; - uiBlockSetCol(block, BUTGREY); - mixrate = sound_get_mixrate(); - sprintf(mixrateinfo, "Game Mixrate: %d Hz", mixrate); - uiDefBut(block, LABEL, 0, mixrateinfo, xco,yco,295,20, 0, 0, 0, 0, 0, ""); - - yco -= 30; - - uiDefBut(block, LABEL, 0, "Game listener settings:",xco,yco,195,20, 0, 0, 0, 0, 0, ""); - - yco -= 30; - uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Volume: ", - xco,yco,195,24,&G.listener->gain, 0.0, 1.0, 1.0, 0, "Sets the maximum volume for the overall sound"); - - yco -= 30; - uiDefBut(block, LABEL, 0, "Game Doppler effect settings:",xco,yco,195,20, 0, 0, 0, 0, 0, ""); - /* - yco -= 30; - uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Scale: ", - xco,yco,195,20,&G.listener->dopplerfactor, 0.0, 10.0, 1.0, 0, "Doppler scaling: sets the scaling factor for doppler effect"); - */ - yco -= 30; - uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Doppler: ", - xco,yco,195,24,&G.listener->dopplervelocity, 0.0, 10.0, 1.0, 0, "Use this for scaling the doppler effect"); - /* - if (sound->channels != SOUND_CHANNELS_STEREO || sample->channels == 1) - { - uiBlockSetCol(block, BUTGREEN); - uiDefButI(block, TOGN|BIT|SOUND_FLAGS_FIXED_PANNING_BIT, B_SOUND_REDRAW, "3D pan", - xco, yco, 95, 20, &sound->flags, 0, 0, 0, 0, ""); - - uiBlockSetCol(block, BUTSALMON); - xco += 100; - uiDefButI(block, TOG|BIT|SOUND_FLAGS_FIXED_PANNING_BIT, B_SOUND_REDRAW, "Fixed", - xco, yco, 95, 20, &sound->flags, 0, 0, 0, 0, ""); - - uiBlockSetCol(block, BUTGREY); - if (sound->flags & SOUND_FLAGS_FIXED_PANNING) - { - xco += 100; - uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Pann: ", - xco,yco,195,20,&sound->panning, -1.0, 1.0, 0, 0, ""); - } - } - */ - uiDrawBlock(block); - } - /* audio sequence engine settings ------------------------------------------------------------------ */ - - draw_buttons_edge(curarea->win, 1000); - - xco = xcostart + 1010; - yco = 195; - - uiDefBut(block, LABEL, 0, "Audio sequencer settings", xco,yco,295,20, 0, 0, 0, 0, 0, ""); - - yco -= 25; - sprintf(mixrateinfo, "Mixing/Sync (latency: %d ms)", (int)( (((float)U.mixbufsize)/(float)G.scene->audio.mixrate)*1000.0 ) ); - uiDefBut(block, LABEL, 0, mixrateinfo, xco,yco,295,20, 0, 0, 0, 0, 0, ""); - - yco -= 25; - uiBlockSetCol(block, BUTGREY); - uiDefButI(block, ROW, B_SOUND_RATECHANGED, "44.1 kHz", xco,yco,75,20, &G.scene->audio.mixrate, 2.0, 44100.0, 0, 0, "Mix at 44.1 kHz"); - uiDefButI(block, ROW, B_SOUND_RATECHANGED, "48.0 kHz", xco+80,yco,75,20, &G.scene->audio.mixrate, 2.0, 48000.0, 0, 0, "Mix at 48 kHz"); - uiBlockSetCol(block, BUTSALMON); - uiDefBut(block, BUT, B_SOUND_RECALC, "Recalc", xco+160,yco,75,20, 0, 0, 0, 0, 0, "Recalculate samples"); - - yco -= 25; - uiBlockSetCol(block, BUTGREEN); - uiDefButS(block, TOG|BIT|1, B_SOUND_CHANGED, "Sync", xco,yco,115,20, &G.scene->audio.flag, 0, 0, 0, 0, "Use sample clock for syncing animation to audio"); - uiDefButS(block, TOG|BIT|2, B_SOUND_CHANGED, "Scrub", xco+120,yco,115,20, &G.scene->audio.flag, 0, 0, 0, 0, "Scrub when changing frames"); - - yco -= 25; - uiDefBut(block, LABEL, 0, "Main mix", xco,yco,295,20, 0, 0, 0, 0, 0, ""); - - yco -= 25; - uiBlockSetCol(block, BUTGREY); - uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Main (dB): ", - xco,yco,235,24,&G.scene->audio.main, -24.0, 6.0, 0, 0, "Set the audio master gain/attenuation in dB"); - - yco -= 25; - uiDefButS(block, TOG|BIT|0, 0, "Mute", xco,yco,235,24, &G.scene->audio.flag, 0, 0, 0, 0, "Mute audio from sequencer"); - - yco -= 35; - uiBlockSetCol(block, BUTSALMON); - uiDefBut(block, BUT, B_SOUND_MIXDOWN, "MIXDOWN", xco,yco,235,24, 0, 0, 0, 0, 0, "Create WAV file from sequenced audio"); - - uiDrawBlock(block); -} - -/* ************************ LAMP *************************** */ - -void do_lampbuts(unsigned short event) -{ - Lamp *la; - MTex *mtex; - - switch(event) { - case B_LAMPREDRAW: - BIF_preview_changed(G.buts); - allqueue(REDRAWVIEW3D, 0); - break; - case B_TEXCLEARLAMP: - la= G.buts->lockpoin; - mtex= la->mtex[ la->texact ]; - if(mtex) { - if(mtex->tex) mtex->tex->id.us--; - MEM_freeN(mtex); - la->mtex[ la->texact ]= 0; - allqueue(REDRAWBUTSLAMP, 0); - allqueue(REDRAWOOPS, 0); - BIF_preview_changed(G.buts); - } - break; - case B_SBUFF: - { - la= G.buts->lockpoin; - la->bufsize = la->bufsize&=(~15); - allqueue(REDRAWBUTSLAMP, 0); - allqueue(REDRAWOOPS, 0); - /*la->bufsize = la->bufsize % 64;*/ - } - break; - } - - if(event) freefastshade(); -} - - -void lampbuts(void) -{ - Object *ob; - Lamp *la; - MTex *mtex; - ID *id; - uiBlock *block; - float grid=0.0; - int loos, a; - char *strp, str[32]; - short xco; - - if(G.vd) grid= G.vd->grid; - if(grid<1.0) grid= 1.0; - - ob= OBACT; - if(ob==0) return; - if(ob->type!=OB_LAMP) return; - - sprintf(str, "buttonswin %d", curarea->win); - block= uiNewBlock(&curarea->uiblocks, str, UI_EMBOSSX, UI_HELV, curarea->win); - - la= ob->data; - uiSetButLock(la->id.lib!=0, "Can't edit library data"); - - uiBlockSetCol(block, BUTGREEN); - uiDefButS(block, ROW,B_LAMPREDRAW,"Lamp", 317,190,61,25,&la->type,1.0,(float)LA_LOCAL, 0, 0, "Use a point light source"); - uiDefButS(block, ROW,B_LAMPREDRAW,"Spot", 379,190,59,25,&la->type,1.0,(float)LA_SPOT, 0, 0, "Restrict lamp to conical space"); - uiDefButS(block, ROW,B_LAMPREDRAW,"Sun", 439,190,58,25,&la->type,1.0,(float)LA_SUN, 0, 0, "Light shines from constant direction"); - uiDefButS(block, ROW,B_LAMPREDRAW,"Hemi", 499,190,55,25,&la->type,1.0,(float)LA_HEMI, 0, 0, "Light shines as half a sphere"); - - uiBlockSetCol(block, BUTGREY); - uiDefButF(block, NUM,B_LAMPREDRAW,"Dist:",611,190,104,25,&la->dist, 0.01, 5000.0, 100, 0, "Set the distance value"); - - uiBlockSetCol(block, BUTBLUE); - uiDefButS(block, TOG|BIT|3, B_MATPRV,"Quad", 203,196,100,17,&la->mode, 0, 0, 0, 0, "Use inverse quadratic proportion"); - uiDefButS(block, TOG|BIT|6, REDRAWVIEW3D,"Sphere", 203,178,100,17,&la->mode, 0, 0, 0, 0, "Lamp only shines inside a sphere"); - uiDefButS(block, TOG|BIT|0, REDRAWVIEW3D, "Shadows", 203,160,100,17,&la->mode, 0, 0, 0, 0, "Let lamp produce shadows"); - uiDefButS(block, TOG|BIT|1, 0,"Halo", 203,142,100,17,&la->mode, 0, 0, 0, 0, "Render spotlights with a volumetric halo"); - uiDefButS(block, TOG|BIT|2, 0,"Layer", 203,124,100,17,&la->mode, 0, 0, 0, 0, "Illuminate objects in the same layer only"); - uiDefButS(block, TOG|BIT|4, B_MATPRV,"Negative", 203,106,100,17,&la->mode, 0, 0, 0, 0, "Cast negative light"); - uiDefButS(block, TOG|BIT|5, 0,"OnlyShadow", 203,88,100,17,&la->mode, 0, 0, 0, 0, "Render shadow only"); - uiDefButS(block, TOG|BIT|7, B_LAMPREDRAW,"Square", 203,70,100,17,&la->mode, 0, 0, 0, 0, "Use square spotbundles"); - uiDefButS(block, TOG|BIT|11, 0,"No Diffuse", 203,52,100,17,&la->mode, 0, 0, 0, 0, "No diffuse shading of material"); - uiDefButS(block, TOG|BIT|12, 0,"No Specular", 203,34,100,17,&la->mode, 0, 0, 0, 0, "No specular shading of material"); - - -#ifdef __SHADOW_EXP - /* move this elsewhere */ - uiDefButS(block, TOG|BIT|10, 0,"DeepShadow", 203,216,100,19,&la->mode, 0, 0, 0, 0, ""); -#endif - - uiBlockSetCol(block, BUTGREY); - uiDefButS(block, NUM,B_SBUFF,"ShadowBuffSize:", 203,10,140,19, &la->bufsize,512,5120, 0, 0, "Set the size of the shadow buffer"); - uiDefButF(block, NUM,REDRAWVIEW3D,"ClipSta:", 346,30,146,19, &la->clipsta, 0.1*grid,1000.0*grid, 10, 0, "Set the shadow map clip start"); - uiDefButF(block, NUM,REDRAWVIEW3D,"ClipEnd:", 346,9,146,19,&la->clipend, 1.0, 5000.0*grid, 100, 0, "Set the shadow map clip end"); - - uiDefButS(block, NUM,0,"Samples:", 496,30,105,19, &la->samp,1.0,16.0, 0, 0, "Number of shadow map samples"); - uiDefButS(block, NUM,0,"Halo step:", 496,10,105,19, &la->shadhalostep, 0.0, 12.0, 0, 0, "Volumetric halo sampling frequency"); - uiDefButF(block, NUM,0,"Bias:", 605,30,108,19, &la->bias, 0.01, 5.0, 1, 0, "Shadow map sampling bias"); - uiDefButF(block, NUM,0,"Soft:", 605,10,108,19, &la->soft,1.0,100.0, 100, 0, "Set the size of the shadow sample area"); - - uiBlockSetCol(block, BUTGREY); - uiDefButF(block, NUMSLI,B_MATPRV,"Energy ", 520,156,195,20, &(la->energy), 0.0, 10.0, 0, 0, "Set the intensity of the light"); - - uiDefButF(block, NUMSLI,B_MATPRV,"R ", 520,128,194,20,&la->r, 0.0, 1.0, B_COLLAMP, 0, "Set the red component of the light"); - uiDefButF(block, NUMSLI,B_MATPRV,"G ", 520,108,194,20,&la->g, 0.0, 1.0, B_COLLAMP, 0, "Set the green component of the light"); - uiDefButF(block, NUMSLI,B_MATPRV,"B ", 520,88,194,20,&la->b, 0.0, 1.0, B_COLLAMP, 0, "Set the blue component of the light"); - - uiDefButF(block, COL, B_COLLAMP, "", 520,64,193,23, &la->r, 0, 0, 0, 0, ""); - - uiDefButF(block, NUMSLI,B_LAMPREDRAW,"SpotSi ",317,157,192,19,&la->spotsize, 1.0, 180.0, 0, 0, "Set the angle of the spot beam in degrees"); - uiDefButF(block, NUMSLI,B_MATPRV,"SpotBl ", 316,136,192,19,&la->spotblend, 0.0, 1.0, 0, 0, "Set the softness of the spot edge"); - uiDefButF(block, NUMSLI,B_MATPRV,"Quad1 ", 316,106,192,19,&la->att1, 0.0, 1.0, 0, 0, "Set the light intensity value 1 for a quad lamp"); - uiDefButF(block, NUMSLI,B_MATPRV,"Quad2 ", 317,86,191,19,&la->att2, 0.0, 1.0, 0, 0, "Set the light intensity value 2 for a quad lamp"); - uiDefButF(block, NUMSLI,0,"HaloInt ", 316,64,193,19,&la->haint, 0.0, 5.0, 0, 0, "Set the intensity of the spot halo"); - - - /* TEX CHANNELS */ - uiBlockSetCol(block, BUTGREY); - xco= 745; - for(a= 0; a<6; a++) { - mtex= la->mtex[a]; - if(mtex && mtex->tex) splitIDname(mtex->tex->id.name+2, str, &loos); - else strcpy(str, ""); - str[10]= 0; - uiDefButS(block, ROW, B_REDR, str, xco, 195, 83, 20, &(la->texact), 3.0, (float)a, 0, 0, ""); - xco+= 85; - } - - mtex= la->mtex[ la->texact ]; - if(mtex==0) { - mtex= &emptytex; - default_mtex(mtex); - mtex->texco= TEXCO_VIEW; - } - - /* TEXCO */ - uiBlockSetCol(block, BUTGREEN); - uiDefButS(block, ROW, B_MATPRV, "Object", 745,146,49,18, &(mtex->texco), 4.0, (float)TEXCO_OBJECT, 0, 0, "Use linked object's coordinates for texture coordinates"); - uiDefIDPoinBut(block, test_obpoin_but, B_MATPRV, "", 745,166,133,18, &(mtex->object), ""); - uiDefButS(block, ROW, B_MATPRV, "Glob", 795,146,45,18, &(mtex->texco), 4.0, (float)TEXCO_GLOB, 0, 0, "Generate texture coordinates from global coordinates"); - uiDefButS(block, ROW, B_MATPRV, "View", 839,146,39,18, &(mtex->texco), 4.0, (float)TEXCO_VIEW, 0, 0, "Generate texture coordinates from view coordinates"); - - uiBlockSetCol(block, BUTGREY); - uiDefButF(block, NUM, B_MATPRV, "dX", 745,114,133,18, mtex->ofs, -20.0, 20.0, 10, 0, "Set the extra translation of the texture coordinate"); - uiDefButF(block, NUM, B_MATPRV, "dY", 745,94,133,18, mtex->ofs+1, -20.0, 20.0, 10, 0, "Set the extra translation of the texture coordinate"); - uiDefButF(block, NUM, B_MATPRV, "dZ", 745,74,133,18, mtex->ofs+2, -20.0, 20.0, 10, 0, "Set the extra translation of the texture coordinate"); - uiDefButF(block, NUM, B_MATPRV, "sizeX", 745,50,133,18, mtex->size, -10.0, 10.0, 10, 0, "Set the extra scaling of the texture coordinate"); - uiDefButF(block, NUM, B_MATPRV, "sizeY", 745,30,133,18, mtex->size+1, -10.0, 10.0, 10, 0, "Set the extra scaling of the texture coordinate"); - uiDefButF(block, NUM, B_MATPRV, "sizeZ", 745,10,133,18, mtex->size+2, -10.0, 10.0, 10, 0, "Set the extra scaling of the texture coordinate"); - - /* TEXTUREBLOK SELECT */ - id= (ID *)mtex->tex; - IDnames_to_pupstring(&strp, NULL, "ADD NEW %x 32767", &(G.main->tex), id, &(G.buts->texnr)); - - /* doesnt work, because lockpoin points to lamp, not to texture */ - uiDefButS(block, MENU, B_LTEXBROWSE, strp, 900,146,20,19, &(G.buts->texnr), 0, 0, 0, 0, "Select an existing texture, or create new"); - MEM_freeN(strp); - - if(id) { - uiDefBut(block, TEX, B_IDNAME, "TE:", 900,166,163,19, id->name+2, 0.0, 18.0, 0, 0, "Name of the texture block"); - sprintf(str, "%d", id->us); - uiDefBut(block, BUT, 0, str, 996,146,21,19, 0, 0, 0, 0, 0, "Select an existing texture, or create new"); - uiDefIconBut(block, BUT, B_AUTOTEXNAME, ICON_AUTO, 1041,146,21,19, 0, 0, 0, 0, 0, "Auto assign a name to the texture"); - if(id->lib) { - if(la->id.lib) uiDefIconBut(block, BUT, 0, ICON_DATALIB, 1019,146,21,19, 0, 0, 0, 0, 0, ""); - else uiDefIconBut(block, BUT, 0, ICON_PARLIB, 1019,146,21,19, 0, 0, 0, 0, 0, ""); - } - uiBlockSetCol(block, BUTSALMON); - uiDefBut(block, BUT, B_TEXCLEARLAMP, "Clear", 922, 146, 72, 19, 0, 0, 0, 0, 0, "Erase link to texture"); - uiBlockSetCol(block, BUTGREY); - } - - /* TEXTURE OUTPUT */ - uiDefButS(block, TOG|BIT|1, B_MATPRV, "Stencil", 900,114,52,18, &(mtex->texflag), 0, 0, 0, 0, "Set the mapping to stencil mode"); - uiDefButS(block, TOG|BIT|2, B_MATPRV, "Neg", 954,114,38,18, &(mtex->texflag), 0, 0, 0, 0, "Apply the inverse of the texture"); - uiDefButS(block, TOG|BIT|0, B_MATPRV, "RGBtoInt", 994,114,69,18, &(mtex->texflag), 0, 0, 0, 0, "Use an RGB texture as an intensity texture"); - - uiDefButF(block, COL, B_MTEXCOL, "", 900,100,163,12, &(mtex->r), 0, 0, 0, 0, ""); - uiDefButF(block, NUMSLI, B_MATPRV, "R ", 900,80,163,18, &(mtex->r), 0.0, 1.0, B_MTEXCOL, 0, "Set the red component of the intensity texture to blend with"); - uiDefButF(block, NUMSLI, B_MATPRV, "G ", 900,60,163,18, &(mtex->g), 0.0, 1.0, B_MTEXCOL, 0, "Set the green component of the intensity texture to blend with"); - uiDefButF(block, NUMSLI, B_MATPRV, "B ", 900,40,163,18, &(mtex->b), 0.0, 1.0, B_MTEXCOL, 0, "Set the blue component of the intensity texture to blend with"); - uiDefButF(block, NUMSLI, B_MATPRV, "DVar ", 900,10,163,18, &(mtex->def_var), 0.0, 1.0, 0, 0, "Set the value the texture blends with"); - - /* MAP TO */ - uiBlockSetCol(block, BUTGREEN); - uiDefButS(block, TOG|BIT|0, B_MATPRV, "Col", 1087,166,81,18, &(mtex->mapto), 0, 0, 0, 0, "Let the texture affect the colour of the lamp"); - - uiBlockSetCol(block, BUTGREY); - uiDefButS(block, ROW, B_MATPRV, "Blend", 1087,114,48,18, &(mtex->blendtype), 9.0, (float)MTEX_BLEND, 0, 0, "Mix the values"); - uiDefButS(block, ROW, B_MATPRV, "Mul", 1136,114,44,18, &(mtex->blendtype), 9.0, (float)MTEX_MUL, 0, 0, "Multiply the values"); - uiDefButS(block, ROW, B_MATPRV, "Add", 1182,114,41,18, &(mtex->blendtype), 9.0, (float)MTEX_ADD, 0, 0, "Add the values"); - uiDefButS(block, ROW, B_MATPRV, "Sub", 1226,114,40,18, &(mtex->blendtype), 9.0, (float)MTEX_SUB, 0, 0, "Subtract the values"); - - uiDefButF(block, NUMSLI, B_MATPRV, "Col ", 1087,50,179,18, &(mtex->colfac), 0.0, 1.0, 0, 0, "Set the amount the texture affects the colour"); - uiDefButF(block, NUMSLI, B_MATPRV, "Nor ", 1087,30,179,18, &(mtex->norfac), 0.0, 1.0, 0, 0, "Set the amount the texture affects the normal"); - uiDefButF(block, NUMSLI, B_MATPRV, "Var ", 1087,10,179,18, &(mtex->varfac), 0.0, 1.0, 0, 0, "Set the amount the texture affects the value"); - - - BIF_previewdraw(G.buts); - - uiDrawBlock(block); -} - -/* ***************************** ANIM ************************** */ - -void do_animbuts(unsigned short event) -{ - Object *ob; - Base *base; - Effect *eff, *effn; - int type; - - ob= OBACT; - - switch(event) { - - case B_RECALCPATH: - calc_curvepath(OBACT); - allqueue(REDRAWVIEW3D, 0); - break; - case B_MUL_IPO: - scale_editipo(); - allqueue(REDRAWBUTSANIM, 0); - break; - case B_AUTOTIMEOFS: - auto_timeoffs(); - break; - case B_FRAMEMAP: - G.scene->r.framelen= G.scene->r.framapto; - G.scene->r.framelen/= G.scene->r.images; - break; - case B_NEWEFFECT: - if(ob) { - if (BLI_countlist(&ob->effect)==MAX_EFFECT) - error("Unable to add: effect limit reached"); - else - copy_act_effect(ob); - } - allqueue(REDRAWBUTSANIM, 0); - break; - case B_DELEFFECT: - if(ob==0 || ob->type!=OB_MESH) break; - eff= ob->effect.first; - while(eff) { - effn= eff->next; - if(eff->flag & SELECT) { - BLI_remlink(&ob->effect, eff); - free_effect(eff); - break; - } - eff= effn; - } - allqueue(REDRAWBUTSANIM, 0); - allqueue(REDRAWVIEW3D, 0); - break; - case B_NEXTEFFECT: - if(ob==0 || ob->type!=OB_MESH) break; - eff= ob->effect.first; - while(eff) { - if(eff->flag & SELECT) { - if(eff->next) { - eff->flag &= ~SELECT; - eff->next->flag |= SELECT; - } - break; - } - eff= eff->next; - } - allqueue(REDRAWBUTSANIM, 0); - break; - case B_PREVEFFECT: - if(ob==0 || ob->type!=OB_MESH) break; - eff= ob->effect.first; - while(eff) { - if(eff->flag & SELECT) { - if(eff->prev) { - eff->flag &= ~SELECT; - eff->prev->flag |= SELECT; - } - break; - } - eff= eff->next; - } - allqueue(REDRAWBUTSANIM, 0); - break; - case B_CHANGEEFFECT: - if(ob==0 || ob->type!=OB_MESH) break; - eff= ob->effect.first; - while(eff) { - if(eff->flag & SELECT) { - if(eff->type!=eff->buttype) { - BLI_remlink(&ob->effect, eff); - type= eff->buttype; - free_effect(eff); - eff= add_effect(type); - BLI_addtail(&ob->effect, eff); - } - break; - } - eff= eff->next; - } - allqueue(REDRAWBUTSANIM, 0); - allqueue(REDRAWVIEW3D, 0); - break; - case B_CALCEFFECT: - if(ob==0 || ob->type!=OB_MESH) break; - eff= ob->effect.first; - while(eff) { - if(eff->flag & SELECT) { - if(eff->type==EFF_PARTICLE) build_particle_system(ob); - else if(eff->type==EFF_WAVE) object_wave(ob); - } - eff= eff->next; - } - allqueue(REDRAWVIEW3D, 0); - allqueue(REDRAWBUTSANIM, 0); - break; - case B_RECALCAL: - base= FIRSTBASE; - while(base) { - if(base->lay & G.vd->lay) { - ob= base->object; - eff= ob->effect.first; - while(eff) { - if(eff->flag & SELECT) { - if(eff->type==EFF_PARTICLE) build_particle_system(ob); - } - eff= eff->next; - } - } - base= base->next; - } - allqueue(REDRAWVIEW3D, 0); - break; - case B_SETSPEED: - set_speed_editipo(hspeed); - break; - case B_PRINTSPEED: - ob= OBACT; - if(ob) { - float vec[3]; - CFRA++; - do_ob_ipo(ob); - where_is_object(ob); - VECCOPY(vec, ob->obmat[3]); - CFRA--; - do_ob_ipo(ob); - where_is_object(ob); - VecSubf(vec, vec, ob->obmat[3]); - prspeed= Normalise(vec); - scrarea_queue_winredraw(curarea); - } - break; - case B_PRINTLEN: - ob= OBACT; - if(ob && ob->type==OB_CURVE) { - Curve *cu=ob->data; - - if(cu->path) prlen= cu->path->totdist; else prlen= -1.0; - scrarea_queue_winredraw(curarea); - } - break; - case B_RELKEY: - allspace(REMAKEIPO, 0); - allqueue(REDRAWBUTSANIM, 0); - allqueue(REDRAWIPO, 0); - break; - - default: - if(event>=B_SELEFFECT && eventeffect.first; - while(eff) { - if(event==a) eff->flag |= SELECT; - else eff->flag &= ~SELECT; - - a++; - eff= eff->next; - } - allqueue(REDRAWBUTSANIM, 0); - } - } - } -} - -void animbuts(void) -{ - Object *ob; - Mesh *me; - Lattice *lt; - Effect *eff; - Curve *cu; - ScrArea *sa; - uiBlock *block; - int a, ok; - char str[32]; - short x, y; - - sprintf(str, "buttonswin %d", curarea->win); - block= uiNewBlock(&curarea->uiblocks, str, UI_EMBOSSX, UI_HELV, curarea->win); - - uiDefButS(block, NUM,REDRAWSEQ,"Sta:", 320,17,93,27,&G.scene->r.sfra,1.0,18000.0, 0, 0, "Specify the start frame of the animation"); - uiDefButS(block, NUM,REDRAWSEQ,"End:", 416,17,95,27,&G.scene->r.efra,1.0,18000.0, 0, 0, "Specify the end frame of the animation"); - - uiDefButS(block, NUM,B_FRAMEMAP,"Map Old:", 320,69,93,22,&G.scene->r.framapto,1.0,900.0, 0, 0, "Specify old map value in frames"); - uiDefButS(block, NUM,B_FRAMEMAP,"Map New:", 416,69,95,22,&G.scene->r.images,1.0,900.0, 0, 0, "Specify new map value in frames"); - - uiDefButS(block, NUM,REDRAWSEQ,"Frs/sec:", 320,47,93,19, &G.scene->r.frs_sec, 1.0, 120.0, 100.0, 0, "Frames per second"); - - uiBlockSetCol(block, BUTGREEN); - uiDefButS(block, TOG|BIT|1, B_SOUND_CHANGED, "Sync", 416,47,95,19, &G.scene->audio.flag, 0, 0, 0, 0, "Use sample clock for syncing animation to audio"); - -/* intrr: obsoleted, replaced by frs/sec */ -/* uiDefButS(block, NUM, 0, "AnimSpeed:", 320,47,192,19, &G.animspeed, 1.0, 9.0, 0, 0, "Set the maximum speed of the animation");*/ - - - ob= OBACT; - if(ob) { - - uiBlockSetCol(block, BUTGREEN); -/* uiDefButC(block, TOG|BIT|1, REDRAWVIEW3D, "Quaternions", 320,190,192,19, &ob->transflag, 0.0, 0.0, 0, 0, "Use quaternions for rotation"); */ - uiBlockSetCol(block, BUTGREY); - - uiDefButF(block, NUM, REDRAWALL, "TimeOffset:", 23,18,114,30, &ob->sf, -9000.0, 9000.0, 100, 0, "Specify an offset in frames"); - - uiBlockSetCol(block, BUTGREEN); - uiDefButC(block, TOG|BIT|0, REDRAWVIEW3D, "Draw Key", 25,144,84,19, &ob->ipoflag, 0, 0, 0, 0, "Draw object as key position"); - uiDefButC(block, TOG|BIT|1, REDRAWVIEW3D, "Draw Key Sel", 25,123,84,19, &ob->ipoflag, 0, 0, 0, 0, "Limit the drawing of object keys"); - - uiDefButC(block, TOG|BIT|2, REDRAWALL, "Offs Ob", 25,64,60,20, &ob->ipoflag, 0, 0, 0, 0, "Let the timeoffset work on its own objectipo"); - uiDefButC(block, TOG|BIT|6, REDRAWALL, "Offs Par", 85,64,60,20, &ob->ipoflag, 0, 0, 0, 0, "Let the timeoffset work on the parent"); - uiDefButC(block, TOG|BIT|7, REDRAWALL, "Offs Parti", 145,64,60,20, &ob->ipoflag, 0, 0, 0, 0, "Let the timeoffset work on the particle effect"); - - uiDefButS(block, TOG|BIT|4, 0, "SlowPar", 205,64,60,20, &ob->partype, 0, 0, 0, 0, "Create a delay in the parent relationship"); - - /* uiDefButC(block, TOG|BIT|5, REDRAWALL, "Offs Path", 85,64,60,20, &ob->ipoflag, 0, 0, 0, 0); ,""*/ - /* uiDefButC(block, TOG|BIT|3, REDRAWALL, "Offs Mat", 145,64,60,20, &ob->ipoflag, 0, 0, 0, 0); ,""*/ - /* uiDefButC(block, TOG|BIT|4, REDRAWALL, "Offs VertKey", 205,64,60,20, &ob->ipoflag, 0, 0, 0, 0); ,""*/ - - - uiBlockSetCol(block, BUTGREY); - uiDefButC(block, TOG|BIT|3, REDRAWVIEW3D, "DupliFrames", 112,144,106,19, &ob->transflag, 0, 0, 0, 0, "Make copy of object for every frame"); - uiDefButC(block, TOG|BIT|4, REDRAWVIEW3D, "DupliVerts", 112,123,80,19, &ob->transflag, 0, 0, 0, 0, "Duplicate child objects on all vertices"); - uiBlockSetCol(block, BUTGREEN); - uiDefButC(block, TOG|BIT|5, REDRAWVIEW3D, "Rot", 194,123,24,19, &ob->transflag, 0, 0, 0, 0, "Rotate dupli according to facenormal"); - - uiBlockSetCol(block, BUTGREY); - uiDefButS(block, NUM, REDRAWVIEW3D, "DupSta:", 220,144,93,19, &ob->dupsta, 1.0, 1500.0, 0, 0, "Specify startframe for Dupliframes"); - uiDefButS(block, NUM, REDRAWVIEW3D, "DupEnd", 315,144,93,19, &ob->dupend, 1.0, 2500.0, 0, 0, "Specify endframe for Dupliframes"); - uiDefButS(block, NUM, REDRAWVIEW3D, "DupOn:", 220,123,93,19, &ob->dupon, 1.0, 1500.0, 0, 0, ""); - uiDefButS(block, NUM, REDRAWVIEW3D, "DupOff", 315,123,93,19, &ob->dupoff, 0.0, 1500.0, 0, 0, ""); - uiBlockSetCol(block, BUTGREEN); - uiDefButC(block, TOG|BIT|6, REDRAWVIEW3D, "No Speed", 410,144,93,19, &ob->transflag, 0, 0, 0, 0, "Set dupliframes to still, regardless of frame"); - uiDefButC(block, TOG|BIT|7, REDRAWVIEW3D, "Powertrack", 410,123,93,19, &ob->transflag, 0, 0, 0, 0, "Switch objects rotation off"); - - uiBlockSetCol(block, BUTSALMON); - uiDefBut(block, BUT, B_AUTOTIMEOFS, "Automatic Time", 140,18,104,31, 0, 0, 0, 0, 0, "Generate automatic timeoffset values for all selected frames"); - uiBlockSetCol(block, BUTGREY); - sprintf(str, "%.4f", prspeed); - uiDefBut(block, LABEL, 0, str, 247,40,63,31, 0, 1.0, 0, 0, 0, ""); - uiDefBut(block, BUT, B_PRINTSPEED, "PrSpeed", 247,18,63,31, 0, 0, 0, 0, 0, "Print objectspeed"); - - if(ob->type==OB_MESH) { - me= ob->data; - if(me->key) { - uiDefButS(block, NUM, B_DIFF, "Slurph:", 125,101,93,19, &(me->key->slurph), -500.0, 500.0, 0, 0, ""); - uiDefButS(block, TOG, B_RELKEY, "Relative Keys", 220,100,93,19, &me->key->type, 0, 0, 0, 0, ""); - } - } - if(ob->type==OB_CURVE) { - cu= ob->data; - uiDefButS(block, NUM, B_RECALCPATH, "PathLen:", 34,100,90,19, &cu->pathlen, 1.0, 9000.0, 0, 0, ""); - /* if(cu->key==0) { */ - uiDefButS(block, TOG|BIT|3, B_RECALCPATH, "CurvePath", 125,100,90,19 , &cu->flag, 0, 0, 0, 0, ""); - uiDefButS(block, TOG|BIT|4, REDRAWVIEW3D, "CurveFollow", 216,100,90,19, &cu->flag, 0, 0, 0, 0, ""); - /* } */ - sprintf(str, "%.4f", prlen); - uiDefBut(block, LABEL, 0, str, 396,100,90,19, 0, 1.0, 0, 0, 0, ""); - uiDefBut(block, BUT, B_PRINTLEN, "PrintLen", 306,100,90,19, 0, 0, 0, 0, 0, ""); - } - if(ob->type==OB_SURF) { - cu= ob->data; - - if(cu->key) { - /* uiDefButS(block, NUM, B_DIFF, "Slurph:", 124,100,93,19, &(cu->key->slurph), -500.0, 500.0,0,0); ,""*/ - uiDefButS(block, TOG, B_RELKEY, "Relative Keys", 220,100,93,19, &cu->key->type, 0, 0, 0, 0, ""); - } - } - if(ob->type==OB_LATTICE) { - lt= ob->data; - if(lt->key) { - uiDefButS(block, NUM, B_DIFF, "Slurph:", 124,100,93,19, &(lt->key->slurph), -500.0, 500.0, 0, 0, ""); - uiDefButS(block, TOG, B_RELKEY, "Relative Keys", 370,190,133,19, <->key->type, 0, 0, 0, 0, ""); - } + xco += 314; + uiDefBut(block, BUT, B_SOUND_COPY_SOUND, "Copy sound", + xco,yco,95,24, 0, 0, 0, 0, 0, "Make a copy of the current sound"); + /* + xco += 25; + if (sample->channels > 1) + { + xco += 100; + uiDefButC(block, ROW, B_SOUND_REDRAW, "Left", xco, yco, 95, 20, &sound->channels, 1.0, (float)SOUND_CHANNELS_LEFT, 0, 0, ""); + xco += 100; + uiDefButC(block, ROW, B_SOUND_REDRAW, "Stereo", xco, yco, 95, 20, &sound->channels, 1.0, (float)SOUND_CHANNELS_STEREO, 0, 0, ""); + xco += 100; + uiDefButC(block, ROW, B_SOUND_REDRAW, "Right", xco, yco, 95, 20, &sound->channels, 1.0, (float)SOUND_CHANNELS_RIGHT, 0, 0, ""); } + */ - uiBlockSetCol(block, BUTGREEN); - uiDefButC(block, ROW,REDRAWVIEW3D,"TrackX", 27,190,58,17, &ob->trackflag, 12.0, 0.0, 0, 0, "Specify the axis that points to another object"); - uiDefButC(block, ROW,REDRAWVIEW3D,"Y", 85,190,19,17, &ob->trackflag, 12.0, 1.0, 0, 0, "Specify the axis that points to another object"); - uiDefButC(block, ROW,REDRAWVIEW3D,"Z", 104,190,19,17, &ob->trackflag, 12.0, 2.0, 0, 0, "Specify the axis that points to another object"); - uiDefButC(block, ROW,REDRAWVIEW3D,"-X", 123,190,24,17, &ob->trackflag, 12.0, 3.0, 0, 0, "Specify the axis that points to another object"); - uiDefButC(block, ROW,REDRAWVIEW3D,"-Y", 147,190,24,17, &ob->trackflag, 12.0, 4.0, 0, 0, "Specify the axis that points to another object"); - uiDefButC(block, ROW,REDRAWVIEW3D,"-Z", 171,190,24,17, &ob->trackflag, 12.0, 5.0, 0, 0, "Specify the axis that points to another object"); - uiDefButC(block, ROW,REDRAWVIEW3D,"UpX", 205,190,40,17, &ob->upflag, 13.0, 0.0, 0, 0, "Specify the axis that points up"); - uiDefButC(block, ROW,REDRAWVIEW3D,"Y", 245,190,20,17, &ob->upflag, 13.0, 1.0, 0, 0, "Specify the axis that points up"); - uiDefButC(block, ROW,REDRAWVIEW3D,"Z", 265,190,19,17, &ob->upflag, 13.0, 2.0, 0, 0, "Specify the axis that points up"); - - uiBlockSetCol(block, BUTSALMON); - - /* EFFECTS */ - - draw_buttons_edge(curarea->win, 540); - draw_buttons_edge(curarea->win, 1010); + xco = xcostart; + yco -= 30; + uiDefBut(block, BUT, B_SOUND_LOAD_SAMPLE, "Load sample", + xco, yco,195,24, 0, 0, 0, 0, 0, "Load a different sample"); - if (ob->type == OB_MESH) { - uiDefBut(block, BUT, B_NEWEFFECT, "NEW Effect", 550,187,124,27, 0, 0, 0, 0, 0, "Create a new effect"); - uiDefBut(block, BUT, B_DELEFFECT, "Delete", 676,187,62,27, 0, 0, 0, 0, 0, "Delete the effect"); - } - uiBlockSetCol(block, BUTGREY); - /* select effs */ - eff= ob->effect.first; - a= 0; - while(eff) { - - x= 15 * a + 550; - y= 172; // - 12*( abs(a/10) ) ; - uiDefButS(block, TOG|BIT|0, B_SELEFFECT+a, "", x, y, 15, 12, &eff->flag, 0, 0, 0, 0, ""); - - a++; - if(a==MAX_EFFECT) break; - eff= eff->next; - } - - eff= ob->effect.first; - while(eff) { - if(eff->flag & SELECT) break; - eff= eff->next; - } - - if(eff) { - uiDefButS(block, MENU, B_CHANGEEFFECT, "Build %x0|Particles %x1|Wave %x2", 895,187,107,27, &eff->buttype, 0, 0, 0, 0, "Start building the effect"); - - if(eff->type==EFF_BUILD) { - BuildEff *bld; - - bld= (BuildEff *)eff; - - uiDefButF(block, NUM, 0, "Len:", 649,138,95,21, &bld->len, 1.0, 9000.0, 100, 0, "Specify the total time the building requires"); - uiDefButF(block, NUM, 0, "Sfra:", 746,138,94,22, &bld->sfra, 1.0, 9000.0, 100, 0, "Specify the startframe of the effect"); - } - else if(eff->type==EFF_WAVE) { - WaveEff *wav; - - wav= (WaveEff *)eff; - - uiBlockSetCol(block, BUTGREEN); - uiDefButS(block, TOG|BIT|1, B_CALCEFFECT, "X", 782,135,54,23, &wav->flag, 0, 0, 0, 0, "Enable X axis"); - uiDefButS(block, TOG|BIT|2, B_CALCEFFECT, "Y", 840,135,47,23, &wav->flag, 0, 0, 0, 0, "Enable Y axis"); - uiDefButS(block, TOG|BIT|3, B_CALCEFFECT, "Cycl", 890,135,111,23, &wav->flag, 0, 0, 0, 0, "Enable cyclic wave efefct"); - - uiBlockSetCol(block, BUTGREY); - uiDefButF(block, NUM, B_CALCEFFECT, "Sta x:", 550,135,113,24, &wav->startx, -100.0, 100.0, 100, 0, "Starting position for the X axis"); - uiDefButF(block, NUM, B_CALCEFFECT, "Sta y:", 665,135,104,24, &wav->starty, -100.0, 100.0, 100, 0, "Starting position for the Y axis"); - - uiDefButF(block, NUMSLI, B_CALCEFFECT, "Speed:", 550,100,216,20, &wav->speed, -2.0, 2.0, 0, 0, "Specify the wave speed"); - uiDefButF(block, NUMSLI, B_CALCEFFECT, "Heigth:", 550,80,216,20, &wav->height, -2.0, 2.0, 0, 0, "Specify the amplitude of the wave"); - uiDefButF(block, NUMSLI, B_CALCEFFECT, "Width:", 550,60,216,20, &wav->width, 0.0, 5.0, 0, 0, "Specify the width of the wave"); - uiDefButF(block, NUMSLI, B_CALCEFFECT, "Narrow:", 550,40,216,20, &wav->narrow, 0.0, 10.0, 0, 0, "Specify how narrow the wave follows"); - - uiDefButF(block, NUM, B_CALCEFFECT, "Time sta:", 780,100,219,20, &wav->timeoffs, -1000.0, 1000.0, 100, 0, "Specify startingframe of the wave"); - - uiDefButF(block, NUM, B_CALCEFFECT, "Lifetime:", 780,80,219,20, &wav->lifetime, -1000.0, 1000.0, 100, 0, "Specify the lifespan of the wave"); - uiDefButF(block, NUM, B_CALCEFFECT, "Damptime:", 780,60,219,20, &wav->damp, -1000.0, 1000.0, 100, 0, "Specify the dampingtime of the wave"); - - } - else if(eff->type==EFF_PARTICLE) { - PartEff *paf; - - paf= (PartEff *)eff; - - uiDefBut(block, BUT, B_RECALCAL, "RecalcAll", 741,187,67,27, 0, 0, 0, 0, 0, "Update the particle system"); - uiBlockSetCol(block, BUTGREEN); - uiDefButS(block, TOG|BIT|2, B_CALCEFFECT, "Static", 825,187,67,27, &paf->flag, 0, 0, 0, 0, "Make static particles"); - uiBlockSetCol(block, BUTGREY); - - uiDefButI(block, NUM, B_CALCEFFECT, "Tot:", 550,146,91,20, &paf->totpart, 1.0, 100000.0, 0, 0, "Set the total number of particles"); - if(paf->flag & PAF_STATIC) { - uiDefButS(block, NUM, REDRAWVIEW3D, "Step:", 644,146,84,20, &paf->staticstep, 1.0, 100.0, 10, 0, ""); - } - else { - uiDefButF(block, NUM, B_CALCEFFECT, "Sta:", 644,146,84,20, &paf->sta, -250.0, 9000.0, 100, 0, "Specify the startframe"); - uiDefButF(block, NUM, B_CALCEFFECT, "End:", 731,146,97,20, &paf->end, 1.0, 9000.0, 100, 0, "Specify the endframe"); - } - uiDefButF(block, NUM, B_CALCEFFECT, "Life:", 831,146,88,20, &paf->lifetime, 1.0, 9000.0, 100, 0, "Specify the life span of the particles"); - uiDefButI(block, NUM, B_CALCEFFECT, "Keys:", 922,146,80,20, &paf->totkey, 1.0, 32.0, 0, 0, "Specify the number of key positions"); - - uiBlockSetCol(block, BUTGREEN); - uiDefButS(block, NUM, B_REDR, "CurMul:", 550,124,91,20, &paf->curmult, 0.0, 3.0, 0, 0, "Multiply the particles"); - uiBlockSetCol(block, BUTGREY); - uiDefButS(block, NUM, B_CALCEFFECT, "Mat:", 644,124,84,20, paf->mat+paf->curmult, 1.0, 8.0, 0, 0, "Specify the material used for the particles"); - uiDefButF(block, NUM, B_CALCEFFECT, "Mult:", 730,124,98,20, paf->mult+paf->curmult, 0.0, 1.0, 10, 0, "Probability \"dying\" particle spawns a new one."); - uiDefButS(block, NUM, B_CALCEFFECT, "Child:", 922,124,80,20, paf->child+paf->curmult, 1.0, 600.0, 100, 0, "Specify the number of children of a particle that multiply itself"); - uiDefButF(block, NUM, B_CALCEFFECT, "Life:", 831,124,89,20, paf->life+paf->curmult, 1.0, 600.0, 100, 0, "Specify the lifespan of the next generation particles"); - - uiDefButF(block, NUM, B_CALCEFFECT, "Randlife:", 550,96,96,20, &paf->randlife, 0.0, 2.0, 10, 0, "Give the particlelife a random variation"); - uiDefButI(block, NUM, B_CALCEFFECT, "Seed:", 652,96,80,20, &paf->seed, 0.0, 255.0, 0, 0, "Set an offset in the random table"); - - uiDefButF(block, NUM, B_DIFF, "VectSize", 885,96,116,20, &paf->vectsize, 0.0, 1.0, 10, 0, "Set the speed for Vect"); - uiBlockSetCol(block, BUTGREEN); - uiDefButS(block, TOG|BIT|3, B_CALCEFFECT, "Face", 735,96,46,20, &paf->flag, 0, 0, 0, 0, "Emit particles also from faces"); - uiDefButS(block, TOG|BIT|1, B_CALCEFFECT, "Bspline", 782,96,54,20, &paf->flag, 0, 0, 0, 0, "Use B spline formula for particle interpolation"); - uiDefButS(block, TOG, REDRAWVIEW3D, "Vect", 837,96,45,20, &paf->stype, 0, 0, 0, 0, "Give the particles a rotation direction"); - - uiBlockSetCol(block, BUTPURPLE); - uiDefButF(block, NUM, B_CALCEFFECT, "Norm:", 550,67,96,20, &paf->normfac, -2.0, 2.0, 10, 0, "Let the mesh give the particle a starting speed"); - uiDefButF(block, NUM, B_CALCEFFECT, "Ob:", 649,67,86,20, &paf->obfac, -1.0, 1.0, 10, 0, "Let the object give the particle a starting speed"); - uiDefButF(block, NUM, B_CALCEFFECT, "Rand:", 738,67,86,20, &paf->randfac, 0.0, 2.0, 10, 0, "Give the startingspeed a random variation"); - uiDefButF(block, NUM, B_CALCEFFECT, "Tex:", 826,67,85,20, &paf->texfac, 0.0, 2.0, 10, 0, "Let the texture give the particle a starting speed"); - uiDefButF(block, NUM, B_CALCEFFECT, "Damp:", 913,67,89,20, &paf->damp, 0.0, 1.0, 10, 0, "Specify the damping factor"); - - uiBlockSetCol(block, BUTGREY); - uiDefButF(block, NUM, B_CALCEFFECT, "X:", 550,31,72,20, paf->force, -1.0, 1.0, 1, 0, "Specify the X axis of a continues force"); - uiDefButF(block, NUM, B_CALCEFFECT, "Y:", 624,31,78,20, paf->force+1,-1.0, 1.0, 1, 0, "Specify the Y axis of a continues force"); - uiDefBut(block, LABEL, 0, "Force:", 550,9,72,20, 0, 1.0, 0, 0, 0, ""); - uiDefButF(block, NUM, B_CALCEFFECT, "Z:", 623,9,79,20, paf->force+2, -1.0, 1.0, 1, 0, "Specify the Z axis of a continues force"); - - uiDefBut(block, LABEL, 0, "Texture:", 722,9,74,20, 0, 1.0, 0, 0, 0, ""); - uiBlockSetCol(block, BUTGREEN); - uiDefButS(block, ROW, B_CALCEFFECT, "Int", 875,9,32,43, &paf->texmap, 14.0, 0.0, 0, 0, "Use texture intensity as a factor for texture force"); - uiDefButS(block, ROW, B_CALCEFFECT, "RGB", 911,31,45,20, &paf->texmap, 14.0, 1.0, 0, 0, "Use RGB values as a factor for particle speed"); - uiDefButS(block, ROW, B_CALCEFFECT, "Grad", 958,31,44,20, &paf->texmap, 14.0, 2.0, 0, 0, "Use texture gradient as a factor for particle speed"); - uiBlockSetCol(block, BUTGREY); - uiDefButF(block, NUM, B_CALCEFFECT, "Nabla:", 911,9,91,20, &paf->nabla, 0.0001, 1.0, 1, 0, "Specify the dimension of the area for gradient calculation"); - uiDefButF(block, NUM, B_CALCEFFECT, "X:", 722,31,74,20, paf->defvec, -1.0, 1.0, 1, 0, "Specify the X axis of a force, determined by the texture"); - uiDefButF(block, NUM, B_CALCEFFECT, "Y:", 798,31,74,20, paf->defvec+1,-1.0, 1.0, 1, 0, "Specify the Y axis of a force, determined by the texture"); - uiDefButF(block, NUM, B_CALCEFFECT, "Z:", 797,9,75,20, paf->defvec+2, -1.0, 1.0, 1, 0, "Specify the Z axis of a force, determined by the texture"); - - } - } - } - - /* IPO BUTTONS AS LAST */ - ok= 0; - if(G.sipo) { - /* do these exist? */ - sa= G.curscreen->areabase.first; - while(sa) { - if(sa->spacetype==SPACE_IPO && sa->spacedata.first==G.sipo) break; - sa= sa->next; - } - if(sa) { - if(G.sipo->ipo && G.sipo->ipo->curve.first) ok= 1; + id= (ID *)sound->sample; + IDnames_to_pupstring(&strp, NULL, NULL, samples, id, &(G.buts->menunr)); + if (strp[0]) { + xco += 200; + uiDefButS(block, MENU, B_SOUND_MENU_SAMPLE, strp,xco,yco,23,24, &(G.buts->menunr), 0, 0, 0, 0, "Select another loaded sample"); } - } - - uiBlockSetCol(block, BUTGREEN); - // RMGRP uiDefButC(block, ROW, B_REDR, "Ipo settings", 1020, 180, 100, 19, &G.buts->showgroup, 15.0, 0.0, 0, 0, ""); - // RMGRP uiDefButC(block, ROW, B_REDR, "Group settings", 1120, 180, 100, 19, &G.buts->showgroup, 15.0, 1.0, 0, 0, ""); - uiBlockSetCol(block, BUTGREY); - - if(ok && G.buts->showgroup==0) { - sprintf(str, "%.3f", G.sipo->v2d.tot.xmin); - uiDefBut(block, LABEL, 0, str, 1020, 140, 100, 19, 0, 0, 0, 0, 0, ""); - sprintf(str, "%.3f", G.sipo->v2d.tot.xmax); - uiDefBut(block, LABEL, 0, str, 1120, 140, 100, 19, 0, 0, 0, 0, 0, ""); - - uiDefButF(block, NUM, B_DIFF, "Xmin:", 1020, 120, 100, 19, &G.sipo->tot.xmin, -G.sipo->v2d.max[0], G.sipo->v2d.max[0], 100, 0, ""); - uiDefButF(block, NUM, B_DIFF, "Xmax:", 1120, 120, 100, 19, &G.sipo->tot.xmax, -G.sipo->v2d.max[0], G.sipo->v2d.max[0], 100, 0, ""); + MEM_freeN(strp); - sprintf(str, "%.3f", G.sipo->v2d.tot.ymin); - uiDefBut(block, LABEL, 0, str, 1020, 100, 100, 19, 0, 0, 0, 0, 0, ""); - sprintf(str, "%.3f", G.sipo->v2d.tot.ymax); - uiDefBut(block, LABEL, 0, str, 1120, 100, 100, 19, 0, 0, 0, 0, 0, ""); - - uiDefButF(block, NUM, B_DIFF, "Ymin:", 1020, 80, 100, 19, &G.sipo->tot.ymin, -G.sipo->v2d.max[1], G.sipo->v2d.max[1], 100, 0, ""); - uiDefButF(block, NUM, B_DIFF, "Ymax:", 1120, 80, 100, 19, &G.sipo->tot.ymax, -G.sipo->v2d.max[1], G.sipo->v2d.max[1], 100, 0, ""); - - uiBlockSetCol(block, BUTSALMON); - uiDefBut(block, BUT, B_MUL_IPO, "SET", 1220,79,50,62, 0, 0, 0, 0, 0, ""); + xco += 25; + uiDefBut(block, TEX, B_SOUND_NAME_SAMPLE, "",xco,yco,412,24, sound->name, 0.0, 79.0, 0, 0, "The sample used by this sound"); + sprintf(str, "1"); + // sprintf(str, "%d", tex->ima->id.us); + xco += 415; + uiDefBut(block, BUT, B_SOUND_UNLINK_SAMPLE, str,xco,yco,23,24, 0, 0, 0, 0, 0, "The number of users"); - /* SPEED BUTTON */ - uiBlockSetCol(block, BUTGREY); - uiDefButF(block, NUM, B_DIFF, "Speed:", 1020,23,164,28, &hspeed, 0.0, 180.0, 1, 0, ""); + if (sound->sample->packedfile) + packdummy = 1; + else + packdummy = 0; - uiBlockSetCol(block, BUTSALMON); - uiDefBut(block, BUT, B_SETSPEED, "SET", 1185,23,83,29, 0, 0, 0, 0, 0, ""); - } - - if(G.buts->showgroup && G.scene->group) { - GroupKey *gk; - short yco= 140; + xco += 25; + uiDefIconButI(block, TOG|BIT|0, B_SOUND_UNPACK_SAMPLE, ICON_PACKAGE, + xco, yco,24,24, &packdummy, 0, 0, 0, 0,"Pack/Unpack this sample"); + /* + xco += 25; + uiDefBut(block, BUT, B_SOUND_RELOAD_SAMPLE, "Reload",xco, yco,68,24, 0, 0, 0, 0, 0, ""); + */ + /* parameters settings ------------------------------------------------------------------ */ - gk= G.scene->group->gkey.first; - while(gk) { - if(gk==G.scene->group->active) uiBlockSetCol(block, BUTPURPLE); - else uiBlockSetCol(block, BUTGREY); - uiDefBut(block, TEX, B_DIFF, "Name:", 1020, yco, 140, 19, &gk->name, 0.0, 31.0, 10, 0, ""); - uiDefButS(block, NUM, B_DIFF, "Sta:", 1160, yco, 60, 19, &gk->sfra, 0.0, 5000.0, 10, 0, ""); - uiDefButS(block, NUM, B_DIFF, "End:", 1220, yco, 50, 19, &gk->efra, 0.0, 5000.0, 10, 0, ""); - yco-= 20; - gk= gk->next; - } - } - - uiDrawBlock(block); -} - + xco = xcostart; + yco -= 45; + uiDefBut(block, LABEL, 0, "Game sound settings:",xco,yco,195,20, 0, 0, 0, 0, 0, ""); + yco -= 30; + uiBlockSetCol(block, BUTGREY); + uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Volume: ", + xco,yco,195,24,&sound->volume, 0.0, 1.0, 0, 0, "Set the volume of this sound"); + xco += 200; + uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Pitch: ", + xco,yco,195,24,&sound->pitch, -12.0, 12.0, 0, 0, "Set the pitch of this sound"); -/* ***************************** WORLD ************************** */ + xco = xcostart; + yco -= 30; + uiBlockSetCol(block, BUTSALMON); + uiDefButI(block, TOG|BIT|SOUND_FLAGS_LOOP_BIT, B_SOUND_REDRAW, "Loop", + xco, yco, 95, 24, &sound->flags, 0.0, 0.0, 0, 0,"Toggle between looping on/off"); -void do_worldbuts(unsigned short event) -{ - World *wrld; - MTex *mtex; - - switch(event) { - case B_TEXCLEARWORLD: - wrld= G.buts->lockpoin; - mtex= wrld->mtex[ wrld->texact ]; - if(mtex) { - if(mtex->tex) mtex->tex->id.us--; - MEM_freeN(mtex); - wrld->mtex[ wrld->texact ]= 0; - allqueue(REDRAWBUTSWORLD, 0); - allqueue(REDRAWOOPS, 0); - BIF_preview_changed(G.buts); + if (sound->flags & SOUND_FLAGS_LOOP) + { + xco += 100; + uiDefButI(block, TOG|BIT|SOUND_FLAGS_BIDIRECTIONAL_LOOP_BIT, B_SOUND_REDRAW, "Ping Pong", + xco, yco, 95, 24, &sound->flags, 0.0, 0.0, 0, 0,"Toggle between A->B and A->B->A looping"); + +#ifdef SOUND_UNDER_DEVELOPMENT +/* uiBlockSetCol(block, REDALERT); + xco += 100; + uiDefButI(block, NUM, B_SOUND_LOOPSTART, "loopstart: ", xco,yco,195,24, + &sound->loopstart, 0, sound->sample->len, 0, 0, "Set the startpoint for the loop of this sound"); + + xco += 200; + uiDefButI(block, NUM, B_SOUND_LOOPEND, "loopend: ",xco,yco,195,24, + &sound->loopend, 0, sound->sample->len, 0, 0, "Set the endpoint for the loop of this sound"); +*/ +#endif } - break; - } -} - -void worldbuts(void) -{ - World *wrld; - MTex *mtex; - ID *id; - uiBlock *block; - int a, loos; - char str[30], *strp; - short xco; - - wrld= G.scene->world; - if(wrld==0) return; - - sprintf(str, "buttonswin %d", curarea->win); - block= uiNewBlock(&curarea->uiblocks, str, UI_EMBOSSX, UI_HELV, curarea->win); - - uiSetButLock(wrld->id.lib!=0, "Can't edit library data"); - uiBlockSetCol(block, BUTGREEN); - - uiDefButS(block, TOG|BIT|1,B_MATPRV,"Real", 286,190,71,19, &wrld->skytype, 0, 0, 0, 0, "Render background with real horizon"); - uiDefButS(block, TOG|BIT|0,B_MATPRV,"Blend", 208,190,74,19, &wrld->skytype, 0, 0, 0, 0, "Render background with natural progression"); - uiDefButS(block, TOG|BIT|2,B_MATPRV,"Paper", 361,190,71,19, &wrld->skytype, 0, 0, 0, 0, "Flatten blend or texture coordinates"); - uiBlockSetCol(block, BUTGREY); - uiDefButF(block, NUMSLI,B_MATPRV,"HoR ", 200,55,175,18, &(wrld->horr), 0.0, 1.0, 0,0, "The amount of red of the horizon colour"); - uiDefButF(block, NUMSLI,B_MATPRV,"HoG ", 200,34,175,18, &(wrld->horg), 0.0, 1.0, 0,0, "The amount of green of the horizon colour"); - uiDefButF(block, NUMSLI,B_MATPRV,"HoB ", 200,13,175,18, &(wrld->horb), 0.0, 1.0, 0,0, "The amount of blue of the horizon colour"); - uiDefButF(block, NUMSLI,B_MATPRV,"ZeR ", 200,136,175,18, &(wrld->zenr), 0.0, 1.0, 0,0, "The amount of red of the zenith colour"); - uiDefButF(block, NUMSLI,B_MATPRV,"ZeG ", 200,116,175,18, &(wrld->zeng), 0.0, 1.0, 0,0, "The amount of green of the zenith colour"); - uiDefButF(block, NUMSLI,B_MATPRV,"ZeB ", 200,96,175,18, &(wrld->zenb), 0.0, 1.0, 0,0, "The amount of blue of the zenith colour"); - uiDefButF(block, NUMSLI,B_MATPRV,"AmbR ", 380,55,175,18, &(wrld->ambr), 0.0, 1.0 ,0,0, "The amount of red of the ambient colour"); - uiDefButF(block, NUMSLI,B_MATPRV,"AmbG ", 380,34,175,18, &(wrld->ambg), 0.0, 1.0 ,0,0, "The amount of red of the ambient colour"); - uiDefButF(block, NUMSLI,B_MATPRV,"AmbB ", 380,13,175,18, &(wrld->ambb), 0.0, 1.0 ,0,0, "The amount of red of the ambient colour"); - - uiDefBut(block, MENU|SHO, 1, physics_pup(), - 380,152,175,18, &wrld->pad1, 0, 0, 0, 0, "Physics Engine"); - - - /* Activity bubble */ - // uiDefButS(block, TOG|BIT|3,B_DIFF, "Do activity culling", - // 380,152,175,18, &wrld->mode, 0, 0, 0, 0, - // "Disable logic and physics for far away objects."); -/* if (wrld->mode & WO_ACTIVITY_CULLING) { */ - // uiDefButF(block, NUM,0, "Active R ", - // 380,132,175,18, &(wrld->activityBoxRadius), 0.5, 10000.0, 100.0, 0, - // "Radius for activity culling (in Manhattan length)."); -/* } */ - - /* Gravitation for the game worlds */ - uiDefButF(block, NUMSLI,0, "Grav ", - 380,112,175,18, &(wrld->gravity), 0.0, 25.0, 0, 0, - "Gravitation constant of the game world."); - - uiDefButF(block, NUMSLI,0, "Expos ", 380,92,175,18, &(wrld->exposure), 0.2, 5.0, 0, 0, "Set the lighting time, exposure"); - - uiBlockSetCol(block, BUTGREEN); - uiDefButS(block, TOG|BIT|0,REDRAWVIEW3D,"Mist", 571,190,100,19, &wrld->mode, 0, 0, 0, 0, "Enable mist"); - uiBlockSetCol(block, BUTGREY); - uiDefButS(block, ROW, B_DIFF, "Qua", 571, 170, 33, 19, &wrld->mistype, 1.0, 0.0, 0, 0, "Use quadratic progression"); - uiDefButS(block, ROW, B_DIFF, "Lin", 604, 170, 33, 19, &wrld->mistype, 1.0, 1.0, 0, 0, "Use linear progression"); - uiDefButS(block, ROW, B_DIFF, "Sqr", 637, 170, 33, 19, &wrld->mistype, 1.0, 2.0, 0, 0, "Use inverse quadratic progression"); - - uiDefButF(block, NUM,REDRAWVIEW3D, "Sta:",571,150,100,17, &wrld->miststa, 0.0, 1000.0, 10, 0, "Specify the starting distance of the mist"); - uiDefButF(block, NUM,REDRAWVIEW3D, "Di:",571,133,100,17, &wrld->mistdist, 0.0,1000.0, 10, 00, "Specify the depth of the mist"); - uiDefButF(block, NUM,B_DIFF,"Hi:", 571,116,100,17, &wrld->misthi,0.0,100.0, 10, 0, "Specify the factor for a less dense mist with increasing height"); - - uiDefButF(block, NUM, 0, "misi", 571,99,100,17, &(wrld->misi), 0., 1.0, 0, 0, "Set the mist intensity"); - uiBlockSetCol(block, BUTGREEN); - uiDefButS(block, TOG|BIT|1,B_DIFF, "Stars",571,82,100,17, &wrld->mode, 0, 0, 0, 0, "Enable stars"); - uiBlockSetCol(block, BUTGREY); - uiDefButF(block, NUM,B_DIFF,"StarDist:", 571,65,100,17, &(wrld->stardist), 2.0, 1000.0, 100, 0, "Specify the average distance between two stars"); - uiDefButF(block, NUM,B_DIFF,"MinDist:", 571,48,100,17, &(wrld->starmindist), 0.0, 1000.0, 100, 0, "Specify the minimum distance to the camera"); - uiDefButF(block, NUM,B_DIFF,"Size:", 571,31,100,17, &(wrld->starsize), 0.0, 10.0, 10, 0, "Specify the average screen dimension"); - uiDefButF(block, NUM,B_DIFF,"Colnoise:", 571,12,100,17, &(wrld->starcolnoise), 0.0, 1.0, 100, 0, "Randomize starcolour"); +#ifdef SOUND_UNDER_DEVELOPMENT + xco = xcostart; + yco -= 30; + uiDefButI(block, TOG|BIT|SOUND_FLAGS_PRIORITY_BIT, B_SOUND_REDRAW, "Priority", + xco, yco, 95, 24, &sound->flags, 0.0, 0.0, 0, 0,"Toggle between high and low priority"); +#endif + /* 2D & 3D settings ------------------------------------------------------------------ */ - /* TEX CHANNELS */ - uiBlockSetCol(block, BUTGREY); - xco= 745; - for(a= 0; a<6; a++) { - mtex= wrld->mtex[a]; - if(mtex && mtex->tex) splitIDname(mtex->tex->id.name+2, str, &loos); - else strcpy(str, ""); - str[10]= 0; - uiDefButS(block, ROW, REDRAWBUTSWORLD, str, xco, 195, 83, 20, &(wrld->texact), 3.0, (float)a, 0, 0, "Texture channel"); - xco+= 85; - } - - mtex= wrld->mtex[ wrld->texact ]; - if(mtex==0) { - mtex= &emptytex; - default_mtex(mtex); - mtex->texco= TEXCO_VIEW; - } - - /* TEXCO */ - uiBlockSetCol(block, BUTGREEN); - uiDefButS(block, ROW, B_MATPRV, "Object", 745,146,49,18, &(mtex->texco), 4.0, (float)TEXCO_OBJECT, 0, 0, "The name of the object used as a source for texture coordinates"); - uiDefIDPoinBut(block, test_obpoin_but, B_MATPRV, "", 745,166,133,18, &(mtex->object), ""); - uiDefButS(block, ROW, B_MATPRV, "View", 839,146,39,18, &(mtex->texco), 4.0, (float)TEXCO_VIEW, 0, 0, "Pass camera view vector on to the texture"); - - uiBlockSetCol(block, BUTGREY); - uiDefButF(block, NUM, B_MATPRV, "dX", 745,114,133,18, mtex->ofs, -20.0, 20.0, 10, 0, "Fine tune X coordinate"); - uiDefButF(block, NUM, B_MATPRV, "dY", 745,94,133,18, mtex->ofs+1, -20.0, 20.0, 10, 0, "Fine tune Y coordinate"); - uiDefButF(block, NUM, B_MATPRV, "dZ", 745,74,133,18, mtex->ofs+2, -20.0, 20.0, 10, 0, "Fine tune Z coordinate"); - uiDefButF(block, NUM, B_MATPRV, "sizeX", 745,50,133,18, mtex->size, -20.0, 20.0, 10, 0, "Set an extra scaling for the texture coordinate"); - uiDefButF(block, NUM, B_MATPRV, "sizeY", 745,30,133,18, mtex->size+1, -20.0, 20.0, 10, 0, "Set an extra scaling for the texture coordinate"); - uiDefButF(block, NUM, B_MATPRV, "sizeZ", 745,10,133,18, mtex->size+2, -20.0, 20.0, 10, 0, "Set an extra scaling for the texture coordinate"); - - /* TEXTUREBLOCK SELECT */ - id= (ID *)mtex->tex; - IDnames_to_pupstring(&strp, NULL, "ADD NEW %x 32767", &(G.main->tex), id, &(G.buts->texnr)); - uiDefButS(block, MENU, B_WTEXBROWSE, strp, 900,146,20,19, &(G.buts->texnr), 0, 0, 0, 0, "Browse"); - MEM_freeN(strp); - - if(id) { - uiDefBut(block, TEX, B_IDNAME, "TE:", 900,166,163,19, id->name+2, 0.0, 18.0, 0, 0, "Specify the texture name"); - sprintf(str, "%d", id->us); - uiDefBut(block, BUT, 0, str, 996,146,21,19, 0, 0, 0, 0, 0, "Number of users"); - uiDefIconBut(block, BUT, B_AUTOTEXNAME, ICON_AUTO, 1041,146,21,19, 0, 0, 0, 0, 0, "Auto assign name to texture"); - if(id->lib) { - if(wrld->id.lib) uiDefIconBut(block, BUT, 0, ICON_DATALIB, 1019,146,21,19, 0, 0, 0, 0, 0, ""); - else uiDefIconBut(block, BUT, 0, ICON_PARLIB, 1019,146,21,19, 0, 0, 0, 0, 0, ""); - } - uiBlockSetCol(block, BUTSALMON); - uiDefBut(block, BUT, B_TEXCLEARWORLD, "Clear", 922, 146, 72, 19, 0, 0, 0, 0, 0, "Erase link to texture"); uiBlockSetCol(block, BUTGREY); - } - - /* TEXTURE OUTPUT */ - uiDefButS(block, TOG|BIT|1, B_MATPRV, "Stencil", 900,114,52,18, &(mtex->texflag), 0, 0, 0, 0, "Use stencil mode"); - uiDefButS(block, TOG|BIT|2, B_MATPRV, "Neg", 954,114,38,18, &(mtex->texflag), 0, 0, 0, 0, "Inverse texture operation"); - uiDefButS(block, TOG|BIT|0, B_MATPRV, "RGBtoInt", 994,114,69,18, &(mtex->texflag), 0, 0, 0, 0, "Use RGB values for intensity texure"); - - uiDefButF(block, COL, B_MTEXCOL, "", 900,100,163,12, &(mtex->r), 0, 0, 0, 0, ""); - uiDefButF(block, NUMSLI, B_MATPRV, "R ", 900,80,163,18, &(mtex->r), 0.0, 1.0, B_MTEXCOL, 0, "The amount of red that blends with the intensity colour"); - uiDefButF(block, NUMSLI, B_MATPRV, "G ", 900,60,163,18, &(mtex->g), 0.0, 1.0, B_MTEXCOL, 0, "The amount of green that blends with the intensity colour"); - uiDefButF(block, NUMSLI, B_MATPRV, "B ", 900,40,163,18, &(mtex->b), 0.0, 1.0, B_MTEXCOL, 0, "The amount of blue that blends with the intensity colour"); - uiDefButF(block, NUMSLI, B_MATPRV, "DVar ", 900,10,163,18, &(mtex->def_var), 0.0, 1.0, 0, 0, "The value that an intensity texture blends with the current value"); - - /* MAP TO */ - uiBlockSetCol(block, BUTGREEN); - uiDefButS(block, TOG|BIT|0, B_MATPRV, "Blend", 1087,166,81,18, &(mtex->mapto), 0, 0, 0, 0, "Let the texture work on the colour progression in the sky"); - uiDefButS(block, TOG|BIT|1, B_MATPRV, "Hori", 1172,166,81,18, &(mtex->mapto), 0, 0, 0, 0, "Let the texture work on the colour of the horizon"); - uiDefButS(block, TOG|BIT|2, B_MATPRV, "ZenUp", 1087,147,81,18, &(mtex->mapto), 0, 0, 0, 0, "Let the texture work on the colour of the zenith above"); - uiDefButS(block, TOG|BIT|3, B_MATPRV, "ZenDo", 1172,147,81,18, &(mtex->mapto), 0, 0, 0, 0, "Let the texture work on the colour of the zenith below"); - - uiBlockSetCol(block, BUTGREY); - uiDefButS(block, ROW, B_MATPRV, "Blend", 1087,114,48,18, &(mtex->blendtype), 9.0, (float)MTEX_BLEND, 0, 0, "The texture blends the values"); - uiDefButS(block, ROW, B_MATPRV, "Mul", 1136,114,44,18, &(mtex->blendtype), 9.0, (float)MTEX_MUL, 0, 0, "The texture multiplies the values"); - uiDefButS(block, ROW, B_MATPRV, "Add", 1182,114,41,18, &(mtex->blendtype), 9.0, (float)MTEX_ADD, 0, 0, "The texture adds the values"); - uiDefButS(block, ROW, B_MATPRV, "Sub", 1226,114,40,18, &(mtex->blendtype), 9.0, (float)MTEX_SUB, 0, 0, "The texture subtracts the values"); - - uiDefButF(block, NUMSLI, B_MATPRV, "Col ", 1087,50,179,18, &(mtex->colfac), 0.0, 1.0, 0, 0, "Specify the extent to which the texture works on colour"); - uiDefButF(block, NUMSLI, B_MATPRV, "Nor ", 1087,30,179,18, &(mtex->norfac), 0.0, 1.0, 0, 0, "Specify the extent to which the texture works on the normal"); - uiDefButF(block, NUMSLI, B_MATPRV, "Var ", 1087,10,179,18, &(mtex->varfac), 0.0, 1.0, 0, 0, "Specify the extent to which the texture works on a value"); - - - BIF_previewdraw(G.buts); + if (sound->sample->channels == 1) + { + xco = xcostart; + yco -= 30; + uiDefButI(block, TOG|BIT|SOUND_FLAGS_3D_BIT, B_SOUND_REDRAW, "3D Sound", + xco, yco, 95, 24, &sound->flags, 0, 0, 0, 0, "Turns 3D sound on"); + + if (sound->flags & SOUND_FLAGS_3D) + { + xco = xcostart; + yco -= 30; + uiBlockSetCol(block, BUTGREY); + uiDefBut(block, LABEL, 0, "3D surround settings:",xco,yco,195,20, 0, 0, 0, 0, 0, ""); + uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Scale: ", + xco,(short)(yco-=30),195,24,&sound->attenuation, 0.0, 5.0, 1.0, 0, "Sets the world-scaling factor for this sound"); + + /* + xco += 200; + uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Distance: ", + xco,yco,195,20,&sound->distance, 0.0, 100.0, 1.0, 0, "Reference distance: sets the distance at which the listener will experience gain"); + xco -= 200; + yco -= 30; + uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Minvol: ", + xco,yco,195,20,&sound->min_gain, 0.0, 1.0, 1.0, 0, "Minimal volume: sets the lower threshold for the gain of this sound"); + xco += 200; + uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Maxvol: ", + xco,yco,195,20,&sound->max_gain, 0.0, 10.0, 1.0, 0, "Maximal volume: sets the upper threshold for the gain of this sound"); + */ + } + } - uiDrawBlock(block); -} + /* listener settings ------------------------------------------------------------------ */ + draw_buttons_edge(curarea->win, 740); + + xco = xcostart + 750; + yco = 195; + uiBlockSetCol(block, BUTGREY); + mixrate = sound_get_mixrate(); + sprintf(mixrateinfo, "Game Mixrate: %d Hz", mixrate); + uiDefBut(block, LABEL, 0, mixrateinfo, xco,yco,295,20, 0, 0, 0, 0, 0, ""); -/* **************************** VIEW ************************ */ + yco -= 30; -static void view3d_change_bgpic_ima(View3D *v3d, Image *newima) { - if (v3d->bgpic && v3d->bgpic->ima!=newima) { - if (newima) - id_us_plus((ID*) newima); - if (v3d->bgpic->ima) - v3d->bgpic->ima->id.us--; - v3d->bgpic->ima= newima; + uiDefBut(block, LABEL, 0, "Game listener settings:",xco,yco,195,20, 0, 0, 0, 0, 0, ""); - if(v3d->bgpic->rect) MEM_freeN(v3d->bgpic->rect); - v3d->bgpic->rect= NULL; + yco -= 30; + uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Volume: ", + xco,yco,195,24,&G.listener->gain, 0.0, 1.0, 1.0, 0, "Sets the maximum volume for the overall sound"); - allqueue(REDRAWBUTSVIEW, 0); - } -} -static void view3d_change_bgpic_tex(View3D *v3d, Tex *newtex) { - if (v3d->bgpic && v3d->bgpic->tex!=newtex) { - if (newtex) - id_us_plus((ID*) newtex); - if (v3d->bgpic->tex) - v3d->bgpic->tex->id.us--; - v3d->bgpic->tex= newtex; + yco -= 30; + uiDefBut(block, LABEL, 0, "Game Doppler effect settings:",xco,yco,195,20, 0, 0, 0, 0, 0, ""); + /* + yco -= 30; + uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Scale: ", + xco,yco,195,20,&G.listener->dopplerfactor, 0.0, 10.0, 1.0, 0, "Doppler scaling: sets the scaling factor for doppler effect"); + */ + yco -= 30; + uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Doppler: ", + xco,yco,195,24,&G.listener->dopplervelocity, 0.0, 10.0, 1.0, 0, "Use this for scaling the doppler effect"); + /* + if (sound->channels != SOUND_CHANNELS_STEREO || sample->channels == 1) + { + uiBlockSetCol(block, BUTGREEN); + uiDefButI(block, TOGN|BIT|SOUND_FLAGS_FIXED_PANNING_BIT, B_SOUND_REDRAW, "3D pan", + xco, yco, 95, 20, &sound->flags, 0, 0, 0, 0, ""); - allqueue(REDRAWBUTSVIEW, 0); - } -} - -static void load_bgpic_image(char *name) -{ - Image *ima; - View3D *vd; - - vd= scrarea_find_space_of_type(curarea, SPACE_VIEW3D); - if(vd==0 || vd->bgpic==0) return; - - ima= add_image(name); - if(ima) { - if(vd->bgpic->ima) { - vd->bgpic->ima->id.us--; + uiBlockSetCol(block, BUTSALMON); + xco += 100; + uiDefButI(block, TOG|BIT|SOUND_FLAGS_FIXED_PANNING_BIT, B_SOUND_REDRAW, "Fixed", + xco, yco, 95, 20, &sound->flags, 0, 0, 0, 0, ""); + + uiBlockSetCol(block, BUTGREY); + if (sound->flags & SOUND_FLAGS_FIXED_PANNING) + { + xco += 100; + uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Pann: ", + xco,yco,195,20,&sound->panning, -1.0, 1.0, 0, 0, ""); + } } - vd->bgpic->ima= ima; - - free_image_buffers(ima); /* force read again */ - ima->ok= 1; + */ + uiDrawBlock(block); } - allqueue(REDRAWBUTSVIEW, 0); - -} + /* audio sequence engine settings ------------------------------------------------------------------ */ -void do_viewbuts(unsigned short event) -{ - View3D *vd; - char *name; + draw_buttons_edge(curarea->win, 1000); - vd= scrarea_find_space_of_type(curarea, SPACE_VIEW3D); - if(vd==0) return; + xco = xcostart + 1010; + yco = 195; - switch(event) { - case B_LOADBGPIC: - if(vd->bgpic && vd->bgpic->ima) name= vd->bgpic->ima->name; - else name= G.ima; - - activate_imageselect(FILE_SPECIAL, "SELECT IMAGE", name, load_bgpic_image); - break; - case B_BLENDBGPIC: - if(vd->bgpic && vd->bgpic->rect) setalpha_bgpic(vd->bgpic); - break; - case B_BGPICBROWSE: - if(vd->bgpic) { - if (G.buts->menunr==-2) { - activate_databrowse((ID*) vd->bgpic->ima, ID_IM, 0, B_BGPICBROWSE, &G.buts->menunr, do_viewbuts); - } else if (G.buts->menunr>0) { - Image *newima= (Image*) BLI_findlink(&G.main->image, G.buts->menunr-1); + uiDefBut(block, LABEL, 0, "Audio sequencer settings", xco,yco,295,20, 0, 0, 0, 0, 0, ""); - if (newima) - view3d_change_bgpic_ima(vd, newima); - } - } - break; - case B_BGPICCLEAR: - if (vd->bgpic) - view3d_change_bgpic_ima(vd, NULL); - break; - case B_BGPICTEX: - if (vd->bgpic) { - if (G.buts->texnr==-2) { - activate_databrowse((ID*) vd->bgpic->tex, ID_TE, 0, B_BGPICTEX, &G.buts->texnr, do_viewbuts); - } else if (G.buts->texnr>0) { - Tex *newtex= (Tex*) BLI_findlink(&G.main->tex, G.buts->texnr-1); - - if (newtex) - view3d_change_bgpic_tex(vd, newtex); - } - } - break; - case B_BGPICTEXCLEAR: - if (vd->bgpic) - view3d_change_bgpic_tex(vd, NULL); - break; - } -} + yco -= 25; + sprintf(mixrateinfo, "Mixing/Sync (latency: %d ms)", (int)( (((float)U.mixbufsize)/(float)G.scene->audio.mixrate)*1000.0 ) ); + uiDefBut(block, LABEL, 0, mixrateinfo, xco,yco,295,20, 0, 0, 0, 0, 0, ""); -void viewbuts(void) -{ - View3D *vd; - ID *id; - uiBlock *block; - char *strp, str[64]; + yco -= 25; + uiBlockSetCol(block, BUTGREY); + uiDefButI(block, ROW, B_SOUND_RATECHANGED, "44.1 kHz", xco,yco,75,20, &G.scene->audio.mixrate, 2.0, 44100.0, 0, 0, "Mix at 44.1 kHz"); + uiDefButI(block, ROW, B_SOUND_RATECHANGED, "48.0 kHz", xco+80,yco,75,20, &G.scene->audio.mixrate, 2.0, 48000.0, 0, 0, "Mix at 48 kHz"); + uiBlockSetCol(block, BUTSALMON); + uiDefBut(block, BUT, B_SOUND_RECALC, "Recalc", xco+160,yco,75,20, 0, 0, 0, 0, 0, "Recalculate samples"); + + yco -= 25; + uiBlockSetCol(block, BUTGREEN); + uiDefButS(block, TOG|BIT|1, B_SOUND_CHANGED, "Sync", xco,yco,115,20, &G.scene->audio.flag, 0, 0, 0, 0, "Use sample clock for syncing animation to audio"); + uiDefButS(block, TOG|BIT|2, B_SOUND_CHANGED, "Scrub", xco+120,yco,115,20, &G.scene->audio.flag, 0, 0, 0, 0, "Scrub when changing frames"); + + yco -= 25; + uiDefBut(block, LABEL, 0, "Main mix", xco,yco,295,20, 0, 0, 0, 0, 0, ""); + + yco -= 25; + uiBlockSetCol(block, BUTGREY); + uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Main (dB): ", + xco,yco,235,24,&G.scene->audio.main, -24.0, 6.0, 0, 0, "Set the audio master gain/attenuation in dB"); + + yco -= 25; + uiDefButS(block, TOG|BIT|0, 0, "Mute", xco,yco,235,24, &G.scene->audio.flag, 0, 0, 0, 0, "Mute audio from sequencer"); - /* searching for spacedata */ - vd= scrarea_find_space_of_type(curarea, SPACE_VIEW3D); - if(vd==0) return; + yco -= 35; + uiBlockSetCol(block, BUTSALMON); + uiDefBut(block, BUT, B_SOUND_MIXDOWN, "MIXDOWN", xco,yco,235,24, 0, 0, 0, 0, 0, "Create WAV file from sequenced audio"); - sprintf(str, "buttonswin %d", curarea->win); - block= uiNewBlock(&curarea->uiblocks, str, UI_EMBOSSX, UI_HELV, curarea->win); + uiDrawBlock(block); +} - if(vd->flag & V3D_DISPBGPIC) { - if(vd->bgpic==0) { - vd->bgpic= MEM_callocN(sizeof(BGpic), "bgpic"); - vd->bgpic->size= 5.0; - vd->bgpic->blend= 0.5; - } - } - - uiDefButS(block, TOG|BIT|1, REDRAWBUTSVIEW, "BackGroundPic", 347,160,127,29 , - &vd->flag, 0, 0, 0, 0, "Display a picture in the 3D background"); - if(vd->bgpic) { - uiDefButF(block, NUM, B_DIFF, "Size:", - 478,160,82,29, &vd->bgpic->size, 0.1, - 250.0, 100, 0, "Set the size for the width of the BackGroundPic"); - - id= (ID *)vd->bgpic->ima; - IDnames_to_pupstring(&strp, NULL, NULL, &(G.main->image), id, &(G.buts->menunr)); - if(strp[0]) - uiDefButS(block, MENU, B_BGPICBROWSE, strp, 347,112,20,19, &(G.buts->menunr), 0, 0, 0, 0, "Browse"); - MEM_freeN(strp); - - uiDefBut(block, BUT, B_LOADBGPIC, "LOAD", 370,112,189,19, 0, 0, 0, 0, 0, "Specify the BackGroundPic"); - uiDefButF(block, NUMSLI, B_BLENDBGPIC, "Blend:", 347,84,213,19,&vd->bgpic->blend, 0.0,1.0, 0, 0, "Set the BackGroundPic transparency"); - - if(vd->bgpic->ima) { - uiDefBut(block, TEX, 0,"BGpic: ", 347,136,211,19,&vd->bgpic->ima->name,0.0,100.0, 0, 0, "The Selected BackGroundPic"); - uiDefIconBut(block, BUT, B_BGPICCLEAR, ICON_X, 347+211,112,20,19, 0, 0, 0, 0, 0, "Remove background image link"); - } - - /* There is a bug here ... (what bug? where? what is this? - zr) */ - /* texture block: */ - id= (ID *)vd->bgpic->tex; - IDnames_to_pupstring(&strp, NULL, NULL, &(G.main->tex), id, &(G.buts->texnr)); - if (strp[0]) - uiDefButS(block, MENU, B_BGPICTEX, strp, 347, 20, 20,19, &(G.buts->texnr), 0, 0, 0, 0, "Browse"); - MEM_freeN(strp); - - uiDefBut(block, LABEL, 0, "Select texture for animated backgroundimage", 370, 20, 300,19, 0, 0, 0, 0, 0, ""); +/* ************************ LAMP *************************** */ + +void do_lampbuts(unsigned short event) +{ + Lamp *la; + MTex *mtex; - if (id) { - uiDefBut(block, TEX, B_IDNAME, "TE:", 347,0,211,19, id->name+2, 0.0, 18.0, 0, 0, ""); - uiDefIconBut(block, BUT, B_BGPICTEXCLEAR, ICON_X, 347+211,0,20,19, 0, 0, 0, 0, 0, "Remove background texture link"); + switch(event) { + case B_LAMPREDRAW: + BIF_preview_changed(G.buts); + allqueue(REDRAWVIEW3D, 0); + break; + case B_TEXCLEARLAMP: + la= G.buts->lockpoin; + mtex= la->mtex[ la->texact ]; + if(mtex) { + if(mtex->tex) mtex->tex->id.us--; + MEM_freeN(mtex); + la->mtex[ la->texact ]= 0; + allqueue(REDRAWBUTSLAMP, 0); + allqueue(REDRAWOOPS, 0); + BIF_preview_changed(G.buts); } + break; + case B_SBUFF: + { + la= G.buts->lockpoin; + la->bufsize = la->bufsize&=(~15); + allqueue(REDRAWBUTSLAMP, 0); + allqueue(REDRAWOOPS, 0); + /*la->bufsize = la->bufsize % 64;*/ + } + break; } - - uiDefButF(block, NUM, B_DIFF, "Grid:", 347, 60, 105, 19, &vd->grid, 0.001, 1000.0, 100, 0, "Set the distance between gridlines"); - uiDefButS(block, NUM, B_DIFF, "GridLines:", 452, 60, 105, 19, &vd->gridlines, 0.0, 100.0, 100, 0, "Set the number of gridlines"); - uiDefButF(block, NUM, B_DIFF, "Lens:", 557, 60, 105, 19, &vd->lens, 10.0, 120.0, 100, 0, "Set the lens for the perspective view"); - uiDefButF(block, NUM, B_DIFF, "ClipStart:", 347, 40, 105, 19, &vd->near, 0.1*vd->grid, 100.0, 100, 0, "Set startvalue in perspective view mode"); - uiDefButF(block, NUM, B_DIFF, "ClipEnd:", 452, 40, 105, 19, &vd->far, 1.0, 1000.0*vd->grid, 100, 0, "Set endvalue in perspective view mode"); - - /* for(b=0; b<8; b++) { */ - /* for(a=0; a<8; a++) { */ - /* uiDefButC(block, TOG|BIT|(7-a), 0, "", 100+12*a, 100-12*b, 12, 12, &(arr[b]),0,0,0,0); ,""*/ - /* } */ - /* } */ - /* DefBut(BUT, 1001, "print", 50,100,50,20, 0, 0, 0, 0,0); */ - - uiDrawBlock(block); + if(event) freefastshade(); } -void output_pic(char *name) -{ - strcpy(G.scene->r.pic, name); - allqueue(REDRAWBUTSRENDER, 0); -} -void backbuf_pic(char *name) +void lampbuts(void) { - Image *ima; + Object *ob; + Lamp *la; + MTex *mtex; + ID *id; + uiBlock *block; + float grid=0.0; + int loos, a; + char *strp, str[32]; + short xco; - strcpy(G.scene->r.backbuf, name); - allqueue(REDRAWBUTSRENDER, 0); - - ima= add_image(name); - if(ima) { - free_image_buffers(ima); /* force read again */ - ima->ok= 1; - } -} + if(G.vd) grid= G.vd->grid; + if(grid<1.0) grid= 1.0; + + ob= OBACT; + if(ob==0) return; + if(ob->type!=OB_LAMP) return; -void ftype_pic(char *name) -{ - strcpy(G.scene->r.ftype, name); - allqueue(REDRAWBUTSRENDER, 0); -} + sprintf(str, "buttonswin %d", curarea->win); + block= uiNewBlock(&curarea->uiblocks, str, UI_EMBOSSX, UI_HELV, curarea->win); + la= ob->data; + uiSetButLock(la->id.lib!=0, "Can't edit library data"); -/* **************************** VIEW ************************ */ + uiBlockSetCol(block, BUTGREEN); + uiDefButS(block, ROW,B_LAMPREDRAW,"Lamp", 317,190,61,25,&la->type,1.0,(float)LA_LOCAL, 0, 0, "Use a point light source"); + uiDefButS(block, ROW,B_LAMPREDRAW,"Spot", 379,190,59,25,&la->type,1.0,(float)LA_SPOT, 0, 0, "Restrict lamp to conical space"); + uiDefButS(block, ROW,B_LAMPREDRAW,"Sun", 439,190,58,25,&la->type,1.0,(float)LA_SUN, 0, 0, "Light shines from constant direction"); + uiDefButS(block, ROW,B_LAMPREDRAW,"Hemi", 499,190,55,25,&la->type,1.0,(float)LA_HEMI, 0, 0, "Light shines as half a sphere"); + uiBlockSetCol(block, BUTGREY); + uiDefButF(block, NUM,B_LAMPREDRAW,"Dist:",611,190,104,25,&la->dist, 0.01, 5000.0, 100, 0, "Set the distance value"); -static void scene_change_set(Scene *sc, Scene *set) { - if (sc->set!=set) { - sc->set= set; - - allqueue(REDRAWBUTSRENDER, 0); - allqueue(REDRAWVIEW3D, 0); - } -} + uiBlockSetCol(block, BUTBLUE); + uiDefButS(block, TOG|BIT|3, B_MATPRV,"Quad", 203,196,100,17,&la->mode, 0, 0, 0, 0, "Use inverse quadratic proportion"); + uiDefButS(block, TOG|BIT|6, REDRAWVIEW3D,"Sphere", 203,178,100,17,&la->mode, 0, 0, 0, 0, "Lamp only shines inside a sphere"); + uiDefButS(block, TOG|BIT|0, REDRAWVIEW3D, "Shadows", 203,160,100,17,&la->mode, 0, 0, 0, 0, "Let lamp produce shadows"); + uiDefButS(block, TOG|BIT|1, 0,"Halo", 203,142,100,17,&la->mode, 0, 0, 0, 0, "Render spotlights with a volumetric halo"); + uiDefButS(block, TOG|BIT|2, 0,"Layer", 203,124,100,17,&la->mode, 0, 0, 0, 0, "Illuminate objects in the same layer only"); + uiDefButS(block, TOG|BIT|4, B_MATPRV,"Negative", 203,106,100,17,&la->mode, 0, 0, 0, 0, "Cast negative light"); + uiDefButS(block, TOG|BIT|5, 0,"OnlyShadow", 203,88,100,17,&la->mode, 0, 0, 0, 0, "Render shadow only"); + uiDefButS(block, TOG|BIT|7, B_LAMPREDRAW,"Square", 203,70,100,17,&la->mode, 0, 0, 0, 0, "Use square spotbundles"); + uiDefButS(block, TOG|BIT|11, 0,"No Diffuse", 203,52,100,17,&la->mode, 0, 0, 0, 0, "No diffuse shading of material"); + uiDefButS(block, TOG|BIT|12, 0,"No Specular", 203,34,100,17,&la->mode, 0, 0, 0, 0, "No specular shading of material"); -static void run_playanim(char *file) { - extern char bprogname[]; /* usiblender.c */ - char str[FILE_MAXDIR+FILE_MAXFILE]; - int pos[2], size[2]; - calc_renderwin_rectangle(R.winpos, pos, size); +#ifdef __SHADOW_EXP + /* move this elsewhere */ + uiDefButS(block, TOG|BIT|10, 0,"DeepShadow", 203,216,100,19,&la->mode, 0, 0, 0, 0, ""); +#endif + + uiBlockSetCol(block, BUTGREY); + uiDefButS(block, NUM,B_SBUFF,"ShadowBuffSize:", 203,10,140,19, &la->bufsize,512,5120, 0, 0, "Set the size of the shadow buffer"); + uiDefButF(block, NUM,REDRAWVIEW3D,"ClipSta:", 346,30,146,19, &la->clipsta, 0.1*grid,1000.0*grid, 10, 0, "Set the shadow map clip start"); + uiDefButF(block, NUM,REDRAWVIEW3D,"ClipEnd:", 346,9,146,19,&la->clipend, 1.0, 5000.0*grid, 100, 0, "Set the shadow map clip end"); - sprintf(str, "%s -a -p %d %d \"%s\"", bprogname, pos[0], pos[1], file); - system(str); -} + uiDefButS(block, NUM,0,"Samples:", 496,30,105,19, &la->samp,1.0,16.0, 0, 0, "Number of shadow map samples"); + uiDefButS(block, NUM,0,"Halo step:", 496,10,105,19, &la->shadhalostep, 0.0, 12.0, 0, 0, "Volumetric halo sampling frequency"); + uiDefButF(block, NUM,0,"Bias:", 605,30,108,19, &la->bias, 0.01, 5.0, 1, 0, "Shadow map sampling bias"); + uiDefButF(block, NUM,0,"Soft:", 605,10,108,19, &la->soft,1.0,100.0, 100, 0, "Set the size of the shadow sample area"); + + uiBlockSetCol(block, BUTGREY); + uiDefButF(block, NUMSLI,B_MATPRV,"Energy ", 520,156,195,20, &(la->energy), 0.0, 10.0, 0, 0, "Set the intensity of the light"); -void do_renderbuts(unsigned short event) -{ - ScrArea *sa; - ID *id; - char file[FILE_MAXDIR+FILE_MAXFILE]; + uiDefButF(block, NUMSLI,B_MATPRV,"R ", 520,128,194,20,&la->r, 0.0, 1.0, B_COLLAMP, 0, "Set the red component of the light"); + uiDefButF(block, NUMSLI,B_MATPRV,"G ", 520,108,194,20,&la->g, 0.0, 1.0, B_COLLAMP, 0, "Set the green component of the light"); + uiDefButF(block, NUMSLI,B_MATPRV,"B ", 520,88,194,20,&la->b, 0.0, 1.0, B_COLLAMP, 0, "Set the blue component of the light"); + + uiDefButF(block, COL, B_COLLAMP, "", 520,64,193,23, &la->r, 0, 0, 0, 0, ""); + + uiDefButF(block, NUMSLI,B_LAMPREDRAW,"SpotSi ",317,157,192,19,&la->spotsize, 1.0, 180.0, 0, 0, "Set the angle of the spot beam in degrees"); + uiDefButF(block, NUMSLI,B_MATPRV,"SpotBl ", 316,136,192,19,&la->spotblend, 0.0, 1.0, 0, 0, "Set the softness of the spot edge"); + uiDefButF(block, NUMSLI,B_MATPRV,"Quad1 ", 316,106,192,19,&la->att1, 0.0, 1.0, 0, 0, "Set the light intensity value 1 for a quad lamp"); + uiDefButF(block, NUMSLI,B_MATPRV,"Quad2 ", 317,86,191,19,&la->att2, 0.0, 1.0, 0, 0, "Set the light intensity value 2 for a quad lamp"); + uiDefButF(block, NUMSLI,0,"HaloInt ", 316,64,193,19,&la->haint, 0.0, 5.0, 0, 0, "Set the intensity of the spot halo"); - switch(event) { - case B_DORENDER: - BIF_do_render(0); - break; - case B_RTCHANGED: - allqueue(REDRAWALL, 0); - break; - case B_PLAYANIM: -#ifdef WITH_QUICKTIME - if(G.scene->r.imtype == R_QUICKTIME) - makeqtstring(file); - else -#endif - makeavistring(file); - if(BLI_exist(file)) { - run_playanim(file); - } - else { - makepicstring(file, G.scene->r.sfra); - if(BLI_exist(file)) { - run_playanim(file); - } - else error("Can't find image: %s", file); - } - break; - - case B_DOANIM: - BIF_do_render(1); - break; + /* TEX CHANNELS */ + uiBlockSetCol(block, BUTGREY); + xco= 745; + for(a= 0; a<6; a++) { + mtex= la->mtex[a]; + if(mtex && mtex->tex) splitIDname(mtex->tex->id.name+2, str, &loos); + else strcpy(str, ""); + str[10]= 0; + uiDefButS(block, ROW, B_REDR, str, xco, 195, 83, 20, &(la->texact), 3.0, (float)a, 0, 0, ""); + xco+= 85; + } - case B_FS_PIC: - sa= closest_bigger_area(); - areawinset(sa->win); - activate_fileselect(FILE_SPECIAL, "SELECT OUTPUT PICTURES", G.scene->r.pic, output_pic); - break; - case B_FS_BACKBUF: - sa= closest_bigger_area(); - areawinset(sa->win); - activate_fileselect(FILE_SPECIAL, "SELECT BACKBUF PICTURE", G.scene->r.backbuf, backbuf_pic); - break; - case B_IS_BACKBUF: - sa= closest_bigger_area(); - areawinset(sa->win); - activate_imageselect(FILE_SPECIAL, "SELECT BACKBUF PICTURE", G.scene->r.backbuf, backbuf_pic); - break; - case B_FS_FTYPE: - sa= closest_bigger_area(); - areawinset(sa->win); - activate_fileselect(FILE_SPECIAL, "SELECT FTYPE", G.scene->r.ftype, ftype_pic); - break; - case B_IS_FTYPE: - sa= closest_bigger_area(); - areawinset(sa->win); - activate_imageselect(FILE_SPECIAL, "SELECT FTYPE", G.scene->r.ftype, ftype_pic); - break; + mtex= la->mtex[ la->texact ]; + if(mtex==0) { + mtex= &emptytex; + default_mtex(mtex); + mtex->texco= TEXCO_VIEW; + } - case B_PR_PAL: - G.scene->r.xsch= 720; - G.scene->r.ysch= 576; - G.scene->r.xasp= 54; - G.scene->r.yasp= 51; - G.scene->r.size= 100; - G.scene->r.frs_sec= 25; - G.scene->r.mode &= ~R_PANORAMA; - G.scene->r.xparts= G.scene->r.yparts= 1; - - BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9); - allqueue(REDRAWBUTSRENDER, 0); - allqueue(REDRAWVIEWCAM, 0); - break; - -#ifdef WITH_QUICKTIME - case B_FILETYPEMENU: - allqueue(REDRAWBUTSRENDER, 0); -#if defined (_WIN32) || defined (__APPLE__) - // fall through to codec settings if this is the first - // time R_AVICODEC is selected for this scene. - if (((G.scene->r.imtype == R_AVICODEC) - && (G.scene->r.avicodecdata == NULL)) || - ((G.scene->r.imtype == R_QUICKTIME) - && (G.scene->r.qtcodecdata == NULL))) { - } else { - break; - } -#else /* libquicktime */ - if(G.scene->r.imtype == R_QUICKTIME) { - /* i'm not sure if this should be here... */ - /* set default quicktime codec */ - if (!G.scene->r.qtcodecdata) { - G.scene->r.qtcodecdata = MEM_callocN(sizeof(QtCodecData), - "QtCodecData"); - qtcodec_idx = 1; - } - - qt_init_codecs(); - if (qtcodec_idx < 1) qtcodec_idx = 1; - - G.scene->r.qtcodecdata->fourcc = - qtcodecidx_to_fcc(qtcodec_idx-1); - qt_init_codecdata(G.scene->r.qtcodecdata); -/* I'm not sure if this is really needed, so don't remove it yet */ -#if 0 - /* get index of codec that can handle a given fourcc */ - if (qtcodec_idx < 1) - qtcodec_idx = get_qtcodec_idx(G.scene->r.qtcodecdata->fourcc)+1; - - /* no suitable codec found, alert user */ - if (qtcodec_idx < -1) { - error("no suitable codec found!"); - qtcodec_idx = 1; - } -#endif /* 0 */ - } -#endif /*_WIN32 || __APPLE__ */ + /* TEXCO */ + uiBlockSetCol(block, BUTGREEN); + uiDefButS(block, ROW, B_MATPRV, "Object", 745,146,49,18, &(mtex->texco), 4.0, (float)TEXCO_OBJECT, 0, 0, "Use linked object's coordinates for texture coordinates"); + uiDefIDPoinBut(block, test_obpoin_but, B_MATPRV, "", 745,166,133,18, &(mtex->object), ""); + uiDefButS(block, ROW, B_MATPRV, "Glob", 795,146,45,18, &(mtex->texco), 4.0, (float)TEXCO_GLOB, 0, 0, "Generate texture coordinates from global coordinates"); + uiDefButS(block, ROW, B_MATPRV, "View", 839,146,39,18, &(mtex->texco), 4.0, (float)TEXCO_VIEW, 0, 0, "Generate texture coordinates from view coordinates"); + + uiBlockSetCol(block, BUTGREY); + uiDefButF(block, NUM, B_MATPRV, "dX", 745,114,133,18, mtex->ofs, -20.0, 20.0, 10, 0, "Set the extra translation of the texture coordinate"); + uiDefButF(block, NUM, B_MATPRV, "dY", 745,94,133,18, mtex->ofs+1, -20.0, 20.0, 10, 0, "Set the extra translation of the texture coordinate"); + uiDefButF(block, NUM, B_MATPRV, "dZ", 745,74,133,18, mtex->ofs+2, -20.0, 20.0, 10, 0, "Set the extra translation of the texture coordinate"); + uiDefButF(block, NUM, B_MATPRV, "sizeX", 745,50,133,18, mtex->size, -10.0, 10.0, 10, 0, "Set the extra scaling of the texture coordinate"); + uiDefButF(block, NUM, B_MATPRV, "sizeY", 745,30,133,18, mtex->size+1, -10.0, 10.0, 10, 0, "Set the extra scaling of the texture coordinate"); + uiDefButF(block, NUM, B_MATPRV, "sizeZ", 745,10,133,18, mtex->size+2, -10.0, 10.0, 10, 0, "Set the extra scaling of the texture coordinate"); - case B_SELECTCODEC: -#if defined (_WIN32) || defined (__APPLE__) - if ((G.scene->r.imtype == R_QUICKTIME)) /* || (G.scene->r.qtcodecdata)) */ - get_qtcodec_settings(); -#ifdef _WIN32 - else - get_avicodec_settings(); -#endif /* _WIN32 */ -#else /* libquicktime */ - if (!G.scene->r.qtcodecdata) { - G.scene->r.qtcodecdata = MEM_callocN(sizeof(QtCodecData), - "QtCodecData"); - qtcodec_idx = 1; - } - if (qtcodec_idx < 1) { - qtcodec_idx = 1; - qt_init_codecs(); + /* TEXTUREBLOK SELECT */ + id= (ID *)mtex->tex; + IDnames_to_pupstring(&strp, NULL, "ADD NEW %x 32767", &(G.main->tex), id, &(G.buts->texnr)); + + /* doesnt work, because lockpoin points to lamp, not to texture */ + uiDefButS(block, MENU, B_LTEXBROWSE, strp, 900,146,20,19, &(G.buts->texnr), 0, 0, 0, 0, "Select an existing texture, or create new"); + MEM_freeN(strp); + + if(id) { + uiDefBut(block, TEX, B_IDNAME, "TE:", 900,166,163,19, id->name+2, 0.0, 18.0, 0, 0, "Name of the texture block"); + sprintf(str, "%d", id->us); + uiDefBut(block, BUT, 0, str, 996,146,21,19, 0, 0, 0, 0, 0, "Select an existing texture, or create new"); + uiDefIconBut(block, BUT, B_AUTOTEXNAME, ICON_AUTO, 1041,146,21,19, 0, 0, 0, 0, 0, "Auto assign a name to the texture"); + if(id->lib) { + if(la->id.lib) uiDefIconBut(block, BUT, 0, ICON_DATALIB, 1019,146,21,19, 0, 0, 0, 0, 0, ""); + else uiDefIconBut(block, BUT, 0, ICON_PARLIB, 1019,146,21,19, 0, 0, 0, 0, 0, ""); } - - G.scene->r.qtcodecdata->fourcc = qtcodecidx_to_fcc(qtcodec_idx-1); - /* if the selected codec differs from the previous one, reinit it */ - qt_init_codecdata(G.scene->r.qtcodecdata); - allqueue(REDRAWBUTSRENDER, 0); -#endif /* _WIN32 || __APPLE__ */ - break; -#endif /* WITH_QUICKTIME */ - - case B_PR_FULL: - G.scene->r.xsch= 1280; - G.scene->r.ysch= 1024; - G.scene->r.xasp= 1; - G.scene->r.yasp= 1; - G.scene->r.size= 100; - G.scene->r.mode &= ~R_PANORAMA; - G.scene->r.xparts= G.scene->r.yparts= 1; - - BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9); - allqueue(REDRAWBUTSRENDER, 0); - allqueue(REDRAWVIEWCAM, 0); - break; - case B_PR_PRV: - G.scene->r.xsch= 640; - G.scene->r.ysch= 512; - G.scene->r.xasp= 1; - G.scene->r.yasp= 1; - G.scene->r.size= 50; - G.scene->r.mode &= ~R_PANORAMA; - G.scene->r.xparts= G.scene->r.yparts= 1; - - BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9); - allqueue(REDRAWVIEWCAM, 0); - allqueue(REDRAWBUTSRENDER, 0); - break; - case B_PR_CDI: - G.scene->r.xsch= 384; - G.scene->r.ysch= 280; - G.scene->r.xasp= 1; - G.scene->r.yasp= 1; - G.scene->r.size= 100; - G.scene->r.mode &= ~R_PANORAMA; - G.scene->r.xparts= G.scene->r.yparts= 1; - - BLI_init_rctf(&G.scene->r.safety, 0.15, 0.85, 0.15, 0.85); - allqueue(REDRAWVIEWCAM, 0); - allqueue(REDRAWBUTSRENDER, 0); - break; - case B_PR_PAL169: - G.scene->r.xsch= 720; - G.scene->r.ysch= 576; - G.scene->r.xasp= 64; - G.scene->r.yasp= 45; - G.scene->r.size= 100; - G.scene->r.frs_sec= 25; - G.scene->r.mode &= ~R_PANORAMA; - G.scene->r.xparts= G.scene->r.yparts= 1; - - BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9); - allqueue(REDRAWVIEWCAM, 0); - allqueue(REDRAWBUTSRENDER, 0); - break; - case B_PR_D2MAC: - G.scene->r.xsch= 1024; - G.scene->r.ysch= 576; - G.scene->r.xasp= 1; - G.scene->r.yasp= 1; - G.scene->r.size= 50; - G.scene->r.mode &= ~R_PANORAMA; - G.scene->r.xparts= G.scene->r.yparts= 1; - - BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9); - allqueue(REDRAWVIEWCAM, 0); - allqueue(REDRAWBUTSRENDER, 0); - break; - case B_PR_MPEG: - G.scene->r.xsch= 368; - G.scene->r.ysch= 272; - G.scene->r.xasp= 105; - G.scene->r.yasp= 100; - G.scene->r.size= 100; - G.scene->r.mode &= ~R_PANORAMA; - G.scene->r.xparts= G.scene->r.yparts= 1; - - BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9); - allqueue(REDRAWVIEWCAM, 0); - allqueue(REDRAWBUTSRENDER, 0); - break; - case B_PR_PC: - G.scene->r.xsch= 640; - G.scene->r.ysch= 480; - G.scene->r.xasp= 100; - G.scene->r.yasp= 100; - G.scene->r.size= 100; - G.scene->r.mode &= ~R_PANORAMA; - G.scene->r.xparts= G.scene->r.yparts= 1; - - BLI_init_rctf(&G.scene->r.safety, 0.0, 1.0, 0.0, 1.0); - allqueue(REDRAWVIEWCAM, 0); - allqueue(REDRAWBUTSRENDER, 0); - break; - case B_PR_PRESET: - G.scene->r.xsch= 720; - G.scene->r.ysch= 576; - G.scene->r.xasp= 54; - G.scene->r.yasp= 51; - G.scene->r.size= 100; - G.scene->r.mode= R_OSA+R_SHADOW+R_FIELDS; - G.scene->r.imtype= R_TARGA; - G.scene->r.xparts= G.scene->r.yparts= 1; - - BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9); - allqueue(REDRAWVIEWCAM, 0); - allqueue(REDRAWBUTSRENDER, 0); - break; - case B_PR_PANO: - G.scene->r.xsch= 36; - G.scene->r.ysch= 176; - G.scene->r.xasp= 115; - G.scene->r.yasp= 100; - G.scene->r.size= 100; - G.scene->r.mode |= R_PANORAMA; - G.scene->r.xparts= 16; - G.scene->r.yparts= 1; - - BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9); - allqueue(REDRAWVIEWCAM, 0); - allqueue(REDRAWBUTSRENDER, 0); - break; - case B_PR_NTSC: - G.scene->r.xsch= 720; - G.scene->r.ysch= 480; - G.scene->r.xasp= 10; - G.scene->r.yasp= 11; - G.scene->r.size= 100; - G.scene->r.frs_sec= 30; - G.scene->r.mode &= ~R_PANORAMA; - G.scene->r.xparts= G.scene->r.yparts= 1; - - BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9); - allqueue(REDRAWBUTSRENDER, 0); - allqueue(REDRAWVIEWCAM, 0); - break; - - case B_SETBROWSE: - id= (ID*) G.scene->set; - - if (G.buts->menunr==-2) { - activate_databrowse(id, ID_SCE, 0, B_SETBROWSE, &G.buts->menunr, do_renderbuts); - } else if (G.buts->menunr>0) { - Scene *newset= (Scene*) BLI_findlink(&G.main->scene, G.buts->menunr-1); - - if (newset==G.scene) - error("Not allowed"); - else if (newset) - scene_change_set(G.scene, newset); - } - break; - case B_CLEARSET: - scene_change_set(G.scene, NULL); - break; + uiBlockSetCol(block, BUTSALMON); + uiDefBut(block, BUT, B_TEXCLEARLAMP, "Clear", 922, 146, 72, 19, 0, 0, 0, 0, 0, "Erase link to texture"); + uiBlockSetCol(block, BUTGREY); } -} -uiBlock *edge_render_menu(void *arg_unused) -{ - uiBlock *block; + /* TEXTURE OUTPUT */ + uiDefButS(block, TOG|BIT|1, B_MATPRV, "Stencil", 900,114,52,18, &(mtex->texflag), 0, 0, 0, 0, "Set the mapping to stencil mode"); + uiDefButS(block, TOG|BIT|2, B_MATPRV, "Neg", 954,114,38,18, &(mtex->texflag), 0, 0, 0, 0, "Apply the inverse of the texture"); + uiDefButS(block, TOG|BIT|0, B_MATPRV, "RGBtoInt", 994,114,69,18, &(mtex->texflag), 0, 0, 0, 0, "Use an RGB texture as an intensity texture"); + + uiDefButF(block, COL, B_MTEXCOL, "", 900,100,163,12, &(mtex->r), 0, 0, 0, 0, ""); + uiDefButF(block, NUMSLI, B_MATPRV, "R ", 900,80,163,18, &(mtex->r), 0.0, 1.0, B_MTEXCOL, 0, "Set the red component of the intensity texture to blend with"); + uiDefButF(block, NUMSLI, B_MATPRV, "G ", 900,60,163,18, &(mtex->g), 0.0, 1.0, B_MTEXCOL, 0, "Set the green component of the intensity texture to blend with"); + uiDefButF(block, NUMSLI, B_MATPRV, "B ", 900,40,163,18, &(mtex->b), 0.0, 1.0, B_MTEXCOL, 0, "Set the blue component of the intensity texture to blend with"); + uiDefButF(block, NUMSLI, B_MATPRV, "DVar ", 900,10,163,18, &(mtex->def_var), 0.0, 1.0, 0, 0, "Set the value the texture blends with"); - block= uiNewBlock(&curarea->uiblocks, - "edge render", UI_EMBOSSX, UI_HELV, - curarea->win); - - /* use this for a fake extra empy space around the buttons */ - uiDefBut(block, LABEL, 0, "", -/* 285, -20, 230, 100, NULL, */ - 285, -20, 230, 120, NULL, - 0, 0, 0, 0, ""); - - uiDefButS(block, NUM, 0,"Eint:", - 295,50,70,19, - &G.scene->r.edgeint, 0.0, 255.0, 0, 0, - "Sets edge intensity for Toon shading"); + /* MAP TO */ uiBlockSetCol(block, BUTGREEN); - uiDefButI(block, TOG, 0,"Shift", - 365,50,70,19, - &G.compat, 0, 0, 0, 0, - "For unified renderer: use old offsets for edges"); - uiDefButI(block, TOG, 0,"All", 435,50,70,19, - &G.notonlysolid, 0, 0, 0, 0, - "For unified renderer: also consider transparent " - "faces for toon shading"); - - /* colour settings for the toon shading */ + uiDefButS(block, TOG|BIT|0, B_MATPRV, "Col", 1087,166,81,18, &(mtex->mapto), 0, 0, 0, 0, "Let the texture affect the colour of the lamp"); + uiBlockSetCol(block, BUTGREY); - uiDefButF(block, COL, B_EDGECOLSLI, "", - 295,-10,30,60, - &(G.scene->r.edgeR), 0, 0, 0, 0, - ""); - - uiDefButF(block, NUMSLI, 0, "R ", - 325, 30, 180,19, - &G.scene->r.edgeR, 0.0, 1.0, B_EDGECOLSLI, 0, - "For unified renderer: Colour for edges in toon shading mode."); - uiDefButF(block, NUMSLI, 0, "G ", - 325, 10, 180,19, - &G.scene->r.edgeG, 0.0, 1.0, B_EDGECOLSLI, 0, - "For unified renderer: Colour for edges in toon shading mode."); - uiDefButF(block, NUMSLI, 0, "B ", - 325, -10, 180,19, - &G.scene->r.edgeB, 0.0, 1.0, B_EDGECOLSLI, 0, - "For unified renderer: Colour for edges in toon shading mode."); - - uiDefButS(block, NUM, 0,"AntiShift", - 365,70,140,19, - &(G.scene->r.same_mat_redux), 0, 255.0, 0, 0, - "For unified renderer: reduce intensity on boundaries " - "with identical materials with this number."); - - uiBlockSetDirection(block, UI_TOP); - - return block; + uiDefButS(block, ROW, B_MATPRV, "Blend", 1087,114,48,18, &(mtex->blendtype), 9.0, (float)MTEX_BLEND, 0, 0, "Mix the values"); + uiDefButS(block, ROW, B_MATPRV, "Mul", 1136,114,44,18, &(mtex->blendtype), 9.0, (float)MTEX_MUL, 0, 0, "Multiply the values"); + uiDefButS(block, ROW, B_MATPRV, "Add", 1182,114,41,18, &(mtex->blendtype), 9.0, (float)MTEX_ADD, 0, 0, "Add the values"); + uiDefButS(block, ROW, B_MATPRV, "Sub", 1226,114,40,18, &(mtex->blendtype), 9.0, (float)MTEX_SUB, 0, 0, "Subtract the values"); + + uiDefButF(block, NUMSLI, B_MATPRV, "Col ", 1087,50,179,18, &(mtex->colfac), 0.0, 1.0, 0, 0, "Set the amount the texture affects the colour"); + uiDefButF(block, NUMSLI, B_MATPRV, "Nor ", 1087,30,179,18, &(mtex->norfac), 0.0, 1.0, 0, 0, "Set the amount the texture affects the normal"); + uiDefButF(block, NUMSLI, B_MATPRV, "Var ", 1087,10,179,18, &(mtex->varfac), 0.0, 1.0, 0, 0, "Set the amount the texture affects the value"); + + + BIF_previewdraw(G.buts); + + uiDrawBlock(block); } -static uiBlock *post_render_menu(void *arg_unused) -{ - uiBlock *block; - - block= uiNewBlock(&curarea->uiblocks, "post render", UI_EMBOSSX, UI_HELV, curarea->win); - - /* use this for a fake extra empy space around the buttons */ - uiDefBut(block, LABEL, 0, "", -10, 10, 200, 80, NULL, 0, 0, 0, 0, ""); - - uiDefButF(block, NUMSLI, 0,"Add:", 0,60,180,19, - &G.scene->r.postadd, -1.0, 1.0, 0, 0, ""); - uiDefButF(block, NUMSLI, 0,"Mul:", 0,40,180,19, - &G.scene->r.postmul, 0.01, 4.0, 0, 0, ""); - uiDefButF(block, NUMSLI, 0,"Gamma:", 0,20,180,19, - &G.scene->r.postgamma, 0.2, 2.0, 0, 0, ""); - uiBlockSetDirection(block, UI_TOP); +/* ***************************** WORLD ************************** */ + +void do_worldbuts(unsigned short event) +{ + World *wrld; + MTex *mtex; - return block; + switch(event) { + case B_TEXCLEARWORLD: + wrld= G.buts->lockpoin; + mtex= wrld->mtex[ wrld->texact ]; + if(mtex) { + if(mtex->tex) mtex->tex->id.us--; + MEM_freeN(mtex); + wrld->mtex[ wrld->texact ]= 0; + allqueue(REDRAWBUTSWORLD, 0); + allqueue(REDRAWOOPS, 0); + BIF_preview_changed(G.buts); + } + break; + } } - -static uiBlock *framing_render_menu(void *arg_unused) +void worldbuts(void) { + World *wrld; + MTex *mtex; + ID *id; uiBlock *block; - short yco = 60, xco = 0; - int randomcolorindex = 1234; + int a, loos; + char str[30], *strp; + short xco; - block= uiNewBlock(&curarea->uiblocks, "framing_options", UI_EMBOSSX, UI_HELV, curarea->win); + wrld= G.scene->world; + if(wrld==0) return; - /* use this for a fake extra empy space around the buttons */ - uiDefBut(block, LABEL, 0, "", -10, -10, 300, 100, NULL, 0, 0, 0, 0, ""); + sprintf(str, "buttonswin %d", curarea->win); + block= uiNewBlock(&curarea->uiblocks, str, UI_EMBOSSX, UI_HELV, curarea->win); - uiDefBut(block, LABEL, B_NOP, "Framing:", xco, yco, 68,19, 0, 0, 0, 0, 0, ""); - uiDefButC(block, ROW, 0, "Stretch", xco += 70, yco, 68, 19, &G.scene->framing.type, 1.0, SCE_GAMEFRAMING_SCALE , 0, 0, "Stretch or squeeze the viewport to fill the display window"); - uiDefButC(block, ROW, 0, "Expose", xco += 70, yco, 68, 19, &G.scene->framing.type, 1.0, SCE_GAMEFRAMING_EXTEND, 0, 0, "Show the entire viewport in the display window, viewing more horizontally or vertically"); - uiDefButC(block, ROW, 0, "Bars", xco += 70, yco, 68, 19, &G.scene->framing.type, 1.0, SCE_GAMEFRAMING_BARS , 0, 0, "Show the entire viewport in the display window, using bar horizontally or vertically"); + uiSetButLock(wrld->id.lib!=0, "Can't edit library data"); + uiBlockSetCol(block, BUTGREEN); - yco -= 20; - xco = 35; + uiDefButS(block, TOG|BIT|1,B_MATPRV,"Real", 286,190,71,19, &wrld->skytype, 0, 0, 0, 0, "Render background with real horizon"); + uiDefButS(block, TOG|BIT|0,B_MATPRV,"Blend", 208,190,74,19, &wrld->skytype, 0, 0, 0, 0, "Render background with natural progression"); + uiDefButS(block, TOG|BIT|2,B_MATPRV,"Paper", 361,190,71,19, &wrld->skytype, 0, 0, 0, 0, "Flatten blend or texture coordinates"); + uiBlockSetCol(block, BUTGREY); + uiDefButF(block, NUMSLI,B_MATPRV,"HoR ", 200,55,175,18, &(wrld->horr), 0.0, 1.0, 0,0, "The amount of red of the horizon colour"); + uiDefButF(block, NUMSLI,B_MATPRV,"HoG ", 200,34,175,18, &(wrld->horg), 0.0, 1.0, 0,0, "The amount of green of the horizon colour"); + uiDefButF(block, NUMSLI,B_MATPRV,"HoB ", 200,13,175,18, &(wrld->horb), 0.0, 1.0, 0,0, "The amount of blue of the horizon colour"); + uiDefButF(block, NUMSLI,B_MATPRV,"ZeR ", 200,136,175,18, &(wrld->zenr), 0.0, 1.0, 0,0, "The amount of red of the zenith colour"); + uiDefButF(block, NUMSLI,B_MATPRV,"ZeG ", 200,116,175,18, &(wrld->zeng), 0.0, 1.0, 0,0, "The amount of green of the zenith colour"); + uiDefButF(block, NUMSLI,B_MATPRV,"ZeB ", 200,96,175,18, &(wrld->zenb), 0.0, 1.0, 0,0, "The amount of blue of the zenith colour"); + uiDefButF(block, NUMSLI,B_MATPRV,"AmbR ", 380,55,175,18, &(wrld->ambr), 0.0, 1.0 ,0,0, "The amount of red of the ambient colour"); + uiDefButF(block, NUMSLI,B_MATPRV,"AmbG ", 380,34,175,18, &(wrld->ambg), 0.0, 1.0 ,0,0, "The amount of red of the ambient colour"); + uiDefButF(block, NUMSLI,B_MATPRV,"AmbB ", 380,13,175,18, &(wrld->ambb), 0.0, 1.0 ,0,0, "The amount of red of the ambient colour"); - uiDefButF(block, COL, randomcolorindex, "", 0, yco - 58 + 18, 33, 58, &G.scene->framing.col[0], 0, 0, 0, 0, ""); + uiDefBut(block, MENU|SHO, 1, physics_pup(), + 380,152,175,18, &wrld->pad1, 0, 0, 0, 0, "Physics Engine"); + - uiDefButF(block, NUMSLI, 0, "R ", xco,yco,243,18, &G.scene->framing.col[0], 0.0, 1.0, randomcolorindex, 0, "Set the red component of the bars"); - yco -= 20; - uiDefButF(block, NUMSLI, 0, "G ", xco,yco,243,18, &G.scene->framing.col[1], 0.0, 1.0, randomcolorindex, 0, "Set the green component of the bars"); - yco -= 20; - uiDefButF(block, NUMSLI, 0, "B ", xco,yco,243,18, &G.scene->framing.col[2], 0.0, 1.0, randomcolorindex, 0, "Set the blue component of the bars"); + /* Activity bubble */ + // uiDefButS(block, TOG|BIT|3,B_DIFF, "Do activity culling", + // 380,152,175,18, &wrld->mode, 0, 0, 0, 0, + // "Disable logic and physics for far away objects."); +/* if (wrld->mode & WO_ACTIVITY_CULLING) { */ + // uiDefButF(block, NUM,0, "Active R ", + // 380,132,175,18, &(wrld->activityBoxRadius), 0.5, 10000.0, 100.0, 0, + // "Radius for activity culling (in Manhattan length)."); +/* } */ + + /* Gravitation for the game worlds */ + uiDefButF(block, NUMSLI,0, "Grav ", + 380,112,175,18, &(wrld->gravity), 0.0, 25.0, 0, 0, + "Gravitation constant of the game world."); + + uiDefButF(block, NUMSLI,0, "Expos ", 380,92,175,18, &(wrld->exposure), 0.2, 5.0, 0, 0, "Set the lighting time, exposure"); - uiBlockSetDirection(block, UI_TOP); + uiBlockSetCol(block, BUTGREEN); + uiDefButS(block, TOG|BIT|0,REDRAWVIEW3D,"Mist", 571,190,100,19, &wrld->mode, 0, 0, 0, 0, "Enable mist"); + uiBlockSetCol(block, BUTGREY); + uiDefButS(block, ROW, B_DIFF, "Qua", 571, 170, 33, 19, &wrld->mistype, 1.0, 0.0, 0, 0, "Use quadratic progression"); + uiDefButS(block, ROW, B_DIFF, "Lin", 604, 170, 33, 19, &wrld->mistype, 1.0, 1.0, 0, 0, "Use linear progression"); + uiDefButS(block, ROW, B_DIFF, "Sqr", 637, 170, 33, 19, &wrld->mistype, 1.0, 2.0, 0, 0, "Use inverse quadratic progression"); + + uiDefButF(block, NUM,REDRAWVIEW3D, "Sta:",571,150,100,17, &wrld->miststa, 0.0, 1000.0, 10, 0, "Specify the starting distance of the mist"); + uiDefButF(block, NUM,REDRAWVIEW3D, "Di:",571,133,100,17, &wrld->mistdist, 0.0,1000.0, 10, 00, "Specify the depth of the mist"); + uiDefButF(block, NUM,B_DIFF,"Hi:", 571,116,100,17, &wrld->misthi,0.0,100.0, 10, 0, "Specify the factor for a less dense mist with increasing height"); + + uiDefButF(block, NUM, 0, "misi", 571,99,100,17, &(wrld->misi), 0., 1.0, 0, 0, "Set the mist intensity"); - return block; -} + uiBlockSetCol(block, BUTGREEN); + uiDefButS(block, TOG|BIT|1,B_DIFF, "Stars",571,82,100,17, &wrld->mode, 0, 0, 0, 0, "Enable stars"); + uiBlockSetCol(block, BUTGREY); + uiDefButF(block, NUM,B_DIFF,"StarDist:", 571,65,100,17, &(wrld->stardist), 2.0, 1000.0, 100, 0, "Specify the average distance between two stars"); + uiDefButF(block, NUM,B_DIFF,"MinDist:", 571,48,100,17, &(wrld->starmindist), 0.0, 1000.0, 100, 0, "Specify the minimum distance to the camera"); + uiDefButF(block, NUM,B_DIFF,"Size:", 571,31,100,17, &(wrld->starsize), 0.0, 10.0, 10, 0, "Specify the average screen dimension"); + uiDefButF(block, NUM,B_DIFF,"Colnoise:", 571,12,100,17, &(wrld->starcolnoise), 0.0, 1.0, 100, 0, "Randomize starcolour"); -static char *imagetype_pup(void) -{ - static char string[1024]; - char formatstring[1024]; + /* TEX CHANNELS */ + uiBlockSetCol(block, BUTGREY); + xco= 745; + for(a= 0; a<6; a++) { + mtex= wrld->mtex[a]; + if(mtex && mtex->tex) splitIDname(mtex->tex->id.name+2, str, &loos); + else strcpy(str, ""); + str[10]= 0; + uiDefButS(block, ROW, REDRAWBUTSWORLD, str, xco, 195, 83, 20, &(wrld->texact), 3.0, (float)a, 0, 0, "Texture channel"); + xco+= 85; + } + + mtex= wrld->mtex[ wrld->texact ]; + if(mtex==0) { + mtex= &emptytex; + default_mtex(mtex); + mtex->texco= TEXCO_VIEW; + } + + /* TEXCO */ + uiBlockSetCol(block, BUTGREEN); + uiDefButS(block, ROW, B_MATPRV, "Object", 745,146,49,18, &(mtex->texco), 4.0, (float)TEXCO_OBJECT, 0, 0, "The name of the object used as a source for texture coordinates"); + uiDefIDPoinBut(block, test_obpoin_but, B_MATPRV, "", 745,166,133,18, &(mtex->object), ""); + uiDefButS(block, ROW, B_MATPRV, "View", 839,146,39,18, &(mtex->texco), 4.0, (float)TEXCO_VIEW, 0, 0, "Pass camera view vector on to the texture"); + + uiBlockSetCol(block, BUTGREY); + uiDefButF(block, NUM, B_MATPRV, "dX", 745,114,133,18, mtex->ofs, -20.0, 20.0, 10, 0, "Fine tune X coordinate"); + uiDefButF(block, NUM, B_MATPRV, "dY", 745,94,133,18, mtex->ofs+1, -20.0, 20.0, 10, 0, "Fine tune Y coordinate"); + uiDefButF(block, NUM, B_MATPRV, "dZ", 745,74,133,18, mtex->ofs+2, -20.0, 20.0, 10, 0, "Fine tune Z coordinate"); + uiDefButF(block, NUM, B_MATPRV, "sizeX", 745,50,133,18, mtex->size, -20.0, 20.0, 10, 0, "Set an extra scaling for the texture coordinate"); + uiDefButF(block, NUM, B_MATPRV, "sizeY", 745,30,133,18, mtex->size+1, -20.0, 20.0, 10, 0, "Set an extra scaling for the texture coordinate"); + uiDefButF(block, NUM, B_MATPRV, "sizeZ", 745,10,133,18, mtex->size+2, -20.0, 20.0, 10, 0, "Set an extra scaling for the texture coordinate"); + + /* TEXTUREBLOCK SELECT */ + id= (ID *)mtex->tex; + IDnames_to_pupstring(&strp, NULL, "ADD NEW %x 32767", &(G.main->tex), id, &(G.buts->texnr)); + uiDefButS(block, MENU, B_WTEXBROWSE, strp, 900,146,20,19, &(G.buts->texnr), 0, 0, 0, 0, "Browse"); + MEM_freeN(strp); + + if(id) { + uiDefBut(block, TEX, B_IDNAME, "TE:", 900,166,163,19, id->name+2, 0.0, 18.0, 0, 0, "Specify the texture name"); + sprintf(str, "%d", id->us); + uiDefBut(block, BUT, 0, str, 996,146,21,19, 0, 0, 0, 0, 0, "Number of users"); + uiDefIconBut(block, BUT, B_AUTOTEXNAME, ICON_AUTO, 1041,146,21,19, 0, 0, 0, 0, 0, "Auto assign name to texture"); + if(id->lib) { + if(wrld->id.lib) uiDefIconBut(block, BUT, 0, ICON_DATALIB, 1019,146,21,19, 0, 0, 0, 0, 0, ""); + else uiDefIconBut(block, BUT, 0, ICON_PARLIB, 1019,146,21,19, 0, 0, 0, 0, 0, ""); + } + uiBlockSetCol(block, BUTSALMON); + uiDefBut(block, BUT, B_TEXCLEARWORLD, "Clear", 922, 146, 72, 19, 0, 0, 0, 0, 0, "Erase link to texture"); + uiBlockSetCol(block, BUTGREY); + } + + /* TEXTURE OUTPUT */ + uiDefButS(block, TOG|BIT|1, B_MATPRV, "Stencil", 900,114,52,18, &(mtex->texflag), 0, 0, 0, 0, "Use stencil mode"); + uiDefButS(block, TOG|BIT|2, B_MATPRV, "Neg", 954,114,38,18, &(mtex->texflag), 0, 0, 0, 0, "Inverse texture operation"); + uiDefButS(block, TOG|BIT|0, B_MATPRV, "RGBtoInt", 994,114,69,18, &(mtex->texflag), 0, 0, 0, 0, "Use RGB values for intensity texure"); + + uiDefButF(block, COL, B_MTEXCOL, "", 900,100,163,12, &(mtex->r), 0, 0, 0, 0, ""); + uiDefButF(block, NUMSLI, B_MATPRV, "R ", 900,80,163,18, &(mtex->r), 0.0, 1.0, B_MTEXCOL, 0, "The amount of red that blends with the intensity colour"); + uiDefButF(block, NUMSLI, B_MATPRV, "G ", 900,60,163,18, &(mtex->g), 0.0, 1.0, B_MTEXCOL, 0, "The amount of green that blends with the intensity colour"); + uiDefButF(block, NUMSLI, B_MATPRV, "B ", 900,40,163,18, &(mtex->b), 0.0, 1.0, B_MTEXCOL, 0, "The amount of blue that blends with the intensity colour"); + uiDefButF(block, NUMSLI, B_MATPRV, "DVar ", 900,10,163,18, &(mtex->def_var), 0.0, 1.0, 0, 0, "The value that an intensity texture blends with the current value"); + + /* MAP TO */ + uiBlockSetCol(block, BUTGREEN); + uiDefButS(block, TOG|BIT|0, B_MATPRV, "Blend", 1087,166,81,18, &(mtex->mapto), 0, 0, 0, 0, "Let the texture work on the colour progression in the sky"); + uiDefButS(block, TOG|BIT|1, B_MATPRV, "Hori", 1172,166,81,18, &(mtex->mapto), 0, 0, 0, 0, "Let the texture work on the colour of the horizon"); + uiDefButS(block, TOG|BIT|2, B_MATPRV, "ZenUp", 1087,147,81,18, &(mtex->mapto), 0, 0, 0, 0, "Let the texture work on the colour of the zenith above"); + uiDefButS(block, TOG|BIT|3, B_MATPRV, "ZenDo", 1172,147,81,18, &(mtex->mapto), 0, 0, 0, 0, "Let the texture work on the colour of the zenith below"); + + uiBlockSetCol(block, BUTGREY); + uiDefButS(block, ROW, B_MATPRV, "Blend", 1087,114,48,18, &(mtex->blendtype), 9.0, (float)MTEX_BLEND, 0, 0, "The texture blends the values"); + uiDefButS(block, ROW, B_MATPRV, "Mul", 1136,114,44,18, &(mtex->blendtype), 9.0, (float)MTEX_MUL, 0, 0, "The texture multiplies the values"); + uiDefButS(block, ROW, B_MATPRV, "Add", 1182,114,41,18, &(mtex->blendtype), 9.0, (float)MTEX_ADD, 0, 0, "The texture adds the values"); + uiDefButS(block, ROW, B_MATPRV, "Sub", 1226,114,40,18, &(mtex->blendtype), 9.0, (float)MTEX_SUB, 0, 0, "The texture subtracts the values"); + + uiDefButF(block, NUMSLI, B_MATPRV, "Col ", 1087,50,179,18, &(mtex->colfac), 0.0, 1.0, 0, 0, "Specify the extent to which the texture works on colour"); + uiDefButF(block, NUMSLI, B_MATPRV, "Nor ", 1087,30,179,18, &(mtex->norfac), 0.0, 1.0, 0, 0, "Specify the extent to which the texture works on the normal"); + uiDefButF(block, NUMSLI, B_MATPRV, "Var ", 1087,10,179,18, &(mtex->varfac), 0.0, 1.0, 0, 0, "Specify the extent to which the texture works on a value"); - strcpy(formatstring, "Save image as: %%t|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d"); -#ifdef __sgi - strcat(formatstring, "|%s %%x%d"); // add space for Movie -#endif + BIF_previewdraw(G.buts); - strcat(formatstring, "|%s %%x%d"); // add space for PNG + uiDrawBlock(block); +} -#ifdef _WIN32 - strcat(formatstring, "|%s %%x%d"); // add space for AVI Codec -#endif -#ifdef WITH_QUICKTIME - if(G.have_quicktime) - strcat(formatstring, "|%s %%x%d"); // add space for Quicktime -#endif +/* **************************** VIEW ************************ */ - if(G.have_quicktime) { - sprintf(string, formatstring, - "AVI Raw", R_AVIRAW, - "AVI Jpeg", R_AVIJPEG, -#ifdef _WIN32 - "AVI Codec", R_AVICODEC, -#endif -#ifdef WITH_QUICKTIME - "QuickTime", R_QUICKTIME, -#endif - "Targa", R_TARGA, - "Targa Raw", R_RAWTGA, - "PNG", R_PNG, - "Jpeg", R_JPEG90, - "HamX", R_HAMX, - "Iris", R_IRIS, - "Iris + Zbuffer", R_IRIZ, - "Ftype", R_FTYPE, - "Movie", R_MOVIE - ); - } else { - sprintf(string, formatstring, - "AVI Raw", R_AVIRAW, - "AVI Jpeg", R_AVIJPEG, -#ifdef _WIN32 - "AVI Codec", R_AVICODEC, -#endif - "Targa", R_TARGA, - "Targa Raw", R_RAWTGA, - "PNG", R_PNG, - "Jpeg", R_JPEG90, - "HamX", R_HAMX, - "Iris", R_IRIS, - "Iris + Zbuffer", R_IRIZ, - "Ftype", R_FTYPE, - "Movie", R_MOVIE - ); - } +static void view3d_change_bgpic_ima(View3D *v3d, Image *newima) { + if (v3d->bgpic && v3d->bgpic->ima!=newima) { + if (newima) + id_us_plus((ID*) newima); + if (v3d->bgpic->ima) + v3d->bgpic->ima->id.us--; + v3d->bgpic->ima= newima; - return (string); + if(v3d->bgpic->rect) MEM_freeN(v3d->bgpic->rect); + v3d->bgpic->rect= NULL; + + allqueue(REDRAWBUTSVIEW, 0); + } +} +static void view3d_change_bgpic_tex(View3D *v3d, Tex *newtex) { + if (v3d->bgpic && v3d->bgpic->tex!=newtex) { + if (newtex) + id_us_plus((ID*) newtex); + if (v3d->bgpic->tex) + v3d->bgpic->tex->id.us--; + v3d->bgpic->tex= newtex; + + allqueue(REDRAWBUTSVIEW, 0); + } } +static void load_bgpic_image(char *name) +{ + Image *ima; + View3D *vd; + + vd= scrarea_find_space_of_type(curarea, SPACE_VIEW3D); + if(vd==0 || vd->bgpic==0) return; + + ima= add_image(name); + if(ima) { + if(vd->bgpic->ima) { + vd->bgpic->ima->id.us--; + } + vd->bgpic->ima= ima; + + free_image_buffers(ima); /* force read again */ + ima->ok= 1; + } + allqueue(REDRAWBUTSVIEW, 0); + +} -static char *avicodec_str(void) +void do_viewbuts(unsigned short event) { - static char string[1024]; + View3D *vd; + char *name; + + vd= scrarea_find_space_of_type(curarea, SPACE_VIEW3D); + if(vd==0) return; - sprintf(string, "Codec: %s", G.scene->r.avicodecdata->avicodecname); + switch(event) { + case B_LOADBGPIC: + if(vd->bgpic && vd->bgpic->ima) name= vd->bgpic->ima->name; + else name= G.ima; + + activate_imageselect(FILE_SPECIAL, "SELECT IMAGE", name, load_bgpic_image); + break; + case B_BLENDBGPIC: + if(vd->bgpic && vd->bgpic->rect) setalpha_bgpic(vd->bgpic); + break; + case B_BGPICBROWSE: + if(vd->bgpic) { + if (G.buts->menunr==-2) { + activate_databrowse((ID*) vd->bgpic->ima, ID_IM, 0, B_BGPICBROWSE, &G.buts->menunr, do_viewbuts); + } else if (G.buts->menunr>0) { + Image *newima= (Image*) BLI_findlink(&G.main->image, G.buts->menunr-1); - return string; + if (newima) + view3d_change_bgpic_ima(vd, newima); + } + } + break; + case B_BGPICCLEAR: + if (vd->bgpic) + view3d_change_bgpic_ima(vd, NULL); + break; + case B_BGPICTEX: + if (vd->bgpic) { + if (G.buts->texnr==-2) { + activate_databrowse((ID*) vd->bgpic->tex, ID_TE, 0, B_BGPICTEX, &G.buts->texnr, do_viewbuts); + } else if (G.buts->texnr>0) { + Tex *newtex= (Tex*) BLI_findlink(&G.main->tex, G.buts->texnr-1); + + if (newtex) + view3d_change_bgpic_tex(vd, newtex); + } + } + break; + case B_BGPICTEXCLEAR: + if (vd->bgpic) + view3d_change_bgpic_tex(vd, NULL); + break; + } } - -void renderbuts(void) +void viewbuts(void) { + View3D *vd; ID *id; - int a,b; uiBlock *block; - char *strp; - char str[64]; - int yofs; + char *strp, str[64]; + + /* searching for spacedata */ + vd= scrarea_find_space_of_type(curarea, SPACE_VIEW3D); + if(vd==0) return; sprintf(str, "buttonswin %d", curarea->win); block= uiNewBlock(&curarea->uiblocks, str, UI_EMBOSSX, UI_HELV, curarea->win); - - uiDefBut(block, TEX,0,"", 34,172,257,19,G.scene->r.pic, 0.0,79.0, 0, 0, "Directory/name to save rendered Pics to"); - uiDefBut(block, BUT,B_FS_PIC," ", 10,172,22,19, 0, 0, 0, 0, 0, "Open Fileselect to get Pics dir/name"); - uiDefBut(block, TEX,0,"", 34,149,257,19,G.scene->r.backbuf, 0.0,79.0, 0, 0, "Image to use as background for rendering"); - uiDefBut(block, BUT,B_FS_BACKBUF," ", 21,149,11,19, 0, 0, 0, 0, 0, "Open Fileselect to get Backbuf image"); - uiDefBut(block, TEX,0,"", 34,126,257,19,G.scene->r.ftype,0.0,79.0, 0, 0, "Image to use with FTYPE Image type"); - uiDefBut(block, BUT,B_FS_FTYPE," ", 21,126,11,19, 0, 0, 0, 0, 0, "Open Fileselect to get Ftype image"); - uiDefIconBut(block, BUT, B_CLEARSET, ICON_X, 267,102,24,21, 0, 0, 0, 0, 0, "Remove Set link"); - - /* SET BUTTON */ - id= (ID *)G.scene->set; - IDnames_to_pupstring(&strp, NULL, NULL, &(G.main->scene), id, &(G.buts->menunr)); - if(strp[0]) - uiDefButS(block, MENU, B_SETBROWSE, strp, 10,103,22,19, &(G.buts->menunr), 0, 0, 0, 0, "Scene to link as a Set"); - MEM_freeN(strp); - - uiDefBut(block, LABEL, 0, "Set", 295,103,63,19, 0, 0, 0, 0, 0, ""); - - uiBlockSetCol(block, BUTBLUE); - if(G.scene->set) { - uiSetButLock(1, NULL); - uiDefIDPoinBut(block, test_scenepoin_but, 0, "", 34,103,231,19, &(G.scene->set), "Name of the Set"); - uiClearButLock(); + if(vd->flag & V3D_DISPBGPIC) { + if(vd->bgpic==0) { + vd->bgpic= MEM_callocN(sizeof(BGpic), "bgpic"); + vd->bgpic->size= 5.0; + vd->bgpic->blend= 0.5; + } } - - uiBlockSetCol(block, BUTSALMON); - uiDefBut(block, BUT,B_IS_BACKBUF," ", 10,149,11,19, 0, 0, 0, 0, 0, "Open Imageselect to get Backbuf image"); - uiDefBut(block, BUT,B_IS_FTYPE," ", 10,126,11,19, 0, 0, 0, 0, 0, "Open Imageselect to get Ftype image"); - uiBlockSetCol(block, BUTGREY); - - uiDefBut(block, LABEL,0,"Pics", 295,172,63,19, 0, 0, 0, 0, 0, ""); - uiDefButS(block, TOG|BIT|0, 0,"Backbuf", 295,149,63,19, &G.scene->r.bufflag, 0, 0, 0, 0, "Enable/Disable use of Backbuf image"); - uiDefBut(block, LABEL,0,"Ftype", 295,126,63,19, 0, 0, 0, 0, 0, ""); - - uiBlockSetCol(block, BUTGREY); - - for(b=0; b<3; b++) - for(a=0; a<3; a++) - uiDefButS(block, TOG|BIT|(3*b+a),800,"", (short)(34+18*a),(short)(11+12*b),16,10, &R.winpos, 0, 0, 0, 0, "Render window placement on screen"); - - uiDefButS(block, ROW, B_REDR, "DispView", 99,28,77,18, &R.displaymode, 0.0, (float)R_DISPLAYVIEW, 0, 0, "Sets render output to display in 3D view"); - uiDefButS(block, ROW, B_REDR, "DispWin", 99,10,78,18, &R.displaymode, 0.0, (float)R_DISPLAYWIN, 0, 0, "Sets render output to display in a seperate window"); - - uiDefButS(block, TOG|BIT|4, 0, "Extensions", 190,10,95,18, &G.scene->r.scemode, 0.0, 0.0, 0, 0, "Adds extensions to the output when rendering animations"); - - uiBlockSetCol(block, BUTSALMON); - uiDefBut(block, BUT,B_DORENDER,"RENDER", 369,142,192,47, 0, 0, 0, 0, 0, "Start the rendering"); - - uiBlockSetCol(block, BUTGREY); - uiDefButS(block, TOG|BIT|1,0,"Shadow", 565,167,61,22, &G.scene->r.mode, 0, 0, 0, 0, "Enable shadow calculation"); - uiDefButS(block, TOG|BIT|4,0,"EnvMap", 626,167,61,22, &G.scene->r.mode, 0, 0, 0, 0, "Enable shadow calculation"); - uiDefButS(block, TOG|BIT|10,0,"Pano", 565,142,61,22, &G.scene->r.mode, 0, 0, 0, 0, "Enable panorama rendering (output width is multiplied by Xparts)"); - uiDefButS(block, TOG|BIT|8,0,"Radio", 626,142,61,22, &G.scene->r.mode, 0, 0, 0, 0, "Enable radiosity rendering"); - - uiDefButS(block, ROW,B_DIFF,"100%", 565,114,121,20,&G.scene->r.size,1.0,100.0, 0, 0, "Set render size to defined size"); - uiDefButS(block, ROW,B_DIFF,"75%", 565,90,36,20,&G.scene->r.size,1.0,75.0, 0, 0, "Set render size to 3/4 of defined size"); - uiDefButS(block, ROW,B_DIFF,"50%", 604,90,40,20,&G.scene->r.size,1.0,50.0, 0, 0, "Set render size to 1/2 of defined size"); - uiDefButS(block, ROW,B_DIFF,"25%", 647,90,39,20,&G.scene->r.size,1.0,25.0, 0, 0, "Set render size to 1/4 of defined size"); - - uiDefButS(block, TOG|BIT|0, 0, "OSA", 369,114,124,20,&G.scene->r.mode, 0, 0, 0, 0, "Enables Oversampling (Anti-aliasing)"); - uiDefButF(block, NUM,B_DIFF,"Bf:", 495,90,65,20,&G.scene->r.blurfac, 0.01, 5.0, 10, 0, "Sets motion blur factor"); - uiDefButS(block, TOG|BIT|14, 0, "MBLUR", 495,114,66,20,&G.scene->r.mode, 0, 0, 0, 0, "Enables Motion Blur calculation"); - - uiDefButS(block, ROW,B_DIFF,"5", 369,90,29,20,&G.scene->r.osa,2.0,5.0, 0, 0, "Sets oversample level to 5"); - uiDefButS(block, ROW,B_DIFF,"8", 400,90,29,20,&G.scene->r.osa,2.0,8.0, 0, 0, "Sets oversample level to 8 (Recommended)"); - uiDefButS(block, ROW,B_DIFF,"11", 431,90,33,20,&G.scene->r.osa,2.0,11.0, 0, 0, "Sets oversample level to 11"); - uiDefButS(block, ROW,B_DIFF,"16", 466,90,28,20,&G.scene->r.osa,2.0,16.0, 0, 0, "Sets oversample level to 16"); + uiDefButS(block, TOG|BIT|1, REDRAWBUTSVIEW, "BackGroundPic", 347,160,127,29 , + &vd->flag, 0, 0, 0, 0, "Display a picture in the 3D background"); + if(vd->bgpic) { + uiDefButF(block, NUM, B_DIFF, "Size:", + 478,160,82,29, &vd->bgpic->size, 0.1, + 250.0, 100, 0, "Set the size for the width of the BackGroundPic"); - uiDefButS(block, NUM,B_DIFF,"Xparts:", 369,42,99,31,&G.scene->r.xparts,1.0, 64.0, 0, 0, "Sets the number of horizontal parts to render image in (For panorama sets number of camera slices)"); - uiDefButS(block, NUM,B_DIFF,"Yparts:", 472,42,86,31,&G.scene->r.yparts,1.0, 64.0, 0, 0, "Sets the number of vertical parts to render image in"); - - uiDefButS(block, TOG|BIT|6,0,"Fields",564,42,90,31,&G.scene->r.mode, 0, 0, 0, 0, "Enables field rendering"); - - uiDefButS(block, TOG|BIT|13,0,"Odd", 655,57,30,16,&G.scene->r.mode, 0, 0, 0, 0, "Enables Odd field first rendering (Default: Even field)"); - uiDefButS(block, TOG|BIT|7,0,"x", 655,42,30,15,&G.scene->r.mode, 0, 0, 0, 0, "Disables time difference in field calculations"); - - uiDefButS(block, ROW,800,"Sky", 369,11,38,24,&G.scene->r.alphamode,3.0,0.0, 0, 0, "Fill background with sky"); - uiDefButS(block, ROW,800,"Premul", 410,11,54,24,&G.scene->r.alphamode,3.0,1.0, 0, 0, "Multiply alpha in advance"); - uiDefButS(block, ROW,800,"Key", 467,11,44,24,&G.scene->r.alphamode,3.0,2.0, 0, 0, "Alpha and colour values remain unchanged"); - - /* Toon shading buttons */ - uiDefButS(block, TOG|BIT|5, 0,"Edge", 295,70,70,19, - &G.scene->r.mode, 0, 0, 0, 0, "Enable Toon shading"); - uiDefBlockBut(block, edge_render_menu, NULL, "Edge Settings |>> ", 155, 70, 138, 19, "Display edge settings"); - - /* unified render buttons */ - if(G.scene->r.mode & R_UNIFIED) { - uiDefBlockBut(block, post_render_menu, NULL, "Post process |>> ", 15, 70, 138, 19, "Only for unified render"); - if (G.scene->r.mode & R_GAMMA) { - uiDefButF(block, NUMSLI, 0,"Gamma:", 15, 50, 280, 19, - &(G.scene->r.gamma), 0.2, 5.0, B_GAMMASLI, 0, - "The gamma value for blending oversampled images (1.0 = no correction)."); - } + id= (ID *)vd->bgpic->ima; + IDnames_to_pupstring(&strp, NULL, NULL, &(G.main->image), id, &(G.buts->menunr)); + if(strp[0]) + uiDefButS(block, MENU, B_BGPICBROWSE, strp, 347,112,20,19, &(G.buts->menunr), 0, 0, 0, 0, "Browse"); + MEM_freeN(strp); + + uiDefBut(block, BUT, B_LOADBGPIC, "LOAD", 370,112,189,19, 0, 0, 0, 0, 0, "Specify the BackGroundPic"); + uiDefButF(block, NUMSLI, B_BLENDBGPIC, "Blend:", 347,84,213,19,&vd->bgpic->blend, 0.0,1.0, 0, 0, "Set the BackGroundPic transparency"); + + if(vd->bgpic->ima) { + uiDefBut(block, TEX, 0,"BGpic: ", 347,136,211,19,&vd->bgpic->ima->name,0.0,100.0, 0, 0, "The Selected BackGroundPic"); + uiDefIconBut(block, BUT, B_BGPICCLEAR, ICON_X, 347+211,112,20,19, 0, 0, 0, 0, 0, "Remove background image link"); + } + + /* There is a bug here ... (what bug? where? what is this? - zr) */ + /* texture block: */ + id= (ID *)vd->bgpic->tex; + IDnames_to_pupstring(&strp, NULL, NULL, &(G.main->tex), id, &(G.buts->texnr)); + if (strp[0]) + uiDefButS(block, MENU, B_BGPICTEX, strp, 347, 20, 20,19, &(G.buts->texnr), 0, 0, 0, 0, "Browse"); + MEM_freeN(strp); + + uiDefBut(block, LABEL, 0, "Select texture for animated backgroundimage", 370, 20, 300,19, 0, 0, 0, 0, 0, ""); + + if (id) { + uiDefBut(block, TEX, B_IDNAME, "TE:", 347,0,211,19, id->name+2, 0.0, 18.0, 0, 0, ""); + uiDefIconBut(block, BUT, B_BGPICTEXCLEAR, ICON_X, 347+211,0,20,19, 0, 0, 0, 0, 0, "Remove background texture link"); + } } - - uiDefButS(block, TOG|BIT|9,REDRAWVIEWCAM, "Border", 565,11,58,24, &G.scene->r.mode, 0, 0, 0, 0, "Render a small cut-out of the image"); - uiDefButS(block, TOG|BIT|2,0, "Gamma", 626,11,58,24, &G.scene->r.mode, 0, 0, 0, 0, "Enable gamma correction"); - - uiBlockSetCol(block, BUTSALMON); - uiDefBut(block, BUT,B_DOANIM,"ANIM", 692,142,192,47, 0, 0, 0, 0, 0, "Start rendering a sequence"); + uiDefButF(block, NUM, B_DIFF, "Grid:", 347, 60, 105, 19, &vd->grid, 0.001, 1000.0, 100, 0, "Set the distance between gridlines"); + uiDefButS(block, NUM, B_DIFF, "GridLines:", 452, 60, 105, 19, &vd->gridlines, 0.0, 100.0, 100, 0, "Set the number of gridlines"); + uiDefButF(block, NUM, B_DIFF, "Lens:", 557, 60, 105, 19, &vd->lens, 10.0, 120.0, 100, 0, "Set the lens for the perspective view"); - uiBlockSetCol(block, BUTBLUE); + uiDefButF(block, NUM, B_DIFF, "ClipStart:", 347, 40, 105, 19, &vd->near, 0.1*vd->grid, 100.0, 100, 0, "Set startvalue in perspective view mode"); + uiDefButF(block, NUM, B_DIFF, "ClipEnd:", 452, 40, 105, 19, &vd->far, 1.0, 1000.0*vd->grid, 100, 0, "Set endvalue in perspective view mode"); - uiDefButS(block, TOG|BIT|0, 0, "Do Sequence", 692,114,192,20, &G.scene->r.scemode, 0, 0, 0, 0, "Enables sequence output rendering (Default: 3D rendering)"); - uiDefButS(block, TOG|BIT|1, 0, "Render Daemon", 692,90,192,20, &G.scene->r.scemode, 0, 0, 0, 0, "Let external network render current scene"); + /* for(b=0; b<8; b++) { */ + /* for(a=0; a<8; a++) { */ + /* uiDefButC(block, TOG|BIT|(7-a), 0, "", 100+12*a, 100-12*b, 12, 12, &(arr[b]),0,0,0,0); ,""*/ + /* } */ + /* } */ + /* DefBut(BUT, 1001, "print", 50,100,50,20, 0, 0, 0, 0,0); */ - uiBlockSetCol(block, BUTGREY); - uiDefBut(block, BUT,B_PLAYANIM, "PLAY", 692,40,94,33, 0, 0, 0, 0, 0, "Play animation of rendered images/avi (searches Pics: field)"); - - uiDefButS(block, NUM, B_RTCHANGED, "rt:", 790,40,95,33, &G.rt, 0.0, 256.0, 0, 0, "General testing/debug button"); + uiDrawBlock(block); +} - uiDefButS(block, ROW,B_DIFF,"BW", 892, 10,74,20, &G.scene->r.planes, 5.0,(float)R_PLANESBW, 0, 0, "Images are saved with BW (grayscale) data"); - uiDefButS(block, ROW,B_DIFF,"RGB", 968, 10,74,20, &G.scene->r.planes, 5.0,(float)R_PLANES24, 0, 0, "Images are saved with RGB (color) data"); - uiDefButS(block, ROW,B_DIFF,"RGBA", 1044, 10,75,20, &G.scene->r.planes, 5.0,(float)R_PLANES32, 0, 0, "Images are saved with RGB and Alpha data (if supported)"); +void output_pic(char *name) +{ + strcpy(G.scene->r.pic, name); + allqueue(REDRAWBUTSRENDER, 0); +} - yofs = 54; +void backbuf_pic(char *name) +{ + Image *ima; + + strcpy(G.scene->r.backbuf, name); + allqueue(REDRAWBUTSRENDER, 0); -#ifdef __sgi - yofs = 76; - uiDefButS(block, NUM,B_DIFF,"MaxSize:", 892,32,165,20, &G.scene->r.maximsize, 0.0, 500.0, 0, 0, "Maximum size per frame to save in an SGI movie"); - uiBlockSetCol(block, BUTGREEN); - uiDefButS(block, TOG|BIT|12,0,"Cosmo", 1059,32,60,20, &G.scene->r.mode, 0, 0, 0, 0, "Attempt to save SGI movies using Cosmo hardware"); - uiBlockSetCol(block, BUTGREY); -#endif + ima= add_image(name); + if(ima) { + free_image_buffers(ima); /* force read again */ + ima->ok= 1; + } +} - uiDefButS(block, MENU,B_FILETYPEMENU,imagetype_pup(), 892,yofs,174,20, &G.scene->r.imtype, 0, 0, 0, 0, "Images are saved in this file format"); - uiBlockSetCol(block, BUTGREEN); - uiDefButS(block, TOG|BIT|11,0, "Crop", 1068,yofs,51,20, &G.scene->r.mode, 0, 0, 0, 0, "Exclude border rendering from total image"); - uiBlockSetCol(block, BUTGREY); +void ftype_pic(char *name) +{ + strcpy(G.scene->r.ftype, name); + allqueue(REDRAWBUTSRENDER, 0); +} - yofs -= 22; - if(G.scene->r.quality==0) G.scene->r.quality= 90; +/* **************************** VIEW ************************ */ -#ifdef WITH_QUICKTIME - if (G.scene->r.imtype == R_AVICODEC || G.scene->r.imtype == R_QUICKTIME) { -#else /* WITH_QUICKTIME */ - if (0) { -#endif - if(G.scene->r.imtype == R_QUICKTIME) { -#ifdef WITH_QUICKTIME -#if defined (_WIN32) || defined (__APPLE__) - glColor3f(0.65, 0.65, 0.7); - glRecti(892,yofs+46,892+225,yofs+45+20); - if(G.scene->r.qtcodecdata == NULL) - uiDefBut(block, LABEL, 0, "Codec: not set", 892,yofs+44,225,20, 0, 0, 0, 0, 0, ""); - else - uiDefBut(block, LABEL, 0, G.scene->r.qtcodecdata->qtcodecname, 892,yofs+44,225,20, 0, 0, 0, 0, 0, ""); - uiDefBut(block, BUT,B_SELECTCODEC, "Set codec", 892,yofs,112,20, 0, 0, 0, 0, 0, "Set codec settings for Quicktime"); -#else /* libquicktime */ - if (!G.scene->r.qtcodecdata) G.scene->r.qtcodecdata = MEM_callocN(sizeof(QtCodecData), "QtCodecData"); - uiDefButI(block, MENU, B_SELECTCODEC, qtcodecs_pup(), 892,yofs, 112, 20, &qtcodec_idx, 0, 0, 0, 0, "Codec"); - /* make sure the codec stored in G.scene->r.qtcodecdata matches the selected - * one, especially if it's not set.. */ - if (!G.scene->r.qtcodecdata->fourcc) { - G.scene->r.qtcodecdata->fourcc = qtcodecidx_to_fcc(qtcodec_idx-1); - qt_init_codecdata(G.scene->r.qtcodecdata); - } - - yofs -= 22; - uiDefBlockBut(block, qtcodec_menu, NULL, "Codec Settings |>> ", 892,yofs, 227, 20, "Edit Codec settings for QuickTime"); - yofs +=22; -#endif /* libquicktime */ -#endif /* WITH_QUICKTIME */ - } else { -#ifdef _WIN32 - glColor3f(0.65, 0.65, 0.7); - glRecti(892,yofs+46,892+225,yofs+45+20); - if(G.scene->r.avicodecdata == NULL) - uiDefBut(block, LABEL, 0, "Codec: not set.", 892,yofs+43,225,20, 0, 0, 0, 0, 0, ""); - else - uiDefBut(block, LABEL, 0, avicodec_str(), 892,yofs+43,225,20, 0, 0, 0, 0, 0, ""); -#endif - uiDefBut(block, BUT,B_SELECTCODEC, "Set codec", 892,yofs,112,20, 0, 0, 0, 0, 0, "Set codec settings for AVI"); - } - } else { - uiDefButS(block, NUM,0, "Quality:", 892,yofs,112,20, &G.scene->r.quality, 10.0, 100.0, 0, 0, "Quality setting for JPEG images, AVI Jpeg and SGI movies"); +static void scene_change_set(Scene *sc, Scene *set) { + if (sc->set!=set) { + sc->set= set; + + allqueue(REDRAWBUTSRENDER, 0); + allqueue(REDRAWVIEW3D, 0); } - uiDefButS(block, NUM,REDRAWSEQ,"Frs/sec:", 1006,yofs,113,20, &G.scene->r.frs_sec, 1.0, 120.0, 100.0, 0, "Frames per second"); - - uiDefButS(block, NUM,REDRAWSEQ,"Sta:", 692,10,94,24, &G.scene->r.sfra,1.0,18000.0, 0, 0, "The start frame of the animation"); - uiDefButS(block, NUM,REDRAWSEQ,"End:", 790,10,95,24, &G.scene->r.efra,1.0,18000.0, 0, 0, "The end frame of the animation"); - - uiDefBlockBut(block, framing_render_menu, NULL, "Game framing settings |>> ", 892, 169, 227, 20, "Display game framing settings"); - - uiDefButS(block, NUM,REDRAWVIEWCAM,"SizeX:", 892 ,136,112,27, &G.scene->r.xsch, 4.0, 10000.0, 0, 0, "The image width in pixels"); - uiDefButS(block, NUM,REDRAWVIEWCAM,"SizeY:", 1007,136,112,27, &G.scene->r.ysch, 4.0,10000.0, 0, 0, "The image height in scanlines"); - uiDefButS(block, NUM,REDRAWVIEWCAM,"AspX:", 892 ,114,112,20, &G.scene->r.xasp, 1.0,200.0, 0, 0, "The horizontal aspect ratio"); - uiDefButS(block, NUM,REDRAWVIEWCAM,"AspY:", 1007,114,112,20, &G.scene->r.yasp, 1.0,200.0, 0, 0, "The vertical aspect ratio"); - - uiDefBut(block, BUT,B_PR_PAL, "PAL", 1146,170,133,18, 0, 0, 0, 0, 0, "Size preset: Image size - 720x576, Aspect ratio - 54x51, 25 fps"); - uiDefBut(block, BUT,B_PR_NTSC, "NTSC", 1146,150,133,18, 0, 0, 0, 0, 0, "Size preset: Image size - 720x480, Aspect ratio - 10x11, 30 fps"); - uiDefBut(block, BUT,B_PR_PRESET, "Default", 1146,130,133,18, 0, 0, 0, 0, 0, "Same as PAL, with render settings (OSA, Shadows, Fields)"); - uiDefBut(block, BUT,B_PR_PRV, "Preview", 1146,110,133,18, 0, 0, 0, 0, 0, "Size preset: Image size - 640x512, Render size 50%"); - uiDefBut(block, BUT,B_PR_PC, "PC", 1146,90,133,18, 0, 0, 0, 0, 0, "Size preset: Image size - 640x480, Aspect ratio - 100x100"); - uiDefBut(block, BUT,B_PR_PAL169, "PAL 16:9",1146,70,133,18, 0, 0, 0, 0, 0, "Size preset: Image size - 720x576, Aspect ratio - 64x45"); - uiDefBut(block, BUT,B_PR_PANO, "PANO", 1146,50,133,18, 0, 0, 0, 0, 0, "Standard panorama settings"); - uiDefBut(block, BUT,B_PR_FULL, "FULL", 1146,30,133,18, 0, 0, 0, 0, 0, "Size preset: Image size - 1280x1024, Aspect ratio - 1x1"); - uiDefButS(block, TOG|BIT|15, B_REDR, "Unified Renderer", 1146,10,133,18, - &G.scene->r.mode, 0, 0, 0, 0, - "Use the unified renderer."); - - uiDrawBlock(block); } + /* ********************* CONSTRAINT ***************************** */ static void activate_constraint_ipo_func (void *arg1v, void *unused) @@ -7293,221 +4088,3 @@ static void do_constraintbuts(unsigned short event) } } -/* ********************* GAME ***************************** */ - -/* in editsca.c */ - -/* ***************************<>******************************** */ - -void drawbutspace_old(ScrArea *sa, void *spacedata) -{ - SpaceButs *sbuts= curarea->spacedata.first; - View2D *v2d= &sbuts->v2d; - ID *id; - Object *ob; - float vec[2]; - - if(curarea->headertype==0) { - ID *id, *idfrom; - - buttons_active_id(&id, &idfrom); - G.buts->lockpoin= id; - } - - ob= OBACT; - -// myortho2(v2d->cur.xmin, v2d->cur.xmax, v2d->cur.ymin-0.6, v2d->cur.ymax+0.6); - myortho2(v2d->cur.xmin, v2d->cur.xmax, v2d->cur.ymin, v2d->cur.ymax); - - glShadeModel(GL_SMOOTH); - glBegin(GL_QUADS); - cpack(0x909090); - vec[0]= v2d->cur.xmin; - vec[1]= v2d->cur.ymax-15; - glVertex2fv(vec); - vec[0]= v2d->cur.xmax; - glVertex2fv(vec); - cpack(0x646464); - vec[1]= v2d->cur.ymax; - glVertex2fv(vec); - vec[0]= v2d->cur.xmin; - glVertex2fv(vec); - glEnd(); - glShadeModel(GL_FLAT); - - cpack(0x909090); - glRectf(v2d->cur.xmin, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax-15); - - uiSetButLock(G.scene->id.lib!=0, "Can't edit library data"); - uiFreeBlocksWin(&curarea->uiblocks, curarea->win); - - switch(G.buts->mainb) { - case BUTS_VIEW: - viewbuts(); - break; - case BUTS_LAMP: - lampbuts(); - break; - case BUTS_MAT: - if(ob==0) return; - if(ob->type>=OB_LAMP) return; - - matbuts(); - break; - case BUTS_TEX: - texbuts(); - break; - case BUTS_ANIM: - animbuts(); - break; - case BUTS_WORLD: - worldbuts(); - break; - case BUTS_RENDER: - renderbuts(); - break; - case BUTS_GAME: - gamebuts(); - break; - case BUTS_FPAINT: - fpaintbuts(); - break; - case BUTS_RADIO: - radiobuts(); - break; - case BUTS_SOUND: - soundbuts(); - break; - case BUTS_CONSTRAINT: - constraintbuts(); - break; - case BUTS_SCRIPT: - scriptbuts(); - break; - case BUTS_EDIT: - if(ob==0) return; - - common_editbuts(); - - id= ob->data; - if(id && id->lib) uiSetButLock(1, "Can't edit library data"); - - if(ob->type==OB_MESH) meshbuts(); - else if ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT) { - curvebuts(); - if(ob->type==OB_FONT) fontbuts(); - } - else if(ob->type==OB_CAMERA) camerabuts(); - else if(ob->type==OB_MBALL) mballbuts(); - else if(ob->type==OB_LATTICE) latticebuts(); - else if(ob->type==OB_IKA) ikabuts(); -#ifdef __NLA - else if(ob->type==OB_ARMATURE) armaturebuts(); -#endif - - break; - } - - uiClearButLock(); - - test_butspace(); - - curarea->win_swap= WIN_BACK_OK; -} - - -void clever_numbuts_buts() -{ - Material *ma; - Lamp *la; - World *wo; - static char hexrgb[8]; /* Uh... */ - static char hexspec[8]; /* Uh... */ - static char hexmir[8]; /* Uh... */ - static char hexho[8]; - static char hexze[8]; - int rgb[3]; - - switch (G.buts->mainb){ - case BUTS_FPAINT: - - sprintf(hexrgb, "%02X%02X%02X", (int)(Gvp.r*255), (int)(Gvp.g*255), (int)(Gvp.b*255)); - - add_numbut(0, TEX, "RGB:", 0, 6, hexrgb, "HTML Hex value for the RGB color"); - do_clever_numbuts("Vertex Paint RGB Hex Value", 1, REDRAW); - - /* Assign the new hex value */ - sscanf(hexrgb, "%02X%02X%02X", &rgb[0], &rgb[1], &rgb[2]); - Gvp.r= (rgb[0]/255.0 >= 0.0 && rgb[0]/255.0 <= 1.0 ? rgb[0]/255.0 : 0.0) ; - Gvp.g = (rgb[1]/255.0 >= 0.0 && rgb[1]/255.0 <= 1.0 ? rgb[1]/255.0 : 0.0) ; - Gvp.b = (rgb[2]/255.0 >= 0.0 && rgb[2]/255.0 <= 1.0 ? rgb[2]/255.0 : 0.0) ; - - break; - case BUTS_LAMP: - la= G.buts->lockpoin; - if (la){ - sprintf(hexrgb, "%02X%02X%02X", (int)(la->r*255), (int)(la->g*255), (int)(la->b*255)); - add_numbut(0, TEX, "RGB:", 0, 6, hexrgb, "HTML Hex value for the lamp color"); - do_clever_numbuts("Lamp RGB Hex Values", 1, REDRAW); - sscanf(hexrgb, "%02X%02X%02X", &rgb[0], &rgb[1], &rgb[2]); - la->r = (rgb[0]/255.0 >= 0.0 && rgb[0]/255.0 <= 1.0 ? rgb[0]/255.0 : 0.0) ; - la->g = (rgb[1]/255.0 >= 0.0 && rgb[1]/255.0 <= 1.0 ? rgb[1]/255.0 : 0.0) ; - la->b = (rgb[2]/255.0 >= 0.0 && rgb[2]/255.0 <= 1.0 ? rgb[2]/255.0 : 0.0) ; - BIF_preview_changed(G.buts); - } - break; - case BUTS_WORLD: - wo= G.buts->lockpoin; - if (wo){ - sprintf(hexho, "%02X%02X%02X", (int)(wo->horr*255), (int)(wo->horg*255), (int)(wo->horb*255)); - sprintf(hexze, "%02X%02X%02X", (int)(wo->zenr*255), (int)(wo->zeng*255), (int)(wo->zenb*255)); - add_numbut(0, TEX, "Zen:", 0, 6, hexze, "HTML Hex value for the Zenith color"); - add_numbut(1, TEX, "Hor:", 0, 6, hexho, "HTML Hex value for the Horizon color"); - do_clever_numbuts("World RGB Hex Values", 2, REDRAW); - - sscanf(hexho, "%02X%02X%02X", &rgb[0], &rgb[1], &rgb[2]); - wo->horr = (rgb[0]/255.0 >= 0.0 && rgb[0]/255.0 <= 1.0 ? rgb[0]/255.0 : 0.0) ; - wo->horg = (rgb[1]/255.0 >= 0.0 && rgb[1]/255.0 <= 1.0 ? rgb[1]/255.0 : 0.0) ; - wo->horb = (rgb[2]/255.0 >= 0.0 && rgb[2]/255.0 <= 1.0 ? rgb[2]/255.0 : 0.0) ; - sscanf(hexze, "%02X%02X%02X", &rgb[0], &rgb[1], &rgb[2]); - wo->zenr = (rgb[0]/255.0 >= 0.0 && rgb[0]/255.0 <= 1.0 ? rgb[0]/255.0 : 0.0) ; - wo->zeng = (rgb[1]/255.0 >= 0.0 && rgb[1]/255.0 <= 1.0 ? rgb[1]/255.0 : 0.0) ; - wo->zenb = (rgb[2]/255.0 >= 0.0 && rgb[2]/255.0 <= 1.0 ? rgb[2]/255.0 : 0.0) ; - BIF_preview_changed(G.buts); - - } - break; - case BUTS_MAT: - - ma= G.buts->lockpoin; - - /* Build a hex value */ - if (ma){ - sprintf(hexrgb, "%02X%02X%02X", (int)(ma->r*255), (int)(ma->g*255), (int)(ma->b*255)); - sprintf(hexspec, "%02X%02X%02X", (int)(ma->specr*255), (int)(ma->specg*255), (int)(ma->specb*255)); - sprintf(hexmir, "%02X%02X%02X", (int)(ma->mirr*255), (int)(ma->mirg*255), (int)(ma->mirb*255)); - - add_numbut(0, TEX, "Col:", 0, 6, hexrgb, "HTML Hex value for the RGB color"); - add_numbut(1, TEX, "Spec:", 0, 6, hexspec, "HTML Hex value for the Spec color"); - add_numbut(2, TEX, "Mir:", 0, 6, hexmir, "HTML Hex value for the Mir color"); - do_clever_numbuts("Material RGB Hex Values", 3, REDRAW); - - /* Assign the new hex value */ - sscanf(hexrgb, "%02X%02X%02X", &rgb[0], &rgb[1], &rgb[2]); - ma->r = (rgb[0]/255.0 >= 0.0 && rgb[0]/255.0 <= 1.0 ? rgb[0]/255.0 : 0.0) ; - ma->g = (rgb[1]/255.0 >= 0.0 && rgb[1]/255.0 <= 1.0 ? rgb[1]/255.0 : 0.0) ; - ma->b = (rgb[2]/255.0 >= 0.0 && rgb[2]/255.0 <= 1.0 ? rgb[2]/255.0 : 0.0) ; - sscanf(hexspec, "%02X%02X%02X", &rgb[0], &rgb[1], &rgb[2]); - ma->specr = (rgb[0]/255.0 >= 0.0 && rgb[0]/255.0 <= 1.0 ? rgb[0]/255.0 : 0.0) ; - ma->specg = (rgb[1]/255.0 >= 0.0 && rgb[1]/255.0 <= 1.0 ? rgb[1]/255.0 : 0.0) ; - ma->specb = (rgb[2]/255.0 >= 0.0 && rgb[2]/255.0 <= 1.0 ? rgb[2]/255.0 : 0.0) ; - sscanf(hexmir, "%02X%02X%02X", &rgb[0], &rgb[1], &rgb[2]); - ma->mirr = (rgb[0]/255.0 >= 0.0 && rgb[0]/255.0 <= 1.0 ? rgb[0]/255.0 : 0.0) ; - ma->mirg = (rgb[1]/255.0 >= 0.0 && rgb[1]/255.0 <= 1.0 ? rgb[1]/255.0 : 0.0) ; - ma->mirb = (rgb[2]/255.0 >= 0.0 && rgb[2]/255.0 <= 1.0 ? rgb[2]/255.0 : 0.0) ; - - BIF_preview_changed(G.buts); - } - break; - } -} diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c new file mode 100644 index 00000000000..f57a844d128 --- /dev/null +++ b/source/blender/src/buttons_editing.c @@ -0,0 +1,2057 @@ +/** + * $Id: + * + * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. The Blender + * Foundation also sells licenses for use in proprietary software under + * the Blender License. See http://www.blender.org/BL/ for information + * about this. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL/BL DUAL LICENSE BLOCK ***** + */ + +#include +#include +#include +#include + +#ifdef HAVE_CONFIG_H +#include +#endif + +#ifdef WIN32 +#include "BLI_winstuff.h" +#endif + +#include "MEM_guardedalloc.h" +#include "DNA_screen_types.h" +#include "DNA_space_types.h" +#include "DNA_scene_types.h" + +#include "DNA_action_types.h" +#include "DNA_armature_types.h" +#include "DNA_camera_types.h" +#include "DNA_constraint_types.h" +#include "DNA_curve_types.h" +#include "DNA_effect_types.h" +#include "DNA_group_types.h" +#include "DNA_ika_types.h" +#include "DNA_image_types.h" +#include "DNA_key_types.h" +#include "DNA_lamp_types.h" +#include "DNA_lattice_types.h" +#include "DNA_material_types.h" +#include "DNA_meta_types.h" +#include "DNA_mesh_types.h" +#include "DNA_object_types.h" +#include "DNA_radio_types.h" +#include "DNA_screen_types.h" +#include "DNA_sound_types.h" +#include "DNA_texture_types.h" +#include "DNA_userdef_types.h" +#include "DNA_vfont_types.h" +#include "DNA_view3d_types.h" +#include "DNA_world_types.h" +#include "DNA_packedFile_types.h" + +#include "BKE_global.h" +#include "BKE_main.h" +#include "BKE_library.h" +#include "BKE_packedFile.h" + +#include "BLI_blenlib.h" +#include "BLI_arithb.h" + +#include "BSE_filesel.h" + +#include "BIF_gl.h" +#include "BIF_editarmature.h" +#include "BIF_editconstraint.h" +#include "BIF_editdeform.h" +#include "BIF_editfont.h" +#include "BIF_editmesh.h" +#include "BIF_editsound.h" +#include "BIF_interface.h" +#include "BIF_mywindow.h" +#include "BIF_renderwin.h" +#include "BIF_resources.h" +#include "BIF_screen.h" +#include "BIF_scrarea.h" +#include "BIF_space.h" +#include "BIF_toets.h" +#include "BIF_toolbox.h" +#include "BIF_previewrender.h" +#include "BIF_butspace.h" + +#include "interface.h" +#include "mydevice.h" +#include "blendef.h" + +#include "BKE_anim.h" +#include "BKE_armature.h" +#include "BKE_constraint.h" +#include "BKE_curve.h" +#include "BKE_displist.h" +#include "BKE_effect.h" +#include "BKE_font.h" +#include "BKE_ika.h" +#include "BKE_image.h" +#include "BKE_ipo.h" +#include "BKE_lattice.h" +#include "BKE_material.h" +#include "BKE_mball.h" +#include "BKE_mesh.h" +#include "BKE_object.h" +#include "BKE_sound.h" +#include "BKE_texture.h" +#include "BKE_utildefines.h" + +#include "BDR_drawobject.h" +#include "BDR_editcurve.h" +#include "BDR_editface.h" +#include "BDR_editobject.h" +#include "BDR_vpaint.h" + +#include "BSE_drawview.h" +#include "BSE_editipo.h" +#include "BSE_edit.h" +#include "BSE_filesel.h" +#include "BSE_headerbuttons.h" +#include "BSE_trans_types.h" +#include "BSE_view.h" +#include "BSE_buttons.h" +#include "BSE_seqaudio.h" + +#include "LOD_DependKludge.h" +#include "LOD_decimation.h" + +#include "butspace.h" // own module + +int decim_faces=0; +short degr= 90, step= 9, turn= 1, editbutflag= 1; +float doublimit= 0.001; +float editbutvweight=1; +float extr_offs= 1.0, editbutweight=1.0, editbutsize=0.1, cumapsize= 1.0; + + + + +/* *************************** MESH DECIMATE ******************************** */ + +/* should be removed from this c file (ton) */ + +static int decimate_count_tria(Object *ob) +{ + int tottria; + MFace *mface; + Mesh *me; + int a; + + me= ob->data; + + /* count number of trias, since decimator doesnt allow quads */ + tottria= 0; + mface= me->mface; + for(a=0; atotface; a++, mface++) { + if(mface->v4) tottria++; + if(mface->v3) tottria++; + } + + return tottria; +} + +static void decimate_faces(void) +{ + Object *ob; + Mesh *me; + MVert *mvert; + MFace *mface; + LOD_Decimation_Info lod; + float *vb=NULL; + float *vnb=NULL; + int *tib=NULL; + int a, tottria; + + /* we assume the active object being decimated */ + ob= OBACT; + if(ob==NULL || ob->type!=OB_MESH) return; + me= ob->data; + + /* add warning for vertex col and tfaces */ + if(me->tface || me->mcol) { + if(okee("This will remove UV coordinates and vertexcolors")==0) return; + if(me->tface) MEM_freeN(me->tface); + if(me->mcol) MEM_freeN(me->mcol); + me->tface= NULL; + me->mcol= NULL; + } + + /* count number of trias, since decimator doesnt allow quads */ + tottria= decimate_count_tria(ob); + + if(tottria<3) { + error("You must have more than 3 input faces selected."); + return; + } + /* allocate and init */ + lod.vertex_buffer= MEM_mallocN(3*sizeof(float)*me->totvert, "vertices"); + lod.vertex_normal_buffer= MEM_mallocN(3*sizeof(float)*me->totvert, "normals"); + lod.triangle_index_buffer= MEM_mallocN(3*sizeof(int)*tottria, "trias"); + lod.vertex_num= me->totvert; + lod.face_num= tottria; + + /* fill vertex buffer */ + vb= lod.vertex_buffer; + vnb= lod.vertex_normal_buffer; + mvert= me->mvert; + for(a=0; atotvert; a++, mvert++, vb+=3, vnb+=3) { + VECCOPY(vb, mvert->co); + VECCOPY(vnb, mvert->no); + Normalise(vnb); + } + + /* fill index buffer */ + mface= me->mface; + tib= lod.triangle_index_buffer; + for(a=0; atotface; a++, mface++) { + if(mface->v4) { + tib[0]= mface->v1; + tib[1]= mface->v3; + tib[2]= mface->v4; + tib+= 3; + } + if(mface->v3) { + tib[0]= mface->v1; + tib[1]= mface->v2; + tib[2]= mface->v3; + tib+= 3; + } + } + + if(LOD_LoadMesh(&lod) ) { + if( LOD_PreprocessMesh(&lod) ) { + DispList *dl; + DispListMesh *dlm; + MFaceInt *mfaceint; + + /* we assume the decim_faces tells how much to reduce */ + + while(lod.face_num > decim_faces) { + if( LOD_CollapseEdge(&lod)==0) break; + } + + /* ok, put back the stuff in a displist */ + freedisplist(&(ob->disp)); + dl= MEM_callocN(sizeof(DispList), "disp"); + BLI_addtail(&ob->disp, dl); + dl->type= DL_MESH; + dlm=dl->mesh= MEM_callocN(sizeof(DispListMesh), "dispmesh"); + dlm->mvert= MEM_callocN(lod.vertex_num*sizeof(MVert), "mvert"); + dlm->mface= MEM_callocN(lod.face_num*sizeof(MFaceInt), "mface"); + dlm->totvert= lod.vertex_num; + dlm->totface= lod.face_num; + + mvert= dlm->mvert; + vb= lod.vertex_buffer; + for(a=0; aco, vb); + } + + mfaceint= dlm->mface; + tib= lod.triangle_index_buffer; + for(a=0; av1= tib[0]; + mfaceint->v2= tib[1]; + mfaceint->v3= tib[2]; + } + } + else error("No memory"); + + LOD_FreeDecimationData(&lod); + } + else error("No manifold Mesh"); + + MEM_freeN(lod.vertex_buffer); + MEM_freeN(lod.vertex_normal_buffer); + MEM_freeN(lod.triangle_index_buffer); + + allqueue(REDRAWVIEW3D, 0); +} + + + +static void decimate_cancel(void) +{ + Object *ob; + + ob= OBACT; + if(ob) { + freedisplist(&ob->disp); + makeDispList(ob); + } + allqueue(REDRAWVIEW3D, 0); +} + +static void decimate_apply(void) +{ + Object *ob; + DispList *dl; + DispListMesh *dlm; + Mesh *me; + MFace *mface; + MFaceInt *mfaceint; + int a; + + if(G.obedit) return; + + ob= OBACT; + if(ob) { + dl= ob->disp.first; + if(dl && dl->mesh) { + dlm= dl->mesh; + me= ob->data; + + // vertices + if(me->mvert) MEM_freeN(me->mvert); + me->mvert= dlm->mvert; + dlm->mvert= NULL; + me->totvert= dlm->totvert; + + // faces + if(me->mface) MEM_freeN(me->mface); + me->mface= MEM_callocN(dlm->totface*sizeof(MFace), "mface"); + me->totface= dlm->totface; + mface= me->mface; + mfaceint= dlm->mface; + for(a=0; atotface; a++, mface++, mfaceint++) { + mface->v1= mfaceint->v1; + mface->v2= mfaceint->v2; + mface->v3= mfaceint->v3; + test_index_mface(mface, 3); + } + + freedisplist(&ob->disp); + + G.obedit= ob; + make_editMesh(); + load_editMesh(); + free_editMesh(); + G.obedit= NULL; + tex_space_mesh(me); + } + else error("Not a decimated Mesh"); + } +} + +/* *************************** MESH ******************************** */ + + +static void editing_panel_mesh_type(Object *ob, Mesh *me) +{ + uiBlock *block; + float val; + + block= uiNewBlock(&curarea->uiblocks, "editing_panel_mesh_type", UI_EMBOSSX, UI_HELV, curarea->win); + if( uiNewPanel(curarea, block, "Mesh", "Editing", 320, 0, 318, 204)==0) return; + + uiBlockSetCol(block, BUTGREEN); + uiDefButS(block, TOG|BIT|5, REDRAWVIEW3D, "Auto Smooth",10,178,130,17, &me->flag, 0, 0, 0, 0, "Treats all faces with angles less than Degr: as 'smooth' during render"); + uiBlockSetCol(block, BUTGREY); + uiDefButS(block, NUM, B_DIFF, "Degr:", 10,156,130,17, &me->smoothresh, 1, 80, 0, 0, "Defines maximum angle between face normals that 'Auto Smooth' will operate on"); + uiBlockSetCol(block, BUTGREEN); + uiDefButS(block, TOG|BIT|7, B_MAKEDISP, "SubSurf", 10,124,130,17, &me->flag, 0, 0, 0, 0, "Treats the active object as a Catmull-Clark Subdivision Surface"); + uiBlockSetCol(block, BUTGREY); + uiDefButS(block, NUM, B_MAKEDISP, "Subdiv:", 10,104,100,18, &me->subdiv, 0, 12, 0, 0, "Defines the level of subdivision to display in real time interactively"); + uiDefButS(block, NUM, B_MAKEDISP, "", 110, 104, 30, 18, &me->subdivr, 0, 12, 0, 0, "Defines the level of subdivision to apply during rendering"); + + uiBlockSetCol(block, BUTSALMON); + + if(me->msticky) val= 1.0; else val= 0.0; + uiDefBut(block, LABEL, 0, "Sticky", 10,57,70,20, 0, val, 0, 0, 0, ""); + if(me->msticky==0) { + uiDefBut(block, BUT, B_MAKESTICKY, "Make", 60,59,63,19, 0, 0, 0, 0, 0, "Creates Sticky coordinates for the active object from the current camera view background picture"); + } + else uiDefBut(block, BUT, B_DELSTICKY, "Delete", 60,59,63,19, 0, 0, 0, 0, 0, "Deletes Sticky texture coordinates"); + + if(me->mcol) val= 1.0; else val= 0.0; + uiDefBut(block, LABEL, 0, "VertCol", 10,34,70,20, 0, val, 0, 0, 0, ""); + if(me->mcol==0) { + uiDefBut(block, BUT, B_MAKEVERTCOL, "Make", 60,36,64,19, 0, 0, 0, 0, 0, "Enables vertex colour painting on active object"); + } + else uiDefBut(block, BUT, B_DELVERTCOL, "Delete", 60,36,64,19, 0, 0, 0, 0, 0, "Deletes vertex colours on active object"); + + if(me->tface) val= 1.0; else val= 0.0; + uiDefBut(block, LABEL, 0, "TexFace", 10,14,70,20, 0, val, 0, 0, 0, ""); + if(me->tface==0) { + uiDefBut(block, BUT, B_MAKE_TFACES, "Make", 60,15,64,20, 0, 0, 0, 0, 0, "Enables the active object's faces for UV coordinate mapping"); + } + else uiDefBut(block, BUT, B_DEL_TFACES, "Delete", 60,15,64,20, 0, 0, 0, 0, 0, "Deletes UV coordinates for active object's faces"); + + + /* decimator */ + if(G.obedit==NULL) { + int tottria= decimate_count_tria(ob); + DispList *dl; + + // wacko, wait for new displist system (ton) + if( (dl=ob->disp.first) && dl->mesh); + else decim_faces= tottria; + + uiBlockSetCol(block, BUTPURPLE); + uiDefButI(block, NUMSLI,B_DECIM_FACES, "Decimator: ", 173,176,233,19, &decim_faces, 4.0, tottria, 10, 10, "Defines the number of triangular faces to decimate the active Mesh object to"); + uiBlockSetCol(block, BUTSALMON); + uiDefBut(block, BUT,B_DECIM_CANCEL, "Cancel", 290,156,116,18, 0, 0, 0, 0, 0, "Restores the Mesh to its original number of faces"); + uiDefBut(block, BUT,B_DECIM_APPLY, "Apply", 173,156,115,18, 0, 0, 0, 0, 0, "Applies the decimation to the active Mesh object"); + } + + + uiBlockSetCol(block, BUTGREY); + uiDefIDPoinBut(block, test_meshpoin_but, 0, "TexMesh: ", 174,120,234,19, &me->texcomesh, "Enter the name of a Meshblock"); + + if(me->key) { + uiDefButS(block, NUM, B_DIFF, "Slurph:", 174,75,100,19, &(me->key->slurph), -500.0, 500.0, 0, 0, ""); + uiDefButS(block, TOG, B_RELKEY, "Relative Keys", 174,55,100,19, &me->key->type, 0, 0, 0, 0, ""); + } + + uiBlockSetCol(block, BUTSALMON); + uiDefBut(block, BUT, B_SLOWERDRAW,"SlowerDraw", 174,35,100,19, 0, 0, 0, 0, 0, "Displays the active object with all possible edges shown"); + uiDefBut(block, BUT, B_FASTERDRAW,"FasterDraw", 175,15,100,19, 0, 0, 0, 0, 0, "Displays the active object faster by omitting some edges when drawing"); + + + uiBlockSetCol(block, BUTSALMON); + uiDefBut(block, BUT,B_DOCENTRE, "Centre", 275, 95, 133, 19, 0, 0, 0, 0, 0, "Shifts object data to be centered about object's origin"); + uiDefBut(block, BUT,B_DOCENTRENEW, "Centre New", 275, 75, 133, 19, 0, 0, 0, 0, 0, "Shifts object's origin to center of object data"); + uiDefBut(block, BUT,B_DOCENTRECURSOR, "Centre Cursor", 275, 55, 133, 19, 0, 0, 0, 0, 0, "Shifts object's origin to cursor location"); + + uiBlockSetCol(block, BUTGREEN); + uiDefButS(block, TOG|BIT|2, REDRAWVIEW3D, "Double Sided", 275,35,133,19, &me->flag, 0, 0, 0, 0, "Toggles selected faces as doublesided or single-sided"); + uiDefButS(block, TOG|BIT|1, REDRAWVIEW3D, "No V.Normal Flip",275,15,133,19, &me->flag, 0, 0, 0, 0, "Disables flipping of vertexnormals during render"); + +} + + + +/* *************************** FONT ******************************** */ + +static short give_vfontnr(VFont *vfont) +{ + VFont *vf; + short nr= 1; + + vf= G.main->vfont.first; + while(vf) { + if(vf==vfont) return nr; + nr++; + vf= vf->id.next; + } + return -1; +} + +static VFont *give_vfontpointer(int nr) /* nr= button */ +{ + VFont *vf; + short tel= 1; + + vf= G.main->vfont.first; + while(vf) { + if(tel==nr) return vf; + tel++; + vf= vf->id.next; + } + return G.main->vfont.first; +} + +static VFont *exist_vfont(char *str) +{ + VFont *vf; + + vf= G.main->vfont.first; + while(vf) { + if(strcmp(vf->name, str)==0) return vf; + vf= vf->id.next; + } + return 0; +} + +static char *give_vfontbutstr(void) +{ + VFont *vf; + int len= 0; + char *str, di[FILE_MAXDIR], fi[FILE_MAXFILE]; + + vf= G.main->vfont.first; + while(vf) { + strcpy(di, vf->name); + BLI_splitdirstring(di, fi); + len+= strlen(fi)+4; + vf= vf->id.next; + } + + str= MEM_callocN(len+21, "vfontbutstr"); + strcpy(str, "FONTS %t"); + vf= G.main->vfont.first; + while(vf) { + + if(vf->id.us==0) strcat(str, "|0 "); + else strcat(str, "| "); + + strcpy(di, vf->name); + BLI_splitdirstring(di, fi); + + strcat(str, fi); + vf= vf->id.next; + } + return str; +} + +static void load_buts_vfont(char *name) +{ + VFont *vf; + Curve *cu; + + if(OBACT && OBACT->type==OB_FONT) cu= OBACT->data; + else return; + + vf= exist_vfont(name); + if(vf==0) { + vf= load_vfont(name); + if(vf==0) return; + } + else id_us_plus((ID *)vf); + + if(cu->vfont) cu->vfont->id.us--; + cu->vfont= vf; + + text_to_curve(OBACT, 0); + makeDispList(OBACT); + allqueue(REDRAWVIEW3D, 0); + allqueue(REDRAWBUTSEDIT, 0); +} + +void do_fontbuts(unsigned short event) +{ + Curve *cu; + VFont *vf; + Object *ob; + ScrArea *sa; + char str[80]; + + ob= OBACT; + + switch(event) { + case B_MAKEFONT: + text_to_curve(ob, 0); + makeDispList(ob); + allqueue(REDRAWVIEW3D, 0); + break; + case B_TOUPPER: + to_upper(); + break; + case B_LOADFONT: + vf= give_vfontpointer(G.buts->texnr); + if(vf && vf->id.prev!=vf->id.next) strcpy(str, vf->name); + else strcpy(str, U.fontdir); + + sa= closest_bigger_area(); + areawinset(sa->win); + + activate_fileselect(FILE_SPECIAL, "SELECT FONT", str, load_buts_vfont); + + break; + case B_PACKFONT: + if (ob) { + cu= ob->data; + if(cu && cu->vfont) { + if (cu->vfont->packedfile) { + if (G.fileflags & G_AUTOPACK) { + if (okee("Disable AutoPack ?")) { + G.fileflags &= ~G_AUTOPACK; + } + } + + if ((G.fileflags & G_AUTOPACK) == 0) { + if (unpackVFont(cu->vfont, PF_ASK) == RET_OK) { + text_to_curve(ob, 0); + makeDispList(ob); + allqueue(REDRAWVIEW3D, 0); + } + } + } else { + cu->vfont->packedfile = newPackedFile(cu->vfont->name); + } + } + } + allqueue(REDRAWHEADERS, 0); + allqueue(REDRAWBUTSEDIT, 0); + break; + + case B_SETFONT: + if(ob) { + cu= ob->data; + + vf= give_vfontpointer(G.buts->texnr); + if(vf) { + id_us_plus((ID *)vf); + cu->vfont->id.us--; + cu->vfont= vf; + text_to_curve(ob, 0); + makeDispList(ob); + allqueue(REDRAWVIEW3D, 0); + allqueue(REDRAWBUTSEDIT, 0); + } + } + break; + case B_TEXTONCURVE: + if(ob) { + cu= ob->data; + if(cu->textoncurve && cu->textoncurve->type!=OB_CURVE) { + error("Only Curve Objects"); + cu->textoncurve= 0; + allqueue(REDRAWBUTSEDIT, 0); + } + text_to_curve(ob, 0); + makeDispList(ob); + } + } +} + + + +static void editing_panel_font_type(Object *ob, Curve *cu) +{ + uiBlock *block; + char *strp; + static int packdummy = 0; + + block= uiNewBlock(&curarea->uiblocks, "editing_panel_font_type", UI_EMBOSSX, UI_HELV, curarea->win); + if(uiNewPanel(curarea, block, "Font", "Editing", 640, 0, 318, 204)==0) return; + + uiBlockSetCol(block, BUTGREEN); + uiDefButS(block, ROW,B_MAKEFONT, "Left", 484,139,53,18, &cu->spacemode, 0.0,0.0, 0, 0, ""); + uiDefButS(block, ROW,B_MAKEFONT, "Middle", 604,139,61,18, &cu->spacemode, 0.0,1.0, 0, 0, ""); + uiDefButS(block, ROW,B_MAKEFONT, "Right", 540,139,62,18, &cu->spacemode, 0.0,2.0, 0, 0, ""); + uiDefButS(block, ROW,B_MAKEFONT, "Flush", 665,139,61,18, &cu->spacemode, 0.0,3.0, 0, 0, ""); + + uiBlockSetCol(block, BUTGREY); + + uiDefIDPoinBut(block, test_obpoin_but, B_TEXTONCURVE, "TextOnCurve:", 484,115,243,19, &cu->textoncurve, ""); + uiDefBut(block, TEX,REDRAWVIEW3D, "Ob Family:", 484,85,243,19, cu->family, 0.0, 20.0, 0, 0, ""); + + uiDefButF(block, NUM,B_MAKEFONT, "Size:", 482,56,121,19, &cu->fsize, 0.1,10.0, 10, 0, ""); + uiDefButF(block, NUM,B_MAKEFONT, "Linedist:", 605,56,121,19, &cu->linedist, 0.0,10.0, 10, 0, ""); + uiDefButF(block, NUM,B_MAKEFONT, "Spacing:", 482,34,121,19, &cu->spacing, 0.0,10.0, 10, 0, ""); + uiDefButF(block, NUM,B_MAKEFONT, "Y offset:", 605,34,121,19, &cu->yof, -50.0,50.0, 10, 0, ""); + uiDefButF(block, NUM,B_MAKEFONT, "Shear:", 482,12,121,19, &cu->shear, -1.0,1.0, 10, 0, ""); + uiDefButF(block, NUM,B_MAKEFONT, "X offset:", 605,12,121,19, &cu->xof, -50.0,50.0, 10, 0, ""); + + uiBlockSetCol(block, BUTSALMON); + uiDefBut(block, BUT, B_TOUPPER, "ToUpper", 623,163,103,23, 0, 0, 0, 0, 0, ""); + + uiBlockSetCol(block, BUTGREY); + + G.buts->texnr= give_vfontnr(cu->vfont); + + strp= give_vfontbutstr(); + + uiDefButS(block, MENU, B_SETFONT, strp, 484,191,220,20, &G.buts->texnr, 0, 0, 0, 0, ""); + + if (cu->vfont->packedfile) { + packdummy = 1; + } else { + packdummy = 0; + } + + uiBlockSetCol(block, BUTYELLOW); + uiDefIconButI(block, TOG|BIT|0, B_PACKFONT, ICON_PACKAGE, 706,191,20,20, &packdummy, 0, 0, 0, 0, "Pack/Unpack this Vectorfont"); + + MEM_freeN(strp); + + uiBlockSetCol(block, BUTSALMON); + uiDefBut(block, BUT,B_LOADFONT, "Load Font", 484,163,103,23, 0, 0, 0, 0, 0, ""); + +} + +/* *************************** CURVE ******************************** */ + + +void do_curvebuts(unsigned short event) +{ + extern Nurb *lastnu; + extern ListBase editNurb; /* from editcurve */ + Object *ob; + Curve *cu; + Nurb *nu; + + ob= OBACT; + if(ob==0) return; + + switch(event) { + + case B_CONVERTPOLY: + case B_CONVERTBEZ: + case B_CONVERTBSPL: + case B_CONVERTCARD: + case B_CONVERTNURB: + if(G.obedit) { + setsplinetype(event-B_CONVERTPOLY); + makeDispList(G.obedit); + allqueue(REDRAWVIEW3D, 0); + } + break; + case B_UNIFU: + case B_ENDPU: + case B_BEZU: + case B_UNIFV: + case B_ENDPV: + case B_BEZV: + if(G.obedit) { + nu= editNurb.first; + while(nu) { + if(isNurbsel(nu)) { + if((nu->type & 7)==CU_NURBS) { + if(eventflagu &= 1; + nu->flagu += ((event-B_UNIFU)<<1); + makeknots(nu, 1, nu->flagu>>1); + } + else if(nu->pntsv>1) { + nu->flagv &= 1; + nu->flagv += ((event-B_UNIFV)<<1); + makeknots(nu, 2, nu->flagv>>1); + } + } + } + nu= nu->next; + } + makeDispList(G.obedit); + allqueue(REDRAWVIEW3D, 0); + } + break; + case B_SETWEIGHT: + if(G.obedit) { + weightflagNurb(1, editbutweight, 0); + makeDispList(G.obedit); + allqueue(REDRAWVIEW3D, 0); + } + break; + case B_SETW1: + editbutweight= 1.0; + scrarea_queue_winredraw(curarea); + break; + case B_SETW2: + editbutweight= sqrt(2.0)/4.0; + scrarea_queue_winredraw(curarea); + break; + case B_SETW3: + editbutweight= 0.25; + scrarea_queue_winredraw(curarea); + break; + case B_SETW4: + editbutweight= sqrt(0.5); + scrarea_queue_winredraw(curarea); + break; + case B_SETORDER: + if(G.obedit) { + nu= lastnu; + if(nu && (nu->type & 7)==CU_NURBS ) { + if(nu->orderu>nu->pntsu) { + nu->orderu= nu->pntsu; + scrarea_queue_winredraw(curarea); + } + makeknots(nu, 1, nu->flagu>>1); + if(nu->orderv>nu->pntsv) { + nu->orderv= nu->pntsv; + scrarea_queue_winredraw(curarea); + } + makeknots(nu, 2, nu->flagv>>1); + } + makeDispList(G.obedit); + allqueue(REDRAWVIEW3D, 0); + } + break; + case B_MAKEDISP: + if(ob->type==OB_FONT) text_to_curve(ob, 0); + makeDispList(ob); + allqueue(REDRAWVIEW3D, 0); + allqueue(REDRAWINFO, 1); /* 1, because header->win==0! */ + break; + + case B_SUBDIVCURVE: + subdivideNurb(); + break; + case B_SPINNURB: + /* bad bad bad!!! use brackets!!! In case you wondered: + {==,!=} goes before & goes before || */ + if( (G.obedit==0) || + (G.obedit->type!=OB_SURF) || + ((G.obedit->lay & G.vd->lay) == 0) ) return; + spinNurb(0, 0); + countall(); + makeDispList(G.obedit); + allqueue(REDRAWVIEW3D, 0); + break; + case B_CU3D: /* allow 3D curve */ + if(G.obedit) { + cu= G.obedit->data; + nu= editNurb.first; + while(nu) { + nu->type &= ~CU_2D; + if((cu->flag & CU_3D)==0) nu->type |= CU_2D; + test2DNurb(nu); + nu= nu->next; + } + } + if(ob->type==OB_CURVE) { + cu= ob->data; + nu= cu->nurb.first; + while(nu) { + nu->type &= ~CU_2D; + if((cu->flag & CU_3D)==0) nu->type |= CU_2D; + test2DNurb(nu); + nu= nu->next; + } + } + break; + case B_SETRESOLU: + if(ob->type==OB_CURVE) { + cu= ob->data; + if(ob==G.obedit) nu= editNurb.first; + else nu= cu->nurb.first; + + while(nu) { + nu->resolu= cu->resolu; + nu= nu->next; + } + } + else if(ob->type==OB_FONT) text_to_curve(ob, 0); + + makeDispList(ob); + allqueue(REDRAWVIEW3D, 0); + + break; + } +} + +static void editing_panel_curve_tools(Object *ob, Curve *cu) +{ + Nurb *nu; + extern ListBase editNurb; /* from editcurve */ + extern Nurb *lastnu; + uiBlock *block; + short *sp; + + block= uiNewBlock(&curarea->uiblocks, "editing_panel_curve_tools", UI_EMBOSSX, UI_HELV, curarea->win); + if(uiNewPanel(curarea, block, "Curve Tools", "Editing", 640, 0, 318, 204)==0) return; + + uiBlockSetCol(block, BUTSALMON); + if(ob->type==OB_CURVE) { + uiDefBut(block, LABEL, 0, "Convert", 463,173,72, 18, 0, 0, 0, 0, 0, ""); + uiDefBut(block, BUT,B_CONVERTPOLY,"Poly", 467,152,72, 18, 0, 0, 0, 0, 0, ""); + uiDefBut(block, BUT,B_CONVERTBEZ,"Bezier", 467,132,72, 18, 0, 0, 0, 0, 0, ""); + uiDefBut(block, BUT,B_CONVERTBSPL,"Bspline", 467,112,72, 18, 0, 0, 0, 0, 0, ""); + uiDefBut(block, BUT,B_CONVERTCARD,"Cardinal", 467,92,72, 18, 0, 0, 0, 0, 0, ""); + uiDefBut(block, BUT,B_CONVERTNURB,"Nurb", 467,72,72, 18, 0, 0, 0, 0, 0, ""); + } + uiDefBut(block, LABEL, 0, "Make Knots",562,173,102, 18, 0, 0, 0, 0, 0, ""); + uiDefBut(block, BUT,B_UNIFU,"Uniform U", 565,152,102, 18, 0, 0, 0, 0, 0, ""); + uiDefBut(block, BUT,B_ENDPU,"Endpoint U", 565,132,102, 18, 0, 0, 0, 0, 0, ""); + uiDefBut(block, BUT,B_BEZU,"Bezier U", 565,112,102, 18, 0, 0, 0, 0, 0, ""); + uiDefBut(block, BUT,B_UNIFV,"V", 670,152,50, 18, 0, 0, 0, 0, 0, ""); + uiDefBut(block, BUT,B_ENDPV,"V", 670,132,50, 18, 0, 0, 0, 0, 0, ""); + uiDefBut(block, BUT,B_BEZV,"V", 670,112,50, 18, 0, 0, 0, 0, 0, ""); + + uiDefBut(block, BUT,B_SETWEIGHT,"Set Weight", 465,11,95,49, 0, 0, 0, 0, 0, ""); + uiBlockSetCol(block, BUTGREY); + uiDefButF(block, NUM,0,"Weight:", 564,36,102,22, &editbutweight, 0.01, 10.0, 10, 0, ""); + uiDefBut(block, BUT,B_SETW1,"1.0", 669,36,50,22, 0, 0, 0, 0, 0, ""); + uiDefBut(block, BUT,B_SETW2,"sqrt(2)/4",564,11,57,20, 0, 0, 0, 0, 0, ""); + uiDefBut(block, BUT,B_SETW3,"0.25", 621,11,43,20, 0, 0, 0, 0, 0, ""); + uiDefBut(block, BUT,B_SETW4,"sqrt(0.5)",664,11,57,20, 0, 0, 0, 0, 0, ""); + + if(ob==G.obedit) { + nu= lastnu; + if(nu==NULL) nu= editNurb.first; + if(nu) { + sp= &(nu->orderu); + uiDefButS(block, NUM, B_SETORDER, "Order U:", 565,91,102, 18, sp, 2.0, 6.0, 0, 0, ""); + sp= &(nu->orderv); + uiDefButS(block, NUM, B_SETORDER, "V:", 670,91,50, 18, sp, 2.0, 6.0, 0, 0, ""); + sp= &(nu->resolu); + uiDefButS(block, NUM, B_MAKEDISP, "Resol U:", 565,70,102, 18, sp, 1.0, 128.0, 0, 0, ""); + sp= &(nu->resolv); + uiDefButS(block, NUM, B_MAKEDISP, "V:", 670,70,50, 18, sp, 1.0, 128.0, 0, 0, ""); + } + } + + +} + +static void editing_panel_curve_tools1(Object *ob, Curve *cu) +{ + uiBlock *block; + + block= uiNewBlock(&curarea->uiblocks, "editing_panel_curve_tools1", UI_EMBOSSX, UI_HELV, curarea->win); + if(uiNewPanel(curarea, block, "Curve Tools1", "Editing", 960, 0, 318, 204)==0) return; + + uiBlockSetCol(block, BUTSALMON); + + uiDefBut(block, BUT, B_SUBDIVCURVE, "Subdivide", 400,180,150,20, 0, 0, 0, 0, 0, ""); + if(ob->type==OB_SURF) { + uiDefBut(block, BUT, B_SPINNURB, "Spin", 400,160,150,20, 0, 0, 0, 0, 0, ""); + } + + uiBlockSetCol(block, BUTGREY); + uiDefBut(block, BUT,B_HIDE, "Hide", 400,120,150,18, 0, 0, 0, 0, 0, "Hides selected faces"); + uiDefBut(block, BUT,B_REVEAL, "Reveal", 400,100,150,18, 0, 0, 0, 0, 0, "Reveals selected faces"); + uiDefBut(block, BUT,B_SELSWAP, "Select Swap", 400,80,150,18, 0, 0, 0, 0, 0, "Selects unselected faces, and deselects selected faces"); + + uiDefButF(block, NUM, REDRAWVIEW3D, "NSize:", 400, 40, 150, 19, &editbutsize, 0.001, 1.0, 10, 0, ""); +} + +/* for curve, surf and font! */ +static void editing_panel_curve_type(Object *ob, Curve *cu) +{ + uiBlock *block; + + block= uiNewBlock(&curarea->uiblocks, "editing_panel_curve_type", UI_EMBOSSX, UI_HELV, curarea->win); + if(uiNewPanel(curarea, block, "Curve and Surface", "Editing", 320, 0, 318, 204)==0) return; + + uiDefButS(block, TOG|BIT|5, 0, "UV Orco", 543,160,130,18, &cu->flag, 0, 0, 0, 0, ""); + if(ob->type==OB_SURF) + uiDefButS(block, TOG|BIT|6, REDRAWVIEW3D, "No Puno Flip", 543,140,130,18, &cu->flag, 0, 0, 0, 0, ""); + + uiBlockSetCol(block, BUTSALMON); + uiDefBut(block, BUT,B_DOCENTRE, "Centre", 543, 115, 140, 19, 0, 0, 0, 0, 0, "Shifts object data to be centered about object's origin"); + uiDefBut(block, BUT,B_DOCENTRENEW, "Centre New", 543, 95, 140, 19, 0, 0, 0, 0, 0, "Shifts object's origin to center of object data"); + uiDefBut(block, BUT,B_DOCENTRECURSOR, "Centre Cursor", 543, 75, 140, 19, 0, 0, 0, 0, 0, "Shifts object's origin to cursor location"); + + if(ob->type==OB_SURF) { + if(cu->key) { + uiBlockSetCol(block, BUTGREEN); + /* uiDefButS(block, NUM, B_DIFF, "Slurph:", 543,25,140,19, &(cu->key->slurph), -500.0, 500.0,0,0); ,""*/ + uiDefButS(block, TOG, B_RELKEY, "Relative Keys", 543,45,140,19, &cu->key->type, 0, 0, 0, 0, ""); + } + } + + if(ob->type!=OB_SURF) { + + if(ob->type==OB_CURVE) { + static float prlen; + char str[32]; + uiBlockSetCol(block, BUTGREY); + uiDefButS(block, NUM, B_RECALCPATH, "PathLen:", 543,50,140,19, &cu->pathlen, 1.0, 9000.0, 0, 0, ""); + uiBlockSetCol(block, BUTGREEN); + uiDefButS(block, TOG|BIT|3, B_RECALCPATH, "CurvePath", 543,30,70,19 , &cu->flag, 0, 0, 0, 0, ""); + uiDefButS(block, TOG|BIT|4, REDRAWVIEW3D, "CurveFollow",613,30,70,19, &cu->flag, 0, 0, 0, 0, ""); + uiBlockSetCol(block, BUTGREY); + sprintf(str, "%.4f", prlen); + uiDefBut(block, BUT, B_PRINTLEN, "PrintLen", 543,10,70,19, 0, 0, 0, 0, 0, ""); + uiDefBut(block, LABEL, 0, str, 613,10,70,19, 0, 1.0, 0, 0, 0, ""); + } + uiDefButS(block, NUM, B_MAKEDISP, "DefResolU:", 752,163,132,21, &cu->resolu, 1.0, 128.0, 0, 0, ""); + uiBlockSetCol(block, BUTSALMON); + uiDefBut(block, BUT, B_SETRESOLU, "Set", 887,163,29,21, 0, 0, 0, 0, 0, ""); + + uiBlockSetCol(block, BUTGREY); + uiDefButS(block, NUM, B_MAKEDISP, "BevResol:", 753,30,163,18, &cu->bevresol, 0.0, 10.0, 0, 0, ""); + + uiDefIDPoinBut(block, test_obcurpoin_but, B_MAKEDISP, "BevOb:", 753,10,163,18, &cu->bevobj, ""); + uiDefButF(block, NUM, B_MAKEDISP, "Width:", 753,90,163,18, &cu->width, 0.0, 2.0, 1, 0, ""); + uiDefButF(block, NUM, B_MAKEDISP, "Ext1:", 753,70,163,18, &cu->ext1, 0.0, 5.0, 10, 0, ""); + uiDefButF(block, NUM, B_MAKEDISP, "Ext2:", 753,50,163,18, &cu->ext2, 0.0, 2.0, 1, 0, ""); + uiBlockSetCol(block, BUTBLUE); + + uiDefButS(block, TOG|BIT|0, B_CU3D, "3D", 867,130,47,18, &cu->flag, 0, 0, 0, 0, ""); + uiDefButS(block, TOG|BIT|1, B_MAKEDISP, "Front", 810,130,55,18, &cu->flag, 0, 0, 0, 0, ""); + uiDefButS(block, TOG|BIT|2, B_MAKEDISP, "Back", 753,130,53,18, &cu->flag, 0, 0, 0, 0, ""); + + + } + +} + + +/* *************************** CAMERA ******************************** */ + + +static void editing_panel_camera_type(Object *ob, Camera *cam) +{ + uiBlock *block; + float grid=0.0; + + if(G.vd) grid= G.vd->grid; + if(grid<1.0) grid= 1.0; + + block= uiNewBlock(&curarea->uiblocks, "editing_panel_camera_type", UI_EMBOSSX, UI_HELV, curarea->win); + if(uiNewPanel(curarea, block, "Camera", "Editing", 320, 0, 318, 204)==0) return; + + + uiDefButF(block, NUM,REDRAWVIEW3D, "Lens:", 470,178,160,20, &cam->lens, 1.0, 250.0, 100, 0, "Specify the lens of the camera"); + uiDefButF(block, NUM,REDRAWVIEW3D, "ClipSta:", 470,147,160,20, &cam->clipsta, 0.001*grid, 100.0*grid, 10, 0, "Specify the startvalue of the the field of view"); + uiDefButF(block, NUM,REDRAWVIEW3D, "ClipEnd:", 470,125,160,20, &cam->clipend, 1.0, 5000.0*grid, 100, 0, "Specify the endvalue of the the field of view"); + uiDefButF(block, NUM,REDRAWVIEW3D, "DrawSize:", 470,90,160,20, &cam->drawsize, 0.1*grid, 10.0, 10, 0, "Specify the drawsize of the camera"); + + uiBlockSetCol(block, BUTGREEN); + uiDefButS(block, TOG, REDRAWVIEW3D, "Ortho", 470,49,61,40, &cam->type, 0, 0, 0, 0, "Render orthogonally"); + + uiDefButS(block, TOG|BIT|0,REDRAWVIEW3D, "ShowLimits", 533,69,97,20, &cam->flag, 0, 0, 0, 0, "Draw the field of view"); + uiDefButS(block, TOG|BIT|1,REDRAWVIEW3D, "Show Mist", 533,49,97,20, &cam->flag, 0, 0, 0, 0, "Draw a line that indicates the mist area"); + + if(G.special1 & G_HOLO) { + uiBlockSetCol(block, BUTGREY); + if(cam->netend==0.0) cam->netend= EFRA; + uiDefButF(block, NUM, REDRAWVIEW3D, "Anim len", 670,80,100,20, &cam->netend, 1.0, 2500.0, 0, 0, ""); + uiDefButF(block, NUM, REDRAWVIEW3D, "Path len:", 670,160,100,20, &cam->hololen, 0.1, 25.0, 10, 0, ""); + uiDefButF(block, NUM, REDRAWVIEW3D, "Shear fac:", 670,140,100,20, &cam->hololen1, 0.1, 5.0, 10, 0, ""); + uiBlockSetCol(block, BUTGREEN); + uiDefButS(block, TOG|BIT|4, REDRAWVIEW3D, "Holo 1", 670,120,100,20, &cam->flag, 0.0, 0.0, 0, 0, ""); + uiDefButS(block, TOG|BIT|5, REDRAWVIEW3D, "Holo 2", 670,100,100,20, &cam->flag, 0.0, 0.0, 0, 0, ""); + + } + +} + +/* *************************** MBALL ******************************** */ + +void do_mballbuts(unsigned short event) +{ + switch(event) { + case B_RECALCMBALL: + makeDispList(OBACT); + allqueue(REDRAWVIEW3D, 0); + break; + } +} + +static void editing_panel_mball_type(Object *ob, MetaBall *mb) +{ + uiBlock *block; + + block= uiNewBlock(&curarea->uiblocks, "editing_panel_mball_type", UI_EMBOSSX, UI_HELV, curarea->win); + if(uiNewPanel(curarea, block, "MetaBall", "Editing", 320, 0, 318, 204)==0) return; + + if (ob==find_basis_mball(ob)) { + uiDefButF(block, NUMSLI, B_RECALCMBALL, "Wiresize:", 470,178,250,19, &mb->wiresize, 0.05, 1.0, 0, 0, ""); + uiDefButF(block, NUMSLI, 0, "Rendersize:", 470,158,250,19, &mb->rendersize, 0.05, 1.0, 0, 0, ""); + uiDefButF(block, NUMSLI, B_RECALCMBALL, "Threshold:", 470,138,250,19, &mb->thresh, 0.0001, 5.0, 0, 0, ""); + + uiBlockSetCol(block, BUTBLUE); + uiDefBut(block, LABEL, 0, "Update:", 471,108,120,19, 0, 0, 0, 0, 0, ""); + uiDefButS(block, ROW, B_DIFF, "Always", 471, 85, 120, 19, &mb->flag, 0.0, 0.0, 0, 0, ""); + uiDefButS(block, ROW, B_DIFF, "Half Res", 471, 65, 120, 19, &mb->flag, 0.0, 1.0, 0, 0, ""); + uiDefButS(block, ROW, B_DIFF, "Fast", 471, 45, 120, 19, &mb->flag, 0.0, 2.0, 0, 0, ""); + uiBlockSetCol(block, BUTGREY); + } + +} + +static void editing_panel_mball_tools(Object *ob, MetaBall *mb) +{ + extern MetaElem *lastelem; + uiBlock *block; + + block= uiNewBlock(&curarea->uiblocks, "editing_panel_mball_tools", UI_EMBOSSX, UI_HELV, curarea->win); + if( uiNewPanel(curarea, block, "MetaBall tools", "Editing", 640, 0, 318, 204)==0) return; + + if(ob==G.obedit && lastelem) { + uiDefButF(block, NUMSLI, B_RECALCMBALL, "Stiffness:", 750,178,250,19, &lastelem->s, 0.0, 10.0, 0, 0, ""); + if(lastelem->type!=MB_BALL) + uiDefButF(block, NUMSLI, B_RECALCMBALL, "dx:", 750,158,250,19, &lastelem->expx, 0.0, 20.0, 0, 0, ""); + if((lastelem->type!=MB_BALL)&&(lastelem->type!=MB_TUBE)) + uiDefButF(block, NUMSLI, B_RECALCMBALL, "dy:", 750,138,250,19, &lastelem->expy, 0.0, 20.0, 0, 0, ""); + + if((lastelem->type==MB_CUBE)||(lastelem->type==MB_ELIPSOID)) + uiDefButF(block, NUMSLI, B_RECALCMBALL, "dz:", 750,118,250,19, &lastelem->expz, 0.0, 20.0, 0, 0, ""); + + uiBlockSetCol(block, BUTGREEN); + uiDefButS(block, TOG|BIT|1, B_RECALCMBALL, "Negative",753,16,60,19, &lastelem->flag, 0, 0, 0, 0, ""); + + uiDefButS(block, ROW, B_RECALCMBALL, "Ball", 753,83,60,19, &lastelem->type, 1.0, 0.0, 0, 0, ""); + uiDefButS(block, ROW, B_RECALCMBALL, "Tube", 753,62,60,19, &lastelem->type, 1.0, 4.0, 0, 0, ""); + uiDefButS(block, ROW, B_RECALCMBALL, "Plane", 814,62,60,19, &lastelem->type, 1.0, 5.0, 0, 0, ""); + uiDefButS(block, ROW, B_RECALCMBALL, "Elipsoid", 876,62,60,19, &lastelem->type, 1.0, 6.0, 0, 0, ""); + uiDefButS(block, ROW, B_RECALCMBALL, "Cube", 938,62,60,19, &lastelem->type, 1.0, 7.0, 0, 0, ""); + } + +} + + +/* *************************** LATTICE ******************************** */ + +void do_latticebuts(unsigned short event) +{ + Object *ob; + Lattice *lt; + + ob= OBACT; + if(ob->type!=OB_LATTICE) return; + + switch(event) { + case B_RESIZELAT: + if(ob) { + if(ob==G.obedit) resizelattice(editLatt); + else resizelattice(ob->data); + } + allqueue(REDRAWVIEW3D, 0); + break; + case B_DRAWLAT: + if(ob==G.obedit) calc_lattverts_ext(); + allqueue(REDRAWVIEW3D, 0); + break; + case B_LATTCHANGED: + + lt= ob->data; + if(lt->flag & LT_OUTSIDE) outside_lattice(lt); + + make_displists_by_parent(ob); + + allqueue(REDRAWVIEW3D, 0); + + break; + } +} + +static void editing_panel_lattice_type(Object *ob, Lattice *lt) +{ + uiBlock *block; + + block= uiNewBlock(&curarea->uiblocks, "editing_panel_lattice_type", UI_EMBOSSX, UI_HELV, curarea->win); + if(uiNewPanel(curarea, block, "Latice", "Editing", 320, 0, 318, 204)==0) return; + + + uiSetButLock(lt->key!=0, "Not with VertexKeys"); + uiSetButLock(ob==G.obedit, "Unable to perform function in EditMode"); + uiDefButS(block, NUM, B_RESIZELAT, "U:", 470,178,100,19, <->pntsu, 1.0, 64.0, 0, 0, ""); + uiDefButS(block, NUM, B_RESIZELAT, "V:", 470,158,100,19, <->pntsv, 1.0, 64.0, 0, 0, ""); + uiDefButS(block, NUM, B_RESIZELAT, "W:", 470,138,100,19, <->pntsw, 1.0, 64.0, 0, 0, ""); + uiClearButLock(); + + uiBlockSetCol(block, BUTGREEN); + uiDefButC(block, ROW, B_LATTCHANGED, "Lin", 572, 178, 40, 19, <->typeu, 1.0, (float)KEY_LINEAR, 0, 0, ""); + uiDefButC(block, ROW, B_LATTCHANGED, "Card", 612, 178, 40, 19, <->typeu, 1.0, (float)KEY_CARDINAL, 0, 0, ""); + uiDefButC(block, ROW, B_LATTCHANGED, "B", 652, 178, 40, 19, <->typeu, 1.0, (float)KEY_BSPLINE, 0, 0, ""); + + uiDefButC(block, ROW, B_LATTCHANGED, "Lin", 572, 158, 40, 19, <->typev, 2.0, (float)KEY_LINEAR, 0, 0, ""); + uiDefButC(block, ROW, B_LATTCHANGED, "Card", 612, 158, 40, 19, <->typev, 2.0, (float)KEY_CARDINAL, 0, 0, ""); + uiDefButC(block, ROW, B_LATTCHANGED, "B", 652, 158, 40, 19, <->typev, 2.0, (float)KEY_BSPLINE, 0, 0, ""); + + uiDefButC(block, ROW, B_LATTCHANGED, "Lin", 572, 138, 40, 19, <->typew, 3.0, (float)KEY_LINEAR, 0, 0, ""); + uiDefButC(block, ROW, B_LATTCHANGED, "Card", 612, 138, 40, 19, <->typew, 3.0, (float)KEY_CARDINAL, 0, 0, ""); + uiDefButC(block, ROW, B_LATTCHANGED, "B", 652, 138, 40, 19, <->typew, 3.0, (float)KEY_BSPLINE, 0, 0, ""); + + uiBlockSetCol(block, BUTSALMON); + uiDefBut(block, BUT, B_RESIZELAT, "Make Regular", 470,101,99,32, 0, 0, 0, 0, 0, ""); + + uiBlockSetCol(block, BUTGREEN); + uiDefButS(block, TOG|BIT|1, B_LATTCHANGED, "Outside", 571,101,120,31, <->flag, 0, 0, 0, 0, ""); + + if(lt->key) { + uiDefButS(block, NUM, B_DIFF, "Slurph:", 470,60,120,19, &(lt->key->slurph), -500.0, 500.0, 0, 0, ""); + uiDefButS(block, TOG, B_RELKEY, "Relative Keys", 470,40,120,19, <->key->type, 0, 0, 0, 0, ""); + } + +} + +/* *************************** ARMATURE ******************************** */ + + + +static int editbone_to_parnr (EditBone *bone) +{ + EditBone *ebone; + int index; + + for (ebone=G.edbo.first, index=0; ebone; ebone=ebone->next, index++){ + if (ebone==bone) + return index; + } + + return -1; +} + + + +static void attach_bone_to_parent(EditBone *bone) +{ + EditBone *curbone; + + if (bone->flag & BONE_IK_TOPARENT) { + + /* See if there are any other bones that refer to the same parent and disconnect them */ + for (curbone = G.edbo.first; curbone; curbone=curbone->next){ + if (curbone!=bone){ + if (curbone->parent && (curbone->parent == bone->parent) && (curbone->flag & BONE_IK_TOPARENT)) + curbone->flag &= ~BONE_IK_TOPARENT; + } + } + + /* Attach this bone to its parent */ + VECCOPY(bone->head, bone->parent->tail); + } + +} + +static void attach_bone_to_parent_cb(void *bonev, void *arg2_unused) +{ + EditBone *curBone= bonev; + attach_bone_to_parent(curBone); +} + +static void parnr_to_editbone(EditBone *bone) +{ + if (bone->parNr == -1){ + bone->parent = NULL; + bone->flag &= ~BONE_IK_TOPARENT; + } + else{ + bone->parent = BLI_findlink(&G.edbo, bone->parNr); + attach_bone_to_parent(bone); + } +} + +static void parnr_to_editbone_cb(void *bonev, void *arg2_unused) +{ + EditBone *curBone= bonev; + parnr_to_editbone(curBone); +} + + +static void build_bonestring (char *string, EditBone *bone){ + EditBone *curBone; + EditBone *pBone; + int skip=0; + int index; + + sprintf (string, "Parent%%t| %%x%d", -1); /* That space is there for a reason */ + + for (curBone = G.edbo.first, index=0; curBone; curBone=curBone->next, index++){ + /* Make sure this is a valid child */ + if (curBone != bone){ + skip=0; + for (pBone=curBone->parent; pBone; pBone=pBone->parent){ + if (pBone==bone){ + skip=1; + break; + } + } + + if (skip) + continue; + + sprintf (string, "%s|%s%%x%d", string, curBone->name, index); + } + } +} + +static void validate_editbonebutton(EditBone *eBone){ + EditBone *prev; + bAction *act=NULL; + bActionChannel *chan; + Base *base; + + /* Separate the bone from the G.edbo */ + prev=eBone->prev; + BLI_remlink (&G.edbo, eBone); + + /* Validate the name */ + unique_editbone_name (eBone->name); + + /* Re-insert the bone */ + if (prev) + BLI_insertlink(&G.edbo, prev, eBone); + else + BLI_addhead (&G.edbo, eBone); + + /* Rename channel if necessary */ + if (G.obedit) + act = G.obedit->action; + + if (act && !act->id.lib){ + // Find the appropriate channel + for (chan = act->chanbase.first; chan; chan=chan->next){ + if (!strcmp (chan->name, eBone->oldname)){ + strcpy (chan->name, eBone->name); + } + } + allqueue(REDRAWACTION, 0); + } + + /* Update the parenting info of any users */ + /* Yes, I know this is the worst thing you have ever seen. */ + + for (base = G.scene->base.first; base; base=base->next){ + Object *ob = base->object; + + /* See if an object is parented to this armature */ + if (ob->parent && ob->partype==PARBONE && (ob->parent->type==OB_ARMATURE) && (ob->parent->data == G.obedit->data)){ + if (!strcmp(ob->parsubstr, eBone->oldname)) + strcpy(ob->parsubstr, eBone->name); + } + } + + exit_editmode(0); /* To ensure new names make it to the edit armature */ + +} + +static void validate_editbonebutton_cb(void *bonev, void *arg2_unused) +{ + EditBone *curBone= bonev; + validate_editbonebutton(curBone); +} + + +static void editing_panel_armature_type(Object *ob, bArmature *arm) +{ + uiBlock *block; + int bx=148, by=100; + + block= uiNewBlock(&curarea->uiblocks, "editing_panel_armature_type", UI_EMBOSSX, UI_HELV, curarea->win); + if(uiNewPanel(curarea, block, "Armature", "Editing", 320, 0, 318, 204)==0) return; + + uiBlockSetCol(block, BUTGREEN); + uiDefButI(block, TOG|BIT|ARM_RESTPOSBIT,REDRAWVIEW3D, "Rest Pos", bx,by,97,20, &arm->flag, 0, 0, 0, 0, "Disable all animation for this object"); + uiDefButI(block, TOG|BIT|ARM_DRAWAXESBIT,REDRAWVIEW3D, "Draw Axes", bx,by-46,97,20, &arm->flag, 0, 0, 0, 0, "Draw bone axes"); + uiDefButI(block, TOG|BIT|ARM_DRAWNAMESBIT,REDRAWVIEW3D, "Draw Names", bx,by-69,97,20, &arm->flag, 0, 0, 0, 0, "Draw bone names"); + uiDefButI(block, TOG|BIT|ARM_DRAWXRAYBIT,REDRAWVIEW3D, "X-Ray", bx,by-92,97,20, &arm->flag, 0, 0, 0, 0, "Draw armature in front of shaded objects"); + + + +} + +static void editing_panel_armature_bones(Object *ob, bArmature *arm) +{ + uiBlock *block; + EditBone *curBone; + uiBut *but; + char *boneString=NULL; + int bx=148, by=180; + int index; + + /* Draw the bone name block */ + + block= uiNewBlock(&curarea->uiblocks, "editing_panel_armature_bones", UI_EMBOSSX, UI_HELV, curarea->win); + if(uiNewPanel(curarea, block, "Armature Bones", "Editing", 640, 0, 318, 204)==0) return; + + /* this is a variable height panel, newpanel doesnt force new size on existing panels */ + /* so first we make it default height */ + uiNewPanelHeight(block, 204); + + + uiDefBut(block, LABEL, 0, "Selected Bones", bx,by,158,18, 0, 0, 0, 0, 0, ""); + by-=20; + for (curBone=G.edbo.first, index=0; curBone; curBone=curBone->next, index++){ + if (curBone->flag & (BONE_SELECTED)) { + + /* Hide in posemode flag */ + uiBlockSetCol(block, BUTGREEN); + uiDefButI(block, TOG|BIT|BONE_HIDDENBIT, REDRAWVIEW3D, "Hide", bx-55,by,45,18, &curBone->flag, 0, 0, 0, 0, "Toggles display of this bone in posemode"); + + /* Bone naming button */ + uiBlockSetCol(block, BUTGREY); + strcpy (curBone->oldname, curBone->name); + but=uiDefBut(block, TEX, REDRAWVIEW3D, "BO:", bx-10,by,117,18, &curBone->name, 0, 24, 0, 0, "Change the bone name"); + uiButSetFunc(but, validate_editbonebutton_cb, curBone, NULL); + + uiDefBut(block, LABEL, 0, "child of", bx+107,by,73,18, NULL, 0.0, 0.0, 0.0, 0.0, ""); + + boneString = malloc((BLI_countlist(&G.edbo) * 64)+64); + build_bonestring (boneString, curBone); + + curBone->parNr = editbone_to_parnr(curBone->parent); + but = uiDefButI(block, MENU,REDRAWVIEW3D, boneString, bx+180,by,120,18, &curBone->parNr, 0.0, 0.0, 0.0, 0.0, "Parent"); + uiButSetFunc(but, parnr_to_editbone_cb, curBone, NULL); + + free(boneString); + + /* IK to parent flag */ + if (curBone->parent){ + uiBlockSetCol(block, BUTGREEN); + but=uiDefButI(block, TOG|BIT|BONE_IK_TOPARENTBIT, REDRAWVIEW3D, "IK", bx+300,by,32,18, &curBone->flag, 0.0, 0.0, 0.0, 0.0, "IK link to parent"); + uiButSetFunc(but, attach_bone_to_parent_cb, curBone, NULL); + } + + /* Dist and weight buttons */ + uiBlockSetCol(block, BUTGREY); + but=uiDefButS(block, MENU, REDRAWVIEW3D, + "Skinnable %x0|" + "Unskinnable %x1|" + "Head %x2|" + "Neck %x3|" + "Back %x4|" + "Shoulder %x5|" + "Arm %x6|" + "Hand %x7|" + "Finger %x8|" + "Thumb %x9|" + "Pelvis %x10|" + "Leg %x11|" + "Foot %x12|" + "Toe %x13|" + "Tentacle %x14", + bx-10,by-19,117,18, + &curBone->boneclass, + 0.0, 0.0, 0.0, 0.0, + "Classification of armature element"); + + /* Dist and weight buttons */ + uiBlockSetCol(block, BUTGREY); + uiDefButF(block, NUM,REDRAWVIEW3D, "Dist:", bx+110, by-19, + 105, 18, &curBone->dist, 0.0, 1000.0, 10.0, 0.0, + "Bone deformation distance"); + uiDefButF(block, NUM,REDRAWVIEW3D, "Weight:", bx+223, by-19, + 110, 18, &curBone->weight, 0.0F, 1000.0F, + 10.0F, 0.0F, "Bone deformation weight"); + + by-=42; + } + } + + if(by<0) { + uiNewPanelHeight(block, 204 - by); + } + +} + + +/* *************************** MESH ******************************** */ + + + +void do_meshbuts(unsigned short event) +{ + void decimate_faces(void); + void decimate_cancel(void); + void decimate_apply(void); + Object *ob; + Mesh *me; + float fac; + short randfac; + + ob= OBACT; + if(ob && ob->type==OB_MESH) { + + me= get_mesh(ob); + if(me==0) return; + + switch(event) { + case B_AUTOVGROUP: + if (!get_armature(ob->parent)){ + error ("Mesh must be the child of an armature"); + break; + } + /* Verify that there are vertex groups for bones in armature */ + /* Remove selected vertices from all defgroups */ + /* Perform assignment for selected vertices */ + + allqueue (REDRAWVIEW3D, 1); + break; + case B_NEWVGROUP: + add_defgroup (G.obedit); + scrarea_queue_winredraw(curarea); + break; + case B_DELVGROUP: + del_defgroup (G.obedit); + allqueue (REDRAWVIEW3D, 1); + break; + case B_ASSIGNVGROUP: + assign_verts_defgroup (); + allqueue (REDRAWVIEW3D, 1); + break; + case B_REMOVEVGROUP: + remove_verts_defgroup (0); + allqueue (REDRAWVIEW3D, 1); + break; + case B_SELVGROUP: + sel_verts_defgroup(1); + allqueue (REDRAWVIEW3D, 1); + break; + case B_DESELVGROUP: + sel_verts_defgroup(0); + allqueue (REDRAWVIEW3D, 1); + break; + case B_DELSTICKY: + + if(me->msticky) MEM_freeN(me->msticky); + me->msticky= 0; + allqueue(REDRAWBUTSEDIT, 0); + break; + case B_MAKESTICKY: + make_sticky(); + break; + case B_MAKEVERTCOL: + make_vertexcol(); + break; + case B_DELVERTCOL: + if(me->mcol) MEM_freeN(me->mcol); + me->mcol= 0; + G.f &= ~G_VERTEXPAINT; + freedisplist(&(ob->disp)); + allqueue(REDRAWBUTSEDIT, 0); + allqueue(REDRAWVIEW3D, 0); + break; + + case B_MAKE_TFACES: + make_tfaces(me); + allqueue(REDRAWBUTSEDIT, 0); + break; + + case B_DEL_TFACES: + if(me->tface) MEM_freeN(me->tface); + me->tface= 0; + G.f &= ~G_FACESELECT; + allqueue(REDRAWBUTSEDIT, 0); + allqueue(REDRAWVIEW3D, 0); + allqueue(REDRAWIMAGE, 0); + break; + + case B_FLIPNORM: + if(G.obedit) { + flip_editnormals(); + } + else flipnorm_mesh( get_mesh(ob) ); + + allqueue(REDRAWVIEW3D, 0); + break; + + case B_DECIM_FACES: + decimate_faces(); + break; + case B_DECIM_CANCEL: + decimate_cancel(); + break; + case B_DECIM_APPLY: + decimate_apply(); + break; + + case B_SLOWERDRAW: + slowerdraw(); + break; + case B_FASTERDRAW: + fasterdraw(); + break; + } + } + + if(G.obedit==0 || (G.obedit->type!=OB_MESH)) return; + + switch(event) { + case B_SPIN: + if( select_area(SPACE_VIEW3D)) spin_mesh(step, degr, 0, 0); + break; + case B_SPINDUP: + if( select_area(SPACE_VIEW3D)) spin_mesh(step, degr, 0, 1); + break; + case B_EXTR: + G.f |= G_DISABLE_OK; + if( select_area(SPACE_VIEW3D)) extrude_mesh(); + G.f -= G_DISABLE_OK; + break; + case B_SCREW: + if( select_area(SPACE_VIEW3D)) screw_mesh(step, turn); + break; + case B_EXTREP: + if( select_area(SPACE_VIEW3D)) extrude_repeat_mesh(step, extr_offs); + break; + case B_SPLIT: + G.f |= G_DISABLE_OK; + split_mesh(); + G.f -= G_DISABLE_OK; + break; + case B_REMDOUB: + notice("Removed: %d", removedoublesflag(1, doublimit)); + allqueue(REDRAWVIEW3D, 0); + break; + case B_SUBDIV: + waitcursor(1); + subdivideflag(1, 0.0, editbutflag & B_BEAUTY); + countall(); + waitcursor(0); + allqueue(REDRAWVIEW3D, 0); + break; + case B_FRACSUBDIV: + randfac= 10; + if(button(&randfac, 1, 100, "Rand fac:")==0) return; + waitcursor(1); + fac= -( (float)randfac )/100; + subdivideflag(1, fac, editbutflag & B_BEAUTY); + countall(); + waitcursor(0); + allqueue(REDRAWVIEW3D, 0); + break; + case B_XSORT: + if( select_area(SPACE_VIEW3D)) xsortvert_flag(1); + break; + case B_HASH: + hashvert_flag(1); + break; + case B_TOSPHERE: + vertices_to_sphere(); + break; + case B_VERTEXNOISE: + vertexnoise(); + break; + case B_VERTEXSMOOTH: + vertexsmooth(); + break; + } + /* WATCH IT: previous events only in editmode! */ +} + +static void editing_panel_mesh_tools(Object *ob, Mesh *me) +{ + uiBlock *block; + + block= uiNewBlock(&curarea->uiblocks, "editing_panel_mesh_tools", UI_EMBOSSX, UI_HELV, curarea->win); + if(uiNewPanel(curarea, block, "Mesh Tools", "Editing", 640, 0, 318, 204)==0) return; + + + uiBlockSetCol(block, BUTGREEN); + uiDefButS(block, TOG|BIT|2, 0, "Beauty", 477,195,80,19, &editbutflag, 0, 0, 0, 0, "Causes 'Subdivide' to split faces in halves instead of quarters"); + uiBlockSetCol(block, BUTSALMON); + uiDefBut(block, BUT,B_SPLIT,"Split", 477,175,80,19, 0, 0, 0, 0, 0, "Separates selected faces from unselected faces"); + uiDefBut(block, BUT,B_TOSPHERE,"To Sphere", 477,155,80,19, 0, 0, 0, 0, 0, "Moves selected vertices outwards into a spherical shape"); + uiDefBut(block, BUT,B_SUBDIV,"Subdivide", 477,135,80,19, 0, 0, 0, 0, 0, "Splits selected faces into halves or quarters"); + + uiDefBut(block, BUT,B_FRACSUBDIV, "Fract Subd", 557,195,80,19, 0, 0, 0, 0, 0, "Subdivides selected faces with a random factor"); + uiDefBut(block, BUT,B_VERTEXNOISE,"Noise", 557,175,80,19, 0, 0, 0, 0, 0, "Use vertex coordinate as texture coordinate"); + uiDefBut(block, BUT,B_VERTEXSMOOTH,"Smooth", 557,155,80,19, 0, 0, 0, 0, 0, "Flattens angles of selected faces"); + uiDefBut(block, BUT,B_XSORT,"Xsort", 557,135,80,19, 0, 0, 0, 0, 0, "Sorts selected vertice data in the X direction"); + + uiDefBut(block, BUT,B_HASH,"Hash", 637,195,80,19, 0, 0, 0, 0, 0, "Randomizes selected vertice sequence data"); + uiBlockSetCol(block, BUTGREY); + uiDefButF(block, NUM, B_DIFF, "Limit:", 637,175,80,19, &doublimit, 0.0001, 1.0, 10, 0, "Specifies the max distance 'Rem Doubles' will consider vertices as 'doubled'"); + uiBlockSetCol(block, BUTSALMON); + uiDefBut(block, BUT,B_REMDOUB,"Rem Doubles", 637,155,80,19, 0, 0, 0, 0, 0, "Removes duplicates from selected vertices"); + uiDefBut(block, BUT,B_FLIPNORM,"Flip Normals", 637,135,80,19, 0, 0, 0, 0, 0, "Toggles the direction of the selected face's normals"); + + + uiBlockSetCol(block, BUTSALMON); + uiDefBut(block, BUT,B_EXTR,"Extrude", 477,100,249,24, 0, 0, 0, 0, 0, "Converts selected edges to faces and selects the new vertices"); + uiDefBut(block, BUT,B_SPINDUP,"Spin Dupe", 639,75,87,24, 0, 0, 0, 0, 0, "Creates copies of the selected vertices in a circle around the cursor in the indicated viewport"); + uiDefBut(block, BUT,B_SPIN, "Spin", 558,75,78,24, 0, 0, 0, 0, 0, "Extrudes the selected vertices in a circle around the cursor in the indicated viewport"); + uiDefBut(block, BUT,B_SCREW,"Screw", 477,75,79,24, 0, 0, 0, 0, 0, "Activates the screw tool"); // Bish - This could use some more definition + uiDefBut(block, BUT,B_EXTREP, "Extrude Dupe", 477,15,128,19, 0, 0, 0, 0, 0, "Creates copies of the selected vertices in a straight line away from the current viewport"); + + uiBlockSetCol(block, BUTGREY); + uiDefButS(block, NUM, B_DIFF, "Degr:", 477,55,78,19, °r,10.0,360.0, 0, 0, "Specifies the number of degrees 'Spin' revolves"); + uiDefButS(block, NUM, B_DIFF, "Steps:", 558,55,78,19, &step,1.0,180.0, 0, 0, "Specifies the total number of 'Spin' slices"); + uiDefButS(block, NUM, B_DIFF, "Turns:", 639,55,86,19, &turn,1.0,360.0, 0, 0, "Specifies the number of revolutions the screw turns"); + uiDefButS(block, TOG|BIT|0, B_DIFF, "Clockwise", 639,35,86,19, &editbutflag, 0, 0, 0, 0, "Specifies the direction for 'Screw' and 'Spin'"); + uiDefButS(block, TOG|BIT|1, B_DIFF, "Keep Original", 477,35,156,19, &editbutflag, 0, 0, 0, 0, "Keeps a copy of the original vertices and faces after executing tools"); + uiDefButF(block, NUM, B_DIFF, "Offset:", 608,15,117,19, &extr_offs, 0.01, 10.0, 100, 0, "Sets the distance between each copy for 'Extrude Dupe'"); + + +} + +static void verify_vertexgroup_name_func(void *datav, void *data2_unused) +{ + unique_vertexgroup_name((bDeformGroup*)datav, OBACT); +} + + + +static void editing_panel_mesh_tools1(Object *ob, Mesh *me) +{ + uiBlock *block; + + + block= uiNewBlock(&curarea->uiblocks, "editing_panel_mesh_tools1", UI_EMBOSSX, UI_HELV, curarea->win); + if(uiNewPanel(curarea, block, "Mesh Tools 1", "Editing", 960, 0, 318, 204)==0) return; + + uiBlockSetCol(block, BUTSALMON); + uiDefBut(block, BUT,B_DOCENTRE, "Centre", 1091, 200, 100, 19, 0, 0, 0, 0, 0, "Shifts object data to be centered about object's origin"); + + + uiDefBut(block, BUT,B_HIDE, "Hide", 1091,152,77,18, 0, 0, 0, 0, 0, "Hides selected faces"); + uiDefBut(block, BUT,B_REVEAL, "Reveal", 1171,152,86,18, 0, 0, 0, 0, 0, "Reveals selected faces"); + uiDefBut(block, BUT,B_SELSWAP, "Select Swap", 1091,129,166,18, 0, 0, 0, 0, 0, "Selects unselected faces, and deselects selected faces"); + + uiBlockSetCol(block, BUTGREY); + uiDefButF(block, NUM, REDRAWVIEW3D, "NSize:", 1090, 90, 164, 19, &editbutsize, 0.001, 2.0, 10, 0, "Sets the length to use when displaying face normals"); + uiDefButI(block, TOG|BIT|6, REDRAWVIEW3D, "Draw Normals", 1090,70,164,19, &G.f, 0, 0, 0, 0, "Displays face normals as lines"); + uiDefButI(block, TOG|BIT|7, REDRAWVIEW3D, "Draw Faces", 1090,50,164,19, &G.f, 0, 0, 0, 0, "Displays all faces as shades"); + uiDefButI(block, TOG|BIT|18, REDRAWVIEW3D, "Draw Edges", 1090,30,164,19, &G.f, 0, 0, 0, 0, "Displays selected edges using hilights"); + uiDefButI(block, TOG|BIT|11, 0, "All edges", 1090,10,164,19, &G.f, 0, 0, 0, 0, "Displays all edges in object mode without optimization"); + + + /* Draw Vertex grouping buttons mostly if we're in editmode */ + { + uiBut *but; + int defCount; + bDeformGroup *defGroup; + char *s, *menustr; + bDeformGroup *dg; + int min, by=210, index; + + uiBlockSetCol(block, BUTGREY); + uiDefBut(block, LABEL,0,"Vertex Groups", 940,by-=19,113,18, 0, 0, 0, 0, 0, ""); + + defCount=BLI_countlist(&ob->defbase); + + if (!defCount) min=0; + else min=1; + + s= menustr = MEM_callocN((32 * defCount)+20, "menustr"); + + for (index = 1, dg = ob->defbase.first; dg; index++, dg=dg->next) { + int cnt= sprintf (s, "%s%%x%d|", dg->name, index); + + if (cnt>0) s+= cnt; + } + + by-=22; + if (defCount) uiDefButS(block, MENU, REDRAWBUTSEDIT, menustr, 940, by,18,18, &ob->actdef, min, defCount, 0, 0, "Browses available vertex groups"); + + MEM_freeN (menustr); + + if (ob->actdef){ + defGroup = BLI_findlink(&ob->defbase, ob->actdef-1); + but= uiDefBut(block, TEX,REDRAWBUTSEDIT,"", 958,by,93-18,18, defGroup->name, 0, 32, 0, 0, "Displays current vertex group name. Click to change. (Match bone name for deformation.)"); + uiButSetFunc(but, verify_vertexgroup_name_func, defGroup, NULL); + } + + uiDefButF(block, NUM, REDRAWVIEW3D, "Weight:", 940, by-=22, 93, 18, &editbutvweight, 0, 1, 10, 0, "Sets the current vertex group's bone deformation strength"); + + if (G.obedit && G.obedit==ob){ + + uiBlockSetCol(block, BUTSALMON); + /* uiDefBut(block, BUT,B_AUTOVGROUP,"Auto Weight", 740,by-=22,93,18, 0, 0, 0, 0, 0, "Automatically assigns deformation groups"); */ + uiDefBut(block, BUT,B_NEWVGROUP,"New", 940,by-=22,45,18, 0, 0, 0, 0, 0, "Creates a new vertex group"); + uiDefBut(block, BUT,B_DELVGROUP,"Delete", 988,by,45,18, 0, 0, 0, 0, 0, "Removes the current vertex group"); + + uiBlockSetCol(block, BUTSALMON); + uiDefBut(block, BUT,B_ASSIGNVGROUP,"Assign", 940,by-=22,93,18, 0, 0, 0, 0, 0, "Assigns selected vertices to the current vertex group"); + uiDefBut(block, BUT,B_REMOVEVGROUP,"Remove", 940,by-=22,93,18, 0, 0, 0, 0, 0, "Removes selected vertices from the current vertex group"); + + uiBlockSetCol(block, BUTGREY); + uiDefBut(block, BUT,B_SELVGROUP,"Select", 940,by-=22,93,18, 0, 0, 0, 0, 0, "Selects vertices belonging to the current vertex group"); + uiDefBut(block, BUT,B_DESELVGROUP,"Deselect", 940,by-=22,93,18, 0, 0, 0, 0, 0, "Deselects vertices belonging to the current vertex group"); + } + } + +} + + +static void editing_panel_materials(Object *ob) +{ + uiBlock *block; + int *poin; + float min; + Material *ma; + char str[64]; + + block= uiNewBlock(&curarea->uiblocks, "editing_panel_materials", UI_EMBOSSX, UI_HELV, curarea->win); + if(uiNewPanel(curarea, block, "Materials", "Editing", 0, 0, 318, 204)==0) return; + + /* to be sure */ + if ELEM5(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL); + else return; + + + if(ob->type==OB_MESH) poin= &( ((Mesh *)ob->data)->texflag ); + else if(ob->type==OB_MBALL) poin= &( ((MetaBall *)ob->data)->texflag ); + else poin= &( ((Curve *)ob->data)->texflag ); + uiDefButI(block, TOG|BIT|0, B_AUTOTEX, "AutoTexSpace", 143,180,130,19, poin, 0, 0, 0, 0, "Adjusts active object's texture space automatically when transforming object"); + + sprintf(str,"%d Mat:", ob->totcol); + if(ob->totcol) min= 1.0; else min= 0.0; + ma= give_current_material(ob, ob->actcol); + + if(ma) { + uiDefButF(block, COL, 0, "", 291,123,24,30, &(ma->r), 0, 0, 0, 0, ""); + uiDefBut(block, LABEL, 0, ma->id.name+2, 318,146, 103, 30, 0, 0, 0, 0, 0, ""); + } + uiDefButC(block, NUM, B_REDR, str, 318,123,103,30, &ob->actcol, min, (float)(ob->totcol), 0, 0, "Displays total number of material indices and the current index"); + uiDefBut(block, BUT,B_MATWICH, "?", 423,123,31,30, 0, 0, 0, 0, 0, "In EditMode, sets the active material index from selected faces"); + + uiBlockSetCol(block, BUTSALMON); + uiDefBut(block, BUT,B_MATNEW, "New", 292,101,80,21, 0, 0, 0, 0, 0, "Adds a new Material index"); + uiDefBut(block, BUT,B_MATDEL, "Delete", 374,101,80,21, 0, 0, 0, 0, 0, "Deletes this Material index"); + uiDefBut(block, BUT,B_MATASS, "Assign", 291,47,162,26, 0, 0, 0, 0, 0, "In EditMode, assigns the active index to selected faces"); + + uiBlockSetCol(block, BUTGREY); + uiDefBut(block, BUT,B_MATSEL, "Select", 292,76,79,22, 0, 0, 0, 0, 0, "In EditMode, selects faces that have the active index"); + uiDefBut(block, BUT,B_MATDESEL, "Deselect", 373,76,79,21, 0, 0, 0, 0, 0, "Deselects everything with current indexnumber"); + + uiDefBut(block, BUT,B_SETSMOOTH, "Set Smooth", 291,15,80,20, 0, 0, 0, 0, 0, "In EditMode, sets 'smooth' rendering of selected faces"); + uiDefBut(block, BUT,B_SETSOLID, "Set Solid", 373,15,80,20, 0, 0, 0, 0, 0, "In EditMode, sets 'solid' rendering of selected faces"); + +} + +/* *************************** FACE/PAINT *************************** */ + +void do_fpaintbuts(unsigned short event) +{ + Mesh *me; + Object *ob; + extern TFace *lasttface; /* caches info on tface bookkeeping ?*/ + + ob= OBACT; + if(ob==0) return; + + switch(event) { + + case B_VPGAMMA: + vpaint_dogamma(); + break; + case B_COPY_TF_MODE: + case B_COPY_TF_UV: + case B_COPY_TF_COL: + case B_COPY_TF_TEX: + me= get_mesh(ob); + if(me && me->tface) { +/* extern TFace *lasttface; */ + TFace *tface= me->tface; + int a= me->totface; + + set_lasttface(); + if(lasttface) { + + while(a--) { + if(tface!=lasttface && (tface->flag & TF_SELECT)) { + if(event==B_COPY_TF_MODE) { + tface->mode= lasttface->mode; + tface->transp= lasttface->transp; + } + else if(event==B_COPY_TF_UV) { + memcpy(tface->uv, lasttface->uv, sizeof(tface->uv)); + tface->tpage= lasttface->tpage; + tface->tile= lasttface->tile; + + if(lasttface->mode & TF_TILES) tface->mode |= TF_TILES; + else tface->mode &= ~TF_TILES; + + } + else if(event==B_COPY_TF_TEX) { + tface->tpage= lasttface->tpage; + tface->tile= lasttface->tile; + + if(lasttface->mode & TF_TILES) tface->mode |= TF_TILES; + else tface->mode &= ~TF_TILES; + } + else if(event==B_COPY_TF_COL) memcpy(tface->col, lasttface->col, sizeof(tface->col)); + } + tface++; + } + } + do_shared_vertexcol(me); + allqueue(REDRAWVIEW3D, 0); + allqueue(REDRAWIMAGE, 0); + } + break; + case B_SET_VCOL: + clear_vpaint_selectedfaces(); + break; + case B_REDR_3D_IMA: + allqueue(REDRAWVIEW3D, 0); + allqueue(REDRAWIMAGE, 0); + break; + case B_ASSIGNMESH: + + test_object_materials(ob->data); + allqueue(REDRAWVIEW3D, 0); + allqueue(REDRAWBUTSEDIT, 0); + break; + + case B_TFACE_HALO: + set_lasttface(); + if(lasttface) { + lasttface->mode &= ~TF_BILLBOARD2; + allqueue(REDRAWBUTSEDIT, 0); + } + break; + + case B_TFACE_BILLB: + set_lasttface(); + if(lasttface) { + lasttface->mode &= ~TF_BILLBOARD; + allqueue(REDRAWBUTSEDIT, 0); + } + break; + } +} + + +/* -------------------- MODE: vpaint faceselect ------------------- */ + +static void editing_panel_mesh_paint(void) +{ + extern VPaint Gvp; /* from vpaint */ + uiBlock *block; + + block= uiNewBlock(&curarea->uiblocks, "editing_panel_mesh_paint", UI_EMBOSSX, UI_HELV, curarea->win); + if(uiNewPanel(curarea, block, "Paint", "Editing", 640, 0, 318, 204)==0) return; + + uiBlockSetCol(block, BUTGREY); + + uiDefButF(block, NUMSLI, 0, "R ", 979,160,194,19, &Gvp.r, 0.0, 1.0, B_VPCOLSLI, 0, "The amount of red used for painting"); + uiDefButF(block, NUMSLI, 0, "G ", 979,140,194,19, &Gvp.g, 0.0, 1.0, B_VPCOLSLI, 0, "The amount of green used for painting"); + uiDefButF(block, NUMSLI, 0, "B ", 979,120,194,19, &Gvp.b, 0.0, 1.0, B_VPCOLSLI, 0, "The amount of blue used for painting"); + uiDefButF(block, NUMSLI, 0, "Opacity ", 979,100,194,19, &Gvp.a, 0.0, 1.0, 0, 0, "The amount of pressure on the brush"); + uiDefButF(block, NUMSLI, 0, "Size ", 979,80,194,19, &Gvp.size, 2.0, 64.0, 0, 0, "The size of the brush"); + + uiDefButF(block, COL, B_VPCOLSLI, "", 1176,100,28,80, &(Gvp.r), 0, 0, 0, 0, ""); + + uiDefButS(block, ROW, B_DIFF, "Mix", 1212,160,63,19, &Gvp.mode, 1.0, 0.0, 0, 0, "Mix the vertex colours"); + uiDefButS(block, ROW, B_DIFF, "Add", 1212,140,63,19, &Gvp.mode, 1.0, 1.0, 0, 0, "Add the vertex colour"); + uiDefButS(block, ROW, B_DIFF, "Sub", 1212, 120,63,19, &Gvp.mode, 1.0, 2.0, 0, 0, "Subtract from the vertex colour"); + uiDefButS(block, ROW, B_DIFF, "Mul", 1212, 100,63,19, &Gvp.mode, 1.0, 3.0, 0, 0, "Multiply the vertex colour"); + uiDefButS(block, ROW, B_DIFF, "Filter", 1212, 80,63,19, &Gvp.mode, 1.0, 4.0, 0, 0, "Mix the colours with an alpha factor"); + + uiBlockSetCol(block, BUTGREEN); + uiDefButS(block, TOG|BIT|1, 0, "Area", 980,50,80,19, &Gvp.flag, 0, 0, 0, 0, "Set the area the brush covers"); + uiDefButS(block, TOG|BIT|2, 0, "Soft", 1061,50,112,19, &Gvp.flag, 0, 0, 0, 0, "Use a soft brush"); + uiDefButS(block, TOG|BIT|3, 0, "Normals", 1174,50,102,19, &Gvp.flag, 0, 0, 0, 0, "Use vertex normal for painting"); + + uiBlockSetCol(block, BUTSALMON); + uiDefBut(block, BUT, B_VPGAMMA, "Set", 980,30,80,19, 0, 0, 0, 0, 0, "Apply Mul and Gamma to vertex colours"); + uiBlockSetCol(block, BUTGREY); + uiDefButF(block, NUM, B_DIFF, "Mul:", 1061,30,112,19, &Gvp.mul, 0.1, 50.0, 10, 0, "Set the number to multiply vertex colours with"); + uiDefButF(block, NUM, B_DIFF, "Gamma:", 1174,30,102,19, &Gvp.gamma, 0.1, 5.0, 10, 0, "Change the clarity of the vertex colours"); + + uiBlockSetCol(block, BUTSALMON); + uiDefBut(block, BUT, B_SET_VCOL, "Set VertCol", 980,5,103,28, 0, 0, 0, 0, 0, "Set Vertex colour of selection to current (Shift+K)"); + +} + + +static void editing_panel_mesh_texface(void) +{ + uiBlock *block; + extern TFace *lasttface; + + block= uiNewBlock(&curarea->uiblocks, "editing_panel_mesh_texface", UI_EMBOSSX, UI_HELV, curarea->win); + if(uiNewPanel(curarea, block, "Texture face", "Editing", 640, 0, 318, 204)==0) return; + + set_lasttface(); // checks for ob type + if(lasttface) { + + uiBlockSetCol(block, BUTGREEN); + uiDefButS(block, TOG|BIT|2, B_REDR_3D_IMA, "Tex", 600,160,60,19, &lasttface->mode, 0, 0, 0, 0, "Render face with texture"); + uiDefButS(block, TOG|BIT|7, B_REDR_3D_IMA, "Tiles", 660,160,60,19, &lasttface->mode, 0, 0, 0, 0, "Use tilemode for face"); + uiDefButS(block, TOG|BIT|4, REDRAWVIEW3D, "Light", 720,160,60,19, &lasttface->mode, 0, 0, 0, 0, "Use light for face"); + uiDefButS(block, TOG|BIT|10, REDRAWVIEW3D, "Invisible",780,160,60,19, &lasttface->mode, 0, 0, 0, 0, "Make face invisible"); + uiDefButS(block, TOG|BIT|0, REDRAWVIEW3D, "Collision", 840,160,60,19, &lasttface->mode, 0, 0, 0, 0, "Use face for collision detection"); + + uiDefButS(block, TOG|BIT|6, REDRAWVIEW3D, "Shared", 600,140,60,19, &lasttface->mode, 0, 0, 0, 0, "Blend vertex colours across face when vertices are shared"); + uiDefButS(block, TOG|BIT|9, REDRAWVIEW3D, "Twoside", 660,140,60,19, &lasttface->mode, 0, 0, 0, 0, "Render face twosided"); + uiDefButS(block, TOG|BIT|11, REDRAWVIEW3D, "ObColor",720,140,60,19, &lasttface->mode, 0, 0, 0, 0, "Use ObColor instead of vertex colours"); + + uiDefButS(block, TOG|BIT|8, B_TFACE_HALO, "Halo", 600,120,60,19, &lasttface->mode, 0, 0, 0, 0, "Screen aligned billboard"); + uiDefButS(block, TOG|BIT|12, B_TFACE_BILLB, "Billboard",660,120,60,19, &lasttface->mode, 0, 0, 0, 0, "Billboard with Z-axis constraint"); + uiDefButS(block, TOG|BIT|13, REDRAWVIEW3D, "Shadow", 720,120,60,19, &lasttface->mode, 0, 0, 0, 0, "Face is used for shadow"); + uiDefButS(block, TOG|BIT|14, REDRAWVIEW3D, "Text", 780,120,60,19, &lasttface->mode, 0, 0, 0, 0, "Enable bitmap text on face"); + + uiBlockSetCol(block, BUTPURPLE); + uiDefButC(block, ROW, REDRAWVIEW3D, "Opaque", 600,100,60,19, &lasttface->transp, 2.0, 0.0, 0, 0, "Render colour of textured face as colour"); + uiDefButC(block, ROW, REDRAWVIEW3D, "Add", 660,100,60,19, &lasttface->transp, 2.0, 1.0, 0, 0, "Render face transparent and add colour of face"); + uiDefButC(block, ROW, REDRAWVIEW3D, "Alpha", 720,100,60,19, &lasttface->transp, 2.0, 2.0, 0, 0, "Render polygon transparent, depending on alpha channel of the texture"); + /* uiDefButC(block, ROW, REDRAWVIEW3D, "Sub", 780,100,60,19, &lasttface->transp, 2.0, 3.0, 0, 0); ,""*/ + + uiBlockSetCol(block, BUTSALMON); + uiDefBut(block, BUT, B_COPY_TF_MODE, "Copy DrawMode", 600,7,117,28, 0, 0, 0, 0, 0, "Copy the drawmode"); + uiDefBut(block, BUT, B_COPY_TF_UV, "Copy UV+tex", 721,7,85,28, 0, 0, 0, 0, 0, "Copy UV information and textures"); + uiDefBut(block, BUT, B_COPY_TF_COL, "Copy VertCol", 809,7,103,28, 0, 0, 0, 0, 0, "Copy vertex colours"); + } + +} + + +/* this is a mode context sensitive system */ + +void editing_panels() +{ + Object *ob; + Curve *cu; + MetaBall *mb; + Lattice *lt; + bArmature *arm; + Camera *cam; + + ob= OBACT; + if(ob==NULL) return; + + switch(ob->type) { + case OB_MESH: + editing_panel_materials(ob); // no editmode! + editing_panel_mesh_type(ob, ob->data); // no editmode! + /* modes */ + if(G.obedit) { + editing_panel_mesh_tools(ob, ob->data); // no editmode! + editing_panel_mesh_tools1(ob, ob->data); // no editmode! + } + else if(G.f & G_FACESELECT) { + editing_panel_mesh_texface(); + } + else if(G.f & (G_VERTEXPAINT | G_TEXTUREPAINT) ) { + editing_panel_mesh_paint(); + } + break; + + case OB_CURVE: + case OB_SURF: + cu= ob->data; + editing_panel_materials(ob); // no editmode! + editing_panel_curve_type(ob, cu); + if(G.obedit) { + editing_panel_curve_tools(ob, cu); + editing_panel_curve_tools1(ob, cu); + } + break; + + case OB_MBALL: + mb= ob->data; + editing_panel_materials(ob); // no editmode! + editing_panel_mball_type(ob, mb); + if(G.obedit) { + editing_panel_mball_tools(ob, mb); + } + break; + + case OB_FONT: + cu= ob->data; + editing_panel_materials(ob); // no editmode! + editing_panel_curve_type(ob, cu); + editing_panel_font_type(ob, cu); + break; + + case OB_LATTICE: + lt= ob->data; + editing_panel_lattice_type(ob, lt); + break; + + case OB_CAMERA: + cam= ob->data; + editing_panel_camera_type(ob, cam); + break; + + case OB_ARMATURE: + arm= ob->data; + editing_panel_armature_type(ob, arm); + if(G.obedit) { + editing_panel_armature_bones(ob, arm); + } + break; + } + +} diff --git a/source/blender/src/buttons_logic.c b/source/blender/src/buttons_logic.c new file mode 100644 index 00000000000..79d353d5945 --- /dev/null +++ b/source/blender/src/buttons_logic.c @@ -0,0 +1,2618 @@ +/** + * $Id: + * + * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. The Blender + * Foundation also sells licenses for use in proprietary software under + * the Blender License. See http://www.blender.org/BL/ for information + * about this. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL/BL DUAL LICENSE BLOCK ***** + */ + +#include +#include +#include + +#ifdef HAVE_CONFIG_H +#include +#endif + +#ifndef WIN32 +#include +#else +#include +#include "BLI_winstuff.h" +#endif + +#include "MEM_guardedalloc.h" + +#include "BLI_blenlib.h" +#include "BLI_arithb.h" +#include "BLI_editVert.h" + +#include "DNA_action_types.h" +#include "DNA_material_types.h" +#include "DNA_sensor_types.h" +#include "DNA_actuator_types.h" +#include "DNA_controller_types.h" +#include "DNA_property_types.h" +#include "DNA_object_types.h" +#include "DNA_screen_types.h" +#include "DNA_space_types.h" +#include "DNA_scene_types.h" +#include "DNA_sound_types.h" +#include "DNA_text_types.h" +#include "DNA_view3d_types.h" +#include "DNA_mesh_types.h" + +#include "BKE_library.h" +#include "BKE_global.h" +#include "BKE_main.h" +#include "BKE_sca.h" +#include "BKE_property.h" + +#include "BIF_gl.h" +#include "BIF_resources.h" +#include "BIF_space.h" +#include "BIF_interface.h" +#include "BIF_butspace.h" +#include "BIF_screen.h" +#include "BIF_keyval.h" +#include "BIF_editsound.h" + +#include "BDR_editcurve.h" +#include "BSE_buttons.h" + +#include "blendef.h" +#include "mydevice.h" +#include "interface.h" +#include "nla.h" /* For __NLA : Important, do not remove */ +#include "butspace.h" // own module + + +/* internals */ + +/****/ + +static ID **get_selected_and_linked_obs(short *count, short scavisflag); +static char *actuator_pup(Object *owner); + +/****/ + + +static void del_property(void *selpropv, void *data2_unused) +{ + bProperty *prop, *selprop= selpropv; + Object *ob; + int a=0; + + ob= OBACT; + if(ob==NULL) return; + + prop= ob->prop.first; + while(prop) { + if(prop==selprop) { + if (strcmp(prop->name,"Text") == 0) { + allqueue(REDRAWVIEW3D, 0); + } + BLI_remlink(&ob->prop, prop); + free_property(prop); + break; + } + a++; + prop= prop->next; + } + allqueue(REDRAWBUTSLOGIC, 0); + +} + +static int vergname(const void *v1, const void *v2) +{ + char **x1, **x2; + + x1= (char **)v1; + x2= (char **)v2; + + return strcmp(*x1, *x2); +} + +void make_unique_prop_names(char *str) +{ + Object *ob; + bProperty *prop; + bSensor *sens; + bController *cont; + bActuator *act; + ID **idar; + short a, obcount, propcount=0, nr; + char **names; + + /* this function is called by a Button, and gives the current + * stringpointer as an argument, this is the one that can change + */ + + idar= get_selected_and_linked_obs(&obcount, BUTS_SENS_SEL|BUTS_SENS_ACT|BUTS_ACT_SEL|BUTS_ACT_ACT|BUTS_CONT_SEL|BUTS_CONT_ACT); + + /* for each object, make properties and sca names unique */ + + /* count total names */ + for(a=0; aprop); + propcount+= BLI_countlist(&ob->sensors); + propcount+= BLI_countlist(&ob->controllers); + propcount+= BLI_countlist(&ob->actuators); + } + if(propcount==0) { + if(idar) MEM_freeN(idar); + return; + } + + /* make names array for sorting */ + names= MEM_callocN(propcount*sizeof(void *), "names"); + + /* count total names */ + nr= 0; + for(a=0; aprop.first; + while(prop) { + names[nr++]= prop->name; + prop= prop->next; + } + sens= ob->sensors.first; + while(sens) { + names[nr++]= sens->name; + sens= sens->next; + } + cont= ob->controllers.first; + while(cont) { + names[nr++]= cont->name; + cont= cont->next; + } + act= ob->actuators.first; + while(act) { + names[nr++]= act->name; + act= act->next; + } + } + + qsort(names, propcount, sizeof(void *), vergname); + + /* now we check for double names, and change them */ + + for(nr=0; nr0) { + /* now find out which object has this ... */ + base= FIRSTBASE; + while(base) { + + sens= base->object->sensors.first; + while(sens) { + if(sens == sens_to_delete) break; + sens= sens->next; + } + + if(sens) { + if( val==1 && sens->prev) { + BLI_remlink(&base->object->sensors, sens); + BLI_insertlinkbefore(&base->object->sensors, sens->prev, sens); + } + else if( val==2 && sens->next) { + BLI_remlink(&base->object->sensors, sens); + BLI_insertlink(&base->object->sensors, sens->next, sens); + } + allqueue(REDRAWBUTSLOGIC, 0); + break; + } + + base= base->next; + } + } +} + +static void sca_move_controller(void *datav, void *data2_unused) +{ + bController *controller_to_del= datav; + int val; + Base *base; + bController *cont; + + val= pupmenu("Move up%x1|Move down %x2"); + + if(val>0) { + /* now find out which object has this ... */ + base= FIRSTBASE; + while(base) { + + cont= base->object->controllers.first; + while(cont) { + if(cont == controller_to_del) break; + cont= cont->next; + } + + if(cont) { + if( val==1 && cont->prev) { + BLI_remlink(&base->object->controllers, cont); + BLI_insertlinkbefore(&base->object->controllers, cont->prev, cont); + } + else if( val==2 && cont->next) { + BLI_remlink(&base->object->controllers, cont); + BLI_insertlink(&base->object->controllers, cont->next, cont); + } + allqueue(REDRAWBUTSLOGIC, 0); + break; + } + + base= base->next; + } + } +} + +static void sca_move_actuator(void *datav, void *data2_unused) +{ + bActuator *actuator_to_move= datav; + int val; + Base *base; + bActuator *act; + + val= pupmenu("Move up%x1|Move down %x2"); + + if(val>0) { + /* now find out which object has this ... */ + base= FIRSTBASE; + while(base) { + + act= base->object->actuators.first; + while(act) { + if(act == actuator_to_move) break; + act= act->next; + } + + if(act) { + if( val==1 && act->prev) { + BLI_remlink(&base->object->actuators, act); + BLI_insertlinkbefore(&base->object->actuators, act->prev, act); + } + else if( val==2 && act->next) { + BLI_remlink(&base->object->actuators, act); + BLI_insertlink(&base->object->actuators, act->next, act); + } + allqueue(REDRAWBUTSLOGIC, 0); + break; + } + + base= base->next; + } + } +} + +void do_logic_buts(unsigned short event) +{ + bProperty *prop; + bSensor *sens; + bController *cont; + bActuator *act; + Base *base; + Object *ob; + int didit; + + ob= OBACT; + if(ob==0) return; + + switch(event) { + + case B_ADD_PROP: + prop= new_property(PROP_FLOAT); + make_unique_prop_names(prop->name); + BLI_addtail(&ob->prop, prop); + allqueue(REDRAWBUTSLOGIC, 0); + break; + + case B_CHANGE_PROP: + prop= ob->prop.first; + while(prop) { + if(prop->type!=prop->otype) { + init_property(prop); + if (strcmp(prop->name, "Text") == 0) { + allqueue(REDRAWVIEW3D, 0); + } + } + prop= prop->next; + } + allqueue(REDRAWBUTSLOGIC, 0); + break; + + case B_ADD_SENS: + base= FIRSTBASE; + while(base) { + if(base->object->scaflag & OB_ADDSENS) { + base->object->scaflag &= ~OB_ADDSENS; + sens= new_sensor(SENS_ALWAYS); + BLI_addtail(&(base->object->sensors), sens); + make_unique_prop_names(sens->name); + base->object->scaflag |= OB_SHOWSENS; + } + base= base->next; + } + + allqueue(REDRAWBUTSLOGIC, 0); + break; + + case B_CHANGE_SENS: + base= FIRSTBASE; + while(base) { + sens= base->object->sensors.first; + while(sens) { + if(sens->type != sens->otype) { + init_sensor(sens); + sens->otype= sens->type; + break; + } + sens= sens->next; + } + base= base->next; + } + allqueue(REDRAWBUTSLOGIC, 0); + break; + + case B_DEL_SENS: + base= FIRSTBASE; + while(base) { + sens= base->object->sensors.first; + while(sens) { + if(sens->flag & SENS_DEL) { + BLI_remlink(&(base->object->sensors), sens); + free_sensor(sens); + break; + } + sens= sens->next; + } + base= base->next; + } + allqueue(REDRAWBUTSLOGIC, 0); + break; + + case B_ADD_CONT: + base= FIRSTBASE; + while(base) { + if(base->object->scaflag & OB_ADDCONT) { + base->object->scaflag &= ~OB_ADDCONT; + cont= new_controller(CONT_LOGIC_AND); + make_unique_prop_names(cont->name); + base->object->scaflag |= OB_SHOWCONT; + BLI_addtail(&(base->object->controllers), cont); + } + base= base->next; + } + allqueue(REDRAWBUTSLOGIC, 0); + break; + + case B_CHANGE_CONT: + base= FIRSTBASE; + while(base) { + cont= base->object->controllers.first; + while(cont) { + if(cont->type != cont->otype) { + init_controller(cont); + cont->otype= cont->type; + break; + } + cont= cont->next; + } + base= base->next; + } + allqueue(REDRAWBUTSLOGIC, 0); + break; + + + case B_DEL_CONT: + base= FIRSTBASE; + while(base) { + cont= base->object->controllers.first; + while(cont) { + if(cont->flag & CONT_DEL) { + BLI_remlink(&(base->object->controllers), cont); + unlink_controller(cont); + free_controller(cont); + break; + } + cont= cont->next; + } + base= base->next; + } + allqueue(REDRAWBUTSLOGIC, 0); + break; + + case B_ADD_ACT: + base= FIRSTBASE; + while(base) { + if(base->object->scaflag & OB_ADDACT) { + base->object->scaflag &= ~OB_ADDACT; + act= new_actuator(ACT_OBJECT); + make_unique_prop_names(act->name); + BLI_addtail(&(base->object->actuators), act); + base->object->scaflag |= OB_SHOWACT; + } + base= base->next; + } + allqueue(REDRAWBUTSLOGIC, 0); + break; + + case B_CHANGE_ACT: + base= FIRSTBASE; + while(base) { + act= base->object->actuators.first; + while(act) { + if(act->type != act->otype) { + init_actuator(act); + act->otype= act->type; + break; + } + act= act->next; + } + base= base->next; + } + allqueue(REDRAWBUTSLOGIC, 0); + break; + + case B_DEL_ACT: + base= FIRSTBASE; + while(base) { + act= base->object->actuators.first; + while(act) { + if(act->flag & ACT_DEL) { + BLI_remlink(&(base->object->actuators), act); + unlink_actuator(act); + free_actuator(act); + break; + } + act= act->next; + } + base= base->next; + } + allqueue(REDRAWBUTSLOGIC, 0); + break; + + case B_SOUNDACT_BROWSE: + /* since we don't know which... */ + didit= 0; + base= FIRSTBASE; + while(base) + { + act= base->object->actuators.first; + while(act) + { + if(act->type==ACT_SOUND) + { + bSoundActuator *sa= act->data; + if(sa->sndnr) + { + bSound *sound= G.main->sound.first; + int nr= 1; + + while(sound) + { + if(nr==sa->sndnr) + break; + nr++; + sound= sound->id.next; + } + + if(sa->sound) + sa->sound->id.us--; + + sa->sound= sound; + + if(sound) + sound->id.us++; + + sa->sndnr= 0; + didit= 1; + } + } + act= act->next; + } + if(didit) + break; + base= base->next; + } + allqueue(REDRAWBUTSLOGIC, 0); + allqueue(REDRAWSOUND, 0); + + break; + + } +} + + +static char *sensor_name(int type) +{ + switch (type) { + case SENS_ALWAYS: + return "Always"; + case SENS_TOUCH: + return "Touch"; + case SENS_NEAR: + return "Near"; + case SENS_KEYBOARD: + return "Keyboard"; + case SENS_PROPERTY: + return "Property"; + case SENS_MOUSE: + return "Mouse"; + case SENS_COLLISION: + return "Collision"; + case SENS_RADAR: + return "Radar"; + case SENS_RANDOM: + return "Random"; + case SENS_RAY: + return "Ray"; + case SENS_MESSAGE: + return "Message"; + } + return "unknown"; +} + +static char *sensor_pup(void) +{ + /* the number needs to match defines in game.h */ + return "Sensors %t|Always %x0|Keyboard %x3|Mouse %x5|" + "Touch %x1|Collision %x6|Near %x2|Radar %x7|" + "Property %x4|Random %x8|Ray %x9|Message %x10"; +} + +static char *controller_name(int type) +{ + switch (type) { + case CONT_LOGIC_AND: + return "AND"; + case CONT_LOGIC_OR: + return "OR"; + case CONT_EXPRESSION: + return "Expression"; + case CONT_PYTHON: + return "Python"; + } + return "unknown"; +} + +static char *controller_pup(void) +{ + return "Controllers %t|AND %x0|OR %x1|Expression %x2|Python %x3"; +} + +static char *actuator_name(int type) +{ + switch (type) { + case ACT_ACTION: + return "Action"; + case ACT_OBJECT: + return "Motion"; + case ACT_IPO: + return "Ipo"; + case ACT_LAMP: + return "Lamp"; + case ACT_CAMERA: + return "Camera"; + case ACT_MATERIAL: + return "Material"; + case ACT_SOUND: + return "Sound"; + case ACT_CD: + return "CD"; + case ACT_PROPERTY: + return "Property"; + case ACT_EDIT_OBJECT: + return "Edit Object"; + case ACT_CONSTRAINT: + return "Constraint"; + case ACT_SCENE: + return "Scene"; + case ACT_GROUP: + return "Group"; + case ACT_RANDOM: + return "Random"; + case ACT_MESSAGE: + return "Message"; + case ACT_GAME: + return "Game"; + case ACT_VISIBILITY: + return "Game"; + } + return "unknown"; +} + + + + +static char *actuator_pup(Object *owner) +{ + switch (owner->type) + { + case OB_ARMATURE: + return "Actuators %t|Action %x15|Motion %x0|Constraint %x9|Ipo %x1" + "|Camera %x3|Sound %x5|Property %x6|Edit Object %x10" + "|Scene %x11|Random %x13|Message %x14|CD %x16|Game %x17" + "|Visibility %x18"; + break; + default: + return "Actuators %t|Motion %x0|Constraint %x9|Ipo %x1" + "|Camera %x3|Sound %x5|Property %x6|Edit Object %x10" + "|Scene %x11|Random %x13|Message %x14|CD %x16|Game %x17" + "|Visibility %x18"; + } +} + + + +static void set_sca_ob(Object *ob) +{ + bController *cont; + bActuator *act; + + cont= ob->controllers.first; + while(cont) { + cont->mynew= (bController *)ob; + cont= cont->next; + } + act= ob->actuators.first; + while(act) { + act->mynew= (bActuator *)ob; + act= act->next; + } +} + +static ID **get_selected_and_linked_obs(short *count, short scavisflag) +{ + Base *base; + Object *ob, *obt; + ID **idar; + bSensor *sens; + bController *cont; + unsigned int lay; + int a, nr, doit; + + /* we need a sorted object list */ + /* set scavisflags flags in Objects to indicate these should be evaluated */ + /* also hide ob pointers in ->new entries of controllerss/actuators */ + + *count= 0; + + if(G.scene==NULL) return NULL; + + ob= G.main->object.first; + while(ob) { + ob->scavisflag= 0; + set_sca_ob(ob); + ob= ob->id.next; + } + + if(G.vd) lay= G.vd->lay; + else lay= G.scene->lay; + + base= FIRSTBASE; + while(base) { + if(base->lay & lay) { + if(base->flag & SELECT) { + if(scavisflag & BUTS_SENS_SEL) base->object->scavisflag |= OB_VIS_SENS; + if(scavisflag & BUTS_CONT_SEL) base->object->scavisflag |= OB_VIS_CONT; + if(scavisflag & BUTS_ACT_SEL) base->object->scavisflag |= OB_VIS_ACT; + } + } + base= base->next; + } + + if(OBACT) { + if(scavisflag & BUTS_SENS_ACT) OBACT->scavisflag |= OB_VIS_SENS; + if(scavisflag & BUTS_CONT_ACT) OBACT->scavisflag |= OB_VIS_CONT; + if(scavisflag & BUTS_ACT_ACT) OBACT->scavisflag |= OB_VIS_ACT; + } + + if(scavisflag & (BUTS_SENS_LINK|BUTS_CONT_LINK|BUTS_ACT_LINK)) { + doit= 1; + while(doit) { + doit= 0; + + ob= G.main->object.first; + while(ob) { + + /* 1st case: select sensor when controller selected */ + if((scavisflag & BUTS_SENS_LINK) && (ob->scavisflag & OB_VIS_SENS)==0) { + sens= ob->sensors.first; + while(sens) { + for(a=0; atotlinks; a++) { + if(sens->links[a]) { + obt= (Object *)sens->links[a]->mynew; + if(obt && (obt->scavisflag & OB_VIS_CONT)) { + doit= 1; + ob->scavisflag |= OB_VIS_SENS; + break; + } + } + } + if(doit) break; + sens= sens->next; + } + } + + /* 2nd case: select cont when act selected */ + if((scavisflag & BUTS_CONT_LINK) && (ob->scavisflag & OB_VIS_CONT)==0) { + cont= ob->controllers.first; + while(cont) { + for(a=0; atotlinks; a++) { + if(cont->links[a]) { + obt= (Object *)cont->links[a]->mynew; + if(obt && (obt->scavisflag & OB_VIS_ACT)) { + doit= 1; + ob->scavisflag |= OB_VIS_CONT; + break; + } + } + } + if(doit) break; + cont= cont->next; + } + } + + /* 3rd case: select controller when sensor selected */ + if((scavisflag & BUTS_CONT_LINK) && (ob->scavisflag & OB_VIS_SENS)) { + sens= ob->sensors.first; + while(sens) { + for(a=0; atotlinks; a++) { + if(sens->links[a]) { + obt= (Object *)sens->links[a]->mynew; + if(obt && (obt->scavisflag & OB_VIS_CONT)==0) { + doit= 1; + obt->scavisflag |= OB_VIS_CONT; + } + } + } + sens= sens->next; + } + } + + /* 4th case: select actuator when controller selected */ + if( (scavisflag & BUTS_ACT_LINK) && (ob->scavisflag & OB_VIS_CONT)) { + cont= ob->controllers.first; + while(cont) { + for(a=0; atotlinks; a++) { + if(cont->links[a]) { + obt= (Object *)cont->links[a]->mynew; + if(obt && (obt->scavisflag & OB_VIS_ACT)==0) { + doit= 1; + obt->scavisflag |= OB_VIS_ACT; + } + } + } + cont= cont->next; + } + + } + ob= ob->id.next; + } + } + } + + /* now we count */ + ob= G.main->object.first; + while(ob) { + if( ob->scavisflag ) (*count)++; + ob= ob->id.next; + } + + if(*count==0) return NULL; + if(*count>24) *count= 24; /* temporal */ + + idar= MEM_callocN( (*count)*sizeof(void *), "idar"); + + ob= G.main->object.first; + nr= 0; + while(ob) { + if( ob->scavisflag ) { + idar[nr]= (ID *)ob; + nr++; + } + if(nr>=24) break; + ob= ob->id.next; + } + + /* just to be sure... these were set in set_sca_done_ob() */ + clear_sca_new_poins(); + + return idar; +} + + +static BIFColorID get_col_sensor(int type) +{ + switch(type) { + case SENS_ALWAYS: return BUTACTION; + case SENS_TOUCH: return BUTCAMERA; + case SENS_COLLISION: return BUTCAMERA; + case SENS_NEAR: return BUTRANDOM; + case SENS_KEYBOARD: return BUTIPO; + case SENS_PROPERTY: return BUTPROPERTY; + case SENS_MOUSE: return BUTAUDIO; + case SENS_RADAR: return BUTEDITOBJECT; + case SENS_RANDOM: return BUTSCENE; + case SENS_RAY: return BUTMOTION; + case SENS_MESSAGE: return BUTMESSAGE; + default: return BUTGREY; + } +} +static void set_col_sensor(int type, int medium) +{ + BIFColorID col= get_col_sensor(type); + BIF_set_color(col, medium?COLORSHADE_LIGHT:COLORSHADE_MEDIUM); +} + +/** + * Draws a toggle for pulse mode, a frequency fiels and a toggle to invert + * the value of this sensor. Operates on the shared data block of sensors. + */ +static void draw_default_sensor_header(bSensor *sens, + uiBlock *block, + short x, + short y, + short w) +{ + /* Pulsing and frequency */ + uiDefIconButS(block, TOG|BIT|0, 1, ICON_DOTSUP, + (short)(x + 10), (short)(y - 19), (short)(0.15 * (w-20)), 19, + &sens->pulse, 0.0, 0.0, 0, 0, + "Activate TRUE pulse mode"); + uiDefIconButS(block, TOG|BIT|2, 1, ICON_DOTSDOWN, + (short)(x + 10 + 0.15 * (w-20)), (short)(y - 19), (short)(0.15 * (w-20)), 19, + &sens->pulse, 0.0, 0.0, 0, 0, + "Activate FALSE pulse mode"); + uiDefButS(block, NUM, 1, "f:", + (short)(x + 10 + 0.3 * (w-20)), (short)(y - 19), (short)(0.275 * (w-20)), 19, + &sens->freq, 0.0, 10000.0, 0, 0, + "Frequency of pulses (in 1/50 sec)"); + + /* value or shift? */ + uiDefButS(block, TOG, 1, "Inv", + (short)(x + 10 + 0.85 * (w-20)), (short)(y - 19), (short)(0.15 * (w-20)), 19, + &sens->invert, 1.0, SENS_NOT, 0, 0, + "Invert the output of this sensor"); +} + +static short draw_sensorbuttons(bSensor *sens, uiBlock *block, short xco, short yco, short width,char* objectname) +{ + bNearSensor *ns = NULL; + bTouchSensor *ts = NULL; + bKeyboardSensor *ks = NULL; + bPropertySensor *ps = NULL; + bMouseSensor *ms = NULL; + bCollisionSensor *cs = NULL; + bRadarSensor *rs = NULL; + bRandomSensor *randomSensor = NULL; + bRaySensor *raySens = NULL; + bMessageSensor *mes = NULL; + short ysize; + char *str; + + /* yco is at the top of the rect, draw downwards */ + + uiBlockSetEmboss(block, UI_EMBOSSW); + + set_col_sensor(sens->type, 0); + + switch (sens->type) + { + case SENS_ALWAYS: + { + ysize= 24; + + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + draw_default_sensor_header(sens, block, xco, yco, width); + + yco-= ysize; + + break; + } + case SENS_TOUCH: + { + ysize= 48; + + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + draw_default_sensor_header(sens, block, xco, yco, width); + + ts= sens->data; + + /* uiDefBut(block, TEX, 1, "Property:", xco,yco-22,width, 19, &ts->name, 0, 31, 0, 0, "Only look for Objects with this property"); */ + uiDefIDPoinBut(block, test_matpoin_but, 1, "MA:",(short)(xco + 10),(short)(yco-44), (short)(width - 20), 19, &ts->ma, "Only look for floors with this Material"); + ///* uiDefButF(block, NUM, 1, "Margin:", xco+width/2,yco-44,width/2, 19, &ts->dist, 0.0, 10.0, 100, 0, "Extra margin (distance) for larger sensitivity"); + yco-= ysize; + break; + } + case SENS_COLLISION: + { + ysize= 48; + + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + draw_default_sensor_header(sens, block, xco, yco, width); + cs= sens->data; + + /* The collision sensor will become a generic collision (i.e. it */ + /* absorb the old touch sensor). */ + uiDefButS(block, TOG|BIT|0, B_REDR, "M/P",(short)(xco + 10),(short)(yco - 44), + (short)(0.20 * (width-20)), 19, &cs->mode, 0.0, 0.0, 0, 0, + "Toggle collision on material or property."); + + if (cs->mode & SENS_COLLISION_MATERIAL) { + uiDefBut(block, TEX, 1, "Material:", (short)(xco + 10 + 0.20 * (width-20)), + (short)(yco-44), (short)(0.8*(width-20)), 19, &cs->materialName, 0, 31, 0, 0, + "Only look for Objects with this material"); + } else { + uiDefBut(block, TEX, 1, "Property:", (short)(xco + 10 + 0.20 * (width-20)), (short)(yco-44), + (short)(0.8*(width-20)), 19, &cs->name, 0, 31, 0, 0, + "Only look for Objects with this property"); + } + + /* uiDefButS(block, NUM, 1, "Damp:", xco+10+width-90,yco-24, 70, 19, &cs->damp, 0, 250, 0, 0, "For 'damp' time don't detect another collision"); */ + + yco-= ysize; + break; + } + case SENS_NEAR: + { + ysize= 72; + + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + draw_default_sensor_header(sens, block, xco, yco, width); + ns= sens->data; + + uiDefBut(block, TEX, 1, "Property:",(short)(10+xco),(short)(yco-44), (short)(width-20), 19, + &ns->name, 0, 31, 0, 0, "Only look for Objects with this property"); + uiDefButF(block, NUM, 1, "Dist",(short)(10+xco),(short)(yco-68),(short)((width-22)/2), 19, + &ns->dist, 0.0, 1000.0, 1000, 0, "Trigger distance"); + uiDefButF(block, NUM, 1, "Reset",(short)(10+xco+(width-22)/2), (short)(yco-68), (short)((width-22)/2), 19, + &ns->resetdist, 0.0, 1000.0, 1000, 0, "Reset distance"); + yco-= ysize; + break; + } + case SENS_RADAR: + { + ysize= 72; + + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + draw_default_sensor_header(sens, block, xco, yco, width); + + rs= sens->data; + + uiDefBut(block, TEX, 1, "Prop:", + (short)(10+xco),(short)(yco-44), (short)(0.7 * (width-20)), 19, + &rs->name, 0, 31, 0, 0, + "Only look for Objects with this property"); + uiDefButS(block, ROW, 1, "X", + (short)(10+xco+0.7 * (width-20)),(short)(yco-44), (short)(0.1 * (width-22)),19, + &rs->axis, 2.0, 0, 0, 0, + "Cast the cone along the object's positive x-axis"); + uiDefButS(block, ROW, 1, "Y", + (short)(10+xco+0.8 * (width-20)),(short)(yco-44),(short)(0.1 * (width-22)), 19, + &rs->axis, 2.0, 1, 0, 0, + "Cast the cone along the object's positive y-axis"); + uiDefButS(block, ROW, 1, "Z", + (short)(10+xco+0.9 * (width-20)), (short)(yco-44), (short)(0.1 * (width-22)), 19, + &rs->axis, 2.0, 2, 0, 0, + "Cast the cone along the object's positive z-axis"); + uiDefButF(block, NUM, 1, "Ang:", + (short)(10+xco), (short)(yco-68), (short)((width-20)/2), 19, + &rs->angle, 0.0, 179.9, 10, 0, + "Opening angle of the radar cone."); + uiDefButF(block, NUM, 1, "Dist:", + (short)(xco+10 + (width-20)/2), (short)(yco-68), (short)((width-20)/2), 19, + &rs->range, 0.01, 10000.0, 100, 0, + "Depth of the radar cone"); + yco-= ysize; + break; + } + case SENS_KEYBOARD: + { + /* 5 lines: 120 height */ + ysize= 120; + + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + /* header line */ + draw_default_sensor_header(sens, block, xco, yco, width); + ks= sens->data; + + /* line 2: hotkey and allkeys toggle */ + uiDefKeyevtButS(block, B_DIFF, "", xco+40, yco-44, (width)/2, 19, &ks->key, "Key code"); + + /* line 3: two key modifyers (qual1, qual2) */ + uiDefKeyevtButS(block, B_DIFF, "", xco+40, yco-68, (width-50)/2, 19, &ks->qual, "Modifier key code"); + uiDefKeyevtButS(block, B_DIFF, "", xco+40+(width-50)/2, yco-68, (width-50)/2, 19, &ks->qual2, "Second Modifier key code"); + + /* labels for line 1 and 2 */ + uiDefBut(block, LABEL, 0, "Key", xco, yco-44, 40, 19, NULL, 0, 0, 0, 0, ""); + uiDefBut(block, LABEL, 0, "Hold", xco, yco-68, 40, 19, NULL, 0, 0, 0, 0, ""); + + /* part of line 1 */ + uiBlockSetCol(block, BUTPURPLE); + uiDefButS(block, TOG|BIT|0, 0, "All keys", xco+40+(width/2), yco-44, (width/2)-50, 19, + &ks->type, 0, 0, 0, 0, ""); + + /* line 4: toggle property for string logging mode */ + uiDefBut(block, TEX, 1, "LogToggle: ", + xco+10, yco-92, (width-20), 19, + ks->toggleName, 0, 31, 0, 0, + "Property that indicates whether to log " + "keystrokes as a string."); + + /* line 5: target property for string logging mode */ + uiDefBut(block, TEX, 1, "Target: ", + xco+10, yco-116, (width-20), 19, + ks->targetName, 0, 31, 0, 0, + "Property that receives the keystrokes in case " + "a string is logged."); + + yco-= ysize; + break; + } + case SENS_PROPERTY: + { + ysize= 96; + + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, + (float)xco+width, (float)yco, 1); + + draw_default_sensor_header(sens, block, xco, yco, width); + ps= sens->data; + + str= "Type %t|Equal %x0|Not Equal %x1|Interval %x2|Changed %x3"; + /* str= "Type %t|Equal %x0|Not Equal %x1"; */ + uiDefButI(block, MENU, B_REDR, str, xco+30,yco-44,width-60, 19, + &ps->type, 0, 31, 0, 0, "Type"); + + if (ps->type != SENS_PROP_EXPRESSION) + { + uiDefBut(block, TEX, 1, "Prop: ", xco+30,yco-68,width-60, 19, + ps->name, 0, 31, 0, 0, "Property name"); + } + + if(ps->type == SENS_PROP_INTERVAL) + { + uiDefBut(block, TEX, 1, "Min: ", xco,yco-92,width/2, 19, + ps->value, 0, 31, 0, 0, "test for value"); + uiDefBut(block, TEX, 1, "Max: ", xco+width/2,yco-92,width/2, 19, + ps->maxvalue, 0, 31, 0, 0, "test for max value"); + } + else if(ps->type == SENS_PROP_CHANGED); + else + { + uiDefBut(block, TEX, 1, "Value: ", xco+30,yco-92,width-60, 19, + ps->value, 0, 31, 0, 0, "test for value"); + } + + yco-= ysize; + break; + } + case SENS_MOUSE: + { + ms= sens->data; + /* Two lines: 48 pixels high. */ + ysize = 48; + + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + /* line 1: header */ + draw_default_sensor_header(sens, block, xco, yco, width); + + /* Line 2: type selection. The number are a bit mangled to get + * proper compatibility with older .blend files. */ + str= "Type %t|Left button %x1|Middle button %x2|" + "Right button %x4|Movement %x8|Mouse over %x16"; + uiDefButS(block, MENU, B_REDR, str, xco+10, yco-44, width-20, 19, + &ms->type, 0, 31, 0, 0, + "Specify the type of event this mouse sensor should trigger on."); + + yco-= ysize; + break; + } + case SENS_RANDOM: + { + ysize = 48; + + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + draw_default_sensor_header(sens, block, xco, yco, width); + randomSensor = sens->data; + /* some files were wrongly written, avoid crash now */ + if (randomSensor) + { + uiDefButI(block, NUM, 1, "Seed: ", xco+10,yco-44,(width-20), 19, + &randomSensor->seed, 0, 1000, 0, 0, + "Initial seed of the generator. (Choose 0 for not random)"); + } + yco-= ysize; + break; + } + case SENS_RAY: + { + ysize = 72; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + draw_default_sensor_header(sens, block, xco, yco, width); + raySens = sens->data; + + /* 1. property or material */ + uiDefButS(block, TOG|BIT|0, B_REDR, "M/P", + xco + 10,yco - 44, 0.20 * (width-20), 19, + &raySens->mode, 0.0, 0.0, 0, 0, + "Toggle collision on material or property."); + + if (raySens->mode & SENS_COLLISION_MATERIAL) + { + uiDefBut(block, TEX, 1, "Material:", xco + 10 + 0.20 * (width-20), yco-44, 0.8*(width-20), 19, + &raySens->matname, 0, 31, 0, 0, + "Only look for Objects with this material"); + } + else + { + uiDefBut(block, TEX, 1, "Property:", xco + 10 + 0.20 * (width-20), yco-44, 0.8*(width-20), 19, + &raySens->propname, 0, 31, 0, 0, + "Only look for Objects with this property"); + } + + /* 2. sensing range */ + uiDefButF(block, NUM, 1, "Range", xco+10, yco-68, 0.6 * (width-20), 19, + &raySens->range, 0.01, 10000.0, 100, 0, + "Sense objects no farther than this distance"); + + /* 3. axis choice */ + str = "Type %t|+ X axis %x1|+ Y axis %x0|+ Z axis %x2|- X axis %x3|- Y axis %x4|- Z axis %x5"; + uiDefButI(block, MENU, B_REDR, str, xco+10 + 0.6 * (width-20), yco-68, 0.4 * (width-20), 19, + &raySens->axisflag, 2.0, 31, 0, 0, + "Specify along which axis the ray is cast."); + + yco-= ysize; + break; + } + case SENS_MESSAGE: + { + mes = sens->data; + ysize = 2 * 24; /* total number of lines * 24 pixels/line */ + + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, + (float)xco+width, (float)yco, 1); + + /* line 1: header line */ + draw_default_sensor_header(sens, block, xco, yco, width); + + /* line 2: Subject filter */ + uiDefBut(block, TEX, 1, "Subject: ", + (xco+10), (yco-44), (width-20), 19, + mes->subject, 0, 31, 0, 0, + "Optional subject filter: only accept messages with this subject" + ", or empty for all"); + + yco -= ysize; + break; + } + } + + uiBlockSetEmboss(block, UI_EMBOSSM); + uiBlockSetCol(block, BUTGREY); + + return yco-4; +} + + + +static short draw_controllerbuttons(bController *cont, uiBlock *block, short xco, short yco, short width) +{ + bExpressionCont *ec; + bPythonCont *pc; + short ysize; + + uiBlockSetEmboss(block, UI_EMBOSSW); + + switch (cont->type) { + case CONT_EXPRESSION: + ysize= 28; + + BIF_set_color(BUTPROPERTY, COLORSHADE_GREY); + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + /* uiDefBut(block, LABEL, 1, "Not yet...", xco,yco-24,80, 19, NULL, 0, 0, 0, 0, ""); */ + ec= cont->data; + /* uiDefBut(block, BUT, 1, "Variables", xco,yco-24,80, 19, NULL, 0, 0, 0, 0, "Available variables for expression"); */ + uiDefBut(block, TEX, 1, "Exp:", xco + 10 , yco-21, width-20, 19, + ec->str, 0, 127, 0, 0, + "Expression"); + + yco-= ysize; + break; + case CONT_PYTHON: + ysize= 28; + + if(cont->data==NULL) init_controller(cont); + pc= cont->data; + + BIF_set_color(BUTMESSAGE, COLORSHADE_GREY); + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + uiDefIDPoinBut(block, test_scriptpoin_but, 1, "Script: ", xco+45,yco-24,width-90, 19, &pc->text, ""); + + yco-= ysize; + break; + + default: + ysize= 4; + + BIF_set_color(BUTIPO, COLORSHADE_GREY); + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + yco-= ysize; + } + + uiBlockSetEmboss(block, UI_EMBOSSM); + uiBlockSetCol(block, BUTGREY); + + return yco; +} + +static BIFColorID get_col_actuator(int type) +{ + switch(type) { + case ACT_ACTION: return BUTACTION; + case ACT_OBJECT: return BUTMOTION; + case ACT_IPO: return BUTIPO; + case ACT_PROPERTY: return BUTPROPERTY; + case ACT_SOUND: return BUTAUDIO; + case ACT_CD: return BUTCD; + case ACT_CAMERA: return BUTCAMERA; + case ACT_EDIT_OBJECT: return BUTEDITOBJECT; + case ACT_GROUP: return BUTYELLOW; + case ACT_RANDOM: return BUTRANDOM; + case ACT_SCENE: return BUTSCENE; + case ACT_MESSAGE: return BUTMESSAGE; + case ACT_GAME: return BUTGAME; + case ACT_VISIBILITY: return BUTVISIBILITY; + default: return BUTGREY; + } +} +static void set_col_actuator(int item, int medium) +{ + if (item==ACT_CONSTRAINT) { + BIF_set_color(BUTRUST, medium?COLORSHADE_HILITE:COLORSHADE_MEDIUM); + } else { + BIFColorID col= get_col_actuator(item); + BIF_set_color(col, medium?COLORSHADE_MEDIUM:COLORSHADE_GREY); + } +} + +static short draw_actuatorbuttons(bActuator *act, uiBlock *block, short xco, short yco, short width) +{ + bSoundActuator *sa = NULL; + bCDActuator *cda = NULL; + bObjectActuator *oa = NULL; + bIpoActuator *ia = NULL; + bPropertyActuator *pa = NULL; + bCameraActuator *ca = NULL; + bEditObjectActuator *eoa = NULL; + bConstraintActuator *coa = NULL; + bSceneActuator *sca = NULL; + bGroupActuator *ga = NULL; + bRandomActuator *randAct = NULL; + bMessageActuator *ma = NULL; + bActionActuator *aa = NULL; + bGameActuator *gma = NULL; + bVisibilityActuator *visAct = NULL; + + float *fp; + short ysize = 0, wval; + char *str; + int myline; + + /* yco is at the top of the rect, draw downwards */ + uiBlockSetEmboss(block, UI_EMBOSSW); + set_col_actuator(act->type, 0); + + switch (act->type) + { + case ACT_OBJECT: + { + ysize= 129; + + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + uiBlockSetCol(block, BUTGREY); + + oa = act->data; + wval = (width-100)/3; + + uiDefBut(block, LABEL, 0, "Force", xco, yco-22, 55, 19, NULL, 0, 0, 0, 0, "Sets the force"); + uiDefButF(block, NUM, 0, "", xco+45, yco-22, wval, 19, oa->forceloc, -10000.0, 10000.0, 10, 0, ""); + uiDefButF(block, NUM, 0, "", xco+45+wval, yco-22, wval, 19, oa->forceloc+1, -10000.0, 10000.0, 10, 0, ""); + uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-22, wval, 19, oa->forceloc+2, -10000.0, 10000.0, 10, 0, ""); + + uiDefBut(block, LABEL, 0, "Torque", xco, yco-41, 55, 19, NULL, 0, 0, 0, 0, "Sets the torque"); + uiDefButF(block, NUM, 0, "", xco+45, yco-41, wval, 19, oa->forcerot, -10000.0, 10000.0, 10, 0, ""); + uiDefButF(block, NUM, 0, "", xco+45+wval, yco-41, wval, 19, oa->forcerot+1, -10000.0, 10000.0, 10, 0, ""); + uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-41, wval, 19, oa->forcerot+2, -10000.0, 10000.0, 10, 0, ""); + + uiDefBut(block, LABEL, 0, "dLoc", xco, yco-64, 45, 19, NULL, 0, 0, 0, 0, "Sets the dLoc"); + uiDefButF(block, NUM, 0, "", xco+45, yco-64, wval, 19, oa->dloc, -10000.0, 10000.0, 10, 0, ""); + uiDefButF(block, NUM, 0, "", xco+45+wval, yco-64, wval, 19, oa->dloc+1, -10000.0, 10000.0, 10, 0, ""); + uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-64, wval, 19, oa->dloc+2, -10000.0, 10000.0, 10, 0, ""); + + uiDefBut(block, LABEL, 0, "dRot", xco, yco-83, 45, 19, NULL, 0, 0, 0, 0, "Sets the dRot"); + uiDefButF(block, NUM, 0, "", xco+45, yco-83, wval, 19, oa->drot, -10000.0, 10000.0, 10, 0, ""); + uiDefButF(block, NUM, 0, "", xco+45+wval, yco-83, wval, 19, oa->drot+1, -10000.0, 10000.0, 10, 0, ""); + uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-83, wval, 19, oa->drot+2, -10000.0, 10000.0, 10, 0, ""); + + uiDefBut(block, LABEL, 0, "linV", xco, yco-106, 45, 19, NULL, 0, 0, 0, 0, "Sets the linear velocity"); + uiDefButF(block, NUM, 0, "", xco+45, yco-106, wval, 19, oa->linearvelocity, -10000.0, 10000.0, 10, 0, ""); + uiDefButF(block, NUM, 0, "", xco+45+wval, yco-106, wval, 19, oa->linearvelocity+1, -10000.0, 10000.0, 10, 0, ""); + uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-106, wval, 19, oa->linearvelocity+2, -10000.0, 10000.0, 10, 0, ""); + + uiDefBut(block, LABEL, 0, "angV", xco, yco-125, 45, 19, NULL, 0, 0, 0, 0, "Sets the angular velocity"); + uiDefButF(block, NUM, 0, "", xco+45, yco-125, wval, 19, oa->angularvelocity, -10000.0, 10000.0, 10, 0, ""); + uiDefButF(block, NUM, 0, "", xco+45+wval, yco-125, wval, 19, oa->angularvelocity+1, -10000.0, 10000.0, 10, 0, ""); + uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-125, wval, 19, oa->angularvelocity+2, -10000.0, 10000.0, 10, 0, ""); + + uiBlockSetCol(block, BUTGREEN); + uiDefButI(block, TOG|BIT|0, 0, "L", xco+45+3*wval, yco-22, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation"); + uiDefButI(block, TOG|BIT|1, 0, "L", xco+45+3*wval, yco-41, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation"); + uiDefButI(block, TOG|BIT|2, 0, "L", xco+45+3*wval, yco-64, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation"); + uiDefButI(block, TOG|BIT|3, 0, "L", xco+45+3*wval, yco-83, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation"); + uiDefButI(block, TOG|BIT|4, 0, "L", xco+45+3*wval, yco-106, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation"); + uiDefButI(block, TOG|BIT|5, 0, "L", xco+45+3*wval, yco-125, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation"); + + uiBlockSetCol(block, BUTGREEN); + uiDefButI(block, TOG|BIT|6, 0, "add",xco+45+3*wval+15, yco-106, 35, 19, &oa->flag, 0.0, 0.0, 0, 0, "Toggles between ADD and SET linV"); + uiBlockSetCol(block, BUTGREY); + + yco-= ysize; + break; + } + case ACT_ACTION: + { + /* DrawAct */ +#ifdef __NLA_ACTION_BY_MOTION_ACTUATOR + ysize = 112; +#else + ysize= 92; +#endif + + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + aa = act->data; + wval = (width-60)/3; + + uiBlockSetCol(block, BUTGREY); + // str= "Action types %t|Play %x0|Ping Pong %x1|Flipper %x2|Loop Stop %x3|Loop End %x4|Property %x6"; +#ifdef __NLA_ACTION_BY_MOTION_ACTUATOR + str= "Action types %t|Play %x0|Flipper %x2|Loop Stop %x3|Loop End %x4|Property %x6|Displacement %x7"; +#else + str= "Action types %t|Play %x0|Flipper %x2|Loop Stop %x3|Loop End %x4|Property %x6"; +#endif + uiDefButS(block, MENU, B_REDR, str, xco+30, yco-24, width-60, 19, &aa->type, 0.0, 0.0, 0.0, 0.0, "Action playback type"); + uiDefIDPoinBut(block, test_actionpoin_but, 1, "AC: ", xco+30, yco-44, width-60, 19, &aa->act, "Action name"); + + if(aa->type == ACT_ACTION_FROM_PROP) + { + uiDefBut(block, TEX, 0, "Prop: ",xco+30, yco-64, width-60, 19, aa->name, 0.0, 31.0, 0, 0, "Use this property to define the Action position"); + } + else + { + uiDefButS(block, NUM, 0, "Sta: ",xco+30, yco-64, (width-60)/2, 19, &aa->sta, 0.0, 18000.0, 0, 0, "Start frame"); + uiDefButS(block, NUM, 0, "End: ",xco+30+(width-60)/2, yco-64, (width-60)/2, 19, &aa->end, 0.0, 18000.0, 0, 0, "End frame"); + } + + + + uiDefButS(block, NUM, 0, "Blendin: ", xco+30, yco-84, (width-60)/2, 19, &aa->blendin, 0.0, 18000.0, 0.0, 0.0, "Number of frames of motion blending"); + uiDefButS(block, NUM, 0, "Priority: ", xco+30+(width-60)/2, yco-84, (width-60)/2, 19, &aa->priority, 0.0, 100.0, 0.0, 0.0, "Execution priority - lower numbers will override actions with higher numbers"); + +#ifdef __NLA_ACTION_BY_MOTION_ACTUATOR + if(aa->type == ACT_ACTION_MOTION) + { + uiDefButF(block, NUM, 0, "Cycle: ",xco+30, yco-104, (width-60)/2, 19, &aa->stridelength, 0.0, 2500.0, 0, 0, "Distance covered by a single cycle of the action"); + } +#endif + + yco-=ysize; + break; + } + case ACT_IPO: + { + ia= act->data; + + if(ia->type==ACT_IPO_KEY2KEY) + ysize= 72; + else + ysize= 52; + + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + str = "Ipo types %t|Play %x0|Ping Pong %x1|Flipper %x2|Loop Stop %x3|Loop End %x4|Property %x6"; + + uiDefButS(block, MENU, B_REDR, str, xco+20, yco-24, width-40 - (width-40)/3, 19, &ia->type, 0, 0, 0, 0, ""); + uiBlockSetCol(block, BUTGREEN); + uiDefButS(block, TOG|BIT|ACT_IPOCHILD_BIT, B_REDR, + "Child", xco+20+0.666*(width-40), yco-24, (width-40)/3, 19, + &ia->flag, 0, 0, 0, 0, + "Add all children Objects as well"); + uiBlockSetCol(block, BUTGREY); + /* + Key2key was disabled.... the settings below should not be reused without + thought, because they interfere with other variables. + + if(ia->type==ACT_IPO_KEY2KEY) { + uiBlockSetCol(block, BUTGREEN); + + uiDefButS(block, TOG|BIT|0, 0, "Prev", xco+20, yco-44, (width-40)/3, 19, &ia->flag, 0, 0, 0, 0, "Play backwards"); + uiDefButS(block, TOG|BIT|1, 0, "Cycl", xco+20+(width-40)/3, yco-44, (width-40)/3, 19, &ia->flag, 0, 0, 0, 0, "Play cyclic"); + uiDefButS(block, TOG|BIT|3, 0, "Hold", xco+20+2*(width-40)/3, yco-44, (width-40)/3, 19, &ia->flag, 0, 0, 0, 0, "Keep playing while activated"); + + uiDefBut(block, TEX, 0, "Prop: ", xco+20, yco-66, width-40, 19, ia->name, 0.0, 31.0, 0, 0, "Set property to key position"); + } else + */ + if(ia->type==ACT_IPO_FROM_PROP) { + uiDefBut(block, TEX, 0, + "Prop: ", xco+20, yco-44, width-40, 19, + ia->name, 0.0, 31.0, 0, 0, + "Use this property to define the Ipo position"); + } + else { + uiDefButS(block, NUM, 0, + "Sta", xco+20, yco-44, (width-100)/2, 19, + &ia->sta, 0.0, 18000.0, 0, 0, + "Start frame"); + uiDefButS(block, NUM, 0, + "End", xco+18+(width-90)/2, yco-44, (width-100)/2, 19, + &ia->end, 0.0, 18000.0, 0, 0, + "End frame"); + + uiBlockSetCol(block, BUTGREEN); + uiDefButS(block, TOG|BIT|ACT_IPOFORCE_BIT, B_REDR, + "Force", xco+width-78, yco-44, 43, 19, + &ia->flag, 0, 0, 0, 0, + "Convert Ipo to force"); + + /* Only show the do-force-local toggle if force is requested */ + if (ia->flag & ACT_IPOFORCE) { + uiDefButS(block, TOG|BIT|ACT_IPOFORCE_LOCAL_BIT, 0, + "L", xco+width-35, yco-44, 15, 19, + &ia->flag, 0, 0, 0, 0, + "Let the force-ipo act in local coordinates."); + } + + } + yco-= ysize; + break; + } + case ACT_PROPERTY: + { + ysize= 68; + + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + pa= act->data; + + str= "Type %t|Assign %x0|Add %x1|Copy %x2"; + uiDefButI(block, MENU, B_REDR, str, xco+30,yco-24,width-60, 19, &pa->type, 0, 31, 0, 0, "Type"); + + uiDefBut(block, TEX, 1, "Prop: ", xco+30,yco-44,width-60, 19, pa->name, 0, 31, 0, 0, "Property name"); + + if(pa->type==ACT_PROP_COPY) { + uiDefIDPoinBut(block, test_obpoin_but, 1, "OB:", xco+10, yco-64, (width-20)/2, 19, &(pa->ob), "Copy from this Object"); + uiDefBut(block, TEX, 1, "Prop: ", xco+10+(width-20)/2, yco-64, (width-20)/2, 19, pa->value, 0, 31, 0, 0, "Copy this property"); + } + else { + uiDefBut(block, TEX, 1, "Value: ", xco+30,yco-64,width-60, 19, pa->value, 0, 31, 0, 0, "change with this value"); + } + yco-= ysize; + + break; + } + case ACT_SOUND: + { + ysize = 70; + + sa = act->data; + sa->sndnr = 0; + + wval = (width-20)/2; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + IDnames_to_pupstring(&str, "Sound files", NULL, &(G.main->sound), (ID *)sa->sound, &(sa->sndnr)); + + if(str[0]) + { + /* reset this value, it is for handling the event */ + sa->sndnr = 0; + uiDefButS(block, MENU, B_SOUNDACT_BROWSE, str, xco+10,yco-22,20,19, &(sa->sndnr), 0, 0, 0, 0, ""); + + if(sa->sound) + { + char dummy_str[] = "Sound mode %t|Play Stop %x0|Play End %x1|Loop Stop %x2|Loop End %x3|Loop Ping Pong Stop %x5|Loop Ping Pong %x4"; + uiDefBut(block, TEX, B_IDNAME, "SO:",xco+30,yco-22,width-40,19, sa->sound->id.name+2, 0.0, 18.0, 0, 0, ""); + uiDefButS(block, MENU, 1, dummy_str,xco+10,yco-44,width-20, 19, &sa->type, 0.0, 0.0, 0, 0, ""); + uiDefButF(block, NUM, 0, "Volume:", xco+10,yco-66,wval, 19, &sa->sound->volume, 0.0, 1.0, 0, 0, "Sets the volume of this sound"); + uiDefButF(block, NUM, 0, "Pitch:",xco+wval+10,yco-66,wval, 19, &sa->sound->pitch,-12.0, 12.0, 0, 0, "Sets the pitch of this sound"); + } + } + else + { + uiDefBut(block, LABEL, 0, "Use Sound window to load files", xco, yco-24, width, 19, NULL, 0, 0, 0, 0, ""); + } + + MEM_freeN(str); + + yco-= ysize; + + break; + } + case ACT_CD: + { + char cd_type_str[] = "Sound mode %t|Play all tracks %x0|Play one track %x1|" + "Volume %x3|Stop %x4|Pause %x5|Resume %x6"; + cda = act->data; + + if (cda) + { + if (cda->track == 0) + { + cda->track = 1; + cda->volume = 1; + cda->type = ACT_CD_PLAY_ALL; + } + + if (cda->type == ACT_CD_PLAY_TRACK || cda->type == ACT_CD_LOOP_TRACK) + { + ysize = 48; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + uiDefButS(block, NUM, 0, "Track:", xco+10,yco-44,width-20, 19, &cda->track, 1, 99, 0, 0, "Select the track to be played"); + } + else if (cda->type == ACT_CD_VOLUME) + { + ysize = 48; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + uiDefButF(block, NUM, 0, "Volume:", xco+10,yco-44,width-20, 19, &cda->volume, 0, 1, 0, 0, "Set the volume for CD playback"); + } + else + { + ysize = 28; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + } + uiDefButS(block, MENU, B_REDR, cd_type_str,xco+10,yco-22,width-20, 19, &cda->type, 0.0, 0.0, 0, 0, ""); + } + yco-= ysize; + break; + } + case ACT_CAMERA: + + ysize= 48; + + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + ca= act->data; + + uiDefIDPoinBut(block, test_obpoin_but, 1, "OB:", xco+10, yco-24, (width-20)/2, 19, &(ca->ob), "Look at this Object"); + uiDefButF(block, NUM, 0, "Height:", xco+10+(width-20)/2, yco-24, (width-20)/2, 19, &ca->height, 0.0, 20.0, 0, 0, ""); + + uiDefButF(block, NUM, 0, "Min:", xco+10, yco-44, (width-60)/2, 19, &ca->min, 0.0, 20.0, 0, 0, ""); + + if(ca->axis==0) ca->axis= 'x'; + uiDefButS(block, ROW, 0, "X", xco+10+(width-60)/2, yco-44, 20, 19, &ca->axis, 4.0, (float)'x', 0, 0, "Camera tries to get behind the X axis"); + uiDefButS(block, ROW, 0, "Y", xco+30+(width-60)/2, yco-44, 20, 19, &ca->axis, 4.0, (float)'y', 0, 0, "Camera tries to get behind the Y axis"); + + uiDefButF(block, NUM, 0, "Max:", xco+20+(width)/2, yco-44, (width-60)/2, 19, &ca->max, 0.0, 20.0, 0, 0, ""); + + yco-= ysize; + + break; + + case ACT_EDIT_OBJECT: + + eoa= act->data; + + if(eoa->type==ACT_EDOB_ADD_OBJECT) { + int wval; /* just a temp width */ + ysize = 72; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + uiDefIDPoinBut(block, test_obpoin_but, 1, "OB:", xco+10, yco-44, (width-20)/2, 19, &(eoa->ob), "Add this Object"); + uiDefButI(block, NUM, 0, "Time:", xco+10+(width-20)/2, yco-44, (width-20)/2, 19, &eoa->time, 0.0, 2000.0, 0, 0, "Duration the new Object lives"); + + wval= (width-60)/3; + uiDefBut(block, LABEL, 0, "linV", xco, yco-68, 45, 19, + NULL, 0, 0, 0, 0, + "Velocity upon creation."); + uiDefButF(block, NUM, 0, "", xco+45, yco-68, wval, 19, + eoa->linVelocity, -100.0, 100.0, 10, 0, + "Velocity upon creation, x component."); + uiDefButF(block, NUM, 0, "", xco+45+wval, yco-68, wval, 19, + eoa->linVelocity+1, -100.0, 100.0, 10, 0, + "Velocity upon creation, y component."); + uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-68, wval, 19, + eoa->linVelocity+2, -100.0, 100.0, 10, 0, + "Velocity upon creation, z component."); + uiDefButS(block, TOG|BIT|1, 0, "L", xco+45+3*wval, yco-68, 15, 19, + &eoa->localflag, 0.0, 0.0, 0, 0, + "Apply the transformation locally"); + + } + else if(eoa->type==ACT_EDOB_END_OBJECT) { + ysize= 28; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + } + else if(eoa->type==ACT_EDOB_REPLACE_MESH) { + ysize= 48; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + uiDefIDPoinBut(block, test_meshpoin_but, 1, "ME:", xco+40, yco-44, (width-80), 19, &(eoa->me), "Add this Object"); + } + else if(eoa->type==ACT_EDOB_TRACK_TO) { + ysize= 48; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + uiDefIDPoinBut(block, test_obpoin_but, 1, "OB:", xco+10, yco-44, (width-20)/2, 19, &(eoa->ob), "Track to this Object"); + uiDefButI(block, NUM, 0, "Time:", xco+10+(width-20)/2, yco-44, (width-20)/2-40, 19, &eoa->time, 0.0, 2000.0, 0, 0, "Duration the tracking takes"); + uiBlockSetCol(block, BUTGREEN); + uiDefButS(block, TOG, 0, "3D", xco+width-50, yco-44, 40, 19, &eoa->flag, 0.0, 0.0, 0, 0, "Enable 3D tracking"); + uiBlockSetCol(block, BUTGREY); + } + + str= "Edit Object %t|Add Object %x0|End Object %x1|Replace Mesh %x2|Track to %x3"; + uiDefButS(block, MENU, B_REDR, str, xco+40, yco-24, (width-80), 19, &eoa->type, 0.0, 0.0, 0, 0, ""); + + yco-= ysize; + + break; + + case ACT_CONSTRAINT: + + ysize= 44; + + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + coa= act->data; + +/* str= "Limit %t|None %x0|Loc X %x1|Loc Y %x2|Loc Z %x4|Rot X %x8|Rot Y %x16|Rot Z %x32"; */ + str= "Limit %t|None %x0|Loc X %x1|Loc Y %x2|Loc Z %x4"; + uiDefButS(block, MENU, 1, str, xco+10, yco-40, 70, 19, &coa->flag, 0.0, 0.0, 0, 0, ""); + + uiDefButS(block, NUM, 0, "Damp:", xco+10, yco-20, 70, 19, &coa->damp, 0.0, 100.0, 0, 0, ""); + uiDefBut(block, LABEL, 0, "Min", xco+80, yco-20, (width-90)/2, 19, NULL, 0.0, 0.0, 0, 0, ""); + uiDefBut(block, LABEL, 0, "Max", xco+80+(width-90)/2, yco-20, (width-90)/2, 19, NULL, 0.0, 0.0, 0, 0, ""); + + if(coa->flag & ACT_CONST_LOCX) fp= coa->minloc; + else if(coa->flag & ACT_CONST_LOCY) fp= coa->minloc+1; + else if(coa->flag & ACT_CONST_LOCZ) fp= coa->minloc+2; + else if(coa->flag & ACT_CONST_ROTX) fp= coa->minrot; + else if(coa->flag & ACT_CONST_ROTY) fp= coa->minrot+1; + else fp= coa->minrot+2; + + uiDefButF(block, NUM, 0, "", xco+80, yco-40, (width-90)/2, 19, fp, -2000.0, 2000.0, 10, 0, ""); + uiDefButF(block, NUM, 0, "", xco+80+(width-90)/2, yco-40, (width-90)/2, 19, fp+3, -2000.0, 2000.0, 10, 0, ""); + + yco-= ysize; + + break; + + case ACT_SCENE: + sca= act->data; + + if(sca->type==ACT_SCENE_RESTART) { + ysize= 28; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + } + else if(sca->type==ACT_SCENE_CAMERA) { + + ysize= 48; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + uiDefIDPoinBut(block, test_obpoin_but, 1, "OB:", xco+40, yco-44, (width-80), 19, &(sca->camera), "Set this Camera"); + } + else if(sca->type==ACT_SCENE_SET) { + + ysize= 48; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + uiDefIDPoinBut(block, test_scenepoin_but, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Set this Scene"); + } + else if(sca->type==ACT_SCENE_ADD_FRONT) { + + ysize= 48; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + uiDefIDPoinBut(block, test_scenepoin_but, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Add an Overlay Scene"); + } + else if(sca->type==ACT_SCENE_ADD_BACK) { + + ysize= 48; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + uiDefIDPoinBut(block, test_scenepoin_but, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Add a Background Scene"); + } + else if(sca->type==ACT_SCENE_REMOVE) { + + ysize= 48; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + uiDefIDPoinBut(block, test_scenepoin_but, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Remove a Scene"); + } + else if(sca->type==ACT_SCENE_SUSPEND) { + + ysize= 48; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + uiDefIDPoinBut(block, test_scenepoin_but, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Pause a Scene"); + } + else if(sca->type==ACT_SCENE_RESUME) { + + ysize= 48; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + uiDefIDPoinBut(block, test_scenepoin_but, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Unpause a Scene"); + } + + str= "Scene %t|Restart %x0|Set Scene %x1|Set Camera %x2|Add OverlayScene %x3|Add BackgroundScene %x4|Remove Scene %x5|Suspend Scene %x6|Resume Scene %x7"; + uiDefButS(block, MENU, B_REDR, str, xco+40, yco-24, (width-80), 19, &sca->type, 0.0, 0.0, 0, 0, ""); + + yco-= ysize; + break; + case ACT_GAME: + { + gma = act->data; + if (gma->type == ACT_GAME_LOAD) + { + //ysize = 68; + ysize = 48; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + uiDefBut(block, TEX, 1, "File: ", xco+10, yco-44,width-20,19, &(gma->filename), 0, 63, 0, 0, "Load this file"); +// uiDefBut(block, TEX, 1, "Anim: ", xco+10, yco-64,width-20,19, &(gma->loadaniname), 0, 63, 0, 0, "Use this loadinganimation"); + } +/* else if (gma->type == ACT_GAME_START) + { + ysize = 68; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + uiDefBut(block, TEX, 1, "File: ", xco+10, yco-44,width-20,19, &(gma->filename), 0, 63, 0, 0, "Load this file"); + uiDefBut(block, TEX, 1, "Anim: ", xco+10, yco-64,width-20,19, &(gma->loadaniname), 0, 63, 0, 0, "Use this loadinganimation"); + } +*/ else if (gma->type == ACT_GAME_RESTART) + { + ysize = 28; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + } + else if (gma->type == ACT_GAME_QUIT) + { + ysize = 28; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + } + + //str = "Scene %t|Load game%x0|Start loaded game%x1|Restart this game%x2|Quit this game %x3"; + str = "Scene %t|Start new game%x0|Restart this game%x2|Quit this game %x3"; + uiDefButS(block, MENU, B_REDR, str, xco+40, yco-24, (width-80), 19, &gma->type, 0.0, 0.0, 0, 0, ""); + + yco -= ysize; + break; + } + case ACT_GROUP: + ga= act->data; + + ysize= 52; + + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + str= "GroupKey types %t|Set Key %x6|Play %x0|Ping Pong %x1|Flipper %x2|Loop Stop %x3|Loop End %x4|Property %x5"; + + uiDefButS(block, MENU, 1, str, xco+20, yco-24, width-40, 19, &ga->type, 0, 0, 0, 0, ""); + if(ga->type==ACT_GROUP_SET) { + uiDefBut(block, TEX, 0, "Key: ", xco+20, yco-44, (width-10)/2, 19, ga->name, 0.0, 31.0, 0, 0, "This name defines groupkey to be set"); + uiDefButS(block, NUM, 0, "Frame:", xco+20+(width-10)/2, yco-44, (width-70)/2, 19, &ga->sta, 0.0, 2500.0, 0, 0, "Set this frame"); + } + else if(ga->type==ACT_GROUP_FROM_PROP) { + uiDefBut(block, TEX, 0, "Prop: ", xco+20, yco-44, width-40, 19, ga->name, 0.0, 31.0, 0, 0, "Use this property to define the Group position"); + } + else { + uiDefButS(block, NUM, 0, "Sta", xco+20, yco-44, (width-40)/2, 19, &ga->sta, 0.0, 2500.0, 0, 0, "Start frame"); + uiDefButS(block, NUM, 0, "End", xco+20+(width-40)/2, yco-44, (width-40)/2, 19, &ga->end, 0.0, 2500.0, 0, 0, "End frame"); + } + yco-= ysize; + break; + + case ACT_VISIBILITY: + ysize = 24; + + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, + (float)yco-ysize, (float)xco+width, (float)yco, 1); + + visAct = act->data; + + str= "Visibility %t|Visible %x0|Invisible %x1"; + + uiDefButI(block, MENU, B_REDR, str, + xco + 10, yco - 24, width - 20, 19, &visAct->flag, + 0.0, 0.0, 0, 0, + "Make the object invisible or visible."); +/* + uiDefButI(block, TOG|BIT|ACT_VISIBILITY_INVISIBLE_BIT, 0, + "Invisible", + xco + 10, yco - 24, width - 20, 19, &visAct->flag, + 0.0, 0.0, 0, 0, + "Make the object invisible or visible."); +*/ + yco-= ysize; + + break; + + case ACT_RANDOM: + ysize = 69; + + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, + (float)yco-ysize, (float)xco+width, (float)yco, 1); + + randAct = act->data; + + /* 1. seed */ + uiDefButI(block, NUM, 1, "Seed: ", (xco+10),yco-24, 0.4 *(width-20), 19, + &randAct->seed, 0, 1000, 0, 0, + "Initial seed of the random generator. Use Python for more freedom. " + " (Choose 0 for not random)"); + + /* 2. distribution type */ + /* One pick per distribution. These numbers MUST match the #defines */ + /* in game.h !!! */ + str= "Distribution %t|Bool Constant %x0|Bool Uniform %x1" + "|Bool Bernoulli %x2|Int Constant %x3|Int Uniform %x4" + "|Int Poisson %x5|Float Constant %x6|Float Uniform %x7" + "|Float Normal %x8|Float Neg. Exp. %x9"; + uiDefButI(block, MENU, B_REDR, str, (xco+10) + 0.4 * (width-20), yco-24, 0.6 * (width-20), 19, + &randAct->distribution, 0.0, 0.0, 0, 0, + "Choose the type of distribution"); + + /* 3. property */ + uiDefBut(block, TEX, 1, "Property:", (xco+10), yco-44, (width-20), 19, + &randAct->propname, 0, 31, 0, 0, + "Assign the random value to this property"); + + /*4. and 5. arguments for the distribution*/ + switch (randAct->distribution) { + case ACT_RANDOM_BOOL_CONST: + uiDefButI(block, TOG|BIT|0, 1, "Always true", (xco+10), yco-64, (width-20), 19, + &randAct->int_arg_1, 2.0, 1, 0, 0, + "Always false or always true"); + break; + case ACT_RANDOM_BOOL_UNIFORM: + uiDefBut(block, LABEL, 0, " Do a 50-50 pick.", (xco+10), yco-64, (width-20), 19, + NULL, 0, 0, 0, 0, + "Choose between true and false, 50%% chance each."); + break; + case ACT_RANDOM_BOOL_BERNOUILLI: + uiDefButF(block, NUM, 1, "Chance", (xco+10), yco-64, (width-20), 19, + &randAct->float_arg_1, 0.0, 1.0, 0, 0, + "Pick a number between 0 and 1. Success if you stay " + "below this value"); + break; + case ACT_RANDOM_INT_CONST: + uiDefButI(block, NUM, 1, "Value: ", (xco+10), yco-64, (width-20), 19, + &randAct->int_arg_1, -1000, 1000, 0, 0, + "Always return this number"); + break; + case ACT_RANDOM_INT_UNIFORM: + uiDefButI(block, NUM, 1, "Min: ", (xco+10), yco-64, (width-20)/2, 19, + &randAct->int_arg_1, -1000, 1000, 0, 0, + "Choose a number from a range. " + "Lower boundary of the range."); + uiDefButI(block, NUM, 1, "Max: ", (xco+10) + (width-20)/2, yco-64, (width-20)/2, 19, + &randAct->int_arg_2, -1000, 1000, 0, 0, + "Choose a number from a range. " + "Upper boundary of the range."); + break; + case ACT_RANDOM_INT_POISSON: + uiDefButF(block, NUM, 1, "Mean: ", (xco+10), yco-64, (width-20), 19, + &randAct->float_arg_1, 0.01, 100.0, 0, 0, + "Expected mean value of the distribution."); + break; + case ACT_RANDOM_FLOAT_CONST: + uiDefButF(block, NUM, 1, "Value: ", (xco+10), yco-64, (width-20), 19, + &randAct->float_arg_1, 0.0, 1.0, 0, 0, + "Always return this number"); + break; + case ACT_RANDOM_FLOAT_UNIFORM: + uiDefButF(block, NUM, 1, "Min: ", (xco+10), yco-64, (width-20)/2, 19, + &randAct->float_arg_1, -10000.0, 10000.0, 0, 0, + "Choose a number from a range. " + "Lower boundary of the range."); + uiDefButF(block, NUM, 1, "Max: ", (xco+10) + (width-20)/2, yco-64, (width-20)/2, 19, + &randAct->float_arg_2, -10000.0, 10000.0, 0, 0, + "Choose a number from a range. " + "Upper boundary of the range."); + break; + case ACT_RANDOM_FLOAT_NORMAL: + uiDefButF(block, NUM, 1, "Mean: ", (xco+10), yco-64, (width-20)/2, 19, + &randAct->float_arg_1, -10000.0, 10000.0, 0, 0, + "A normal distribution. Mean of the distribution."); + uiDefButF(block, NUM, 1, "SD: ", (xco+10) + (width-20)/2, yco-64, (width-20)/2, 19, + &randAct->float_arg_2, 0.0, 10000.0, 0, 0, + "A normal distribution. Standard deviation of the " + "distribution."); + break; + case ACT_RANDOM_FLOAT_NEGATIVE_EXPONENTIAL: + uiDefButF(block, NUM, 1, "Half-life time: ", (xco+10), yco-64, (width-20), 19, + &randAct->float_arg_1, 0.001, 10000.0, 0, 0, + "Negative exponential dropoff."); + break; + default: + ; /* don't know what this distro is... can be useful for testing */ + /* though :) */ + } + + yco-= ysize; + break; + case ACT_MESSAGE: + ma = act->data; + +#define MESSAGE_SENSOR_TO_FIELD_WORKS /* Really? Not really. Don't remove this ifdef yet */ + +#ifdef MESSAGE_SENSOR_TO_FIELD_WORKS + ysize = 4 + (3 * 24); /* footer + number of lines * 24 pixels/line */ +#else + ysize = 4 + (2 * 24); /* footer + number of lines * 24 pixels/line */ +#endif + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, + (float)xco+width, (float)yco, 1); + + myline=1; + + +#ifdef MESSAGE_SENSOR_TO_FIELD_WORKS + /* line 1: To */ + uiDefBut(block, TEX, 1, "To: ", + (xco+10), (yco-(myline++*24)), (width-20), 19, + &ma->toPropName, 0, 31, 0, 0, + "Optional send message to objects with this property only" + ", or empty to broadcast"); + +#endif + + /* line 2: Message Subject */ + uiDefBut(block, TEX, 1, "Subject: ", + (xco+10), (yco-(myline++*24)), (width-20), 19, + &ma->subject, 0, 31, 0, 0, + "Optional message subject. This is what can be filtered on."); + + /* line 3: Text/Property */ + uiDefButS(block, TOG|BIT|0, B_REDR, "T/P", + (xco+10),(yco-(myline*24)), (0.20 * (width-20)), 19, + &ma->bodyType, 0.0, 0.0, 0, 0, + "Toggle message type: either Text or a PropertyName."); + + if (ma->bodyType == ACT_MESG_MESG) + { + /* line 3: Message Body */ + uiDefBut(block, TEX, 1, "Body: ", + (xco+10+(0.20*(width-20))),(yco-(myline++*24)),(0.8*(width-20)),19, + &ma->body, 0, 31, 0, 0, + "Optional message body Text"); + } else + { + /* line 3: Property body (set by property) */ + uiDefBut(block, TEX, 1, "Propname: ", + (xco+10+(0.20*(width-20))),(yco-(myline++*24)),(0.8*(width-20)),19, + &ma->body, 0, 31, 0, 0, + "The message body will be set by the Property Value"); + } + + yco -= ysize; + break; + default: + ysize= 4; + + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + yco-= ysize; + break; + } + + uiBlockSetEmboss(block, UI_EMBOSSM); + uiBlockSetCol(block, BUTGREY); + + return yco-4; +} + +static void do_sensor_menu(void *arg, int event) +{ + ID **idar; + Object *ob; + bSensor *sens; + short count, a; + + idar= get_selected_and_linked_obs(&count, G.buts->scaflag); + + for(a=0; ascaflag |= OB_SHOWSENS; + else if(event==1) ob->scaflag &= ~OB_SHOWSENS; + } + + for(a=0; asensors.first; + while(sens) { + if(event==2) sens->flag |= SENS_SHOW; + else if(event==3) sens->flag &= ~SENS_SHOW; + sens= sens->next; + } + } + + if(idar) MEM_freeN(idar); + allqueue(REDRAWBUTSLOGIC, 0); +} + +static uiBlock *sensor_menu(void *arg_unused) +{ + uiBlock *block; + int yco=0; + + block= uiNewBlock(&curarea->uiblocks, "filemenu", UI_EMBOSSP, UI_HELV, curarea->win); + uiBlockSetButmFunc(block, do_sensor_menu, NULL); + uiBlockSetCol(block, MENUCOL); + + uiDefBut(block, BUTM, 1, "Show Objects", 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 0, ""); + uiDefBut(block, BUTM, 1, "Hide Objects", 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 1, ""); + uiDefBut(block, SEPR, 0, "", 0, (short)(yco-=6), 160, 6, NULL, 0.0, 0.0, 0, 0, ""); + uiDefBut(block, BUTM, 1, "Show Sensors", 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 2, ""); + uiDefBut(block, BUTM, 1, "Hide Sensors", 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 3, ""); + + uiBlockSetDirection(block, UI_TOP); + + return block; +} + +static void do_controller_menu(void *arg, int event) +{ + ID **idar; + Object *ob; + bController *cont; + short count, a; + + idar= get_selected_and_linked_obs(&count, G.buts->scaflag); + + for(a=0; ascaflag |= OB_SHOWCONT; + else if(event==1) ob->scaflag &= ~OB_SHOWCONT; + } + + for(a=0; acontrollers.first; + while(cont) { + if(event==2) cont->flag |= CONT_SHOW; + else if(event==3) cont->flag &= ~CONT_SHOW; + cont= cont->next; + } + } + + if(idar) MEM_freeN(idar); + allqueue(REDRAWBUTSLOGIC, 0); +} + +static uiBlock *controller_menu(void *arg_unused) +{ + uiBlock *block; + int yco=0; + + block= uiNewBlock(&curarea->uiblocks, "filemenu", UI_EMBOSSP, UI_HELV, curarea->win); + uiBlockSetButmFunc(block, do_controller_menu, NULL); + uiBlockSetCol(block, MENUCOL); + + uiDefBut(block, BUTM, 1, "Show Objects", 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 0, ""); + uiDefBut(block, BUTM, 1, "Hide Objects", 0,(short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 1, ""); + uiDefBut(block, SEPR, 0, "", 0, (short)(yco-=6), 160, 6, NULL, 0.0, 0.0, 0, 0, ""); + uiDefBut(block, BUTM, 1, "Show Controllers", 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 2, 2, ""); + uiDefBut(block, BUTM, 1, "Hide Controllers", 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 3, 3, ""); + + uiBlockSetDirection(block, UI_TOP); + + return block; +} + +static void do_actuator_menu(void *arg, int event) +{ + ID **idar; + Object *ob; + bActuator *act; + short count, a; + + idar= get_selected_and_linked_obs(&count, G.buts->scaflag); + + for(a=0; ascaflag |= OB_SHOWACT; + else if(event==1) ob->scaflag &= ~OB_SHOWACT; + } + + for(a=0; aactuators.first; + while(act) { + if(event==2) act->flag |= ACT_SHOW; + else if(event==3) act->flag &= ~ACT_SHOW; + act= act->next; + } + } + + if(idar) MEM_freeN(idar); + allqueue(REDRAWBUTSLOGIC, 0); +} + +static uiBlock *actuator_menu(void *arg_unused) +{ + uiBlock *block; + int xco=0; + + block= uiNewBlock(&curarea->uiblocks, "filemenu", UI_EMBOSSP, UI_HELV, curarea->win); + uiBlockSetButmFunc(block, do_actuator_menu, NULL); + uiBlockSetCol(block, MENUCOL); + + uiDefBut(block, BUTM, 1, "Show Objects", 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 0, ""); + uiDefBut(block, BUTM, 1, "Hide Objects", 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 1, ""); + uiDefBut(block, SEPR, 0, "", 0, (short)(xco-=6), 160, 6, NULL, 0.0, 0.0, 0, 0, ""); + uiDefBut(block, BUTM, 1, "Show Actuators", 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 2, ""); + uiDefBut(block, BUTM, 1, "Hide Actuators", 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 3, ""); + + uiBlockSetDirection(block, UI_TOP); + + return block; +} + +/* never used, see CVS 1.134 for the code */ +/* static FreeCamera *new_freecamera(void) */ + +/* never used, see CVS 1.120 for the code */ +/* static uiBlock *freecamera_menu(void) */ + +void logic_buts(void) +{ + ID **idar; + Object *ob; + bProperty *prop; + bSensor *sens; + bController *cont; + bActuator *act; + uiBlock *block; + uiBut *but; + int a; + short xco, yco, count, width, ycoo; + char *pupstr, name[32]; + int butreturn = 0; + + ob= OBACT; + + if(ob==0) return; + uiSetButLock(ob->id.lib!=0, "Can't edit library data"); + + sprintf(name, "buttonswin %d", curarea->win); + block= uiNewBlock(&curarea->uiblocks, name, UI_EMBOSSX, UI_HELV, curarea->win); + + uiBlockSetCol(block, BUTPURPLE); + // uiDefButI(block, TOG|BIT|0, B_REDR, "X", + // 15,205,10,19, &ob->gameflag2, 0, 0, 0, 0, + // "Toggle to always ignore activity culling."); + uiDefButI(block, TOG|BIT|2, B_REDR, "Actor", + 25,205,60,19, &ob->gameflag, 0, 0, 0, 0, + "Objects that are evaluated by the engine "); + + if(ob->gameflag & OB_ACTOR) { + uiDefButI(block, TOG|BIT|9, B_REDR, "Ghost", 85,205,65,19, &ob->gameflag, 0, 0, 0, 0, "Objects that don't restitute collisions (like a ghost)"); + uiDefButI(block, TOG|BIT|0, B_REDR, "Dynamic", 150,205,65,19, &ob->gameflag, 0, 0, 0, 0, "Motion defined by laws of physics"); + + if(ob->gameflag & OB_DYNAMIC) { + + uiDefButI(block, TOG|BIT|10, B_REDR, "Rigid Body", 215,205,135,19, &ob->gameflag, 0, 0, 0, 0, ""); + + uiDefButI(block, TOG|BIT|6, B_DIFF, "Do Fh", 10,185,50,19, &ob->gameflag, 0, 0, 0, 0, "Use Fh settings in Materials"); + uiDefButI(block, TOG|BIT|7, B_DIFF, "Rot Fh", 60,185,50,19, &ob->gameflag, 0, 0, 0, 0, "Use face normal to rotate Object"); + + uiBlockSetCol(block, BUTGREY); + + uiDefButF(block, NUM, B_DIFF, "Mass:", 110, 185, 80, 19, &ob->mass, 0.01, 100.0, 10, 0, "The mass of the Object"); + uiDefButF(block, NUM, REDRAWVIEW3D, "Size:", 190, 185, 80, 19, &ob->inertia, 0.01, 10.0, 10, 0, "Bounding sphere size"); + uiDefButF(block, NUM, B_DIFF, "Form:", 270, 185, 80, 19, &ob->formfactor, 0.01, 100.0, 10, 0, "Form factor"); + + uiDefButF(block, NUM, B_DIFF, "Damp:", 10, 165, 100, 19, &ob->damping, 0.0, 1.0, 10, 0, "General movement damping"); + uiDefButF(block, NUM, B_DIFF, "RotDamp:", 110, 165, 120, 19, &ob->rdamping, 0.0, 1.0, 10, 0, "General rotation damping"); + uiDefButI(block, TOG|BIT|8, B_REDR, "Anisotropic", 230, 165, 120, 19, + &ob->gameflag, 0.0, 1.0, 10, 0, + "Enable anisotropic friction"); + } + } + + if (ob->gameflag & OB_ANISOTROPIC_FRICTION) { + uiDefButF(block, NUM, B_DIFF, "x friction:", 10, 145, 114, 19, + &ob->anisotropicFriction[0], 0.0, 1.0, 10, 0, + "Relative friction coefficient in the x-direction."); + uiDefButF(block, NUM, B_DIFF, "y friction:", 124, 145, 113, 19, + &ob->anisotropicFriction[1], 0.0, 1.0, 10, 0, + "Relative friction coefficient in the y-direction."); + uiDefButF(block, NUM, B_DIFF, "z friction:", 237, 145, 113, 19, + &ob->anisotropicFriction[2], 0.0, 1.0, 10, 0, + "Relative friction coefficient in the z-direction."); + } + + uiBlockSetCol(block, BUTSALMON); + uiDefBut(block, BUT, B_ADD_PROP, "ADD property", 10, 110, 340, 24, + NULL, 0.0, 100.0, 100, 0, + ""); + + pupstr= "Types %t|Bool %x0|Int %x1|Float %x2|String %x3|Timer %x5"; + + a= 0; + prop= ob->prop.first; + while(prop) { + + uiBlockSetCol(block, BUTSALMON); + but= uiDefBut(block, BUT, 1, "Del", 10, (short)(90-20*a), 40, 19, NULL, 0.0, 0.0, 1, (float)a, ""); + uiButSetFunc(but, del_property, prop, NULL); + uiBlockSetCol(block, BUTGREY); + uiDefButS(block, MENU, B_CHANGE_PROP, pupstr, 50, (short)(90-20*a), 60, 19, &prop->type, 0, 0, 0, 0, ""); + but= uiDefBut(block, TEX, 1, "Name:", 110, (short)(90-20*a), 105, 19, prop->name, 0, 31, 0, 0, ""); + uiButSetFunc(but, make_unique_prop_names_cb, prop->name, (void*) 1); + + if (strcmp(prop->name, "Text") == 0) { + butreturn = REDRAWVIEW3D; + } else { + butreturn = 0; + } + + if(prop->type==PROP_BOOL) { + uiBlockSetCol(block, BUTGREEN); + uiDefButI(block, TOG|BIT|0, B_REDR, "True", 215, (short)(90-20*a), 55, 19, &prop->data, 0, 0, 0, 0, ""); + uiDefButI(block, TOGN|BIT|0, B_REDR, "False", 270, (short)(90-20*a), 55, 19, &prop->data, 0, 0, 0, 0, ""); + uiBlockSetCol(block, BUTGREY); + } + else if(prop->type==PROP_INT) + uiDefButI(block, NUM, butreturn, "", 215, (short)(90-20*a), 110, 19, &prop->data, -10000, 10000, 0, 0, ""); + else if(prop->type==PROP_FLOAT) + uiDefButF(block, NUM, butreturn, "", 215, (short)(90-20*a), 110, 19, (float*) &prop->data, -10000, 10000, 100, 0, ""); + else if(prop->type==PROP_STRING) + uiDefBut(block, TEX, butreturn, "", 215, (short)(90-20*a), 110, 19, prop->poin, 0, 127, 0, 0, ""); + else if(prop->type==PROP_TIME) + uiDefButF(block, NUM, butreturn, "", 215, (short)(90-20*a), 110, 19, (float*) &prop->data, -10000, 10000, 0, 0, ""); + + uiDefButS(block, TOG|BIT|0, 0, "D", 325, (short)(90-20*a), 20, 19, &prop->flag, 0, 0, 0, 0, "Print Debug info"); + + a++; + prop= prop->next; + } + + uiClearButLock(); + + idar= get_selected_and_linked_obs(&count, G.buts->scaflag); + + /* ******************************* */ + xco= 375; yco= 170; width= 230; + + uiBlockSetCol(block, BUTGREY); + uiBlockSetEmboss(block, UI_EMBOSSP); + uiDefBlockBut(block, sensor_menu, NULL, "Sensors", xco-10, yco+35, 80, 19, ""); + uiBlockSetCol(block, BUTGREEN); + uiBlockSetEmboss(block, UI_EMBOSSX); + uiDefButS(block, TOG|BIT|0, B_REDR, "Sel", xco+110, yco+35, (width-100)/3, 19, &G.buts->scaflag, 0, 0, 0, 0, "Show all selected Objects"); + uiDefButS(block, TOG|BIT|1, B_REDR, "Act", xco+110+(width-100)/3, yco+35, (width-100)/3, 19, &G.buts->scaflag, 0, 0, 0, 0, "Show active Object"); + uiDefButS(block, TOG|BIT|2, B_REDR, "Link", xco+110+2*(width-100)/3, yco+35, (width-100)/3, 19, &G.buts->scaflag, 0, 0, 0, 0, "Show linked Objects to Controller"); + + for(a=0; aid.lib!=0, "Can't edit library data"); + + if( (ob->scavisflag & OB_VIS_SENS) == 0) continue; + + /* presume it is only objects for now */ + uiBlockSetEmboss(block, UI_EMBOSSX); + uiBlockSetCol(block, BUTGREY); + if(ob->sensors.first) uiSetCurFont(block, UI_HELVB); + uiBlockSetCol(block, MIDGREY); + uiDefButS(block, TOG|BIT|6, B_REDR, ob->id.name+2,(short)(xco-10), yco, (short)(width-30), 19, &ob->scaflag, 0, 31, 0, 0, "Object name, click to show/hide sensors"); + if(ob->sensors.first) uiSetCurFont(block, UI_HELV); + uiBlockSetCol(block, BUTSALMON); + uiDefButS(block, TOG|BIT|8, B_ADD_SENS, "Add",(short)(xco+width-40), yco, 50, 19, &ob->scaflag, 0, 0, 0, 0, "Add a new Sensor"); + yco-=20; + + if(ob->scaflag & OB_SHOWSENS) { + + sens= ob->sensors.first; + while(sens) { + uiBlockSetEmboss(block, UI_EMBOSSW); + uiBlockSetCol(block, BUTSALMON); + uiDefIconButS(block, TOG|BIT|1, B_DEL_SENS, ICON_X, xco, yco, 22, 19, &sens->flag, 0, 0, 0, 0, "Delete Sensor"); + uiBlockSetCol(block, BUTGREY); + uiDefIconButS(block, ICONTOG|BIT|0, B_REDR, ICON_RIGHTARROW, (short)(xco+width-22), yco, 22, 19, &sens->flag, 0, 0, 0, 0, "Sensor settings"); + + ycoo= yco; + if(sens->flag & SENS_SHOW) + { + uiBlockSetCol(block, BUTYELLOW); + + uiDefButS(block, MENU, B_CHANGE_SENS, sensor_pup(), (short)(xco+22), yco, 100, 19, &sens->type, 0, 0, 0, 0, "Sensor type"); + but= uiDefBut(block, TEX, 1, "", (short)(xco+122), yco, (short)(width-144), 19, sens->name, 0, 31, 0, 0, "Sensor name"); + uiButSetFunc(but, make_unique_prop_names_cb, sens->name, (void*) 0); + + sens->otype= sens->type; + uiBlockSetCol(block, BUTGREY); + yco= draw_sensorbuttons(sens, block, xco, yco, width,ob->id.name); + if(yco-6 < ycoo) ycoo= (yco+ycoo-20)/2; + } + else { + set_col_sensor(sens->type, 1); + glRecti(xco+22, yco, xco+width-22,yco+19); + but= uiDefBut(block, LABEL, 0, sensor_name(sens->type), (short)(xco+22), yco, 100, 19, sens, 0, 0, 0, 0, ""); + uiButSetFunc(but, sca_move_sensor, sens, NULL); + but= uiDefBut(block, LABEL, 0, sens->name, (short)(xco+122), yco, (short)(width-144), 19, sens, 0, 31, 0, 0, ""); + uiButSetFunc(but, sca_move_sensor, sens, NULL); + } + + but= uiDefIconBut(block, LINK, 0, ICON_LINK, (short)(xco+width), ycoo, 19, 19, NULL, 0, 0, 0, 0, ""); + uiSetButLink(but, NULL, (void ***)&(sens->links), &sens->totlinks, LINK_SENSOR, LINK_CONTROLLER); + + yco-=20; + + sens= sens->next; + } + yco-= 6; + } + } + + /* ******************************* */ + xco= 675; yco= 170; width= 230; + + uiBlockSetCol(block, BUTGREY); + uiBlockSetEmboss(block, UI_EMBOSSP); + uiDefBlockBut(block, controller_menu, NULL, "Controllers", xco-10, yco+35, 100, 19, ""); + uiBlockSetCol(block, BUTGREEN); + uiBlockSetEmboss(block, UI_EMBOSSX); + uiDefButS(block, TOG|BIT|3, B_REDR, "Sel", xco+110, yco+35, (width-100)/3, 19, &G.buts->scaflag, 0, 0, 0, 0, "Show all selected Objects"); + uiDefButS(block, TOG|BIT|4, B_REDR, "Act", xco+110+(width-100)/3, yco+35, (width-100)/3, 19, &G.buts->scaflag, 0, 0, 0, 0, "Show active Object"); + uiDefButS(block, TOG|BIT|5, B_REDR, "Link", xco+110+2*(width-100)/3, yco+35, (width-100)/3, 19, &G.buts->scaflag, 0, 0, 0, 0, "Show linked Objects to Sensor/Actuator"); + + ob= OBACT; + + for(a=0; aid.lib!=0, "Can't edit library data"); + if( (ob->scavisflag & OB_VIS_CONT) == 0) continue; + + /* presume it is only objects for now */ + uiBlockSetEmboss(block, UI_EMBOSSX); + uiBlockSetCol(block, BUTSALMON); + uiDefButS(block, TOG|BIT|9, B_ADD_CONT, "Add",(short)(xco+width-40), yco, 50, 19, &ob->scaflag, 0, 0, 0, 0, "Add a new Controller"); + uiBlockSetCol(block, MIDGREY); + if(ob->controllers.first) uiSetCurFont(block, UI_HELVB); + uiDefButS(block, TOG|BIT|11, B_REDR, ob->id.name+2,(short)(xco-10), yco, (short)(width-30), 19, &ob->scaflag, 0, 0, 0, 0, "Active Object name"); + if(ob->controllers.first) uiSetCurFont(block, UI_HELV); + yco-=20; + + if(ob->scaflag & OB_SHOWCONT) { + + cont= ob->controllers.first; + while(cont) { + uiBlockSetEmboss(block, UI_EMBOSSW); + uiBlockSetCol(block, BUTSALMON); + uiDefIconButS(block, TOG|BIT|1, B_DEL_CONT, ICON_X, xco, yco, 22, 19, &cont->flag, 0, 0, 0, 0, "Delete Controller"); + uiBlockSetCol(block, BUTGREY); + uiDefIconButS(block, ICONTOG|BIT|0, B_REDR, ICON_RIGHTARROW, (short)(xco+width-22), yco, 22, 19, &cont->flag, 0, 0, 0, 0, "Controller settings"); + + if(cont->flag & CONT_SHOW) { + uiBlockSetCol(block, BUTYELLOW); + cont->otype= cont->type; + uiDefButS(block, MENU, B_CHANGE_CONT, controller_pup(),(short)(xco+22), yco, 100, 19, &cont->type, 0, 0, 0, 0, "Controller type"); + but= uiDefBut(block, TEX, 1, "", (short)(xco+122), yco, (short)(width-144), 19, cont->name, 0, 31, 0, 0, "Controller name"); + uiButSetFunc(but, make_unique_prop_names_cb, cont->name, (void*) 0); + uiBlockSetCol(block, BUTGREY); + + ycoo= yco; + yco= draw_controllerbuttons(cont, block, xco, yco, width); + if(yco-6 < ycoo) ycoo= (yco+ycoo-20)/2; + } + else { + cpack(0x999999); + glRecti(xco+22, yco, xco+width-22,yco+19); + but= uiDefBut(block, LABEL, 0, controller_name(cont->type), (short)(xco+22), yco, 100, 19, cont, 0, 0, 0, 0, "Controller type"); + uiButSetFunc(but, sca_move_controller, cont, NULL); + but= uiDefBut(block, LABEL, 0, cont->name,(short)(xco+122), yco,(short)(width-144), 19, cont, 0, 0, 0, 0, "Controller name"); + uiButSetFunc(but, sca_move_controller, cont, NULL); + ycoo= yco; + } + + but= uiDefIconBut(block, LINK, 0, ICON_LINK, (short)(xco+width), ycoo, 19, 19, NULL, 0, 0, 0, 0, ""); + uiSetButLink(but, NULL, (void ***)&(cont->links), &cont->totlinks, LINK_CONTROLLER, LINK_ACTUATOR); + + uiDefIconBut(block, INLINK, 0, ICON_INLINK,(short)(xco-19), ycoo, 19, 19, cont, LINK_CONTROLLER, 0, 0, 0, ""); + + yco-=20; + + cont= cont->next; + } + yco-= 6; + } + } + + /* ******************************* */ + xco= 985; yco= 170; width= 280; + + uiBlockSetCol(block, BUTGREY); + uiBlockSetEmboss(block, UI_EMBOSSP); + uiDefBlockBut(block, actuator_menu, NULL, "Actuators", xco-10, yco+35, 100, 19, ""); + uiBlockSetCol(block, BUTGREEN); + uiBlockSetEmboss(block, UI_EMBOSSX); + uiDefButS(block, TOG|BIT|6, B_REDR, "Sel", xco+110, yco+35, (width-110)/3, 19, &G.buts->scaflag, 0, 0, 0, 0, "Show all selected Objects"); + uiDefButS(block, TOG|BIT|7, B_REDR, "Act", xco+110+(width-110)/3, yco+35, (width-110)/3, 19, &G.buts->scaflag, 0, 0, 0, 0, "Show active Object"); + uiDefButS(block, TOG|BIT|8, B_REDR, "Link", xco+110+2*(width-110)/3, yco+35, (width-110)/3, 19, &G.buts->scaflag, 0, 0, 0, 0, "Show linked Objects to Controller"); + + for(a=0; aid.lib!=0, "Can't edit library data"); + if( (ob->scavisflag & OB_VIS_ACT) == 0) continue; + + /* presume it is only objects for now */ + uiBlockSetEmboss(block, UI_EMBOSSX); + uiBlockSetCol(block, BUTGREY); + if(ob->actuators.first) uiSetCurFont(block, UI_HELVB); + uiBlockSetCol(block, MIDGREY); + uiDefButS(block, TOG|BIT|7, B_REDR, ob->id.name+2,(short)(xco-10), yco,(short)(width-30), 19, &ob->scaflag, 0, 31, 0, 0, "Object name, click to show/hide actuators"); + if(ob->actuators.first) uiSetCurFont(block, UI_HELV); + uiBlockSetCol(block, BUTSALMON); + uiDefButS(block, TOG|BIT|10, B_ADD_ACT, "Add",(short)(xco+width-40), yco, 50, 19, &ob->scaflag, 0, 0, 0, 0, "Add a new Actuator"); + yco-=20; + + if(ob->scaflag & OB_SHOWACT) { + + act= ob->actuators.first; + while(act) { + uiBlockSetEmboss(block, UI_EMBOSSW); + uiBlockSetCol(block, BUTSALMON); + uiDefIconButS(block, TOG|BIT|1, B_DEL_ACT, ICON_X, xco, yco, 22, 19, &act->flag, 0, 0, 0, 0, "Delete Actuator"); + uiBlockSetCol(block, BUTGREY); + uiDefIconButS(block, ICONTOG|BIT|0, B_REDR, ICON_RIGHTARROW, (short)(xco+width-22), yco, 22, 19, &act->flag, 0, 0, 0, 0, "Actuator settings"); + + if(act->flag & ACT_SHOW) { + uiBlockSetCol(block, BUTYELLOW); + act->otype= act->type; + uiDefButS(block, MENU, B_CHANGE_ACT, actuator_pup(ob), (short)(xco+22), yco, 100, 19, &act->type, 0, 0, 0, 0, "Actuator type"); + but= uiDefBut(block, TEX, 1, "", (short)(xco+122), yco, (short)(width-144), 19, act->name, 0, 31, 0, 0, "Actuator name"); + uiButSetFunc(but, make_unique_prop_names_cb, act->name, (void*) 0); + uiBlockSetCol(block, BUTGREY); + + ycoo= yco; + yco= draw_actuatorbuttons(act, block, xco, yco, width); + if(yco-6 < ycoo) ycoo= (yco+ycoo-20)/2; + } + else { + set_col_actuator(act->type, 1); + glRecti((short)(xco+22), yco, (short)(xco+width-22),(short)(yco+19)); + but= uiDefBut(block, LABEL, 0, actuator_name(act->type), (short)(xco+22), yco, 100, 19, act, 0, 0, 0, 0, "Actuator type"); + uiButSetFunc(but, sca_move_actuator, act, NULL); + but= uiDefBut(block, LABEL, 0, act->name, (short)(xco+122), yco, (short)(width-144), 19, act, 0, 0, 0, 0, "Actuator name"); + uiButSetFunc(but, sca_move_actuator, act, NULL); + ycoo= yco; + } + + uiDefIconBut(block, INLINK, 0, ICON_INLINK,(short)(xco-19), ycoo, 19, 19, act, LINK_ACTUATOR, 0, 0, 0, ""); + + yco-=20; + + act= act->next; + } + yco-= 6; + } + } + + uiComposeLinks(block); + uiDrawBlock(block); + + if(idar) MEM_freeN(idar); +} + diff --git a/source/blender/src/buttons_object.c b/source/blender/src/buttons_object.c new file mode 100644 index 00000000000..7448df3d6ff --- /dev/null +++ b/source/blender/src/buttons_object.c @@ -0,0 +1,903 @@ +/** + * $Id: + * + * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. The Blender + * Foundation also sells licenses for use in proprietary software under + * the Blender License. See http://www.blender.org/BL/ for information + * about this. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL/BL DUAL LICENSE BLOCK ***** + */ + +#include +#include +#include +#include + +#ifdef HAVE_CONFIG_H +#include +#endif + +#ifdef WIN32 +#include "BLI_winstuff.h" +#endif + +#include "MEM_guardedalloc.h" +#include "DNA_screen_types.h" +#include "DNA_space_types.h" +#include "DNA_scene_types.h" + +#include "BKE_global.h" +#include "BKE_main.h" +#include "BKE_library.h" + +#include "BLI_blenlib.h" +#include "BLI_arithb.h" + +#include "BSE_filesel.h" + +#include "BIF_gl.h" +#include "BIF_graphics.h" +#include "BIF_keyval.h" +#include "BIF_mainqueue.h" +#include "BIF_resources.h" +#include "BIF_screen.h" +#include "BIF_mywindow.h" +#include "BIF_space.h" +#include "BIF_glutil.h" +#include "BIF_interface.h" +#include "BIF_toolbox.h" +#include "BIF_editmesh.h" +#include "BDR_editcurve.h" +#include "BDR_editface.h" +#include "BDR_drawobject.h" +#include "BIF_butspace.h" + +#include "interface.h" +#include "mydevice.h" +#include "blendef.h" + +/* -----includes for this file specific----- */ + + +#include "DNA_action_types.h" +#include "DNA_armature_types.h" +#include "DNA_camera_types.h" +#include "DNA_constraint_types.h" +#include "DNA_curve_types.h" +#include "DNA_effect_types.h" +#include "DNA_group_types.h" +#include "DNA_ika_types.h" +#include "DNA_image_types.h" +#include "DNA_key_types.h" +#include "DNA_lamp_types.h" +#include "DNA_lattice_types.h" +#include "DNA_material_types.h" +#include "DNA_meta_types.h" +#include "DNA_mesh_types.h" +#include "DNA_object_types.h" +#include "DNA_radio_types.h" +#include "DNA_screen_types.h" +#include "DNA_sound_types.h" +#include "DNA_texture_types.h" +#include "DNA_userdef_types.h" +#include "DNA_vfont_types.h" +#include "DNA_view3d_types.h" +#include "DNA_world_types.h" + +#include "BKE_anim.h" +#include "BKE_armature.h" +#include "BKE_constraint.h" +#include "BKE_curve.h" +#include "BKE_displist.h" +#include "BKE_effect.h" +#include "BKE_font.h" +#include "BKE_ika.h" +#include "BKE_image.h" +#include "BKE_ipo.h" +#include "BKE_lattice.h" +#include "BKE_material.h" +#include "BKE_mball.h" +#include "BKE_mesh.h" +#include "BKE_object.h" +#include "BKE_sound.h" +#include "BKE_texture.h" +#include "BKE_utildefines.h" + +#include "BSE_editipo.h" +#include "BDR_editobject.h" + +#include "butspace.h" // own module + +float hspeed=0.1, prspeed=0.0, prlen=0.0; + + + +/* ************************************* */ + +#include "BLI_editVert.h" +extern ListBase editNurb; + +void do_common_editbuts(unsigned short event) // old name +{ + EditVlak *evl; + Base *base; + Object *ob; + Mesh *me; + Nurb *nu; + Curve *cu; + MFace *mface; + BezTriple *bezt; + BPoint *bp; + unsigned int local; + int a, bit, index= -1; + + switch(event) { + + case B_MATWICH: + if(G.obedit && G.obedit->actcol>0) { + if(G.obedit->type == OB_MESH) { + evl= G.edvl.first; + while(evl) { + if( vlakselectedAND(evl, 1) ) { + if(index== -1) index= evl->mat_nr; + else if(index!=evl->mat_nr) { + error("Mixed colors"); + return; + } + } + evl= evl->next; + } + } + else if ELEM(G.obedit->type, OB_CURVE, OB_SURF) { + nu= editNurb.first; + while(nu) { + if( isNurbsel(nu) ) { + if(index== -1) index= nu->mat_nr; + else if(index!=nu->mat_nr) { + error("Mixed colors"); + return; + } + } + nu= nu->next; + } + } + if(index>=0) { + G.obedit->actcol= index+1; + scrarea_queue_winredraw(curarea); + } + } + break; + case B_MATNEW: + new_material_to_objectdata((G.scene->basact) ? (G.scene->basact->object) : 0); + scrarea_queue_winredraw(curarea); + allqueue(REDRAWVIEW3D_Z, 0); + break; + case B_MATDEL: + delete_material_index(); + scrarea_queue_winredraw(curarea); + allqueue(REDRAWVIEW3D_Z, 0); + break; + case B_MATASS: + if(G.obedit && G.obedit->actcol>0) { + if(G.obedit->type == OB_MESH) { + evl= G.edvl.first; + while(evl) { + if( vlakselectedAND(evl, 1) ) + evl->mat_nr= G.obedit->actcol-1; + evl= evl->next; + } + allqueue(REDRAWVIEW3D_Z, 0); + makeDispList(G.obedit); + } + else if ELEM(G.obedit->type, OB_CURVE, OB_SURF) { + nu= editNurb.first; + while(nu) { + if( isNurbsel(nu) ) + nu->mat_nr= G.obedit->actcol-1; + nu= nu->next; + } + } + } + break; + case B_MATSEL: + case B_MATDESEL: + if(G.obedit) { + if(G.obedit->type == OB_MESH) { + evl= G.edvl.first; + while(evl) { + if(evl->mat_nr== G.obedit->actcol-1) { + if(event==B_MATSEL) { + if(evl->v1->h==0) evl->v1->f |= 1; + if(evl->v2->h==0) evl->v2->f |= 1; + if(evl->v3->h==0) evl->v3->f |= 1; + if(evl->v4 && evl->v4->h==0) evl->v4->f |= 1; + } + else { + if(evl->v1->h==0) evl->v1->f &= ~1; + if(evl->v2->h==0) evl->v2->f &= ~1; + if(evl->v3->h==0) evl->v3->f &= ~1; + if(evl->v4 && evl->v4->h==0) evl->v4->f &= ~1; + } + } + evl= evl->next; + } + tekenvertices_ext( event==B_MATSEL ); + } + else if ELEM(G.obedit->type, OB_CURVE, OB_SURF) { + nu= editNurb.first; + while(nu) { + if(nu->mat_nr==G.obedit->actcol-1) { + if(nu->bezt) { + a= nu->pntsu; + bezt= nu->bezt; + while(a--) { + if(bezt->hide==0) { + if(event==B_MATSEL) { + bezt->f1 |= 1; + bezt->f2 |= 1; + bezt->f3 |= 1; + } + else { + bezt->f1 &= ~1; + bezt->f2 &= ~1; + bezt->f3 &= ~1; + } + } + bezt++; + } + } + else if(nu->bp) { + a= nu->pntsu*nu->pntsv; + bp= nu->bp; + while(a--) { + if(bp->hide==0) { + if(event==B_MATSEL) bp->f1 |= 1; + else bp->f1 &= ~1; + } + bp++; + } + } + } + nu= nu->next; + } + allqueue(REDRAWVIEW3D, 0); + } + } + break; + case B_HIDE: + if(G.obedit) { + if(G.obedit->type == OB_MESH) hide_mesh(0); + else if ELEM(G.obedit->type, OB_CURVE, OB_SURF) hideNurb(0); + } + break; + case B_REVEAL: + if(G.obedit) { + if(G.obedit->type == OB_MESH) reveal_mesh(); + else if ELEM(G.obedit->type, OB_CURVE, OB_SURF) revealNurb(); + } + else if(G.f & G_FACESELECT) reveal_tface(); + + break; + case B_SELSWAP: + if(G.obedit) { + if(G.obedit->type == OB_MESH) selectswap_mesh(); + else if ELEM(G.obedit->type, OB_CURVE, OB_SURF) selectswapNurb(); + } + break; + case B_AUTOTEX: + ob= OBACT; + if(ob && G.obedit==0) { + if(ob->type==OB_MESH) tex_space_mesh(ob->data); + else if(ob->type==OB_MBALL) ; + else tex_space_curve(ob->data); + } + break; + case B_DOCENTRE: + docentre(); + break; + case B_DOCENTRENEW: + docentre_new(); + break; + case B_DOCENTRECURSOR: + docentre_cursor(); + break; + case B_SETSMOOTH: + case B_SETSOLID: + if(G.obedit) { + if(G.obedit->type == OB_MESH) { + evl= G.edvl.first; + while(evl) { + if( vlakselectedAND(evl, 1) ) { + if(event==B_SETSMOOTH) evl->flag |= ME_SMOOTH; + else evl->flag &= ~ME_SMOOTH; + } + evl= evl->next; + } + + makeDispList(G.obedit); + allqueue(REDRAWVIEW3D, 0); + } + else { + nu= editNurb.first; + while(nu) { + if(isNurbsel(nu)) { + if(event==B_SETSMOOTH) nu->flag |= ME_SMOOTH; + else nu->flag &= ~ME_SMOOTH; + } + nu= nu->next; + } + + } + } + else { + base= FIRSTBASE; + while(base) { + if(TESTBASELIB(base)) { + if(base->object->type==OB_MESH) { + me= base->object->data; + mface= me->mface; + for(a=0; atotface; a++, mface++) { + if(event==B_SETSMOOTH) mface->flag |= ME_SMOOTH; + else mface->flag &= ~ME_SMOOTH; + } + + makeDispList(base->object); + } + else if ELEM(base->object->type, OB_SURF, OB_CURVE) { + cu= base->object->data; + nu= cu->nurb.first; + while(nu) { + if(event==B_SETSMOOTH) nu->flag |= ME_SMOOTH; + else nu->flag &= ~ME_SMOOTH; + nu= nu->next; + } + } + } + base= base->next; + } + allqueue(REDRAWVIEW3D, 0); + } + break; + + default: + if(event>=B_OBLAY && event<=B_OBLAY+31) { + local= BASACT->lay & 0xFF000000; + BASACT->lay -= local; + if(BASACT->lay==0 || (G.qual & LR_SHIFTKEY)==0) { + bit= event-B_OBLAY; + BASACT->lay= 1<lay += local; + /* optimal redraw */ + if( (OBACT->lay & G.vd->lay) && (BASACT->lay & G.vd->lay) ); + else if( (OBACT->lay & G.vd->lay)==0 && (BASACT->lay & G.vd->lay)==0 ); + else allqueue(REDRAWVIEW3D, 0); + + OBACT->lay= BASACT->lay; + } + } + +} + +void object_panel_draw(Object *ob) +{ + ID *id; + uiBlock *block; + int xco, a, dx, dy; + + + block= uiNewBlock(&curarea->uiblocks, "object_panel_draw", UI_EMBOSSX, UI_HELV, curarea->win); + if(uiNewPanel(curarea, block, "Draw", "Object", 320, 0, 318, 204)==0) return; + + /* LAYERS */ + xco= 151; + dx= 32; + dy= 30; + for(a=0; a<10; a++) { + /* the (a+10) evaluates correctly because of + precedence... brackets aren't a bad idea though */ + uiDefButI(block, TOG|BIT|(a+10), B_OBLAY+a+10, "", (short)(xco+a*(dx/2)), 180, (short)(dx/2), (short)(dy/2), &(BASACT->lay), 0, 0, 0, 0, ""); + uiDefButI(block, TOG|BIT|a, B_OBLAY+a, "",(short)(xco+a*(dx/2)), (short)(180+dy/2), (short)(dx/2), (short)(1+dy/2), &(BASACT->lay), 0, 0, 0, 0, ""); + if(a==4) xco+= 5; + } + + id= ob->data; + if(id && id->lib) uiSetButLock(1, "Can't edit library data"); + + uiBlockSetCol(block, BUTGREY); + uiDefBut(block, LABEL, 0, "Drawtype", 28,200,100,18, 0, 0, 0, 0, 0, ""); + uiDefButC(block, MENU, REDRAWVIEW3D, "Drawtype%t|Bounds %x1|Wire %x2|Solid %x3|Shaded %x4", + 28,180,100,18, &ob->dt, 0, 0, 0, 0, "Sets the drawing type of the active object"); + uiDefBut(block, LABEL, 0, "Draw Extra", 28,160,100,18, 0, 0, 0, 0, 0, ""); + uiDefButC(block, TOG|BIT|0, REDRAWVIEW3D, "Bounds", 28, 140, 100, 18, &ob->dtx, 0, 0, 0, 0, "Displays the active object's bounds"); + uiDefButS(block, MENU, REDRAWVIEW3D, "Boundary Display%t|Box%x0|Sphere%x1|Cylinder%x2|Cone%x3|Polyheder", + 28, 120, 100, 18, &ob->boundtype, 0, 0, 0, 0, "Selects the boundary display type"); + uiDefButC(block, TOG|BIT|5, REDRAWVIEW3D, "Wire", 28, 100, 100, 18, &ob->dtx, 0, 0, 0, 0, "Displays the active object's wireframe in shaded drawing modes"); + uiDefButC(block, TOG|BIT|1, REDRAWVIEW3D, "Axis", 28, 80, 100, 18, &ob->dtx, 0, 0, 0, 0, "Displays the active object's centre and axis"); + uiDefButC(block, TOG|BIT|2, REDRAWVIEW3D, "TexSpace", 28, 60, 100, 18, &ob->dtx, 0, 0, 0, 0, "Displays the active object's texture space"); + uiDefButC(block, TOG|BIT|3, REDRAWVIEW3D, "Name", 28, 40, 100, 18, &ob->dtx, 0, 0, 0, 0, "Displays the active object's name"); + + uiBlockSetCol(block, BUTGREY); + + uiScalePanelBlock(block); // scales and centers + uiDrawBlock(block); + +} + + + + +void do_object_panels(unsigned short event) +{ + Object *ob; + Base *base; + Effect *eff, *effn; + int type; + + ob= OBACT; + + switch(event) { + + case B_RECALCPATH: + calc_curvepath(OBACT); + allqueue(REDRAWVIEW3D, 0); + break; + case B_MUL_IPO: + scale_editipo(); + allqueue(REDRAWBUTSOBJECT, 0); + break; + case B_AUTOTIMEOFS: + auto_timeoffs(); + break; + case B_FRAMEMAP: + G.scene->r.framelen= G.scene->r.framapto; + G.scene->r.framelen/= G.scene->r.images; + break; + case B_NEWEFFECT: + if(ob) { + if (BLI_countlist(&ob->effect)==MAX_EFFECT) + error("Unable to add: effect limit reached"); + else + copy_act_effect(ob); + } + allqueue(REDRAWBUTSOBJECT, 0); + break; + case B_DELEFFECT: + if(ob==0 || ob->type!=OB_MESH) break; + eff= ob->effect.first; + while(eff) { + effn= eff->next; + if(eff->flag & SELECT) { + BLI_remlink(&ob->effect, eff); + free_effect(eff); + break; + } + eff= effn; + } + allqueue(REDRAWBUTSOBJECT, 0); + allqueue(REDRAWVIEW3D, 0); + break; + case B_NEXTEFFECT: + if(ob==0 || ob->type!=OB_MESH) break; + eff= ob->effect.first; + while(eff) { + if(eff->flag & SELECT) { + if(eff->next) { + eff->flag &= ~SELECT; + eff->next->flag |= SELECT; + } + break; + } + eff= eff->next; + } + allqueue(REDRAWBUTSOBJECT, 0); + break; + case B_PREVEFFECT: + if(ob==0 || ob->type!=OB_MESH) break; + eff= ob->effect.first; + while(eff) { + if(eff->flag & SELECT) { + if(eff->prev) { + eff->flag &= ~SELECT; + eff->prev->flag |= SELECT; + } + break; + } + eff= eff->next; + } + allqueue(REDRAWBUTSOBJECT, 0); + break; + case B_CHANGEEFFECT: + if(ob==0 || ob->type!=OB_MESH) break; + eff= ob->effect.first; + while(eff) { + if(eff->flag & SELECT) { + if(eff->type!=eff->buttype) { + BLI_remlink(&ob->effect, eff); + type= eff->buttype; + free_effect(eff); + eff= add_effect(type); + BLI_addtail(&ob->effect, eff); + } + break; + } + eff= eff->next; + } + allqueue(REDRAWBUTSOBJECT, 0); + allqueue(REDRAWVIEW3D, 0); + break; + case B_CALCEFFECT: + if(ob==0 || ob->type!=OB_MESH) break; + eff= ob->effect.first; + while(eff) { + if(eff->flag & SELECT) { + if(eff->type==EFF_PARTICLE) build_particle_system(ob); + else if(eff->type==EFF_WAVE) object_wave(ob); + } + eff= eff->next; + } + allqueue(REDRAWVIEW3D, 0); + allqueue(REDRAWBUTSOBJECT, 0); + break; + case B_RECALCAL: + base= FIRSTBASE; + while(base) { + if(base->lay & G.vd->lay) { + ob= base->object; + eff= ob->effect.first; + while(eff) { + if(eff->flag & SELECT) { + if(eff->type==EFF_PARTICLE) build_particle_system(ob); + } + eff= eff->next; + } + } + base= base->next; + } + allqueue(REDRAWVIEW3D, 0); + break; + case B_SETSPEED: + set_speed_editipo(hspeed); + break; + case B_PRINTSPEED: + ob= OBACT; + if(ob) { + float vec[3]; + CFRA++; + do_ob_ipo(ob); + where_is_object(ob); + VECCOPY(vec, ob->obmat[3]); + CFRA--; + do_ob_ipo(ob); + where_is_object(ob); + VecSubf(vec, vec, ob->obmat[3]); + prspeed= Normalise(vec); + scrarea_queue_winredraw(curarea); + } + break; + case B_PRINTLEN: + ob= OBACT; + if(ob && ob->type==OB_CURVE) { + Curve *cu=ob->data; + + if(cu->path) prlen= cu->path->totdist; else prlen= -1.0; + scrarea_queue_winredraw(curarea); + } + break; + case B_RELKEY: + allspace(REMAKEIPO, 0); + allqueue(REDRAWBUTSOBJECT, 0); + allqueue(REDRAWIPO, 0); + break; + + default: + if(event>=B_SELEFFECT && eventeffect.first; + while(eff) { + if(event==a) eff->flag |= SELECT; + else eff->flag &= ~SELECT; + + a++; + eff= eff->next; + } + allqueue(REDRAWBUTSOBJECT, 0); + } + } + } + +} + +void object_panel_effects(Object *ob) +{ + Effect *eff; + uiBlock *block; + int a; + short x, y; + + block= uiNewBlock(&curarea->uiblocks, "object_panel_effects", UI_EMBOSSX, UI_HELV, curarea->win); + if(uiNewPanel(curarea, block, "Effects", "Object", 640, 0, 418, 204)==0) return; + + uiBlockSetCol(block, BUTSALMON); + + /* EFFECTS */ + + if (ob->type == OB_MESH) { + uiDefBut(block, BUT, B_NEWEFFECT, "NEW Effect", 550,187,124,27, 0, 0, 0, 0, 0, "Create a new effect"); + uiDefBut(block, BUT, B_DELEFFECT, "Delete", 676,187,62,27, 0, 0, 0, 0, 0, "Delete the effect"); + } + + uiBlockSetCol(block, BUTGREY); + + /* select effs */ + eff= ob->effect.first; + a= 0; + while(eff) { + + x= 15 * a + 550; + y= 172; // - 12*( abs(a/10) ) ; + uiDefButS(block, TOG|BIT|0, B_SELEFFECT+a, "", x, y, 15, 12, &eff->flag, 0, 0, 0, 0, ""); + + a++; + if(a==MAX_EFFECT) break; + eff= eff->next; + } + + eff= ob->effect.first; + while(eff) { + if(eff->flag & SELECT) break; + eff= eff->next; + } + + if(eff) { + uiDefButS(block, MENU, B_CHANGEEFFECT, "Build %x0|Particles %x1|Wave %x2", 895,187,107,27, &eff->buttype, 0, 0, 0, 0, "Start building the effect"); + + if(eff->type==EFF_BUILD) { + BuildEff *bld; + + bld= (BuildEff *)eff; + + uiDefButF(block, NUM, 0, "Len:", 649,138,95,21, &bld->len, 1.0, 9000.0, 100, 0, "Specify the total time the building requires"); + uiDefButF(block, NUM, 0, "Sfra:", 746,138,94,22, &bld->sfra, 1.0, 9000.0, 100, 0, "Specify the startframe of the effect"); + } + else if(eff->type==EFF_WAVE) { + WaveEff *wav; + + wav= (WaveEff *)eff; + + uiBlockSetCol(block, BUTGREEN); + uiDefButS(block, TOG|BIT|1, B_CALCEFFECT, "X", 782,135,54,23, &wav->flag, 0, 0, 0, 0, "Enable X axis"); + uiDefButS(block, TOG|BIT|2, B_CALCEFFECT, "Y", 840,135,47,23, &wav->flag, 0, 0, 0, 0, "Enable Y axis"); + uiDefButS(block, TOG|BIT|3, B_CALCEFFECT, "Cycl", 890,135,111,23, &wav->flag, 0, 0, 0, 0, "Enable cyclic wave efefct"); + + uiBlockSetCol(block, BUTGREY); + uiDefButF(block, NUM, B_CALCEFFECT, "Sta x:", 550,135,113,24, &wav->startx, -100.0, 100.0, 100, 0, "Starting position for the X axis"); + uiDefButF(block, NUM, B_CALCEFFECT, "Sta y:", 665,135,104,24, &wav->starty, -100.0, 100.0, 100, 0, "Starting position for the Y axis"); + + uiDefButF(block, NUMSLI, B_CALCEFFECT, "Speed:", 550,100,216,20, &wav->speed, -2.0, 2.0, 0, 0, "Specify the wave speed"); + uiDefButF(block, NUMSLI, B_CALCEFFECT, "Heigth:", 550,80,216,20, &wav->height, -2.0, 2.0, 0, 0, "Specify the amplitude of the wave"); + uiDefButF(block, NUMSLI, B_CALCEFFECT, "Width:", 550,60,216,20, &wav->width, 0.0, 5.0, 0, 0, "Specify the width of the wave"); + uiDefButF(block, NUMSLI, B_CALCEFFECT, "Narrow:", 550,40,216,20, &wav->narrow, 0.0, 10.0, 0, 0, "Specify how narrow the wave follows"); + + uiDefButF(block, NUM, B_CALCEFFECT, "Time sta:", 780,100,219,20, &wav->timeoffs, -1000.0, 1000.0, 100, 0, "Specify startingframe of the wave"); + + uiDefButF(block, NUM, B_CALCEFFECT, "Lifetime:", 780,80,219,20, &wav->lifetime, -1000.0, 1000.0, 100, 0, "Specify the lifespan of the wave"); + uiDefButF(block, NUM, B_CALCEFFECT, "Damptime:", 780,60,219,20, &wav->damp, -1000.0, 1000.0, 100, 0, "Specify the dampingtime of the wave"); + + } + else if(eff->type==EFF_PARTICLE) { + PartEff *paf; + + paf= (PartEff *)eff; + + uiDefBut(block, BUT, B_RECALCAL, "RecalcAll", 741,187,67,27, 0, 0, 0, 0, 0, "Update the particle system"); + uiBlockSetCol(block, BUTGREEN); + uiDefButS(block, TOG|BIT|2, B_CALCEFFECT, "Static", 825,187,67,27, &paf->flag, 0, 0, 0, 0, "Make static particles"); + uiBlockSetCol(block, BUTGREY); + + uiDefButI(block, NUM, B_CALCEFFECT, "Tot:", 550,146,91,20, &paf->totpart, 1.0, 100000.0, 0, 0, "Set the total number of particles"); + if(paf->flag & PAF_STATIC) { + uiDefButS(block, NUM, REDRAWVIEW3D, "Step:", 644,146,84,20, &paf->staticstep, 1.0, 100.0, 10, 0, ""); + } + else { + uiDefButF(block, NUM, B_CALCEFFECT, "Sta:", 644,146,84,20, &paf->sta, -250.0, 9000.0, 100, 0, "Specify the startframe"); + uiDefButF(block, NUM, B_CALCEFFECT, "End:", 731,146,97,20, &paf->end, 1.0, 9000.0, 100, 0, "Specify the endframe"); + } + uiDefButF(block, NUM, B_CALCEFFECT, "Life:", 831,146,88,20, &paf->lifetime, 1.0, 9000.0, 100, 0, "Specify the life span of the particles"); + uiDefButI(block, NUM, B_CALCEFFECT, "Keys:", 922,146,80,20, &paf->totkey, 1.0, 32.0, 0, 0, "Specify the number of key positions"); + + uiBlockSetCol(block, BUTGREEN); + uiDefButS(block, NUM, B_REDR, "CurMul:", 550,124,91,20, &paf->curmult, 0.0, 3.0, 0, 0, "Multiply the particles"); + uiBlockSetCol(block, BUTGREY); + uiDefButS(block, NUM, B_CALCEFFECT, "Mat:", 644,124,84,20, paf->mat+paf->curmult, 1.0, 8.0, 0, 0, "Specify the material used for the particles"); + uiDefButF(block, NUM, B_CALCEFFECT, "Mult:", 730,124,98,20, paf->mult+paf->curmult, 0.0, 1.0, 10, 0, "Probability \"dying\" particle spawns a new one."); + uiDefButS(block, NUM, B_CALCEFFECT, "Child:", 922,124,80,20, paf->child+paf->curmult, 1.0, 600.0, 100, 0, "Specify the number of children of a particle that multiply itself"); + uiDefButF(block, NUM, B_CALCEFFECT, "Life:", 831,124,89,20, paf->life+paf->curmult, 1.0, 600.0, 100, 0, "Specify the lifespan of the next generation particles"); + + uiDefButF(block, NUM, B_CALCEFFECT, "Randlife:", 550,96,96,20, &paf->randlife, 0.0, 2.0, 10, 0, "Give the particlelife a random variation"); + uiDefButI(block, NUM, B_CALCEFFECT, "Seed:", 652,96,80,20, &paf->seed, 0.0, 255.0, 0, 0, "Set an offset in the random table"); + + uiDefButF(block, NUM, B_DIFF, "VectSize", 885,96,116,20, &paf->vectsize, 0.0, 1.0, 10, 0, "Set the speed for Vect"); + uiBlockSetCol(block, BUTGREEN); + uiDefButS(block, TOG|BIT|3, B_CALCEFFECT, "Face", 735,96,46,20, &paf->flag, 0, 0, 0, 0, "Emit particles also from faces"); + uiDefButS(block, TOG|BIT|1, B_CALCEFFECT, "Bspline", 782,96,54,20, &paf->flag, 0, 0, 0, 0, "Use B spline formula for particle interpolation"); + uiDefButS(block, TOG, REDRAWVIEW3D, "Vect", 837,96,45,20, &paf->stype, 0, 0, 0, 0, "Give the particles a rotation direction"); + + uiBlockSetCol(block, BUTPURPLE); + uiDefButF(block, NUM, B_CALCEFFECT, "Norm:", 550,67,96,20, &paf->normfac, -2.0, 2.0, 10, 0, "Let the mesh give the particle a starting speed"); + uiDefButF(block, NUM, B_CALCEFFECT, "Ob:", 649,67,86,20, &paf->obfac, -1.0, 1.0, 10, 0, "Let the object give the particle a starting speed"); + uiDefButF(block, NUM, B_CALCEFFECT, "Rand:", 738,67,86,20, &paf->randfac, 0.0, 2.0, 10, 0, "Give the startingspeed a random variation"); + uiDefButF(block, NUM, B_CALCEFFECT, "Tex:", 826,67,85,20, &paf->texfac, 0.0, 2.0, 10, 0, "Let the texture give the particle a starting speed"); + uiDefButF(block, NUM, B_CALCEFFECT, "Damp:", 913,67,89,20, &paf->damp, 0.0, 1.0, 10, 0, "Specify the damping factor"); + + uiBlockSetCol(block, BUTGREY); + uiDefButF(block, NUM, B_CALCEFFECT, "X:", 550,31,72,20, paf->force, -1.0, 1.0, 1, 0, "Specify the X axis of a continues force"); + uiDefButF(block, NUM, B_CALCEFFECT, "Y:", 624,31,78,20, paf->force+1,-1.0, 1.0, 1, 0, "Specify the Y axis of a continues force"); + uiDefBut(block, LABEL, 0, "Force:", 550,9,72,20, 0, 1.0, 0, 0, 0, ""); + uiDefButF(block, NUM, B_CALCEFFECT, "Z:", 623,9,79,20, paf->force+2, -1.0, 1.0, 1, 0, "Specify the Z axis of a continues force"); + + uiDefBut(block, LABEL, 0, "Texture:", 722,9,74,20, 0, 1.0, 0, 0, 0, ""); + uiBlockSetCol(block, BUTGREEN); + uiDefButS(block, ROW, B_CALCEFFECT, "Int", 875,9,32,43, &paf->texmap, 14.0, 0.0, 0, 0, "Use texture intensity as a factor for texture force"); + uiDefButS(block, ROW, B_CALCEFFECT, "RGB", 911,31,45,20, &paf->texmap, 14.0, 1.0, 0, 0, "Use RGB values as a factor for particle speed"); + uiDefButS(block, ROW, B_CALCEFFECT, "Grad", 958,31,44,20, &paf->texmap, 14.0, 2.0, 0, 0, "Use texture gradient as a factor for particle speed"); + uiBlockSetCol(block, BUTGREY); + uiDefButF(block, NUM, B_CALCEFFECT, "Nabla:", 911,9,91,20, &paf->nabla, 0.0001, 1.0, 1, 0, "Specify the dimension of the area for gradient calculation"); + uiDefButF(block, NUM, B_CALCEFFECT, "X:", 722,31,74,20, paf->defvec, -1.0, 1.0, 1, 0, "Specify the X axis of a force, determined by the texture"); + uiDefButF(block, NUM, B_CALCEFFECT, "Y:", 798,31,74,20, paf->defvec+1,-1.0, 1.0, 1, 0, "Specify the Y axis of a force, determined by the texture"); + uiDefButF(block, NUM, B_CALCEFFECT, "Z:", 797,9,75,20, paf->defvec+2, -1.0, 1.0, 1, 0, "Specify the Z axis of a force, determined by the texture"); + + } + } + + uiScalePanelBlock(block); // scales and centers + uiDrawBlock(block); +} + +static void object_panel_anim(Object *ob) +{ + uiBlock *block; + char str[32]; + + block= uiNewBlock(&curarea->uiblocks, "object_panel_anim", UI_EMBOSSX, UI_HELV, curarea->win); + if(uiNewPanel(curarea, block, "Anim settings", "Object", 0, 0, 318, 204)==0) return; + + uiBlockSetCol(block, BUTGREEN); + uiDefButC(block, ROW,REDRAWVIEW3D,"TrackX", 27,190,58,17, &ob->trackflag, 12.0, 0.0, 0, 0, "Specify the axis that points to another object"); + uiDefButC(block, ROW,REDRAWVIEW3D,"Y", 85,190,19,17, &ob->trackflag, 12.0, 1.0, 0, 0, "Specify the axis that points to another object"); + uiDefButC(block, ROW,REDRAWVIEW3D,"Z", 104,190,19,17, &ob->trackflag, 12.0, 2.0, 0, 0, "Specify the axis that points to another object"); + uiDefButC(block, ROW,REDRAWVIEW3D,"-X", 124,190,24,17, &ob->trackflag, 12.0, 3.0, 0, 0, "Specify the axis that points to another object"); + uiDefButC(block, ROW,REDRAWVIEW3D,"-Y", 150,190,24,17, &ob->trackflag, 12.0, 4.0, 0, 0, "Specify the axis that points to another object"); + uiDefButC(block, ROW,REDRAWVIEW3D,"-Z", 177,190,24,17, &ob->trackflag, 12.0, 5.0, 0, 0, "Specify the axis that points to another object"); + uiDefButC(block, ROW,REDRAWVIEW3D,"UpX", 226,190,45,17, &ob->upflag, 13.0, 0.0, 0, 0, "Specify the axis that points up"); + uiDefButC(block, ROW,REDRAWVIEW3D,"Y", 274,190,20,17, &ob->upflag, 13.0, 1.0, 0, 0, "Specify the axis that points up"); + uiDefButC(block, ROW,REDRAWVIEW3D,"Z", 297,190,19,17, &ob->upflag, 13.0, 2.0, 0, 0, "Specify the axis that points up"); + + uiBlockSetCol(block, BUTGREEN); + uiDefButC(block, TOG|BIT|0, REDRAWVIEW3D, "Draw Key", 25,160,70,19, &ob->ipoflag, 0, 0, 0, 0, "Draw object as key position"); + uiDefButC(block, TOG|BIT|1, REDRAWVIEW3D, "Draw Key Sel", 97,160,81,20, &ob->ipoflag, 0, 0, 0, 0, "Limit the drawing of object keys"); + uiDefButS(block, TOG|BIT|4, 0, "SlowPar", 261,160,56,20, &ob->partype, 0, 0, 0, 0, "Create a delay in the parent relationship"); + uiDefButC(block, TOG|BIT|7, REDRAWVIEW3D, "Powertrack", 180,160,78,19, &ob->transflag, 0, 0, 0, 0, "Switch objects rotation off"); + + + uiBlockSetCol(block, BUTGREY); + uiDefButC(block, TOG|BIT|3, REDRAWVIEW3D, "DupliFrames", 24,128,88,19, &ob->transflag, 0, 0, 0, 0, "Make copy of object for every frame"); + uiDefButC(block, TOG|BIT|4, REDRAWVIEW3D, "DupliVerts", 114,128,82,19, &ob->transflag, 0, 0, 0, 0, "Duplicate child objects on all vertices"); + uiBlockSetCol(block, BUTGREEN); + uiDefButC(block, TOG|BIT|5, REDRAWVIEW3D, "Rot", 200,128,31,20, &ob->transflag, 0, 0, 0, 0, "Rotate dupli according to facenormal"); + uiDefButC(block, TOG|BIT|6, REDRAWVIEW3D, "No Speed", 234,128,82,19, &ob->transflag, 0, 0, 0, 0, "Set dupliframes to still, regardless of frame"); + + uiBlockSetCol(block, BUTGREY); + uiDefButS(block, NUM, REDRAWVIEW3D, "DupSta:", 24,105,141,18, &ob->dupsta, 1.0, 1500.0, 0, 0, "Specify startframe for Dupliframes"); + uiDefButS(block, NUM, REDRAWVIEW3D, "DupEnd", 24,83,140,19, &ob->dupend, 1.0, 2500.0, 0, 0, "Specify endframe for Dupliframes"); + uiDefButS(block, NUM, REDRAWVIEW3D, "DupOn:", 169,104,146,19, &ob->dupon, 1.0, 1500.0, 0, 0, ""); + uiDefButS(block, NUM, REDRAWVIEW3D, "DupOff", 169,82,145,19, &ob->dupoff, 0.0, 1500.0, 0, 0, ""); + + uiBlockSetCol(block, BUTGREEN); + uiDefButC(block, TOG|BIT|2, REDRAWALL, "Offs Ob", 23,51,56,20, &ob->ipoflag, 0, 0, 0, 0, "Let the timeoffset work on its own objectipo"); + uiDefButC(block, TOG|BIT|6, REDRAWALL, "Offs Par", 82,51,56,20 , &ob->ipoflag, 0, 0, 0, 0, "Let the timeoffset work on the parent"); + uiDefButC(block, TOG|BIT|7, REDRAWALL, "Offs Particle", 141,51,103,20, &ob->ipoflag, 0, 0, 0, 0, "Let the timeoffset work on the particle effect"); + + uiBlockSetCol(block, BUTGREY); + sprintf(str, "%.4f", prspeed); + uiDefBut(block, LABEL, 0, str, 247,40,63,31, 0, 1.0, 0, 0, 0, ""); + uiDefBut(block, BUT, B_PRINTSPEED, "PrSpeed", 246,17,67,31, 0, 0, 0, 0, 0, "Print objectspeed"); + + uiBlockSetCol(block, BUTGREY); + uiDefButF(block, NUM, REDRAWALL, "TimeOffset:", 23,17,114,30, &ob->sf, -9000.0, 9000.0, 100, 0, "Specify an offset in frames"); + uiBlockSetCol(block, BUTSALMON); + uiDefBut(block, BUT, B_AUTOTIMEOFS, "Automatic Time", 139,17,104,31, 0, 0, 0, 0, 0, "Generate automatic timeoffset values for all selected frames"); + +#if 0 + /* IPO BUTTONS AS LAST */ + ScrArea *sa; + + ok= 0; + if(G.sipo) { + /* do these exist? */ + sa= G.curscreen->areabase.first; + while(sa) { + if(sa->spacetype==SPACE_IPO && sa->spacedata.first==G.sipo) break; + sa= sa->next; + } + if(sa) { + if(G.sipo->ipo && G.sipo->ipo->curve.first) ok= 1; + } + } + + uiBlockSetCol(block, BUTGREY); + + sprintf(str, "%.3f", G.sipo->v2d.tot.xmin); + uiDefBut(block, LABEL, 0, str, 1020, 140, 100, 19, 0, 0, 0, 0, 0, ""); + sprintf(str, "%.3f", G.sipo->v2d.tot.xmax); + uiDefBut(block, LABEL, 0, str, 1120, 140, 100, 19, 0, 0, 0, 0, 0, ""); + + uiDefButF(block, NUM, B_DIFF, "Xmin:", 1020, 120, 100, 19, &G.sipo->tot.xmin, -G.sipo->v2d.max[0], G.sipo->v2d.max[0], 100, 0, ""); + uiDefButF(block, NUM, B_DIFF, "Xmax:", 1120, 120, 100, 19, &G.sipo->tot.xmax, -G.sipo->v2d.max[0], G.sipo->v2d.max[0], 100, 0, ""); + + sprintf(str, "%.3f", G.sipo->v2d.tot.ymin); + uiDefBut(block, LABEL, 0, str, 1020, 100, 100, 19, 0, 0, 0, 0, 0, ""); + sprintf(str, "%.3f", G.sipo->v2d.tot.ymax); + uiDefBut(block, LABEL, 0, str, 1120, 100, 100, 19, 0, 0, 0, 0, 0, ""); + + uiDefButF(block, NUM, B_DIFF, "Ymin:", 1020, 80, 100, 19, &G.sipo->tot.ymin, -G.sipo->v2d.max[1], G.sipo->v2d.max[1], 100, 0, ""); + uiDefButF(block, NUM, B_DIFF, "Ymax:", 1120, 80, 100, 19, &G.sipo->tot.ymax, -G.sipo->v2d.max[1], G.sipo->v2d.max[1], 100, 0, ""); + + uiBlockSetCol(block, BUTSALMON); + uiDefBut(block, BUT, B_MUL_IPO, "SET", 1220,79,50,62, 0, 0, 0, 0, 0, ""); + + + /* SPEED BUTTON */ + uiBlockSetCol(block, BUTGREY); + uiDefButF(block, NUM, B_DIFF, "Speed:", 1020,23,164,28, &hspeed, 0.0, 180.0, 1, 0, ""); + + uiBlockSetCol(block, BUTSALMON); + uiDefBut(block, BUT, B_SETSPEED, "SET", 1185,23,83,29, 0, 0, 0, 0, 0, ""); + +#endif + + + uiScalePanelBlock(block); // scales and centers + uiDrawBlock(block); +} + +void object_panels() +{ + Object *ob; + + /* check context here */ + ob= OBACT; + if(ob) { + object_panel_anim(ob); + object_panel_draw(ob); + if(ob->type==OB_MESH) + object_panel_effects(ob); + } +} + diff --git a/source/blender/src/buttons_scene.c b/source/blender/src/buttons_scene.c index 19384c78cae..3b29a00d0c7 100644 --- a/source/blender/src/buttons_scene.c +++ b/source/blender/src/buttons_scene.c @@ -84,6 +84,8 @@ #include "BIF_writeimage.h" #include "BIF_writeavicodec.h" +#include "butspace.h" // own module + #ifdef WITH_QUICKTIME #include "quicktime_export.h" #endif @@ -644,8 +646,7 @@ static void render_panel_output() block= uiNewBlock(&curarea->uiblocks, "render_panel_output", UI_EMBOSSX, UI_HELV, curarea->win); - uiNewPanel(curarea, block, "Output", "Render", 0, 0, 318, 204); - if( uiIsPanelClosed(block) ) return; // does draw when closed + if(uiNewPanel(curarea, block, "Output", "Render", 0, 0, 318, 204)==0) return; uiDefBut(block, TEX,0,"", 30, 170, 268, 19,G.scene->r.pic, 0.0,79.0, 0, 0, "Directory/name to save rendered Pics to"); uiDefBut(block, BUT,B_FS_PIC," ", 8, 170, 20, 19, 0, 0, 0, 0, 0, "Open Fileselect to get Pics dir/name"); @@ -701,9 +702,6 @@ static void render_panel_output() "The gamma value for blending oversampled images (1.0 = no correction)."); } } - - uiScalePanelBlock(block); // scales and centers - uiDrawBlock(block); } static void render_panel_render() @@ -712,8 +710,7 @@ static void render_panel_render() block= uiNewBlock(&curarea->uiblocks, "render_panel_render", UI_EMBOSSX, UI_HELV, curarea->win); - uiNewPanel(curarea, block, "Render", "Render", 320, 0, 318, 204); - if( uiIsPanelClosed(block) ) return; // does draw when closed + if(uiNewPanel(curarea, block, "Render", "Render", 320, 0, 318, 204)==0) return; uiBlockSetCol(block, BUTSALMON); @@ -757,8 +754,6 @@ static void render_panel_render() uiDefButS(block, TOG|BIT|2,0, "Gamma", 626,11,58,24, &G.scene->r.mode, 0, 0, 0, 0, "Enable gamma correction"); - uiScalePanelBlock(block); // scales and centers - uiDrawBlock(block); } static void render_panel_anim() @@ -767,8 +762,7 @@ static void render_panel_anim() block= uiNewBlock(&curarea->uiblocks, "render_panel_anim", UI_EMBOSSX, UI_HELV, curarea->win); - uiNewPanel(curarea, block, "Anim", "Render", 640, 0, 318, 204); - if( uiIsPanelClosed(block) ) return; // does draw when closed + if(uiNewPanel(curarea, block, "Anim", "Render", 640, 0, 318, 204)==0) return; uiBlockSetCol(block, BUTSALMON); @@ -786,8 +780,6 @@ static void render_panel_anim() uiDefButS(block, NUM,REDRAWSEQ,"Sta:", 692,10,94,24, &G.scene->r.sfra,1.0,18000.0, 0, 0, "The start frame of the animation"); uiDefButS(block, NUM,REDRAWSEQ,"End:", 790,10,95,24, &G.scene->r.efra,1.0,18000.0, 0, 0, "The end frame of the animation"); - uiScalePanelBlock(block); // scales and centers - uiDrawBlock(block); } static void render_panel_format() @@ -797,8 +789,7 @@ static void render_panel_format() block= uiNewBlock(&curarea->uiblocks, "render_panel_format", UI_EMBOSSX, UI_HELV, curarea->win); - uiNewPanel(curarea, block, "Format", "Render", 960, 0, 318, 204); - if( uiIsPanelClosed(block) ) return; // does draw when closed + if(uiNewPanel(curarea, block, "Format", "Render", 960, 0, 318, 204)==0) return; uiDefBlockBut(block, framing_render_menu, NULL, "Game framing settings |>> ", 892, 169, 227, 20, "Display game framing settings"); @@ -891,9 +882,6 @@ static void render_panel_format() uiDefBut(block, BUT,B_PR_FULL, "FULL", 1146,30,100,18, 0, 0, 0, 0, 0, "Size preset: Image size - 1280x1024, Aspect ratio - 1x1"); uiDefButS(block, TOG|BIT|15, B_REDR, "Unified Renderer", 1146,10,100,18, &G.scene->r.mode, 0, 0, 0, 0, "Use the unified renderer."); - - uiScalePanelBlock(block); // scales and centers - uiDrawBlock(block); } @@ -906,3 +894,41 @@ void render_panels() render_panel_format(); } + +/* --------------------------------------------- */ + +void anim_panels() +{ + uiBlock *block; + + + block= uiNewBlock(&curarea->uiblocks, "anim_panels", UI_EMBOSSX, UI_HELV, curarea->win); + + uiDefButS(block, NUM,REDRAWSEQ,"Sta:", 320,17,93,27,&G.scene->r.sfra,1.0,18000.0, 0, 0, "Specify the start frame of the animation"); + uiDefButS(block, NUM,REDRAWSEQ,"End:", 416,17,95,27,&G.scene->r.efra,1.0,18000.0, 0, 0, "Specify the end frame of the animation"); + + uiDefButS(block, NUM,B_FRAMEMAP,"Map Old:", 320,69,93,22,&G.scene->r.framapto,1.0,900.0, 0, 0, "Specify old map value in frames"); + uiDefButS(block, NUM,B_FRAMEMAP,"Map New:", 416,69,95,22,&G.scene->r.images,1.0,900.0, 0, 0, "Specify new map value in frames"); + + uiDefButS(block, NUM,REDRAWSEQ,"Frs/sec:", 320,47,93,19, &G.scene->r.frs_sec, 1.0, 120.0, 100.0, 0, "Frames per second"); + + uiBlockSetCol(block, BUTGREEN); + uiDefButS(block, TOG|BIT|1, B_SOUND_CHANGED, "Sync", 416,47,95,19, &G.scene->audio.flag, 0, 0, 0, 0, "Use sample clock for syncing animation to audio"); + + + uiDrawBlock(block); + + +} + +/* --------------------------------------------- */ + +void sound_panels() +{ + + + +} + + + diff --git a/source/blender/src/buttons_script.c b/source/blender/src/buttons_script.c new file mode 100644 index 00000000000..834b1083d4e --- /dev/null +++ b/source/blender/src/buttons_script.c @@ -0,0 +1,82 @@ +/** + * $Id: + * + * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. The Blender + * Foundation also sells licenses for use in proprietary software under + * the Blender License. See http://www.blender.org/BL/ for information + * about this. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL/BL DUAL LICENSE BLOCK ***** + */ + +#include +#include +#include +#include + +#ifdef HAVE_CONFIG_H +#include +#endif + +#ifdef WIN32 +#include "BLI_winstuff.h" +#endif + +#include "MEM_guardedalloc.h" +#include "DNA_screen_types.h" +#include "DNA_space_types.h" +#include "DNA_scene_types.h" + +#include "BKE_global.h" +#include "BKE_main.h" +#include "BKE_library.h" + +#include "BLI_blenlib.h" + +#include "BSE_filesel.h" + +#include "BIF_gl.h" +#include "BIF_graphics.h" +#include "BIF_keyval.h" +#include "BIF_mainqueue.h" +#include "BIF_resources.h" +#include "BIF_screen.h" +#include "BIF_mywindow.h" +#include "BIF_space.h" +#include "BIF_glutil.h" +#include "BIF_interface.h" +#include "BIF_toolbox.h" + +#include "BIF_butspace.h" + +#include "interface.h" +#include "mydevice.h" +#include "blendef.h" + + +void script_panels() +{ + + +} diff --git a/source/blender/src/buttons_shading.c b/source/blender/src/buttons_shading.c new file mode 100644 index 00000000000..53824014b46 --- /dev/null +++ b/source/blender/src/buttons_shading.c @@ -0,0 +1,85 @@ +/** + * $Id: + * + * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. The Blender + * Foundation also sells licenses for use in proprietary software under + * the Blender License. See http://www.blender.org/BL/ for information + * about this. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL/BL DUAL LICENSE BLOCK ***** + */ + +#include +#include +#include +#include + +#ifdef HAVE_CONFIG_H +#include +#endif + +#ifdef WIN32 +#include "BLI_winstuff.h" +#endif + +#include "MEM_guardedalloc.h" +#include "DNA_screen_types.h" +#include "DNA_space_types.h" +#include "DNA_scene_types.h" + +#include "BKE_global.h" +#include "BKE_main.h" +#include "BKE_library.h" + +#include "BLI_blenlib.h" + +#include "BSE_filesel.h" + +#include "BIF_gl.h" +#include "BIF_graphics.h" +#include "BIF_keyval.h" +#include "BIF_mainqueue.h" +#include "BIF_resources.h" +#include "BIF_screen.h" +#include "BIF_mywindow.h" +#include "BIF_space.h" +#include "BIF_glutil.h" +#include "BIF_interface.h" +#include "BIF_toolbox.h" + +#include "BIF_butspace.h" + +#include "interface.h" +#include "mydevice.h" +#include "blendef.h" + +/* -----includes for this file specific----- */ + +#include "butspace.h" // own module + +void shading_panels() +{ + + +} diff --git a/source/blender/src/editarmature.c b/source/blender/src/editarmature.c index 90a15fc6d1a..d0a428408be 100644 --- a/source/blender/src/editarmature.c +++ b/source/blender/src/editarmature.c @@ -110,12 +110,10 @@ extern float centre[3], centroid[3]; /* Originally defined in editobject.c */ /* Local Function Prototypes */ static void editbones_to_armature (ListBase *bones, Object *ob); -static int editbone_to_parnr (EditBone *bone); -static void validate_editbonebutton(EditBone *bone); static void fix_bonelist_roll (ListBase *bonelist, ListBase *editbonelist); static int select_bonechildren_by_name (struct Bone *bone, char *name, int select); -static void build_bonestring (char *string, struct EditBone *bone); + static void draw_boneverti (float x, float y, float z, float size, int flag); static void draw_bone (int armflag, int boneflag, unsigned int id, char *name, float length); static void draw_bonechildren (struct Bone *bone, int flag, unsigned int *index); @@ -124,7 +122,6 @@ static void make_boneList(struct ListBase* list, struct ListBase *bones, struct static void make_bone_menu_children (struct Bone *bone, char *str, int *index); static void delete_bone(struct EditBone* exBone); static void clear_armature_children (struct Bone *bone, struct bPose *pose, char mode); -static void parnr_to_editbone(EditBone *bone); static int count_bones (struct bArmature *arm, int flagmask, int allbones); @@ -134,11 +131,10 @@ static void deselect_bonechildren (struct Bone *bone, int mode); static void selectconnected_posebonechildren (struct Bone *bone); static int editbone_name_exists (char* name); -static void unique_editbone_name (char* name); + static void *get_nearest_bone (int findunsel); static EditBone * get_nearest_editbonepoint (int findunsel, int *selmask); -static void attach_bone_to_parent(EditBone *bone); static Bone *get_first_selected_bonechildren (Bone *bone); @@ -1703,251 +1699,6 @@ static void add_bone_input (Object *ob) } -static void validate_editbonebutton_cb(void *bonev, void *arg2_unused) -{ - EditBone *curBone= bonev; - validate_editbonebutton(curBone); -} -static void parnr_to_editbone_cb(void *bonev, void *arg2_unused) -{ - EditBone *curBone= bonev; - parnr_to_editbone(curBone); -} -static void attach_bone_to_parent_cb(void *bonev, void *arg2_unused) -{ - EditBone *curBone= bonev; - attach_bone_to_parent(curBone); -} - -void armaturebuts(void) -{ - bArmature *arm=NULL; - Object *ob=NULL; - uiBlock *block=NULL; - char str[64]; - int bx=148, by=100; - EditBone *curBone; - uiBut *but; - char *boneString=NULL; - int index; - - ob= OBACT; - if (ob==NULL) return; - - sprintf(str, "editbuttonswin %d", curarea->win); - block= uiNewBlock (&curarea->uiblocks, str, UI_EMBOSSX, UI_HELV, curarea->win); - - arm= ob->data; - if (arm==NULL) return; - - uiBlockSetCol(block, BUTGREEN); - uiDefButI(block, TOG|BIT|ARM_RESTPOSBIT,REDRAWVIEW3D, "Rest Pos", bx,by,97,20, &arm->flag, 0, 0, 0, 0, "Disable all animation for this object"); - uiDefButI(block, TOG|BIT|ARM_DRAWAXESBIT,REDRAWVIEW3D, "Draw Axes", bx,by-46,97,20, &arm->flag, 0, 0, 0, 0, "Draw bone axes"); - uiDefButI(block, TOG|BIT|ARM_DRAWNAMESBIT,REDRAWVIEW3D, "Draw Names", bx,by-69,97,20, &arm->flag, 0, 0, 0, 0, "Draw bone names"); - uiDefButI(block, TOG|BIT|ARM_DRAWXRAYBIT,REDRAWVIEW3D, "X-Ray", bx,by-92,97,20, &arm->flag, 0, 0, 0, 0, "Draw armature in front of shaded objects"); - - uiBlockSetCol(block, BUTGREY); - - /* Draw the bone name block */ - - bx+=400; by=200; - - if (G.obedit==ob){ - uiDefBut(block, LABEL, 0, "Selected Bones", bx,by,128,18, 0, 0, 0, 0, 0, ""); - by-=20; - for (curBone=G.edbo.first, index=0; curBone; curBone=curBone->next, index++){ - if (curBone->flag & (BONE_SELECTED)){ - - /* Hide in posemode flag */ - uiBlockSetCol(block, BUTGREEN); - uiDefButI(block, TOG|BIT|BONE_HIDDENBIT, REDRAWVIEW3D, "Hide", bx-50,by,48,18, &curBone->flag, 0, 0, 0, 0, "Toggles display of this bone in posemode"); - - /* Bone naming button */ - uiBlockSetCol(block, BUTGREY); - strcpy (curBone->oldname, curBone->name); - but=uiDefBut(block, TEX, REDRAWVIEW3D, "BO:", bx,by,97,18, &curBone->name, 0, 24, 0, 0, "Change the bone name"); - uiButSetFunc(but, validate_editbonebutton_cb, curBone, NULL); - - uiDefBut(block, LABEL, 0, "child of", bx+106,by,100,18, NULL, 0.0, 0.0, 0.0, 0.0, ""); - - boneString = malloc((BLI_countlist(&G.edbo) * 64)+64); - build_bonestring (boneString, curBone); - - curBone->parNr = editbone_to_parnr(curBone->parent); - but = uiDefButI(block, MENU,REDRAWVIEW3D, boneString, bx+164,by,97,18, &curBone->parNr, 0.0, 0.0, 0.0, 0.0, "Parent"); - uiButSetFunc(but, parnr_to_editbone_cb, curBone, NULL); - - free(boneString); - - /* IK to parent flag */ - if (curBone->parent){ - uiBlockSetCol(block, BUTGREEN); - but=uiDefButI(block, TOG|BIT|BONE_IK_TOPARENTBIT, REDRAWVIEW3D, "IK", bx+275,by,32,18, &curBone->flag, 0.0, 0.0, 0.0, 0.0, "IK link to parent"); - uiButSetFunc(but, attach_bone_to_parent_cb, curBone, NULL); - } - - /* Dist and weight buttons */ - uiBlockSetCol(block, BUTGREY); - but=uiDefButS(block, MENU, REDRAWVIEW3D, - "Skinnable %x0|" - "Unskinnable %x1|" - "Head %x2|" - "Neck %x3|" - "Back %x4|" - "Shoulder %x5|" - "Arm %x6|" - "Hand %x7|" - "Finger %x8|" - "Thumb %x9|" - "Pelvis %x10|" - "Leg %x11|" - "Foot %x12|" - "Toe %x13|" - "Tentacle %x14", - bx+320,by,97,18, - &curBone->boneclass, - 0.0, 0.0, 0.0, 0.0, - "Classification of armature element"); - - /* Dist and weight buttons */ - uiBlockSetCol(block, BUTGREY); - uiDefButF(block, NUM,REDRAWVIEW3D, "Dist:", bx+425, by, - 110, 18, &curBone->dist, 0.0, 1000.0, 10.0, 0.0, - "Bone deformation distance"); - uiDefButF(block, NUM,REDRAWVIEW3D, "Weight:", bx+543, by, - 110, 18, &curBone->weight, 0.0F, 1000.0F, - 10.0F, 0.0F, "Bone deformation weight"); - - by-=19; - } - } - } - - uiDrawBlock (block); - -} - -static int editbone_to_parnr (EditBone *bone) -{ - EditBone *ebone; - int index; - - for (ebone=G.edbo.first, index=0; ebone; ebone=ebone->next, index++){ - if (ebone==bone) - return index; - } - - return -1; -} - -static void parnr_to_editbone(EditBone *bone) -{ - if (bone->parNr == -1){ - bone->parent = NULL; - bone->flag &= ~BONE_IK_TOPARENT; - } - else{ - bone->parent = BLI_findlink(&G.edbo, bone->parNr); - attach_bone_to_parent(bone); - } -} - -static void attach_bone_to_parent(EditBone *bone) -{ - EditBone *curbone; - - if (bone->flag & BONE_IK_TOPARENT) { - - /* See if there are any other bones that refer to the same parent and disconnect them */ - for (curbone = G.edbo.first; curbone; curbone=curbone->next){ - if (curbone!=bone){ - if (curbone->parent && (curbone->parent == bone->parent) && (curbone->flag & BONE_IK_TOPARENT)) - curbone->flag &= ~BONE_IK_TOPARENT; - } - } - - /* Attach this bone to its parent */ - VECCOPY(bone->head, bone->parent->tail); - } - -} - -static void build_bonestring (char *string, EditBone *bone){ - EditBone *curBone; - EditBone *pBone; - int skip=0; - int index; - - sprintf (string, "Parent%%t| %%x%d", -1); /* That space is there for a reason */ - - for (curBone = G.edbo.first, index=0; curBone; curBone=curBone->next, index++){ - /* Make sure this is a valid child */ - if (curBone != bone){ - skip=0; - for (pBone=curBone->parent; pBone; pBone=pBone->parent){ - if (pBone==bone){ - skip=1; - break; - } - } - - if (skip) - continue; - - sprintf (string, "%s|%s%%x%d", string, curBone->name, index); - } - } -} - -static void validate_editbonebutton(EditBone *eBone){ - EditBone *prev; - bAction *act=NULL; - bActionChannel *chan; - Base *base; - - /* Separate the bone from the G.edbo */ - prev=eBone->prev; - BLI_remlink (&G.edbo, eBone); - - /* Validate the name */ - unique_editbone_name (eBone->name); - - /* Re-insert the bone */ - if (prev) - BLI_insertlink(&G.edbo, prev, eBone); - else - BLI_addhead (&G.edbo, eBone); - - /* Rename channel if necessary */ - if (G.obedit) - act = G.obedit->action; - - if (act && !act->id.lib){ - // Find the appropriate channel - for (chan = act->chanbase.first; chan; chan=chan->next){ - if (!strcmp (chan->name, eBone->oldname)){ - strcpy (chan->name, eBone->name); - } - } - allqueue(REDRAWACTION, 0); - } - - /* Update the parenting info of any users */ - /* Yes, I know this is the worst thing you have ever seen. */ - - for (base = G.scene->base.first; base; base=base->next){ - Object *ob = base->object; - - /* See if an object is parented to this armature */ - if (ob->parent && ob->partype==PARBONE && (ob->parent->type==OB_ARMATURE) && (ob->parent->data == G.obedit->data)){ - if (!strcmp(ob->parsubstr, eBone->oldname)) - strcpy(ob->parsubstr, eBone->name); - } - } - - exit_editmode(0); /* To ensure new names make it to the edit armature */ - -} void deselectall_armature(void) /* Actually, it toggles selection, deselecting @@ -2098,7 +1849,7 @@ static int editbone_name_exists (char *name){ } -static void unique_editbone_name (char *name){ +void unique_editbone_name (char *name){ char tempname[64]; int number; char *dot; diff --git a/source/blender/src/editconstraint.c b/source/blender/src/editconstraint.c index 2ac25d1283d..574e55b03e5 100644 --- a/source/blender/src/editconstraint.c +++ b/source/blender/src/editconstraint.c @@ -41,6 +41,7 @@ #include "DNA_armature_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" +#include "DNA_screen_types.h" #include "DNA_constraint_types.h" #include "DNA_curve_types.h" diff --git a/source/blender/src/editface.c b/source/blender/src/editface.c index cb8b120fcb6..d1b520260d9 100644 --- a/source/blender/src/editface.c +++ b/source/blender/src/editface.c @@ -106,6 +106,7 @@ void set_lasttface() int a; lasttface= 0; + if(OBACT==NULL || OBACT->type!=OB_MESH) return; me= get_mesh(OBACT); if(me==0 || me->tface==0) return; diff --git a/source/blender/src/editipo.c b/source/blender/src/editipo.c index f870173004a..ac7992dfc03 100644 --- a/source/blender/src/editipo.c +++ b/source/blender/src/editipo.c @@ -3762,7 +3762,7 @@ void common_insertkey() } } } - else if(G.buts->mainb==CONTEXT_TYPES) { + else if(G.buts->mainb==CONTEXT_EDITING) { ob= OBACT; if(ob && ob->type==OB_CAMERA) { id= G.buts->lockpoin; diff --git a/source/blender/src/editsca.c b/source/blender/src/editsca.c deleted file mode 100644 index 397eeff92ed..00000000000 --- a/source/blender/src/editsca.c +++ /dev/null @@ -1,2635 +0,0 @@ -/** - * $Id$ - * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** - */ - -#include -#include -#include - -#ifdef HAVE_CONFIG_H -#include -#endif - -#ifndef WIN32 -#include -#else -#include -#include "BLI_winstuff.h" -#endif - -#include "MEM_guardedalloc.h" - -#include "BLI_blenlib.h" -#include "BLI_arithb.h" -#include "BLI_editVert.h" - -#include "DNA_action_types.h" -#include "DNA_material_types.h" -#include "DNA_sensor_types.h" -#include "DNA_actuator_types.h" -#include "DNA_controller_types.h" -#include "DNA_property_types.h" -#include "DNA_object_types.h" -#include "DNA_screen_types.h" -#include "DNA_space_types.h" -#include "DNA_scene_types.h" -#include "DNA_sound_types.h" -#include "DNA_text_types.h" -#include "DNA_view3d_types.h" -#include "DNA_mesh_types.h" - -#include "BKE_library.h" -#include "BKE_global.h" -#include "BKE_main.h" -#include "BKE_sca.h" -#include "BKE_property.h" - -#include "BIF_gl.h" -#include "BIF_resources.h" -#include "BIF_space.h" -#include "BIF_interface.h" -#include "BIF_butspace.h" -#include "BIF_screen.h" -#include "BIF_editsca.h" -#include "BIF_keyval.h" -#include "BIF_editsound.h" - -#include "BDR_editcurve.h" -#include "BSE_buttons.h" - -#include "blendef.h" -#include "mydevice.h" -#include "interface.h" -#include "nla.h" /* For __NLA : Important, do not remove */ - -#define B_DIFF 1 -#define B_ADD_PROP 2701 -#define B_CHANGE_PROP 2702 - -#define B_ADD_SENS 2703 -#define B_CHANGE_SENS 2704 -#define B_DEL_SENS 2705 - -#define B_ADD_CONT 2706 -#define B_CHANGE_CONT 2707 -#define B_DEL_CONT 2708 - -#define B_ADD_ACT 2709 -#define B_CHANGE_ACT 2710 -#define B_DEL_ACT 2711 - -#define B_SOUNDACT_BROWSE 2712 - -/* internals */ - -/****/ - -static ID **get_selected_and_linked_obs(short *count, short scavisflag); -static char *actuator_pup(Object *owner); - -/****/ - - -static void del_property(void *selpropv, void *data2_unused) -{ - bProperty *prop, *selprop= selpropv; - Object *ob; - int a=0; - - ob= OBACT; - if(ob==NULL) return; - - prop= ob->prop.first; - while(prop) { - if(prop==selprop) { - if (strcmp(prop->name,"Text") == 0) { - allqueue(REDRAWVIEW3D, 0); - } - BLI_remlink(&ob->prop, prop); - free_property(prop); - break; - } - a++; - prop= prop->next; - } - allqueue(REDRAWBUTSLOGIC, 0); - -} - -static int vergname(const void *v1, const void *v2) -{ - char **x1, **x2; - - x1= (char **)v1; - x2= (char **)v2; - - return strcmp(*x1, *x2); -} - -void make_unique_prop_names(char *str) -{ - Object *ob; - bProperty *prop; - bSensor *sens; - bController *cont; - bActuator *act; - ID **idar; - short a, obcount, propcount=0, nr; - char **names; - - /* this function is called by a Button, and gives the current - * stringpointer as an argument, this is the one that can change - */ - - idar= get_selected_and_linked_obs(&obcount, BUTS_SENS_SEL|BUTS_SENS_ACT|BUTS_ACT_SEL|BUTS_ACT_ACT|BUTS_CONT_SEL|BUTS_CONT_ACT); - - /* for each object, make properties and sca names unique */ - - /* count total names */ - for(a=0; aprop); - propcount+= BLI_countlist(&ob->sensors); - propcount+= BLI_countlist(&ob->controllers); - propcount+= BLI_countlist(&ob->actuators); - } - if(propcount==0) { - if(idar) MEM_freeN(idar); - return; - } - - /* make names array for sorting */ - names= MEM_callocN(propcount*sizeof(void *), "names"); - - /* count total names */ - nr= 0; - for(a=0; aprop.first; - while(prop) { - names[nr++]= prop->name; - prop= prop->next; - } - sens= ob->sensors.first; - while(sens) { - names[nr++]= sens->name; - sens= sens->next; - } - cont= ob->controllers.first; - while(cont) { - names[nr++]= cont->name; - cont= cont->next; - } - act= ob->actuators.first; - while(act) { - names[nr++]= act->name; - act= act->next; - } - } - - qsort(names, propcount, sizeof(void *), vergname); - - /* now we check for double names, and change them */ - - for(nr=0; nr0) { - /* now find out which object has this ... */ - base= FIRSTBASE; - while(base) { - - sens= base->object->sensors.first; - while(sens) { - if(sens == sens_to_delete) break; - sens= sens->next; - } - - if(sens) { - if( val==1 && sens->prev) { - BLI_remlink(&base->object->sensors, sens); - BLI_insertlinkbefore(&base->object->sensors, sens->prev, sens); - } - else if( val==2 && sens->next) { - BLI_remlink(&base->object->sensors, sens); - BLI_insertlink(&base->object->sensors, sens->next, sens); - } - allqueue(REDRAWBUTSLOGIC, 0); - break; - } - - base= base->next; - } - } -} - -static void sca_move_controller(void *datav, void *data2_unused) -{ - bController *controller_to_del= datav; - int val; - Base *base; - bController *cont; - - val= pupmenu("Move up%x1|Move down %x2"); - - if(val>0) { - /* now find out which object has this ... */ - base= FIRSTBASE; - while(base) { - - cont= base->object->controllers.first; - while(cont) { - if(cont == controller_to_del) break; - cont= cont->next; - } - - if(cont) { - if( val==1 && cont->prev) { - BLI_remlink(&base->object->controllers, cont); - BLI_insertlinkbefore(&base->object->controllers, cont->prev, cont); - } - else if( val==2 && cont->next) { - BLI_remlink(&base->object->controllers, cont); - BLI_insertlink(&base->object->controllers, cont->next, cont); - } - allqueue(REDRAWBUTSLOGIC, 0); - break; - } - - base= base->next; - } - } -} - -static void sca_move_actuator(void *datav, void *data2_unused) -{ - bActuator *actuator_to_move= datav; - int val; - Base *base; - bActuator *act; - - val= pupmenu("Move up%x1|Move down %x2"); - - if(val>0) { - /* now find out which object has this ... */ - base= FIRSTBASE; - while(base) { - - act= base->object->actuators.first; - while(act) { - if(act == actuator_to_move) break; - act= act->next; - } - - if(act) { - if( val==1 && act->prev) { - BLI_remlink(&base->object->actuators, act); - BLI_insertlinkbefore(&base->object->actuators, act->prev, act); - } - else if( val==2 && act->next) { - BLI_remlink(&base->object->actuators, act); - BLI_insertlink(&base->object->actuators, act->next, act); - } - allqueue(REDRAWBUTSLOGIC, 0); - break; - } - - base= base->next; - } - } -} - -void do_gamebuts(unsigned short event) -{ - bProperty *prop; - bSensor *sens; - bController *cont; - bActuator *act; - Base *base; - Object *ob; - int didit; - - ob= OBACT; - if(ob==0) return; - - switch(event) { - - case B_ADD_PROP: - prop= new_property(PROP_FLOAT); - make_unique_prop_names(prop->name); - BLI_addtail(&ob->prop, prop); - allqueue(REDRAWBUTSLOGIC, 0); - break; - - case B_CHANGE_PROP: - prop= ob->prop.first; - while(prop) { - if(prop->type!=prop->otype) { - init_property(prop); - if (strcmp(prop->name, "Text") == 0) { - allqueue(REDRAWVIEW3D, 0); - } - } - prop= prop->next; - } - allqueue(REDRAWBUTSLOGIC, 0); - break; - - case B_ADD_SENS: - base= FIRSTBASE; - while(base) { - if(base->object->scaflag & OB_ADDSENS) { - base->object->scaflag &= ~OB_ADDSENS; - sens= new_sensor(SENS_ALWAYS); - BLI_addtail(&(base->object->sensors), sens); - make_unique_prop_names(sens->name); - base->object->scaflag |= OB_SHOWSENS; - } - base= base->next; - } - - allqueue(REDRAWBUTSLOGIC, 0); - break; - - case B_CHANGE_SENS: - base= FIRSTBASE; - while(base) { - sens= base->object->sensors.first; - while(sens) { - if(sens->type != sens->otype) { - init_sensor(sens); - sens->otype= sens->type; - break; - } - sens= sens->next; - } - base= base->next; - } - allqueue(REDRAWBUTSLOGIC, 0); - break; - - case B_DEL_SENS: - base= FIRSTBASE; - while(base) { - sens= base->object->sensors.first; - while(sens) { - if(sens->flag & SENS_DEL) { - BLI_remlink(&(base->object->sensors), sens); - free_sensor(sens); - break; - } - sens= sens->next; - } - base= base->next; - } - allqueue(REDRAWBUTSLOGIC, 0); - break; - - case B_ADD_CONT: - base= FIRSTBASE; - while(base) { - if(base->object->scaflag & OB_ADDCONT) { - base->object->scaflag &= ~OB_ADDCONT; - cont= new_controller(CONT_LOGIC_AND); - make_unique_prop_names(cont->name); - base->object->scaflag |= OB_SHOWCONT; - BLI_addtail(&(base->object->controllers), cont); - } - base= base->next; - } - allqueue(REDRAWBUTSLOGIC, 0); - break; - - case B_CHANGE_CONT: - base= FIRSTBASE; - while(base) { - cont= base->object->controllers.first; - while(cont) { - if(cont->type != cont->otype) { - init_controller(cont); - cont->otype= cont->type; - break; - } - cont= cont->next; - } - base= base->next; - } - allqueue(REDRAWBUTSLOGIC, 0); - break; - - - case B_DEL_CONT: - base= FIRSTBASE; - while(base) { - cont= base->object->controllers.first; - while(cont) { - if(cont->flag & CONT_DEL) { - BLI_remlink(&(base->object->controllers), cont); - unlink_controller(cont); - free_controller(cont); - break; - } - cont= cont->next; - } - base= base->next; - } - allqueue(REDRAWBUTSLOGIC, 0); - break; - - case B_ADD_ACT: - base= FIRSTBASE; - while(base) { - if(base->object->scaflag & OB_ADDACT) { - base->object->scaflag &= ~OB_ADDACT; - act= new_actuator(ACT_OBJECT); - make_unique_prop_names(act->name); - BLI_addtail(&(base->object->actuators), act); - base->object->scaflag |= OB_SHOWACT; - } - base= base->next; - } - allqueue(REDRAWBUTSLOGIC, 0); - break; - - case B_CHANGE_ACT: - base= FIRSTBASE; - while(base) { - act= base->object->actuators.first; - while(act) { - if(act->type != act->otype) { - init_actuator(act); - act->otype= act->type; - break; - } - act= act->next; - } - base= base->next; - } - allqueue(REDRAWBUTSLOGIC, 0); - break; - - case B_DEL_ACT: - base= FIRSTBASE; - while(base) { - act= base->object->actuators.first; - while(act) { - if(act->flag & ACT_DEL) { - BLI_remlink(&(base->object->actuators), act); - unlink_actuator(act); - free_actuator(act); - break; - } - act= act->next; - } - base= base->next; - } - allqueue(REDRAWBUTSLOGIC, 0); - break; - - case B_SOUNDACT_BROWSE: - /* since we don't know which... */ - didit= 0; - base= FIRSTBASE; - while(base) - { - act= base->object->actuators.first; - while(act) - { - if(act->type==ACT_SOUND) - { - bSoundActuator *sa= act->data; - if(sa->sndnr) - { - bSound *sound= G.main->sound.first; - int nr= 1; - - while(sound) - { - if(nr==sa->sndnr) - break; - nr++; - sound= sound->id.next; - } - - if(sa->sound) - sa->sound->id.us--; - - sa->sound= sound; - - if(sound) - sound->id.us++; - - sa->sndnr= 0; - didit= 1; - } - } - act= act->next; - } - if(didit) - break; - base= base->next; - } - allqueue(REDRAWBUTSLOGIC, 0); - allqueue(REDRAWSOUND, 0); - - break; - - } -} - - -static char *sensor_name(int type) -{ - switch (type) { - case SENS_ALWAYS: - return "Always"; - case SENS_TOUCH: - return "Touch"; - case SENS_NEAR: - return "Near"; - case SENS_KEYBOARD: - return "Keyboard"; - case SENS_PROPERTY: - return "Property"; - case SENS_MOUSE: - return "Mouse"; - case SENS_COLLISION: - return "Collision"; - case SENS_RADAR: - return "Radar"; - case SENS_RANDOM: - return "Random"; - case SENS_RAY: - return "Ray"; - case SENS_MESSAGE: - return "Message"; - } - return "unknown"; -} - -static char *sensor_pup(void) -{ - /* the number needs to match defines in game.h */ - return "Sensors %t|Always %x0|Keyboard %x3|Mouse %x5|" - "Touch %x1|Collision %x6|Near %x2|Radar %x7|" - "Property %x4|Random %x8|Ray %x9|Message %x10"; -} - -static char *controller_name(int type) -{ - switch (type) { - case CONT_LOGIC_AND: - return "AND"; - case CONT_LOGIC_OR: - return "OR"; - case CONT_EXPRESSION: - return "Expression"; - case CONT_PYTHON: - return "Python"; - } - return "unknown"; -} - -static char *controller_pup(void) -{ - return "Controllers %t|AND %x0|OR %x1|Expression %x2|Python %x3"; -} - -static char *actuator_name(int type) -{ - switch (type) { - case ACT_ACTION: - return "Action"; - case ACT_OBJECT: - return "Motion"; - case ACT_IPO: - return "Ipo"; - case ACT_LAMP: - return "Lamp"; - case ACT_CAMERA: - return "Camera"; - case ACT_MATERIAL: - return "Material"; - case ACT_SOUND: - return "Sound"; - case ACT_CD: - return "CD"; - case ACT_PROPERTY: - return "Property"; - case ACT_EDIT_OBJECT: - return "Edit Object"; - case ACT_CONSTRAINT: - return "Constraint"; - case ACT_SCENE: - return "Scene"; - case ACT_GROUP: - return "Group"; - case ACT_RANDOM: - return "Random"; - case ACT_MESSAGE: - return "Message"; - case ACT_GAME: - return "Game"; - case ACT_VISIBILITY: - return "Game"; - } - return "unknown"; -} - - - - -static char *actuator_pup(Object *owner) -{ - switch (owner->type) - { - case OB_ARMATURE: - return "Actuators %t|Action %x15|Motion %x0|Constraint %x9|Ipo %x1" - "|Camera %x3|Sound %x5|Property %x6|Edit Object %x10" - "|Scene %x11|Random %x13|Message %x14|CD %x16|Game %x17" - "|Visibility %x18"; - break; - default: - return "Actuators %t|Motion %x0|Constraint %x9|Ipo %x1" - "|Camera %x3|Sound %x5|Property %x6|Edit Object %x10" - "|Scene %x11|Random %x13|Message %x14|CD %x16|Game %x17" - "|Visibility %x18"; - } -} - - - -static void set_sca_ob(Object *ob) -{ - bController *cont; - bActuator *act; - - cont= ob->controllers.first; - while(cont) { - cont->mynew= (bController *)ob; - cont= cont->next; - } - act= ob->actuators.first; - while(act) { - act->mynew= (bActuator *)ob; - act= act->next; - } -} - -static ID **get_selected_and_linked_obs(short *count, short scavisflag) -{ - Base *base; - Object *ob, *obt; - ID **idar; - bSensor *sens; - bController *cont; - unsigned int lay; - int a, nr, doit; - - /* we need a sorted object list */ - /* set scavisflags flags in Objects to indicate these should be evaluated */ - /* also hide ob pointers in ->new entries of controllerss/actuators */ - - *count= 0; - - if(G.scene==NULL) return NULL; - - ob= G.main->object.first; - while(ob) { - ob->scavisflag= 0; - set_sca_ob(ob); - ob= ob->id.next; - } - - if(G.vd) lay= G.vd->lay; - else lay= G.scene->lay; - - base= FIRSTBASE; - while(base) { - if(base->lay & lay) { - if(base->flag & SELECT) { - if(scavisflag & BUTS_SENS_SEL) base->object->scavisflag |= OB_VIS_SENS; - if(scavisflag & BUTS_CONT_SEL) base->object->scavisflag |= OB_VIS_CONT; - if(scavisflag & BUTS_ACT_SEL) base->object->scavisflag |= OB_VIS_ACT; - } - } - base= base->next; - } - - if(OBACT) { - if(scavisflag & BUTS_SENS_ACT) OBACT->scavisflag |= OB_VIS_SENS; - if(scavisflag & BUTS_CONT_ACT) OBACT->scavisflag |= OB_VIS_CONT; - if(scavisflag & BUTS_ACT_ACT) OBACT->scavisflag |= OB_VIS_ACT; - } - - if(scavisflag & (BUTS_SENS_LINK|BUTS_CONT_LINK|BUTS_ACT_LINK)) { - doit= 1; - while(doit) { - doit= 0; - - ob= G.main->object.first; - while(ob) { - - /* 1st case: select sensor when controller selected */ - if((scavisflag & BUTS_SENS_LINK) && (ob->scavisflag & OB_VIS_SENS)==0) { - sens= ob->sensors.first; - while(sens) { - for(a=0; atotlinks; a++) { - if(sens->links[a]) { - obt= (Object *)sens->links[a]->mynew; - if(obt && (obt->scavisflag & OB_VIS_CONT)) { - doit= 1; - ob->scavisflag |= OB_VIS_SENS; - break; - } - } - } - if(doit) break; - sens= sens->next; - } - } - - /* 2nd case: select cont when act selected */ - if((scavisflag & BUTS_CONT_LINK) && (ob->scavisflag & OB_VIS_CONT)==0) { - cont= ob->controllers.first; - while(cont) { - for(a=0; atotlinks; a++) { - if(cont->links[a]) { - obt= (Object *)cont->links[a]->mynew; - if(obt && (obt->scavisflag & OB_VIS_ACT)) { - doit= 1; - ob->scavisflag |= OB_VIS_CONT; - break; - } - } - } - if(doit) break; - cont= cont->next; - } - } - - /* 3rd case: select controller when sensor selected */ - if((scavisflag & BUTS_CONT_LINK) && (ob->scavisflag & OB_VIS_SENS)) { - sens= ob->sensors.first; - while(sens) { - for(a=0; atotlinks; a++) { - if(sens->links[a]) { - obt= (Object *)sens->links[a]->mynew; - if(obt && (obt->scavisflag & OB_VIS_CONT)==0) { - doit= 1; - obt->scavisflag |= OB_VIS_CONT; - } - } - } - sens= sens->next; - } - } - - /* 4th case: select actuator when controller selected */ - if( (scavisflag & BUTS_ACT_LINK) && (ob->scavisflag & OB_VIS_CONT)) { - cont= ob->controllers.first; - while(cont) { - for(a=0; atotlinks; a++) { - if(cont->links[a]) { - obt= (Object *)cont->links[a]->mynew; - if(obt && (obt->scavisflag & OB_VIS_ACT)==0) { - doit= 1; - obt->scavisflag |= OB_VIS_ACT; - } - } - } - cont= cont->next; - } - - } - ob= ob->id.next; - } - } - } - - /* now we count */ - ob= G.main->object.first; - while(ob) { - if( ob->scavisflag ) (*count)++; - ob= ob->id.next; - } - - if(*count==0) return NULL; - if(*count>24) *count= 24; /* temporal */ - - idar= MEM_callocN( (*count)*sizeof(void *), "idar"); - - ob= G.main->object.first; - nr= 0; - while(ob) { - if( ob->scavisflag ) { - idar[nr]= (ID *)ob; - nr++; - } - if(nr>=24) break; - ob= ob->id.next; - } - - /* just to be sure... these were set in set_sca_done_ob() */ - clear_sca_new_poins(); - - return idar; -} - - -static BIFColorID get_col_sensor(int type) -{ - switch(type) { - case SENS_ALWAYS: return BUTACTION; - case SENS_TOUCH: return BUTCAMERA; - case SENS_COLLISION: return BUTCAMERA; - case SENS_NEAR: return BUTRANDOM; - case SENS_KEYBOARD: return BUTIPO; - case SENS_PROPERTY: return BUTPROPERTY; - case SENS_MOUSE: return BUTAUDIO; - case SENS_RADAR: return BUTEDITOBJECT; - case SENS_RANDOM: return BUTSCENE; - case SENS_RAY: return BUTMOTION; - case SENS_MESSAGE: return BUTMESSAGE; - default: return BUTGREY; - } -} -static void set_col_sensor(int type, int medium) -{ - BIFColorID col= get_col_sensor(type); - BIF_set_color(col, medium?COLORSHADE_LIGHT:COLORSHADE_MEDIUM); -} - -/** - * Draws a toggle for pulse mode, a frequency fiels and a toggle to invert - * the value of this sensor. Operates on the shared data block of sensors. - */ -static void draw_default_sensor_header(bSensor *sens, - uiBlock *block, - short x, - short y, - short w) -{ - /* Pulsing and frequency */ - uiDefIconButS(block, TOG|BIT|0, 1, ICON_DOTSUP, - (short)(x + 10), (short)(y - 19), (short)(0.15 * (w-20)), 19, - &sens->pulse, 0.0, 0.0, 0, 0, - "Activate TRUE pulse mode"); - uiDefIconButS(block, TOG|BIT|2, 1, ICON_DOTSDOWN, - (short)(x + 10 + 0.15 * (w-20)), (short)(y - 19), (short)(0.15 * (w-20)), 19, - &sens->pulse, 0.0, 0.0, 0, 0, - "Activate FALSE pulse mode"); - uiDefButS(block, NUM, 1, "f:", - (short)(x + 10 + 0.3 * (w-20)), (short)(y - 19), (short)(0.275 * (w-20)), 19, - &sens->freq, 0.0, 10000.0, 0, 0, - "Frequency of pulses (in 1/50 sec)"); - - /* value or shift? */ - uiDefButS(block, TOG, 1, "Inv", - (short)(x + 10 + 0.85 * (w-20)), (short)(y - 19), (short)(0.15 * (w-20)), 19, - &sens->invert, 1.0, SENS_NOT, 0, 0, - "Invert the output of this sensor"); -} - -static short draw_sensorbuttons(bSensor *sens, uiBlock *block, short xco, short yco, short width,char* objectname) -{ - bNearSensor *ns = NULL; - bTouchSensor *ts = NULL; - bKeyboardSensor *ks = NULL; - bPropertySensor *ps = NULL; - bMouseSensor *ms = NULL; - bCollisionSensor *cs = NULL; - bRadarSensor *rs = NULL; - bRandomSensor *randomSensor = NULL; - bRaySensor *raySens = NULL; - bMessageSensor *mes = NULL; - short ysize; - char *str; - - /* yco is at the top of the rect, draw downwards */ - - uiBlockSetEmboss(block, UI_EMBOSSW); - - set_col_sensor(sens->type, 0); - - switch (sens->type) - { - case SENS_ALWAYS: - { - ysize= 24; - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - draw_default_sensor_header(sens, block, xco, yco, width); - - yco-= ysize; - - break; - } - case SENS_TOUCH: - { - ysize= 48; - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - draw_default_sensor_header(sens, block, xco, yco, width); - - ts= sens->data; - - /* uiDefBut(block, TEX, 1, "Property:", xco,yco-22,width, 19, &ts->name, 0, 31, 0, 0, "Only look for Objects with this property"); */ - uiDefIDPoinBut(block, test_matpoin_but, 1, "MA:",(short)(xco + 10),(short)(yco-44), (short)(width - 20), 19, &ts->ma, "Only look for floors with this Material"); - ///* uiDefButF(block, NUM, 1, "Margin:", xco+width/2,yco-44,width/2, 19, &ts->dist, 0.0, 10.0, 100, 0, "Extra margin (distance) for larger sensitivity"); - yco-= ysize; - break; - } - case SENS_COLLISION: - { - ysize= 48; - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - draw_default_sensor_header(sens, block, xco, yco, width); - cs= sens->data; - - /* The collision sensor will become a generic collision (i.e. it */ - /* absorb the old touch sensor). */ - uiDefButS(block, TOG|BIT|0, B_REDR, "M/P",(short)(xco + 10),(short)(yco - 44), - (short)(0.20 * (width-20)), 19, &cs->mode, 0.0, 0.0, 0, 0, - "Toggle collision on material or property."); - - if (cs->mode & SENS_COLLISION_MATERIAL) { - uiDefBut(block, TEX, 1, "Material:", (short)(xco + 10 + 0.20 * (width-20)), - (short)(yco-44), (short)(0.8*(width-20)), 19, &cs->materialName, 0, 31, 0, 0, - "Only look for Objects with this material"); - } else { - uiDefBut(block, TEX, 1, "Property:", (short)(xco + 10 + 0.20 * (width-20)), (short)(yco-44), - (short)(0.8*(width-20)), 19, &cs->name, 0, 31, 0, 0, - "Only look for Objects with this property"); - } - - /* uiDefButS(block, NUM, 1, "Damp:", xco+10+width-90,yco-24, 70, 19, &cs->damp, 0, 250, 0, 0, "For 'damp' time don't detect another collision"); */ - - yco-= ysize; - break; - } - case SENS_NEAR: - { - ysize= 72; - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - draw_default_sensor_header(sens, block, xco, yco, width); - ns= sens->data; - - uiDefBut(block, TEX, 1, "Property:",(short)(10+xco),(short)(yco-44), (short)(width-20), 19, - &ns->name, 0, 31, 0, 0, "Only look for Objects with this property"); - uiDefButF(block, NUM, 1, "Dist",(short)(10+xco),(short)(yco-68),(short)((width-22)/2), 19, - &ns->dist, 0.0, 1000.0, 1000, 0, "Trigger distance"); - uiDefButF(block, NUM, 1, "Reset",(short)(10+xco+(width-22)/2), (short)(yco-68), (short)((width-22)/2), 19, - &ns->resetdist, 0.0, 1000.0, 1000, 0, "Reset distance"); - yco-= ysize; - break; - } - case SENS_RADAR: - { - ysize= 72; - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - draw_default_sensor_header(sens, block, xco, yco, width); - - rs= sens->data; - - uiDefBut(block, TEX, 1, "Prop:", - (short)(10+xco),(short)(yco-44), (short)(0.7 * (width-20)), 19, - &rs->name, 0, 31, 0, 0, - "Only look for Objects with this property"); - uiDefButS(block, ROW, 1, "X", - (short)(10+xco+0.7 * (width-20)),(short)(yco-44), (short)(0.1 * (width-22)),19, - &rs->axis, 2.0, 0, 0, 0, - "Cast the cone along the object's positive x-axis"); - uiDefButS(block, ROW, 1, "Y", - (short)(10+xco+0.8 * (width-20)),(short)(yco-44),(short)(0.1 * (width-22)), 19, - &rs->axis, 2.0, 1, 0, 0, - "Cast the cone along the object's positive y-axis"); - uiDefButS(block, ROW, 1, "Z", - (short)(10+xco+0.9 * (width-20)), (short)(yco-44), (short)(0.1 * (width-22)), 19, - &rs->axis, 2.0, 2, 0, 0, - "Cast the cone along the object's positive z-axis"); - uiDefButF(block, NUM, 1, "Ang:", - (short)(10+xco), (short)(yco-68), (short)((width-20)/2), 19, - &rs->angle, 0.0, 179.9, 10, 0, - "Opening angle of the radar cone."); - uiDefButF(block, NUM, 1, "Dist:", - (short)(xco+10 + (width-20)/2), (short)(yco-68), (short)((width-20)/2), 19, - &rs->range, 0.01, 10000.0, 100, 0, - "Depth of the radar cone"); - yco-= ysize; - break; - } - case SENS_KEYBOARD: - { - /* 5 lines: 120 height */ - ysize= 120; - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - /* header line */ - draw_default_sensor_header(sens, block, xco, yco, width); - ks= sens->data; - - /* line 2: hotkey and allkeys toggle */ - uiDefKeyevtButS(block, B_DIFF, "", xco+40, yco-44, (width)/2, 19, &ks->key, "Key code"); - - /* line 3: two key modifyers (qual1, qual2) */ - uiDefKeyevtButS(block, B_DIFF, "", xco+40, yco-68, (width-50)/2, 19, &ks->qual, "Modifier key code"); - uiDefKeyevtButS(block, B_DIFF, "", xco+40+(width-50)/2, yco-68, (width-50)/2, 19, &ks->qual2, "Second Modifier key code"); - - /* labels for line 1 and 2 */ - uiDefBut(block, LABEL, 0, "Key", xco, yco-44, 40, 19, NULL, 0, 0, 0, 0, ""); - uiDefBut(block, LABEL, 0, "Hold", xco, yco-68, 40, 19, NULL, 0, 0, 0, 0, ""); - - /* part of line 1 */ - uiBlockSetCol(block, BUTPURPLE); - uiDefButS(block, TOG|BIT|0, 0, "All keys", xco+40+(width/2), yco-44, (width/2)-50, 19, - &ks->type, 0, 0, 0, 0, ""); - - /* line 4: toggle property for string logging mode */ - uiDefBut(block, TEX, 1, "LogToggle: ", - xco+10, yco-92, (width-20), 19, - ks->toggleName, 0, 31, 0, 0, - "Property that indicates whether to log " - "keystrokes as a string."); - - /* line 5: target property for string logging mode */ - uiDefBut(block, TEX, 1, "Target: ", - xco+10, yco-116, (width-20), 19, - ks->targetName, 0, 31, 0, 0, - "Property that receives the keystrokes in case " - "a string is logged."); - - yco-= ysize; - break; - } - case SENS_PROPERTY: - { - ysize= 96; - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, - (float)xco+width, (float)yco, 1); - - draw_default_sensor_header(sens, block, xco, yco, width); - ps= sens->data; - - str= "Type %t|Equal %x0|Not Equal %x1|Interval %x2|Changed %x3"; - /* str= "Type %t|Equal %x0|Not Equal %x1"; */ - uiDefButI(block, MENU, B_REDR, str, xco+30,yco-44,width-60, 19, - &ps->type, 0, 31, 0, 0, "Type"); - - if (ps->type != SENS_PROP_EXPRESSION) - { - uiDefBut(block, TEX, 1, "Prop: ", xco+30,yco-68,width-60, 19, - ps->name, 0, 31, 0, 0, "Property name"); - } - - if(ps->type == SENS_PROP_INTERVAL) - { - uiDefBut(block, TEX, 1, "Min: ", xco,yco-92,width/2, 19, - ps->value, 0, 31, 0, 0, "test for value"); - uiDefBut(block, TEX, 1, "Max: ", xco+width/2,yco-92,width/2, 19, - ps->maxvalue, 0, 31, 0, 0, "test for max value"); - } - else if(ps->type == SENS_PROP_CHANGED); - else - { - uiDefBut(block, TEX, 1, "Value: ", xco+30,yco-92,width-60, 19, - ps->value, 0, 31, 0, 0, "test for value"); - } - - yco-= ysize; - break; - } - case SENS_MOUSE: - { - ms= sens->data; - /* Two lines: 48 pixels high. */ - ysize = 48; - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - /* line 1: header */ - draw_default_sensor_header(sens, block, xco, yco, width); - - /* Line 2: type selection. The number are a bit mangled to get - * proper compatibility with older .blend files. */ - str= "Type %t|Left button %x1|Middle button %x2|" - "Right button %x4|Movement %x8|Mouse over %x16"; - uiDefButS(block, MENU, B_REDR, str, xco+10, yco-44, width-20, 19, - &ms->type, 0, 31, 0, 0, - "Specify the type of event this mouse sensor should trigger on."); - - yco-= ysize; - break; - } - case SENS_RANDOM: - { - ysize = 48; - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - draw_default_sensor_header(sens, block, xco, yco, width); - randomSensor = sens->data; - /* some files were wrongly written, avoid crash now */ - if (randomSensor) - { - uiDefButI(block, NUM, 1, "Seed: ", xco+10,yco-44,(width-20), 19, - &randomSensor->seed, 0, 1000, 0, 0, - "Initial seed of the generator. (Choose 0 for not random)"); - } - yco-= ysize; - break; - } - case SENS_RAY: - { - ysize = 72; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - draw_default_sensor_header(sens, block, xco, yco, width); - raySens = sens->data; - - /* 1. property or material */ - uiDefButS(block, TOG|BIT|0, B_REDR, "M/P", - xco + 10,yco - 44, 0.20 * (width-20), 19, - &raySens->mode, 0.0, 0.0, 0, 0, - "Toggle collision on material or property."); - - if (raySens->mode & SENS_COLLISION_MATERIAL) - { - uiDefBut(block, TEX, 1, "Material:", xco + 10 + 0.20 * (width-20), yco-44, 0.8*(width-20), 19, - &raySens->matname, 0, 31, 0, 0, - "Only look for Objects with this material"); - } - else - { - uiDefBut(block, TEX, 1, "Property:", xco + 10 + 0.20 * (width-20), yco-44, 0.8*(width-20), 19, - &raySens->propname, 0, 31, 0, 0, - "Only look for Objects with this property"); - } - - /* 2. sensing range */ - uiDefButF(block, NUM, 1, "Range", xco+10, yco-68, 0.6 * (width-20), 19, - &raySens->range, 0.01, 10000.0, 100, 0, - "Sense objects no farther than this distance"); - - /* 3. axis choice */ - str = "Type %t|+ X axis %x1|+ Y axis %x0|+ Z axis %x2|- X axis %x3|- Y axis %x4|- Z axis %x5"; - uiDefButI(block, MENU, B_REDR, str, xco+10 + 0.6 * (width-20), yco-68, 0.4 * (width-20), 19, - &raySens->axisflag, 2.0, 31, 0, 0, - "Specify along which axis the ray is cast."); - - yco-= ysize; - break; - } - case SENS_MESSAGE: - { - mes = sens->data; - ysize = 2 * 24; /* total number of lines * 24 pixels/line */ - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, - (float)xco+width, (float)yco, 1); - - /* line 1: header line */ - draw_default_sensor_header(sens, block, xco, yco, width); - - /* line 2: Subject filter */ - uiDefBut(block, TEX, 1, "Subject: ", - (xco+10), (yco-44), (width-20), 19, - mes->subject, 0, 31, 0, 0, - "Optional subject filter: only accept messages with this subject" - ", or empty for all"); - - yco -= ysize; - break; - } - } - - uiBlockSetEmboss(block, UI_EMBOSSM); - uiBlockSetCol(block, BUTGREY); - - return yco-4; -} - - - -static short draw_controllerbuttons(bController *cont, uiBlock *block, short xco, short yco, short width) -{ - bExpressionCont *ec; - bPythonCont *pc; - short ysize; - - uiBlockSetEmboss(block, UI_EMBOSSW); - - switch (cont->type) { - case CONT_EXPRESSION: - ysize= 28; - - BIF_set_color(BUTPROPERTY, COLORSHADE_GREY); - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - /* uiDefBut(block, LABEL, 1, "Not yet...", xco,yco-24,80, 19, NULL, 0, 0, 0, 0, ""); */ - ec= cont->data; - /* uiDefBut(block, BUT, 1, "Variables", xco,yco-24,80, 19, NULL, 0, 0, 0, 0, "Available variables for expression"); */ - uiDefBut(block, TEX, 1, "Exp:", xco + 10 , yco-21, width-20, 19, - ec->str, 0, 127, 0, 0, - "Expression"); - - yco-= ysize; - break; - case CONT_PYTHON: - ysize= 28; - - if(cont->data==NULL) init_controller(cont); - pc= cont->data; - - BIF_set_color(BUTMESSAGE, COLORSHADE_GREY); - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - uiDefIDPoinBut(block, test_scriptpoin_but, 1, "Script: ", xco+45,yco-24,width-90, 19, &pc->text, ""); - - yco-= ysize; - break; - - default: - ysize= 4; - - BIF_set_color(BUTIPO, COLORSHADE_GREY); - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - yco-= ysize; - } - - uiBlockSetEmboss(block, UI_EMBOSSM); - uiBlockSetCol(block, BUTGREY); - - return yco; -} - -static BIFColorID get_col_actuator(int type) -{ - switch(type) { - case ACT_ACTION: return BUTACTION; - case ACT_OBJECT: return BUTMOTION; - case ACT_IPO: return BUTIPO; - case ACT_PROPERTY: return BUTPROPERTY; - case ACT_SOUND: return BUTAUDIO; - case ACT_CD: return BUTCD; - case ACT_CAMERA: return BUTCAMERA; - case ACT_EDIT_OBJECT: return BUTEDITOBJECT; - case ACT_GROUP: return BUTYELLOW; - case ACT_RANDOM: return BUTRANDOM; - case ACT_SCENE: return BUTSCENE; - case ACT_MESSAGE: return BUTMESSAGE; - case ACT_GAME: return BUTGAME; - case ACT_VISIBILITY: return BUTVISIBILITY; - default: return BUTGREY; - } -} -static void set_col_actuator(int item, int medium) -{ - if (item==ACT_CONSTRAINT) { - BIF_set_color(BUTRUST, medium?COLORSHADE_HILITE:COLORSHADE_MEDIUM); - } else { - BIFColorID col= get_col_actuator(item); - BIF_set_color(col, medium?COLORSHADE_MEDIUM:COLORSHADE_GREY); - } -} - -static short draw_actuatorbuttons(bActuator *act, uiBlock *block, short xco, short yco, short width) -{ - bSoundActuator *sa = NULL; - bCDActuator *cda = NULL; - bObjectActuator *oa = NULL; - bIpoActuator *ia = NULL; - bPropertyActuator *pa = NULL; - bCameraActuator *ca = NULL; - bEditObjectActuator *eoa = NULL; - bConstraintActuator *coa = NULL; - bSceneActuator *sca = NULL; - bGroupActuator *ga = NULL; - bRandomActuator *randAct = NULL; - bMessageActuator *ma = NULL; - bActionActuator *aa = NULL; - bGameActuator *gma = NULL; - bVisibilityActuator *visAct = NULL; - - float *fp; - short ysize = 0, wval; - char *str; - int myline; - - /* yco is at the top of the rect, draw downwards */ - uiBlockSetEmboss(block, UI_EMBOSSW); - set_col_actuator(act->type, 0); - - switch (act->type) - { - case ACT_OBJECT: - { - ysize= 129; - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - uiBlockSetCol(block, BUTGREY); - - oa = act->data; - wval = (width-100)/3; - - uiDefBut(block, LABEL, 0, "Force", xco, yco-22, 55, 19, NULL, 0, 0, 0, 0, "Sets the force"); - uiDefButF(block, NUM, 0, "", xco+45, yco-22, wval, 19, oa->forceloc, -10000.0, 10000.0, 10, 0, ""); - uiDefButF(block, NUM, 0, "", xco+45+wval, yco-22, wval, 19, oa->forceloc+1, -10000.0, 10000.0, 10, 0, ""); - uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-22, wval, 19, oa->forceloc+2, -10000.0, 10000.0, 10, 0, ""); - - uiDefBut(block, LABEL, 0, "Torque", xco, yco-41, 55, 19, NULL, 0, 0, 0, 0, "Sets the torque"); - uiDefButF(block, NUM, 0, "", xco+45, yco-41, wval, 19, oa->forcerot, -10000.0, 10000.0, 10, 0, ""); - uiDefButF(block, NUM, 0, "", xco+45+wval, yco-41, wval, 19, oa->forcerot+1, -10000.0, 10000.0, 10, 0, ""); - uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-41, wval, 19, oa->forcerot+2, -10000.0, 10000.0, 10, 0, ""); - - uiDefBut(block, LABEL, 0, "dLoc", xco, yco-64, 45, 19, NULL, 0, 0, 0, 0, "Sets the dLoc"); - uiDefButF(block, NUM, 0, "", xco+45, yco-64, wval, 19, oa->dloc, -10000.0, 10000.0, 10, 0, ""); - uiDefButF(block, NUM, 0, "", xco+45+wval, yco-64, wval, 19, oa->dloc+1, -10000.0, 10000.0, 10, 0, ""); - uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-64, wval, 19, oa->dloc+2, -10000.0, 10000.0, 10, 0, ""); - - uiDefBut(block, LABEL, 0, "dRot", xco, yco-83, 45, 19, NULL, 0, 0, 0, 0, "Sets the dRot"); - uiDefButF(block, NUM, 0, "", xco+45, yco-83, wval, 19, oa->drot, -10000.0, 10000.0, 10, 0, ""); - uiDefButF(block, NUM, 0, "", xco+45+wval, yco-83, wval, 19, oa->drot+1, -10000.0, 10000.0, 10, 0, ""); - uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-83, wval, 19, oa->drot+2, -10000.0, 10000.0, 10, 0, ""); - - uiDefBut(block, LABEL, 0, "linV", xco, yco-106, 45, 19, NULL, 0, 0, 0, 0, "Sets the linear velocity"); - uiDefButF(block, NUM, 0, "", xco+45, yco-106, wval, 19, oa->linearvelocity, -10000.0, 10000.0, 10, 0, ""); - uiDefButF(block, NUM, 0, "", xco+45+wval, yco-106, wval, 19, oa->linearvelocity+1, -10000.0, 10000.0, 10, 0, ""); - uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-106, wval, 19, oa->linearvelocity+2, -10000.0, 10000.0, 10, 0, ""); - - uiDefBut(block, LABEL, 0, "angV", xco, yco-125, 45, 19, NULL, 0, 0, 0, 0, "Sets the angular velocity"); - uiDefButF(block, NUM, 0, "", xco+45, yco-125, wval, 19, oa->angularvelocity, -10000.0, 10000.0, 10, 0, ""); - uiDefButF(block, NUM, 0, "", xco+45+wval, yco-125, wval, 19, oa->angularvelocity+1, -10000.0, 10000.0, 10, 0, ""); - uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-125, wval, 19, oa->angularvelocity+2, -10000.0, 10000.0, 10, 0, ""); - - uiBlockSetCol(block, BUTGREEN); - uiDefButI(block, TOG|BIT|0, 0, "L", xco+45+3*wval, yco-22, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation"); - uiDefButI(block, TOG|BIT|1, 0, "L", xco+45+3*wval, yco-41, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation"); - uiDefButI(block, TOG|BIT|2, 0, "L", xco+45+3*wval, yco-64, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation"); - uiDefButI(block, TOG|BIT|3, 0, "L", xco+45+3*wval, yco-83, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation"); - uiDefButI(block, TOG|BIT|4, 0, "L", xco+45+3*wval, yco-106, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation"); - uiDefButI(block, TOG|BIT|5, 0, "L", xco+45+3*wval, yco-125, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation"); - - uiBlockSetCol(block, BUTGREEN); - uiDefButI(block, TOG|BIT|6, 0, "add",xco+45+3*wval+15, yco-106, 35, 19, &oa->flag, 0.0, 0.0, 0, 0, "Toggles between ADD and SET linV"); - uiBlockSetCol(block, BUTGREY); - - yco-= ysize; - break; - } - case ACT_ACTION: - { - /* DrawAct */ -#ifdef __NLA_ACTION_BY_MOTION_ACTUATOR - ysize = 112; -#else - ysize= 92; -#endif - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - aa = act->data; - wval = (width-60)/3; - - uiBlockSetCol(block, BUTGREY); - // str= "Action types %t|Play %x0|Ping Pong %x1|Flipper %x2|Loop Stop %x3|Loop End %x4|Property %x6"; -#ifdef __NLA_ACTION_BY_MOTION_ACTUATOR - str= "Action types %t|Play %x0|Flipper %x2|Loop Stop %x3|Loop End %x4|Property %x6|Displacement %x7"; -#else - str= "Action types %t|Play %x0|Flipper %x2|Loop Stop %x3|Loop End %x4|Property %x6"; -#endif - uiDefButS(block, MENU, B_REDR, str, xco+30, yco-24, width-60, 19, &aa->type, 0.0, 0.0, 0.0, 0.0, "Action playback type"); - uiDefIDPoinBut(block, test_actionpoin_but, 1, "AC: ", xco+30, yco-44, width-60, 19, &aa->act, "Action name"); - - if(aa->type == ACT_ACTION_FROM_PROP) - { - uiDefBut(block, TEX, 0, "Prop: ",xco+30, yco-64, width-60, 19, aa->name, 0.0, 31.0, 0, 0, "Use this property to define the Action position"); - } - else - { - uiDefButS(block, NUM, 0, "Sta: ",xco+30, yco-64, (width-60)/2, 19, &aa->sta, 0.0, 18000.0, 0, 0, "Start frame"); - uiDefButS(block, NUM, 0, "End: ",xco+30+(width-60)/2, yco-64, (width-60)/2, 19, &aa->end, 0.0, 18000.0, 0, 0, "End frame"); - } - - - - uiDefButS(block, NUM, 0, "Blendin: ", xco+30, yco-84, (width-60)/2, 19, &aa->blendin, 0.0, 18000.0, 0.0, 0.0, "Number of frames of motion blending"); - uiDefButS(block, NUM, 0, "Priority: ", xco+30+(width-60)/2, yco-84, (width-60)/2, 19, &aa->priority, 0.0, 100.0, 0.0, 0.0, "Execution priority - lower numbers will override actions with higher numbers"); - -#ifdef __NLA_ACTION_BY_MOTION_ACTUATOR - if(aa->type == ACT_ACTION_MOTION) - { - uiDefButF(block, NUM, 0, "Cycle: ",xco+30, yco-104, (width-60)/2, 19, &aa->stridelength, 0.0, 2500.0, 0, 0, "Distance covered by a single cycle of the action"); - } -#endif - - yco-=ysize; - break; - } - case ACT_IPO: - { - ia= act->data; - - if(ia->type==ACT_IPO_KEY2KEY) - ysize= 72; - else - ysize= 52; - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - str = "Ipo types %t|Play %x0|Ping Pong %x1|Flipper %x2|Loop Stop %x3|Loop End %x4|Property %x6"; - - uiDefButS(block, MENU, B_REDR, str, xco+20, yco-24, width-40 - (width-40)/3, 19, &ia->type, 0, 0, 0, 0, ""); - uiBlockSetCol(block, BUTGREEN); - uiDefButS(block, TOG|BIT|ACT_IPOCHILD_BIT, B_REDR, - "Child", xco+20+0.666*(width-40), yco-24, (width-40)/3, 19, - &ia->flag, 0, 0, 0, 0, - "Add all children Objects as well"); - uiBlockSetCol(block, BUTGREY); - /* - Key2key was disabled.... the settings below should not be reused without - thought, because they interfere with other variables. - - if(ia->type==ACT_IPO_KEY2KEY) { - uiBlockSetCol(block, BUTGREEN); - - uiDefButS(block, TOG|BIT|0, 0, "Prev", xco+20, yco-44, (width-40)/3, 19, &ia->flag, 0, 0, 0, 0, "Play backwards"); - uiDefButS(block, TOG|BIT|1, 0, "Cycl", xco+20+(width-40)/3, yco-44, (width-40)/3, 19, &ia->flag, 0, 0, 0, 0, "Play cyclic"); - uiDefButS(block, TOG|BIT|3, 0, "Hold", xco+20+2*(width-40)/3, yco-44, (width-40)/3, 19, &ia->flag, 0, 0, 0, 0, "Keep playing while activated"); - - uiDefBut(block, TEX, 0, "Prop: ", xco+20, yco-66, width-40, 19, ia->name, 0.0, 31.0, 0, 0, "Set property to key position"); - } else - */ - if(ia->type==ACT_IPO_FROM_PROP) { - uiDefBut(block, TEX, 0, - "Prop: ", xco+20, yco-44, width-40, 19, - ia->name, 0.0, 31.0, 0, 0, - "Use this property to define the Ipo position"); - } - else { - uiDefButS(block, NUM, 0, - "Sta", xco+20, yco-44, (width-100)/2, 19, - &ia->sta, 0.0, 18000.0, 0, 0, - "Start frame"); - uiDefButS(block, NUM, 0, - "End", xco+18+(width-90)/2, yco-44, (width-100)/2, 19, - &ia->end, 0.0, 18000.0, 0, 0, - "End frame"); - - uiBlockSetCol(block, BUTGREEN); - uiDefButS(block, TOG|BIT|ACT_IPOFORCE_BIT, B_REDR, - "Force", xco+width-78, yco-44, 43, 19, - &ia->flag, 0, 0, 0, 0, - "Convert Ipo to force"); - - /* Only show the do-force-local toggle if force is requested */ - if (ia->flag & ACT_IPOFORCE) { - uiDefButS(block, TOG|BIT|ACT_IPOFORCE_LOCAL_BIT, 0, - "L", xco+width-35, yco-44, 15, 19, - &ia->flag, 0, 0, 0, 0, - "Let the force-ipo act in local coordinates."); - } - - } - yco-= ysize; - break; - } - case ACT_PROPERTY: - { - ysize= 68; - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - pa= act->data; - - str= "Type %t|Assign %x0|Add %x1|Copy %x2"; - uiDefButI(block, MENU, B_REDR, str, xco+30,yco-24,width-60, 19, &pa->type, 0, 31, 0, 0, "Type"); - - uiDefBut(block, TEX, 1, "Prop: ", xco+30,yco-44,width-60, 19, pa->name, 0, 31, 0, 0, "Property name"); - - if(pa->type==ACT_PROP_COPY) { - uiDefIDPoinBut(block, test_obpoin_but, 1, "OB:", xco+10, yco-64, (width-20)/2, 19, &(pa->ob), "Copy from this Object"); - uiDefBut(block, TEX, 1, "Prop: ", xco+10+(width-20)/2, yco-64, (width-20)/2, 19, pa->value, 0, 31, 0, 0, "Copy this property"); - } - else { - uiDefBut(block, TEX, 1, "Value: ", xco+30,yco-64,width-60, 19, pa->value, 0, 31, 0, 0, "change with this value"); - } - yco-= ysize; - - break; - } - case ACT_SOUND: - { - ysize = 70; - - sa = act->data; - sa->sndnr = 0; - - wval = (width-20)/2; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - IDnames_to_pupstring(&str, "Sound files", NULL, &(G.main->sound), (ID *)sa->sound, &(sa->sndnr)); - - if(str[0]) - { - /* reset this value, it is for handling the event */ - sa->sndnr = 0; - uiDefButS(block, MENU, B_SOUNDACT_BROWSE, str, xco+10,yco-22,20,19, &(sa->sndnr), 0, 0, 0, 0, ""); - - if(sa->sound) - { - char dummy_str[] = "Sound mode %t|Play Stop %x0|Play End %x1|Loop Stop %x2|Loop End %x3|Loop Ping Pong Stop %x5|Loop Ping Pong %x4"; - uiDefBut(block, TEX, B_IDNAME, "SO:",xco+30,yco-22,width-40,19, sa->sound->id.name+2, 0.0, 18.0, 0, 0, ""); - uiDefButS(block, MENU, 1, dummy_str,xco+10,yco-44,width-20, 19, &sa->type, 0.0, 0.0, 0, 0, ""); - uiDefButF(block, NUM, 0, "Volume:", xco+10,yco-66,wval, 19, &sa->sound->volume, 0.0, 1.0, 0, 0, "Sets the volume of this sound"); - uiDefButF(block, NUM, 0, "Pitch:",xco+wval+10,yco-66,wval, 19, &sa->sound->pitch,-12.0, 12.0, 0, 0, "Sets the pitch of this sound"); - } - } - else - { - uiDefBut(block, LABEL, 0, "Use Sound window to load files", xco, yco-24, width, 19, NULL, 0, 0, 0, 0, ""); - } - - MEM_freeN(str); - - yco-= ysize; - - break; - } - case ACT_CD: - { - char cd_type_str[] = "Sound mode %t|Play all tracks %x0|Play one track %x1|" - "Volume %x3|Stop %x4|Pause %x5|Resume %x6"; - cda = act->data; - - if (cda) - { - if (cda->track == 0) - { - cda->track = 1; - cda->volume = 1; - cda->type = ACT_CD_PLAY_ALL; - } - - if (cda->type == ACT_CD_PLAY_TRACK || cda->type == ACT_CD_LOOP_TRACK) - { - ysize = 48; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - uiDefButS(block, NUM, 0, "Track:", xco+10,yco-44,width-20, 19, &cda->track, 1, 99, 0, 0, "Select the track to be played"); - } - else if (cda->type == ACT_CD_VOLUME) - { - ysize = 48; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - uiDefButF(block, NUM, 0, "Volume:", xco+10,yco-44,width-20, 19, &cda->volume, 0, 1, 0, 0, "Set the volume for CD playback"); - } - else - { - ysize = 28; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - } - uiDefButS(block, MENU, B_REDR, cd_type_str,xco+10,yco-22,width-20, 19, &cda->type, 0.0, 0.0, 0, 0, ""); - } - yco-= ysize; - break; - } - case ACT_CAMERA: - - ysize= 48; - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - ca= act->data; - - uiDefIDPoinBut(block, test_obpoin_but, 1, "OB:", xco+10, yco-24, (width-20)/2, 19, &(ca->ob), "Look at this Object"); - uiDefButF(block, NUM, 0, "Height:", xco+10+(width-20)/2, yco-24, (width-20)/2, 19, &ca->height, 0.0, 20.0, 0, 0, ""); - - uiDefButF(block, NUM, 0, "Min:", xco+10, yco-44, (width-60)/2, 19, &ca->min, 0.0, 20.0, 0, 0, ""); - - if(ca->axis==0) ca->axis= 'x'; - uiDefButS(block, ROW, 0, "X", xco+10+(width-60)/2, yco-44, 20, 19, &ca->axis, 4.0, (float)'x', 0, 0, "Camera tries to get behind the X axis"); - uiDefButS(block, ROW, 0, "Y", xco+30+(width-60)/2, yco-44, 20, 19, &ca->axis, 4.0, (float)'y', 0, 0, "Camera tries to get behind the Y axis"); - - uiDefButF(block, NUM, 0, "Max:", xco+20+(width)/2, yco-44, (width-60)/2, 19, &ca->max, 0.0, 20.0, 0, 0, ""); - - yco-= ysize; - - break; - - case ACT_EDIT_OBJECT: - - eoa= act->data; - - if(eoa->type==ACT_EDOB_ADD_OBJECT) { - int wval; /* just a temp width */ - ysize = 72; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - uiDefIDPoinBut(block, test_obpoin_but, 1, "OB:", xco+10, yco-44, (width-20)/2, 19, &(eoa->ob), "Add this Object"); - uiDefButI(block, NUM, 0, "Time:", xco+10+(width-20)/2, yco-44, (width-20)/2, 19, &eoa->time, 0.0, 2000.0, 0, 0, "Duration the new Object lives"); - - wval= (width-60)/3; - uiDefBut(block, LABEL, 0, "linV", xco, yco-68, 45, 19, - NULL, 0, 0, 0, 0, - "Velocity upon creation."); - uiDefButF(block, NUM, 0, "", xco+45, yco-68, wval, 19, - eoa->linVelocity, -100.0, 100.0, 10, 0, - "Velocity upon creation, x component."); - uiDefButF(block, NUM, 0, "", xco+45+wval, yco-68, wval, 19, - eoa->linVelocity+1, -100.0, 100.0, 10, 0, - "Velocity upon creation, y component."); - uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-68, wval, 19, - eoa->linVelocity+2, -100.0, 100.0, 10, 0, - "Velocity upon creation, z component."); - uiDefButS(block, TOG|BIT|1, 0, "L", xco+45+3*wval, yco-68, 15, 19, - &eoa->localflag, 0.0, 0.0, 0, 0, - "Apply the transformation locally"); - - } - else if(eoa->type==ACT_EDOB_END_OBJECT) { - ysize= 28; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - } - else if(eoa->type==ACT_EDOB_REPLACE_MESH) { - ysize= 48; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - uiDefIDPoinBut(block, test_meshpoin_but, 1, "ME:", xco+40, yco-44, (width-80), 19, &(eoa->me), "Add this Object"); - } - else if(eoa->type==ACT_EDOB_TRACK_TO) { - ysize= 48; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - uiDefIDPoinBut(block, test_obpoin_but, 1, "OB:", xco+10, yco-44, (width-20)/2, 19, &(eoa->ob), "Track to this Object"); - uiDefButI(block, NUM, 0, "Time:", xco+10+(width-20)/2, yco-44, (width-20)/2-40, 19, &eoa->time, 0.0, 2000.0, 0, 0, "Duration the tracking takes"); - uiBlockSetCol(block, BUTGREEN); - uiDefButS(block, TOG, 0, "3D", xco+width-50, yco-44, 40, 19, &eoa->flag, 0.0, 0.0, 0, 0, "Enable 3D tracking"); - uiBlockSetCol(block, BUTGREY); - } - - str= "Edit Object %t|Add Object %x0|End Object %x1|Replace Mesh %x2|Track to %x3"; - uiDefButS(block, MENU, B_REDR, str, xco+40, yco-24, (width-80), 19, &eoa->type, 0.0, 0.0, 0, 0, ""); - - yco-= ysize; - - break; - - case ACT_CONSTRAINT: - - ysize= 44; - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - coa= act->data; - -/* str= "Limit %t|None %x0|Loc X %x1|Loc Y %x2|Loc Z %x4|Rot X %x8|Rot Y %x16|Rot Z %x32"; */ - str= "Limit %t|None %x0|Loc X %x1|Loc Y %x2|Loc Z %x4"; - uiDefButS(block, MENU, 1, str, xco+10, yco-40, 70, 19, &coa->flag, 0.0, 0.0, 0, 0, ""); - - uiDefButS(block, NUM, 0, "Damp:", xco+10, yco-20, 70, 19, &coa->damp, 0.0, 100.0, 0, 0, ""); - uiDefBut(block, LABEL, 0, "Min", xco+80, yco-20, (width-90)/2, 19, NULL, 0.0, 0.0, 0, 0, ""); - uiDefBut(block, LABEL, 0, "Max", xco+80+(width-90)/2, yco-20, (width-90)/2, 19, NULL, 0.0, 0.0, 0, 0, ""); - - if(coa->flag & ACT_CONST_LOCX) fp= coa->minloc; - else if(coa->flag & ACT_CONST_LOCY) fp= coa->minloc+1; - else if(coa->flag & ACT_CONST_LOCZ) fp= coa->minloc+2; - else if(coa->flag & ACT_CONST_ROTX) fp= coa->minrot; - else if(coa->flag & ACT_CONST_ROTY) fp= coa->minrot+1; - else fp= coa->minrot+2; - - uiDefButF(block, NUM, 0, "", xco+80, yco-40, (width-90)/2, 19, fp, -2000.0, 2000.0, 10, 0, ""); - uiDefButF(block, NUM, 0, "", xco+80+(width-90)/2, yco-40, (width-90)/2, 19, fp+3, -2000.0, 2000.0, 10, 0, ""); - - yco-= ysize; - - break; - - case ACT_SCENE: - sca= act->data; - - if(sca->type==ACT_SCENE_RESTART) { - ysize= 28; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - } - else if(sca->type==ACT_SCENE_CAMERA) { - - ysize= 48; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - uiDefIDPoinBut(block, test_obpoin_but, 1, "OB:", xco+40, yco-44, (width-80), 19, &(sca->camera), "Set this Camera"); - } - else if(sca->type==ACT_SCENE_SET) { - - ysize= 48; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - uiDefIDPoinBut(block, test_scenepoin_but, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Set this Scene"); - } - else if(sca->type==ACT_SCENE_ADD_FRONT) { - - ysize= 48; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - uiDefIDPoinBut(block, test_scenepoin_but, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Add an Overlay Scene"); - } - else if(sca->type==ACT_SCENE_ADD_BACK) { - - ysize= 48; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - uiDefIDPoinBut(block, test_scenepoin_but, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Add a Background Scene"); - } - else if(sca->type==ACT_SCENE_REMOVE) { - - ysize= 48; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - uiDefIDPoinBut(block, test_scenepoin_but, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Remove a Scene"); - } - else if(sca->type==ACT_SCENE_SUSPEND) { - - ysize= 48; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - uiDefIDPoinBut(block, test_scenepoin_but, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Pause a Scene"); - } - else if(sca->type==ACT_SCENE_RESUME) { - - ysize= 48; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - uiDefIDPoinBut(block, test_scenepoin_but, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Unpause a Scene"); - } - - str= "Scene %t|Restart %x0|Set Scene %x1|Set Camera %x2|Add OverlayScene %x3|Add BackgroundScene %x4|Remove Scene %x5|Suspend Scene %x6|Resume Scene %x7"; - uiDefButS(block, MENU, B_REDR, str, xco+40, yco-24, (width-80), 19, &sca->type, 0.0, 0.0, 0, 0, ""); - - yco-= ysize; - break; - case ACT_GAME: - { - gma = act->data; - if (gma->type == ACT_GAME_LOAD) - { - //ysize = 68; - ysize = 48; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - uiDefBut(block, TEX, 1, "File: ", xco+10, yco-44,width-20,19, &(gma->filename), 0, 63, 0, 0, "Load this file"); -// uiDefBut(block, TEX, 1, "Anim: ", xco+10, yco-64,width-20,19, &(gma->loadaniname), 0, 63, 0, 0, "Use this loadinganimation"); - } -/* else if (gma->type == ACT_GAME_START) - { - ysize = 68; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - uiDefBut(block, TEX, 1, "File: ", xco+10, yco-44,width-20,19, &(gma->filename), 0, 63, 0, 0, "Load this file"); - uiDefBut(block, TEX, 1, "Anim: ", xco+10, yco-64,width-20,19, &(gma->loadaniname), 0, 63, 0, 0, "Use this loadinganimation"); - } -*/ else if (gma->type == ACT_GAME_RESTART) - { - ysize = 28; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - } - else if (gma->type == ACT_GAME_QUIT) - { - ysize = 28; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - } - - //str = "Scene %t|Load game%x0|Start loaded game%x1|Restart this game%x2|Quit this game %x3"; - str = "Scene %t|Start new game%x0|Restart this game%x2|Quit this game %x3"; - uiDefButS(block, MENU, B_REDR, str, xco+40, yco-24, (width-80), 19, &gma->type, 0.0, 0.0, 0, 0, ""); - - yco -= ysize; - break; - } - case ACT_GROUP: - ga= act->data; - - ysize= 52; - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - str= "GroupKey types %t|Set Key %x6|Play %x0|Ping Pong %x1|Flipper %x2|Loop Stop %x3|Loop End %x4|Property %x5"; - - uiDefButS(block, MENU, 1, str, xco+20, yco-24, width-40, 19, &ga->type, 0, 0, 0, 0, ""); - if(ga->type==ACT_GROUP_SET) { - uiDefBut(block, TEX, 0, "Key: ", xco+20, yco-44, (width-10)/2, 19, ga->name, 0.0, 31.0, 0, 0, "This name defines groupkey to be set"); - uiDefButS(block, NUM, 0, "Frame:", xco+20+(width-10)/2, yco-44, (width-70)/2, 19, &ga->sta, 0.0, 2500.0, 0, 0, "Set this frame"); - } - else if(ga->type==ACT_GROUP_FROM_PROP) { - uiDefBut(block, TEX, 0, "Prop: ", xco+20, yco-44, width-40, 19, ga->name, 0.0, 31.0, 0, 0, "Use this property to define the Group position"); - } - else { - uiDefButS(block, NUM, 0, "Sta", xco+20, yco-44, (width-40)/2, 19, &ga->sta, 0.0, 2500.0, 0, 0, "Start frame"); - uiDefButS(block, NUM, 0, "End", xco+20+(width-40)/2, yco-44, (width-40)/2, 19, &ga->end, 0.0, 2500.0, 0, 0, "End frame"); - } - yco-= ysize; - break; - - case ACT_VISIBILITY: - ysize = 24; - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, - (float)yco-ysize, (float)xco+width, (float)yco, 1); - - visAct = act->data; - - str= "Visibility %t|Visible %x0|Invisible %x1"; - - uiDefButI(block, MENU, B_REDR, str, - xco + 10, yco - 24, width - 20, 19, &visAct->flag, - 0.0, 0.0, 0, 0, - "Make the object invisible or visible."); -/* - uiDefButI(block, TOG|BIT|ACT_VISIBILITY_INVISIBLE_BIT, 0, - "Invisible", - xco + 10, yco - 24, width - 20, 19, &visAct->flag, - 0.0, 0.0, 0, 0, - "Make the object invisible or visible."); -*/ - yco-= ysize; - - break; - - case ACT_RANDOM: - ysize = 69; - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, - (float)yco-ysize, (float)xco+width, (float)yco, 1); - - randAct = act->data; - - /* 1. seed */ - uiDefButI(block, NUM, 1, "Seed: ", (xco+10),yco-24, 0.4 *(width-20), 19, - &randAct->seed, 0, 1000, 0, 0, - "Initial seed of the random generator. Use Python for more freedom. " - " (Choose 0 for not random)"); - - /* 2. distribution type */ - /* One pick per distribution. These numbers MUST match the #defines */ - /* in game.h !!! */ - str= "Distribution %t|Bool Constant %x0|Bool Uniform %x1" - "|Bool Bernoulli %x2|Int Constant %x3|Int Uniform %x4" - "|Int Poisson %x5|Float Constant %x6|Float Uniform %x7" - "|Float Normal %x8|Float Neg. Exp. %x9"; - uiDefButI(block, MENU, B_REDR, str, (xco+10) + 0.4 * (width-20), yco-24, 0.6 * (width-20), 19, - &randAct->distribution, 0.0, 0.0, 0, 0, - "Choose the type of distribution"); - - /* 3. property */ - uiDefBut(block, TEX, 1, "Property:", (xco+10), yco-44, (width-20), 19, - &randAct->propname, 0, 31, 0, 0, - "Assign the random value to this property"); - - /*4. and 5. arguments for the distribution*/ - switch (randAct->distribution) { - case ACT_RANDOM_BOOL_CONST: - uiDefButI(block, TOG|BIT|0, 1, "Always true", (xco+10), yco-64, (width-20), 19, - &randAct->int_arg_1, 2.0, 1, 0, 0, - "Always false or always true"); - break; - case ACT_RANDOM_BOOL_UNIFORM: - uiDefBut(block, LABEL, 0, " Do a 50-50 pick.", (xco+10), yco-64, (width-20), 19, - NULL, 0, 0, 0, 0, - "Choose between true and false, 50%% chance each."); - break; - case ACT_RANDOM_BOOL_BERNOUILLI: - uiDefButF(block, NUM, 1, "Chance", (xco+10), yco-64, (width-20), 19, - &randAct->float_arg_1, 0.0, 1.0, 0, 0, - "Pick a number between 0 and 1. Success if you stay " - "below this value"); - break; - case ACT_RANDOM_INT_CONST: - uiDefButI(block, NUM, 1, "Value: ", (xco+10), yco-64, (width-20), 19, - &randAct->int_arg_1, -1000, 1000, 0, 0, - "Always return this number"); - break; - case ACT_RANDOM_INT_UNIFORM: - uiDefButI(block, NUM, 1, "Min: ", (xco+10), yco-64, (width-20)/2, 19, - &randAct->int_arg_1, -1000, 1000, 0, 0, - "Choose a number from a range. " - "Lower boundary of the range."); - uiDefButI(block, NUM, 1, "Max: ", (xco+10) + (width-20)/2, yco-64, (width-20)/2, 19, - &randAct->int_arg_2, -1000, 1000, 0, 0, - "Choose a number from a range. " - "Upper boundary of the range."); - break; - case ACT_RANDOM_INT_POISSON: - uiDefButF(block, NUM, 1, "Mean: ", (xco+10), yco-64, (width-20), 19, - &randAct->float_arg_1, 0.01, 100.0, 0, 0, - "Expected mean value of the distribution."); - break; - case ACT_RANDOM_FLOAT_CONST: - uiDefButF(block, NUM, 1, "Value: ", (xco+10), yco-64, (width-20), 19, - &randAct->float_arg_1, 0.0, 1.0, 0, 0, - "Always return this number"); - break; - case ACT_RANDOM_FLOAT_UNIFORM: - uiDefButF(block, NUM, 1, "Min: ", (xco+10), yco-64, (width-20)/2, 19, - &randAct->float_arg_1, -10000.0, 10000.0, 0, 0, - "Choose a number from a range. " - "Lower boundary of the range."); - uiDefButF(block, NUM, 1, "Max: ", (xco+10) + (width-20)/2, yco-64, (width-20)/2, 19, - &randAct->float_arg_2, -10000.0, 10000.0, 0, 0, - "Choose a number from a range. " - "Upper boundary of the range."); - break; - case ACT_RANDOM_FLOAT_NORMAL: - uiDefButF(block, NUM, 1, "Mean: ", (xco+10), yco-64, (width-20)/2, 19, - &randAct->float_arg_1, -10000.0, 10000.0, 0, 0, - "A normal distribution. Mean of the distribution."); - uiDefButF(block, NUM, 1, "SD: ", (xco+10) + (width-20)/2, yco-64, (width-20)/2, 19, - &randAct->float_arg_2, 0.0, 10000.0, 0, 0, - "A normal distribution. Standard deviation of the " - "distribution."); - break; - case ACT_RANDOM_FLOAT_NEGATIVE_EXPONENTIAL: - uiDefButF(block, NUM, 1, "Half-life time: ", (xco+10), yco-64, (width-20), 19, - &randAct->float_arg_1, 0.001, 10000.0, 0, 0, - "Negative exponential dropoff."); - break; - default: - ; /* don't know what this distro is... can be useful for testing */ - /* though :) */ - } - - yco-= ysize; - break; - case ACT_MESSAGE: - ma = act->data; - -#define MESSAGE_SENSOR_TO_FIELD_WORKS /* Really? Not really. Don't remove this ifdef yet */ - -#ifdef MESSAGE_SENSOR_TO_FIELD_WORKS - ysize = 4 + (3 * 24); /* footer + number of lines * 24 pixels/line */ -#else - ysize = 4 + (2 * 24); /* footer + number of lines * 24 pixels/line */ -#endif - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, - (float)xco+width, (float)yco, 1); - - myline=1; - - -#ifdef MESSAGE_SENSOR_TO_FIELD_WORKS - /* line 1: To */ - uiDefBut(block, TEX, 1, "To: ", - (xco+10), (yco-(myline++*24)), (width-20), 19, - &ma->toPropName, 0, 31, 0, 0, - "Optional send message to objects with this property only" - ", or empty to broadcast"); - -#endif - - /* line 2: Message Subject */ - uiDefBut(block, TEX, 1, "Subject: ", - (xco+10), (yco-(myline++*24)), (width-20), 19, - &ma->subject, 0, 31, 0, 0, - "Optional message subject. This is what can be filtered on."); - - /* line 3: Text/Property */ - uiDefButS(block, TOG|BIT|0, B_REDR, "T/P", - (xco+10),(yco-(myline*24)), (0.20 * (width-20)), 19, - &ma->bodyType, 0.0, 0.0, 0, 0, - "Toggle message type: either Text or a PropertyName."); - - if (ma->bodyType == ACT_MESG_MESG) - { - /* line 3: Message Body */ - uiDefBut(block, TEX, 1, "Body: ", - (xco+10+(0.20*(width-20))),(yco-(myline++*24)),(0.8*(width-20)),19, - &ma->body, 0, 31, 0, 0, - "Optional message body Text"); - } else - { - /* line 3: Property body (set by property) */ - uiDefBut(block, TEX, 1, "Propname: ", - (xco+10+(0.20*(width-20))),(yco-(myline++*24)),(0.8*(width-20)),19, - &ma->body, 0, 31, 0, 0, - "The message body will be set by the Property Value"); - } - - yco -= ysize; - break; - default: - ysize= 4; - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - yco-= ysize; - break; - } - - uiBlockSetEmboss(block, UI_EMBOSSM); - uiBlockSetCol(block, BUTGREY); - - return yco-4; -} - -static void do_sensor_menu(void *arg, int event) -{ - ID **idar; - Object *ob; - bSensor *sens; - short count, a; - - idar= get_selected_and_linked_obs(&count, G.buts->scaflag); - - for(a=0; ascaflag |= OB_SHOWSENS; - else if(event==1) ob->scaflag &= ~OB_SHOWSENS; - } - - for(a=0; asensors.first; - while(sens) { - if(event==2) sens->flag |= SENS_SHOW; - else if(event==3) sens->flag &= ~SENS_SHOW; - sens= sens->next; - } - } - - if(idar) MEM_freeN(idar); - allqueue(REDRAWBUTSLOGIC, 0); -} - -static uiBlock *sensor_menu(void *arg_unused) -{ - uiBlock *block; - int yco=0; - - block= uiNewBlock(&curarea->uiblocks, "filemenu", UI_EMBOSSP, UI_HELV, curarea->win); - uiBlockSetButmFunc(block, do_sensor_menu, NULL); - uiBlockSetCol(block, MENUCOL); - - uiDefBut(block, BUTM, 1, "Show Objects", 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 0, ""); - uiDefBut(block, BUTM, 1, "Hide Objects", 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 1, ""); - uiDefBut(block, SEPR, 0, "", 0, (short)(yco-=6), 160, 6, NULL, 0.0, 0.0, 0, 0, ""); - uiDefBut(block, BUTM, 1, "Show Sensors", 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 2, ""); - uiDefBut(block, BUTM, 1, "Hide Sensors", 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 3, ""); - - uiBlockSetDirection(block, UI_TOP); - - return block; -} - -static void do_controller_menu(void *arg, int event) -{ - ID **idar; - Object *ob; - bController *cont; - short count, a; - - idar= get_selected_and_linked_obs(&count, G.buts->scaflag); - - for(a=0; ascaflag |= OB_SHOWCONT; - else if(event==1) ob->scaflag &= ~OB_SHOWCONT; - } - - for(a=0; acontrollers.first; - while(cont) { - if(event==2) cont->flag |= CONT_SHOW; - else if(event==3) cont->flag &= ~CONT_SHOW; - cont= cont->next; - } - } - - if(idar) MEM_freeN(idar); - allqueue(REDRAWBUTSLOGIC, 0); -} - -static uiBlock *controller_menu(void *arg_unused) -{ - uiBlock *block; - int yco=0; - - block= uiNewBlock(&curarea->uiblocks, "filemenu", UI_EMBOSSP, UI_HELV, curarea->win); - uiBlockSetButmFunc(block, do_controller_menu, NULL); - uiBlockSetCol(block, MENUCOL); - - uiDefBut(block, BUTM, 1, "Show Objects", 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 0, ""); - uiDefBut(block, BUTM, 1, "Hide Objects", 0,(short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 1, ""); - uiDefBut(block, SEPR, 0, "", 0, (short)(yco-=6), 160, 6, NULL, 0.0, 0.0, 0, 0, ""); - uiDefBut(block, BUTM, 1, "Show Controllers", 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 2, 2, ""); - uiDefBut(block, BUTM, 1, "Hide Controllers", 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 3, 3, ""); - - uiBlockSetDirection(block, UI_TOP); - - return block; -} - -static void do_actuator_menu(void *arg, int event) -{ - ID **idar; - Object *ob; - bActuator *act; - short count, a; - - idar= get_selected_and_linked_obs(&count, G.buts->scaflag); - - for(a=0; ascaflag |= OB_SHOWACT; - else if(event==1) ob->scaflag &= ~OB_SHOWACT; - } - - for(a=0; aactuators.first; - while(act) { - if(event==2) act->flag |= ACT_SHOW; - else if(event==3) act->flag &= ~ACT_SHOW; - act= act->next; - } - } - - if(idar) MEM_freeN(idar); - allqueue(REDRAWBUTSLOGIC, 0); -} - -static uiBlock *actuator_menu(void *arg_unused) -{ - uiBlock *block; - int xco=0; - - block= uiNewBlock(&curarea->uiblocks, "filemenu", UI_EMBOSSP, UI_HELV, curarea->win); - uiBlockSetButmFunc(block, do_actuator_menu, NULL); - uiBlockSetCol(block, MENUCOL); - - uiDefBut(block, BUTM, 1, "Show Objects", 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 0, ""); - uiDefBut(block, BUTM, 1, "Hide Objects", 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 1, ""); - uiDefBut(block, SEPR, 0, "", 0, (short)(xco-=6), 160, 6, NULL, 0.0, 0.0, 0, 0, ""); - uiDefBut(block, BUTM, 1, "Show Actuators", 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 2, ""); - uiDefBut(block, BUTM, 1, "Hide Actuators", 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 3, ""); - - uiBlockSetDirection(block, UI_TOP); - - return block; -} - -/* never used, see CVS 1.134 for the code */ -/* static FreeCamera *new_freecamera(void) */ - -/* never used, see CVS 1.120 for the code */ -/* static uiBlock *freecamera_menu(void) */ - -void gamebuts(void) -{ - ID **idar; - Object *ob; - bProperty *prop; - bSensor *sens; - bController *cont; - bActuator *act; - uiBlock *block; - uiBut *but; - int a; - short xco, yco, count, width, ycoo; - char *pupstr, name[32]; - int butreturn = 0; - - ob= OBACT; - - if(ob==0) return; - uiSetButLock(ob->id.lib!=0, "Can't edit library data"); - - sprintf(name, "buttonswin %d", curarea->win); - block= uiNewBlock(&curarea->uiblocks, name, UI_EMBOSSX, UI_HELV, curarea->win); - - uiBlockSetCol(block, BUTPURPLE); - // uiDefButI(block, TOG|BIT|0, B_REDR, "X", - // 15,205,10,19, &ob->gameflag2, 0, 0, 0, 0, - // "Toggle to always ignore activity culling."); - uiDefButI(block, TOG|BIT|2, B_REDR, "Actor", - 25,205,60,19, &ob->gameflag, 0, 0, 0, 0, - "Objects that are evaluated by the engine "); - - if(ob->gameflag & OB_ACTOR) { - uiDefButI(block, TOG|BIT|9, B_REDR, "Ghost", 85,205,65,19, &ob->gameflag, 0, 0, 0, 0, "Objects that don't restitute collisions (like a ghost)"); - uiDefButI(block, TOG|BIT|0, B_REDR, "Dynamic", 150,205,65,19, &ob->gameflag, 0, 0, 0, 0, "Motion defined by laws of physics"); - - if(ob->gameflag & OB_DYNAMIC) { - - uiDefButI(block, TOG|BIT|10, B_REDR, "Rigid Body", 215,205,135,19, &ob->gameflag, 0, 0, 0, 0, ""); - - uiDefButI(block, TOG|BIT|6, B_DIFF, "Do Fh", 10,185,50,19, &ob->gameflag, 0, 0, 0, 0, "Use Fh settings in Materials"); - uiDefButI(block, TOG|BIT|7, B_DIFF, "Rot Fh", 60,185,50,19, &ob->gameflag, 0, 0, 0, 0, "Use face normal to rotate Object"); - - uiBlockSetCol(block, BUTGREY); - - uiDefButF(block, NUM, B_DIFF, "Mass:", 110, 185, 80, 19, &ob->mass, 0.01, 100.0, 10, 0, "The mass of the Object"); - uiDefButF(block, NUM, REDRAWVIEW3D, "Size:", 190, 185, 80, 19, &ob->inertia, 0.01, 10.0, 10, 0, "Bounding sphere size"); - uiDefButF(block, NUM, B_DIFF, "Form:", 270, 185, 80, 19, &ob->formfactor, 0.01, 100.0, 10, 0, "Form factor"); - - uiDefButF(block, NUM, B_DIFF, "Damp:", 10, 165, 100, 19, &ob->damping, 0.0, 1.0, 10, 0, "General movement damping"); - uiDefButF(block, NUM, B_DIFF, "RotDamp:", 110, 165, 120, 19, &ob->rdamping, 0.0, 1.0, 10, 0, "General rotation damping"); - uiDefButI(block, TOG|BIT|8, B_REDR, "Anisotropic", 230, 165, 120, 19, - &ob->gameflag, 0.0, 1.0, 10, 0, - "Enable anisotropic friction"); - } - } - - if (ob->gameflag & OB_ANISOTROPIC_FRICTION) { - uiDefButF(block, NUM, B_DIFF, "x friction:", 10, 145, 114, 19, - &ob->anisotropicFriction[0], 0.0, 1.0, 10, 0, - "Relative friction coefficient in the x-direction."); - uiDefButF(block, NUM, B_DIFF, "y friction:", 124, 145, 113, 19, - &ob->anisotropicFriction[1], 0.0, 1.0, 10, 0, - "Relative friction coefficient in the y-direction."); - uiDefButF(block, NUM, B_DIFF, "z friction:", 237, 145, 113, 19, - &ob->anisotropicFriction[2], 0.0, 1.0, 10, 0, - "Relative friction coefficient in the z-direction."); - } - - uiBlockSetCol(block, BUTSALMON); - uiDefBut(block, BUT, B_ADD_PROP, "ADD property", 10, 110, 340, 24, - NULL, 0.0, 100.0, 100, 0, - ""); - - pupstr= "Types %t|Bool %x0|Int %x1|Float %x2|String %x3|Timer %x5"; - - a= 0; - prop= ob->prop.first; - while(prop) { - - uiBlockSetCol(block, BUTSALMON); - but= uiDefBut(block, BUT, 1, "Del", 10, (short)(90-20*a), 40, 19, NULL, 0.0, 0.0, 1, (float)a, ""); - uiButSetFunc(but, del_property, prop, NULL); - uiBlockSetCol(block, BUTGREY); - uiDefButS(block, MENU, B_CHANGE_PROP, pupstr, 50, (short)(90-20*a), 60, 19, &prop->type, 0, 0, 0, 0, ""); - but= uiDefBut(block, TEX, 1, "Name:", 110, (short)(90-20*a), 105, 19, prop->name, 0, 31, 0, 0, ""); - uiButSetFunc(but, make_unique_prop_names_cb, prop->name, (void*) 1); - - if (strcmp(prop->name, "Text") == 0) { - butreturn = REDRAWVIEW3D; - } else { - butreturn = 0; - } - - if(prop->type==PROP_BOOL) { - uiBlockSetCol(block, BUTGREEN); - uiDefButI(block, TOG|BIT|0, B_REDR, "True", 215, (short)(90-20*a), 55, 19, &prop->data, 0, 0, 0, 0, ""); - uiDefButI(block, TOGN|BIT|0, B_REDR, "False", 270, (short)(90-20*a), 55, 19, &prop->data, 0, 0, 0, 0, ""); - uiBlockSetCol(block, BUTGREY); - } - else if(prop->type==PROP_INT) - uiDefButI(block, NUM, butreturn, "", 215, (short)(90-20*a), 110, 19, &prop->data, -10000, 10000, 0, 0, ""); - else if(prop->type==PROP_FLOAT) - uiDefButF(block, NUM, butreturn, "", 215, (short)(90-20*a), 110, 19, (float*) &prop->data, -10000, 10000, 100, 0, ""); - else if(prop->type==PROP_STRING) - uiDefBut(block, TEX, butreturn, "", 215, (short)(90-20*a), 110, 19, prop->poin, 0, 127, 0, 0, ""); - else if(prop->type==PROP_TIME) - uiDefButF(block, NUM, butreturn, "", 215, (short)(90-20*a), 110, 19, (float*) &prop->data, -10000, 10000, 0, 0, ""); - - uiDefButS(block, TOG|BIT|0, 0, "D", 325, (short)(90-20*a), 20, 19, &prop->flag, 0, 0, 0, 0, "Print Debug info"); - - a++; - prop= prop->next; - } - - uiClearButLock(); - - idar= get_selected_and_linked_obs(&count, G.buts->scaflag); - - /* ******************************* */ - xco= 375; yco= 170; width= 230; - - uiBlockSetCol(block, BUTGREY); - uiBlockSetEmboss(block, UI_EMBOSSP); - uiDefBlockBut(block, sensor_menu, NULL, "Sensors", xco-10, yco+35, 80, 19, ""); - uiBlockSetCol(block, BUTGREEN); - uiBlockSetEmboss(block, UI_EMBOSSX); - uiDefButS(block, TOG|BIT|0, B_REDR, "Sel", xco+110, yco+35, (width-100)/3, 19, &G.buts->scaflag, 0, 0, 0, 0, "Show all selected Objects"); - uiDefButS(block, TOG|BIT|1, B_REDR, "Act", xco+110+(width-100)/3, yco+35, (width-100)/3, 19, &G.buts->scaflag, 0, 0, 0, 0, "Show active Object"); - uiDefButS(block, TOG|BIT|2, B_REDR, "Link", xco+110+2*(width-100)/3, yco+35, (width-100)/3, 19, &G.buts->scaflag, 0, 0, 0, 0, "Show linked Objects to Controller"); - - for(a=0; aid.lib!=0, "Can't edit library data"); - - if( (ob->scavisflag & OB_VIS_SENS) == 0) continue; - - /* presume it is only objects for now */ - uiBlockSetEmboss(block, UI_EMBOSSX); - uiBlockSetCol(block, BUTGREY); - if(ob->sensors.first) uiSetCurFont(block, UI_HELVB); - uiBlockSetCol(block, MIDGREY); - uiDefButS(block, TOG|BIT|6, B_REDR, ob->id.name+2,(short)(xco-10), yco, (short)(width-30), 19, &ob->scaflag, 0, 31, 0, 0, "Object name, click to show/hide sensors"); - if(ob->sensors.first) uiSetCurFont(block, UI_HELV); - uiBlockSetCol(block, BUTSALMON); - uiDefButS(block, TOG|BIT|8, B_ADD_SENS, "Add",(short)(xco+width-40), yco, 50, 19, &ob->scaflag, 0, 0, 0, 0, "Add a new Sensor"); - yco-=20; - - if(ob->scaflag & OB_SHOWSENS) { - - sens= ob->sensors.first; - while(sens) { - uiBlockSetEmboss(block, UI_EMBOSSW); - uiBlockSetCol(block, BUTSALMON); - uiDefIconButS(block, TOG|BIT|1, B_DEL_SENS, ICON_X, xco, yco, 22, 19, &sens->flag, 0, 0, 0, 0, "Delete Sensor"); - uiBlockSetCol(block, BUTGREY); - uiDefIconButS(block, ICONTOG|BIT|0, B_REDR, ICON_RIGHTARROW, (short)(xco+width-22), yco, 22, 19, &sens->flag, 0, 0, 0, 0, "Sensor settings"); - - ycoo= yco; - if(sens->flag & SENS_SHOW) - { - uiBlockSetCol(block, BUTYELLOW); - - uiDefButS(block, MENU, B_CHANGE_SENS, sensor_pup(), (short)(xco+22), yco, 100, 19, &sens->type, 0, 0, 0, 0, "Sensor type"); - but= uiDefBut(block, TEX, 1, "", (short)(xco+122), yco, (short)(width-144), 19, sens->name, 0, 31, 0, 0, "Sensor name"); - uiButSetFunc(but, make_unique_prop_names_cb, sens->name, (void*) 0); - - sens->otype= sens->type; - uiBlockSetCol(block, BUTGREY); - yco= draw_sensorbuttons(sens, block, xco, yco, width,ob->id.name); - if(yco-6 < ycoo) ycoo= (yco+ycoo-20)/2; - } - else { - set_col_sensor(sens->type, 1); - glRecti(xco+22, yco, xco+width-22,yco+19); - but= uiDefBut(block, LABEL, 0, sensor_name(sens->type), (short)(xco+22), yco, 100, 19, sens, 0, 0, 0, 0, ""); - uiButSetFunc(but, sca_move_sensor, sens, NULL); - but= uiDefBut(block, LABEL, 0, sens->name, (short)(xco+122), yco, (short)(width-144), 19, sens, 0, 31, 0, 0, ""); - uiButSetFunc(but, sca_move_sensor, sens, NULL); - } - - but= uiDefIconBut(block, LINK, 0, ICON_LINK, (short)(xco+width), ycoo, 19, 19, NULL, 0, 0, 0, 0, ""); - uiSetButLink(but, NULL, (void ***)&(sens->links), &sens->totlinks, LINK_SENSOR, LINK_CONTROLLER); - - yco-=20; - - sens= sens->next; - } - yco-= 6; - } - } - - /* ******************************* */ - xco= 675; yco= 170; width= 230; - - uiBlockSetCol(block, BUTGREY); - uiBlockSetEmboss(block, UI_EMBOSSP); - uiDefBlockBut(block, controller_menu, NULL, "Controllers", xco-10, yco+35, 100, 19, ""); - uiBlockSetCol(block, BUTGREEN); - uiBlockSetEmboss(block, UI_EMBOSSX); - uiDefButS(block, TOG|BIT|3, B_REDR, "Sel", xco+110, yco+35, (width-100)/3, 19, &G.buts->scaflag, 0, 0, 0, 0, "Show all selected Objects"); - uiDefButS(block, TOG|BIT|4, B_REDR, "Act", xco+110+(width-100)/3, yco+35, (width-100)/3, 19, &G.buts->scaflag, 0, 0, 0, 0, "Show active Object"); - uiDefButS(block, TOG|BIT|5, B_REDR, "Link", xco+110+2*(width-100)/3, yco+35, (width-100)/3, 19, &G.buts->scaflag, 0, 0, 0, 0, "Show linked Objects to Sensor/Actuator"); - - ob= OBACT; - - for(a=0; aid.lib!=0, "Can't edit library data"); - if( (ob->scavisflag & OB_VIS_CONT) == 0) continue; - - /* presume it is only objects for now */ - uiBlockSetEmboss(block, UI_EMBOSSX); - uiBlockSetCol(block, BUTSALMON); - uiDefButS(block, TOG|BIT|9, B_ADD_CONT, "Add",(short)(xco+width-40), yco, 50, 19, &ob->scaflag, 0, 0, 0, 0, "Add a new Controller"); - uiBlockSetCol(block, MIDGREY); - if(ob->controllers.first) uiSetCurFont(block, UI_HELVB); - uiDefButS(block, TOG|BIT|11, B_REDR, ob->id.name+2,(short)(xco-10), yco, (short)(width-30), 19, &ob->scaflag, 0, 0, 0, 0, "Active Object name"); - if(ob->controllers.first) uiSetCurFont(block, UI_HELV); - yco-=20; - - if(ob->scaflag & OB_SHOWCONT) { - - cont= ob->controllers.first; - while(cont) { - uiBlockSetEmboss(block, UI_EMBOSSW); - uiBlockSetCol(block, BUTSALMON); - uiDefIconButS(block, TOG|BIT|1, B_DEL_CONT, ICON_X, xco, yco, 22, 19, &cont->flag, 0, 0, 0, 0, "Delete Controller"); - uiBlockSetCol(block, BUTGREY); - uiDefIconButS(block, ICONTOG|BIT|0, B_REDR, ICON_RIGHTARROW, (short)(xco+width-22), yco, 22, 19, &cont->flag, 0, 0, 0, 0, "Controller settings"); - - if(cont->flag & CONT_SHOW) { - uiBlockSetCol(block, BUTYELLOW); - cont->otype= cont->type; - uiDefButS(block, MENU, B_CHANGE_CONT, controller_pup(),(short)(xco+22), yco, 100, 19, &cont->type, 0, 0, 0, 0, "Controller type"); - but= uiDefBut(block, TEX, 1, "", (short)(xco+122), yco, (short)(width-144), 19, cont->name, 0, 31, 0, 0, "Controller name"); - uiButSetFunc(but, make_unique_prop_names_cb, cont->name, (void*) 0); - uiBlockSetCol(block, BUTGREY); - - ycoo= yco; - yco= draw_controllerbuttons(cont, block, xco, yco, width); - if(yco-6 < ycoo) ycoo= (yco+ycoo-20)/2; - } - else { - cpack(0x999999); - glRecti(xco+22, yco, xco+width-22,yco+19); - but= uiDefBut(block, LABEL, 0, controller_name(cont->type), (short)(xco+22), yco, 100, 19, cont, 0, 0, 0, 0, "Controller type"); - uiButSetFunc(but, sca_move_controller, cont, NULL); - but= uiDefBut(block, LABEL, 0, cont->name,(short)(xco+122), yco,(short)(width-144), 19, cont, 0, 0, 0, 0, "Controller name"); - uiButSetFunc(but, sca_move_controller, cont, NULL); - ycoo= yco; - } - - but= uiDefIconBut(block, LINK, 0, ICON_LINK, (short)(xco+width), ycoo, 19, 19, NULL, 0, 0, 0, 0, ""); - uiSetButLink(but, NULL, (void ***)&(cont->links), &cont->totlinks, LINK_CONTROLLER, LINK_ACTUATOR); - - uiDefIconBut(block, INLINK, 0, ICON_INLINK,(short)(xco-19), ycoo, 19, 19, cont, LINK_CONTROLLER, 0, 0, 0, ""); - - yco-=20; - - cont= cont->next; - } - yco-= 6; - } - } - - /* ******************************* */ - xco= 985; yco= 170; width= 280; - - uiBlockSetCol(block, BUTGREY); - uiBlockSetEmboss(block, UI_EMBOSSP); - uiDefBlockBut(block, actuator_menu, NULL, "Actuators", xco-10, yco+35, 100, 19, ""); - uiBlockSetCol(block, BUTGREEN); - uiBlockSetEmboss(block, UI_EMBOSSX); - uiDefButS(block, TOG|BIT|6, B_REDR, "Sel", xco+110, yco+35, (width-110)/3, 19, &G.buts->scaflag, 0, 0, 0, 0, "Show all selected Objects"); - uiDefButS(block, TOG|BIT|7, B_REDR, "Act", xco+110+(width-110)/3, yco+35, (width-110)/3, 19, &G.buts->scaflag, 0, 0, 0, 0, "Show active Object"); - uiDefButS(block, TOG|BIT|8, B_REDR, "Link", xco+110+2*(width-110)/3, yco+35, (width-110)/3, 19, &G.buts->scaflag, 0, 0, 0, 0, "Show linked Objects to Controller"); - - for(a=0; aid.lib!=0, "Can't edit library data"); - if( (ob->scavisflag & OB_VIS_ACT) == 0) continue; - - /* presume it is only objects for now */ - uiBlockSetEmboss(block, UI_EMBOSSX); - uiBlockSetCol(block, BUTGREY); - if(ob->actuators.first) uiSetCurFont(block, UI_HELVB); - uiBlockSetCol(block, MIDGREY); - uiDefButS(block, TOG|BIT|7, B_REDR, ob->id.name+2,(short)(xco-10), yco,(short)(width-30), 19, &ob->scaflag, 0, 31, 0, 0, "Object name, click to show/hide actuators"); - if(ob->actuators.first) uiSetCurFont(block, UI_HELV); - uiBlockSetCol(block, BUTSALMON); - uiDefButS(block, TOG|BIT|10, B_ADD_ACT, "Add",(short)(xco+width-40), yco, 50, 19, &ob->scaflag, 0, 0, 0, 0, "Add a new Actuator"); - yco-=20; - - if(ob->scaflag & OB_SHOWACT) { - - act= ob->actuators.first; - while(act) { - uiBlockSetEmboss(block, UI_EMBOSSW); - uiBlockSetCol(block, BUTSALMON); - uiDefIconButS(block, TOG|BIT|1, B_DEL_ACT, ICON_X, xco, yco, 22, 19, &act->flag, 0, 0, 0, 0, "Delete Actuator"); - uiBlockSetCol(block, BUTGREY); - uiDefIconButS(block, ICONTOG|BIT|0, B_REDR, ICON_RIGHTARROW, (short)(xco+width-22), yco, 22, 19, &act->flag, 0, 0, 0, 0, "Actuator settings"); - - if(act->flag & ACT_SHOW) { - uiBlockSetCol(block, BUTYELLOW); - act->otype= act->type; - uiDefButS(block, MENU, B_CHANGE_ACT, actuator_pup(ob), (short)(xco+22), yco, 100, 19, &act->type, 0, 0, 0, 0, "Actuator type"); - but= uiDefBut(block, TEX, 1, "", (short)(xco+122), yco, (short)(width-144), 19, act->name, 0, 31, 0, 0, "Actuator name"); - uiButSetFunc(but, make_unique_prop_names_cb, act->name, (void*) 0); - uiBlockSetCol(block, BUTGREY); - - ycoo= yco; - yco= draw_actuatorbuttons(act, block, xco, yco, width); - if(yco-6 < ycoo) ycoo= (yco+ycoo-20)/2; - } - else { - set_col_actuator(act->type, 1); - glRecti((short)(xco+22), yco, (short)(xco+width-22),(short)(yco+19)); - but= uiDefBut(block, LABEL, 0, actuator_name(act->type), (short)(xco+22), yco, 100, 19, act, 0, 0, 0, 0, "Actuator type"); - uiButSetFunc(but, sca_move_actuator, act, NULL); - but= uiDefBut(block, LABEL, 0, act->name, (short)(xco+122), yco, (short)(width-144), 19, act, 0, 0, 0, 0, "Actuator name"); - uiButSetFunc(but, sca_move_actuator, act, NULL); - ycoo= yco; - } - - uiDefIconBut(block, INLINK, 0, ICON_INLINK,(short)(xco-19), ycoo, 19, 19, act, LINK_ACTUATOR, 0, 0, 0, ""); - - yco-=20; - - act= act->next; - } - yco-= 6; - } - } - - uiComposeLinks(block); - uiDrawBlock(block); - - if(idar) MEM_freeN(idar); -} - diff --git a/source/blender/src/editscreen.c b/source/blender/src/editscreen.c index 20434766fd1..37edc66a74b 100644 --- a/source/blender/src/editscreen.c +++ b/source/blender/src/editscreen.c @@ -916,7 +916,7 @@ static ScrArea *screen_find_area_for_pt(bScreen *sc, short *mval) void screenmain(void) { - int has_input= 0; /* was one, why! (ton) */ + int has_input= 1; int firsttime = 1; window_make_active(mainwin); @@ -1165,7 +1165,13 @@ void setprefsize(int stax, int stay, int sizx, int sizy) if(sizy<256) sizy= 256; if(stax+sizx>scrwidth) sizx= scrwidth-stax; + if(stay+sizy>scrheight) sizy= scrheight-stay; + +#ifdef __APPLE__ + if(stay+sizy>scrheight-22) sizy= scrheight-22-stay; // 22 = topbar +#endif + if(sizx<320 || sizy<256) { printf("ERROR: illegal prefsize\n"); return; diff --git a/source/blender/src/ghostwinlay.c b/source/blender/src/ghostwinlay.c index cf29efd71b8..e4fa0429d28 100644 --- a/source/blender/src/ghostwinlay.c +++ b/source/blender/src/ghostwinlay.c @@ -229,6 +229,10 @@ Window *window_open(char *title, int posx, int posy, int sizex, int sizey, int s int scr_w, scr_h; winlay_get_screensize(&scr_w, &scr_h); + if(G.f & G_DEBUG) { + printf("screen size %d %d\n", scr_w, scr_h); + printf("win start %d %d size %d %d\n", posx, posy, sizex, sizey); + } posy= (scr_h-posy-sizey); /* create a fullscreen window on unix by default*/ @@ -241,7 +245,7 @@ Window *window_open(char *title, int posx, int posy, int sizex, int sizey, int s inital_state= GHOST_kWindowStateFullScreen; else inital_state= start_maximized?GHOST_kWindowStateMaximized:GHOST_kWindowStateNormal; -#else +#else // APPLE inital_state= start_maximized?GHOST_kWindowStateMaximized:GHOST_kWindowStateNormal; #endif #endif diff --git a/source/blender/src/header_buttonswin.c b/source/blender/src/header_buttonswin.c index c612a56a950..b9b34f30c6e 100644 --- a/source/blender/src/header_buttonswin.c +++ b/source/blender/src/header_buttonswin.c @@ -69,6 +69,8 @@ #include "BIF_resources.h" #include "BIF_screen.h" #include "BIF_space.h" +#include "BIF_butspace.h" + #include "BKE_armature.h" #include "BKE_global.h" #include "BKE_library.h" @@ -252,7 +254,7 @@ void buttons_active_id(ID **id, ID **idfrom) *id= (ID *)ob; } } - else if(G.buts->mainb==CONTEXT_TYPES || G.buts->mainb==CONTEXT_EDITING) { + else if(G.buts->mainb==CONTEXT_EDITING) { if(ob && ob->data) { *id= ob->data; } @@ -352,11 +354,10 @@ static uiBlock *sbuts_context_menu(void *arg_unused) /* should be branches from tree */ uiDefIconTextButS(block, BUTM, B_REDR, ICON_SCENE_DEHLT, "Scene|F10", 0, yco-=22, 100, 20, &G.buts->mainb, 0.0, 0.0, 0, 0, ""); uiDefIconTextButS(block, BUTM, B_REDR, ICON_EDIT, "Editing|F9", 0, yco-=22, 100, 20, &G.buts->mainb, 4.0, 0.0, 0, 0, ""); - uiDefIconTextButS(block, BUTM, B_REDR, ICON_OBJECT, "Object|F8", 0, yco-=22, 100, 20, &G.buts->mainb, 1.0, 0.0, 0, 0, ""); - uiDefIconTextButS(block, BUTM, B_REDR, ICON_BBOX, "Types|F7", 0, yco-=22, 100, 20, &G.buts->mainb, 2.0, 0.0, 0, 0, ""); - uiDefIconTextButS(block, BUTM, B_REDR, ICON_SCRIPT, "Script|F6", 0, yco-=22, 100, 20, &G.buts->mainb, 5.0, 0.0, 0, 0, ""); + uiDefIconTextButS(block, BUTM, B_REDR, ICON_OBJECT, "Object|F6", 0, yco-=22, 100, 20, &G.buts->mainb, 1.0, 0.0, 0, 0, ""); + uiDefIconTextButS(block, BUTM, B_REDR, ICON_SCRIPT, "Script", 0, yco-=22, 100, 20, &G.buts->mainb, 5.0, 0.0, 0, 0, ""); + uiDefIconTextButS(block, BUTM, B_REDR, ICON_GAME, "Logic", 0, yco-=22, 100, 20, &G.buts->mainb, 6.0, 0.0, 0, 0, ""); uiDefIconTextButS(block, BUTM, B_REDR, ICON_MATERIAL_DEHLT, "Shading|F5", 0, yco-=22, 100, 20, &G.buts->mainb, 3.0, 0.0, 0, 0, ""); - uiDefIconTextButS(block, BUTM, B_REDR, ICON_GAME, "Logic|F4", 0, yco-=22, 100, 20, &G.buts->mainb, 6.0, 0.0, 0, 0, ""); if(curarea->headertype==HEADERTOP) { uiBlockSetDirection(block, UI_DOWN); @@ -369,6 +370,7 @@ static uiBlock *sbuts_context_menu(void *arg_unused) return block; } + void buts_buttons(void) { ID *id, *idfrom; @@ -413,17 +415,16 @@ void buts_buttons(void) } /* select the context to be drawn, per contex/tab the actual context is tested */ + uiBlockSetEmboss(block, UI_EMBOSSX); // normal switch(G.buts->mainb) { case CONTEXT_SCENE: - uiDefIconButC(block, ROW, B_REDR, ICON_SCENE, xco+=XIC, t_base, XIC, YIC, &(G.buts->tab[CONTEXT_SCENE]), 1.0, (float)TAB_SCENE_RENDER, 0, 0, "Display buttons (F10)"); - uiDefIconButC(block, ROW, B_BUTSPREVIEW,ICON_WORLD, xco+=XIC, t_base, XIC, YIC, &(G.buts->tab[CONTEXT_SCENE]), 1.0, (float)TAB_SCENE_WORLD, 0, 0, "World buttons"); + uiDefIconButC(block, ROW, B_REDR, ICON_SCENE, xco+=XIC, t_base, XIC, YIC, &(G.buts->tab[CONTEXT_SCENE]), 1.0, (float)TAB_SCENE_RENDER, 0, 0, "Render buttons "); + uiDefIconButC(block, ROW, B_REDR, ICON_ANIM, xco+=XIC, t_base, XIC, YIC, &(G.buts->tab[CONTEXT_SCENE]), 1.0, (float)TAB_SCENE_ANIM, 0, 0, "Anim/playback buttons"); + uiDefIconButC(block, ROW, B_REDR, ICON_SOUND, xco+=XIC, t_base, XIC, YIC, &(G.buts->tab[CONTEXT_SCENE]), 1.0, (float)TAB_SCENE_SOUND, 0, 0, "Sound block buttons"); break; case CONTEXT_OBJECT: - break; - case CONTEXT_TYPES: - break; case CONTEXT_SHADING: uiDefIconButC(block, ROW, B_BUTSPREVIEW, ICON_LAMP, xco+=XIC, t_base, XIC, YIC, &(G.buts->tab[CONTEXT_SHADING]), 1.0, (float)TAB_SHADING_LAMP, 0, 0, "Lamp buttons"); @@ -445,19 +446,6 @@ void buts_buttons(void) } #if 0 - xco+= 2*XIC; - uiDefIconButS(block, ROW, B_REDR, ICON_EYE, xco+=XIC, t_base, 30, YIC, &(G.buts->mainb), 1.0, (float)BUTS_VIEW, 0, 0, "View buttons"); - - uiDefIconButS(block, ROW, B_REDR, ICON_ANIM, xco+=30, t_base, 30, YIC, &(G.buts->mainb), 1.0, (float)BUTS_ANIM, 0, 0, "Animation buttons (F7)"); - uiDefIconButS(block, ROW, B_REDR, ICON_GAME, xco+=30, t_base, 30, YIC, &(G.buts->mainb), 1.0, (float)BUTS_GAME, 0, 0, "Realtime buttons (F8)"); - uiDefIconButS(block, ROW, B_REDR, ICON_EDIT, xco+=30, t_base, 30, YIC, &(G.buts->mainb), 1.0, (float)BUTS_EDIT, 0, 0, "Edit buttons (F9)"); - uiDefIconButS(block, ROW, B_REDR, ICON_CONSTRAINT,xco+=30, t_base, 30, YIC, &(G.buts->mainb), 1.0, (float)BUTS_CONSTRAINT, 0, 0, "Constraint buttons"); - uiDefIconButS(block, ROW, B_REDR, ICON_SPEAKER,xco+=30, t_base, 30, YIC, &(G.buts->mainb), 1.0, (float)BUTS_SOUND, 0, 0, "Sound buttons"); - uiDefIconButS(block, ROW, B_REDR, ICON_PAINT,xco+=30, t_base, 30, YIC, &(G.buts->mainb), 1.0, (float)BUTS_FPAINT, 0, 0, "Paint buttons"); - uiDefIconButS(block, ROW, B_REDR, ICON_SCRIPT,xco+=30, t_base, 30, YIC, &(G.buts->mainb), 1.0, (float)BUTS_SCRIPT, 0, 0, "Script buttons"); - uiDefIconButS(block, ROW, B_REDR, ICON_SCENE, xco+=30, t_base, 50, YIC, &(G.buts->mainb), 1.0, (float)BUTS_RENDER, 0, 0, "Display buttons (F10)"); - xco+= 80; - uiBlockSetCol(block, BUTGREY); uiBlockSetEmboss(block, UI_EMBOSSX); @@ -621,10 +609,6 @@ void buts_buttons(void) xco+= 80; #endif - // memory for finding which texture you'd like to see - G.buts->mainbo= G.buts->mainb; - G.buts->tabo= G.buts->tab[G.buts->mainb]; - /* always do as last */ uiDrawBlock(block); curarea->headbutlen= xco; diff --git a/source/blender/src/headerbuttons.c b/source/blender/src/headerbuttons.c index 7d5b3caf66f..65432429fde 100644 --- a/source/blender/src/headerbuttons.c +++ b/source/blender/src/headerbuttons.c @@ -148,6 +148,7 @@ #include "BIF_usiblender.h" #include "BIF_previewrender.h" #include "BIF_writeimage.h" +#include "BIF_butspace.h" #include "BSE_edit.h" #include "BSE_filesel.h" diff --git a/source/blender/src/interface.c b/source/blender/src/interface.c index e04518c2c55..6ea39293b7b 100644 --- a/source/blender/src/interface.c +++ b/source/blender/src/interface.c @@ -2816,6 +2816,7 @@ static void ui_warp_pointer(short x, short y) #endif } +#if 0 static int ui_do_but_MENUo(uiBut *but) { uiBlock *block; @@ -2956,6 +2957,7 @@ static int ui_do_but_MENUo(uiBut *but) return event; } +#endif static int ui_do_but_MENU(uiBut *but) { @@ -4193,8 +4195,10 @@ static void setup_file(uiBlock *block) else { but= block->buttons.first; while(but) { - if(but->rt[3]==1) - fprintf(fp,"%d,%d,%d,%d %s %s\n", (int)but->x1, (int)but->y1, (int)( but->x2-but->x1), (int)(but->y2-but->y1), but->str, but->tip); + // if(but->rt[3]==1) { + ui_check_but(but); + fprintf(fp,"%d,%d,%d,%d %s %s\n", (int)but->x1, (int)but->y1, (int)( but->x2-but->x1), (int)(but->y2-but->y1), but->str, but->tip); + // } but= but->next; } fclose(fp); @@ -5251,6 +5255,9 @@ void uiFreeBlock(uiBlock *block) ui_free_but(but); } + if(block->panel) block->panel->active= 0; + + MEM_freeN(block); UIbuttip= NULL; } @@ -5349,6 +5356,7 @@ static void ui_check_but(uiBut *but) switch( but->type ) { case MENU: + case ICONTEXTROW: if(but->x2 - but->x1 > 24) { value= ui_get_but_val(but); @@ -5404,8 +5412,10 @@ static void ui_check_but(uiBut *but) } - if(but->drawstr[0]) + if(but->drawstr[0]) { but->strwidth= but->aspect*BIF_GetStringWidth(but->font, but->drawstr, (U.transopts & TR_BUTTONS)); + // here should be check for less space for icon offsets... + } else but->strwidth= 0; @@ -5414,32 +5424,45 @@ static void ui_check_but(uiBut *but) but->x2= (but->x1+but->strwidth+6); } - /* calc but->ofs, to draw the string shorter if too long */ - but->ofs= 0; - while(but->strwidth > (int)(but->x2-but->x1-7) ) { - but->ofs++; - - if(but->drawstr[but->ofs]) - but->strwidth= but->aspect*BIF_GetStringWidth(but->font, but->drawstr+but->ofs, (U.transopts & TR_BUTTONS)); - else but->strwidth= 0; - - /* textbut exception */ - if(but->pos != -1) { - pos= but->pos+strlen(but->str); - if(pos-1 < but->ofs) { - pos= but->ofs-pos+1; - but->ofs -= pos; - if(but->ofs<0) { - but->ofs= 0; - pos--; + if(but->strwidth==0) but->drawstr[0]= 0; + else { + + /* calc but->ofs, to draw the string shorter if too long */ + but->ofs= 0; + while(but->strwidth > (int)(but->x2-but->x1-7) ) { + but->ofs++; + + if(but->drawstr[but->ofs]) + but->strwidth= but->aspect*BIF_GetStringWidth(but->font, but->drawstr+but->ofs, (U.transopts & TR_BUTTONS)); + else but->strwidth= 0; + + /* textbut exception */ + if(but->pos != -1) { + pos= but->pos+strlen(but->str); + if(pos-1 < but->ofs) { + pos= but->ofs-pos+1; + but->ofs -= pos; + if(but->ofs<0) { + but->ofs= 0; + pos--; + } + but->drawstr[ strlen(but->drawstr)-pos ]= 0; } - but->drawstr[ strlen(but->drawstr)-pos ]= 0; } + + if(but->strwidth < 10) break; } - if(but->strwidth < 10) break; + /* fix for buttons that better not have text cut off to the right */ + if(but->ofs) { + if ELEM4(but->type, NUM, TEX, NUMSLI, HSVSLI); // only these cut off right + else { + but->drawstr[ strlen(but->drawstr)-but->ofs ]= 0; + but->ofs= 0; + } + } } - + /* test for min and max, icon sliders, etc */ switch( but->type ) { @@ -5466,7 +5489,6 @@ static void ui_check_but(uiBut *but) case ICONTEXTROW: value= ui_get_but_val(but); - ui_set_name_menu(but, (int)value); but->iconadd= (int)value- (int)(but->min); break; } @@ -6058,35 +6080,56 @@ short pupmenu_col(char *instr, int maxrow) /* ofsx/ofsy only used for new panel definitions */ -void uiNewPanel(ScrArea *sa, uiBlock *block, char *panelname, char *tabname, int ofsx, int ofsy, int sizex, int sizey) +/* return 1 if visible (create buttons!) */ +int uiNewPanel(ScrArea *sa, uiBlock *block, char *panelname, char *tabname, int ofsx, int ofsy, int sizex, int sizey) { - Panel *pa; + Panel *pa, *palign; /* check if Panel exists, then use that one */ pa= sa->panels.first; while(pa) { if( strncmp(pa->panelname, panelname, UI_MAX_NAME_STR)==0) { if( strncmp(pa->tabname, tabname, UI_MAX_NAME_STR)==0) { - block->panel= pa; - return; + break; } } pa= pa->next; } - /* new panel */ - pa= MEM_callocN(sizeof(Panel), "new panel"); - BLI_addtail(&sa->panels, pa); - strncpy(pa->panelname, panelname, UI_MAX_NAME_STR); - strncpy(pa->tabname, tabname, UI_MAX_NAME_STR); - - pa->ofsx= ofsx & ~(PNL_GRID-1); - pa->ofsy= ofsy & ~(PNL_GRID-1); - pa->sizex= sizex; - pa->sizey= sizey; - + if(pa==NULL) { + + /* new panel */ + pa= MEM_callocN(sizeof(Panel), "new panel"); + BLI_addtail(&sa->panels, pa); + strncpy(pa->panelname, panelname, UI_MAX_NAME_STR); + strncpy(pa->tabname, tabname, UI_MAX_NAME_STR); + + pa->ofsx= ofsx & ~(PNL_GRID-1); + pa->ofsy= ofsy & ~(PNL_GRID-1); + pa->sizex= sizex; + pa->sizey= sizey; + + /* pre align, for good sorting later on */ + if(sa->spacetype==SPACE_BUTS && pa->prev) { + SpaceButs *sbuts= sa->spacedata.first; + + palign= pa->prev; + if(sbuts->align==BUT_VERTICAL) { + pa->ofsy= palign->ofsy - pa->sizey - PNL_HEADER; + } + else if(sbuts->align==BUT_HORIZONTAL) { + pa->ofsx= palign->ofsx + palign->sizex; + } + } + } + block->panel= pa; + pa->active= 1; + if(block->panel->paneltab) return 0; + if(block->panel->flag & PNL_CLOSED) return 0; + + return 1; } void uiFreePanels(ListBase *lb) @@ -6099,6 +6142,16 @@ void uiFreePanels(ListBase *lb) } } +void uiNewPanelHeight(uiBlock *block, int sizey) +{ + if(sizey<64) sizey= 64; + + if(block->panel) { + block->panel->ofsy+= (block->panel->sizey - sizey); + block->panel->sizey= sizey; + } +} + static int panel_has_tabs(Panel *panel) { Panel *pa= curarea->panels.first; @@ -6116,7 +6169,7 @@ void uiScalePanelBlock(uiBlock *block) { uiBut *but; float facx= 1.0, facy= 1.0; - int centrex= 0, tabsy; + int centrex= 0, topy=0, tabsy; if(block->panel==NULL) return; @@ -6129,16 +6182,17 @@ void uiScalePanelBlock(uiBlock *block) else centrex= (block->panel->sizex-( block->maxx-block->minx ) - PNL_SAFETY)/2; tabsy= PNL_HEADER*panel_has_tabs(block->panel); - if( block->maxy-block->miny > block->panel->sizey - 2*PNL_SAFETY - tabsy) { + if( (block->maxy-block->miny) > block->panel->sizey - 2*PNL_SAFETY - tabsy) { facy= (block->panel->sizey - (2*PNL_SAFETY) - tabsy)/( block->maxy-block->miny ); } + else topy= (block->panel->sizey- 2*PNL_SAFETY - tabsy) - ( block->maxy-block->miny ) ; but= block->buttons.first; while(but) { but->x1= PNL_SAFETY+centrex+ facx*(but->x1-block->minx); - but->y1= PNL_SAFETY+ facy*(but->y1-block->miny); + but->y1= PNL_SAFETY+topy + facy*(but->y1-block->miny); but->x2= PNL_SAFETY+centrex+ facx*(but->x2-block->minx); - but->y2= PNL_SAFETY+ facy*(but->y2-block->miny); + but->y2= PNL_SAFETY+topy + facy*(but->y2-block->miny); if(facx!=1.0) ui_check_but(but); /* for strlen */ but= but->next; } @@ -6153,40 +6207,32 @@ void uiSetPanel_view2d(ScrArea *sa) { Panel *pa; float minx=10000, maxx= -10000, miny=10000, maxy= -10000; - - if(sa->panels.first==NULL) return; + int done=0; pa= sa->panels.first; while(pa) { - if(pa->ofsx < minx) minx= pa->ofsx; - if(pa->ofsx+pa->sizex > maxx) maxx= pa->ofsx+pa->sizex; - if(pa->ofsy < miny) miny= pa->ofsy; - if(pa->ofsy+pa->sizey+PNL_HEADER > maxy) maxy= pa->ofsy+pa->sizey+PNL_HEADER; - + if(pa->active) { + done= 1; + if(pa->ofsx < minx) minx= pa->ofsx; + if(pa->ofsx+pa->sizex > maxx) maxx= pa->ofsx+pa->sizex; + if(pa->ofsy < miny) miny= pa->ofsy; + if(pa->ofsy+pa->sizey+PNL_HEADER > maxy) maxy= pa->ofsy+pa->sizey+PNL_HEADER; + } pa= pa->next; } - - G.v2d->tot.xmin= minx-PNL_DIST; - G.v2d->tot.xmax= maxx+PNL_DIST; - G.v2d->tot.ymin= miny-PNL_DIST; - G.v2d->tot.ymax= maxy+PNL_DIST; - - -} - -int uiIsPanelClosed(uiBlock *block) -{ - if(block->panel && block->panel->paneltab) { - /* needed for min max */ - uiBoundsBlock(block, 0); - return 1; + if(done) { + G.v2d->tot.xmin= minx-PNL_DIST; + G.v2d->tot.xmax= maxx+PNL_DIST; + G.v2d->tot.ymin= miny-PNL_DIST; + G.v2d->tot.ymax= maxy+PNL_DIST; } - else if(block->panel && (block->panel->flag & PNL_CLOSED)) { - /* draw does bounds too */ - uiDrawBlock(block); - return 1; + else { + G.v2d->tot.xmin= 0; + G.v2d->tot.xmax= 1280; + G.v2d->tot.ymin= 0; + G.v2d->tot.ymax= 228; } - return 0; + } static void ui_panel_push(uiBlock *block) @@ -6258,7 +6304,7 @@ static void ui_draw_panel_tabs(uiBlock *block) /* count */ pa= curarea->panels.first; while(pa) { - if(pa!=panel) { + if(pa->active) { if(pa->paneltab==panel) nr++; } pa= pa->next; @@ -6272,7 +6318,8 @@ static void ui_draw_panel_tabs(uiBlock *block) width= (panel->sizex - 2*PNL_SAFETY)/nr; pa= curarea->panels.first; while(pa) { - if(pa==panel) { + if(pa->active==0); + else if(pa==panel) { /* active tab */ uiSetRoundBox(12); glColor3ub(160, 160, 167); @@ -6407,137 +6454,121 @@ static int get_panel_real_ofsy(Panel *pa) else return pa->ofsy; } +typedef struct PanelSort { + Panel *pa, *orig; +} PanelSort; -static Panel *find_highest_panel(ListBase *lb) +static int find_leftmost_panel(const void *a1, const void *a2) { - Panel *pa, *patop=NULL; - int top= -100000, extra; + const PanelSort *ps1=a1, *ps2=a2; - pa= lb->first; - while(pa) { - /* sorting based at name to keep tabs in order too */ - extra= (pa->panelname[0]+pa->panelname[1] - 'A' - 'A')/4; - - if( pa->ofsy + pa->sizey + extra > top) { - top= pa->ofsy + pa->sizey+extra; - patop= pa; - } - pa= pa->next; - } - - return patop; + if( ps1->pa->ofsx > ps2->pa->ofsx) return 1; + else if( ps1->pa->ofsx < ps2->pa->ofsx) return -1; + else if( ps1->pa->next == ps2->pa) return -1; + else if( ((long)ps1->pa) < ((long)ps2->pa)) return -1; + else if( ((long)ps1->pa) > ((long)ps2->pa)) return 1; + + return 0; } -static Panel *find_leftmost_panel(ListBase *lb) + +static int find_highest_panel(const void *a1, const void *a2) { - Panel *pa, *paleft=NULL; - int left= 100000, extra; + const PanelSort *ps1=a1, *ps2=a2; - pa= lb->first; - while(pa) { - /* sorting based at name to keep tabs in order too */ - extra= (pa->panelname[0]+pa->panelname[1] - 'A' - 'A')/4; - - if( pa->ofsx + extra < left) { - left= pa->ofsx + extra; - paleft= pa; - } - pa= pa->next; - } - return paleft; - + if( ps1->pa->ofsy < ps2->pa->ofsy) return 1; + else if( ps1->pa->ofsy > ps2->pa->ofsy) return -1; + else if( ((long)ps1->pa) < ((long)ps2->pa)) return -1; + else if( ((long)ps1->pa) > ((long)ps2->pa)) return 1; + + return 0; } - -/* this also animates */ -static void ui_align_panel_step(ScrArea *sa, float fac) +/* this doesnt draw */ +/* returns 1 when it did something */ +int uiAlignPanelStep(ScrArea *sa, float fac) { SpaceButs *sbuts= sa->spacedata.first; - ListBase lb1= {NULL, NULL}; - Panel *pa, *panel, *next; - - /* find the desired positions of current panels first */ - /* sorting */ - while(sa->panels.first) { - if(sbuts->align==BUT_VERTICAL) - pa= find_highest_panel(&sa->panels); - else - pa= find_leftmost_panel(&sa->panels); - - if(pa==NULL) printf("panel sort error (crash!)\n"); - BLI_remlink(&sa->panels, pa); - BLI_addtail(&lb1, pa); + Panel *pa; + PanelSort *ps, *panelsort, *psnext; + int a, tot=0, done; + + if(sa->spacetype!=SPACE_BUTS) { + printf("align not supported yet here\n"); + return 0; + } + + /* count active, not tabbed Panels */ + for(pa= sa->panels.first; pa; pa= pa->next) { + if(pa->active && pa->paneltab==NULL) tot++; } - /* put back sorted */ - sa->panels = lb1; - /* make copy */ - duplicatelist(&lb1, &sa->panels); + if(tot==0) return 0; - /* now we fill in lb1 panels the desired location */ - pa= lb1.first; - /* but, we start with the first panel that's not a tab */ - while(pa) { - if(pa->paneltab==NULL) break; - pa= pa->next; + panelsort= MEM_callocN( tot*sizeof(PanelSort), "panelsort"); + + /* fill panelsort array */ + ps= panelsort; + for(pa= sa->panels.first; pa; pa= pa->next) { + if(pa->active && pa->paneltab==NULL) { + ps->pa= MEM_dupallocN(pa); + ps->orig= pa; + ps++; + } } + if(sbuts->align==BUT_VERTICAL) + qsort(panelsort, tot, sizeof(PanelSort), find_highest_panel); + else + qsort(panelsort, tot, sizeof(PanelSort), find_leftmost_panel); + + /* now we fill in copied panels the desired location */ /* default startloc current view2d topleft corner */ - pa->ofsx= sbuts->v2d.tot.xmin+PNL_DIST; - pa->ofsy= sbuts->v2d.tot.ymax-PNL_DIST- pa->sizey-PNL_HEADER; - - if(sbuts->align==BUT_VERTICAL) { - next= pa->next; - while(next) { - if(next->paneltab==NULL) { - next->ofsx = pa->ofsx; - next->ofsy = get_panel_real_ofsy(pa) - pa->sizey-PNL_HEADER-PNL_DIST; - pa= next; - } - next= next->next; + ps= panelsort; + ps->pa->ofsx= sbuts->v2d.tot.xmin; + ps->pa->ofsy= sbuts->v2d.tot.ymax- ps->pa->sizey-PNL_HEADER; + for(a=0 ; aalign==BUT_VERTICAL) { + psnext->pa->ofsx = ps->pa->ofsx; + psnext->pa->ofsy = get_panel_real_ofsy(ps->pa) - ps->pa->sizey-PNL_HEADER-PNL_DIST; } - } - else { - next= pa->next; - while(next) { - if(next->paneltab==NULL) { - next->ofsx = pa->ofsx + pa->sizex+PNL_DIST; - next->ofsy = pa->ofsy; - pa= next; - } - next= next->next; + else { + psnext->pa->ofsx = ps->pa->ofsx + ps->pa->sizex+PNL_DIST; + psnext->pa->ofsy = ps->pa->ofsy; } } /* we interpolate */ - panel= sa->panels.first; - pa= lb1.first; - while(panel && pa) { - - if( (panel->flag & PNL_SELECT)==0) { - panel->ofsx= floor(0.5 + fac*pa->ofsx + (1.0-fac)*panel->ofsx); - panel->ofsy= floor(0.5 + fac*pa->ofsy + (1.0-fac)*panel->ofsy); + done= 0; + ps= panelsort; + for(a=0; apa->flag & PNL_SELECT)==0) { + if( (ps->orig->ofsx != ps->pa->ofsx) || (ps->orig->ofsy != ps->pa->ofsy)) { + ps->orig->ofsx= floor(0.5 + fac*ps->pa->ofsx + (1.0-fac)*ps->orig->ofsx); + ps->orig->ofsy= floor(0.5 + fac*ps->pa->ofsy + (1.0-fac)*ps->orig->ofsy); + done= 1; + } } - panel= panel->next; - pa= pa->next; } - - BLI_freelistN(&lb1); - + /* copy locations to tabs */ - panel= sa->panels.first; - while(panel) { - if(panel->paneltab) { - panel->ofsx= panel->paneltab->ofsx; - panel->ofsy= panel->paneltab->ofsy; + for(pa= sa->panels.first; pa; pa= pa->next) { + if(pa->paneltab && pa->active) { + pa->ofsx= pa->paneltab->ofsx; + pa->ofsy= pa->paneltab->ofsy; } - panel= panel->next; } + + /* free panelsort array */ + ps= panelsort; + for(a=0; apa); + } + MEM_freeN(panelsort); - /* warn: this re-allocs uiblocks! */ - scrarea_do_windraw(curarea); - ui_redraw_select_panel(curarea); - screen_swapbuffers(); + return done; } @@ -6551,7 +6582,17 @@ void uiAnimatePanels(ScrArea *sa) /* for max 1 second, interpolate positions */ while(TRUE) { - ui_align_panel_step(sa, fac); + if( uiAlignPanelStep(sa, fac) ) { + /* warn: this re-allocs uiblocks! */ + scrarea_do_windraw(curarea); + ui_redraw_select_panel(curarea); + screen_swapbuffers(); + } + else { + addqueue(curarea->win, REDRAW,1 ); // because 'Animate' is also called as redraw + break; + } + if(result >= 1.0) break; if(result==0.0) { // firsttime @@ -6571,6 +6612,58 @@ void uiAnimatePanels(ScrArea *sa) } } +/* only draws blocks with panels */ +void uiDrawBlocksPanels(ScrArea *sa, int re_align) +{ + uiBlock *block; + Panel *panot, *panew, *patest; + + /* scaling contents */ + block= sa->uiblocks.first; + while(block) { + if(block->panel) uiScalePanelBlock(block); + block= block->next; + } + + /* consistancy; are panels not made, whilst they have tabs */ + for(panot= sa->panels.first; panot; panot= panot->next) { + if(panot->active==0) { // not made + + for(panew= sa->panels.first; panew; panew= panew->next) { + if(panew->active) { + if(panew->paneltab==panot) { // panew is tab in notmade pa + break; + } + } + } + /* now panew can become the new parent, check all other tabs */ + if(panew) { + for(patest= sa->panels.first; patest; patest= patest->next) { + if(patest->paneltab == panot) { + patest->paneltab= panew; + } + } + panot->paneltab= panew; + panew->paneltab= NULL; + addqueue(sa->win, REDRAW, 1); // the buttons panew were not made + } + } + } + + /* re-align */ + if(re_align) uiAlignPanelStep(sa, 1.0); + + /* draw */ + block= sa->uiblocks.first; + while(block) { + if(block->panel) uiDrawBlock(block); + block= block->next; + } + +} + + + /* ------------ panel merging ---------------- */ static void check_panel_overlap(ScrArea *sa, Panel *panel) @@ -6582,7 +6675,7 @@ static void check_panel_overlap(ScrArea *sa, Panel *panel) while(pa) { pa->flag &= ~PNL_OVERLAP; if(panel && (pa != panel)) { - if(pa->paneltab==NULL) { + if(pa->paneltab==NULL && pa->active) { float safe= 0.2; if(pa->flag & PNL_CLOSED) safe= 0.05; @@ -6606,8 +6699,10 @@ static void test_add_new_tabs(ScrArea *sa) pa= sa->panels.first; while(pa) { - if(pa->flag & PNL_SELECT) pasel= pa; - if(pa->flag & PNL_OVERLAP) palap= pa; + if(pa->active) { + if(pa->flag & PNL_SELECT) pasel= pa; + if(pa->flag & PNL_OVERLAP) palap= pa; + } pa= pa->next; } @@ -6661,6 +6756,11 @@ static void ui_drag_panel(uiBlock *block) Panel *panel= block->panel; short first=1, ofsx, ofsy, dx, dy, dxo=0, dyo=0, mval[2], mvalo[2]; + if(curarea->spacetype!=SPACE_BUTS) { + printf("align not supported yet here\n"); + return; + } + uiGetMouse(block->win, mvalo); ofsx= block->panel->ofsx; ofsy= block->panel->ofsy; @@ -6671,10 +6771,14 @@ static void ui_drag_panel(uiBlock *block) if( !(get_mbut() & L_MOUSE) ) break; - uiGetMouse(mywinget(), mval); - dx= (mval[0]-mvalo[0]) & ~(PNL_GRID-1); - dy= (mval[1]-mvalo[1]) & ~(PNL_GRID-1); - + /* first clip for window, no dragging outside */ + getmouseco_areawin(mval); + if( mval[0]>0 && mval[0]winx && mval[1]>0 && mval[1]winy) { + uiGetMouse(mywinget(), mval); + dx= (mval[0]-mvalo[0]) & ~(PNL_GRID-1); + dy= (mval[1]-mvalo[1]) & ~(PNL_GRID-1); + } + if(dx!=dxo || dy!=dyo || first) { dxo= dx; dyo= dy; first= 0; @@ -6684,13 +6788,12 @@ static void ui_drag_panel(uiBlock *block) check_panel_overlap(curarea, panel); + if(sbuts->align) uiAlignPanelStep(curarea, 0.2); + /* warn: this re-allocs blocks! */ - if(sbuts->align==0) { - scrarea_do_windraw(curarea); - ui_redraw_select_panel(curarea); - screen_swapbuffers(); - } - else ui_align_panel_step(curarea, 0.2); + scrarea_do_windraw(curarea); + ui_redraw_select_panel(curarea); + screen_swapbuffers(); /* so, we find the new block */ block= curarea->uiblocks.first; @@ -6831,8 +6934,13 @@ static void ui_do_panel(uiBlock *block, uiEvent *uevent) SpaceButs *sbuts= curarea->spacedata.first; Panel *pa; + if(curarea->spacetype!=SPACE_BUTS) { + printf("align not supported yet here\n"); + return; + } + /* mouse coordinates in panel space! */ - + if(uevent->event==LEFTMOUSE && block->panel->paneltab==NULL) { /* check if clicked in tabbed area */ diff --git a/source/blender/src/previewrender.c b/source/blender/src/previewrender.c index b6c4d68b406..4195b33a8e5 100644 --- a/source/blender/src/previewrender.c +++ b/source/blender/src/previewrender.c @@ -76,6 +76,7 @@ #include "BIF_gl.h" #include "BIF_screen.h" #include "BIF_space.h" /* allqueue */ +#include "BIF_butspace.h" #include "BIF_drawimage.h" /* rectwrite_part */ #include "BIF_mywindow.h" #include "PIL_time.h" diff --git a/source/blender/src/space.c b/source/blender/src/space.c index f2a3436c249..4e37b3a9758 100644 --- a/source/blender/src/space.c +++ b/source/blender/src/space.c @@ -2168,11 +2168,23 @@ void extern_set_butspace(int fkey) sbuts= sa->spacedata.first; - if(fkey==F4KEY) sbuts->mainb= CONTEXT_LOGIC; - else if(fkey==F5KEY) sbuts->mainb= CONTEXT_SHADING; - else if(fkey==F6KEY) sbuts->mainb= CONTEXT_SCRIPT; - else if(fkey==F7KEY) sbuts->mainb= CONTEXT_TYPES; - else if(fkey==F8KEY) sbuts->mainb= CONTEXT_OBJECT; + if(fkey==F4KEY) { + sbuts->mainb= CONTEXT_SHADING; + sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_LAMP; + } + else if(fkey==F5KEY) { + sbuts->mainb= CONTEXT_SHADING; + sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_MAT; + } + else if(fkey==F6KEY) { + sbuts->mainb= CONTEXT_SHADING; + sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_TEX; + } + else if(fkey==F7KEY) sbuts->mainb= CONTEXT_OBJECT; + else if(fkey==F8KEY) { + sbuts->mainb= CONTEXT_SHADING; + sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_WORLD; + } else if(fkey==F9KEY) sbuts->mainb= CONTEXT_EDITING; else if(fkey==F10KEY) sbuts->mainb= CONTEXT_SCENE; @@ -3169,6 +3181,8 @@ void allqueue(unsigned short event, short val) case REDRAWBUTSALL: if(sa->spacetype==SPACE_BUTS) { + buts= sa->spacedata.first; + buts->re_align= 1; scrarea_queue_winredraw(sa); scrarea_queue_headredraw(sa); } @@ -3182,6 +3196,7 @@ void allqueue(unsigned short event, short val) if(sa->spacetype==SPACE_BUTS) { buts= sa->spacedata.first; if(buts->mainb==CONTEXT_SCENE) { + buts->re_align= 1; scrarea_queue_winredraw(sa); scrarea_queue_headredraw(sa); } @@ -3191,15 +3206,7 @@ void allqueue(unsigned short event, short val) if(sa->spacetype==SPACE_BUTS) { buts= sa->spacedata.first; if(buts->mainb==CONTEXT_OBJECT) { - scrarea_queue_winredraw(sa); - scrarea_queue_headredraw(sa); - } - } - break; - case REDRAWBUTSTYPES: - if(sa->spacetype==SPACE_BUTS) { - buts= sa->spacedata.first; - if(buts->mainb==CONTEXT_TYPES) { + buts->re_align= 1; scrarea_queue_winredraw(sa); scrarea_queue_headredraw(sa); } @@ -3209,6 +3216,7 @@ void allqueue(unsigned short event, short val) if(sa->spacetype==SPACE_BUTS) { buts= sa->spacedata.first; if(buts->mainb==CONTEXT_SHADING) { + buts->re_align= 1; scrarea_queue_winredraw(sa); scrarea_queue_headredraw(sa); } @@ -3218,6 +3226,7 @@ void allqueue(unsigned short event, short val) if(sa->spacetype==SPACE_BUTS) { buts= sa->spacedata.first; if(buts->mainb==CONTEXT_EDITING) { + buts->re_align= 1; scrarea_queue_winredraw(sa); scrarea_queue_headredraw(sa); } @@ -3227,6 +3236,7 @@ void allqueue(unsigned short event, short val) if(sa->spacetype==SPACE_BUTS) { buts= sa->spacedata.first; if(buts->mainb==CONTEXT_SCRIPT) { + buts->re_align= 1; scrarea_queue_winredraw(sa); scrarea_queue_headredraw(sa); } @@ -3244,7 +3254,8 @@ void allqueue(unsigned short event, short val) case REDRAWBUTSLAMP: if(sa->spacetype==SPACE_BUTS) { buts= sa->spacedata.first; - if(buts->mainb==CONTEXT_SHADING || buts->mainb==CONTEXT_TYPES) { + if(buts->mainb==CONTEXT_SHADING) { + buts->re_align= 1; scrarea_queue_winredraw(sa); scrarea_queue_headredraw(sa); } -- cgit v1.2.3