#include "FixedSimulationObject.h"
#include "../Logger.h"

FixedSimulationObject::FixedSimulationObject(const dVector3 size, const dVector3 pos, const dReal direction, const dReal weight):
	SimulationObject()
{
	_size[0] = size[0]; _size[1] = size[1]; _size[2] = size[2]; 
	_body = dBodyCreate(getWorldID());
	_geom = dCreateBox(getSpaceID(), size[0], size[1], size[2]);
	dBodySetPosition(_body, pos[0], pos[1], pos[2]);
	dMass m;
	dMassSetBox(&m, 1, size[0], size[1], size[2]);
	dMassAdjust(&m, weight);
	dBodySetMass(_body, &m);
	dGeomSetBody(_geom, _body);
	dMatrix3 rot;
	dRFromAxisAndAngle(rot, 0, 0, 1, direction);
	dBodySetRotation(_body, rot);
	dBodyDisable(_body);
}

FixedSimulationObject::~FixedSimulationObject()
{
	dGeomDestroy(_geom);
	dBodyDestroy(_body);
}
