2015-07-10 07:26:38 +00:00
|
|
|
#include "object/object.h"
|
|
|
|
|
2015-07-11 17:48:37 +00:00
|
|
|
#include "graphics/model/model_crash_sphere.h"
|
|
|
|
|
|
|
|
|
2015-07-10 07:26:38 +00:00
|
|
|
CObject::CObject(int id, ObjectType type)
|
|
|
|
: m_id(id)
|
|
|
|
, m_type(type)
|
|
|
|
{
|
|
|
|
m_implementedInterfaces.fill(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
CObject::~CObject()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-07-11 17:48:37 +00:00
|
|
|
void CObject::SetCrashSpheres(const std::vector<Gfx::ModelCrashSphere>& crashSpheres)
|
|
|
|
{
|
|
|
|
for (const auto& crashSphere : crashSpheres)
|
|
|
|
{
|
|
|
|
SoundType sound = ParseSoundType(crashSphere.sound);
|
|
|
|
CrashSphere objectCrashSphere(crashSphere.position, crashSphere.radius, sound, crashSphere.hardness);
|
|
|
|
AddCrashSphere(objectCrashSphere);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-10 07:26:38 +00:00
|
|
|
void CObject::AddCrashSphere(const CrashSphere& crashSphere)
|
|
|
|
{
|
|
|
|
m_crashSpheres.push_back(crashSphere);
|
|
|
|
}
|
|
|
|
|
|
|
|
CrashSphere CObject::GetFirstCrashSphere()
|
|
|
|
{
|
|
|
|
assert(m_crashSpheres.size() >= 1);
|
|
|
|
|
|
|
|
CrashSphere transformedFirstCrashSphere = m_crashSpheres[0];
|
|
|
|
TransformCrashSphere(transformedFirstCrashSphere.sphere);
|
|
|
|
return transformedFirstCrashSphere;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<CrashSphere> CObject::GetAllCrashSpheres()
|
|
|
|
{
|
|
|
|
std::vector<CrashSphere> allCrashSpheres;
|
|
|
|
|
|
|
|
for (const auto& crashSphere : m_crashSpheres)
|
|
|
|
{
|
|
|
|
CrashSphere transformedCrashSphere = crashSphere;
|
|
|
|
TransformCrashSphere(transformedCrashSphere.sphere);
|
|
|
|
allCrashSpheres.push_back(transformedCrashSphere);
|
|
|
|
}
|
|
|
|
|
|
|
|
return allCrashSpheres;
|
|
|
|
}
|
|
|
|
|
|
|
|
int CObject::GetCrashSphereCount()
|
|
|
|
{
|
|
|
|
return m_crashSpheres.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CObject::DeleteAllCrashSpheres()
|
|
|
|
{
|
|
|
|
m_crashSpheres.clear();
|
|
|
|
}
|
2015-07-11 09:35:20 +00:00
|
|
|
|
|
|
|
void CObject::SetCameraCollisionSphere(const Math::Sphere& sphere)
|
|
|
|
{
|
|
|
|
m_cameraCollisionSphere = sphere;
|
|
|
|
}
|
|
|
|
|
|
|
|
Math::Sphere CObject::GetCameraCollisionSphere()
|
|
|
|
{
|
|
|
|
Math::Sphere transformedSphere = m_cameraCollisionSphere;
|
|
|
|
TransformCrashSphere(transformedSphere);
|
|
|
|
return transformedSphere;
|
|
|
|
}
|
|
|
|
|