mirror of
https://bitbucket.org/seefoe/src.git
synced 2026-10-01 16:13:35 -04:00
Added sharedGame sharedMathArchive and sharedUtility libraries
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
project(sharedMathArchive)
|
||||
|
||||
if(WIN32)
|
||||
add_definitions(/D_CRT_SECURE_NO_WARNINGS)
|
||||
endif()
|
||||
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include/public)
|
||||
|
||||
add_subdirectory(src)
|
||||
+1
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/FirstSharedMathArchive.h"
|
||||
+1
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/QuaternionArchive.h"
|
||||
+1
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/SphereArchive.h"
|
||||
+1
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/TransformArchive.h"
|
||||
+1
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/VectorArchive.h"
|
||||
@@ -0,0 +1,28 @@
|
||||
|
||||
set(SHARED_SOURCES
|
||||
shared/FirstSharedMathArchive.h
|
||||
shared/QuaternionArchive.h
|
||||
shared/SphereArchive.h
|
||||
shared/TransformArchive.h
|
||||
shared/VectorArchive.h
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
set(EXCLUDE_PROJECT "")
|
||||
else()
|
||||
set(EXCLUDE_PROJECT "EXCLUDE_FROM_ALL")
|
||||
endif()
|
||||
|
||||
include_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shared
|
||||
#${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedDebug/include/public
|
||||
#${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundation/include/public
|
||||
#${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public
|
||||
#${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public
|
||||
)
|
||||
|
||||
add_library(sharedMathArchive STATIC ${EXCLUDE_PROJECT}
|
||||
${SHARED_SOURCES}
|
||||
)
|
||||
|
||||
set_target_properties(sharedMathArchive PROPERTIES LINKER_LANGUAGE CXX)
|
||||
@@ -0,0 +1,17 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// FirstMathArchive.h
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef INCLUDED_FirstMathArchive_H
|
||||
#define INCLUDED_FirstMathArchive_H
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#include "sharedFoundation/FirstSharedFoundation.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,91 @@
|
||||
// QuaternionArchive.h
|
||||
// copyright 2001 Verant Interactive
|
||||
// Author: Justin Randall
|
||||
|
||||
#ifndef _INCLUDED_QuaternionArchive_H
|
||||
#define _INCLUDED_QuaternionArchive_H
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "Archive/Archive.h"
|
||||
#include "Archive/ByteStream.h"
|
||||
#include "sharedMath/Quaternion.h"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
namespace Archive
|
||||
{
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
@brief get a Quaternion from a source Archive::ByteStream
|
||||
|
||||
Rertrieves a quaternion's x, y, z and w values from the
|
||||
Archive::ByteStream object's current read position.
|
||||
|
||||
@param source The Archive::ByteStream object containing the
|
||||
quaternion x, y, z and w members at the current
|
||||
read position.
|
||||
@param target A Quaternion object that will receive the
|
||||
x, y z and w components from the
|
||||
Archive::ByteStream
|
||||
|
||||
@see Archive
|
||||
@see Archive::ByteStream
|
||||
@see Vector
|
||||
|
||||
@author Justin Randall
|
||||
*/
|
||||
inline void get(ReadIterator & source, Quaternion & target)
|
||||
{
|
||||
Archive::get(source, target.x);
|
||||
Archive::get(source, target.y);
|
||||
Archive::get(source, target.z);
|
||||
Archive::get(source, target.w);
|
||||
|
||||
#ifdef _WIN32
|
||||
if (_isnan(static_cast<double>(target.w)) || _isnan(static_cast<double>(target.x)) || _isnan(static_cast<double>(target.y)) || _isnan(static_cast<double>(target.z)))
|
||||
#else
|
||||
if (isnan(target.w) || isnan(target.x) || isnan(target.y) || isnan(target.z))
|
||||
#endif
|
||||
{
|
||||
target.w = 1.0f;
|
||||
target.x = 0.0f;
|
||||
target.y = 0.0f;
|
||||
target.z = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
@brief put a Quaternion into an Archive::ByteStream
|
||||
|
||||
Puts the Quaternion into the Archive::ByteStream at its current
|
||||
write position.
|
||||
|
||||
@param target The ByteStream object that will receive the data
|
||||
at its current write position.
|
||||
@param source A Quaternion containing the x, y, z and w
|
||||
components that will be written to the ByteStream
|
||||
|
||||
@see Archive
|
||||
@see Archive::ByteStream
|
||||
@see Quaternion
|
||||
|
||||
@author Justin Randall
|
||||
*/
|
||||
inline void put(ByteStream & target, const Quaternion & source)
|
||||
{
|
||||
Archive::put(target, source.x);
|
||||
Archive::put(target, source.y);
|
||||
Archive::put(target, source.z);
|
||||
Archive::put(target, source.w);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
}//namespace Archive
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#endif // _INCLUDED_QuaternionArchive_H
|
||||
@@ -0,0 +1,40 @@
|
||||
// SphereArchive.h
|
||||
// copyright 2004 Sony Online Entertainment
|
||||
|
||||
#ifndef _INCLUDED_SphereArchive_H
|
||||
#define _INCLUDED_SphereArchive_H
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "Archive/Archive.h"
|
||||
#include "Archive/ByteStream.h"
|
||||
#include "sharedMath/Sphere.h"
|
||||
#include "sharedMathArchive/VectorArchive.h"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
namespace Archive
|
||||
{
|
||||
|
||||
inline void get(ReadIterator & source, Sphere & target)
|
||||
{
|
||||
Vector v;
|
||||
float f;
|
||||
Archive::get(source, v);
|
||||
Archive::get(source, f);
|
||||
target.setCenter(v);
|
||||
target.setRadius(f);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
inline void put(ByteStream & target, const Sphere & source)
|
||||
{
|
||||
Archive::put(target, source.getCenter());
|
||||
Archive::put(target, static_cast<float>(source.getRadius()));
|
||||
}
|
||||
|
||||
}//namespace Archive
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#endif // _INCLUDED_SphereArchive_H
|
||||
@@ -0,0 +1,102 @@
|
||||
// TransformArchive.h
|
||||
// copyright 2001 Verant Interactive
|
||||
// Author: Justin Randall
|
||||
|
||||
#ifndef _INCLUDED_TransformArchive_H
|
||||
#define _INCLUDED_TransformArchive_H
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "Archive/Archive.h"
|
||||
#include "Archive/ByteStream.h"
|
||||
#include "sharedMathArchive/QuaternionArchive.h"
|
||||
#include "sharedMath/Transform.h"
|
||||
#include "sharedMathArchive/VectorArchive.h"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
namespace Archive
|
||||
{
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
@brief Get a Transform from a ByteStream object
|
||||
|
||||
Reads a Quaternion and a Vector from the source
|
||||
ByteStream object at it's current read position, then
|
||||
sets the Transform data using the Quaternion and Vector
|
||||
values.
|
||||
|
||||
@param source The ByteStream object containing the Quaternion
|
||||
and Vector data at it's current read position.
|
||||
@param target A Transform object that will receive values from
|
||||
the Quaternion and Vector.
|
||||
|
||||
@see Archive
|
||||
@see Archive::ByteStream
|
||||
@see Transform
|
||||
@see Quaternion
|
||||
@see Vector
|
||||
@see Archive::get(const ByteStream & source, Quaternion & target)
|
||||
@see Archive::get(const ByteStream & source, Vector & target)
|
||||
|
||||
@author Justin Randall
|
||||
*/
|
||||
inline void get(ReadIterator & source, Transform & target)
|
||||
{
|
||||
Quaternion q;
|
||||
Vector v;
|
||||
Archive::get(source, q);
|
||||
Archive::get(source, v);
|
||||
q.getTransform(&target);
|
||||
#ifdef _DEBUG
|
||||
target.validate();
|
||||
#endif
|
||||
target.setPosition_p(v);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
@brief Put a Transform into a ByteStream object
|
||||
|
||||
Extracts a Quaternion and Vector from the supplied Transform, then
|
||||
puts the Quaternion followed by the Vector into the ByteStream
|
||||
at its current write position.
|
||||
|
||||
@param target The ByteStream that will receive the Quaternion
|
||||
and Vector derived from the Transform. The
|
||||
Quaternion and Vector data is committed at the
|
||||
ByteStream obect's current write position.
|
||||
@param source A transform that will be used to extract
|
||||
Quaternion and Vector data, which is then
|
||||
put into the target ByteStream object.
|
||||
|
||||
@see Archive
|
||||
@see Archive::ByteStream
|
||||
@see Transform
|
||||
@see Quaternion
|
||||
@see Vector
|
||||
@see Archive::put(ByteStream & target, const Vector & source)
|
||||
@see Archive::put(ByteStream & target, const Quaternion & source)
|
||||
|
||||
@author Justin Randall
|
||||
*/
|
||||
inline void put(ByteStream & target, const Transform & source)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
source.validate();
|
||||
#endif
|
||||
|
||||
Quaternion q(source);
|
||||
|
||||
Vector v = source.getPosition_p();
|
||||
Archive::put(target, q);
|
||||
Archive::put(target, v);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
}//namespace Archive
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#endif // _INCLUDED_TransformArchive_H
|
||||
@@ -0,0 +1,123 @@
|
||||
// VectorArchive.h
|
||||
// copyright 2001 Verant Interactive
|
||||
// Author: Justin Randall
|
||||
|
||||
#ifndef _INCLUDED_VectorArchive_H
|
||||
#define _INCLUDED_VectorArchive_H
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "Archive/Archive.h"
|
||||
#include "Archive/ByteStream.h"
|
||||
#include "sharedMath/Vector.h"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
namespace Archive
|
||||
{
|
||||
void get(const ByteStream & source, Vector & target);
|
||||
void put(ByteStream & target, const Vector & source);
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
@brief get a Vector from an Archive::ByteStream object
|
||||
|
||||
This get's the vector data as 3 floats: x, y, and z
|
||||
|
||||
@param source The Archive::ByteStream object containing the Vector
|
||||
data at it's current read position.
|
||||
@param target A Vector object that will have it's values set from
|
||||
the Archive::ByteStream data
|
||||
|
||||
@see Archive
|
||||
@see Archive::ByteStream
|
||||
@see Vector
|
||||
|
||||
@author Justin Randall
|
||||
*/
|
||||
inline void get(ReadIterator & source, Vector & target)
|
||||
{
|
||||
Archive::get(source, target.x);
|
||||
Archive::get(source, target.y);
|
||||
Archive::get(source, target.z);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
@brief put a Vector into an Archive::ByteStream object
|
||||
|
||||
This puts the Vector object's data into the Archive::ByteStream
|
||||
at it's current write position as x, y and z respectively.
|
||||
|
||||
@param target The Archive::ByteStream object receiving the
|
||||
Vector object's values at its current write
|
||||
position.
|
||||
@param source A Vector object containing the data to be written
|
||||
to the Archive::ByteStream
|
||||
|
||||
@see Archive
|
||||
@see Archive::ByteStream
|
||||
@see Vector
|
||||
|
||||
@author Justin Randall
|
||||
*/
|
||||
inline void put(ByteStream & target, const Vector & source)
|
||||
{
|
||||
Archive::put(target, source.x);
|
||||
Archive::put(target, source.y);
|
||||
Archive::put(target, source.z);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
@brief get a Vector from an Archive::ByteStream object
|
||||
|
||||
This get's the vector data as 3 floats: x, y, and z
|
||||
|
||||
@param source The Archive::ByteStream object containing the Vector
|
||||
data at it's current read position.
|
||||
@param target A Vector object that will have it's values set from
|
||||
the Archive::ByteStream data
|
||||
|
||||
@see Archive
|
||||
@see Archive::ByteStream
|
||||
@see Vector
|
||||
*/
|
||||
inline void get(ReadIterator & source, Vector * target)
|
||||
{
|
||||
Archive::get(source, target->x);
|
||||
Archive::get(source, target->y);
|
||||
Archive::get(source, target->z);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
@brief put a Vector into an Archive::ByteStream object
|
||||
|
||||
This puts the Vector object's data into the Archive::ByteStream
|
||||
at it's current write position as x, y and z respectively.
|
||||
|
||||
@param target The Archive::ByteStream object receiving the
|
||||
Vector object's values at its current write
|
||||
position.
|
||||
@param source A Vector object containing the data to be written
|
||||
to the Archive::ByteStream
|
||||
|
||||
@see Archive
|
||||
@see Archive::ByteStream
|
||||
@see Vector
|
||||
*/
|
||||
inline void put(ByteStream & target, const Vector * source)
|
||||
{
|
||||
Archive::put(target, source->x);
|
||||
Archive::put(target, source->y);
|
||||
Archive::put(target, source->z);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
}//namespace Archive
|
||||
|
||||
#endif // _INCLUDED_VectorArchive_H
|
||||
Reference in New Issue
Block a user