Commit 0800b2f0 authored by Pascal Palenda's avatar Pascal Palenda
Browse files

Add SerializationHelper for Quaternions and use them

parent 2fdc7734
......@@ -6,6 +6,7 @@
// simulation scheduler include
#include <ITA/SimulationScheduler/Utils/utils.h>
#include "../src/ITA/SimulationScheduler/serialization_helper.h"
// Vista include
#include <VistaAspects/VistaSerializer.h>
......@@ -59,15 +60,9 @@ namespace ITA
int C3DObject::Serialize ( IVistaSerializer& pSerializer ) const
{
int returnVal = 0;
returnVal += pSerializer.WriteFloat32 ( m_v3Position [0] );
returnVal += pSerializer.WriteFloat32 ( m_v3Position [1] );
returnVal += pSerializer.WriteFloat32 ( m_v3Position [2] );
returnVal += pSerializer.WriteFloat32 ( m_v3Position [3] );
returnVal += SerializationHelper::WriteVistaVector3D ( pSerializer, m_v3Position );
returnVal += pSerializer.WriteFloat32 ( m_qOrientation [0] );
returnVal += pSerializer.WriteFloat32 ( m_qOrientation [1] );
returnVal += pSerializer.WriteFloat32 ( m_qOrientation [2] );
returnVal += pSerializer.WriteFloat32 ( m_qOrientation [3] );
returnVal += SerializationHelper::WriteVistaQuaternion ( pSerializer, m_qOrientation );
returnVal += pSerializer.WriteInt32 ( m_iID );
......@@ -79,15 +74,9 @@ namespace ITA
{
int returnVal = 0;
int tmp;
returnVal += pDeserializer.ReadFloat32 ( m_v3Position [0] );
returnVal += pDeserializer.ReadFloat32 ( m_v3Position [1] );
returnVal += pDeserializer.ReadFloat32 ( m_v3Position [2] );
returnVal += pDeserializer.ReadFloat32 ( m_v3Position [3] );
returnVal += SerializationHelper::ReadVistaVector3D ( pDeserializer, m_v3Position );
returnVal += pDeserializer.ReadFloat32 ( m_qOrientation [0] );
returnVal += pDeserializer.ReadFloat32 ( m_qOrientation [1] );
returnVal += pDeserializer.ReadFloat32 ( m_qOrientation [2] );
returnVal += pDeserializer.ReadFloat32 ( m_qOrientation [3] );
returnVal += SerializationHelper::ReadVistaQuaternion ( pDeserializer, m_qOrientation );
returnVal += pDeserializer.ReadInt32 ( m_iID );
......
......@@ -117,3 +117,29 @@ int ITA::SimulationScheduler::SerializationHelper::ReadVistaVector3D(IVistaDeSer
return returnVal;
}
int ITA::SimulationScheduler::SerializationHelper::WriteVistaQuaternion(IVistaSerializer& pSerializer,
const VistaQuaternion& qQuaternion)
{
int returnVal = 0;
returnVal += pSerializer.WriteFloat32 ( qQuaternion [Vista::X] );
returnVal += pSerializer.WriteFloat32 ( qQuaternion [Vista::Y] );
returnVal += pSerializer.WriteFloat32 ( qQuaternion [Vista::Z] );
returnVal += pSerializer.WriteFloat32 ( qQuaternion [Vista::W] );
return returnVal;
}
int ITA::SimulationScheduler::SerializationHelper::ReadVistaQuaternion(IVistaDeSerializer& pDeserializer,
VistaQuaternion& qQuaternion)
{
int returnVal = 0;
returnVal += pDeserializer.ReadFloat32 ( qQuaternion [Vista::X] );
returnVal += pDeserializer.ReadFloat32 ( qQuaternion [Vista::Y] );
returnVal += pDeserializer.ReadFloat32 ( qQuaternion [Vista::Z] );
returnVal += pDeserializer.ReadFloat32 ( qQuaternion [Vista::W] );
return returnVal;
}
......@@ -8,6 +8,7 @@
// Vista
#include <VistaBase/VistaVector3D.h>
#include <VistaBase/VistaQuaternion.h>
#include <VistaAspects/VistaSerializer.h>
#include <VistaAspects/VistaDeSerializer.h>
......@@ -58,6 +59,9 @@ namespace ITA
static int WriteVistaVector3D(IVistaSerializer& pSerializer, const VistaVector3D& v3Vector);
static int ReadVistaVector3D(IVistaDeSerializer& pDeserializer, VistaVector3D& v3Vector);
static int WriteVistaQuaternion ( IVistaSerializer& pSerializer, const VistaQuaternion& qQuaternion );
static int ReadVistaQuaternion ( IVistaDeSerializer& pDeserializer, VistaQuaternion& qQuaternion );
};
} // namespace SimulationScheduler
} // namespace ITA
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment