SUPRNOVA.C

Go to the documentation of this file.
00001 /* --
00002 OpenFX version 2.0 - Modelling, Animation and Rendering Package
00003 Copyright (C) 2000 - 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 /* suprnova.c  image post-processor                                         */
00025 /*                                                                       */
00026 
00027 #include <stdlib.h>
00028 #include <stdio.h>
00029 #include <float.h>
00030 #include <math.h>
00031 #include <windows.h>
00032 #include <commctrl.h>
00033 #include "struct.h"           /* general structures    */
00034 #include "..\common\postprocess\ximage.h"
00035 #include "local.h"
00036 
00037 #include "suprnova.h"
00038 
00039 #if __X__MIPS__
00040 BOOL WINAPI _CRT_INIT(HINSTANCE ,DWORD , LPVOID );
00041 #endif
00042 
00043 static HINSTANCE hDLLinstance=NULL; /* use to pick up resources from DLL   */
00044 
00045 #include "utils.h"
00046 #include "paint.c"
00047 
00048 #if __WATCOMC__
00049 int APIENTRY LibMain(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00050 #elif __BC__
00051 BOOL WINAPI DllEntryPoint(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00052 #else
00053 BOOL WINAPI DllMain(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00054 #endif
00055   switch (dwReason) {
00056     case DLL_PROCESS_ATTACH:
00057 #if __X__MIPS__
00058       if(!_CRT_INIT(hDLL,dwReason,lpReserved))return(int)FALSE;
00059 #endif
00060       hDLLinstance = hDLL;  /* handle to DLL file */
00061       break;
00062     case DLL_PROCESS_DETACH:
00063 #if __X__MIPS__
00064       if(!_CRT_INIT(hDLL,dwReason,lpReserved))return(int)FALSE;
00065 #endif
00066       break;
00067   }
00068 return (int)TRUE;
00069 }
00070 
00071 #if __SC__
00072 #pragma startaddress(DllMain)
00073 #endif
00074 
00075 
00076 static void GrayWholeScreen(double mr,
00077                             fullscreenbuffer *Screen,
00078                             float *Zbuffer, double y,
00079                             int Xmax, int Ymax){
00080  int i,j,r,g,b,v=128;
00081  fullscreenbuffer *S;
00082  if(mr < 0.12)v=(int)(160.0*mr/0.12);
00083  for(j=0;j<Ymax;j++)for(i=0;i<Xmax;i++){
00084    S=(Screen+j*Xmax+i);
00085 //   if(y > *(Zbuffer+j*Xmax+i)){
00086    if(S->A < 64){
00087      r=(int)S->R+v;
00088      g=(int)S->G+v;
00089      b=(int)S->B+v;
00090      S->R=(r>255) ? 255:r;
00091      S->G=(g>255) ? 255:g;
00092      S->B=(b>255) ? 255:b;
00093    }
00094    else{
00095      S->R = (unsigned char)(0.5*(double)S->R+64);
00096      S->G = (unsigned char)(0.5*(double)S->G+64);
00097      S->B = (unsigned char)(0.5*(double)S->B+64);
00098    }
00099  }
00100 }
00101 
00102 double Grad(double x, double y1, double y2, int x1, int x2){
00103  double g;
00104  if(x <= x1)return y1;
00105  if(x >= x2)return y2;
00106  g=(y2-y1)/(double)(x2-x1);
00107  return y1+g*(x-(double)x1);
00108 }
00109 
00110 void DrawInBuffer(fullscreenbuffer *Screen, int Xmax, int Ymax,
00111                   int x, int y, unsigned char v ){
00112  int r,g,b;
00113  fullscreenbuffer *S;
00114  if(x < 0 || y < 0 || x >= Xmax || y >= Ymax)return;
00115  S=(Screen+y*Xmax+x);
00116  r=(int)S->R+(int)v;
00117  g=(int)S->G+(int)v;
00118  b=(int)S->B+(int)v;
00119  S->R=(r>255) ? 255:r;
00120  S->G=(g>255) ? 255:g;
00121  S->B=(b>255) ? 255:b;
00122 }
00123 
00124 #define frac(z) fmod(z,1.0)
00125 
00126 void DrawAApixel(double x, double y, double w, double h, double C,
00127                  fullscreenbuffer *S, int X, int Y){
00128   int xa,xb,ya,yb,i,j,brite;
00129   double x2,y2,lfrac,rfrac,tfrac,bfrac,xfrac,yfrac;
00130   brite=(int)C;
00131   if(x < 0 || y < 0)return;
00132   x -= w*0.5; y -= h*0.5;
00133   x2 = x + w;
00134   y2 = y + w;
00135   xa = (int)x;
00136   xb = (int)x2;
00137   ya = (int)y;
00138   yb = (int)y2;
00139   lfrac = 1.0-frac(x);
00140   rfrac = frac(x2);
00141   tfrac = 1.0-frac(y);
00142   bfrac = frac(y2);
00143   if (xa==xb) {
00144     xfrac = lfrac+rfrac-1.0;
00145     if (ya==yb) {
00146       DrawInBuffer(S,X,Y,xa,ya,xfrac*(tfrac+bfrac-1.0)*brite);
00147     }
00148     else {
00149       DrawInBuffer(S,X,Y,xa,ya,xfrac*tfrac*brite);
00150       for (j=ya+1; j<yb; j++) DrawInBuffer(S,X,Y,xa,j,xfrac*brite);
00151       DrawInBuffer(S,X,Y,xa,yb,xfrac*bfrac*brite);
00152     }
00153   }
00154   else {
00155     if (ya==yb) {
00156       yfrac = tfrac+bfrac-1.0;
00157       DrawInBuffer(S,X,Y,xa,ya,yfrac*lfrac*brite);
00158       for (i=xa+1; i<xb; i++) DrawInBuffer(S,X,Y,i,ya,yfrac*brite);
00159       DrawInBuffer(S,X,Y,xb,ya,yfrac*rfrac*brite);
00160     }
00161     else {
00162       DrawInBuffer(S,X,Y,xa,ya,tfrac*lfrac*brite);
00163       for (i=xa+1; i<xb; i++) DrawInBuffer(S,X,Y,i,ya,tfrac*brite);
00164       DrawInBuffer(S,X,Y,xb,ya,tfrac*rfrac*brite);
00165       for (j=ya+1; j<yb; j++) {
00166         DrawInBuffer(S,X,Y,xa,j,lfrac*brite);
00167         for (i=xa+1; i<xb; i++)DrawInBuffer(S,X,Y,i,j,brite);
00168         DrawInBuffer(S,X,Y,xb,j,rfrac*brite);
00169       }
00170       DrawInBuffer(S,X,Y,xa,yb,bfrac*lfrac*brite);
00171       for (i=xa+1; i<xb; i++) DrawInBuffer(S,X,Y,i,yb,bfrac*brite);
00172       DrawInBuffer(S,X,Y,xb,yb,bfrac*rfrac*brite);
00173     }
00174   }
00175 }
00176 
00177 #define DIST(i,j)  sqrt((double)i * (double)i + (double)j * (double)j)
00178 
00179 static double GetW(double l, double dx, double dy,
00180                    double Wmin, double Wmax, double iScale,
00181                    BOOL linear){
00182  double d,f;
00183  d=DIST(dx,dy);
00184  f=d/l;
00185  if(linear){
00186    if(f < 0.5)return (Wmin+2.0*f*(Wmax-Wmin))*(double)iScale;
00187    return (Wmin+(Wmax-Wmin)*2.0*(1.0-f))*(double)iScale;
00188  }
00189  else{
00190    double y,dx,dw;
00191    dw=(Wmax-Wmin);
00192    if(f < 0.5)f=1.0-f;
00193    f = 2.0*(f-0.5);
00194    y=Wmax-dw*f*f*f;
00195    return y*(double)iScale;
00196  }
00197  return 0.0;
00198 }
00199 
00200 static double GetC(double l, double dx, double dy,
00201                    double Wmin, double Wmax, double iScale,
00202                    BOOL linear){
00203  double d,f;
00204  d=DIST(dx,dy);
00205  f=d/l;
00206  if(f < 0.5)return Wmax;
00207  return (Wmin+(Wmax-Wmin)*2.0*(1.0-f));
00208 }
00209 
00210 static void DrawFlareInBuffer(long x, long y, long idx, long idy,
00211                               fullscreenbuffer *Screen,
00212                               long X, long Y, double iScale,
00213                               double Cin,
00214                               double Wmin, double Wmax,
00215                               double z, float *Zb,
00216                               BOOL bDraw, BOOL linear){
00217  long i,j;
00218  double grad,error,W,l,C;
00219  if(iScale <1.1)Cin *= 2; Cin=min(255,Cin); C=Cin;
00220  l=DIST(idx,idy);
00221  if(abs(idx) >= abs(idy)){
00222    grad=(double)idy/(double)idx; j=y;
00223    if(idy >= 0)error = -0.5; else error = 0.5;
00224    if(idx >= 0){
00225      for(i=x;i<x+idx;i++){
00226        error += grad;
00227        if(idy >= 0){
00228          if(error > 0.0){j++; error -= 1.0;}
00229        }
00230        else{
00231          if(error < 0.0){j--; error += 1.0;}
00232        }
00233        W=GetW(l,(double)(i-x),(double)(j-y),Wmin,Wmax,iScale,linear);
00234        if(!linear)C=GetC(l,(double)(i-x),(double)(j-y),Cin*0.25,Cin,1.0,TRUE);
00235 if(bDraw && (Screen+j*X+i)->A < 64)
00236        DrawAApixel((double)i,(double)j,W,W,C,Screen,X,Y);
00237      }
00238    }
00239    else{
00240      for(i=x;i>x+idx;i--){
00241        error -= grad;
00242        if(idy >= 0){
00243          if(error > 0.0){j++; error -= 1.0;}
00244        }
00245        else{
00246          if(error < 0.0){j--; error += 1.0;}
00247        }
00248        W=GetW(l,(double)(i-x),(double)(j-y),Wmin,Wmax,iScale,linear);
00249        if(!linear)C=GetC(l,(double)(i-x),(double)(j-y),Cin*0.25,Cin,1.0,TRUE);
00250 if(bDraw && (Screen+j*X+i)->A < 64)
00251        DrawAApixel((double)i,(double)j,W,W,C,Screen,X,Y);
00252      }
00253    }
00254  }
00255  else{
00256    grad=(double)idx/(double)idy; j=x;
00257    if(idx >= 0)error = -0.5; else error = 0.5;
00258    if(idy >= 0){
00259      for(i=y;i<y+idy;i++){
00260        error += grad;
00261        if(idx >= 0){
00262          if(error > 0.0){j++; error -= 1.0;}
00263        }
00264        else{
00265          if(error < 0.0){j--; error += 1.0;}
00266        }
00267        W=GetW(l,(double)(j-x),(double)(i-y),Wmin,Wmax,iScale,linear);
00268        if(!linear)C=GetC(l,(double)(j-x),(double)(i-y),Cin*0.25,Cin,1.0,TRUE);
00269 if(bDraw && (Screen+i*X+j)->A < 64)
00270        DrawAApixel((double)j,(double)i,W,W,C,Screen,X,Y);
00271      }
00272    }
00273    else{
00274      for(i=y;i>y+idy;i--){
00275        error -= grad;
00276        if(idx >= 0){
00277          if(error > 0.0){j++; error -= 1.0;}
00278        }
00279        else{
00280          if(error < 0.0){j--; error += 1.0;}
00281        }
00282        W=GetW(l,(double)(j-x),(double)(i-y),Wmin,Wmax,iScale,linear);
00283        if(!linear)C=GetC(l,(double)(j-x),(double)(i-y),Cin*0.25,Cin,1.0,TRUE);
00284 if(bDraw && (Screen+i*X+j)->A < 64)
00285        DrawAApixel((double)j,(double)i,W,W,C,Screen,X,Y);
00286      }
00287    }
00288  }
00289  return;
00290 }
00291 
00292 long _RenderImageProcess(char *PrmList, XIMAGE *lpXimage){
00293  int i,j,Nl,n=45;
00294  char dummy[255];
00295  double x,y,z,radius,atnB,atnL,atnV=1.0;
00296  long v,model,type,flicker,id,sx,sy,ipx,ipy,ipz;
00297  long xx,yy,Xmax,Ymax,Xc,Yc;
00298  long xBlue,yBlue,xBrown,yBrown,xGreen,yGreen,xT,yT;
00299  double iScale,ascale,lscale,dlscale,d2r,lc,dx,dy;
00300  double mr;
00301  float *Zb;
00302  BOOL  bDraw=TRUE;
00303 #include "pro_key.c"
00304  sscanf(PrmList,"%s %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld",
00305         dummy,&type,&flicker,&id,&sx,&sy,&ipx,&ipy,&ipz,&model,&v);
00306  mr=(double)(lpXimage->last_frame - lpXimage->first_frame);
00307  if(mr < 1.0)return 1;
00308  mr=(double)(lpXimage->this_frame - lpXimage->first_frame)/mr;
00309  if(type == 1 && (lpXimage->Nlights == 0 || lpXimage->Lights == NULL))return 1;
00310  Xmax=lpXimage->Xmax;  Ymax=lpXimage->Ymax;
00311  Xc=Xmax/2; Yc=Ymax/2;
00312  iScale=(double)Xmax/320;
00313  ascale=5.0/32767.0;
00314  lscale=80.0*(double)iScale;
00315  dlscale=80.0/32767.0*(double)iScale;
00316  d2r=3.1415626/180.0;
00317  Zb=lpXimage->Zbuffer;
00318  if(flicker)srand(lpXimage->Frame);
00319  else       srand(1);
00320  if(type == 1)Nl=lpXimage->Nlights;
00321  else Nl=1;
00322  for(i=0;i<Nl;i++){
00323    if(type == 1){
00324      x=lpXimage->Lights[i].p[0];
00325      y=lpXimage->Lights[i].p[1];
00326      z=lpXimage->Lights[i].p[2];
00327    }
00328    else if(type == 2){
00329      TransformIntoView(lpXimage->ViewTransform,
00330                        (double)ipx,(double)ipy,(double)ipz,
00331                        &x,&y,&z);
00332    }
00333    else if(type == 3){
00334      y=1.1;
00335    }
00336    else if(type == 4){
00337      if(lpXimage->Lights[i].type != DUMMYL)continue;
00338      x=lpXimage->Lights[i].p[0];
00339      y=lpXimage->Lights[i].p[1];
00340      z=lpXimage->Lights[i].p[2];
00341    if(type == 3 && lpXimage->Lights[i].AnimatorID != id)continue;
00342    }
00343    else if(type == 5){
00344      if(lpXimage->Lights[i].AnimatorID != id)continue;
00345      x=lpXimage->Lights[i].p[0];
00346      y=lpXimage->Lights[i].p[1];
00347      z=lpXimage->Lights[i].p[2];
00348    }
00349    if(y >= 1.000){
00350      if(type == 3){
00351        xx=sx; yy=sy;
00352      }
00353      else{
00354        xx=Xc + (long)(lpXimage->Xscale*x/y);
00355        yy=Yc - (long)(lpXimage->Yscale*z/y);
00356      }
00357      if(1){
00358        dx=(double)(xx-Xc);  dy=(double)(yy-Yc);
00359        lc=DIST(dx,dy);  dx /= lc; dy /= lc;
00360        atnB=atnV; atnL=atnV;
00361        if(mr < 0.8){
00362          atnB = atnL = atnV*mr/0.8;
00363        }
00364        else if(mr > 0.9){
00365          atnB = atnL = atnV*(1.0-mr)/0.1;
00366        }
00367        if(model == 1){
00368          for(j=0;j<n;j++){  /* outlying spines */
00369            double a,l,br,mw;
00370            long   idx,idy;
00371            a=360.0/(double)n*(double)j+ascale*(double)rand();
00372            a *= d2r;
00373            l=lscale+dlscale*(double)rand();
00374            l *= atnL;
00375            idx=(long)(l*cos(a)); idy=(long)(l*sin(a));
00376            br=20.0*atnB;
00377            br=64.0*atnB;
00378            mw=0.8;
00379            mw=1.5;
00380            DrawFlareInBuffer(xx,yy,idx,idy,lpXimage->Screen,Xmax,Ymax,
00381                              iScale,
00382                              br, // brightness 0-255
00383                              0.2,// min width
00384                              mw, // max width
00385                              y,Zb,bDraw,TRUE);
00386          }
00387          for(i=0;i<3;i++)for(j=0;j<n;j++){ /* centre spines */
00388            double a,l,C;
00389            long   idx,idy;
00390            a=360.0/(double)n*(double)j+ascale*(double)rand();
00391            a *= d2r;
00392            l=lscale+dlscale*(double)rand();
00393            l *= atnL;
00394            if     (i == 0){l /= 5;            C=32.0 *atnB;}
00395            else if(i == 1){l /= 10;           C=64.0 *atnB;}
00396            else if(i == 2){l /= 20;           C=128.0*atnB;}
00397            idx=(long)(l*cos(a)); idy=(long)(l*sin(a));
00398            DrawFlareInBuffer(xx,yy,idx,idy,lpXimage->Screen,Xmax,Ymax,
00399                              iScale,
00400                              C,
00401                              0.2,0.8,
00402                              y,Zb,bDraw,TRUE);
00403          }
00404        }
00405        else{ /* model2 */
00406          for(j=0;j<5;j++){
00407            double a,l,ddx,ddy;
00408            long   xs,ys,idx,idy;
00409            a= -75.0 + 360.0/(double)5*(double)j;
00410            a *= d2r;
00411            l=lscale*1.5;
00412            l *= atnL;
00413            ddx=l*cos(a); ddy=l*sin(a);
00414            idx=(long)ddx; idy=(long)ddy;
00415            xs=xx+(long)(ddx*0.09); ys=yy+(long)(ddy*0.09);
00416            DrawFlareInBuffer(xs,ys,idx,idy,lpXimage->Screen,Xmax,Ymax,
00417                              iScale,
00418                              40.0*atnB,
00419                              0.0,1.4*atnB,
00420                              y,Zb,bDraw,FALSE);
00421            DrawFlareInBuffer(xs,ys,idx,idy,lpXimage->Screen,Xmax,Ymax,
00422                              iScale,
00423                              20.0*atnB,
00424                              0.0,2.8*atnB,
00425                              y,Zb,bDraw,FALSE);
00426            xs=xx+(long)(ddx*0.2); ys=yy+(long)(ddy*0.2);
00427            DrawFlareInBuffer(xs,ys,idx,idy,lpXimage->Screen,Xmax,Ymax,
00428                              iScale,
00429                              10.0*atnB,     // brightness 0-255
00430                              0.0,4.5*atnB,  // min width max width
00431                              y,Zb,bDraw,FALSE);
00432 #if 0
00433 #endif
00434          }
00435        }
00436        if(mr > 0.7 && mr < 0.9)GrayWholeScreen(mr-0.7,
00437                                                lpXimage->Screen,
00438                                                lpXimage->Zbuffer,y,
00439                                                Xmax,Ymax);
00440      }
00441    }
00442  }
00443  return 1;
00444 }
00445 
00446 /*************** Function that renders anyof the OpenGL Functionality ************/
00447 
00448 long _RenderGLexternal(char *PrmList, XIMAGE *lpXimage){
00449 MessageBox(NULL,"Fog OpenGL function called","OK",MB_OK);
00450  return 1;
00451 }
00452 
00453 
00454 BOOL CALLBACK DlgProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam);
00455 
00456 static long   version=1,type=1,model=1,flicker=0,id = -1 ,
00457               sx=0,sy=0,ipx=0,ipy=0,ipz=0;
00458 static double bscale=1.0,rscale=1.0;
00459 static double px,py,pz;
00460 static X__MEMORY_MANAGER *lpLocalEVI;
00461 
00462 char * _SetExternalParameters(
00463   char *Op,                 /* string for the parameters                  */
00464   HWND hWnd,                /* parent window                              */
00465   long ruler,               /* ruler scale value to facilitate scaling    */
00466   char *name,               /* name of DLL file with the effect           */
00467   X__MEMORY_MANAGER *lpEVI /* pointer to structure with memory functions */
00468                                     ){
00469  char buffer[256];
00470  if(Op != NULL){
00471    sscanf(Op,"%s %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %f %f",
00472           buffer,&type,&flicker,&id,&sx,&sy,&ipx,&ipy,&ipz,&model,&version,
00473           &bscale,&rscale);
00474     px=(double)ipx/(double)ruler;
00475     py=(double)ipy/(double)ruler;
00476     pz=(double)ipz/(double)ruler;
00477  }
00478  lpLocalEVI=lpEVI;
00479  if(DialogBox(hDLLinstance,MAKEINTRESOURCE(DLG_SUPRNOVA),hWnd,
00480               (DLGPROC)DlgProc) == FALSE)return Op;
00481  if(Op != NULL)CALL_FREE(Op);  /* free the old string */
00482  ipx=(long)(px*(double)ruler);
00483  ipy=(long)(py*(double)ruler);
00484  ipz=(long)(pz*(double)ruler);
00485  sprintf(buffer,"%s %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %f %f",
00486          name,type,flicker,id,sx,sy,ipx,ipy,ipz,model,version,bscale,rscale);
00487  if((Op=(char *)CALL_MALLOC(strlen(buffer)+1)) == NULL){
00488    return NULL;
00489  }
00490  strcpy(Op,buffer);
00491  return Op;
00492 }
00493 
00494 static void LoadAnimatedClip(HWND hDlg){
00495  char *c,modname[256];
00496  GetModuleFileName(hDLLinstance,modname,255);
00497  if((c=strrchr(modname,'.')) != NULL){
00498    strcpy(c,".avi");
00499    Animate_Open(GetDlgItem(hDlg,DLG_ANIM),modname);
00500    Animate_Play(GetDlgItem(hDlg,DLG_ANIM),0, -1, -1);
00501  }
00502 }
00503 
00504 
00505 BOOL CALLBACK DlgProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam){
00506  BOOL err;
00507  char str[32];
00508  switch( msg ) {
00509    case WM_INITDIALOG:
00510      if     (type == 1)
00511        SendDlgItemMessage(hwnd,DLG_SUPRNOVA_TYPE1,BM_SETCHECK,TRUE,0);
00512      else if(type == 2)
00513        SendDlgItemMessage(hwnd,DLG_SUPRNOVA_TYPE2,BM_SETCHECK,TRUE,0);
00514      else if(type == 3)
00515        SendDlgItemMessage(hwnd,DLG_SUPRNOVA_TYPE3,BM_SETCHECK,TRUE,0);
00516      else if(type == 4)
00517        SendDlgItemMessage(hwnd,DLG_SUPRNOVA_TYPE4,BM_SETCHECK,TRUE,0);
00518      else if(type == 5)
00519        SendDlgItemMessage(hwnd,DLG_SUPRNOVA_TYPE5,BM_SETCHECK,TRUE,0);
00520 //     if     (model == 2)
00521 //       SendDlgItemMessage(hwnd,DLG_SUPRNOVA_MODEL2,BM_SETCHECK,TRUE,0);
00522 //     else if(model == 3)
00523 //       SendDlgItemMessage(hwnd,DLG_SUPRNOVA_MODEL3,BM_SETCHECK,TRUE,0);
00524 //     else
00525 //       SendDlgItemMessage(hwnd,DLG_SUPRNOVA_MODEL1,BM_SETCHECK,TRUE,0);
00526      sprintf(str,"%.3f",px);
00527      SetDlgItemText(hwnd,DLG_SUPRNOVA_PX,str);
00528      sprintf(str,"%.3f",py);
00529      SetDlgItemText(hwnd,DLG_SUPRNOVA_PY,str);
00530      sprintf(str,"%.3f",pz);
00531      SetDlgItemText(hwnd,DLG_SUPRNOVA_PZ,str);
00532      SetDlgItemInt(hwnd,DLG_SUPRNOVA_SX,sx,FALSE);
00533      SetDlgItemInt(hwnd,DLG_SUPRNOVA_SY,sy,FALSE);
00534 //     sprintf(str,"%.3f",bscale);
00535 //     SetDlgItemText(hwnd,DLG_SUPRNOVA_BSCALE,str);
00536 //     sprintf(str,"%.3f",rscale);
00537 //     SetDlgItemText(hwnd,DLG_SUPRNOVA_RSCALE,str);
00538      if(id >= 0)SendDlgItemMessage(hwnd,DLG_SUPRNOVA_NAME,WM_SETTEXT,
00539                 0,(LPARAM)GetActorsName(lpLocalEVI->lpAni,id));
00540      LoadAnimatedClip(hwnd);
00541      CentreDialogOnScreen(hwnd);
00542      return TRUE;
00543    case WM_PAINT:
00544      PaintBackground(hwnd);
00545      break;
00546    case WM_COMMAND:
00547      switch(LOWORD(wparam)){
00548         case DLG_SUPRNOVA_SETNAME:
00549           id=GetActorsID(lpLocalEVI->lpAni,hwnd);
00550           if(id >= 0)SendDlgItemMessage(hwnd,DLG_SUPRNOVA_NAME,WM_SETTEXT,
00551                      0,(LPARAM)GetActorsName(lpLocalEVI->lpAni,id));
00552           break;
00553         case IDCANCEL:
00554           EndDialog(hwnd,FALSE);
00555           return(TRUE);
00556         case IDOK:
00557           if(GetDlgItemText(hwnd,DLG_SUPRNOVA_PX,str,12) != 0)
00558             sscanf(str,"%f",&px);
00559           if(GetDlgItemText(hwnd,DLG_SUPRNOVA_PY,str,12) != 0)
00560             sscanf(str,"%f",&py);
00561           if(GetDlgItemText(hwnd,DLG_SUPRNOVA_PZ,str,12) != 0)
00562             sscanf(str,"%f",&pz);
00563 //          if(GetDlgItemText(hwnd,DLG_SUPRNOVA_BSCALE,str,12) != 0)
00564 //            sscanf(str,"%f",&bscale);
00565 //          if(GetDlgItemText(hwnd,DLG_SUPRNOVA_RSCALE,str,12) != 0)
00566 //            sscanf(str,"%f",&rscale);
00567           sx=GetDlgItemInt(hwnd,DLG_SUPRNOVA_SX,&err,FALSE);
00568           sy=GetDlgItemInt(hwnd,DLG_SUPRNOVA_SY,&err,FALSE);
00569           if     (SendDlgItemMessage(hwnd,DLG_SUPRNOVA_TYPE5,BM_GETCHECK,0,0))
00570                type=5;
00571           else if(SendDlgItemMessage(hwnd,DLG_SUPRNOVA_TYPE4,BM_GETCHECK,0,0))
00572                type=4;
00573           else if(SendDlgItemMessage(hwnd,DLG_SUPRNOVA_TYPE3,BM_GETCHECK,0,0))
00574                type=3;
00575           else if(SendDlgItemMessage(hwnd,DLG_SUPRNOVA_TYPE2,BM_GETCHECK,0,0))
00576                type=2;
00577           else type=1;
00578 //          if     (SendDlgItemMessage(hwnd,DLG_SUPRNOVA_MODEL2,BM_GETCHECK,0,0))
00579 //               model=2;
00580 //          else if(SendDlgItemMessage(hwnd,DLG_SUPRNOVA_MODEL3,BM_GETCHECK,0,0))
00581 //               model=3;
00582 //          else model=1;
00583           EndDialog(hwnd,TRUE);
00584           return(TRUE);
00585         default:
00586           break;
00587       }
00588       break;
00589     default: break;
00590  }
00591  return FALSE;
00592 }
00593 

Generated on Sun Apr 27 14:20:12 2014 for OpenFX by  doxygen 1.5.6