/* -----------------------------------------------------------------------------
	GSFramework
	Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */


#ifndef	__NPHYSICITEM__
#define	__NPHYSICITEM__


		#include "memory/nshared_ptr.h"
		#include "ntypes.h"


namespace GS {
	struct Vector4;
	class Matrix3;
	class Matrix4;

	namespace S3D {
		struct PhysicItemDesc;
		class PhysicWorld;

/*!
	@short	Abstract physic item.
	@author	Emmanuel Julien (ejulien@gsworks.fr)
*/
class	PhysicItem : public SharedObject
{
protected:

		void			*user_ptr;

public:

		void			SetUserPointer(void *p) { user_ptr = p; }
		void			*GetUserPointer() const { return user_ptr; }

virtual	void			SetSelfMask(uint) = 0;
virtual	void			SetCollisionMask(uint) = 0;

virtual	void			SetLinearFactor(const Vector4 &) = 0;
virtual	void			SetAngularFactor(const Vector4 &) = 0;

virtual	void			SetScale(const Vector4 &) = 0;
virtual	Vector4			GetScale() const = 0;

virtual	void			SetGravity(const Vector4 &) = 0;
virtual	Vector4			GetGravity() const = 0;
virtual	void			ApplyImpulse(const Vector4 &I, const Vector4 *p = 0) = 0;
virtual	void			ApplyForce(const Vector4 &F, const Vector4 *p = 0) = 0;
virtual	void			ApplyTorque(const Vector4 &) = 0;

virtual	void			SetAngularVelocity(const Vector4 &) = 0;
virtual	Vector4			GetAngularVelocity() const = 0;
virtual	void			SetLinearVelocity(const Vector4 &) = 0;
virtual	Vector4			GetLinearVelocity() const = 0;

virtual	Vector4			GetLocalPointVelocity(const Vector4 &) const = 0;
virtual	Vector4			GetWorldPointVelocity(const Vector4 &) const = 0;

virtual	void			SetLinearDamping(float) = 0;
virtual	float			GetLinearDamping() const = 0;
virtual	void			SetAngularDamping(float) = 0;
virtual	float			GetAngularDamping() const = 0;

virtual	Vector4			GetCenterOfMass() const = 0;

/*!
	@short	Vehicle.
	@{
*/
virtual	void			VehicleSetForce(float nUnused(F), uint nUnused(wheel_index)) = 0;
virtual	void			VehicleSetBrake(float nUnused(F), uint nUnused(wheel_index)) = 0;
virtual	void			VehicleSetSteering(float nUnused(v), uint nUnused(wheel_index)) = 0;
virtual	void			VehicleSetFriction(float nUnused(f), uint nUnused(wheel_index)) = 0;

		/// Get wheel matrix as returned by the model.
virtual	Matrix4			VehicleGetWheelMatrix(uint nUnused(wheel_index)) = 0;
/// @}

/*!
	@short	Character.
	@{
*/
virtual	void			CharacterSetRotationMatrix(const Matrix3 &) = 0;
virtual	void			CharacterSetVelocity(const Vector4 &) = 0;
/// @}

		/*!
			@short	Get graphic matrix.

			This is usually an interpolated version of the internal
			current and previous matrices.
		*/
virtual	void			GetGraphicMatrix(Matrix4 &) = 0;
virtual	void			SetEngineMatrix(const Matrix4 &) = 0;
virtual	void			GetMatrix(Matrix4 &) = 0;
virtual	void			SetMatrix(const Matrix4 &) = 0;

virtual	void			SetSleeping(bool = false) = 0;
virtual	bool			IsSleeping() const = 0;
virtual	void			SetActive(bool = true) = 0;
virtual	bool			GetActive() const = 0;

virtual	void			ResetBody() = 0;

virtual	bool			SetupBody(const PhysicItemDesc &, PhysicWorld *) = 0;
virtual	void			ForceUpdateMassShapePhysic(const PhysicItemDesc &, PhysicWorld *) = 0;
virtual	void			DeleteBody() = 0;

		PhysicItem() : user_ptr(0) {}
virtual	~PhysicItem() {}
};

typedef	SharedPtr <PhysicItem> sPhysicItem;

	} // S3D
} // GS


#endif	// __NPHYSICITEM__
