Shinya Kitaoka 810553
#pragma once
Shinya Kitaoka 810553
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------
Toshihiro Shimizu 890ddd
// Iwa_Particle for Marnie
Toshihiro Shimizu 890ddd
// based on ParticlesFx by Digital Video
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef IWA_PARTICLES_H
Toshihiro Shimizu 890ddd
#define IWA_PARTICLES_H
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tsmartpointer.h"
Toshihiro Shimizu 890ddd
#include "tspectrum.h"
Toshihiro Shimizu 890ddd
#include "trandom.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "iwa_particlesengine.h"
Toshihiro Shimizu 890ddd
#include <qlist></qlist>
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
struct particles_values {
Shinya Kitaoka 120a6e
  int source_ctrl_val;
Shinya Kitaoka 120a6e
  int bright_thres_val;
Shinya Kitaoka 120a6e
  bool multi_source_val;
Shinya Kitaoka 120a6e
  double x_pos_val;
Shinya Kitaoka 120a6e
  double y_pos_val;
Shinya Kitaoka 120a6e
  int unit_val;
Shinya Kitaoka 120a6e
  double length_val;
Shinya Kitaoka 120a6e
  double height_val;
Shinya Kitaoka 120a6e
  double maxnum_val;
Shinya Kitaoka 120a6e
  DoublePair lifetime_val;
Shinya Kitaoka 120a6e
  int lifetime_ctrl_val;
Shinya Kitaoka 120a6e
  int column_lifetime_val;
Shinya Kitaoka 120a6e
  int startpos_val;
Shinya Kitaoka 120a6e
  int randseed_val;
Shinya Kitaoka 120a6e
  double gravity_val;
Shinya Kitaoka 120a6e
  double g_angle_val;
Shinya Kitaoka 120a6e
  int gravity_ctrl_val;
Shinya Kitaoka 120a6e
  double friction_val;
Shinya Kitaoka 120a6e
  int friction_ctrl_val;
Shinya Kitaoka 120a6e
  double windint_val;
Shinya Kitaoka 120a6e
  double windangle_val;
Shinya Kitaoka 120a6e
  int swingmode_val;
Shinya Kitaoka 120a6e
  DoublePair randomx_val;
Shinya Kitaoka 120a6e
  DoublePair randomy_val;
Shinya Kitaoka 120a6e
  int randomx_ctrl_val;
Shinya Kitaoka 120a6e
  int randomy_ctrl_val;
Shinya Kitaoka 120a6e
  DoublePair swing_val;
Shinya Kitaoka 120a6e
  DoublePair speed_val;
Shinya Kitaoka 120a6e
  int speed_ctrl_val;
Shinya Kitaoka 120a6e
  DoublePair speeda_val;
Shinya Kitaoka 120a6e
  int speeda_ctrl_val;
Shinya Kitaoka 120a6e
  bool speeda_use_gradient_val;
Shinya Kitaoka 120a6e
  bool speedscale_val;
Shinya Kitaoka 120a6e
  char *levelname_val;
Shinya Kitaoka 120a6e
  int toplayer_val;
Shinya Kitaoka 120a6e
  DoublePair mass_val;
Shinya Kitaoka 120a6e
  DoublePair scale_val;
Shinya Kitaoka 120a6e
  int scale_ctrl_val;
Shinya Kitaoka 120a6e
  bool scale_ctrl_all_val;
Shinya Kitaoka 120a6e
  DoublePair rot_val;
Shinya Kitaoka 120a6e
  int rot_ctrl_val;
Shinya Kitaoka 120a6e
  DoublePair trail_val;
Shinya Kitaoka 120a6e
  double trailstep_val;
Shinya Kitaoka 120a6e
  int rotswingmode_val;
Shinya Kitaoka 120a6e
  double rotspeed_val;
Shinya Kitaoka 120a6e
  DoublePair rotsca_val;
Shinya Kitaoka 120a6e
  DoublePair rotswing_val;
Shinya Kitaoka 120a6e
  bool pathaim_val;
Shinya Kitaoka 120a6e
  DoublePair opacity_val;
Shinya Kitaoka 120a6e
  int opacity_ctrl_val;
Shinya Kitaoka 120a6e
  DoublePair trailopacity_val;
Shinya Kitaoka 120a6e
  double mblur_val;
Shinya Kitaoka 120a6e
  DoublePair scalestep_val;
Shinya Kitaoka 120a6e
  int scalestep_ctrl_val;
Shinya Kitaoka 120a6e
  double fadein_val;
Shinya Kitaoka 120a6e
  double fadeout_val;
Shinya Kitaoka 120a6e
  int animation_val;
Shinya Kitaoka 120a6e
  int step_val;
Shinya Kitaoka 120a6e
  TSpectrum gencol_val;
Shinya Kitaoka 120a6e
  int gencol_ctrl_val;
Shinya Kitaoka 120a6e
  double gencol_spread_val;
Shinya Kitaoka 120a6e
  double genfadecol_val;
Shinya Kitaoka 120a6e
  TSpectrum fincol_val;
Shinya Kitaoka 120a6e
  int fincol_ctrl_val;
Shinya Kitaoka 120a6e
  double fincol_spread_val;
Shinya Kitaoka 120a6e
  double finrangecol_val;
Shinya Kitaoka 120a6e
  double finfadecol_val;
Shinya Kitaoka 120a6e
  TSpectrum foutcol_val;
Shinya Kitaoka 120a6e
  int foutcol_ctrl_val;
Shinya Kitaoka 120a6e
  double foutcol_spread_val;
Shinya Kitaoka 120a6e
  double foutrangecol_val;
Shinya Kitaoka 120a6e
  double foutfadecol_val;
Shinya Kitaoka 120a6e
  TRandom *random_val;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  bool source_gradation_val;
Shinya Kitaoka 120a6e
  bool reset_random_for_every_frame_val;
Shinya Kitaoka 120a6e
  bool pick_color_for_every_frame_val;
Shinya Kitaoka 120a6e
  bool perspective_distribution_val;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /*- 以下、このFxのために追加したパラメータ -*/
Shinya Kitaoka 120a6e
  /*-  計算モード (背景+粒子/粒子/背景/照明された粒子)-*/
Shinya Kitaoka 120a6e
  int iw_rendermode_val;
Shinya Kitaoka 120a6e
  /*- 粒子に貼られる絵の素材 -*/
Shinya Kitaoka 120a6e
  int base_ctrl_val;
Shinya Kitaoka 120a6e
  /*- カールノイズ的な動きを与える -*/
Shinya Kitaoka 120a6e
  double curl_val;
Shinya Kitaoka 120a6e
  int curl_ctrl_1_val;
Shinya Kitaoka 120a6e
  int curl_ctrl_2_val;
Shinya Kitaoka 120a6e
  /*- 粒子敷き詰め。粒子を正三角形で敷き詰めたときの、
Shinya Kitaoka 120a6e
          正三角形の一辺の長さをインチで指定する -*/
Shinya Kitaoka 120a6e
  double iw_triangleSize;
Shinya Kitaoka 120a6e
  /*- ひらひら回転 -*/
Shinya Kitaoka 120a6e
  int flap_ctrl_val;
Shinya Kitaoka 120a6e
  double iw_flap_velocity_val;
Shinya Kitaoka 120a6e
  double iw_flap_dir_sensitivity_val;
Shinya Kitaoka 120a6e
  /*- ひらひら粒子に照明を当てる。normalize_values()内で Degree → Radian 化する
Shinya Kitaoka 120a6e
   * -*/
Shinya Kitaoka 120a6e
  double iw_light_theta_val;
Shinya Kitaoka 120a6e
  double iw_light_phi_val;
Shinya Kitaoka 120a6e
  /*- 読み込みマージン -*/
Shinya Kitaoka 120a6e
  double margin_val;
Shinya Kitaoka 120a6e
  /*- 重力を徐々に与えるためのフレーム長 -*/
Shinya Kitaoka 120a6e
  int iw_gravityBufferFrame_val;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
struct particles_ranges {
Shinya Kitaoka 120a6e
  float swing_range;
Shinya Kitaoka 120a6e
  float randomx_range;
Shinya Kitaoka 120a6e
  float randomy_range;
Shinya Kitaoka 120a6e
  float rot_range;
Shinya Kitaoka 120a6e
  float rotswing_range;
Shinya Kitaoka 120a6e
  float rotsca_range;
Shinya Kitaoka 120a6e
  float lifetime_range;
Shinya Kitaoka 120a6e
  float speed_range;
Shinya Kitaoka 120a6e
  float speeda_range;
Shinya Kitaoka 120a6e
  float mass_range;
Shinya Kitaoka 120a6e
  float scale_range;
Shinya Kitaoka 120a6e
  float scalestep_range;
Shinya Kitaoka 120a6e
  int trail_range;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
struct pos_dummy {
Shinya Kitaoka 120a6e
  float x, y, a;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
typedef struct {
Shinya Kitaoka 120a6e
  TPixel32 col;
Shinya Kitaoka 120a6e
  int rangecol;
Shinya Kitaoka 120a6e
  double fadecol;
Toshihiro Shimizu 890ddd
} coldata;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class Iwa_Particle {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  double x;
Shinya Kitaoka 120a6e
  float y;
Shinya Kitaoka 120a6e
  float oldx;
Shinya Kitaoka 120a6e
  float oldy;
Shinya Kitaoka 120a6e
  float vx;
Shinya Kitaoka 120a6e
  float vy;
Shinya Kitaoka 120a6e
  float mass;
Shinya Kitaoka 120a6e
  float scale;
Shinya Kitaoka 120a6e
  float angle;
Shinya Kitaoka 120a6e
  float smswingx;
Shinya Kitaoka 120a6e
  float smswingy;
Shinya Kitaoka 120a6e
  float smswinga;
Shinya Kitaoka 120a6e
  int smperiodx;
Shinya Kitaoka 120a6e
  int smperiody;
Shinya Kitaoka 120a6e
  int smperioda;
Shinya Kitaoka 120a6e
  int lifetime;    /*- 現在の残り寿命 -*/
Shinya Kitaoka 120a6e
  int genlifetime; /*- 発生時の寿命 -*/
Shinya Kitaoka 120a6e
  int level;
Shinya Kitaoka 120a6e
  int frame;
Shinya Kitaoka 120a6e
  int signx;
Shinya Kitaoka 120a6e
  int trail;
Shinya Kitaoka 120a6e
  coldata gencol;
Shinya Kitaoka 120a6e
  coldata fincol;
Shinya Kitaoka 120a6e
  coldata foutcol;
Shinya Kitaoka 120a6e
  int changesignx;
Shinya Kitaoka 120a6e
  int signy;
Shinya Kitaoka 120a6e
  int changesigny;
Shinya Kitaoka 120a6e
  int signa;
Shinya Kitaoka 120a6e
  int changesigna;
Shinya Kitaoka 120a6e
  bool animswing;
Shinya Kitaoka 120a6e
  TRandom random;
Shinya Kitaoka 120a6e
  int seed;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  float initial_x;
Shinya Kitaoka 120a6e
  float initial_y;
Shinya Kitaoka 120a6e
  float initial_angle;
Shinya Kitaoka 120a6e
  float initial_scale;
Shinya Kitaoka 120a6e
  float curlx;
Shinya Kitaoka 120a6e
  float curly;
Shinya Kitaoka 120a6e
  float curlz;
Shinya Kitaoka 120a6e
  /*- ひらひら動かす回転角(Degree)-*/
Shinya Kitaoka 120a6e
  float flap_theta;
Shinya Kitaoka 120a6e
  float flap_phi;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  Iwa_Particle(int lifetime, int seed, const std::map<int, *="" ttile=""> porttiles,</int,>
Shinya Kitaoka 120a6e
               const particles_values &values, const particles_ranges &ranges,
Shinya Kitaoka 120a6e
               int howmany, int first, int level, int last, float posx,
Shinya Kitaoka 120a6e
               float posy,    /*- 座標を指定 -*/
Shinya Kitaoka 120a6e
               bool isUpward, /*-  初期向き -*/
Shinya Kitaoka 120a6e
               int initSourceFrame);
Shinya Kitaoka 120a6e
  // Constructor
Shinya Kitaoka 120a6e
  ~Iwa_Particle() {}
Shinya Kitaoka 120a6e
  // Destructor
Shinya Kitaoka 120a6e
  void create_Animation(const particles_values &values, int first, int last);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  int check_Swing(const particles_values &values);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void create_Swing(const particles_values &values,
Shinya Kitaoka 120a6e
                    const particles_ranges &ranges, double randomxreference,
Shinya Kitaoka 120a6e
                    double randomyreference);
Shinya Kitaoka 120a6e
  void create_Colors(const particles_values &values,
Shinya Kitaoka 120a6e
                     const particles_ranges &ranges,
Shinya Kitaoka 120a6e
                     std::map<int, *="" ttile=""> porttiles);</int,>
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void move(const std::map<int, *="" ttile=""> porttiles,</int,>
Shinya Kitaoka 120a6e
            const particles_values &values, const particles_ranges &ranges,
Shinya Kitaoka 120a6e
            float windx, float windy, float xgravity, float ygravity, float dpi,
Shinya Kitaoka 120a6e
            int lastframe);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void spread_color(TPixel32 &color, double range);
Shinya Kitaoka 120a6e
  void update_Animation(const particles_values &values, int first, int last,
Shinya Kitaoka 120a6e
                        int keep);
Shinya Kitaoka 120a6e
  void update_Swing(const particles_values &values,
Shinya Kitaoka 120a6e
                    const particles_ranges &ranges, struct pos_dummy &dummy,
Shinya Kitaoka 120a6e
                    double randomxreference, double randomyreference);
Shinya Kitaoka 120a6e
  void update_Scale(const particles_values &values,
Shinya Kitaoka 120a6e
                    const particles_ranges &ranges, double scalereference,
Shinya Kitaoka 120a6e
                    double scalestepreference);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  double set_Opacity(std::map<int, *="" ttile=""> porttiles,</int,>
Shinya Kitaoka 120a6e
                     const particles_values &values, float opacity_range,
Shinya Kitaoka 120a6e
                     double dist_frame);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void modify_colors(TPixel32 &color, double &intensity);
Shinya Kitaoka 120a6e
  void modify_colors_and_opacity(const particles_values &values,
Shinya Kitaoka 120a6e
                                 float curr_opacity, int dist_frame,
Shinya Kitaoka 120a6e
                                 TRaster32P raster);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  bool canHandle(const TRenderSettings &info, double frame) { return false; }
Shinya Kitaoka 120a6e
  void get_image_reference(TTile *ctrl1, const particles_values &values,
Shinya Kitaoka 120a6e
                           float &imagereference, int type);
Shinya Kitaoka 120a6e
  void get_image_reference(TTile *ctrl1, const particles_values &values,
Shinya Kitaoka 120a6e
                           TPixel32 &color);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /*- ベクタ長を返す -*/
Shinya Kitaoka 120a6e
  float get_image_gravity(TTile *ctrl1, const particles_values &values,
Shinya Kitaoka 120a6e
                          float &gx, float &gy);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void get_base_image_texture(TTile *ctrl1, const particles_values &values,
Shinya Kitaoka 120a6e
                              TRasterP texRaster, const TRectD &texBBox,
Shinya Kitaoka 120a6e
                              const TRenderSettings &ri);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void get_base_image_color(TTile *ctrl1, const particles_values &values,
Shinya Kitaoka 120a6e
                            TRasterP texRaster, const TRectD &texBBox,
Shinya Kitaoka 120a6e
                            const TRenderSettings &ri);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /*- Control圏内ならtrueを返す -*/
Shinya Kitaoka 120a6e
  bool get_image_curl(TTile *ctrl1, const particles_values &values, float &cx,
Shinya Kitaoka 120a6e
                      float &cy);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /*- 照明モードのとき、その明るさを色に格納 -*/
Shinya Kitaoka 120a6e
  void set_illuminated_colors(float illuminant, TRasterP texRaster);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class Iwa_ComparebySize {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  bool operator()(const Iwa_Particle &f1, const Iwa_Particle &f2) {
Shinya Kitaoka 120a6e
    if ((f1.scale - f2.scale) > 0) return 1;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    return 0;
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class Iwa_ComparebyLifetime {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  bool operator()(const Iwa_Particle &f1, const Iwa_Particle &f2) {
Shinya Kitaoka 120a6e
    if ((f1.lifetime - f1.genlifetime - f2.lifetime + f2.genlifetime) > 0)
Shinya Kitaoka 120a6e
      return 1;
Shinya Kitaoka 120a6e
    return 0;
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif