PYRO.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 #include <stdlib.h>
00025 #include <stdio.h>
00026 #include <float.h>
00027 #include <math.h>
00028 #include <windows.h>
00029 #include <commctrl.h>
00030 #include "struct.h"           /* general structures    */
00031 #include "..\common\postprocess\ximage.h"
00032 #include "local.h"
00033 
00034 #include "pyro.h"
00035 #include "resource.h"
00036 
00037 #ifndef PI
00038 #define PI  3.1415926535
00039 #endif
00040 
00041 #if __X__MIPS__
00042 BOOL WINAPI _CRT_INIT(HINSTANCE ,DWORD , LPVOID );
00043 #endif
00044 
00045 static HINSTANCE hDLLinstance=NULL; /* use to pick up resources from DLL   */
00046 
00047 /************************** Local Utility Functions ***********************/
00048 
00049 #include "utils.h"
00050 #include "paint.c"
00051 
00052 void FillColourRect(HWND hwnd, DWORD colour);
00053 
00054 /************************** DLL entry point ********************************/
00055 
00056 #if __WATCOMC__
00057 int APIENTRY LibMain(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00058 #elif __BC__
00059 BOOL WINAPI DllEntryPoint(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00060 #else
00061 BOOL WINAPI DllMain(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00062 #endif
00063   switch (dwReason) {
00064     case DLL_PROCESS_ATTACH:
00065 #if __X__MIPS__
00066       if(!_CRT_INIT(hDLL,dwReason,lpReserved))return(int)FALSE;
00067 #endif
00068 //MessageBox(NULL,"Attaching",NULL,MB_OK);
00069       hDLLinstance = hDLL;  /* handle to DLL file */
00070       break;
00071     case DLL_PROCESS_DETACH:
00072 #if __X__MIPS__
00073       if(!_CRT_INIT(hDLL,dwReason,lpReserved))return(int)FALSE;
00074 #endif
00075 //MessageBox(NULL,"Detaching",NULL,MB_OK);
00076       break;
00077   }
00078 return (int)TRUE;
00079 }
00080 
00081 #if __SC__
00082 #pragma startaddress(DllMain)
00083 #endif
00084 
00085 /* Colour references for the custom colours in the full colour dialog*/
00086 COLORREF acrCustClr[16]={
00087   RGB(255,255,255), RGB(239,239,239),
00088   RGB(223,223,223), RGB(207,207,207),
00089   RGB(191,191,191), RGB(175,175,175),
00090   RGB(159,159,159), RGB(143,143,143),
00091   RGB(127,127,127), RGB(111,111,111),
00092   RGB(95,95,95), RGB(79,79,79),
00093   RGB(63,63,63), RGB(47,47,47),
00094   RGB(31,31,31), RGB(15,15,15)};
00095 
00096 X__MEMORY_MANAGER  *lpLocalEVI;
00097 
00098 /*******************************************************************\
00099 |                Code that executes the process                     |
00100 \*******************************************************************/
00101 
00102 long _RenderImageProcess(char *PrmList, XIMAGE *lpXimage){
00103 
00104  long i, j,seed, ruler, t_of_explode;
00105  double Xuser, Yuser, Zuser, Xview, Yview, Zview, xx, yy, Xpos, Ypos, Zpos, velocity, dist;
00106  double time, theta, phi, Xexp, Yexp, Zexp, expvel, expmax;
00107  long launchframe, spark, no_sparks;
00108  int redval, greenval, blueval, factor, trails;
00109  double Xstart, Ystart, Zstart, ground;
00110  long id1, id2, type;
00111  DWORD colour;
00112  BOOL source, target;
00113  light *lightptr;
00114  int lightcount;
00115  char dummy[255];
00116  char test[255];
00117  fullscreenbuffer *S;
00118  float *Z;
00119  /* read the parameters from the parameter list */
00120  sscanf(PrmList,"%s %d %d %f %d %X %f %f %f %f %f %f %f %d %d %d %d %d %d",dummy, &seed, &launchframe, &expmax,
00121             &no_sparks, &colour, &Xstart, &Ystart, &Zstart, &Xexp, &Yexp, &Zexp, 
00122             &ground, &id1, &id2, &source, &target, &type, &ruler);
00123   /* set local pointer to start of screen buffer */
00124  S=lpXimage->Screen;
00125  Z=lpXimage->Zbuffer;
00126  lightptr=lpXimage->Lights;
00127  srand(seed);
00128  redval=GetRValue(colour);
00129  greenval=GetGValue(colour);
00130  blueval=GetBValue(colour);
00131 
00132  /* Is source selected rather than defined? if so find 3-D position */
00133  if(source==FALSE){
00134   for(lightcount=0;lightcount<lpXimage->Nlights;lightcount++){
00135      if(lightptr->AnimatorID==id1){
00136        Xstart=(lightptr->pin[0])/(double)ruler;
00137        Ystart=(lightptr->pin[1])/(double)ruler;
00138        Zstart=(lightptr->pin[2])/(double)ruler;
00139      }
00140      lightptr++;
00141   }
00142  }
00143 
00144  
00145  /* Is target selected rather than defined? if so find 3-D position */
00146  if(target==FALSE){
00147    for(lightcount=0;lightcount<lpXimage->Nlights;lightcount++){
00148      if(lightptr->AnimatorID==id2){
00149        Xexp=(lightptr->pin[0])/(double)ruler;
00150        Yexp=(lightptr->pin[1])/(double)ruler;
00151        Zexp=(lightptr->pin[2])/(double)ruler;
00152      }
00153      lightptr++;
00154    }
00155  }
00156 
00157  velocity=(10.0*(sqrt((Zexp-Zstart)/5.0)));
00158  time=(((double)(lpXimage->this_frame))-((double)(launchframe)))/4.0;
00159  t_of_explode=((long)((velocity/10.0)*(4.0))+(double)(launchframe));
00160 
00161 
00162  /*code that describes the flight path of the rocket (not used for the fountain type)*/
00163 
00164  if(type!=1)
00165  if (lpXimage->this_frame>=launchframe && lpXimage->this_frame<=t_of_explode){
00166   /*find co-ordinates of projectile at any time*/
00167   Xuser=Xstart+(time*((Xexp-Xstart)/((double)(t_of_explode-launchframe)/4.0)));
00168   Yuser=Ystart+(time*((Yexp-Ystart)/((double)(t_of_explode-launchframe)/4.0)));
00169   Zuser=Zstart+(((velocity)*(time))-((5.0)*(time)*(time)));
00170   /*scale co-ordinates to tranformable co-ordinates*/
00171    Xpos=Xuser*(double)ruler;
00172   Ypos=Yuser*(double)ruler;
00173   Zpos=Zuser*(double)ruler;
00174 
00175   TransformIntoView(lpXimage->ViewTransform,Xpos,Ypos,Zpos,&Xview,&Yview,&Zview);
00176   
00177   /*Draw in buffer the position of the rocket*/
00178   if (Yview>=1.000){      /*all points in front of viewer */
00179   /*scale to appear in buffer (image size is Xmax by Ymax)*/
00180     xx=(double)lpXimage->Xmax/2.0 + (lpXimage->Xscale*Xview/Yview);
00181     yy=(double)lpXimage->Ymax/2.0 - (lpXimage->Yscale*Zview/Yview);
00182 
00183     if ((long)xx>=0 && (long)xx<lpXimage->Xmax && (long)yy>=0 && (long)yy<lpXimage->Ymax){
00184       i=(long)xx;
00185       j=(long)yy;
00186       /*check the Z-buffer to see if anything is in the way*/
00187       if((float)Yview<*(Z+(j*(lpXimage->Xmax))+i)){
00188         (S+(j*(lpXimage->Xmax))+i)->R=255;
00189         (S+(j*(lpXimage->Xmax))+i)->G=255;
00190         (S+(j*(lpXimage->Xmax))+i)->B=255;
00191         *(Z+(j*(lpXimage->Xmax))+i)=Yview;  /*update the Z-buffer with the new depth value*/
00192       }
00193     }
00194   }
00195  }
00196 
00197  /*code that executes the explosion*/
00198 
00199  if(lpXimage->this_frame>t_of_explode || (type==1 && lpXimage->this_frame>launchframe)){
00200 
00201    if(type==1){
00202      time=(((double)(lpXimage->this_frame))-((double)(launchframe)))/4.0;
00203    }else{
00204      time=(((double)(lpXimage->this_frame))-((double)(t_of_explode)))/4.0;
00205    }
00206    
00207    for(spark=0;spark<no_sparks;spark++){
00208     /*choose random angles to describe the initial direction of each spark*/
00209     if(type!=1){
00210       theta=(((double)(rand())*(2.0*PI))/(double)(RAND_MAX+1));
00211       phi=(((double)(rand())*(2.0*PI))/(double)(RAND_MAX+1));
00212       expvel=(10.0*(sqrt(expmax/5.0))) ;
00213     }else{
00214       theta=(((double)(rand())*(2.0*PI))/(double)(RAND_MAX+1));
00215       phi=(((double)(rand())*(PI/18.0))/(double)(RAND_MAX+1))+(PI/2.0);
00216       expvel=(20.0*(sqrt(expmax/5.0))) ;
00217     }
00218     /*for each spark and its trails find its current position*/
00219     for(trails=0;trails<10;trails++){
00220 
00221       if(type!=1){
00222 
00223         Xuser=Xexp+((expvel)*(cos(phi))*(cos(theta))*(time+((double)(trails)/30.0)));
00224         Yuser=Yexp+((expvel)*(cos(phi))*(sin(theta))*(time+((double)(trails)/30.0)));
00225         Zuser=Zexp+(((expvel)*(sin(phi))*(time+((double)(trails)/30.0)))-
00226               ((1.8)*(time+((double)(trails)/30.0))*(time+((double)(trails)/30.0))));
00227       }else{
00228         Xuser=Xstart+((expvel)*(cos(phi))*(cos(theta))*(time+((double)(trails)/30.0))-50);
00229         Yuser=Ystart+((expvel)*(cos(phi))*(sin(theta))*(time+((double)(trails)/30.0))-50);
00230         Zuser=Zstart+(((expvel)*(sin(phi))*(time+((double)(trails)/30.0)))-
00231               ((2.5)*(time+((double)(trails)/30.0))*(time+((double)(trails)/30.0))));
00232       }
00233 
00234       if (Zuser<ground){      /*ground detection*/
00235         Zuser=ground;
00236       }
00237       /*scaling*/
00238       Xpos=Xuser*(double)ruler;  
00239       Ypos=Yuser*(double)ruler;
00240       Zpos=Zuser*(double)ruler;
00241 
00242       TransformIntoView(lpXimage->ViewTransform,Xpos,Ypos,Zpos,&Xview,&Yview,&Zview);
00243 
00244       /*draw in buffer the sparks and trails and twinkles if the user has specified it*/
00245       if (Yview>=1.000){    /*all points in front of viewer */
00246       /*scale to appear in buffer (image size is Xmax by Ymax)*/
00247 
00248         xx=(double)lpXimage->Xmax/2.0 + (lpXimage->Xscale*Xview/Yview);
00249         yy=(double)lpXimage->Ymax/2.0 - (lpXimage->Yscale*Zview/Yview);
00250 
00251         if ((long)xx>=0 && (long)xx<lpXimage->Xmax && (long)yy>=0 && (long)yy<lpXimage->Ymax-1){
00252           i=(long)xx;
00253           j=(long)yy;
00254           factor=((20*rand())/RAND_MAX+1)+15;
00255           /*check the Z-buffer to see if anything is in the way*/
00256           if((float)Yview<*(Z+(j*(lpXimage->Xmax))+i)){    
00257             if(trails==9 && type!=1){
00258               (S+(j*(lpXimage->Xmax))+i)->R=max((S+(j*(lpXimage->Xmax))+i)->R,255-(factor*time));
00259               (S+(j*(lpXimage->Xmax))+i)->G=max((S+(j*(lpXimage->Xmax))+i)->G,255-(factor*time));
00260               (S+(j*(lpXimage->Xmax))+i)->B=max((S+(j*(lpXimage->Xmax))+i)->B,255-(factor*time));
00261               *(Z+(j*(lpXimage->Xmax))+i)=Yview;  /*update the Z-buffer with the new depth value*/
00262               if(lpXimage->this_frame%8==0 || (lpXimage->this_frame-1)%8==0 || (lpXimage->this_frame-2)%8==0 || (lpXimage->this_frame-3)%8==0){
00263                 if(type==2 && i>=0 && i<lpXimage->Xmax && j+1>=0 && j+1<=lpXimage->Ymax-1){
00264                   (S+((j+1)*(lpXimage->Xmax))+i)->R=max((S+(j*(lpXimage->Xmax))+i)->R,255-(factor*time));
00265                   (S+((j+1)*(lpXimage->Xmax))+i)->G=max((S+(j*(lpXimage->Xmax))+i)->G,255-(factor*time));
00266                   (S+((j+1)*(lpXimage->Xmax))+i)->B=max((S+(j*(lpXimage->Xmax))+i)->B,255-(factor*time));
00267                   *(Z+((j+1)*(lpXimage->Xmax))+i)=Yview;  /*update the Z-buffer with the new depth value*/
00268                 }
00269                 if(type==2 && i>=0 && i<lpXimage->Xmax && j-1>=0 && j-1<=lpXimage->Ymax-1){
00270                   (S+((j-1)*(lpXimage->Xmax))+i)->R=max((S+(j*(lpXimage->Xmax))+i)->R,255-(factor*time));
00271                   (S+((j-1)*(lpXimage->Xmax))+i)->G=max((S+(j*(lpXimage->Xmax))+i)->G,255-(factor*time));
00272                   (S+((j-1)*(lpXimage->Xmax))+i)->B=max((S+(j*(lpXimage->Xmax))+i)->B,255-(factor*time));
00273                   *(Z+((j-1)*(lpXimage->Xmax))+i)=Yview;  /*update the Z-buffer with the new depth value*/
00274                 }
00275                 if(type==2 && i+1>=0 && i+1<lpXimage->Xmax && j>=0 && j<=lpXimage->Ymax-1){
00276                   (S+(j*(lpXimage->Xmax))+i+1)->R=max((S+(j*(lpXimage->Xmax))+i)->R,255-(factor*time));
00277                   (S+(j*(lpXimage->Xmax))+i+1)->G=max((S+(j*(lpXimage->Xmax))+i)->G,255-(factor*time));
00278                   (S+(j*(lpXimage->Xmax))+i+1)->B=max((S+(j*(lpXimage->Xmax))+i)->B,255-(factor*time));
00279                   *(Z+(j*(lpXimage->Xmax))+i+1)=Yview;  /*update the Z-buffer with the new depth value*/
00280                 }
00281                 if(type==2 && i-1>=0 && i-1<lpXimage->Xmax && j>=0 && j<=lpXimage->Ymax-1){
00282                   (S+(j*(lpXimage->Xmax))+i-1)->R=max((S+(j*(lpXimage->Xmax))+i)->R,255-(factor*time));
00283                   (S+(j*(lpXimage->Xmax))+i-1)->G=max((S+(j*(lpXimage->Xmax))+i)->G,255-(factor*time));
00284                   (S+(j*(lpXimage->Xmax))+i-1)->B=max((S+(j*(lpXimage->Xmax))+i)->B,255-(factor*time));
00285                   *(Z+(j*(lpXimage->Xmax))+i-1)=Yview;  /*update the Z-buffer with the new depth value*/
00286                 }
00287               }
00288             }else{
00289               (S+(j*(lpXimage->Xmax))+i)->R=max((S+(j*(lpXimage->Xmax))+i)->R,redval-(factor*time));
00290               (S+(j*(lpXimage->Xmax))+i)->G=max((S+(j*(lpXimage->Xmax))+i)->G,greenval-(factor*time));
00291               (S+(j*(lpXimage->Xmax))+i)->B=max((S+(j*(lpXimage->Xmax))+i)->B,blueval-(factor*time));
00292               *(Z+(j*(lpXimage->Xmax))+i)=Yview;  /*update the Z-buffer with the new depth value*/
00293             }
00294           }
00295         }
00296       }
00297     }
00298   }   
00299  }
00300 
00301 
00302  /*code that produces the initial flash of the firework*/
00303 
00304  if(lpXimage->this_frame>t_of_explode+1 && lpXimage->this_frame<t_of_explode+6){
00305    for(j=0;j<lpXimage->Ymax-1;j++)  /* do rows in screen buffer */
00306    for(i=0;i<lpXimage->Xmax;i++){  /* do all pixles in row j   */
00307    /* add a little white for pixel i,j to give the illusion of a flash*/
00308     S->R = min(255,(unsigned char)((double)S->R + (5.0/time)));
00309     S->G = min(255,(unsigned char)((double)S->G + (5.0/time)));
00310     S->B = min(255,(unsigned char)((double)S->B + (5.0/time)));
00311     S++;             /* point to next pixels in screen buffer */
00312    }
00313  }
00314  return 1;          /* all done OK                           */
00315 }
00316 
00317 /*************** Function that renders any of the OpenGL Functionality ************/
00318 
00319 long _RenderGLexternal(char *PrmList, XIMAGE *lpXimage){
00320 MessageBox(NULL,"OpenGL function called","OK",MB_OK);
00321  return 1;
00322 }
00323 
00324 
00325 /*************** Functions used for set up  ***************/
00326 
00327 
00328 /* local variable for communication between dialog box and Setup function */
00329 long seed=5643;
00330 long launchframe=1;
00331 long sparks=100;
00332 double expmax=5.0;
00333 DWORD colour=0x000000FF;
00334 BOOL source=TRUE;
00335 BOOL target=TRUE;
00336 double Xstart=0.0;
00337 double Ystart=0.0;
00338 double Zstart=0.0;
00339 double Xexp=0.0;
00340 double Yexp=0.0;
00341 double Zexp=200.0;
00342 double ground=0.0;
00343 long id1=0;
00344 long id2=0;
00345 long type=0;
00346 
00347 
00348 /* Dialog box callback prototype */
00349 BOOL CALLBACK DlgProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam);
00350 BOOL CALLBACK DlgHelp(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam);
00351 
00352 char * _SetExternalParameters(
00353   char *Op,                 /* string for the parameters                  */
00354   HWND hWnd,                /* parent window                              */
00355   long ruler,               /* ruler scale value to facilitate scaling    */
00356   char *name,               /* name of DLL file with the effect           */
00357   X__MEMORY_MANAGER *lpEVI /* pointer to structure with memory functions */
00358                                     ){
00359  /* output buffer should be as long as necessary to hold full string        */
00360  char buffer[256];
00361 
00362  lpLocalEVI=lpEVI;
00363  
00364  if(Op != NULL){  /* parameters exist so read them off the list */
00365    sscanf(Op,"%s %d %d %f %d %X %f %f %f %f %f %f %f %d %d %d %d %d",buffer, &seed, &launchframe, &expmax,
00366               &sparks, &colour, &Xstart, &Ystart, &Zstart, &Xexp, &Yexp, &Zexp,
00367               &ground, &id1, &id2, &source, &target, &type);
00368  }
00369   
00370  /*   Do the user interface as required to set up the effect, may use a     */
00371  /*   dialog box etc. Return old string if effect is cancelled (no change)  */
00372  if(DialogBox(hDLLinstance,MAKEINTRESOURCE(DLG_PYRO),hWnd,
00373               (DLGPROC)DlgProc) == FALSE)return Op;
00374  /* Free space occupied by old parameter string */
00375  if(Op != NULL)CALL_FREE(Op);  /* free the old string */
00376  /* print the parameters into the buffer */
00377  sprintf(buffer,"%s %d %d %f %d %X %f %f %f %f %f %f %f %d %d %d %d %d %d",name, seed, launchframe, expmax,
00378               sparks, colour, Xstart, Ystart, Zstart, Xexp, Yexp, Zexp, ground,
00379               id1, id2, source, target, type, ruler);
00380  /* Prepare the output buffer to take copy of parameter list */
00381  if((Op=(char *)CALL_MALLOC(strlen(buffer)+1)) == NULL){
00382   MessageBox (GetFocus(),"External effect: Out of memory","Error",
00383                 MB_OK|MB_TASKMODAL|MB_ICONSTOP);
00384    return NULL;
00385  }
00386  /* Copy the parameter string to the output buffer */
00387  strcpy(Op,buffer);
00388  return Op;
00389 }
00390 
00391 static void LoadAnimatedClip(HWND hDlg){
00392  char *c,modname[256];
00393  GetModuleFileName(hDLLinstance,modname,255);
00394  if((c=strrchr(modname,'.')) != NULL){
00395    strcpy(c,".avi");
00396    Animate_Open(GetDlgItem(hDlg,DLG_IMAGE),modname);
00397    Animate_Play(GetDlgItem(hDlg,DLG_IMAGE),0, -1, -1);
00398  }
00399 }
00400 
00401 BOOL CALLBACK DlgProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam){
00402  CHOOSECOLOR cs;
00403  PAINTSTRUCT ps;
00404  char str[32];
00405  char test[32];
00406  switch( msg ) {
00407    case WM_INITDIALOG:
00408      /* prime dialog box controls     */
00409      if(source==TRUE){
00410     SendDlgItemMessage(hwnd,DLG_RADFIXED,BM_SETCHECK,1,0);
00411    }else{
00412     SendDlgItemMessage(hwnd,DLG_RADNAMED,BM_SETCHECK,1,0);
00413    }
00414    if(target==TRUE){
00415     SendDlgItemMessage(hwnd,DLG_TARFIXED,BM_SETCHECK,1,0);
00416    }else{
00417       SendDlgItemMessage(hwnd,DLG_TARNAMED,BM_SETCHECK,1,0);
00418    }
00419    switch(type){
00420     case 0:
00421       SendDlgItemMessage(hwnd,DLG_NORMAL,BM_SETCHECK,1,0);
00422       break;
00423     case 1:
00424       SendDlgItemMessage(hwnd,DLG_FOUNTAIN,BM_SETCHECK,1,0);
00425       break;
00426     case 2:
00427       SendDlgItemMessage(hwnd,DLG_TWINKLE,BM_SETCHECK,1,0);
00428       break;
00429     default:
00430       break;
00431    }
00432    if(id1>=1)SendDlgItemMessage(hwnd,IDC_SNAME,WM_SETTEXT,0,
00433               (LPARAM)GetActorsName(lpLocalEVI->lpAni,id1));
00434    if(id2>=1)SendDlgItemMessage(hwnd,IDC_TNAME,WM_SETTEXT,0,
00435               (LPARAM)GetActorsName(lpLocalEVI->lpAni,id2));
00436   
00437    sprintf(str,"%d",seed);
00438      SetDlgItemText(hwnd,DLG_SEED,str);
00439    sprintf(str,"%d",launchframe);
00440      SetDlgItemText(hwnd,DLG_FRAME,str);
00441    sprintf(str,"%.3f",expmax);
00442    SetDlgItemText(hwnd,DLG_RADIUS,str);
00443    sprintf(str,"%d",sparks);
00444    SetDlgItemText(hwnd,DLG_SPARK,str);
00445    sprintf(str,"%.3f",Xstart);
00446    SetDlgItemText(hwnd,DLG_XSTART,str);
00447    sprintf(str,"%.3f",Ystart);
00448    SetDlgItemText(hwnd,DLG_YSTART,str);
00449    sprintf(str,"%.3f",Zstart);
00450    SetDlgItemText(hwnd,DLG_ZSTART,str);
00451    sprintf(str,"%.3f",Xexp);
00452    SetDlgItemText(hwnd,DLG_XEXP,str);
00453    sprintf(str,"%.3f",Yexp);
00454    SetDlgItemText(hwnd,DLG_YEXP,str);
00455    sprintf(str,"%.3f",Zexp);
00456    SetDlgItemText(hwnd,DLG_ZEXP,str);
00457    sprintf(str,"%.3f",ground);
00458    SetDlgItemText(hwnd,DLG_GROUND,str);
00459      LoadAnimatedClip(hwnd);
00460    CentreDialogOnScreen(hwnd);
00461      return TRUE;
00462    case WM_PAINT:
00463      PaintBackground(hwnd);
00464      break;
00465      return TRUE;
00466    case WM_COMMAND:
00467      switch(LOWORD(wparam)){
00468         case IDCANCEL:    /* user clicked cancel                            */
00469           EndDialog(hwnd,FALSE);
00470           return(TRUE);
00471     case DLG_COLOUR:
00472       cs.lStructSize=sizeof(CHOOSECOLOR);
00473       cs.hwndOwner=hwnd;
00474       cs.lpCustColors =(LPDWORD) acrCustClr;
00475       cs.Flags=CC_FULLOPEN;
00476       ChooseColor(&cs);
00477       colour=cs.rgbResult;
00478       FillColourRect(hwnd,colour);
00479       return (TRUE);
00480     case DLG_RADFIXED:
00481       source=TRUE;
00482       return (TRUE);
00483     case DLG_RADNAMED:
00484       source=FALSE;
00485       return (TRUE);
00486     case DLG_TARFIXED:
00487       target=TRUE;
00488       return (TRUE);
00489     case DLG_TARNAMED:
00490       target=FALSE;
00491       return (TRUE);
00492     case DLG_NORMAL:
00493       type=0;
00494       return (TRUE);
00495     case DLG_FOUNTAIN:
00496       type=1;
00497       return (TRUE);
00498     case DLG_TWINKLE:
00499       type=2;
00500       return (TRUE);
00501     case DLG_CHOOSELAUNCH:
00502       id1=GetActorsID(lpLocalEVI->lpAni,hwnd);
00503       if (id1>=0)SendDlgItemMessage(hwnd,IDC_SNAME,WM_SETTEXT,0,
00504               (LPARAM)GetActorsName(lpLocalEVI->lpAni,id1));
00505       return (TRUE);
00506     case DLG_CHOOSEEXP:
00507       id2=GetActorsID(lpLocalEVI->lpAni,hwnd);
00508       if (id2>=0)SendDlgItemMessage(hwnd,IDC_TNAME,WM_SETTEXT,0,
00509               (LPARAM)GetActorsName(lpLocalEVI->lpAni,id2));
00510       return (TRUE);
00511     case DLG_HELP:
00512       if(DialogBox(hDLLinstance,MAKEINTRESOURCE(IDD_HELP),hwnd,
00513               (DLGPROC)DlgHelp)!=1)return(FALSE);
00514       return (TRUE);
00515     case IDOK:        /* OK so get numbers from the Dailog Box controls */
00516          if(GetDlgItemText(hwnd,DLG_SEED,str,12) != 0)
00517             sscanf(str,"%d",&seed);
00518       if(GetDlgItemText(hwnd,DLG_FRAME,str,12) != 0)
00519             sscanf(str,"%d",&launchframe);
00520       if(GetDlgItemText(hwnd,DLG_RADIUS,str,12) != 0)
00521             sscanf(str,"%f",&expmax);
00522       if(GetDlgItemText(hwnd,DLG_SPARK,str,12) != 0)
00523             sscanf(str,"%d",&sparks);
00524       if(GetDlgItemText(hwnd,DLG_XSTART,str,12) !=0)
00525         sscanf(str,"%f",&Xstart);
00526       if(GetDlgItemText(hwnd,DLG_YSTART,str,12) !=0)
00527         sscanf(str,"%f",&Ystart);
00528       if(GetDlgItemText(hwnd,DLG_ZSTART,str,12) !=0)
00529         sscanf(str,"%f",&Zstart);
00530       if(GetDlgItemText(hwnd,DLG_XEXP,str,12) !=0)
00531         sscanf(str,"%f",&Xexp);
00532       if(GetDlgItemText(hwnd,DLG_YEXP,str,12) !=0)
00533         sscanf(str,"%f",&Yexp);
00534       if(GetDlgItemText(hwnd,DLG_ZEXP,str,12) !=0)
00535         sscanf(str,"%f",&Zexp);
00536       if(GetDlgItemText(hwnd,DLG_GROUND,str,12) != 0)
00537             sscanf(str,"%f",&ground);
00538       if (Zstart>Zexp && source==TRUE && target==TRUE){
00539         MessageBox(NULL,"Explosion height must be greater than source height.",NULL,MB_OK);
00540           return(TRUE);
00541 
00542       }else{
00543         EndDialog(hwnd,TRUE);
00544       }
00545         default:
00546           break;
00547       }
00548       break;
00549     default: break;
00550  }
00551  return FALSE;
00552 }
00553 
00554 void FillColourRect(HWND hwnd, DWORD colour){
00555   HDC hdc;
00556   HBRUSH hBrush,hBrushOld;
00557   RECT rect;
00558   POINT point1, point2;
00559 
00560   GetWindowRect(GetDlgItem(hwnd,DLG_COLOUR),&rect);
00561   point1.x=rect.left;
00562   point1.y=rect.top;
00563   point2.x=rect.right;
00564   point2.y=rect.bottom;
00565   ScreenToClient(hwnd,&point1);
00566   ScreenToClient(hwnd,&point2);
00567   rect.left=point1.x+1;
00568   rect.top=point1.y+1;
00569   rect.right=point2.x-1;
00570   rect.bottom=point2.y-1;
00571 
00572   hdc=GetDC(hwnd);
00573   hBrush=CreateSolidBrush(colour);
00574   hBrushOld=SelectObject(hdc,hBrush);
00575   FillRect(hdc,&rect,hBrush);
00576   SelectObject(hdc,hBrushOld);
00577   DeleteObject(hBrush);
00578   ReleaseDC(hwnd,hdc);
00579 }
00580 
00581 
00582 BOOL CALLBACK DlgHelp(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam){
00583   switch( msg ) {
00584     case WM_INITDIALOG:
00585       CentreDialogOnScreen(hwnd);
00586       return TRUE;
00587     case WM_COMMAND:
00588       switch(LOWORD(wparam)){
00589         case IDCANCEL:    /* user clicked cancel                            */
00590         EndDialog(hwnd,FALSE);
00591         return(TRUE);
00592     case IDOK:        
00593             EndDialog(hwnd,TRUE);
00594         return (TRUE);
00595        default:
00596         break;
00597       }
00598       break;
00599     default: break;
00600  }
00601  return FALSE;
00602 }
00603 

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