Shinya Kitaoka 810553
#pragma once
Shinya Kitaoka 810553
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------
Toshihiro Shimizu 890ddd
// Iwa_Particles_Engine for Marnie
Toshihiro Shimizu 890ddd
// based on Particles_Engine by Digital Video
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef IWA_PARTICLESENGINE_H
Toshihiro Shimizu 890ddd
#define IWA_PARTICLESENGINE_H
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tlevel.h"
Toshihiro Shimizu 890ddd
#include "iwa_particles.h"
Toshihiro Shimizu 890ddd
#include "iwa_particlesfx.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
struct float3 {
Shinya Kitaoka 120a6e
  float x, y, z;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class Iwa_Particle;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//--------------------
Toshihiro Shimizu 890ddd
/* 粒子を規則正しく配する、その位置情報と
Toshihiro Shimizu 890ddd
 (剥がれるきっかけとなる)現在のポテンシャルを格納 -*/
Toshihiro Shimizu 890ddd
struct ParticleOrigin {
Shinya Kitaoka 120a6e
  float pos[2];
Shinya Kitaoka 120a6e
  float potential;
Shinya Kitaoka 120a6e
  /*- 上を向いているかどうか -*/
Shinya Kitaoka 120a6e
  bool isUpward;
Shinya Kitaoka 120a6e
  /*- どのテクスチャ素材を使うか -*/
Shinya Kitaoka 120a6e
  unsigned char level;
Shinya Kitaoka 120a6e
  /*- 何番目のフレームを使うか -*/
Shinya Kitaoka 120a6e
  unsigned char initSourceFrame;
Shinya Kitaoka 120a6e
  /*- ピクセル位置 -*/
Shinya Kitaoka 120a6e
  short int pixPos[2];
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  ParticleOrigin(float x, float y, float _potential, bool _isUpward,
Shinya Kitaoka 120a6e
                 unsigned char _level, unsigned char _initSourceFrame,
Shinya Kitaoka 120a6e
                 short int pix_x, short int pix_y) {
Shinya Kitaoka 120a6e
    pos[0]          = x;
Shinya Kitaoka 120a6e
    pos[1]          = y;
Shinya Kitaoka 120a6e
    potential       = _potential;
Shinya Kitaoka 120a6e
    isUpward        = _isUpward;
Shinya Kitaoka 120a6e
    level           = _level;
Shinya Kitaoka 120a6e
    initSourceFrame = _initSourceFrame;
Shinya Kitaoka 120a6e
    pixPos[0]       = pix_x;
Shinya Kitaoka 120a6e
    pixPos[1]       = pix_y;
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//--------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class Iwa_Particles_Engine {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  Iwa_TiledParticlesFx *m_parent;
Shinya Kitaoka 120a6e
  double m_frame;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  Iwa_Particles_Engine(Iwa_TiledParticlesFx *parent, double frame);
Shinya Kitaoka 120a6e
  ~Iwa_Particles_Engine(){};
Shinya Kitaoka 120a6e
  // Destructor
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void scramble_particles(void);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void fill_range_struct(struct particles_values &values,
Shinya Kitaoka 120a6e
                         struct particles_ranges &ranges);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void fill_value_struct(struct particles_values &value, double frame);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void roll_particles(TTile *tile, std::map<int, *="" ttile=""> porttiles,</int,>
Shinya Kitaoka 120a6e
                      const TRenderSettings &ri,
Shinya Kitaoka 120a6e
                      std::list<iwa_particle> &myParticles,</iwa_particle>
Shinya Kitaoka 120a6e
                      struct particles_values &values, float cx, float cy,
Shinya Kitaoka 120a6e
                      int frame, int curr_frame, int level_n,
Shinya Kitaoka 120a6e
                      bool *random_level, float dpi, std::vector<int> lastframe,</int>
Shinya Kitaoka 120a6e
                      int &totalparticles,
Shinya Kitaoka 120a6e
                      QList<particleorigin> &particleOrigin, int genPartNum);</particleorigin>
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void normalize_values(struct particles_values &values,
Shinya Kitaoka 120a6e
                        const TRenderSettings &ri);
Shinya Kitaoka 120a6e
Jeremy Bullock 852210
  void render_particles(TTile *tile, std::vector<trasterfxport *=""> part_ports,</trasterfxport>
Jeremy Bullock 852210
                        const TRenderSettings &ri, TDimension &p_size,
Jeremy Bullock 852210
                        TPointD &p_offset,
Jeremy Bullock 852210
                        std::map<int, *="" trasterfxport=""> ctrl_ports,</int,>
Jeremy Bullock 852210
                        std::vector<tlevelp> partLevel, float dpi,</tlevelp>
Jeremy Bullock 852210
                        int curr_frame, int shrink, double startx,
Jeremy Bullock 852210
                        double starty, double endx, double endy,
Jeremy Bullock 852210
                        std::vector<int> lastframe, unsigned long fxId);</int>
Shinya Kitaoka 120a6e
Jeremy Bullock 175c6b
  void do_render(Iwa_Particle *part, TTile *tile,
Shinya Kitaoka 120a6e
                 std::vector<trasterfxport *=""> part_ports,</trasterfxport>
Shinya Kitaoka 120a6e
                 std::map<int, *="" ttile=""> porttiles, const TRenderSettings &ri,</int,>
Shinya Kitaoka 120a6e
                 TDimension &p_size, TPointD &p_offset, int lastframe,
Shinya Kitaoka 120a6e
                 std::vector<tlevelp> partLevel,</tlevelp>
Shinya Kitaoka 120a6e
                 struct particles_values &values, float opacity_range,
Shinya Kitaoka 120a6e
                 int curr_frame,
Shinya Kitaoka 120a6e
                 std::map<std::pair<int, int="">, float> &partScales,</std::pair<int,>
Shinya Kitaoka 120a6e
                 TTile *baseImgTile);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  bool port_is_used(int i, struct particles_values &values);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void fill_single_region(std::vector<tpointd> &myregions, TTile *ctrl1,</tpointd>
Shinya Kitaoka 120a6e
                          int thres, bool do_source_gradation,
Shinya Kitaoka 120a6e
                          QList<qlist<int>> &myHistogram,</qlist<int>
Shinya Kitaoka 120a6e
                          QList<particleorigin> &particleOrigins);</particleorigin>
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void fill_subregions(int cont_index,
Shinya Kitaoka 120a6e
                       std::vector<std::vector<tpointd>> &myregions,</std::vector<tpointd>
Shinya Kitaoka 120a6e
                       TTile *ctrl1, int thres);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void normalize_array(std::vector<std::vector<tpointd>> &myregions,</std::vector<tpointd>
Shinya Kitaoka 120a6e
                       TPointD pos, int lx, int ly, int regioncounter,
Shinya Kitaoka 120a6e
                       std::vector<int> &myarray, std::vector<int> &lista,</int></int>
Shinya Kitaoka 120a6e
                       std::vector<int> &listb, std::vector<int> & final);</int></int>
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void fill_array(TTile *ctrl1, int ®ioncount, std::vector<int> &myarray,</int>
Shinya Kitaoka 120a6e
                  std::vector<int> &lista, std::vector<int> &listb, int thres);</int></int>
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /*- 敷き詰めのため。まだ出発していない粒子情報を初期化 -*/
Shinya Kitaoka 120a6e
  void initParticleOrigins(TRectD &outTileBBox,
Shinya Kitaoka 120a6e
                           QList<particleorigin> &particleOrigins,</particleorigin>
Shinya Kitaoka 120a6e
                           const double frame, const TAffine affine,
Shinya Kitaoka 120a6e
                           struct particles_values &values, int level_n,
Shinya Kitaoka 120a6e
                           std::vector<int> &lastframe, double pixelMargin);</int>
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /*- Particle::create_Animationと同じ。粒子発生前に
Shinya Kitaoka 120a6e
          あらかじめ計算してparticesOriginに持たせるため -*/
Shinya Kitaoka 120a6e
  unsigned char getInitSourceFrame(const particles_values &values, int first,
Shinya Kitaoka 120a6e
                                   int last);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /*- ここで、出発した粒子の分、穴を開けた背景を描く -*/
Shinya Kitaoka 120a6e
  void renderBackground(TTile *tile, QList<particleorigin> &origins,</particleorigin>
Shinya Kitaoka 120a6e
                        std::vector<trasterfxport *=""> part_ports,</trasterfxport>
Shinya Kitaoka 120a6e
                        const TRenderSettings &ri,
Shinya Kitaoka 120a6e
                        std::vector<tlevelp> partLevel,</tlevelp>
Shinya Kitaoka 120a6e
                        std::map<std::pair<int, int="">, float> &partScales,</std::pair<int,>
Shinya Kitaoka 120a6e
                        TTile *baseImgTile);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif