
/****************************************************************************************

	Explode.h

	Copyright (c)1990 - 1999 MetaCreations. All rights reserved.

	Author:	Guillaume Chermette

	Date:	08/20/99

	Revision History

	when		who			what & why
	=========== ===========	=============================================================

****************************************************************************************/

#ifndef __EXPLODE__
#define __EXPLODE__

#if CP_PRAGMA_ONCE
#pragma once
#endif

#include	"BasicModifiers.h"   
#include	"I3dExModifier.h"
#include	"I3dWireFrame.h"
#include	"ExplodeDef.h"
#include	"PublicUtilities.h"

//****** Globally Unique Id *************************************************

extern const MCGUID CLSID_Explode;


//***************************************************************************

struct ExplodeData {

  real		fMinSize;
  real		fExplosionFactor;
  real		fFloor;
  real		fGravityCoef;
  bool		fApplyGravity;
  TBBox3D	fBoundingBox;  // Bounding Box
};


// Number Maximum of subdivisions of a Facet
#define SPLITMAX 8


/*****************************************************************************\
*                                                                             *
*  Explode                                                                    *
*                                                                             *
\*****************************************************************************/

// Deformer Object :
class Explode : public TBasicDeformModifier 
{

public :  

	Explode();
  
	// IUnknown Interface :
	STANDARD_RELEASE;
	
  	// I3DExDataExchanger methods :
	virtual void*			MCCOMAPI GetExtensionDataBuffer();
	virtual int32	 MCCOMAPI GetParamsBufferSize		() const	{ return sizeof(fData);}
	virtual int16			MCCOMAPI GetResID();
  
	// I3DExDeformer methods :
	virtual void			MCCOMAPI SetBoundingBox		(const TBBox3D& bbox);
	virtual MCCOMErr		MCCOMAPI DeformPoint		(const TVector3& point, TVector3& result);
	virtual MCCOMErr		MCCOMAPI DeformFacetMesh	(real lod,FacetMesh* in, FacetMesh** outMesh);
	virtual MCCOMErr		MCCOMAPI DeformBBox			(const TBBox3D& in, TBBox3D& out);
	virtual TModifierFlags	MCCOMAPI GetModifierFlags	()	{ return fFlags; }


protected :

	ExplodeData	fData;         // Deformer Data
	void		explodeFacet	(const TFacet3D* aFacet, FacetMeshAccumulator* accu, int16 level=0);
	void		moveFacet		(TFacet3D* aFacet);

};

#endif