Offset height for teleport desinations, pickups, and player spawns
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
|
||||
#include <exception>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
@@ -272,7 +273,7 @@ EntityConverter::convertPickup(std::vector<std::string> &lines)
|
||||
// coordinates reordered to x, z, y
|
||||
std::stringstream oss2;
|
||||
oss2 << "\"origin\" \"" << coords[0] << " " << coords[2] << " " <<
|
||||
coords[1] << "\"" << std::endl;
|
||||
offsetHeight(coords[1]) << "\"" << std::endl;
|
||||
convertedLines.push_back ( oss2.str() );
|
||||
return convertedLines;
|
||||
}
|
||||
@@ -367,7 +368,7 @@ EntityConverter::convertPlayerSpawn(std::vector<std::string> &lines)
|
||||
std::stringstream oss;
|
||||
// coordinates reordered to x, z, y
|
||||
oss << "\"origin\" \"" << coords[0] << " " << coords[2] << " " <<
|
||||
coords[1] << "\"" << std::endl;
|
||||
offsetHeight(coords[1]) << "\"" << std::endl;
|
||||
convertedLines.push_back ( oss.str() );
|
||||
std::stringstream oss2;
|
||||
oss2 << "\"angle\" \"" << angle << "\"" << std::endl;
|
||||
@@ -482,24 +483,30 @@ EntityConverter::convertTarget(std::vector<std::string> &lines)
|
||||
if ( havePosition && haveName) {
|
||||
if ( targetMap_[targetName] == "Teleporter") {
|
||||
convertedLines.push_back ( "\"classname\" \"misc_teleporter_dest\"\n" );
|
||||
// coordinates reordered to x, z, y
|
||||
// teleporter height is OFFSET
|
||||
std::stringstream oss;
|
||||
oss << "\"origin\" \"" << coords[0] << " " << coords[2] << " " <<
|
||||
offsetHeight(coords[1]) << "\"" << std::endl;
|
||||
convertedLines.push_back ( oss.str() );
|
||||
}
|
||||
else if ( targetMap_[targetName] == "JumpPad") {
|
||||
convertedLines.push_back ( "\"classname\" \"target_position\"\n" );
|
||||
// coordinates reordered to x, z, y
|
||||
std::stringstream oss;
|
||||
oss << "\"origin\" \"" << coords[0] << " " << coords[2] << " " <<
|
||||
coords[1] << "\"" << std::endl;
|
||||
convertedLines.push_back ( oss.str() );
|
||||
}
|
||||
// coordinates reordered to x, z, y
|
||||
std::stringstream oss2;
|
||||
oss2 << "\"origin\" \"" << coords[0] << " " << coords[2] << " " <<
|
||||
coords[1] << "\"" << std::endl;
|
||||
convertedLines.push_back ( oss2.str() );
|
||||
std::stringstream oss;
|
||||
oss << "\"targetname\" \"" << targetName << "\"" << std::endl;
|
||||
convertedLines.push_back ( oss.str() );
|
||||
|
||||
// Write angle only if position and name exist
|
||||
if ( haveAngle ) {
|
||||
std::stringstream oss3;
|
||||
oss3 << "\"angle\" \"" << angle << "\"" << std::endl;
|
||||
convertedLines.push_back (oss3.str() );
|
||||
std::stringstream oss2;
|
||||
oss2 << "\"angle\" \"" << angle << "\"" << std::endl;
|
||||
convertedLines.push_back (oss2.str() );
|
||||
}
|
||||
return convertedLines;
|
||||
}
|
||||
@@ -535,6 +542,21 @@ EntityConverter::convertRaceFinish(std::vector<std::string> &lines)
|
||||
|
||||
|
||||
|
||||
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()
|
||||
|
@@ -89,6 +89,16 @@ class EntityConverter
|
||||
|
||||
|
||||
private:
|
||||
|
||||
/*
|
||||
*--------------------------------------------------------------------------------------
|
||||
* Class: EntityConverter
|
||||
* Method: EntityConverter :: getOffsetHeight
|
||||
* Description: Returns a constant
|
||||
*--------------------------------------------------------------------------------------
|
||||
*/
|
||||
float getHeightOffset() { return 32.0; }
|
||||
|
||||
/*
|
||||
*--------------------------------------------------------------------------------------
|
||||
* Class: EntityConverter
|
||||
@@ -119,6 +129,17 @@ 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);
|
||||
|
||||
/*
|
||||
*--------------------------------------------------------------------------------------
|
||||
@@ -137,6 +158,7 @@ class EntityConverter
|
||||
std::vector<std::string> convertRaceStart(std::vector<std::string> &entity);
|
||||
std::vector<std::string> convertRaceFinish(std::vector<std::string> &entity);
|
||||
|
||||
|
||||
void printMapping(); //DEBUG
|
||||
void printTargetSources(); //DEBUG
|
||||
|
||||
|
Reference in New Issue
Block a user