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