

#ifndef __CPhysicsEntity_h
#define __CPhysicsEntity_h


#include "PhysicsGlobal.h"
#include "IPhysicsEntity.h"
#include "IPhysicsBodyModifier.h"
#include "CLog.h"

class CPhysicsEntity : public IPhysicsEntity
{
public:
	CPhysicsEntity();
	~CPhysicsEntity();

	void init(NewtonWorld* world, NewtonBody *body, ISceneNode *node, CLog* logger);
	void serialize(stringc file);
	void setMaterial(int material);
	void setPosition(vector3df position);
	void setRotation(vector3df rotation);
	void setScale(vector3df scale);
	vector3df getPosition();
	vector3df getRotation();
	vector3df getScale();

	vector3df getSize();
	NewtonBody *getBody();
	ISceneNode *getNode();
//	ENUMERATED_ENTITY_TYPE getEntityType();

	void createConvexHullModifier();
	matrix4 getMatrix();
	void setMatrix(matrix4 matrix);

	void setUserID(int id);
	int getUserID();
	f32 calculateVolume();
	vector3df calculateInertia();
	vector3df calculateCentreOfMass();

	const NewtonBody* waterBody;

protected:
	NewtonWorld* m_world;
	ISceneNode *m_node;

	NewtonCollision* m_modifier;

	vector3df m_size;

	array<NewtonCollision*> m_compoundArray;

	CLog* m_log;

	static void _cdecl writeToFile(void* serializeHandle, const void* buffer, size_t size);
	static void _cdecl destructor(const NewtonBody* body);

};


#endif
