PageRenderTime 70ms CodeModel.GetById 13ms app.highlight 52ms RepoModel.GetById 2ms app.codeStats 0ms

/xbmc/visualizations/Milkdrop/vis_milkdrop/state.h

http://github.com/xbmc/xbmc
C++ Header | 408 lines | 266 code | 63 blank | 79 comment | 0 complexity | 9b4628fecd38ceb08c201b087b1395ba MD5 | raw file
  1/*
  2  LICENSE
  3  -------
  4Copyright 2005 Nullsoft, Inc.
  5All rights reserved.
  6
  7Redistribution and use in source and binary forms, with or without modification, 
  8are permitted provided that the following conditions are met:
  9
 10  * Redistributions of source code must retain the above copyright notice,
 11    this list of conditions and the following disclaimer. 
 12
 13  * Redistributions in binary form must reproduce the above copyright notice,
 14    this list of conditions and the following disclaimer in the documentation
 15    and/or other materials provided with the distribution. 
 16
 17  * Neither the name of Nullsoft nor the names of its contributors may be used to 
 18    endorse or promote products derived from this software without specific prior written permission. 
 19 
 20THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR 
 21IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
 22FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 
 23CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 24DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 25DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
 26IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 
 27OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 28
 29*/
 30#ifndef _MILKDROP_STATE_
 31#define _MILKDROP_STATE_ 1
 32
 33
 34#include <memory.h>
 35#include <stdlib.h>
 36#include <stdio.h>
 37
 38#include "evallib/eval.h"
 39#include "md_defines.h"
 40
 41// flags for CState::RecompileExpressions():
 42#define RECOMPILE_PRESET_CODE  1
 43#define RECOMPILE_WAVE_CODE    2
 44#define RECOMPILE_SHAPE_CODE   4
 45
 46class CBlendableFloat
 47{
 48public:
 49	CBlendableFloat();
 50	~CBlendableFloat();
 51
 52	float operator = (float f) { 
 53		val = f; 
 54		m_bBlending = false; 
 55        return val;
 56	};
 57	float operator *= (float f) { 
 58		val *= f; 
 59		m_bBlending = false; 
 60        return val;
 61	};
 62	float operator /= (float f) { 
 63		val /= f; 
 64		m_bBlending = false; 
 65        return val;
 66	};
 67	float operator -= (float f) { 
 68		val -= f; 
 69		m_bBlending = false; 
 70        return val;
 71	};
 72	float operator += (float f) { 
 73		val += f; 
 74		m_bBlending = false; 
 75        return val;
 76	};
 77
 78	float eval(float fTime);	// call this from animation code.  if fTime < 0, it will return unblended 'val'.
 79	void  StartBlendFrom(CBlendableFloat *f_from, float fAnimTime, float fDuration);
 80
 81protected:
 82	float val;
 83	bool  m_bBlending;
 84	float m_fBlendStartTime;
 85	float m_fBlendDuration;
 86	float m_fBlendFrom;
 87};
 88
 89class CShape
 90{
 91public:
 92    int  Import(char* szSection, char* szFile, int i);
 93    int  Export(char* szSection, char* szFile, int i, FILE* fOut=NULL);
 94
 95    int   enabled;
 96    int   sides;
 97    int   additive;
 98    int   thickOutline;
 99    int   textured;
100    float x,y,rad,ang;
101    float r,g,b,a;
102    float r2,g2,b2,a2;
103    float border_r,border_g,border_b,border_a;
104    float tex_ang, tex_zoom;
105
106    char  m_szInit[8192]; // note: only executed once -> don't need to save codehandle
107    char  m_szPerFrame[8192];
108    //char  m_szPerPoint[8192];
109    int   m_pf_codehandle;
110    //int   m_pp_codehandle;
111
112	// for per-frame expression evaluation:
113    varType	m_pf_vars[EVAL_MAX_VARS];
114	double *var_pf_time, *var_pf_fps;
115	double *var_pf_frame;
116	double *var_pf_progress;
117	double *var_pf_q1, *var_pf_q2, *var_pf_q3, *var_pf_q4, *var_pf_q5, *var_pf_q6, *var_pf_q7, *var_pf_q8;
118	double *var_pf_t1, *var_pf_t2, *var_pf_t3, *var_pf_t4, *var_pf_t5, *var_pf_t6, *var_pf_t7, *var_pf_t8;
119	double *var_pf_bass, *var_pf_mid, *var_pf_treb, *var_pf_bass_att, *var_pf_mid_att, *var_pf_treb_att;
120	double *var_pf_r, *var_pf_g, *var_pf_b, *var_pf_a;
121	double *var_pf_r2, *var_pf_g2, *var_pf_b2, *var_pf_a2;
122	double *var_pf_border_r, *var_pf_border_g, *var_pf_border_b, *var_pf_border_a;
123    double *var_pf_x, *var_pf_y, *var_pf_rad, *var_pf_ang;
124    double *var_pf_sides, *var_pf_textured, *var_pf_additive, *var_pf_thick;
125    double *var_pf_tex_zoom, *var_pf_tex_ang;
126
127	// for per-point expression evaluation:
128    /*
129    varType m_pp_vars[EVAL_MAX_VARS];
130	double *var_pp_time, *var_pp_fps;
131	double *var_pp_frame;
132	double *var_pp_progress;
133	double *var_pp_q1, *var_pp_q2, *var_pp_q3, *var_pp_q4, *var_pp_q5, *var_pp_q6, *var_pp_q7, *var_pp_q8;
134	double *var_pp_t1, *var_pp_t2, *var_pp_t3, *var_pp_t4, *var_pp_t5, *var_pp_t6, *var_pp_t7, *var_pp_t8;
135	double *var_pp_bass, *var_pp_mid, *var_pp_treb, *var_pp_bass_att, *var_pp_mid_att, *var_pp_treb_att;
136	double *var_pp_r, *var_pp_g, *var_pp_b, *var_pp_a;
137	double *var_pp_r2, *var_pp_g2, *var_pp_b2, *var_pp_a2;
138	double *var_pp_border_r, *var_pp_border_g, *var_pp_border_b, *var_pp_border_a;
139    double *var_pp_x, *var_pp_y, *var_pp_rad, *var_pp_ang, *var_pp_sides;
140    */
141
142	double t_values_after_init_code[8];
143
144};
145
146class CWave
147{
148public:
149    int  Import(char* szSection, char *szFile, int i);
150    int  Export(char* szSection, char* szFile, int i, FILE* fOut=NULL);
151
152    int   enabled;
153    int   samples;
154    int   sep;
155    float scaling;
156    float smoothing;
157    float x,y,r,g,b,a;
158    int   bSpectrum;
159    int   bUseDots;
160    int   bDrawThick;
161    int   bAdditive;
162
163    char  m_szInit[8192]; // note: only executed once -> don't need to save codehandle
164    char  m_szPerFrame[8192];
165    char  m_szPerPoint[8192];
166    int   m_pf_codehandle;
167    int   m_pp_codehandle;
168
169	// for per-frame expression evaluation:
170    varType	m_pf_vars[EVAL_MAX_VARS];
171	double *var_pf_time, *var_pf_fps;
172	double *var_pf_frame;
173	double *var_pf_progress;
174	double *var_pf_q1, *var_pf_q2, *var_pf_q3, *var_pf_q4, *var_pf_q5, *var_pf_q6, *var_pf_q7, *var_pf_q8;
175	double *var_pf_t1, *var_pf_t2, *var_pf_t3, *var_pf_t4, *var_pf_t5, *var_pf_t6, *var_pf_t7, *var_pf_t8;
176	double *var_pf_bass, *var_pf_mid, *var_pf_treb, *var_pf_bass_att, *var_pf_mid_att, *var_pf_treb_att;
177	double *var_pf_r, *var_pf_g, *var_pf_b, *var_pf_a;
178
179	// for per-point expression evaluation:
180    varType m_pp_vars[EVAL_MAX_VARS];
181	double *var_pp_time, *var_pp_fps;
182	double *var_pp_frame;
183	double *var_pp_progress;
184	double *var_pp_q1, *var_pp_q2, *var_pp_q3, *var_pp_q4, *var_pp_q5, *var_pp_q6, *var_pp_q7, *var_pp_q8;
185	double *var_pp_t1, *var_pp_t2, *var_pp_t3, *var_pp_t4, *var_pp_t5, *var_pp_t6, *var_pp_t7, *var_pp_t8;
186	double *var_pp_bass, *var_pp_mid, *var_pp_treb, *var_pp_bass_att, *var_pp_mid_att, *var_pp_treb_att;
187    double *var_pp_sample, *var_pp_value1, *var_pp_value2;
188	double *var_pp_x, *var_pp_y, *var_pp_r, *var_pp_g, *var_pp_b, *var_pp_a;
189
190	double t_values_after_init_code[8];
191
192};
193
194typedef struct 
195{
196	int   type;		
197	int   in_var;	
198	int   out_var;	
199	float constant;
200	float min;
201	float max;
202	float in_scale;	
203	float amp;		// for sine functions
204	float freq;		// for sine functions
205	float freq2;	// for sine functions
206	float phase;	// for sine functions
207	float phase2;	// for sine functions
208} td_modifier;
209
210
211//#define MAX_EVALS 8
212
213
214class CState
215{
216public:
217	CState();
218	~CState();
219
220	void Default();
221	void Randomize(int nMode);
222	void StartBlendFrom(CState *s_from, float fAnimTime, float fTimespan);
223	void Import(char *szSectionName, char *szIniFile);
224	bool Export(char *szSectionName, char *szIniFile);
225	void RecompileExpressions(int flags=0xFFFFFFFF, int bReInit=1);
226
227	char m_szDesc[512];		// this is just the filename, without a path or extension.
228	//char m_szSection[256];
229
230	float				m_fRating;		// 0..5
231	// post-processing:
232	CBlendableFloat		m_fGammaAdj;	// +0 -> +1.0 (double), +2.0 (triple)...
233	CBlendableFloat		m_fVideoEchoZoom;
234	CBlendableFloat 	m_fVideoEchoAlpha;
235	float				m_fVideoEchoAlphaOld;
236	int					m_nVideoEchoOrientation;
237	int					m_nVideoEchoOrientationOld;
238
239	// fps-dependant:
240	CBlendableFloat		m_fDecay;			// 1.0 = none, 0.95 = heavy decay
241
242	// other:
243	int					m_nWaveMode;
244	int					m_nOldWaveMode;
245	bool				m_bAdditiveWaves;
246	CBlendableFloat		m_fWaveAlpha;
247	CBlendableFloat		m_fWaveScale;
248	CBlendableFloat		m_fWaveSmoothing;	
249	bool				m_bWaveDots;
250	bool                m_bWaveThick;
251	CBlendableFloat		m_fWaveParam;		// -1..1; 0 is normal
252	bool				m_bModWaveAlphaByVolume;
253	CBlendableFloat		m_fModWaveAlphaStart;	// when relative volume hits this level, alpha -> 0
254	CBlendableFloat		m_fModWaveAlphaEnd;		// when relative volume hits this level, alpha -> 1
255	float				m_fWarpAnimSpeed;	// 1.0 = normal, 2.0 = double, 0.5 = half, etc.
256	CBlendableFloat		m_fWarpScale;
257	CBlendableFloat		m_fZoomExponent;
258	CBlendableFloat		m_fShader;			// 0 = no color shader, 1 = full color shader
259	bool				m_bMaximizeWaveColor;
260	bool				m_bTexWrap;
261	bool				m_bDarkenCenter;
262	bool				m_bRedBlueStereo;
263	bool				m_bBrighten;
264	bool				m_bDarken;
265	bool				m_bSolarize;
266	bool				m_bInvert;
267	/*
268	bool				m_bPlates;
269	int					m_nPlates;
270	CBlendableFloat		m_fPlateAlpha;		// 0 = off, 0.1 = barely visible, 1.0 = solid
271	CBlendableFloat		m_fPlateR;
272	CBlendableFloat		m_fPlateG;
273	CBlendableFloat		m_fPlateB;
274	CBlendableFloat		m_fPlateWidth;		// 1.0=normal, 2.0=double, etc.
275	CBlendableFloat		m_fPlateLength;		// 1.0=normal, 2.0=double, etc.
276	float				m_fPlateSpeed;		// 1.0=normal, 2.0=double, etc.
277	bool				m_bPlatesAdditive;
278	*/
279
280	// map controls:
281	CBlendableFloat		m_fZoom;
282	CBlendableFloat		m_fRot;	
283	CBlendableFloat		m_fRotCX;	
284	CBlendableFloat		m_fRotCY;	
285	CBlendableFloat		m_fXPush;
286	CBlendableFloat		m_fYPush;
287	CBlendableFloat		m_fWarpAmount;
288	CBlendableFloat		m_fStretchX;
289	CBlendableFloat		m_fStretchY;
290	CBlendableFloat		m_fWaveR;
291	CBlendableFloat		m_fWaveG;
292	CBlendableFloat		m_fWaveB;
293	CBlendableFloat		m_fWaveX;
294	CBlendableFloat		m_fWaveY;
295	CBlendableFloat		m_fOuterBorderSize;
296	CBlendableFloat		m_fOuterBorderR;
297	CBlendableFloat		m_fOuterBorderG;
298	CBlendableFloat		m_fOuterBorderB;
299	CBlendableFloat		m_fOuterBorderA;
300	CBlendableFloat		m_fInnerBorderSize;
301	CBlendableFloat		m_fInnerBorderR;
302	CBlendableFloat		m_fInnerBorderG;
303	CBlendableFloat		m_fInnerBorderB;
304	CBlendableFloat		m_fInnerBorderA;
305	CBlendableFloat		m_fMvX;
306	CBlendableFloat		m_fMvY;
307	CBlendableFloat		m_fMvDX;
308	CBlendableFloat		m_fMvDY;
309	CBlendableFloat		m_fMvL;
310	CBlendableFloat		m_fMvR;
311	CBlendableFloat		m_fMvG;
312	CBlendableFloat		m_fMvB;
313	CBlendableFloat		m_fMvA;
314
315    CShape              m_shape[MAX_CUSTOM_SHAPES];
316    CWave               m_wave[MAX_CUSTOM_WAVES];
317	
318	//COscillator			m_waveR;
319	//COscillator			m_waveG;
320	//COscillator			m_waveB;
321	//COscillator			m_wavePosX;		// 0 = centered
322	//COscillator			m_wavePosY;		// 0 = centered
323
324	// for arbitrary function evaluation:
325    int				m_pf_codehandle;	
326    int				m_pp_codehandle;	
327    char			m_szPerFrameInit[8192];
328    char			m_szPerFrameExpr[8192];
329    //char			m_szPerPixelInit[8192];
330    char			m_szPerPixelExpr[8192];
331	void			FreeVarsAndCode();
332	void			RegisterBuiltInVariables(int flags);
333	void			StripLinefeedCharsAndComments(char *src, char *dest);
334
335	bool  m_bBlending;
336	float m_fBlendStartTime;
337	float m_fBlendDuration;
338	float m_fBlendProgress;	// 0..1; updated every frame based on StartTime and Duration.
339
340	// for once-per-frame expression evaluation:
341    varType	m_pf_vars[EVAL_MAX_VARS];
342    double *var_pf_zoom, *var_pf_zoomexp, *var_pf_rot, *var_pf_warp, *var_pf_cx, *var_pf_cy, *var_pf_dx, *var_pf_dy, *var_pf_sx, *var_pf_sy;
343	double *var_pf_time, *var_pf_fps;
344	double *var_pf_bass, *var_pf_mid, *var_pf_treb, *var_pf_bass_att, *var_pf_mid_att, *var_pf_treb_att;
345	double *var_pf_wave_a, *var_pf_wave_r, *var_pf_wave_g, *var_pf_wave_b, *var_pf_wave_x, *var_pf_wave_y, *var_pf_wave_mystery, *var_pf_wave_mode;
346	double *var_pf_decay;
347	double *var_pf_frame;
348	double *var_pf_q1, *var_pf_q2, *var_pf_q3, *var_pf_q4, *var_pf_q5, *var_pf_q6, *var_pf_q7, *var_pf_q8;
349	double *var_pf_progress;
350	double *var_pf_ob_size, *var_pf_ob_r, *var_pf_ob_g, *var_pf_ob_b, *var_pf_ob_a;
351	double *var_pf_ib_size, *var_pf_ib_r, *var_pf_ib_g, *var_pf_ib_b, *var_pf_ib_a;
352	double *var_pf_mv_x;
353	double *var_pf_mv_y;
354	double *var_pf_mv_dx;
355	double *var_pf_mv_dy;
356	double *var_pf_mv_l;
357	double *var_pf_mv_r;
358	double *var_pf_mv_g;
359	double *var_pf_mv_b;
360	double *var_pf_mv_a;
361	double *var_pf_monitor;
362	double *var_pf_echo_zoom, *var_pf_echo_alpha, *var_pf_echo_orient;
363    // new in v1.04:
364	double *var_pf_wave_usedots, *var_pf_wave_thick, *var_pf_wave_additive, *var_pf_wave_brighten;
365    double *var_pf_darken_center, *var_pf_gamma, *var_pf_wrap;
366    double *var_pf_invert, *var_pf_brighten, *var_pf_darken, *var_pf_solarize;
367    double *var_pf_meshx, *var_pf_meshy;
368    // NOTE: IF YOU ADD NEW VARIABLES, BE SURE TO INCREASE THE VALUE OF 
369    // 'EVAL_MAX_VARS' IN EVAL.H.  OTHERWISE, SOME PRESETS MIGHT BREAK.
370    
371
372	// for per-vertex expression evaluation:
373    varType m_pv_vars[EVAL_MAX_VARS];
374    double *var_pv_zoom, *var_pv_zoomexp, *var_pv_rot, *var_pv_warp, *var_pv_cx, *var_pv_cy, *var_pv_dx, *var_pv_dy, *var_pv_sx, *var_pv_sy;
375	double *var_pv_time, *var_pv_fps;
376	double *var_pv_bass, *var_pv_mid, *var_pv_treb, *var_pv_bass_att, *var_pv_mid_att, *var_pv_treb_att;
377	double *var_pv_x, *var_pv_y, *var_pv_rad, *var_pv_ang;
378	double *var_pv_frame;
379	double *var_pv_q1, *var_pv_q2, *var_pv_q3, *var_pv_q4, *var_pv_q5, *var_pv_q6, *var_pv_q7, *var_pv_q8;
380	double *var_pv_progress;
381    double *var_pv_meshx, *var_pv_meshy;
382
383	double q_values_after_init_code[8];
384    double monitor_after_init_code;
385};
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408#endif