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

	Behavior.h

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

	Author:	Guillaume Chermette

	Date:	11/05/99

	Revision History

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

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

#ifndef __BEHAVIOR__
#define __BEHAVIOR__

#if CP_PRAGMA_ONCE
#pragma once
#endif

#include "BehaviorDef.h"
#include "BasicModifiers.h"
#include "I3dExModifier.h"
#include "I3dExAnimation.h"
#include "PublicUtilities.h"
#include "MCString.h"
#include "Id.h"
#include "IShTokenStream.h"

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

extern const MCGUID CLSID_Behavior;


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

#define kObject1 'obj1'
#define kObject2 'obj2'

struct BehaviorData
{
  real32		fRelPos;		// relative position between the two objects (0 first, 1 second)
};

class Behavior : public TBasicTreeModifier, public IExStreamIO
{

	public :  
		Behavior();
  
		// IMCUnknown Interface :
		STANDARD_RELEASE;

		virtual MCErr  MCCOMAPI QueryInterface	(const MCIID& riid, void** ppvObj);
		virtual uint32 MCCOMAPI AddRef			() { return TBasicTreeModifier::AddRef(); }

		// I3DExModifier methods :
		virtual void*	 MCCOMAPI GetExtensionDataBuffer	();
		virtual int32	 MCCOMAPI GetParamsBufferSize		() const	{ return sizeof(fData);}
		virtual MCCOMErr MCCOMAPI ExtensionDataChanged		();
		virtual void	 MCCOMAPI Clone						(IExDataExchanger**,IMCUnknown* pUnkOuter);
		virtual MCCOMErr MCCOMAPI CopyComponentExtraData (IExDataExchanger* dest);

		virtual MCCOMErr MCCOMAPI HandleEvent				(int32 message,
															 IMFResponder* source,
															 void* data);
		virtual int16	 MCCOMAPI GetResID					();
  
		virtual MCCOMErr MCCOMAPI Apply						(I3DShTreeElement* tree);

		// IExStreamIO methods
		virtual MCCOMErr MCCOMAPI Read				(IShTokenStream* stream, ReadAttributeProc readUnknown, void* privData); // readUnknown should be called by extention if unknown keyword is encountered (instead of calling SkipoTokenData)
		virtual MCCOMErr MCCOMAPI Write				(IShTokenStream* stream);
		virtual MCCOMErr MCCOMAPI FinishRead		(IStreamContext* streamContext){return MC_S_OK;}

	private :
		BehaviorData    fData;      // Behavior Data
		TTreeIdPath		fObject1,
						fObject2;
  };


#endif