hcpbumps.c

Go to the documentation of this file.
00001 /* --
00002 OpenFX version 2.0 - Modelling, Animation and Rendering Package
00003 Copyright (C) 2000 - 2007 OpenFX Development Team
00004 
00005 This program is free software; you can redistribute it and/or
00006 modify it under the terms of the GNU General Public License
00007 as published by the Free Software Foundation; either version 2
00008 of the License, or (at your option) any later version.
00009 
00010 This program is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 GNU General Public License for more details.
00014 
00015 You should have received a copy of the GNU General Public License
00016 along with this program; if not, write to the Free Software
00017 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018 
00019 You may contact the OpenFX development team via elecronic mail
00020 at core@openfx.org, or visit our website at http://openfx.org for
00021 further information and support details.
00022 -- */
00023 
00024 // HCPbumps
00025 
00026 #include <stdlib.h>
00027 #include <stdio.h>
00028 #include <math.h>
00029 #include <float.h>
00030 #include <windows.h>
00031 #include <gl/gl.h>
00032 
00033 #if __ZTC__ || __SC__
00034 #ifndef max
00035 #define max(a,b)  ( ((a) > (b)) ? (a) : (b) )
00036 #endif
00037 #endif
00038 
00039 #if __WATCOMC__
00040 #define PI 3.1415926
00041 #endif
00042 
00043 #if __X__MIPS__
00044 BOOL WINAPI _CRT_INIT(HINSTANCE ,DWORD , LPVOID );
00045 #endif
00046 
00047 static HINSTANCE hDLLinstance=NULL;
00048 
00049 #include "..\animate\memory.h" /* for memory definition */
00050 #include "..\animate\memdef.h" /* local names           */
00051 #include "defines.h"
00052 #include "rstruct.h"
00053 #include "hcpbumps.h"
00054 
00055 
00056 #if __WATCOMC__
00057 int APIENTRY LibMain(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00058 #else
00059 BOOL WINAPI DllMain(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00060 #endif
00061   HANDLE ghMod;
00062   switch (dwReason) {
00063     case DLL_PROCESS_ATTACH:
00064 #if __X__MIPS__
00065       if(!_CRT_INIT(hDLL,dwReason,lpReserved))return(int)FALSE;
00066 #endif
00067       hDLLinstance = hDLL;  /* handle to DLL file */
00068       break;
00069     case DLL_PROCESS_DETACH:
00070 #if __X__MIPS__
00071       if(!_CRT_INIT(hDLL,dwReason,lpReserved))return(int)FALSE;
00072 #endif
00073       break;
00074   }
00075   return (int)TRUE;
00076 }
00077 
00078 #if __SC__
00079 #pragma startaddress(DllMain)
00080 #endif
00081 
00082 #define VECCOPY(a,b)    { b[0] = a[0]; b[1] = a[1]; b[2] = a[2]; }
00083 #define VECSUM(a,b,c)   { c[0]=a[0]+b[0]; c[1]=a[1]+b[1]; c[2]=a[2]+b[2];}
00084 #define VECSUB(a,b,c)   { c[0]=a[0]-b[0]; c[1]=a[1]-b[1]; c[2]=a[2]-b[2];}
00085 #define VECSCALE(a,b,c) { c[0]=(a)*b[0]; c[1]=(a)*b[1]; c[2]=(a)*b[2];}
00086 #define DOT(a,b)        ( (a[0]*b[0]) + (a[1]*b[1]) + (a[2]*b[2]) )
00087 #define CROSS(v1,v2,r)  { \
00088                           r[0] = (v1[1]*v2[2]) - (v2[1]*v1[2]);  \
00089                           r[1] = (v1[2]*v2[0]) - (v1[0]*v2[2]);  \
00090                           r[2] = (v1[0]*v2[1]) - (v2[0]*v1[1]);  \
00091                         }
00092 
00093 #define IMOD(z,a) ((z) - ((z)/(a))*(a))
00094 
00095 #define PATTERN(x,y,z)   ( ((z)+16384L)*64536L +  \
00096                            ((y)+16384L)*32768L +  \
00097                            ((x)+16384L))
00098 #define FLOOR(x) ((x) >= 0.0 ? floor(x) : (0.0 - floor(0.0 - (x)) - 1.0))
00099 #define FMOD(x,a) ((x) >= 0.0 ? fmod(x,a) :(a - fmod(-(x),a)))
00100 #define ROOT32 0.866025403
00101 #define ROOT3   1.73205080
00102 
00103 static void mix(double *r, double *g, double *b, double mx,
00104                 double r1, double g1, double b1,
00105                 double r2, double g2, double b2){
00106  *r = mx*r1 + (1.0-mx)*r2;
00107  *g = mx*g1 + (1.0-mx)*g2;
00108  *b = mx*b1 + (1.0-mx)*b2;
00109 }
00110 
00111 double sigmoid(double t, double tmin, double tmax){
00112  t=3.1415926*(2.0*(t-tmin)/(tmax-tmin));
00113  return 0.5*(1.0-cos(t));
00114 }
00115 
00116 static double size=0.25,depth=1.0;
00117 static double c1[3]={255.0,0.0,0.0};
00118 static double c2[3]={255.0,255.0,0.0};
00119 static double c3[3]={0.0,0.0,255.0};
00120 static double x=1.0,y=1.0,z=1.0;
00121 static long  type=0,colourflag=0,bumps=0;
00122 
00123 #if 0
00124 long CALLBACK ExternalTextureStartup(
00125 #else
00126 long _ExternalTextureStartup(
00127 #endif
00128   long frame,long nframes,char *parameter_list, X__SHADER *lpEVI){
00129  if(parameter_list[0] != '#'){
00130    MessageBox ( GetFocus(),
00131                 (LPCTSTR) "External texture: Startup",
00132                 (LPCTSTR) "Parameter list missing",
00133                 MB_OK | MB_SYSTEMMODAL );
00134  }
00135  else {
00136   parameter_list++;
00137   sscanf(parameter_list,"%f %f %f  %f %f  %f %f %f  %f %f %f   %f %f %f  %ld %ld %ld",
00138          &x,&y,&z,&size,&depth,
00139          &c1[0],&c1[1],&c1[2],
00140          &c2[0],&c2[1],&c2[2],
00141          &c3[0],&c3[1],&c3[2],
00142          &type,&colourflag,&bumps);
00143  }
00144  return LoadAndCompileShader("hcpbumps");
00145 }
00146 
00147 #if 0
00148 long CALLBACK ExternalTextureMorph(
00149 #else
00150 long _ExternalTextureMorph(
00151 #endif
00152  char *parameter_list, double mr){
00153  int i;
00154  double size_m,depth_m;
00155  double c1_m[3],c2_m[3],c3_m[3];
00156  double x_m,y_m,z_m;
00157  parameter_list++;
00158  sscanf(parameter_list,"%f %f %f  %f %f  %f %f %f  %f %f %f   %f %f %f",
00159         &x_m,&y_m,&z_m,&size_m,&depth_m,
00160         &c1_m[0],&c1_m[1],&c1_m[2],
00161         &c2_m[0],&c2_m[1],&c2_m[2],
00162         &c3_m[0],&c3_m[1],&c3_m[2]);
00163  for(i=0;i<3;i++)c1[i]=c1_m[i]+(c1[i]-c1_m[i])*mr;
00164  for(i=0;i<3;i++)c2[i]=c2_m[i]+(c2[i]-c2_m[i])*mr;
00165  for(i=0;i<3;i++)c3[i]=c3_m[i]+(c3[i]-c3_m[i])*mr;
00166  size=size_m+(size-size_m)*mr;
00167  depth=depth_m+(depth-depth_m)*mr;
00168  x=x_m+(x-x_m)*mr;
00169  y=y_m+(y-y_m)*mr;
00170  z=z_m+(z-z_m)*mr;
00171  return 1;
00172 }
00173 
00174 #if 0
00175 long CALLBACK ExternalTextureProcedure(
00176 #else
00177 long _ExternalTextureProcedure(
00178 #endif
00179   long coord_type,  vector p, vector n,
00180   double alpha, double beta, double gamma,
00181   double bump,  double map_x,  double map_y,
00182   double *alpha_channel, unsigned char sc[3], double colour[3],
00183   double *reflectivity, double *transparency,
00184   X__SHADER *lpEVI
00185 ){
00186  static
00187 #if 0
00188  vector pp[22]={{0.25,0.0,      0.0},                     //0
00189                 {0.75,0.0,      0.0},
00190                 {0.0, ROOT32/2, 0.0},
00191                 {0.5, ROOT32/2, 0.0},
00192                 {1.0, ROOT32/2, 0.0},
00193                 {0.25,ROOT32,   0.0},
00194                 {0.75,ROOT32,   0.0},
00195                 {0.0, 1.0/2.0/ROOT3-ROOT32/2,ROOT32/2.0},  //7
00196                 {0.5, 1.0/2.0/ROOT3-ROOT32/2,ROOT32/2.0},
00197                 {1.0, 1.0/2.0/ROOT3-ROOT32/2,ROOT32/2.0},
00198                 {0.25,1.0/2.0/ROOT3,         ROOT32/2.0},
00199                 {0.75,1.0/2.0/ROOT3,         ROOT32/2.0},
00200                 {0.0, 1.0/2.0/ROOT3+ROOT32/2,ROOT32/2.0}, //12
00201                 {0.5, 1.0/2.0/ROOT3+ROOT32/2,ROOT32/2.0},
00202                 {1.0, 1.0/2.0/ROOT3+ROOT32/2,ROOT32/2.0},
00203                 {0.25,0.0,      ROOT32},
00204                 {0.75,0.0,      ROOT32},
00205                 {0.0, ROOT32/2, ROOT32},
00206                 {0.5, ROOT32/2, ROOT32},
00207                 {1.0, ROOT32/2, ROOT32},
00208                 {0.25,ROOT32,   ROOT32},
00209                 {0.75,ROOT32,   ROOT32}};                 //21
00210 #endif
00211  vector pp[35]={{0.25,0.0,      0.0},                     //0
00212                 {0.75,0.0,      0.0},
00213                 {0.0, ROOT32/2, 0.0},
00214                 {0.5, ROOT32/2, 0.0},
00215                 {1.0, ROOT32/2, 0.0},
00216                 {0.25,ROOT32,   0.0},
00217                 {0.75,ROOT32,   0.0},
00218 
00219                 {-0.25,0.0,     0.0},
00220                 { 1.25,0.0,     0.0},
00221                 {-0.25,ROOT32,  0.0},
00222                 { 1.25,ROOT32,  0.0},
00223                 {-0.25,0.0,    ROOT32},
00224                 { 1.25,0.0,    ROOT32},
00225                 {-0.25,ROOT32, ROOT32},
00226                 { 1.25,ROOT32, ROOT32},
00227                 {-0.25,1.0/2.0/ROOT3,ROOT32/2.0},
00228                 { 1.75,1.0/2.0/ROOT3,ROOT32/2.0},
00229                 {0.0,1.0/2.0/ROOT3+ROOT32,ROOT32/2.0},
00230                 {0.5,1.0/2.0/ROOT3+ROOT32,ROOT32/2.0},
00231                 {1.0,1.0/2.0/ROOT3+ROOT32,ROOT32/2.0},
00232 
00233                 {0.0, 1.0/2.0/ROOT3-ROOT32/2,ROOT32/2.0},
00234                 {0.5, 1.0/2.0/ROOT3-ROOT32/2,ROOT32/2.0},
00235                 {1.0, 1.0/2.0/ROOT3-ROOT32/2,ROOT32/2.0},
00236                 {0.25,1.0/2.0/ROOT3,         ROOT32/2.0},
00237                 {0.75,1.0/2.0/ROOT3,         ROOT32/2.0},
00238                 {0.0, 1.0/2.0/ROOT3+ROOT32/2,ROOT32/2.0},
00239                 {0.5, 1.0/2.0/ROOT3+ROOT32/2,ROOT32/2.0},
00240                 {1.0, 1.0/2.0/ROOT3+ROOT32/2,ROOT32/2.0},
00241                 {0.25,0.0,      ROOT32},
00242                 {0.75,0.0,      ROOT32},
00243                 {0.0, ROOT32/2, ROOT32},
00244                 {0.5, ROOT32/2, ROOT32},
00245                 {1.0, ROOT32/2, ROOT32},
00246                 {0.25,ROOT32,   ROOT32},
00247                 {0.75,ROOT32,   ROOT32}};
00248  vector dn,vt;
00249  double dx,dy,dz,zb,ccc;
00250  long i;
00251  double a,cc,xx,yy,zz,r,g,b;
00252  vector u,v;
00253  cc=size;
00254  xx=alpha / x;
00255  yy=beta  / y;
00256  zz=gamma / z;
00257  yy /= ROOT32;
00258  xx=FMOD(xx,1.0);
00259  yy=FMOD(yy,ROOT32);
00260  zz /= ROOT32;
00261  zz=FMOD(zz,ROOT32);
00262  zb=0.0;
00263  r=colour[0];
00264  g=colour[1];
00265  b=colour[2];
00266  VECCOPY(n,dn)
00267  for(i=0;i<35;i++){
00268    dx=(xx-pp[i][0]);
00269    dy=(yy-pp[i][1]);
00270    dz=(zz-pp[i][2]);
00271    if(fabs(dx) > cc)continue;
00272    if(fabs(dy) > cc)continue;
00273    if(fabs(dz) > cc)continue;
00274    if((a=sqrt(dx*dx+dy*dy+dz*dz)) < cc){
00275      if((cc-a) > zb){
00276        zb=(cc-a);
00277        if(colourflag){
00278          r=c1[0];
00279          g=c1[1];
00280          b=c1[2];
00281        }
00282        v[0]=dx; v[1]=dy; v[2]=dz;
00283        VECCOPY(dn,n)
00284        normalize(v);  // direction of bend relative to the texture axes
00285        VECSCALE(v[0],tAxis_unorm,vt)
00286        VECSUM(v[1]*tAxis_vnorm,vt,vt)
00287        VECSUM(-v[2]*tAxis_n,vt,vt)
00288        normalize(vt);  
00289        VECCOPY( vt,v) // direction of bend NOW relative to the global coords (i.e. same as "n")
00290        ccc=fabs(DOT(v,n));
00291        CROSS(v,n,u)
00292        CROSS(n,u,v)
00293        normalize(v);  // direction of bend - at right angles to the surface normal
00294        if(type == 0){
00295          a=1.9*a*sqrt(1.0-ccc*ccc);
00296        }
00297        else if(type == 1){
00298          a=0.5;
00299        }
00300        else{
00301          if(a < 0.5)a=1.0-sigmoid(a,0.0,0.5);
00302          else a=1.0;
00303        }
00304        a *= depth;
00305        if(bumps)VECSCALE( a,v,v)
00306        else     VECSCALE(-a,v,v)
00307        VECSCALE((1.0-a),n,n)
00308        VECSUM(v,n,n)
00309        normalize(n);
00310      }
00311      break;
00312    }
00313  }
00314  colour[0]  = r;
00315  colour[1]  = g;
00316  colour[2]  = b;
00317  return 1;
00318 }
00319 
00320 void _ExternalTextureClose(X__SHADER *lpEVI){
00321  UnloadCompiledShader(tGLshaderID);
00322 }
00323 
00324 long _ExternalTextureProcedureGL(
00325   double bump_scale,
00326   unsigned char sc[3],
00327   unsigned char ac[3],
00328   X__SHADER *lpEVI
00329 ){
00330  // Set any shader specific uniform variables here.
00331 // Set any shader specific uniform variables here.
00332  SetUniformVector(tGLshaderID,"MaterialC",(GLfloat)ac[0]/255.0,(GLfloat)ac[1]/255.0,(GLfloat)ac[2]/255.0);
00333  if(colourflag)SetUniformInteger(tGLshaderID,"ColourType",1);
00334  else          SetUniformInteger(tGLshaderID,"ColourType",0);
00335  if(bumps)SetUniformInteger(tGLshaderID,"Dimples",0);
00336  else     SetUniformInteger(tGLshaderID,"Dimples",1);
00337  SetUniformInteger(tGLshaderID,"ShaderID",type);
00338  SetUniformVector(tGLshaderID,"ScalingV",1.0/x,1.0/z,1.0/y);
00339  SetUniformVariable(tGLshaderID,"BumpDepth",depth);
00340  SetUniformVariable(tGLshaderID,"BumpSize",size);
00341  // Callback to Render the Polygons - this allows for multiple passes - through same shaders
00342  // possibly with different parameters - including vertex offset - blending depth enabling 
00343  // to allow for multipass textures e.g. hair and fur (shell model) it's arguments must not be altered!!!
00344  DrawShadedPolygons(tmatpass,tpass,tprogID,tattrloc,tNface,tMainFp,tNvert,tMainVp);
00345  return 1;
00346 }
00348 
00349 void CentreDialogOnScreen(HWND hwnd){
00350  RECT rcDlg;
00351  long Xres,Yres;
00352  Yres=GetSystemMetrics(SM_CYSCREEN);
00353  Xres=GetSystemMetrics(SM_CXSCREEN);
00354  GetWindowRect(hwnd,&rcDlg);
00355  OffsetRect(&rcDlg,-rcDlg.left,-rcDlg.top);
00356  OffsetRect(&rcDlg,(Xres-rcDlg.right)/2,(Yres-rcDlg.bottom)/2);
00357  SetWindowPos(hwnd,HWND_TOP,rcDlg.left,rcDlg.top,0,0,SWP_NOSIZE);
00358  return;
00359 }
00360 
00361 static void SetColour(double *colour, HWND parent){
00362  CHOOSECOLOR cc;
00363  static COLORREF CustColours[16]={
00364    RGB(255,255,255), RGB(239,239,239), RGB(223,223,223), RGB(207,207,207),
00365    RGB(191,191,191), RGB(175,175,175), RGB(159,159,159), RGB(143,143,143),
00366    RGB(127,127,127), RGB(111,111,111), RGB( 95, 95, 95), RGB( 79, 79, 79),
00367    RGB( 63, 63, 63), RGB( 47, 47, 47), RGB( 31, 31, 31), RGB( 15, 15, 15) };
00368  cc.lStructSize=sizeof(CHOOSECOLOR);
00369  cc.hwndOwner=parent;
00370  cc.rgbResult=RGB((BYTE)colour[0],(BYTE)colour[1],(BYTE)colour[2]);
00371  cc.lpCustColors=(LPDWORD)CustColours;
00372 // cc.Flags=CC_FULLOPEN | CC_RGBINIT | CC_ENABLEHOOK;
00373  cc.Flags= CC_RGBINIT;
00374  cc.lCustData=(DWORD)0;
00375  if(ChooseColor(&cc)){
00376    colour[0]=(double)GetRValue(cc.rgbResult);
00377    colour[1]=(double)GetGValue(cc.rgbResult);
00378    colour[2]=(double)GetBValue(cc.rgbResult);
00379  }
00380 }
00381 
00382 BOOL CALLBACK DlgProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam);
00383 
00384 #if 0
00385 char * CALLBACK SetExternalParameters(
00386 #else
00387 char * _SetExternalParameters(
00388 #endif
00389   char *Op,                 /* string for the parameters                  */
00390   HWND hWnd,                /* parent window                              */
00391   X__MEMORY_MANAGER *lpEVI /* pointer to structure with memory functions */
00392                              ){
00393  char szbuf[255],*Op1;
00394  if(Op != NULL){  /* parameters exist so read them off the list */
00395    Op1=Op;
00396    Op1++;
00397    sscanf(Op1,"%f %f %f  %f %f  %f %f %f  %f %f %f   %f %f %f  %ld %ld %ld",
00398          &x,&y,&z,&size,&depth,
00399          &c1[0],&c1[1],&c1[2],
00400          &c2[0],&c2[1],&c2[2],
00401          &c3[0],&c3[1],&c3[2],
00402          &type,&colourflag,&bumps);
00403  }
00404  if(DialogBox(hDLLinstance,MAKEINTRESOURCE(DLG),hWnd,
00405               (DLGPROC)DlgProc) == FALSE)return Op;
00406  if(Op != NULL)CALL_FREE(Op);  /* free the old string */
00407  sprintf(szbuf,"# %.2f %.2f %.2f  %.3f %.2f "
00408                  "%.2f %.2f %.2f "
00409                  "%.2f %.2f %.2f "
00410                  "%.2f %.2f %.2f %ld %ld %ld",
00411          x,y,z,size,depth,
00412          c1[0],c1[1],c1[2],
00413          c2[0],c2[1],c2[2],
00414          c3[0],c3[1],c3[2],
00415          type,colourflag,bumps);
00416  if((Op=(char *)CALL_MALLOC(strlen(szbuf)+1)) == NULL){
00417   MessageBox (GetFocus(),"External shader: Out of memory","Error",
00418                 MB_OK|MB_TASKMODAL|MB_ICONSTOP);
00419    return NULL;
00420  }
00421  strcpy(Op,szbuf);
00422  return Op;
00423 }
00424 
00425 BOOL CALLBACK DlgProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam){
00426  char str[16];
00427  switch( msg ) {
00428    case WM_INITDIALOG:
00429      sprintf(str,"%.2f",x);
00430      SendDlgItemMessage(hwnd,DLG_XSCALE,WM_SETTEXT,0,(LPARAM)str);
00431      SendDlgItemMessage(hwnd,DLG_XSCALE,EM_LIMITTEXT,(WPARAM)12,0);
00432      sprintf(str,"%.2f",y);
00433      SendDlgItemMessage(hwnd,DLG_YSCALE,WM_SETTEXT,0,(LPARAM)str);
00434      SendDlgItemMessage(hwnd,DLG_YSCALE,EM_LIMITTEXT,(WPARAM)12,0);
00435      sprintf(str,"%.2f",z);
00436      SendDlgItemMessage(hwnd,DLG_ZSCALE,WM_SETTEXT,0,(LPARAM)str);
00437      SendDlgItemMessage(hwnd,DLG_ZSCALE,EM_LIMITTEXT,(WPARAM)12,0);
00438      sprintf(str,"%.2f",size);
00439      SendDlgItemMessage(hwnd,DLG_SIZE,WM_SETTEXT,0,(LPARAM)str);
00440      SendDlgItemMessage(hwnd,DLG_SIZE,EM_LIMITTEXT,(WPARAM)12,0);
00441      sprintf(str,"%.2f",depth);
00442      SendDlgItemMessage(hwnd,DLG_DEPTH,WM_SETTEXT,0,(LPARAM)str);
00443      SendDlgItemMessage(hwnd,DLG_DEPTH,EM_LIMITTEXT,(WPARAM)12,0);
00444      if(colourflag)
00445        SendDlgItemMessage(hwnd,DLG_COLOURFLAG,BM_SETCHECK,TRUE,0);
00446      if(type == 0)
00447        SendDlgItemMessage(hwnd,DLG_TYPE1,BM_SETCHECK,TRUE,0);
00448      else if(type == 1)
00449        SendDlgItemMessage(hwnd,DLG_TYPE2,BM_SETCHECK,TRUE,0);
00450      else if(type == 2)
00451        SendDlgItemMessage(hwnd,DLG_TYPE3,BM_SETCHECK,TRUE,0);
00452      if(bumps == 1)
00453        SendDlgItemMessage(hwnd,DLG_BUMP,BM_SETCHECK,TRUE,0);
00454      else
00455        SendDlgItemMessage(hwnd,DLG_DIMPLE,BM_SETCHECK,TRUE,0);
00456      CentreDialogOnScreen(hwnd);
00457      return TRUE;
00458    case WM_DRAWITEM:{
00459        LPDRAWITEMSTRUCT lpdis;
00460        HBRUSH   hbr,hbrold;
00461        BYTE r,g,b;
00462        lpdis=(LPDRAWITEMSTRUCT)lparam;
00463        if(lpdis->CtlID == DLG_COLOUR1){
00464          if(lpdis->CtlID == DLG_COLOUR1){
00465            r=(BYTE)c1[0]; g=(BYTE)c1[1]; b=(BYTE)c1[2];
00466          }
00467          if(lpdis->itemState & ODS_SELECTED)
00468             InvertRect(lpdis->hDC,&(lpdis->rcItem));
00469          else{
00470            hbr=CreateSolidBrush(RGB(r,g,b));
00471            hbrold=SelectObject(lpdis->hDC,hbr);
00472            Rectangle(lpdis->hDC,lpdis->rcItem.left,lpdis->rcItem.top,
00473                          lpdis->rcItem.right,lpdis->rcItem.bottom);
00474            SelectObject(lpdis->hDC,hbrold);
00475            DeleteObject(hbr);
00476          }
00477        }
00478      }
00479      break;
00480    case WM_COMMAND:
00481      switch(LOWORD(wparam)){
00482         case DLG_COLOUR1:
00483           SetColour(c1,hwnd);
00484           InvalidateRect(GetDlgItem(hwnd,DLG_COLOUR1),NULL,FALSE);
00485           break;
00486         case IDCANCEL:
00487           EndDialog(hwnd,FALSE);
00488           return(TRUE);
00489         case IDOK:
00490           if(GetDlgItemText(hwnd,DLG_XSCALE,str,10) == 0)
00491              EndDialog(hwnd,FALSE);
00492           if((x=atof(str)) == 0)EndDialog(hwnd,FALSE);
00493           if(GetDlgItemText(hwnd,DLG_YSCALE,str,10) == 0)
00494              EndDialog(hwnd,FALSE);
00495           if((y=atof(str)) == 0)EndDialog(hwnd,FALSE);
00496           if(GetDlgItemText(hwnd,DLG_ZSCALE,str,10) == 0)
00497              EndDialog(hwnd,FALSE);
00498           if((z=atof(str)) == 0)EndDialog(hwnd,FALSE);
00499           if(GetDlgItemText(hwnd,DLG_SIZE,str,10) == 0)
00500              EndDialog(hwnd,FALSE);
00501           if((size=atof(str)) == 0)EndDialog(hwnd,FALSE);
00502           if(GetDlgItemText(hwnd,DLG_DEPTH,str,10) == 0)
00503              EndDialog(hwnd,FALSE);
00504           if((depth=atof(str)) == 0)EndDialog(hwnd,FALSE);
00505           if(SendDlgItemMessage(hwnd,DLG_COLOURFLAG,BM_GETCHECK,0,0))
00506             colourflag=1; else colourflag=0;
00507           if(SendDlgItemMessage(hwnd,DLG_TYPE1,BM_GETCHECK,0,0))type=0;
00508           else if(SendDlgItemMessage(hwnd,DLG_TYPE2,BM_GETCHECK,0,0))type=1;
00509           else if(SendDlgItemMessage(hwnd,DLG_TYPE3,BM_GETCHECK,0,0))type=2;
00510           if(SendDlgItemMessage(hwnd,DLG_BUMP,BM_GETCHECK,0,0))bumps=1;
00511           else bumps=0;
00512           EndDialog(hwnd,TRUE);
00513           return(TRUE);
00514         default:
00515           break;
00516       }
00517       break;
00518     default: break;
00519  }
00520  return FALSE;
00521 }
Generated on Tue Jan 28 06:18:32 2014 for OpenFX by  doxygen 1.6.3