explode.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 /* EXPLODE.C */
00025 
00026 #include <math.h>
00027 #include <windows.h>
00028 #include <commctrl.h>
00029 
00030 #include "explode.h"
00031 
00032 #if __ZTC__ || __SC__
00033 #ifndef max
00034 #define max(a,b)  ( ((a) > (b)) ? (a) : (b) )
00035 #endif
00036 #endif
00037 
00038 #ifndef PI
00039 #define PI   3.1415926
00040 #endif
00041 #define PI2  PI/2
00042 
00043 #define VECCOPY(a,b)    { b[0] = a[0]; b[1] = a[1]; b[2] = a[2]; }
00044 #define VECSUM(a,b,c)   { c[0]=a[0]+b[0]; c[1]=a[1]+b[1]; c[2]=a[2]+b[2];}
00045 #define VECSUB(a,b,c)   { c[0]=a[0]-b[0]; c[1]=a[1]-b[1]; c[2]=a[2]-b[2];}
00046 #define VECSCALE(a,b,c) { c[0]=(a)*b[0]; c[1]=(a)*b[1]; c[2]=(a)*b[2];}
00047 #define DOT(a,b)        ( (a[0]*b[0]) + (a[1]*b[1]) + (a[2]*b[2]) )
00048 #define CROSS(v1,v2,r)  { \
00049                           r[0] = (v1[1]*v2[2]) - (v2[1]*v1[2]);  \
00050                           r[1] = (v1[2]*v2[0]) - (v1[0]*v2[2]);  \
00051                           r[2] = (v1[0]*v2[1]) - (v2[0]*v1[1]);  \
00052                         }
00053 #define DIST(a,b)   sqrt(                                           \
00054                          (a[0]-(double)b[0]) * (a[0]-(double)b[0])  \
00055                         +(a[1]-(double)b[1]) * (a[1]-(double)b[1])  \
00056                         +(a[2]-(double)b[2]) * (a[2]-(double)b[2])  \
00057                         )
00058 
00059 #define DIST2(a,b)      (                                           \
00060                          (a[0]-(double)b[0]) * (a[0]-(double)b[0])  \
00061                         +(a[1]-(double)b[1]) * (a[1]-(double)b[1])  \
00062                         +(a[2]-(double)b[2]) * (a[2]-(double)b[2])  \
00063                         )
00064 
00065 int version=1;
00066 
00067 #if __X__MIPS__
00068 BOOL WINAPI _CRT_INIT(HINSTANCE ,DWORD , LPVOID );
00069 #endif
00070 
00071 static HINSTANCE hDLLinstance=NULL; /* use to pick up resources from DLL   */
00072 
00073 #include "pstruct.h"
00074 
00075 static void scal(double t[4][4], double sx, double sy, double sz){
00076  long i,j;
00077  for(i=0;i<4;i++) for(j=0;j<4;j++) t[i][j]=0.0;
00078  t[0][0]=sx; t[1][1]=sy; t[2][2]=sz; t[3][3]=1;
00079  return;
00080 }
00081 
00082 static void rotz(double tr[4][4], double ang){
00083  short i,j;
00084  for(i=0;i<4;i++)
00085  for(j=0;j<4;j++)
00086  {
00087   tr[i][j]=0.0;
00088   if(i == j)tr[i][j]=1.0;
00089  }
00090   tr[0][0]= cos(ang);
00091   tr[0][1]=-sin(ang);
00092   tr[1][0]= sin(ang);
00093   tr[1][1]= cos(ang);
00094   return;
00095 }
00096 
00097 static void roty(double tr[4][4], double ang){
00098  short i,j;
00099  for(i=0;i<4;i++)
00100  for(j=0;j<4;j++)
00101  {
00102   tr[i][j]=0.0;
00103   if(i == j)tr[i][j]=1.0;
00104  }
00105   tr[0][0]= cos(ang);
00106   tr[0][2]=-sin(ang);
00107   tr[2][0]= sin(ang);
00108   tr[2][2]= cos(ang);
00109   return;
00110 }
00111 
00112 static void rotx(double tr[4][4], double ang){
00113  long i,j;
00114  for(i=0;i<4;i++)
00115  for(j=0;j<4;j++)
00116  {
00117   tr[i][j]=0.0;
00118   if(i == j)tr[i][j]=1.0;
00119  }
00120   tr[1][1]= cos(ang);
00121   tr[1][2]=-sin(ang);
00122   tr[2][1]= sin(ang);
00123   tr[2][2]= cos(ang);
00124   return;
00125 }
00126 
00127 static void tram(double t[4][4], double dx, double dy, double dz){
00128  short i,j;
00129  for(i=0;i<4;i++)
00130  for(j=0;j<4;j++)
00131  {
00132   t[i][j]=0.0;
00133   if(i == j)t[i][j]=1.0;
00134  }
00135  t[0][3]=dx;
00136  t[1][3]=dy;
00137  t[2][3]=dz;
00138  t[3][3]=1;
00139  return;
00140 }
00141 
00142 static void m4by4(double t1[4][4], double t2[4][4], double tr[4][4]){
00143  short n=4,i,j,k;
00144  for(i=0;i<4;i++)
00145  for(j=0;j<4;j++)
00146  {
00147   tr[i][j]=0.0;
00148   for(k=0;k<4;k++)tr[i][j]=tr[i][j]+t1[i][k]*t2[k][j];
00149  }
00150  return;
00151 }
00152 
00153 static void m4by1(double t4[4][4], vector v, vector vv){
00154  vv[0]=t4[0][0]*v[0]+t4[0][1]*v[1]+t4[0][2]*v[2]+t4[0][3];
00155  vv[1]=t4[1][0]*v[0]+t4[1][1]*v[1]+t4[1][2]*v[2]+t4[1][3];
00156  vv[2]=t4[2][0]*v[0]+t4[2][1]*v[1]+t4[2][2]*v[2]+t4[2][3];
00157  return;
00158 }
00159 
00160 static void c4to4(double tin[4][4], double tout[4][4]){
00161  short i,j;
00162  for(i=0;i<4;i++)
00163  for(j=0;j<4;j++)
00164  tout[i][j]=tin[i][j];
00165 }
00166 
00167 static void null_transform(double t[4][4]){
00168  short i,j;
00169  for(i=0;i<4;i++)
00170  for(j=0;j<4;j++)
00171  if(i == j)t[i][j]=1.0;
00172  else      t[i][j]=0.0;
00173 }
00174 
00175 static void rotate_round_vector(double angle, vector v, double t[4][4]){
00176   double dx,dy,dz,phi,theta,dxy;
00177   double t1[4][4],t2[4][4],t3[4][4];
00178   angle *= PI/180.0;
00179   dx=v[0]; dy=v[1]; dz=v[2];
00180   dxy=dx*dx+dy*dy;
00181   if(dxy < 0.00001){ /* vertical so just rotate about z  and return */
00182     if(dz > 0.0)rotz(t, angle);
00183     else        rotz(t,-angle);
00184     return;
00185   }
00186   dxy=sqrt(dxy);
00187   if     (dx == 0.0 && dy > 0.0)phi =  PI2;
00188   else if(dx == 0.0 && dy < 0.0)phi = -PI2;
00189   else phi = atan2(dy,dx);
00190   theta = atan2(dz,dxy);
00191   rotz(t3, -phi);
00192   roty(t2, -theta);
00193   m4by4(t2,t3,t1);
00194   rotx(t2, angle);
00195   m4by4(t2,t1,t3);
00196   roty(t2,theta);
00197   m4by4(t2,t3,t1);
00198   rotz(t2,phi);
00199   m4by4(t2,t1,t);
00200 }
00201 
00202 static BOOL normalise(vector v){
00203   double n,nn;
00204   n= (double)((v[0]*v[0]) + (v[1]*v[1]) + (v[2]*v[2]));
00205   if(n < 1.e-10)return FALSE;
00206   nn=sqrt(n);
00207   n = 1.0 / nn;
00208   VECSCALE(n,v,v)
00209   return TRUE;
00210 }
00211 
00212 #include "paint.c"
00213 
00214 #if __WATCOMC__
00215 int APIENTRY LibMain(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00216 #else
00217 BOOL WINAPI DllMain(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00218 #endif
00219   switch (dwReason) {
00220     case DLL_PROCESS_ATTACH:
00221 #if __X__MIPS__
00222       if(!_CRT_INIT(hDLL,dwReason,lpReserved))return(int)FALSE;
00223 #endif
00224       hDLLinstance = hDLL;  /* handle to DLL file */
00225       break;
00226     case DLL_PROCESS_DETACH:
00227 #if __X__MIPS__
00228       if(!_CRT_INIT(hDLL,dwReason,lpReserved))return(int)FALSE;
00229 #endif
00230       break;
00231   }
00232 return (int)TRUE;
00233 }
00234 
00235 #if __SC__
00236 #pragma startaddress(LibMain)
00237 #endif
00238 
00239 static double GetT(double shock, double t, vector dv,
00240                    double dmin, double dmax){
00241  double d;
00242  d=sqrt(dv[0]*dv[0]+dv[1]*dv[1]+dv[2]*dv[2]);
00243  d=(d-dmin)*dmax;
00244  if(t < d)return 0.0;
00245  return t=t-d;
00246 }
00247 
00248 
00249 static void GetSpin(int type, vector p, vector d, double t, double spin[4][4]){
00250  static vector up={0.0,0.0,1.0};
00251  vector a;
00252  double angle;
00253  if(type == 0)VECCOPY(up,a)
00254  else{
00255    CROSS(d,up,a)
00256    if(!normalise(a))VECCOPY(up,a)  /* a is axis of rotation */
00257  }
00258  angle = t*360.0;
00259  rotate_round_vector(angle,a,spin);
00260  return;
00261 }
00262 
00263 static void SpinIntoPosition(vector pp, vector dd, vector dp, double flr,
00264                              double spin[4][4], long type){
00265  vector dpp;
00266  m4by1(spin,dp,dpp);
00267  VECSUM(pp,dpp,dp)
00268  if(type == 2)dp[2]=max(dp[2],flr);
00269  return;
00270 }
00271 
00272 static void GetVandA(double df, double dex, long type,
00273                      double *V, double *A){
00274  if(type == 0){  // assumes velocity falls to zero at end
00275    *V = 2.0*dex;
00276    *A = 0.0;
00277  }
00278  else{
00279    *A = sqrt(2.0*dex) + sqrt(2.0*(dex+df));
00280    *A = (*A) * (*A);
00281    *V = sqrt(2.0*(*A)*dex);
00282  }
00283  return;
00284 }
00285 
00286 static void GetPosition(vector p, vector d, vector po,
00287                         double df, double dex, double t,
00288                         double V, double A, double floor,
00289                         vector pp, vector dd, long type){
00290  // p is face centroid
00291  // d is out direction normalised
00292  // pp is new face centroid position
00293  // dd is new direction  not used
00294  // po is original position
00295  // t is interpolation time
00296  // df is distance
00297  // V is initial velocity
00298  // A is acceleration due to gravity
00299  if(type == 0){
00300    VECCOPY(d,dd)
00301    VECSCALE(V*t*(1.0-0.5*t),d,pp)
00302    VECSUM(p,pp,pp)
00303  }
00304  else{
00305    double ca,sa,r,ti,c;
00306    vector dxy;
00307    dxy[0]=d[0]; dxy[1]=d[1]; dxy[2]=0.0;
00308    normalise(dxy); ca=DOT(d,dxy);
00309    sa=sqrt(1.0 - ca*ca); if(p[2] < po[2])sa = -sa;
00310    c=(V*V*sa*sa - 2.0*A*(floor-p[2]));
00311    if(c >= 0){// if before first bounce fall through
00312      if(c > 0)c=sqrt(c);
00313      ti = (V*sa + c)/A;
00314      if(t > ti){ // subsequent bounces
00315        double vx,vy,dt;
00316        vector pnew;
00317        r = V*ca*ti;
00318        pnew[0]=p[0]+r*dxy[0];
00319        pnew[1]=p[1]+r*dxy[1];
00320        pnew[2]=p[2]+V*sa*ti-0.5*A*ti*ti;
00321        vx=V*ca; vy=A*ti-V*sa;
00322        V=sqrt(vx*vx+vy*vy);
00323        ca=vx/V; sa=vy/V; V *= 0.5; // attenuation
00324        t=t-ti;
00325        dt=2.0*V*sa/A;
00326        if(ti+dt > 1.0){
00327          VECCOPY(pnew,pp);
00328          pp[2]=max(pp[2],floor); // comment out this line - flat finish
00329          return;
00330        }
00331        if(t > dt)t=dt;
00332        r = V*ca*t;
00333        pp[0]=pnew[0]+r*dxy[0];
00334        pp[1]=pnew[1]+r*dxy[1];
00335        pp[2]=pnew[2]+V*sa*t-0.5*A*t*t;
00336        pp[2]=max(pp[2],floor); // comment out this line for totally flat finish
00337        return;
00338      }
00339    }
00340    r = V*ca*t;
00341    pp[0]=p[0]+r*dxy[0];
00342    pp[1]=p[1]+r*dxy[1];
00343    pp[2]=p[2]+V*sa*t-0.5*A*t*t;
00344    pp[2]=max(pp[2],floor); // comment out this line for totally flat finish
00345  }
00346  return;
00347 }
00348 
00349 static void MoveIntoPosition(vector pp, vector dd, vector dp, double flr,
00350                              long type){
00351  VECSUM(pp,dp,dp)
00352  if(type == 2)dp[2]=max(dp[2],flr);
00353  return;
00354 }
00355 
00356 long _RenderGlobalEffect
00357 (char *PrmList, sfxinfo *SFXinfo, sfxdata *SFXdata, vertex *Vlist){
00358  long Nv;
00359  char buffer[128];
00360  long i,type,x,y,z,idf,idex,icentre,ifix,itumble,ishock,tumbletype;
00361  double t,tt,df,dex,V,A,spin[4][4],floor,zmax,dmin,dmax,di,shock;
00362  vector p,pp,po,d,dd,d0,d1,d2;
00363 #include "pro_key.c"
00364  sscanf(PrmList,"%s %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld",
00365   buffer,&version,&type,&x,&y,&z,&idf,&idex,&icentre,&ifix,&itumble,
00366   &ishock,&tumbletype);
00367  shock=(double)ishock/100.0;
00368  if(icentre == 1){ // centre on given point
00369    po[0]=(double)x; po[1]=(double)y; po[2]=(double)z;
00370  }
00371  else VECCOPY((double)SFXdata->pos,po)
00372  df=(double)idf; dex=(double)idex;
00373  if(type == 2){ // fall to ground
00374   if(SFXdata->ground)df=po[2]-(double)SFXdata->ground_pos[2];
00375  }
00376  floor=po[2]-df-10.0;  // just above the floor
00377  Nv=SFXinfo->nvert;
00378  if(ifix == 1)t=1.0;             // go straight to end
00379  else t=(double)SFXinfo->time;   // is on a 0-1 scale
00380  if((Nv/3)*3 != Nv)return 1;     // must be multiple of 3 after split
00381  if(type > 0 || ishock > 0){
00382    dmax = zmax = -1.e20; dmin = 1.e30;
00383    for(i=0;i<Nv;i++){
00384      di=DIST2(po,Vlist[i].p); if(di > dmax)dmax=di; if(di < dmin)dmin=di;
00385      if((double)Vlist[i].p[2] > zmax)zmax=(double)Vlist[i].p[2];
00386    }
00387    if(dmax-dmin < 100.0)ishock=0;   // no difference
00388    else {
00389      dmin=sqrt(dmin); dmax=shock/(sqrt(dmax)-dmin);
00390    }
00391    if(type > 0)df += (zmax - po[2]);
00392  }
00393  GetVandA(df,dex,type,&V,&A);
00394  for(i=0;i<Nv;i+=3){        // for each face
00395    VECSUM((double)Vlist[i].p,(double)Vlist[i+1].p,p)
00396    VECSUM((double)Vlist[i+2].p,p,p)
00397    VECSCALE(0.333,p,p)
00398    VECSUB((double)Vlist[i  ].p,p,d0)
00399    VECSUB((double)Vlist[i+1].p,p,d1)
00400    VECSUB((double)Vlist[i+2].p,p,d2)
00401    VECSUB(p,po,d)                               // -> from centre of exp
00402    if(ishock > 0)tt=GetT(shock,t,d,dmin,dmax);
00403    else          tt=t;
00404    if(!normalise(d))MessageBeep(MB_OK);
00405    GetPosition(p,d,po,df,dex,tt,V,A,floor,pp,dd,type);
00406    if(itumble == 0){
00407      MoveIntoPosition(pp,dd,d0,floor,type);  // d0 will be new vertex posn
00408      MoveIntoPosition(pp,dd,d1,floor,type);
00409      MoveIntoPosition(pp,dd,d2,floor,type);
00410    }
00411    else{
00412      GetSpin(tumbletype,p,d,tt,spin);
00413      SpinIntoPosition(pp,dd,d0,floor,spin,type);  // d0 will be new vertex posn
00414      SpinIntoPosition(pp,dd,d1,floor,spin,type);
00415      SpinIntoPosition(pp,dd,d2,floor,spin,type);
00416    }
00417    VECCOPY((long)d0,Vlist[i].p)
00418    VECCOPY((long)d1,Vlist[i+1].p)
00419    VECCOPY((long)d2,Vlist[i+2].p)
00420  }
00421  return 1;
00422 }
00423 
00424 void _PreviewGlobalEffect
00425 (char *PrmList, sfxinfo *SFXinfo, sfxdata *SFXdata, Svertex *Vlist){
00426  long Nv;
00427  char buffer[128];
00428  long i,type,x,y,z,idf,idex,icentre,ifix,itumble,ishock,tumbletype;
00429  double t,tt,df,dex,V,A,spin[4][4],floor,zmax,shock,dmin,dmax,di;
00430  vector p,pp,po,d,dd,d0,d1,d2;
00431 #include "pro_key1.c"
00432  sscanf(PrmList,"%s %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld",
00433   buffer,&version,&type,&x,&y,&z,&idf,&idex,&icentre,&ifix,&itumble,
00434   &ishock,&tumbletype);
00435  shock=(double)ishock/100.0;
00436  if(icentre == 1){ // centre on given point
00437    po[0]=(double)x; po[1]=(double)y; po[2]=(double)z;
00438  }
00439  else VECCOPY((double)SFXdata->pos,po)
00440  df=(double)idf; dex=(double)idex;
00441  if(type == 2){ // fall to ground
00442   if(SFXdata->ground)df=po[2]-(double)SFXdata->ground_pos[2];
00443  }
00444  floor=po[2]-df-10.0;  // just above the floor
00445  Nv=SFXinfo->nvert;
00446  if(ifix == 1)t=1.0;             // go straight to end
00447  else t=(double)SFXinfo->time;   // is on a 0-1 scale
00448  if((Nv/3)*3 != Nv)return;       // must be multiple of 3 after split
00449  if(type > 0 || ishock > 0){
00450    dmax = zmax = -1.e20; dmin = 1.e30;
00451    for(i=0;i<Nv;i++){
00452      if(ishock > 0){
00453        di=DIST2(po,Vlist[i]); if(di > dmax)dmax=di; if(di < dmin)dmin=di;
00454      }
00455      if((double)Vlist[i][2] > zmax)zmax=(double)Vlist[i][2];
00456    }
00457    if(dmax-dmin < 100.0)ishock=0;   // no difference
00458    else {
00459      dmin=sqrt(dmin); dmax=shock/(sqrt(dmax)-dmin);
00460    }
00461    if(type > 0)df += (zmax - po[2]);
00462  }
00463  GetVandA(df,dex,type,&V,&A);
00464  for(i=0;i<Nv;i+=3){        // for each face
00465    VECSUM((double)Vlist[i],(double)Vlist[i+1],p)
00466    VECSUM((double)Vlist[i+2],p,p)
00467    VECSCALE(0.333,p,p)
00468    VECSUB((double)Vlist[i  ],p,d0)
00469    VECSUB((double)Vlist[i+1],p,d1)
00470    VECSUB((double)Vlist[i+2],p,d2)
00471    VECSUB(p,po,d)                               // -> from centre of exp
00472    if(ishock > 0)tt=GetT(shock,t,d,dmin,dmax);
00473    else          tt=t;
00474    if(!normalise(d))MessageBeep(MB_OK);
00475    GetPosition(p,d,po,df,dex,tt,V,A,floor,pp,dd,type);
00476    if(itumble == 0){
00477      MoveIntoPosition(pp,dd,d0,floor,type);  // d0 will be new vertex posn
00478      MoveIntoPosition(pp,dd,d1,floor,type);
00479      MoveIntoPosition(pp,dd,d2,floor,type);
00480    }
00481    else{
00482      GetSpin(tumbletype,p,d,tt,spin);
00483      SpinIntoPosition(pp,dd,d0,floor,spin,type);  // d0 will be new vertex posn
00484      SpinIntoPosition(pp,dd,d1,floor,spin,type);
00485      SpinIntoPosition(pp,dd,d2,floor,spin,type);
00486    }
00487    VECCOPY((long)d0,Vlist[i])
00488    VECCOPY((long)d1,Vlist[i+1])
00489    VECCOPY((long)d2,Vlist[i+2])
00490  }
00491  return;
00492 }
00493 
00494 long _RenderExternalEffect(char *PrmList, sfxinfo *SFXinfo,
00495                                  vertex *Vlist){
00496 #if 0
00497  long i;   // testing face accesibility
00498  face *f;
00499  char buffer[128];
00500 #include "pro_key.c"
00501  sscanf(PrmList,"%s %d",buffer,&version);
00502  if(SFXinfo->Nfaces > 0 && SFXinfo->Faces != NULL){
00503    f=(face *)SFXinfo->Faces;
00504    for(i=0;i<SFXinfo->Nfaces;i++){
00505      f->color[0]=255; f->color[1] = f->color[2] = 0;
00506      f++;
00507    }
00508  }
00509 #endif
00510  return 1;
00511 }
00512 
00513 void _PreviewExternalEffect(char *PrmList, sfxinfo *SFXinfo,
00514                                     Svertex *Vlist){
00515  return;
00516 }
00517 
00518 static long ix,iy,iz,type=0,idf,idex,icentre=0,ifix=0,itumble=0,
00519             shock=0,tumbletype=0;
00520 double df=1.0,dex=1.0,x=0.0,y=0.0,z=0.0;
00521 
00522 BOOL CALLBACK EffectDlgProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam);
00523 
00524 char * _SetExternalParameters(
00525   char *Op,                 /* string for the parameters                  */
00526   HWND hWnd,                /* parent window                              */
00527   long ruler,               /* ruler scale value to facilitate scaling    */
00528   char *name,               /* name of DLL file with the effect           */
00529   X__MEMORY_MANAGER *lpEVI /* pointer to structure with memory functions */
00530                                     ){
00531  char buffer[128];
00532  if(Op != NULL){  /* parameters exist so read them off the list */
00533    sscanf(Op,"%s %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld",buffer,&version,
00534           &type,&ix,&iy,&iz,&idf,&idex,&icentre,&ifix,&itumble,&shock,
00535           &tumbletype);
00536    df=(double)idf/(double)ruler;
00537    dex=(double)idex/(double)ruler;
00538    x=(double)ix/(double)ruler;
00539    y=(double)iy/(double)ruler;
00540    z=(double)iz/(double)ruler;
00541  }
00542  if(DialogBox(hDLLinstance,MAKEINTRESOURCE(DLG_EXPLODE),hWnd,
00543               (DLGPROC)EffectDlgProc) == FALSE)return Op;
00544  if(Op != NULL)CALL_FREE(Op);  /* free the old string */
00545  idf=df*(double)ruler;
00546  idex=dex*(double)ruler;
00547  ix=x*(double)ruler;
00548  iy=y*(double)ruler;
00549  iz=z*(double)ruler;
00550  sprintf(buffer,"%s %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld",
00551          name,version,type,ix,iy,iz,idf,idex,icentre,ifix,itumble,
00552          shock,tumbletype);
00553  if((Op=(char *)CALL_MALLOC(strlen(buffer)+1)) == NULL){
00554   MessageBox (GetFocus(),"External effect: Out of memory",NULL,
00555                 MB_OK|MB_TASKMODAL|MB_ICONSTOP);
00556    return NULL;
00557  }
00558  strcpy(Op,buffer);
00559  return Op;
00560 }
00561 
00562 BOOL CALLBACK EffectDlgProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam){
00563  BOOL err;
00564  char str[16];
00565  switch( msg ) {
00566    case WM_INITDIALOG:
00567      if(type == 0)
00568        SendDlgItemMessage(hwnd,DLG_EXPLODE_TYPE0,BM_SETCHECK,TRUE,0);
00569      if(type == 1)
00570        SendDlgItemMessage(hwnd,DLG_EXPLODE_TYPE1,BM_SETCHECK,TRUE,0);
00571      if(type == 2)
00572        SendDlgItemMessage(hwnd,DLG_EXPLODE_TYPE2,BM_SETCHECK,TRUE,0);
00573      if(icentre == 0)
00574        SendDlgItemMessage(hwnd,DLG_EXPLODE_CENTRE,BM_SETCHECK,TRUE,0);
00575      if(icentre == 1)
00576        SendDlgItemMessage(hwnd,DLG_EXPLODE_POINT,BM_SETCHECK,TRUE,0);
00577      if(itumble == 1)
00578        SendDlgItemMessage(hwnd,DLG_EXPLODE_TUMBLE,BM_SETCHECK,TRUE,0);
00579      if(tumbletype == 0)
00580        SendDlgItemMessage(hwnd,DLG_EXPLODE_TTYPE0,BM_SETCHECK,TRUE,0);
00581      if(tumbletype == 1)
00582        SendDlgItemMessage(hwnd,DLG_EXPLODE_TTYPE1,BM_SETCHECK,TRUE,0);
00583      if(ifix == 1)
00584        SendDlgItemMessage(hwnd,DLG_EXPLODE_FIX,BM_SETCHECK,TRUE,0);
00585      sprintf(str,"%.2f",x);
00586      SetDlgItemText(hwnd,DLG_EXPLODE_X,str);
00587      sprintf(str,"%.2f",y);
00588      SetDlgItemText(hwnd,DLG_EXPLODE_Y,str);
00589      sprintf(str,"%.2f",z);
00590      SetDlgItemText(hwnd,DLG_EXPLODE_Z,str);
00591      sprintf(str,"%.2f",df);
00592      SetDlgItemText(hwnd,DLG_EXPLODE_FALLD,str);
00593      sprintf(str,"%.2f",dex);
00594      SetDlgItemText(hwnd,DLG_EXPLODE_DEX,str);
00595      SetDlgItemInt(hwnd,DLG_EXPLODE_SHOCK,shock,FALSE);
00596      LoadAnimatedClip(hwnd);
00597      CentreDialogOnScreen(hwnd);
00598      return TRUE;
00599    case WM_PAINT:
00600      PaintBackground(hwnd);
00601      break;
00602    case WM_COMMAND:
00603      switch(LOWORD(wparam)){
00604         case IDCANCEL:
00605           EndDialog(hwnd,FALSE);
00606           return(TRUE);
00607         case IDOK:
00608           if(SendDlgItemMessage(hwnd,DLG_EXPLODE_TYPE2,BM_GETCHECK,0,0))
00609             type=2;
00610           else if(SendDlgItemMessage(hwnd,DLG_EXPLODE_TYPE1,BM_GETCHECK,0,0))
00611             type=1;
00612           else
00613             type=0;
00614           if(SendDlgItemMessage(hwnd,DLG_EXPLODE_POINT,BM_GETCHECK,0,0))
00615             icentre=1;
00616           else
00617             icentre=0;
00618           if(SendDlgItemMessage(hwnd,DLG_EXPLODE_TUMBLE,BM_GETCHECK,0,0))
00619             itumble=1;
00620           else
00621             itumble=0;
00622           if(SendDlgItemMessage(hwnd,DLG_EXPLODE_TTYPE1,BM_GETCHECK,0,0))
00623                tumbletype=1;
00624           else tumbletype=0;
00625           if(SendDlgItemMessage(hwnd,DLG_EXPLODE_FIX,BM_GETCHECK,0,0))
00626             ifix=1;
00627           else
00628             ifix=0;
00629           if(GetDlgItemText(hwnd,DLG_EXPLODE_X,str,12) != 0)
00630             x=atof(str);
00631           if(GetDlgItemText(hwnd,DLG_EXPLODE_Y,str,12) != 0)
00632             y=atof(str);
00633           if(GetDlgItemText(hwnd,DLG_EXPLODE_Z,str,12) != 0)
00634             z=atof(str);
00635           if(GetDlgItemText(hwnd,DLG_EXPLODE_FALLD,str,12) != 0)
00636             df=atof(str);
00637           if(GetDlgItemText(hwnd,DLG_EXPLODE_DEX,str,12) != 0)
00638             dex=atof(str);
00639           shock=GetDlgItemInt(hwnd,DLG_EXPLODE_SHOCK,&err,FALSE);
00640           EndDialog(hwnd,TRUE);
00641           return(TRUE);
00642         default:
00643           break;
00644       }
00645       break;
00646     default: break;
00647  }
00648  return FALSE;
00649 }
00650 
Generated on Tue Jan 28 06:18:29 2014 for OpenFX by  doxygen 1.6.3