///////////////////////////////////////////////////////////
//
//  DEFINITION
//
//  CONTEXT: Genesis3D lightweight framework
//  MODULE:	 some light effects
//  PREREQ:	 genewrap.h 
//  FILE:	 effects.h
//	AUTHOR:  Klaus Zerbe <klaus@zerbe.com>
//  ORIGIN:  http://klaus.zerbe.com
//  VERSION: 1.0
//  DATE:    3.2.1999
//  PURPOSE: Lichteffekte
//  DISCLAIMER:
//  	This code in moost pars is "stolen" from the GTEST
//      example files: dynlight.*, corona.*, and electric.*
//      Not much comments here, since it is assimilated to the
//      framework in the same way as all my other entities
//
///////////////////////////////////////////////////////////

#pragma warning( disable : 4068 )

#pragma GE_Type("dynlight.bmp")
typedef struct	DynamicLight
{
#pragma	GE_Private
	geFloat			LastTime;
	geFloat			IntervalWidth;
	int				NumFunctionValues;
	geLight *		DynLight;
	
#pragma GE_Published
    geVec3d			origin;
    int				MinRadius;
    int				MaxRadius;
	int				InterpolateValues;
	int				AllowRotation;
    char *			RadiusFunction;
    geFloat			RadiusSpeed;
	geWorld_Model *	Model;
    GE_RGBA			Color;

#pragma GE_Origin(origin)
#pragma GE_DefaultValue(MinRadius, "50")
#pragma GE_DefaultValue(MaxRadius, "300")
#pragma GE_DefaultValue(Color, "40.0 40.0 153.0")
#pragma GE_DefaultValue(RadiusFunction, "aza")
#pragma GE_DefaultValue(RadiusSpeed, "2.0")
#pragma GE_DefaultValue(InterpolateValues, "1")
#pragma GE_DefaultValue(AllowRotation, "1")

#pragma GE_Documentation(MinRadius, "Minimum radius of the light (texels)")
#pragma GE_Documentation(MaxRadius, "Maximum radius of the light (texels)")
#pragma GE_Documentation(InterpolateValues, "0 or 1.  Whether to interpolate between the RadiusFunction values")
#pragma GE_Documentation(AllowRotation, "0 or 1.  Whether or not to follow the model rotation if the light is attached to a model")
#pragma GE_Documentation(RadiusFunction, "a-z, repeated (E.g. aabdfzddsfdz)  Specify light values over time.  a = Minimum z = maximum")
#pragma GE_Documentation(RadiusSpeed, "How fast to run through RadiusFunction values (seconds)")
#pragma GE_Documentation(Model, "Model that the light is attached to.  Optional")
#pragma GE_Documentation(Color, "Color of the light")
}	DynamicLight;

class CDynamicLight : public CEntityTemplate {
public:
	CDynamicLight(CEngineWrapper *pEngine);
	~CDynamicLight() {}
	void Render(geXForm3d *pViewPoint, DWORD  dwTime);
};

#pragma GE_Type("corona.bmp")
typedef struct Corona
{
#pragma	GE_Private
	geFloat			LastTime;
	geFloat			LastVisibleTime;
	geFloat			LastVisibleRadius;
	
#pragma GE_Published
    geVec3d			origin;
	int				FadeOut;
	geFloat			FadeTime;
    int				MinRadius;
    int				MaxRadius;
	int				MaxVisibleDistance;
	int				MaxRadiusDistance;
	int				MinRadiusDistance;
	int				AllowRotation;
	geWorld_Model *	Model;
    GE_RGBA			Color;

#pragma GE_Origin(origin)
#pragma GE_DefaultValue(FadeOut, "1")
#pragma GE_DefaultValue(FadeTime, "0.15")
#pragma GE_DefaultValue(MinRadius, "1")
#pragma GE_DefaultValue(MaxRadius, "20")
#pragma GE_DefaultValue(MaxVisibleDistance, "2000")
#pragma GE_DefaultValue(MaxRadiusDistance, "1000")
#pragma GE_DefaultValue(MinRadiusDistance, "100")
#pragma GE_DefaultValue(AllowRotation, "1")
#pragma GE_DefaultValue(Color, "255.0 255.0 255.0")

#pragma GE_Documentation(FadeOut, "Whether to fade out coronas when they pass out of visibility (0 or 1)")
#pragma GE_Documentation(FadeTime, "How long the fade takes to drop to zero visibility (seconds)")
#pragma GE_Documentation(MinRadius, "Minimum radius corona will ever drop to (texels)")
#pragma GE_Documentation(MaxRadius, "Maximum radius corona will ever increase to (texels)")
#pragma GE_Documentation(MaxVisibleDistance, "Maximum distance corona is visible at (texels)")
#pragma GE_Documentation(MaxRadiusDistance, "Above this distance, corona is capped at MaxRadius (texels)")
#pragma GE_Documentation(MinRadiusDistance, "Below this distance, corona is capped at MinRadius (texels)")
#pragma GE_Documentation(AllowRotation, "Permit rotation about model, if one is present (0 or 1)")
#pragma GE_Documentation(Model, "World model to slave motion of corona to")
}	Corona;

class CCorona : public CEntityTemplate {
public:
	CCorona(CEngineWrapper *pEngine);
	~CCorona();
	void Render(geXForm3d *pViewPoint, DWORD  dwTime);
private:
	geBitmap *m_pCoronaBitmap;
};

typedef struct	Electric_BoltEffect	Electric_BoltEffect;

#pragma GE_Type("terminus.bmp")
typedef struct	ElectricBoltTerminus
{
#pragma GE_Published
    geVec3d			origin;

#pragma GE_Origin(origin)
}	ElectricBoltTerminus;

#pragma GE_Type("bolt.bmp")
typedef struct	ElectricBolt
{
#pragma	GE_Private
	geFloat					LastTime;
	geFloat					LastBoltTime;
	Electric_BoltEffect *	Bolt;
	geSound *				LoopingSound;
	
#pragma GE_Published
    geVec3d					origin;
    int						Width;
    int						NumPoints;
    int						Intermittent;
    geFloat					MinFrequency;
    geFloat					MaxFrequency;
    geFloat					Wildness;
    ElectricBoltTerminus *	Terminus;
    int						DominantColor;
    GE_RGBA					Color;

#pragma GE_Origin(origin)
#pragma GE_DefaultValue(Width, "8")
#pragma GE_DefaultValue(NumPoints, "64")
#pragma GE_DefaultValue(Intermittent, "1")
#pragma GE_DefaultValue(MinFrequency, "4.0")
#pragma GE_DefaultValue(MaxFrequency, "1.0")
#pragma GE_DefaultValue(Wildness, "0.5")
#pragma GE_DefaultValue(DominantColor, "2")
#pragma GE_DefaultValue(Color, "160.0 160.0 255.0")

#pragma GE_Documentation(Width, "Width in texels of the bolt")
#pragma GE_Documentation(NumPoints, "Power of 2.  Number of control points.  Stick to 32, 64, 128.")
#pragma GE_Documentation(Intermittent, "0 or 1.  Whether or not the bolt is continuous, or random")
#pragma GE_Documentation(MinFrequency, "If the bolt is intermittent, the minimum time in seconds between zaps")
#pragma GE_Documentation(MaxFrequency, "If the bolt is intermittent, the maximum time in seconds between zaps")
#pragma GE_Documentation(Wildness, "Degree of 'freneticity' of the bolt (0 to 1)")
#pragma GE_Documentation(Terminus, "Where the other end of the bolt is")
#pragma GE_Documentation(DominantColor, "Specifies the dominant color of the bolt. 0 = Red, 1 = Green, 2 = Blue")
#pragma GE_Documentation(Color, "Base color of the bolt.  The two non-dominant color values MUST be the same!")

}	ElectricBolt;

class CElectricBolt : public CEntityTemplate {
public:
	CElectricBolt(CEngineWrapper *pEngine);
	~CElectricBolt();
	void Render(geXForm3d *pViewPoint, DWORD  dwTime);
private:
	geBitmap *m_pBitmap;
	geSound_Def *m_pLoopingDef, *m_pSingleDef;
};


#define	ELECTRIC_BOLT_REDDOMINANT	0
#define	ELECTRIC_BOLT_GREENDOMINANT	1
#define	ELECTRIC_BOLT_BLUEDOMINANT	2

Electric_BoltEffect * Electric_BoltEffectCreate(
	geBitmap				*Texture,	/* The texture we map onto the bolt */
	geBitmap				*Texture2,	/* The texture we map onto the bolt */
	int 					NumPolys,	/* Number of polys, must be power of 2 */
	int						Width,		/* Width in world units of the bolt */
	geFloat 				Wildness);	/* How wild the bolt is (0 to 1 inclusive) */

void Electric_BoltEffectDestroy(Electric_BoltEffect *Effect);

void Electric_BoltEffectAnimate(
	Electric_BoltEffect *	Effect,
	const geVec3d *			start,		/* Starting point of the bolt */
	const geVec3d *			end);		/* Ending point of the bolt */

void Electric_BoltEffectRender(
	geWorld *				World,		/* World to render for */
	Electric_BoltEffect *	Effect,		/* Bolt to render */
	const geXForm3d *		XForm);		/* Transform of our point of view */

void Electric_BoltEffectSetColorInfo(
	Electric_BoltEffect *	Effect,
	GE_RGBA *				BaseColor,		/* Base color of the bolt (2 colors should be the same */
	int						DominantColor);	/* Which color is the one to leave fixed */


#pragma warning( default : 4068 )
