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

		I3DExForce.h

		Copyright: (c) 2001 Eovia Corp. All rights reserved.

		I3DExModifier definition

		Author:	Joshua
		Date:	3/23/99

		Revision History

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

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

#ifndef __I3DEXFORCE__
#define __I3DEXFORCE__

#if CP_PRAGMA_ONCE
#pragma once
#endif

#include "MCCompObj.h"
#include "I3DShTreeElement.h"
#include "RealQuat.h"

struct I3DShTreeElement;

//****** Globally Unique Ids *************************************************

MCDEFINE_GUID	(IID_I3DExForce, 0xda1b8040, 0xe16c, 0x11d2, 0x88, 0x86, 0x0, 0x60, 0x97, 0x14, 0x85, 0x21);

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

/// State of an object animated by the physics engine
///
struct TPhysicalState : public TMCObject
{
	TPhysicalState() : fIsHair(false) {}

	TMCCountedPtr<I3DShTreeElement>	fForceTree; ///< the tree of the force
	TMCCountedPtr<I3DShTreeElement>	fApplyTree; ///< the tree of the object on which the force is applied
	real				fMass;					///< the mass of the object
	real				fSimulationStep;		///< the time duration during which the force is applied
	TVector3			fPosition;				///< the position of the point where the force is applied in global coordinates
	TVector3			fVelocity;				///< the velocity of the point in global coordinates
	TVector3			fAngularVelocity;		///< the angular velocity of the point in global coordinates
	TUnitQuaternion		fOrientation;			///< the local orientation at the point in global coordinates
	real				fSurface;
	boolean				fIsHair;
};

/// \addtogroup ExternalInterface
/// \{


// ****************************************************************************
//					I3DExForce			
// 
/// I3DExForce defines a generic force that applies to all objects whose motion is controlled by
/// physics.
///
struct I3DExForce : public IMCUnknown
{
	// ****************************************************************************
	//								GetForceAndTorque
	// 
	/// Returns the force applied to an object in a given state (the force can depend
	/// position, speed, ...)
	///
	/// \param inPhysicalState	State of the object to which the force is applied
	/// \param outForce			Force that is applied to this object in global coordinates
	/// \param outTorque		Torque that is applied to this object in global coordinates
	///
	/// \return MC_S_OK if succeeded.
	///
	virtual MCCOMErr	MCCOMAPI GetForceAndTorque	(const TPhysicalState& inPhysicalState, TVector3& outForce, TVector3& outTorque)=0;
	
	// ****************************************************************************
	//							WillApplyForce	
	// 
	/// Returns true if this for applies a force (by opposition to torque)
	///
	virtual boolean		MCCOMAPI WillApplyForce		()=0;
	
	// ****************************************************************************
	//							WillApplyForce	
	// 
	/// Returns true if this for applies a torque (by opposition to force)
	///
	virtual boolean		MCCOMAPI WillApplyTorque	()=0;
};

/// \}

#endif