Entity Converter shifts position of entities respective to type
This commit is contained in:
parent
bf9bcdbe47
commit
2d4581c076
@ -24,8 +24,20 @@
|
|||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
// shifts the position of an entity in a given axis.
|
||||||
|
// for discrepancies between origin points between games.
|
||||||
|
#define OFFSET_PLAYER 32 // in reflex is origin the feet; in quake it's the center
|
||||||
|
#define OFFSET_PICKUP 2 // reflex items are on-ground, while quake's are floating
|
||||||
|
std::string offset(std::string axis, float amount) {
|
||||||
|
std::istringstream iss(axis);
|
||||||
|
float c;
|
||||||
|
iss >> c;
|
||||||
|
c += amount;
|
||||||
|
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << std::fixed << std::setprecision(5) << c;
|
||||||
|
return ss.str();
|
||||||
|
}
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------
|
/*-----------------------------------------------------------------------------
|
||||||
* PUBLIC
|
* PUBLIC
|
||||||
@ -273,7 +285,7 @@ EntityConverter::convertPickup(std::vector<std::string> &lines)
|
|||||||
// coordinates reordered to x, z, y
|
// coordinates reordered to x, z, y
|
||||||
std::stringstream oss2;
|
std::stringstream oss2;
|
||||||
oss2 << "\"origin\" \"" << coords[0] << " " << coords[2] << " " <<
|
oss2 << "\"origin\" \"" << coords[0] << " " << coords[2] << " " <<
|
||||||
offsetHeight(coords[1]) << "\"" << std::endl;
|
offset(coords[1], OFFSET_PICKUP) << "\"" << std::endl;
|
||||||
convertedLines.push_back ( oss2.str() );
|
convertedLines.push_back ( oss2.str() );
|
||||||
return convertedLines;
|
return convertedLines;
|
||||||
}
|
}
|
||||||
@ -368,7 +380,7 @@ EntityConverter::convertPlayerSpawn(std::vector<std::string> &lines)
|
|||||||
std::stringstream oss;
|
std::stringstream oss;
|
||||||
// coordinates reordered to x, z, y
|
// coordinates reordered to x, z, y
|
||||||
oss << "\"origin\" \"" << coords[0] << " " << coords[2] << " " <<
|
oss << "\"origin\" \"" << coords[0] << " " << coords[2] << " " <<
|
||||||
offsetHeight(coords[1]) << "\"" << std::endl;
|
offset(coords[1], OFFSET_PLAYER) << "\"" << std::endl;
|
||||||
convertedLines.push_back ( oss.str() );
|
convertedLines.push_back ( oss.str() );
|
||||||
std::stringstream oss2;
|
std::stringstream oss2;
|
||||||
oss2 << "\"angle\" \"" << angle << "\"" << std::endl;
|
oss2 << "\"angle\" \"" << angle << "\"" << std::endl;
|
||||||
@ -487,7 +499,7 @@ EntityConverter::convertTarget(std::vector<std::string> &lines)
|
|||||||
// teleporter height is OFFSET
|
// teleporter height is OFFSET
|
||||||
std::stringstream oss;
|
std::stringstream oss;
|
||||||
oss << "\"origin\" \"" << coords[0] << " " << coords[2] << " " <<
|
oss << "\"origin\" \"" << coords[0] << " " << coords[2] << " " <<
|
||||||
offsetHeight(coords[1]) << "\"" << std::endl;
|
offset(coords[1], OFFSET_PLAYER) << "\"" << std::endl;
|
||||||
convertedLines.push_back ( oss.str() );
|
convertedLines.push_back ( oss.str() );
|
||||||
}
|
}
|
||||||
else if ( targetMap_[targetName] == "JumpPad") {
|
else if ( targetMap_[targetName] == "JumpPad") {
|
||||||
@ -540,23 +552,6 @@ EntityConverter::convertRaceFinish(std::vector<std::string> &lines)
|
|||||||
return convertedLines;
|
return convertedLines;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::string
|
|
||||||
EntityConverter::offsetHeight(std::string coordinate)
|
|
||||||
{
|
|
||||||
std::istringstream iss(coordinate);
|
|
||||||
float c;
|
|
||||||
iss >> c;
|
|
||||||
c += getHeightOffset();
|
|
||||||
|
|
||||||
std::stringstream ss;
|
|
||||||
ss << std::fixed << std::setprecision(5) << c;
|
|
||||||
return ss.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// DEBUG
|
// DEBUG
|
||||||
void
|
void
|
||||||
EntityConverter::printMapping()
|
EntityConverter::printMapping()
|
||||||
|
@ -31,6 +31,16 @@
|
|||||||
#include <queue>
|
#include <queue>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
/*
|
||||||
|
*--------------------------------------------------------------------------------------
|
||||||
|
* Description: Reflex coordinates place entities at the ground and Xonotic entities
|
||||||
|
* are at about center of player height. Offset accordingly.
|
||||||
|
* Paramater: string coordinate, float value passed as string
|
||||||
|
* Return: string, float value passed as string
|
||||||
|
*--------------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
std::string offsetHeight(std::string coordinate);
|
||||||
|
|
||||||
class EntityConverter
|
class EntityConverter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -129,17 +139,6 @@ class EntityConverter
|
|||||||
*--------------------------------------------------------------------------------------
|
*--------------------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
void addIfRelated(std::string &line, std::istream &is);
|
void addIfRelated(std::string &line, std::istream &is);
|
||||||
/*
|
|
||||||
*--------------------------------------------------------------------------------------
|
|
||||||
* Class: EntityConverter
|
|
||||||
* Method: EntityConverter :: offsetHeight
|
|
||||||
* Description: Reflex coordinates place entities at the ground and Xonotic entities
|
|
||||||
* are at about center of player height. Offset accordingly.
|
|
||||||
* Paramater: string coordinate, float value passed as string
|
|
||||||
* Return: string, float value passed as string
|
|
||||||
*--------------------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
std::string offsetHeight(std::string coordinate);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*--------------------------------------------------------------------------------------
|
*--------------------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user