aparticles.c

Go to the documentation of this file.
00001 /*  file aparticles.C  contains all the dialog handler functions */
00002 
00003 
00004 #define MODULE_PARTICLES 1
00005 
00006 #include "animate.h"
00007 #include "spin_dll.h"
00008 
00009 #include "..\render2\particles.h"
00010 
00011 #define NP_BLEND 2
00012 
00013 static char *ParticleBlendList[NP_BLEND]={"Burn","Mix"};
00014 
00015 void InitialiseParticleSystem(ParticleSystem *ps){
00016  ps->blend_model=0; // to allow for dark & light particles
00017  ps->NumP=20;       // particles per second
00018  ps->bSteadyState=FALSE;
00019  ps->bSpinOff=FALSE;
00020  ps->burst=FALSE;
00021  strcpy(ps->ImageName,"cloud");
00022  ps->id=rand();
00023  ps->iid=2;
00024  ps->colour_start[0] = 0.48 *255.0; // scale 0 - 1  integer 0 - 255
00025  ps->colour_start[1] = 0.42 *255.0;
00026  ps->colour_start[2] = 0.10 *255.0;
00027  ps->colour_end[0]   = 0.04 *255.0;
00028  ps->colour_end[1]   = 0.22 *255.0;
00029  ps->colour_end[2]   = 0.81 *255.0;
00030  // variables - 1 - 1000 integer scale
00031  ps->alpha_start= 1000.0* 0.92;            // scale 0 - 1
00032  ps->alpha_end  = 1000.0* 0.14;            // scale 0 - 1
00033  //ps->speed      = 1000.0* 3.0/MAX_SPEED;   // min 0.0
00034  ps->speed      = 1000.0* 9.0/MAX_SPEED;   // min 0.0
00035  ps->life       = 1000.0* 0.6/MAX_LIFETIME;// min 0.1 max MAX_LIFE
00036  ps->theta      = 1000.0* 0.2;             // scale 0 - 1
00037  ps->size_start = 1000.0* 1.04/MAX_SIZE;   // min 0.1
00038  ps->size_end   = 1000.0* 1.08/MAX_SIZE;   // min 0.1
00039  // gravity
00040  ps->ew_start   = ps->ns_start = ps->ud_start = 1000.0*( 0.0 )/(MAX_GRAVITY-MIN_GRAVITY);  // -500 - 500
00041  ps->ew_end     = ps->ns_end   = ps->ud_end   = 1000.0*( 0.0 )/(MAX_GRAVITY-MIN_GRAVITY);  // -500 - 500
00042  // variations
00043  ps->vcolour    = 1000.0* 0.15;   // scale 0 - 1
00044  ps->vspeed     = 1000.0* 0.0/MAX_SPEED;
00045  ps->valpha     = 1000.0* 0.14;
00046  ps->vsize      = 1000.0* 0.04/MAX_SIZE;
00047  ps->vlife      = 1000.0* 0.10/MAX_LIFETIME;
00048  // overall particle scale
00049  ps->particle_size_scale=1000.0*0.5;  // range  0.01  - 1 - 10
00050  ps->particle_speed_scale=1000.0*0.5;
00051 }
00052 
00053 static void SetupParticlePreset(int id, ParticleSystem *ps){
00054  switch(id){
00055    case DLG_PARTICLE_PRESET0:  // starfield
00056     ps->burst=FALSE;
00057     ps->blend_model=0; 
00058     ps->NumP= 80 ; 
00059     strcpy(ps->ImageName,"star"); 
00060     ps->id=rand(); 
00061     ps->iid=4; 
00062     ps->colour_start[0] = 0.81f *255.0;  
00063     ps->colour_start[1] = 0.82f *255.0; 
00064     ps->colour_start[2] = 0.83f *255.0; 
00065     ps->colour_end[0]   = 0.82f *255.0;  
00066     ps->colour_end[1]   = 0.83f *255.0; 
00067     ps->colour_end[2]   = 0.83f *255.0; 
00068     ps->alpha_start= 1000.0* 0.02f; 
00069     ps->alpha_end  = 1000.0* 0.66f; 
00070     ps->speed      = 1000.0* 14.25f/MAX_SPEED;  
00071     ps->life       = 1000.0* 2.25f/MAX_LIFETIME;  
00072     ps->theta      = 1000.0* 0.79f;  
00073     ps->size_start = 1000.0* 0.10f/MAX_SIZE;  
00074     ps->size_end   = 1000.0* 0.20f/MAX_SIZE;  
00075     ps->ew_start   = 1000.0*( 0.00f )/(MAX_GRAVITY-MIN_GRAVITY);  
00076     ps->ew_end     = 1000.0*( 0.00f )/(MAX_GRAVITY-MIN_GRAVITY);   
00077     ps->ns_start   = 1000.0*( 0.00f )/(MAX_GRAVITY-MIN_GRAVITY);  
00078     ps->ns_end     = 1000.0*(-0.44f )/(MAX_GRAVITY-MIN_GRAVITY);   
00079     ps->ud_start   = 1000.0*( 0.00f )/(MAX_GRAVITY-MIN_GRAVITY);  
00080     ps->ud_end     = 1000.0*( 0.00f )/(MAX_GRAVITY-MIN_GRAVITY);   
00081     ps->vcolour    = 1000.0* 0.24f;  
00082     ps->vspeed     = 1000.0* 0.00f/MAX_SPEED; 
00083     ps->valpha     = 1000.0* 0.14f;  
00084     ps->vsize      = 1000.0* 0.28f/MAX_SIZE;  
00085     ps->vlife      = 1000.0* 0.40f/MAX_LIFETIME;   
00086     ps->particle_size_scale=1000.0*0.5; 
00087     break;
00088    case DLG_PARTICLE_PRESET1: // bubbles
00089     ps->blend_model=0; 
00090     ps->burst=FALSE;
00091     ps->NumP= 6 ; 
00092     strcpy(ps->ImageName,"bubble"); 
00093     ps->id=rand(); 
00094     ps->iid=0; 
00095     ps->colour_start[0] = 0.28f *255.0;  
00096     ps->colour_start[1] = 0.29f *255.0; 
00097     ps->colour_start[2] = 0.30f *255.0; 
00098     ps->colour_end[0]   = 0.28f *255.0;  
00099     ps->colour_end[1]   = 0.29f *255.0; 
00100     ps->colour_end[2]   = 0.30f *255.0; 
00101     ps->alpha_start= 1000.0* 0.96f; 
00102     ps->alpha_end  = 1000.0* 0.97f; 
00103     ps->speed      = 1000.0* 3.25f/MAX_SPEED;  
00104     ps->life       = 1000.0* 10.20f/MAX_LIFETIME;  
00105     ps->theta      = 1000.0* 0.16f;  
00106     ps->size_start = 1000.0* 0.12f/MAX_SIZE;  
00107     ps->size_end   = 1000.0* 0.12f/MAX_SIZE;  
00108     ps->ew_start   = 1000.0*( 0.00f )/(MAX_GRAVITY-MIN_GRAVITY);  
00109     ps->ew_end     = 1000.0*( 0.04f )/(MAX_GRAVITY-MIN_GRAVITY);   
00110     ps->ns_start   = 1000.0*( 0.07f )/(MAX_GRAVITY-MIN_GRAVITY);  
00111     ps->ns_end     = 1000.0*( -0.48f )/(MAX_GRAVITY-MIN_GRAVITY);   
00112     ps->ud_start   = 1000.0*( 0.00f )/(MAX_GRAVITY-MIN_GRAVITY);  
00113     ps->ud_end     = 1000.0*( 0.04f )/(MAX_GRAVITY-MIN_GRAVITY);   
00114     ps->vcolour    = 1000.0* 0.85f;  
00115     ps->vspeed     = 1000.0* 0.00f/MAX_SPEED; 
00116     ps->valpha     = 1000.0* 0.01f;  
00117     ps->vsize      = 1000.0* 1.12f/MAX_SIZE;  
00118     ps->vlife      = 1000.0* 0.75f/MAX_LIFETIME;   
00119     ps->particle_size_scale=1000.0*0.5; 
00120     break;
00121    case DLG_PARTICLE_PRESET2: // water drops
00122     ps->blend_model=0; 
00123     ps->burst=FALSE;
00124     ps->NumP= 250; 
00125     strcpy(ps->ImageName,"bubble"); 
00126     ps->id=rand(); 
00127     ps->iid=0; 
00128     ps->colour_start[0] = 0.00f *255.0;  
00129     ps->colour_start[1] = 0.00f *255.0; 
00130     ps->colour_start[2] = 1.00f *255.0; 
00131     ps->colour_end[0]   = 0.32f *255.0;  
00132     ps->colour_end[1]   = 0.47f *255.0; 
00133     ps->colour_end[2]   = 0.96f *255.0; 
00134     ps->alpha_start= 1000.0* 0.8f; 
00135     ps->alpha_end  = 1000.0* 0.92f; 
00136     ps->speed      = 1000.0* 25.0f/MAX_SPEED;  
00137     ps->life       = 1000.0* 8.1f/MAX_LIFETIME;  
00138     ps->theta      = 1000.0* 0.11f;  
00139     ps->size_start = 1000.0* 0.32f/MAX_SIZE;  
00140     ps->size_end   = 1000.0* 0.32f/MAX_SIZE;  
00141     ps->ew_start   = 1000.0*( 0.00f )/(MAX_GRAVITY-MIN_GRAVITY);  
00142     ps->ew_end     = 1000.0*( 0.00f )/(MAX_GRAVITY-MIN_GRAVITY);   
00143     ps->ns_start   = 1000.0*( 0.00f )/(MAX_GRAVITY-MIN_GRAVITY);  
00144     ps->ns_end     = 1000.0*( 0.00f )/(MAX_GRAVITY-MIN_GRAVITY);   
00145     ps->ud_start   = 1000.0*(-0.25f )/(MAX_GRAVITY-MIN_GRAVITY);  
00146     ps->ud_end     = 1000.0*(-0.50f )/(MAX_GRAVITY-MIN_GRAVITY);   
00147     ps->vcolour    = 1000.0* 0.00f;  
00148     ps->vspeed     = 1000.0* 0.00f/MAX_SPEED; 
00149     ps->valpha     = 1000.0* 0.00f;  
00150     ps->vsize      = 1000.0* 0.00f/MAX_SIZE;  
00151     ps->vlife      = 1000.0* 0.09f/MAX_LIFETIME;   
00152     ps->particle_size_scale=1000.0*0.5; 
00153     break;
00154    case DLG_PARTICLE_PRESET3:
00155      ps->blend_model=0; 
00156      ps->burst=FALSE;
00157      ps->NumP=60;   // flames
00158      ps->bSteadyState=FALSE;
00159      ps->bSpinOff=FALSE;
00160      strcpy(ps->ImageName,"cloud");
00161      ps->id=rand();
00162      ps->iid=2;
00163      ps->colour_start[0] = 0.48 *255.0;
00164      ps->colour_start[1] = 0.42 *255.0;
00165      ps->colour_start[2] = 0.10 *255.0;
00166      ps->colour_end[0]   = 0.04 *255.0;
00167      ps->colour_end[1]   = 0.22 *255.0;
00168      ps->colour_end[2]   = 0.81 *255.0;
00169      ps->alpha_start= 1000.0* 0.92;        
00170      ps->alpha_end  = 1000.0* 0.14;           
00171      ps->speed      = 1000.0* 3.0/MAX_SPEED;  
00172      ps->life       = 1000.0* 3.75/MAX_LIFETIME;// min 0.1 max MAX_LIFE
00173      ps->theta      = 1000.0* 0.2;             // scale 0 - 1
00174      ps->size_start = 1000.0* 0.48/MAX_SIZE;   // min 0.1
00175      ps->size_end   = 1000.0* 0.12/MAX_SIZE;   // min 0.1
00176      ps->ew_start   = ps->ns_start = 1000.0*( 0.0 )/(MAX_GRAVITY-MIN_GRAVITY);  // -500 - 500
00177      ps->ew_end     = ps->ns_end   = 1000.0*( 0.0 )/(MAX_GRAVITY-MIN_GRAVITY);  // -500 - 500
00178      ps->ud_start   = 1000.0*( 0.08 )/(MAX_GRAVITY-MIN_GRAVITY);  // -500 - 500
00179      ps->ud_end     = 1000.0*(-0.09 )/(MAX_GRAVITY-MIN_GRAVITY);  // -500 - 500
00180      ps->vcolour    = 1000.0* 0.15;  
00181      ps->vspeed     = 1000.0* 1.2/MAX_SPEED;
00182      ps->valpha     = 1000.0* 0.14;
00183      ps->vsize      = 1000.0* 0.04/MAX_SIZE;
00184      ps->vlife      = 1000.0* 0.10/MAX_LIFETIME;
00185      ps->particle_size_scale=1000.0*0.5;  
00186      ps->particle_speed_scale=1000.0*0.5;
00187      break;
00188    case DLG_PARTICLE_PRESET4: // big_flames
00189      ps->blend_model=0; 
00190      ps->burst=FALSE;
00191      ps->NumP= 140 ; 
00192      strcpy(ps->ImageName,"cloud"); 
00193      ps->id=rand(); 
00194      ps->iid=2; 
00195      ps->colour_start[0] = 0.06f *255.0;  
00196      ps->colour_start[1] = 0.05f *255.0; 
00197      ps->colour_start[2] = 0.18f *255.0; 
00198      ps->colour_end[0]   = 0.52f *255.0;  
00199      ps->colour_end[1]   = 0.29f *255.0; 
00200      ps->colour_end[2]   = 0.04f *255.0; 
00201      ps->alpha_start= 1000.0* 0.96f; 
00202      ps->alpha_end  = 1000.0* 0.03f; 
00203      ps->speed      = 1000.0* 9.75f/MAX_SPEED;  
00204      ps->life       = 1000.0* 6.30f/MAX_LIFETIME;  
00205      ps->theta      = 1000.0* 0.14f;  
00206      ps->size_start = 1000.0* 0.90f/MAX_SIZE;  
00207      ps->size_end   = 1000.0* 1.98f/MAX_SIZE;  
00208      ps->ew_start   = 1000.0*( 0.00f )/(MAX_GRAVITY-MIN_GRAVITY);  
00209      ps->ew_end     = 1000.0*( 0.00f )/(MAX_GRAVITY-MIN_GRAVITY);   
00210      ps->ns_start   = 1000.0*( -0.08f )/(MAX_GRAVITY-MIN_GRAVITY);  
00211      ps->ns_end     = 1000.0*( 0.12f )/(MAX_GRAVITY-MIN_GRAVITY);   
00212      ps->ud_start   = 1000.0*( 0.00f )/(MAX_GRAVITY-MIN_GRAVITY);  
00213      ps->ud_end     = 1000.0*( 0.00f )/(MAX_GRAVITY-MIN_GRAVITY);   
00214      ps->vcolour    = 1000.0* 0.13f;  
00215      ps->vspeed     = 1000.0* 0.00f/MAX_SPEED; 
00216      ps->valpha     = 1000.0* 0.23f;  
00217      ps->vsize      = 1000.0* 0.46f/MAX_SIZE;  
00218      ps->vlife      = 1000.0* 0.75f/MAX_LIFETIME;   
00219      ps->particle_size_scale=1000.0*0.5; 
00220      break;
00221    case DLG_PARTICLE_PRESET5: // fireworks
00222     ps->burst=TRUE;
00223     ps->blend_model=0; 
00224     ps->NumP= 900; 
00225     strcpy(ps->ImageName,"spark"); 
00226     ps->id=rand(); 
00227     ps->iid=3; 
00228     ps->colour_start[0] = 0.27f *255.0;  
00229     ps->colour_start[1] = 0.93f *255.0; 
00230     ps->colour_start[2] = 0.49f *255.0; 
00231     ps->colour_end[0]   = 0.04f *255.0;  
00232     ps->colour_end[1]   = 0.22f *255.0; 
00233     ps->colour_end[2]   = 0.80f *255.0; 
00234     ps->alpha_start= 1000.0* 0.92f;
00235     ps->alpha_end  = 1000.0* 0.93f; 
00236     ps->speed      = 1000.0* 20.3f/MAX_SPEED;  
00237     ps->life       = 1000.0* 0.9f/MAX_LIFETIME;  
00238     ps->theta      = 1000.0* 0.71f;  
00239     ps->size_start = 1000.0* 0.10f/MAX_SIZE;  
00240     ps->size_end   = 1000.0* 0.10f/MAX_SIZE;  
00241     ps->ew_start   = 1000.0*( 0.00f )/(MAX_GRAVITY-MIN_GRAVITY);  
00242     ps->ew_end     = 1000.0*( 0.00f )/(MAX_GRAVITY-MIN_GRAVITY);   
00243     ps->ns_start   = 1000.0*( 0.20f )/(MAX_GRAVITY-MIN_GRAVITY);  
00244     ps->ns_end     = 1000.0*(-0.50f )/(MAX_GRAVITY-MIN_GRAVITY);   
00245     ps->ud_start   = 1000.0*( 0.00f )/(MAX_GRAVITY-MIN_GRAVITY);  
00246     ps->ud_end     = 1000.0*( 0.00f )/(MAX_GRAVITY-MIN_GRAVITY);   
00247     ps->vcolour    = 1000.0* 0.00f;  
00248     ps->vspeed     = 1000.0* 0.00f/MAX_SPEED; 
00249     ps->valpha     = 1000.0* 0.00f;  
00250     ps->vsize      = 1000.0* 0.00f/MAX_SIZE;  
00251     ps->vlife      = 1000.0* 0.00f/MAX_LIFETIME;   
00252     ps->particle_size_scale=1000.0*0.5; 
00253     break;
00254  }
00255 }
00256 
00257 static void UpdateParticleDialog(HWND hdlg, object*op){
00258      int i,lf,ff,val,nType=NP_IMAGES;
00259      SetDlgItemInt(hdlg,DLG_CSG_FROM,op->firstframe,FALSE);
00260      SetDlgItemInt(hdlg,DLG_CSG_TO,op->lastframe,FALSE);
00261      if(op->last != NULL)ff=op->last->lastframe+1;
00262      else                ff=1;
00263      if(op->next != NULL)lf=op->next->firstframe-1;
00264      else                lf=Nframes;
00265      SendDlgItemMessage(hdlg,DLG_CSG_FROMS,SPNM_SETRANGE,0,
00266                         MAKELPARAM(ff,lf));
00267      SendDlgItemMessage(hdlg,DLG_CSG_FROMS,SPNM_SETCRNTVALUE,
00268                         (WPARAM)op->firstframe,0);
00269      SendDlgItemMessage(hdlg,DLG_CSG_FROMS,SPNM_SETEDITCTRL,0,
00270                         (LPARAM)GetDlgItem(hdlg,DLG_CSG_FROM));
00271      SendDlgItemMessage(hdlg,DLG_CSG_TOS,SPNM_SETRANGE,0,
00272                         MAKELPARAM(ff,lf));
00273      SendDlgItemMessage(hdlg,DLG_CSG_TOS,SPNM_SETCRNTVALUE,
00274                         (WPARAM)op->lastframe,0);
00275      SendDlgItemMessage(hdlg,DLG_CSG_TOS,SPNM_SETEDITCTRL,0,
00276                         (LPARAM)GetDlgItem(hdlg,DLG_CSG_TO));
00277      SetDlgItemInt(hdlg,DLG_PARTICLE_NUMBER,op->particles.NumP,FALSE);
00278      SendDlgItemMessage(hdlg,DLG_PARTICLE_NUMBER_SPIN,SPNM_SETRANGE,0,
00279                         MAKELPARAM(1,65535));
00280      SendDlgItemMessage(hdlg,DLG_PARTICLE_NUMBER_SPIN,SPNM_SETCRNTVALUE,
00281                         (WPARAM)op->particles.NumP,0);
00282      SendDlgItemMessage(hdlg,DLG_PARTICLE_NUMBER_SPIN,SPNM_SETEDITCTRL,0,
00283                         (LPARAM)GetDlgItem(hdlg,DLG_PARTICLE_NUMBER));
00284      if(op->particles.burst){
00285        SendDlgItemMessage(hdlg,DLG_PARTICLE_BURST,BM_SETCHECK,TRUE,0);
00286        SendDlgItemMessage(hdlg,DLG_PARTICLE_FLOW,BM_SETCHECK,FALSE,0);
00287      }
00288      else {
00289        SendDlgItemMessage(hdlg,DLG_PARTICLE_FLOW,BM_SETCHECK,TRUE,0);
00290        SendDlgItemMessage(hdlg,DLG_PARTICLE_BURST,BM_SETCHECK,FALSE,0);
00291      }
00292      if(op->particles.bSteadyState)
00293        SendDlgItemMessage(hdlg,DLG_PARTICLE_STEADY_STATE,BM_SETCHECK,TRUE,0);
00294      else 
00295        SendDlgItemMessage(hdlg,DLG_PARTICLE_STEADY_STATE,BM_SETCHECK,FALSE,0);
00296      if(op->particles.bSpinOff)
00297        SendDlgItemMessage(hdlg,DLG_PARTICLE_SPIN_OFF,BM_SETCHECK,TRUE,0);
00298      else 
00299        SendDlgItemMessage(hdlg,DLG_PARTICLE_SPIN_OFF,BM_SETCHECK,FALSE,0);
00300 
00301      if(op->particles.bSingle)
00302        SendDlgItemMessage(hdlg,DLG_PARTICLE_SINGLE,BM_SETCHECK,TRUE,0);
00303      else 
00304        SendDlgItemMessage(hdlg,DLG_PARTICLE_SINGLE,BM_SETCHECK,FALSE,0);
00305 
00306      // parameters
00307 
00308      SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_SIZE_SCALE),
00309        TBM_SETRANGE,(WPARAM)TRUE,(LPARAM)MAKELONG(0,100));
00310      val=op->particles.particle_size_scale/10; // all scaled 0 - 1000 - ranged [0-100]
00311      SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_SIZE_SCALE),TBM_SETPOS,TRUE,(LPARAM)val);
00312 
00313      SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_SIZE),
00314        TBM_SETRANGE,(WPARAM)TRUE,(LPARAM)MAKELONG(0,100));
00315      val=op->particles.size_start/10; // all scaled 0 - 1000 - ranged [0-100]
00316      SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_SIZE),TBM_SETPOS,TRUE,(LPARAM)val);
00317      SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_SIZE_END),
00318        TBM_SETRANGE,(WPARAM)TRUE,(LPARAM)MAKELONG(0,100));
00319      val=op->particles.size_end/10; // all scaled 0 - 1000 - ranged [0-100]
00320      SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_SIZE_END),TBM_SETPOS,TRUE,(LPARAM)val);
00321      SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_ALPHA),
00322        TBM_SETRANGE,(WPARAM)TRUE,(LPARAM)MAKELONG(0,100));
00323      val=op->particles.alpha_start/10; // all scaled 0 - 1000 - ranged [0-100]
00324      SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_ALPHA),TBM_SETPOS,TRUE,(LPARAM)val);
00325      SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_ALPHA_END),
00326        TBM_SETRANGE,(WPARAM)TRUE,(LPARAM)MAKELONG(0,100));
00327      val=op->particles.alpha_end/10; // all scaled 0 - 1000 - ranged [0-100]
00328      SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_ALPHA_END),TBM_SETPOS,TRUE,(LPARAM)val);
00329      SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_LIFE),
00330        TBM_SETRANGE,(WPARAM)TRUE,(LPARAM)MAKELONG(0,100));
00331      val=op->particles.life/10; 
00332      SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_LIFE),TBM_SETPOS,TRUE,(LPARAM)val);
00333      SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_SPEED),
00334        TBM_SETRANGE,(WPARAM)TRUE,(LPARAM)MAKELONG(0,100));
00335      val=op->particles.speed/10; 
00336      SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_SPEED),TBM_SETPOS,TRUE,(LPARAM)val);
00337      SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_THETA),
00338        TBM_SETRANGE,(WPARAM)TRUE,(LPARAM)MAKELONG(0,100));
00339      val=op->particles.theta/10; 
00340      SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_THETA),TBM_SETPOS,TRUE,(LPARAM)val);
00341      // VARIATIONS
00342      SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_VALPHA),
00343        TBM_SETRANGE,(WPARAM)TRUE,(LPARAM)MAKELONG(0,100));
00344      val=op->particles.valpha/10; 
00345      SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_VALPHA),TBM_SETPOS,TRUE,(LPARAM)val);
00346      SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_VCOLOUR),
00347        TBM_SETRANGE,(WPARAM)TRUE,(LPARAM)MAKELONG(0,100));
00348      val=op->particles.vcolour/10; 
00349      SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_VCOLOUR),TBM_SETPOS,TRUE,(LPARAM)val);
00350      SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_VSIZE),
00351        TBM_SETRANGE,(WPARAM)TRUE,(LPARAM)MAKELONG(0,100));
00352      val=op->particles.vsize/10; 
00353      SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_VSIZE),TBM_SETPOS,TRUE,(LPARAM)val);
00354      SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_VLIFE),
00355        TBM_SETRANGE,(WPARAM)TRUE,(LPARAM)MAKELONG(0,100));
00356      val=op->particles.vlife/10; 
00357      SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_VLIFE),TBM_SETPOS,TRUE,(LPARAM)val);
00358      SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_VSPEED),
00359        TBM_SETRANGE,(WPARAM)TRUE,(LPARAM)MAKELONG(0,100));
00360      val=op->particles.vspeed/10; 
00361      SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_VSPEED),TBM_SETPOS,TRUE,(LPARAM)val);
00362      // GRAVITY
00363      SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_GRAV_EW),
00364        TBM_SETRANGE,(WPARAM)TRUE,(LPARAM)MAKELONG(0,100));
00365      val=(op->particles.ew_start+500)/10;  
00366      SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_GRAV_EW),TBM_SETPOS,TRUE,(LPARAM)val);
00367      SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_GRAV_NS),
00368        TBM_SETRANGE,(WPARAM)TRUE,(LPARAM)MAKELONG(0,100));
00369      val=(op->particles.ns_start+500)/10;  
00370      SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_GRAV_NS),TBM_SETPOS,TRUE,(LPARAM)val);
00371      SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_GRAV_UD),
00372        TBM_SETRANGE,(WPARAM)TRUE,(LPARAM)MAKELONG(0,100));
00373      val=(op->particles.ud_start+500)/10;  
00374      SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_GRAV_UD),TBM_SETPOS,TRUE,(LPARAM)val);
00375      SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_GRAV_EW_END),
00376        TBM_SETRANGE,(WPARAM)TRUE,(LPARAM)MAKELONG(0,100));
00377      val=(op->particles.ew_end+500)/10;  
00378      SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_GRAV_EW_END),TBM_SETPOS,TRUE,(LPARAM)val);
00379      SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_GRAV_NS_END),
00380        TBM_SETRANGE,(WPARAM)TRUE,(LPARAM)MAKELONG(0,100));
00381      val=(op->particles.ns_end+500)/10;  
00382      SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_GRAV_NS_END),TBM_SETPOS,TRUE,(LPARAM)val);
00383      SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_GRAV_UD_END),
00384        TBM_SETRANGE,(WPARAM)TRUE,(LPARAM)MAKELONG(0,100));
00385      val=(op->particles.ud_end+500)/10;  
00386      SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_GRAV_UD_END),TBM_SETPOS,TRUE,(LPARAM)val);
00387      SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_TYPE),CB_SELECTSTRING,0,(LPARAM)ParticleList[op->particles.iid]);
00388      SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_BLEND),CB_SELECTSTRING,0,(LPARAM)ParticleBlendList[op->particles.blend_model]);
00389 }
00390 
00391 
00392 BOOL CALLBACK ParticleDlgProc(HWND hdlg,UINT msg, 
00393                              WPARAM wparam,LPARAM lparam){
00394  static object *op,*tp;
00395  LPDRAWITEMSTRUCT lpdis;
00396  int nType=NP_IMAGES;
00397  BOOL err;
00398  struct NC {node *np; object *op,*tp; int d;} *Nc;
00399  int i,j,lf,ff,val;
00400  char title[256];
00401  long range1,range2;
00402  switch( msg ) {
00403    case WM_INITDIALOG:
00404      Nc=(struct NC *)lparam;
00405      memcpy(Nc->tp,Nc->op,sizeof(object));
00406      op=Nc->tp;  tp=Nc->op;
00407      LoadString(ghinst_main,IDX_MISC_DCSGSETUP,res_str,256);
00408      sprintf(title,res_str,Nc->np->actorname);
00409      SendMessage(hdlg,WM_SETTEXT,0,(LPARAM)title);
00410      for(i=0;i<nType;i++)
00411        SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_TYPE),CB_ADDSTRING,0,(LPARAM)ParticleList[i]);
00412      for(i=0;i<NP_BLEND;i++)
00413        SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_BLEND),CB_ADDSTRING,0,(LPARAM)ParticleBlendList[i]);
00414 
00415      UpdateParticleDialog(hdlg,op);
00416      if(Nc->d == 0)EnableWindow(GetDlgItem(hdlg,DLG_CSG_DELETE),FALSE);
00417      CentreDialogOnScreen(hdlg);
00418      EnableToolPannels(ALL_PANNELS,FALSE);
00419      return (TRUE);
00420    case WM_VSCROLL:
00421      if((HWND)lparam == GetDlgItem(hdlg,DLG_PARTICLE_SIZE_SCALE)){
00422        switch (LOWORD(wparam)) {
00423          case SB_THUMBTRACK:
00424          case SB_THUMBPOSITION:
00425          case TB_ENDTRACK:
00426             val=SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_SIZE_SCALE),TBM_GETPOS,0,0);
00427             op->particles.particle_size_scale=val*10;
00428             break;
00429          default: break;
00430        }
00431      }
00432      break;
00433    case WM_HSCROLL:
00434      if((HWND)lparam == GetDlgItem(hdlg,DLG_PARTICLE_SIZE)){
00435        switch (LOWORD(wparam)) {
00436          case SB_THUMBTRACK:
00437          case SB_THUMBPOSITION:
00438          case TB_ENDTRACK:
00439             val=SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_SIZE),TBM_GETPOS,0,0);
00440             op->particles.size_start=val*10;
00441             break;
00442          default: break;
00443        }
00444      }
00445      if((HWND)lparam == GetDlgItem(hdlg,DLG_PARTICLE_SIZE_END)){
00446        switch (LOWORD(wparam)) {
00447          case SB_THUMBTRACK:
00448          case SB_THUMBPOSITION:
00449          case TB_ENDTRACK:
00450             val=SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_SIZE_END),TBM_GETPOS,0,0);
00451             op->particles.size_end=val*10;
00452             break;
00453          default: break;
00454        }
00455      }
00456      if((HWND)lparam == GetDlgItem(hdlg,DLG_PARTICLE_ALPHA)){
00457        switch (LOWORD(wparam)) {
00458          case SB_THUMBTRACK:
00459          case SB_THUMBPOSITION:
00460          case TB_ENDTRACK:
00461             val=SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_ALPHA),TBM_GETPOS,0,0);
00462             op->particles.alpha_start=val*10;
00463             break;
00464          default: break;
00465        }
00466      }
00467      if((HWND)lparam == GetDlgItem(hdlg,DLG_PARTICLE_ALPHA_END)){
00468        switch (LOWORD(wparam)) {
00469          case SB_THUMBTRACK:
00470          case SB_THUMBPOSITION:
00471          case TB_ENDTRACK:
00472             val=SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_ALPHA_END),TBM_GETPOS,0,0);
00473             op->particles.alpha_end=val*10;
00474             break;
00475          default: break;
00476        }
00477      }
00478      if((HWND)lparam == GetDlgItem(hdlg,DLG_PARTICLE_LIFE)){
00479        switch (LOWORD(wparam)) {
00480          case SB_THUMBTRACK:
00481          case SB_THUMBPOSITION:
00482          case TB_ENDTRACK:
00483             val=SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_LIFE),TBM_GETPOS,0,0);
00484             op->particles.life=val*10;
00485             break;
00486          default: break;
00487        }
00488      }
00489      if((HWND)lparam == GetDlgItem(hdlg,DLG_PARTICLE_SPEED)){
00490        switch (LOWORD(wparam)) {
00491          case SB_THUMBTRACK:
00492          case SB_THUMBPOSITION:
00493          case TB_ENDTRACK:
00494             val=SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_SPEED),TBM_GETPOS,0,0);
00495             op->particles.speed=val*10;
00496             break;
00497          default: break;
00498        }
00499      }
00500      if((HWND)lparam == GetDlgItem(hdlg,DLG_PARTICLE_THETA)){
00501        switch (LOWORD(wparam)) {
00502          case SB_THUMBTRACK:
00503          case SB_THUMBPOSITION:
00504          case TB_ENDTRACK:
00505             val=SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_THETA),TBM_GETPOS,0,0);
00506             op->particles.theta=val*10;
00507             break;
00508          default: break;
00509        }
00510      }
00511      if((HWND)lparam == GetDlgItem(hdlg,DLG_PARTICLE_VALPHA)){
00512        switch (LOWORD(wparam)) {
00513          case SB_THUMBTRACK:
00514          case SB_THUMBPOSITION:
00515          case TB_ENDTRACK:
00516             val=SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_VALPHA),TBM_GETPOS,0,0);
00517             op->particles.valpha=val*10;
00518             break;
00519          default: break;
00520        }
00521      }
00522      if((HWND)lparam == GetDlgItem(hdlg,DLG_PARTICLE_VCOLOUR)){
00523        switch (LOWORD(wparam)) {
00524          case SB_THUMBTRACK:
00525          case SB_THUMBPOSITION:
00526          case TB_ENDTRACK:
00527             val=SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_VCOLOUR),TBM_GETPOS,0,0);
00528             op->particles.vcolour=val*10;
00529             break;
00530          default: break;
00531        }
00532      }
00533      if((HWND)lparam == GetDlgItem(hdlg,DLG_PARTICLE_VSIZE)){
00534        switch (LOWORD(wparam)) {
00535          case SB_THUMBTRACK:
00536          case SB_THUMBPOSITION:
00537          case TB_ENDTRACK:
00538             val=SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_VSIZE),TBM_GETPOS,0,0);
00539             op->particles.vsize=val*10;
00540             break;
00541          default: break;
00542        }
00543      }
00544      if((HWND)lparam == GetDlgItem(hdlg,DLG_PARTICLE_VLIFE)){
00545        switch (LOWORD(wparam)) {
00546          case SB_THUMBTRACK:
00547          case SB_THUMBPOSITION:
00548          case TB_ENDTRACK:
00549             val=SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_VLIFE),TBM_GETPOS,0,0);
00550             op->particles.vlife=val*10;
00551             break;
00552          default: break;
00553        }
00554      }
00555      if((HWND)lparam == GetDlgItem(hdlg,DLG_PARTICLE_VSPEED)){
00556        switch (LOWORD(wparam)) {
00557          case SB_THUMBTRACK:
00558          case SB_THUMBPOSITION:
00559          case TB_ENDTRACK:
00560             val=SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_VSPEED),TBM_GETPOS,0,0);
00561             op->particles.vspeed=val*10;
00562             break;
00563          default: break;
00564        }
00565      }
00566      if((HWND)lparam == GetDlgItem(hdlg,DLG_PARTICLE_GRAV_EW)){
00567        switch (LOWORD(wparam)) {
00568          case SB_THUMBTRACK:
00569          case SB_THUMBPOSITION:
00570          case TB_ENDTRACK:
00571             val=SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_GRAV_EW),TBM_GETPOS,0,0);
00572             op->particles.ew_start=val*10-500;
00573             break;
00574          default: break;
00575        }
00576      }
00577      if((HWND)lparam == GetDlgItem(hdlg,DLG_PARTICLE_GRAV_NS)){
00578        switch (LOWORD(wparam)) {
00579          case SB_THUMBTRACK:
00580          case SB_THUMBPOSITION:
00581          case TB_ENDTRACK:
00582             val=SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_GRAV_NS),TBM_GETPOS,0,0);
00583             op->particles.ns_start=val*10-500;
00584             break;
00585          default: break;
00586        }
00587      }
00588      if((HWND)lparam == GetDlgItem(hdlg,DLG_PARTICLE_GRAV_UD)){
00589        switch (LOWORD(wparam)) {
00590          case SB_THUMBTRACK:
00591          case SB_THUMBPOSITION:
00592          case TB_ENDTRACK:
00593             val=SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_GRAV_UD),TBM_GETPOS,0,0);
00594             op->particles.ud_start=val*10-500;
00595             break;
00596          default: break;
00597        }
00598      }
00599      if((HWND)lparam == GetDlgItem(hdlg,DLG_PARTICLE_GRAV_EW_END)){
00600        switch (LOWORD(wparam)) {
00601          case SB_THUMBTRACK:
00602          case SB_THUMBPOSITION:
00603          case TB_ENDTRACK:
00604             val=SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_GRAV_EW_END),TBM_GETPOS,0,0);
00605             op->particles.ew_end=val*10-500;
00606             break;
00607          default: break;
00608        }
00609      }
00610      if((HWND)lparam == GetDlgItem(hdlg,DLG_PARTICLE_GRAV_NS_END)){
00611        switch (LOWORD(wparam)) {
00612          case SB_THUMBTRACK:
00613          case SB_THUMBPOSITION:
00614          case TB_ENDTRACK:
00615             val=SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_GRAV_NS_END),TBM_GETPOS,0,0);
00616             op->particles.ns_end=val*10-500;
00617             break;
00618          default: break;
00619        }
00620      }
00621      if((HWND)lparam == GetDlgItem(hdlg,DLG_PARTICLE_GRAV_UD_END)){
00622        switch (LOWORD(wparam)) {
00623          case SB_THUMBTRACK:
00624          case SB_THUMBPOSITION:
00625          case TB_ENDTRACK:
00626             val=SendMessage(GetDlgItem(hdlg,DLG_PARTICLE_GRAV_UD_END),TBM_GETPOS,0,0);
00627             op->particles.ud_end=val*10-500;
00628             break;
00629          default: break;
00630        }
00631      }
00632      break;
00633    case WM_DESTROY:
00634      EnableToolPannels(ALL_PANNELS,TRUE);
00635      break;
00636    case WM_DRAWITEM:{
00637        HBRUSH   hbr,hbrold;
00638        BYTE r,g,b;
00639        lpdis=(LPDRAWITEMSTRUCT)lparam;
00640        if(lpdis->CtlID == DLG_PARTICLE_COLOUR){
00641          r=op->particles.colour_start[0]; g=op->particles.colour_start[1]; b=op->particles.colour_start[2];
00642          if(lpdis->itemState & ODS_SELECTED)InvertRect(lpdis->hDC,&(lpdis->rcItem));
00643          else{
00644            hbr=CreateSolidBrush(RGB(r,g,b));
00645            hbrold=SelectObject(lpdis->hDC,hbr);
00646            Rectangle(lpdis->hDC,lpdis->rcItem.left,lpdis->rcItem.top,
00647                          lpdis->rcItem.right,lpdis->rcItem.bottom);
00648            SelectObject(lpdis->hDC,hbrold);
00649            DeleteObject(hbr);
00650          }
00651        }
00652        else if(lpdis->CtlID == DLG_PARTICLE_COLOUR_END){
00653          r=op->particles.colour_end[0]; g=op->particles.colour_end[1]; b=op->particles.colour_end[2];
00654          if(lpdis->itemState & ODS_SELECTED)InvertRect(lpdis->hDC,&(lpdis->rcItem));
00655          else{
00656            hbr=CreateSolidBrush(RGB(r,g,b));
00657            hbrold=SelectObject(lpdis->hDC,hbr);
00658            Rectangle(lpdis->hDC,lpdis->rcItem.left,lpdis->rcItem.top,
00659                          lpdis->rcItem.right,lpdis->rcItem.bottom);
00660            SelectObject(lpdis->hDC,hbrold);
00661            DeleteObject(hbr);
00662          }
00663        }
00664      }
00665      return TRUE;
00666    case WM_PAINT:
00667      PaintDialogBackground(hdlg,ghinst_main);
00668      break;
00669    case WM_COMMAND:
00670        /* severe warning about using GWL_USERDATA */
00671       switch( HIWORD(wparam) ){
00672         case CBN_SELENDOK:
00673           if(LOWORD(wparam) == DLG_PARTICLE_TYPE){
00674             char mss1[20];
00675             SendDlgItemMessage(hdlg,DLG_PARTICLE_TYPE,WM_GETTEXT,
00676                (WPARAM)18,(LPARAM)mss1);
00677             op->particles.iid=GetCharListID(mss1,ParticleList,nType);
00678             strcpy(op->particles.ImageName,mss1);
00679           }
00680           else if(LOWORD(wparam) == DLG_PARTICLE_BLEND){
00681             char mss1[20];
00682             SendDlgItemMessage(hdlg,DLG_PARTICLE_BLEND,WM_GETTEXT,
00683                (WPARAM)18,(LPARAM)mss1);
00684             op->particles.blend_model=GetCharListID(mss1,ParticleBlendList,NP_BLEND);
00685           }
00686           break;
00687 
00688           break;
00689         default:
00690           break;
00691       }
00692       switch(LOWORD(wparam)){
00693         case DLG_PARTICLE_COLOUR:
00694           SetSfxColour(op->particles.colour_start,IDX_MISC_CSG_COLOUR,hdlg);
00695           InvalidateRect(GetDlgItem(hdlg,DLG_PARTICLE_COLOUR),NULL,FALSE);
00696           break;
00697         case DLG_PARTICLE_COLOUR_END:
00698           SetSfxColour(op->particles.colour_end,IDX_MISC_CSG_COLOUR,hdlg);
00699           InvalidateRect(GetDlgItem(hdlg,DLG_PARTICLE_COLOUR_END),NULL,FALSE);
00700           break;
00701         case DLG_PARTICLE_BURST:
00702           op->particles.burst=TRUE;
00703           break;
00704         case DLG_PARTICLE_FLOW:
00705           op->particles.burst=FALSE;
00706           break;
00707         case DLG_CSG_DELETE:
00708           EndDialog(hdlg,1);
00709           return(TRUE);
00710         case DLG_PARTICLE_RESET:
00711           InitialiseParticleSystem(&(op->particles));
00712           UpdateParticleDialog(hdlg,op);
00713           InvalidateRect(GetDlgItem(hdlg,DLG_PARTICLE_COLOUR),NULL,FALSE);
00714           InvalidateRect(GetDlgItem(hdlg,DLG_PARTICLE_COLOUR_END),NULL,FALSE);
00715           break;
00716         case DLG_PARTICLE_PRESET0:
00717         case DLG_PARTICLE_PRESET1:
00718         case DLG_PARTICLE_PRESET2:
00719         case DLG_PARTICLE_PRESET3:
00720         case DLG_PARTICLE_PRESET4:
00721         case DLG_PARTICLE_PRESET5:
00722           SetupParticlePreset(LOWORD(wparam),&(op->particles));
00723           UpdateParticleDialog(hdlg,op);
00724           InvalidateRect(GetDlgItem(hdlg,DLG_PARTICLE_COLOUR),NULL,FALSE);
00725           InvalidateRect(GetDlgItem(hdlg,DLG_PARTICLE_COLOUR_END),NULL,FALSE);
00726           break;
00727         case IDOK:
00728           if(SendDlgItemMessage(hdlg,DLG_PARTICLE_STEADY_STATE,BM_GETCHECK,0,0))
00729                op->particles.bSteadyState=TRUE;
00730           else op->particles.bSteadyState=FALSE;
00731           if(SendDlgItemMessage(hdlg,DLG_PARTICLE_SPIN_OFF,BM_GETCHECK,0,0))
00732                op->particles.bSpinOff=TRUE;
00733           else op->particles.bSpinOff=FALSE;
00734           if(SendDlgItemMessage(hdlg,DLG_PARTICLE_SINGLE,BM_GETCHECK,0,0))
00735                op->particles.bSingle=TRUE;
00736           else op->particles.bSingle=FALSE;
00737           op->particles.NumP=GetDlgItemInt(hdlg,DLG_PARTICLE_NUMBER,&err,FALSE);
00738           range1=SendDlgItemMessage(hdlg,DLG_CSG_FROMS,SPNM_GETRANGE,0,0);
00739           range2=SendDlgItemMessage(hdlg,DLG_CSG_TOS,SPNM_GETRANGE,0,0);
00740           i=GetDlgItemInt(hdlg,DLG_CSG_FROM,&err,FALSE);
00741           if(!err || i < LOWORD(range1) ||
00742                      i > HIWORD(range1))goto CANCELX;
00743           j=GetDlgItemInt(hdlg,DLG_CSG_TO,&err,FALSE);
00744           if(!err || j < LOWORD(range2) ||
00745                      j > HIWORD(range2))goto CANCELX;
00746           if(j < i)goto CANCELX;
00747           op->firstframe=i;
00748           op->lastframe=j;
00749           memcpy(tp,op,sizeof(object));
00750           EndDialog(hdlg,0);
00751           return(TRUE);
00752           CANCELX:
00753           MessageBeep(MB_OK);
00754         case IDCANCEL:
00755           EndDialog(hdlg,-1);
00756           return(TRUE);
00757           break;
00758         default:  break;
00759       }
00760       break;
00761     default: break;
00762  }
00763  return(FALSE);
00764 }
00765 

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