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

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

		Author:	charles
		Date:	5/19/2006

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

#ifndef __I3DExRigidBodySolver__
#define __I3DExRigidBodySolver__

#if CP_PRAGMA_ONCE
#pragma once
#endif

#include "APITypes.h"
#include "IExtension.h"
#include "InterfaceIDs.h"


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

MCDEFINE_GUID_H(IID_I3DExRigidBodySolver); 

//****** Family Id *************************************************

const FourCharT kRigidBodySolverFamilyID = kRID_RigidBodySolverFamilyID;


struct Triangle;
struct I3DExForce;

struct I3DExGeometry : public IMCUnknown
{
	// ****************************************************************************
	//								SetVerticesAndFaces
	// 
	/// Sets the vertices and the triangles of the geometry.
	/// 
	/// \param vertices   
	/// \param triangles  
	/// 
	virtual void MCCOMAPI SetVerticesAndFaces(TMCArray<TVector3>& vertices,TMCArray<Triangle>& triangles)=0;


};


struct I3DExPhysicForce : public IMCUnknown
{
};

struct I3DExRigidBody: public IMCUnknown
{
	// ****************************************************************************
	//								SetGeometry
	// 
	/// Sets the geometry associated with the mesh
	/// 
	/// \param geometry  
	/// 
	virtual void MCCOMAPI SetGeometry(I3DExGeometry* geometry) = 0;
	
	// ****************************************************************************
	//								SetTransform
	// 
	/// Sets the position of the rigid body
	/// 
	/// \param position     The position of the rigid body.
	/// \param orientation  The translation of the rigid body.
	/// 
	virtual void MCCOMAPI SetTransform(const TVector3d& position,const TUnitQuaterniond& orientation) = 0;

	// ****************************************************************************
	//								GetTransform
	// 
	/// Returns the position of the object.
	/// 
	/// \param position     
	/// \param orientation  
	/// 
	virtual void MCCOMAPI GetTransform(TVector3d& position,TUnitQuaterniond& orientation) = 0;

	virtual boolean MCCOMAPI IsStatic() const = 0;


	//virtual void MCCOMAPI SetIsStatic(boolean isStatic) = 0;

	//virtual double MCCOMAPI GetVolumeOfAggregateBody( void ) const = 0;

	virtual real MCCOMAPI ObjectMass() const = 0;

	virtual void MCCOMAPI SetFrictionCoefficient(real frictionCoef) = 0;
	virtual void MCCOMAPI SetBounciness(real bounce) = 0;
	virtual void MCCOMAPI SetDensity(real density) = 0;

	virtual void MCCOMAPI	SetVelocity(real x,real y,real z) = 0;
	virtual const TVector3d&	MCCOMAPI GetVelocity() const=0;


	virtual void MCCOMAPI SetAngularVelocity(real x,real y,real z) = 0;

	// ****************************************************************************
	//								SetPrivateData
	// 
	/// Stores data that the physics engine does not know about.
	/// 
	/// \param data  
	/// 
	virtual void MCCOMAPI SetPrivateData(IMCUnknown* data) = 0;

	// ****************************************************************************
	//								GetPrivateData
	// 
	/// Gets data that the physics engine does not know about.
	/// 
	/// 
	virtual IMCUnknown*	MCCOMAPI GetPrivateData() = 0;


	virtual void MCCOMAPI ClearForces()=0;

	virtual void MCCOMAPI AddForce(I3DExPhysicForce* const force)=0;

};


/// \addtogroup ExternalInterface
/// \{

/// <P>Cameras define the projection from the 3D world to the 2D screen on which the image
/// is rendered. There are two common forms of projection: orthographic and perspective.  
/// An orthographic camera takes rays parallel to the z-axis and projects them on the x-y 
/// plane by removing z.</P>
///
struct I3DExRigidBodySolver: public IMCUnknown
{
	virtual void MCCOMAPI Init()=0;

	// ****************************************************************************
	//								SetIntegrationStep
	// 
	/// 
	/// 
	/// \param newTimeStep  
	/// 
	virtual void MCCOMAPI SetIntegrationStep(real64 newTimeStep) = 0;

	// ****************************************************************************
	//								SetCollisionPrecision
	// 
	/// Sets the precision of detecting contact points during collisions
	/// 
	/// \param precision  The precision in inches that is used to detect contact points. (0.01 inches by default)
	/// 
	virtual void MCCOMAPI SetCollisionPrecision(real64 precision) = 0;

	// ****************************************************************************
	//								RunTo
	// 
	/// Run the simulation from current time to the newTime
	/// 
	/// \param time  
	/// 
	virtual void MCCOMAPI RunTo(real64 time) = 0;

	// ****************************************************************************
	//								AddObject
	// 
	/// Adds a new object to the simulation a returns a pointer to that object. If
	/// you release the reference to that object, the body is deleted from the simulation.
	/// 
	/// \param body A pointer to the rigid body that is created
	/// 
	virtual void MCCOMAPI CreateNewObject(I3DExRigidBody** body,boolean isStatic)=0;

	virtual void MCCOMAPI CreateNewGeometry(I3DExGeometry** geometry)=0;


	virtual void MCCOMAPI CreateForce(I3DExPhysicForce** force,I3DExForce* carraraForce,I3DShTreeElement* tree)=0;

};


/// \}





#endif
