Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2004-11-26 00:52:07 +0300
committerTon Roosendaal <ton@blender.org>2004-11-26 00:52:07 +0300
commit4ef448cc51cb0a51ae1301c926e0cfe5770faac3 (patch)
tree905490503af00278ac55a004a3bd0e09f06d7701 /source/blender/src/drawmesh.c
parent806ebc7c7a9b897794184dfbcedde7bffe691e9d (diff)
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.
Diffstat (limited to 'source/blender/src/drawmesh.c')
-rw-r--r--source/blender/src/drawmesh.c294
1 files changed, 177 insertions, 117 deletions
diff --git a/source/blender/src/drawmesh.c b/source/blender/src/drawmesh.c
index c3d9ce0fdf4..538de071b85 100644
--- a/source/blender/src/drawmesh.c
+++ b/source/blender/src/drawmesh.c
@@ -864,7 +864,7 @@ void draw_tface_mesh(Object *ob, Mesh *me, int dt)
int a, mode;
short islight, istex;
- if (!me || !me->tface) return;
+ if(me==NULL) return;
glShadeModel(GL_SMOOTH);
@@ -913,151 +913,211 @@ void draw_tface_mesh(Object *ob, Mesh *me, int dt)
mface= me->mface;
tface= me->tface;
}
- // tface can be NULL
- if(tface==NULL) return;
- 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;
- if(tface->flag & TF_HIDE) continue;
- if(tface->mode & TF_INVISIBLE) continue;
+ // tface can be NULL
+ if(tface==NULL) {
- mode= tface->mode;
+ for (a=0; a<totface; a++) {
+ int v1idx, v2idx, v3idx, v4idx, mf_smooth, matnr;
+ 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;
- 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;
+ 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;
+ }
+
+ {
+ Material *ma= give_current_material(ob, matnr);
+ if(ma) glColor3f(ma->r, ma->g, ma->b);
+ else glColor3f(0.5, 0.5, 0.5);
+ }
+
+ glBegin(v4?GL_QUADS:GL_TRIANGLES);
+
+ if (!mf_smooth) {
+ float nor[3];
+ CalcNormFloat(v1, v2, v3, nor);
+ glNormal3fv(nor);
+ }
+
+ if (mf_smooth) glNormal3sv(mvert[v1idx].no);
+ glVertex3fv(v1);
+
+ if (mf_smooth) glNormal3sv(mvert[v2idx].no);
+ glVertex3fv(v2);
+
+ if (mf_smooth) glNormal3sv(mvert[v3idx].no);
+ glVertex3fv(v3);
+
+ if(v4) {
+ if (mf_smooth) glNormal3sv(mvert[v4idx].no);
+ glVertex3fv(v4);
+ }
+ 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];
+
+ 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;
+ if(tface->flag & TF_HIDE) continue;
+ if(tface->mode & TF_INVISIBLE) continue;
+
+ mode= tface->mode;
- badtex= set_draw_settings_cached(0, istex && (mode&TF_TEX), tface, islight && (mode&TF_LIGHT), ob, matnr, mode&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 (prop && !badtex && !editing && (mode & TF_BMFONT)) {
- char string[MAX_PROPSTRING];
- int characters, index;
- Image *ima;
- float curpos;
+ badtex= set_draw_settings_cached(0, istex && (mode&TF_TEX), tface, islight && (mode&TF_LIGHT), ob, matnr, mode&TF_TWOSIDE);
- // The BM_FONT handling code is duplicated in the gameengine
- // Search for 'Frank van Beek' ;-)
+ if (prop && !badtex && !editing && (mode & TF_BMFONT)) {
+ char string[MAX_PROPSTRING];
+ int characters, index;
+ Image *ima;
+ float curpos;
- // string = "Frank van Beek";
+ // 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;
- }
+ set_property_valstr(prop, string);
+ characters = strlen(string);
+
+ ima = tface->tpage;
+ if (ima == NULL) {
+ characters = 0;
+ }
- if (1 || !mf_smooth) {
- float nor[3];
+ if (1 || !mf_smooth) {
+ float nor[3];
- CalcNormFloat(v1, v2, v3, nor);
+ CalcNormFloat(v1, v2, v3, nor);
- glNormal3fv(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;
+ 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;
+ // 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]);
- if (mode & TF_OBCOL) glColor3ubv(obcol);
+ 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]);
- glTexCoord2f((tface->uv[0][0] - centerx) * sizex + transx, (tface->uv[0][1] - centery) * sizey + transy);
+ 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]);
- glVertex3f(sizex * v1[0] + movex, sizey * v1[1] + movey, v1[2]);
+ if (mf_smooth) glNormal3sv(mvert[v1idx].no);
+ glVertex3fv(v1);
- glTexCoord2f((tface->uv[1][0] - centerx) * sizex + transx, (tface->uv[1][1] - centery) * sizey + transy);
+ glTexCoord2fv(tface->uv[1]);
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 (mf_smooth) glNormal3sv(mvert[v2idx].no);
+ glVertex3fv(v2);
+
+ glTexCoord2fv(tface->uv[2]);
if (cp) glColor3ub(cp[11], cp[10], cp[9]);
- glVertex3f(sizex * v3[0] + movex, sizey * v3[1] + movey, v3[2]);
+ if (mf_smooth) glNormal3sv(mvert[v3idx].no);
+ glVertex3fv(v3);
if(v4) {
- glTexCoord2f((tface->uv[3][0] - centerx) * sizex + transx, (tface->uv[3][1] - centery) * sizey + transy);
+ glTexCoord2fv(tface->uv[3]);
if (cp) glColor3ub(cp[15], cp[14], cp[13]);
- glVertex3f(sizex * v4[0] + movex, sizey * v4[1] + movey, v4[2]);
+ if (mf_smooth) glNormal3sv(mvert[v4idx].no);
+ glVertex3fv(v4);
}
-
- curpos+= advance;
+ glEnd();
}
- 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);
}
-
- /* switch off textures */
- set_tpage(0);
}
glShadeModel(GL_FLAT);
glDisable(GL_CULL_FACE);