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 <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
|
||||
@ -273,7 +285,7 @@ EntityConverter::convertPickup(std::vector<std::string> &lines)
|
||||
// coordinates reordered to x, z, y
|
||||
std::stringstream oss2;
|
||||
oss2 << "\"origin\" \"" << coords[0] << " " << coords[2] << " " <<
|
||||
offsetHeight(coords[1]) << "\"" << std::endl;
|
||||
offset(coords[1], OFFSET_PICKUP) << "\"" << std::endl;
|
||||
convertedLines.push_back ( oss2.str() );
|
||||
return convertedLines;
|
||||
}
|
||||
@ -368,7 +380,7 @@ EntityConverter::convertPlayerSpawn(std::vector<std::string> &lines)
|
||||
std::stringstream oss;
|
||||
// coordinates reordered to x, z, y
|
||||
oss << "\"origin\" \"" << coords[0] << " " << coords[2] << " " <<
|
||||
offsetHeight(coords[1]) << "\"" << std::endl;
|
||||
offset(coords[1], OFFSET_PLAYER) << "\"" << std::endl;
|
||||
convertedLines.push_back ( oss.str() );
|
||||
std::stringstream oss2;
|
||||
oss2 << "\"angle\" \"" << angle << "\"" << std::endl;
|
||||
@ -487,7 +499,7 @@ EntityConverter::convertTarget(std::vector<std::string> &lines)
|
||||
// teleporter height is OFFSET
|
||||
std::stringstream oss;
|
||||
oss << "\"origin\" \"" << coords[0] << " " << coords[2] << " " <<
|
||||
offsetHeight(coords[1]) << "\"" << std::endl;
|
||||
offset(coords[1], OFFSET_PLAYER) << "\"" << std::endl;
|
||||
convertedLines.push_back ( oss.str() );
|
||||
}
|
||||
else if ( targetMap_[targetName] == "JumpPad") {
|
||||
@ -540,23 +552,6 @@ EntityConverter::convertRaceFinish(std::vector<std::string> &lines)
|
||||
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
|
||||
void
|
||||
EntityConverter::printMapping()
|
||||
|
@ -31,6 +31,16 @@
|
||||
#include <queue>
|
||||
#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
|
||||
{
|
||||
public:
|
||||
@ -129,17 +139,6 @@ class EntityConverter
|
||||
*--------------------------------------------------------------------------------------
|
||||
*/
|
||||
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