Small tweaks to make 3d drawing a tad more interactive, and; something

for our interactive 3d artists!

- AL+Z (potato) texture view now draws objects without Texture Faces
  compliant with (new) default in engine. Meaning lit faces, using
  Material RGB for diffuse and specular. It used to draw these as 'shaded'
  which is quite useless.
  Per definition, Potato mode is supposed to show what engine draws.
  (Note; this only for Mesh objects)

- Added a couple of more calls to ensure Shaded drawmode updates on
  changing RGB sliders, moving lamps to layers, or switch layers

This based on feedback from Mal, who'll also give it all good tests.
This commit is contained in:
2004-11-25 21:52:07 +00:00
parent 806ebc7c7a
commit 4ef448cc51
5 changed files with 214 additions and 129 deletions

View File

@@ -160,7 +160,24 @@ static void shade_buttons_change_3d(void)
if(v3d->drawtype >= OB_SOLID) addqueue(sa->win, REDRAW, 0); if(v3d->drawtype >= OB_SOLID) addqueue(sa->win, REDRAW, 0);
if(v3d->drawtype == OB_SHADED) { if(v3d->drawtype == OB_SHADED) {
if(ob->type==OB_LAMP) reshadeall_displist(); if(ob->type==OB_LAMP) reshadeall_displist();
else freedisplist(&ob->disp); else {
/* all objects using material */
Base *base= FIRSTBASE;
Material *ma= give_current_material(ob, ob->actcol);
int a;
while(base) {
if(base->lay & G.vd->lay) {
for(a=1; a<=ob->totcol; a++) {
if(ma == give_current_material(base->object, a)) {
freedisplist(&(base->object->disp));
break;
}
}
}
base= base->next;
}
}
} }
} }
} }

View File

@@ -864,7 +864,7 @@ void draw_tface_mesh(Object *ob, Mesh *me, int dt)
int a, mode; int a, mode;
short islight, istex; short islight, istex;
if (!me || !me->tface) return; if(me==NULL) return;
glShadeModel(GL_SMOOTH); glShadeModel(GL_SMOOTH);
@@ -913,151 +913,211 @@ void draw_tface_mesh(Object *ob, Mesh *me, int dt)
mface= me->mface; mface= me->mface;
tface= me->tface; tface= me->tface;
} }
// tface can be NULL // tface can be NULL
if(tface==NULL) return; if(tface==NULL) {
for (a=0; a<totface; a++, tface++) {
int v1idx, v2idx, v3idx, v4idx, mf_smooth, matnr, badtex;
float *v1, *v2, *v3, *v4;
MFace *mf= &mface[a];
v1idx= mf->v1;
v2idx= mf->v2;
v3idx= mf->v3;
v4idx= mf->v4;
mf_smooth= mf->flag & ME_SMOOTH;
matnr= mf->mat_nr;
if(v3idx==0) continue; for (a=0; a<totface; a++) {
if(tface->flag & TF_HIDE) continue; int v1idx, v2idx, v3idx, v4idx, mf_smooth, matnr;
if(tface->mode & TF_INVISIBLE) continue; float *v1, *v2, *v3, *v4;
MFace *mf= &mface[a];
mode= tface->mode;
if (extverts) {
v1= extverts+3*v1idx;
v2= extverts+3*v2idx;
v3= extverts+3*v3idx;
v4= v4idx?(extverts+3*v4idx):NULL;
} else {
v1= (mvert+v1idx)->co;
v2= (mvert+v2idx)->co;
v3= (mvert+v3idx)->co;
v4= v4idx?(mvert+v4idx)->co:NULL;
}
badtex= set_draw_settings_cached(0, istex && (mode&TF_TEX), tface, islight && (mode&TF_LIGHT), ob, matnr, mode&TF_TWOSIDE);
if (prop && !badtex && !editing && (mode & TF_BMFONT)) {
char string[MAX_PROPSTRING];
int characters, index;
Image *ima;
float curpos;
// The BM_FONT handling code is duplicated in the gameengine
// Search for 'Frank van Beek' ;-)
// string = "Frank van Beek";
set_property_valstr(prop, string);
characters = strlen(string);
ima = tface->tpage; v1idx= mf->v1;
if (ima == NULL) { v2idx= mf->v2;
characters = 0; v3idx= mf->v3;
v4idx= mf->v4;
mf_smooth= mf->flag & ME_SMOOTH;
matnr= mf->mat_nr;
if(v3idx==0) continue;
set_draw_settings_cached(0, 0, NULL, 1, ob, matnr, TF_TWOSIDE);
if (extverts) {
v1= extverts+3*v1idx;
v2= extverts+3*v2idx;
v3= extverts+3*v3idx;
v4= v4idx?(extverts+3*v4idx):NULL;
} else {
v1= (mvert+v1idx)->co;
v2= (mvert+v2idx)->co;
v3= (mvert+v3idx)->co;
v4= v4idx?(mvert+v4idx)->co:NULL;
} }
if (1 || !mf_smooth) { {
float nor[3]; Material *ma= give_current_material(ob, matnr);
if(ma) glColor3f(ma->r, ma->g, ma->b);
CalcNormFloat(v1, v2, v3, nor); else glColor3f(0.5, 0.5, 0.5);
glNormal3fv(nor);
} }
curpos= 0.0;
glBegin(v4?GL_QUADS:GL_TRIANGLES); glBegin(v4?GL_QUADS:GL_TRIANGLES);
for (index = 0; index < characters; index++) {
float centerx, centery, sizex, sizey, transx, transy, movex, movey, advance;
int character = string[index];
char *cp= NULL;
// lets calculate offset stuff
// space starts at offset 1
// character = character - ' ' + 1;
matrixGlyph(ima->ibuf, character, & centerx, &centery, &sizex, &sizey, &transx, &transy, &movex, &movey, &advance);
movex+= curpos;
if (mode & TF_OBCOL) glColor3ubv(obcol);
else cp= (char *)&(tface->col[0]);
glTexCoord2f((tface->uv[0][0] - centerx) * sizex + transx, (tface->uv[0][1] - centery) * sizey + transy);
if (cp) glColor3ub(cp[3], cp[2], cp[1]);
glVertex3f(sizex * v1[0] + movex, sizey * v1[1] + movey, v1[2]);
glTexCoord2f((tface->uv[1][0] - centerx) * sizex + transx, (tface->uv[1][1] - centery) * sizey + transy);
if (cp) glColor3ub(cp[7], cp[6], cp[5]);
glVertex3f(sizex * v2[0] + movex, sizey * v2[1] + movey, v2[2]);
glTexCoord2f((tface->uv[2][0] - centerx) * sizex + transx, (tface->uv[2][1] - centery) * sizey + transy);
if (cp) glColor3ub(cp[11], cp[10], cp[9]);
glVertex3f(sizex * v3[0] + movex, sizey * v3[1] + movey, v3[2]);
if(v4) {
glTexCoord2f((tface->uv[3][0] - centerx) * sizex + transx, (tface->uv[3][1] - centery) * sizey + transy);
if (cp) glColor3ub(cp[15], cp[14], cp[13]);
glVertex3f(sizex * v4[0] + movex, sizey * v4[1] + movey, v4[2]);
}
curpos+= advance;
}
glEnd();
}
else {
char *cp= NULL;
if (badtex) glColor3ub(0xFF, 0x00, 0xFF);
else if (mode & TF_OBCOL) glColor3ubv(obcol);
else cp= (char *)&(tface->col[0]);
if (!mf_smooth) { if (!mf_smooth) {
float nor[3]; float nor[3];
CalcNormFloat(v1, v2, v3, nor); CalcNormFloat(v1, v2, v3, nor);
glNormal3fv(nor); glNormal3fv(nor);
} }
glBegin(v4?GL_QUADS:GL_TRIANGLES);
glTexCoord2fv(tface->uv[0]);
if (cp) glColor3ub(cp[3], cp[2], cp[1]);
if (mf_smooth) glNormal3sv(mvert[v1idx].no); if (mf_smooth) glNormal3sv(mvert[v1idx].no);
glVertex3fv(v1); glVertex3fv(v1);
glTexCoord2fv(tface->uv[1]);
if (cp) glColor3ub(cp[7], cp[6], cp[5]);
if (mf_smooth) glNormal3sv(mvert[v2idx].no); if (mf_smooth) glNormal3sv(mvert[v2idx].no);
glVertex3fv(v2); glVertex3fv(v2);
glTexCoord2fv(tface->uv[2]);
if (cp) glColor3ub(cp[11], cp[10], cp[9]);
if (mf_smooth) glNormal3sv(mvert[v3idx].no); if (mf_smooth) glNormal3sv(mvert[v3idx].no);
glVertex3fv(v3); glVertex3fv(v3);
if(v4) { if(v4) {
glTexCoord2fv(tface->uv[3]);
if (cp) glColor3ub(cp[15], cp[14], cp[13]);
if (mf_smooth) glNormal3sv(mvert[v4idx].no); if (mf_smooth) glNormal3sv(mvert[v4idx].no);
glVertex3fv(v4); glVertex3fv(v4);
} }
glEnd(); glEnd();
} }
} }
else { // has tfaces
for (a=0; a<totface; a++, tface++) {
int v1idx, v2idx, v3idx, v4idx, mf_smooth, matnr, badtex;
float *v1, *v2, *v3, *v4;
MFace *mf= &mface[a];
/* switch off textures */ v1idx= mf->v1;
set_tpage(0); v2idx= mf->v2;
v3idx= mf->v3;
v4idx= mf->v4;
mf_smooth= mf->flag & ME_SMOOTH;
matnr= mf->mat_nr;
if(v3idx==0) continue;
if(tface->flag & TF_HIDE) continue;
if(tface->mode & TF_INVISIBLE) continue;
mode= tface->mode;
if (extverts) {
v1= extverts+3*v1idx;
v2= extverts+3*v2idx;
v3= extverts+3*v3idx;
v4= v4idx?(extverts+3*v4idx):NULL;
} else {
v1= (mvert+v1idx)->co;
v2= (mvert+v2idx)->co;
v3= (mvert+v3idx)->co;
v4= v4idx?(mvert+v4idx)->co:NULL;
}
badtex= set_draw_settings_cached(0, istex && (mode&TF_TEX), tface, islight && (mode&TF_LIGHT), ob, matnr, mode&TF_TWOSIDE);
if (prop && !badtex && !editing && (mode & TF_BMFONT)) {
char string[MAX_PROPSTRING];
int characters, index;
Image *ima;
float curpos;
// The BM_FONT handling code is duplicated in the gameengine
// Search for 'Frank van Beek' ;-)
// string = "Frank van Beek";
set_property_valstr(prop, string);
characters = strlen(string);
ima = tface->tpage;
if (ima == NULL) {
characters = 0;
}
if (1 || !mf_smooth) {
float nor[3];
CalcNormFloat(v1, v2, v3, nor);
glNormal3fv(nor);
}
curpos= 0.0;
glBegin(v4?GL_QUADS:GL_TRIANGLES);
for (index = 0; index < characters; index++) {
float centerx, centery, sizex, sizey, transx, transy, movex, movey, advance;
int character = string[index];
char *cp= NULL;
// lets calculate offset stuff
// space starts at offset 1
// character = character - ' ' + 1;
matrixGlyph(ima->ibuf, character, & centerx, &centery, &sizex, &sizey, &transx, &transy, &movex, &movey, &advance);
movex+= curpos;
if (mode & TF_OBCOL) glColor3ubv(obcol);
else cp= (char *)&(tface->col[0]);
glTexCoord2f((tface->uv[0][0] - centerx) * sizex + transx, (tface->uv[0][1] - centery) * sizey + transy);
if (cp) glColor3ub(cp[3], cp[2], cp[1]);
glVertex3f(sizex * v1[0] + movex, sizey * v1[1] + movey, v1[2]);
glTexCoord2f((tface->uv[1][0] - centerx) * sizex + transx, (tface->uv[1][1] - centery) * sizey + transy);
if (cp) glColor3ub(cp[7], cp[6], cp[5]);
glVertex3f(sizex * v2[0] + movex, sizey * v2[1] + movey, v2[2]);
glTexCoord2f((tface->uv[2][0] - centerx) * sizex + transx, (tface->uv[2][1] - centery) * sizey + transy);
if (cp) glColor3ub(cp[11], cp[10], cp[9]);
glVertex3f(sizex * v3[0] + movex, sizey * v3[1] + movey, v3[2]);
if(v4) {
glTexCoord2f((tface->uv[3][0] - centerx) * sizex + transx, (tface->uv[3][1] - centery) * sizey + transy);
if (cp) glColor3ub(cp[15], cp[14], cp[13]);
glVertex3f(sizex * v4[0] + movex, sizey * v4[1] + movey, v4[2]);
}
curpos+= advance;
}
glEnd();
}
else {
char *cp= NULL;
if (badtex) glColor3ub(0xFF, 0x00, 0xFF);
else if (mode & TF_OBCOL) glColor3ubv(obcol);
else cp= (char *)&(tface->col[0]);
if (!mf_smooth) {
float nor[3];
CalcNormFloat(v1, v2, v3, nor);
glNormal3fv(nor);
}
glBegin(v4?GL_QUADS:GL_TRIANGLES);
glTexCoord2fv(tface->uv[0]);
if (cp) glColor3ub(cp[3], cp[2], cp[1]);
if (mf_smooth) glNormal3sv(mvert[v1idx].no);
glVertex3fv(v1);
glTexCoord2fv(tface->uv[1]);
if (cp) glColor3ub(cp[7], cp[6], cp[5]);
if (mf_smooth) glNormal3sv(mvert[v2idx].no);
glVertex3fv(v2);
glTexCoord2fv(tface->uv[2]);
if (cp) glColor3ub(cp[11], cp[10], cp[9]);
if (mf_smooth) glNormal3sv(mvert[v3idx].no);
glVertex3fv(v3);
if(v4) {
glTexCoord2fv(tface->uv[3]);
if (cp) glColor3ub(cp[15], cp[14], cp[13]);
if (mf_smooth) glNormal3sv(mvert[v4idx].no);
glVertex3fv(v4);
}
glEnd();
}
}
/* switch off textures */
set_tpage(0);
}
} }
glShadeModel(GL_FLAT); glShadeModel(GL_FLAT);
glDisable(GL_CULL_FACE); glDisable(GL_CULL_FACE);

View File

@@ -4237,11 +4237,8 @@ void draw_object(Base *base)
else if(dt==OB_BOUNDBOX) draw_bounding_volume(ob); else if(dt==OB_BOUNDBOX) draw_bounding_volume(ob);
else if(dt==OB_WIRE || me->totface==0) drawmeshwire(ob); else if(dt==OB_WIRE || me->totface==0) drawmeshwire(ob);
else if(ma && (ma->mode & MA_HALO)) drawmeshwire(ob); else if(ma && (ma->mode & MA_HALO)) drawmeshwire(ob);
else if(me->tface) { else if(G.f & G_FACESELECT || G.vd->drawtype==OB_TEXTURE) {
if(G.f & G_FACESELECT || G.vd->drawtype==OB_TEXTURE) { draw_tface_mesh(ob, ob->data, dt);
draw_tface_mesh(ob, ob->data, dt);
}
else drawDispList(ob, dt);
} }
else drawDispList(ob, dt); else drawDispList(ob, dt);
} }

View File

@@ -200,7 +200,10 @@ void add_object_draw(int type) /* for toolbox or menus, only non-editmode stuff
base_init_from_view3d(BASACT, G.vd); base_init_from_view3d(BASACT, G.vd);
if(type==OB_EMPTY) BIF_undo_push("Add Empty"); if(type==OB_EMPTY) BIF_undo_push("Add Empty");
else if(type==OB_LAMP) BIF_undo_push("Add Lamp"); else if(type==OB_LAMP) {
BIF_undo_push("Add Lamp");
if(G.vd->drawtype == OB_SHADED) reshadeall_displist();
}
else if(type==OB_LATTICE) BIF_undo_push("Add Lattice"); else if(type==OB_LATTICE) BIF_undo_push("Add Lattice");
else BIF_undo_push("Add Camera"); else BIF_undo_push("Add Camera");
@@ -247,6 +250,7 @@ void free_and_unlink_base(Base *base)
void delete_obj(int ok) void delete_obj(int ok)
{ {
Base *base; Base *base;
int islamp= 0;
if(G.obpose) return; if(G.obpose) return;
if(G.obedit) return; if(G.obedit) return;
@@ -258,6 +262,7 @@ void delete_obj(int ok)
if TESTBASE(base) { if TESTBASE(base) {
if(ok==0 && (ok=okee("Erase selected"))==0) return; if(ok==0 && (ok=okee("Erase selected"))==0) return;
if(base->object->type==OB_LAMP) islamp= 1;
free_and_unlink_base(base); free_and_unlink_base(base);
} }
@@ -269,6 +274,8 @@ void delete_obj(int ok)
G.f &= ~(G_VERTEXPAINT+G_FACESELECT+G_TEXTUREPAINT+G_WEIGHTPAINT); G.f &= ~(G_VERTEXPAINT+G_FACESELECT+G_TEXTUREPAINT+G_WEIGHTPAINT);
setcursor_space(SPACE_VIEW3D, CURSOR_STD); setcursor_space(SPACE_VIEW3D, CURSOR_STD);
if(islamp && G.vd->drawtype==OB_SHADED) reshadeall_displist();
test_scene_constraints(); test_scene_constraints();
allqueue(REDRAWVIEW3D, 0); allqueue(REDRAWVIEW3D, 0);
redraw_test_buttons(OBACT); redraw_test_buttons(OBACT);
@@ -1832,7 +1839,8 @@ void movetolayer(void)
{ {
Base *base; Base *base;
unsigned int lay= 0, local; unsigned int lay= 0, local;
int islamp= 0;
if(G.scene->id.lib) return; if(G.scene->id.lib) return;
base= FIRSTBASE; base= FIRSTBASE;
@@ -1852,11 +1860,14 @@ void movetolayer(void)
/* upper byte is used for local view */ /* upper byte is used for local view */
local= base->lay & 0xFF000000; local= base->lay & 0xFF000000;
base->lay= lay + local; base->lay= lay + local;
base->object->lay= lay; base->object->lay= lay;
if(base->object->type==OB_LAMP) islamp= 1;
} }
base= base->next; base= base->next;
} }
if(islamp && G.vd->drawtype == OB_SHADED) reshadeall_displist();
countall(); countall();
allqueue(REDRAWBUTSEDIT, 0); allqueue(REDRAWBUTSEDIT, 0);
allqueue(REDRAWVIEW3D, 0); allqueue(REDRAWVIEW3D, 0);

View File

@@ -176,7 +176,7 @@ void do_layer_buttons(short event)
scrarea_queue_headredraw(curarea); scrarea_queue_headredraw(curarea);
if(curarea->spacetype==SPACE_OOPS) allqueue(REDRAWVIEW3D, 1); /* 1==also do headwin */ if(curarea->spacetype==SPACE_OOPS) allqueue(REDRAWVIEW3D, 1); /* 1==also do headwin */
if(G.vd->drawtype == OB_SHADED) reshadeall_displist();
} }
static void do_view3d_view_cameracontrolsmenu(void *arg, int event) static void do_view3d_view_cameracontrolsmenu(void *arg, int event)