//********************************************************************
// This source file is part of Ninfa3D Engine
// 
// Copyright (C) 2008-2009 Viz_fuerte.
// All rights reserved.
// 
// LIMITED WARRANTY
// This software is provided "as-is", without any express or implied warranty.
// In no event shall the author be held liable for any damages arising from the use of this software.
// This is a contract. By accepting the Ninfa3D Engine (the SOFTWARE), 
// you (either an individual or a single entity, the LICENSEE) accept the terms and conditions of this licensing agreement.
// 
// If the LICENSEE does not accept the terms and conditions, then LICENSEE must not accept the SOFTWARE.
// If at a later time the LICENSEE decides not to continue licensing the SOFTWARE under these terms and 
// conditions, then the LICENSEE must delete permanently all files constituting the SOFTWARE.
//
// File: CBodySceneNode.h
//********************************************************************

/*--------------------------------------------------------------------
Includos*/

	#include "..\Header Files\Ninfa3D.h"

/*--------------------------------------------------------------------
Clases*/

	class CBodySceneNode : public ISceneNode
	{
	public:

		CBodySceneNode(ISceneNode* parent,ISceneManager* mgr,s32 id);
		~CBodySceneNode();

		void addBodyNull();

		void addBodyCube(float dx,float dy,float dz,float mass);
		void addBodySphere(float rx,float ry,float rz,float mass);
		void addBodyCone(float radius,float height,float mass,bool offset);
		void addBodyCylinder(float radius,float height,float mass,bool offset);
		void addBodyCapsule(float radius,float height,float mass,bool offset);

		void addBodyHull(IAnimatedMeshSceneNode* mesh,float mass);
		void addBodyTree(IAnimatedMeshSceneNode* mesh,float mass);
		void addBodyTreeBSP(IAnimatedMesh* q3levelmesh,ISceneNode* q3node);
		void addBodyTerrain(ITerrainSceneNode* mesh,int LOD);
		void addBodyWater(float SX,float SY,float SZ,float FluidDensity,float LinearViscosity,float AngularViscosity);

		virtual void setParent(ISceneNode* newParent);
		virtual void setPosition(const vector3df& position);
		virtual void setRotation(const vector3df& rot);

		void setElasticity(float elasticity);
		void setFriction(float staticFriction,float kineticFriction);
		void setSoftness(float softness);

		bool BodiesCollide(NewtonBody* body2);
		vector3df getColl(NewtonBody* body2,int mode);
		NewtonBody* getBody();
		virtual vector3df getAbsolutePosition() const;
		virtual const vector3df& getRotation() const;

		virtual void remove();
		virtual void OnPreRender();
		virtual void render();

		virtual SMaterial& getMaterial(s32 i);
		virtual const aabbox3d<f32>& getBoundingBox() const;

	private:

		aabbox3d<f32> BBox;
		SMaterial material;

		NewtonBody* body;
	};