mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-15 20:49:56 +00:00
44 lines
1.1 KiB
C++
44 lines
1.1 KiB
C++
#include "coordinateconverter.hpp"
|
|
|
|
#include <components/esm/loadcell.hpp>
|
|
#include <components/esm/loadland.hpp>
|
|
|
|
namespace MWMechanics
|
|
{
|
|
CoordinateConverter::CoordinateConverter(const ESM::Cell* cell)
|
|
: mCellX(0), mCellY(0)
|
|
{
|
|
if (cell->isExterior())
|
|
{
|
|
mCellX = cell->mData.mX * ESM::Land::REAL_SIZE;
|
|
mCellY = cell->mData.mY * ESM::Land::REAL_SIZE;
|
|
}
|
|
}
|
|
|
|
void CoordinateConverter::toWorld(ESM::Pathgrid::Point& point)
|
|
{
|
|
point.mX += mCellX;
|
|
point.mY += mCellY;
|
|
}
|
|
|
|
void CoordinateConverter::toWorld(osg::Vec3f& point)
|
|
{
|
|
point.x() += static_cast<float>(mCellX);
|
|
point.y() += static_cast<float>(mCellY);
|
|
}
|
|
|
|
void CoordinateConverter::toLocal(osg::Vec3f& point)
|
|
{
|
|
point.x() -= static_cast<float>(mCellX);
|
|
point.y() -= static_cast<float>(mCellY);
|
|
}
|
|
|
|
osg::Vec3f CoordinateConverter::toLocalVec3(const osg::Vec3f& point)
|
|
{
|
|
return osg::Vec3f(
|
|
point.x() - static_cast<float>(mCellX),
|
|
point.y() - static_cast<float>(mCellY),
|
|
point.z()
|
|
);
|
|
}
|
|
}
|