new rendering system and other additions

This commit is contained in:
Tim Nebel 2023-07-19 14:50:43 +02:00
commit 2e24e1714e
33 changed files with 1229 additions and 269 deletions

View file

@ -9,7 +9,7 @@ find_package(GLEW REQUIRED)
find_package(yaml-cpp REQUIRED)
add_library(SpoonMapTools STATIC src/Map.cpp include/Map.h include/LevelObject.h include/Transform.h "include/Vector3.h" src/Vectior3.cpp src/Transform.cpp src/LevelObject.cpp include/Link.h src/Link.cpp include/Rail.h src/Rail.cpp include/RailPoint.h src/RailPoint.cpp include/SpecialObjectParams.h src/SpecialObjectParams.cpp include/SpecialObjectParamVersions/All.h include/SpecialObjectParamVersions/Default.h include/LayerConfig.h include/LayerConfig.h include/Element.h src/Element.cpp)
add_library(SpoonMapTools STATIC src/Map.cpp include/Map.h include/LevelObject.h include/Transform.h "include/Vector3.h" src/Vectior3.cpp src/Transform.cpp src/LevelObject.cpp include/Link.h src/Link.cpp include/Rail.h src/Rail.cpp include/RailPoint.h src/RailPoint.cpp include/SpecialObjectParams.h src/SpecialObjectParams.cpp include/SpecialObjectParamVersions/All.h include/SpecialObjectParamVersions/Default.h include/Element.h src/Element.cpp)
target_include_directories(SpoonMapTools PUBLIC include)

View file

@ -15,8 +15,8 @@
namespace Teams{
constexpr long Player = 0;
constexpr long Neutral = 1;
constexpr long Enemy = 2;
constexpr long Enemy = 1;
constexpr long Neutral = 2;
constexpr std::array<long,3> AllOptions = {Player,Neutral,Enemy};
@ -25,9 +25,9 @@ namespace Teams{
case 0:
return "Player";
case 1:
return "Neutral";
case 2:
return "Enemy";
case 2:
return "Neutral";
default:
return "Invalid";
}

View file

@ -24,6 +24,8 @@ struct Map {
std::vector<Rail> Rails;
Element* GetElementById(std::string id);
};

View file

@ -1,5 +1,6 @@
#include<Element.h>
#include<algorithm>
#include <iomanip>
Element::Element(const YAML::Node &ObjNode,std::list<std::string> PropertyBlockList) {
@ -28,14 +29,14 @@ Element::Element(const YAML::Node &ObjNode,std::list<std::string> PropertyBlockL
ModelName = ObjNode["ModelName"].as<std::string>();
IsLinkDest = ObjNode["IsLinkDest"].as<bool>();
unsigned int ParamId = 1;
unsigned int ParamId = 0;
while(YAML::Node ParamNode = ObjNode["Parameter" + std::to_string(ParamId)]){
Parameters.push_back(ParamNode.as<long>());
ParamId++;
}
unsigned int FloatParamId = 1;
unsigned int FloatParamId = 0;
while(YAML::Node ParamNode = ObjNode["FloatParameter" + std::to_string(FloatParamId)]){
FloatParameters.push_back(ParamNode.as<float>());
@ -118,12 +119,16 @@ void Element::YamlInsertBody(YAML::Emitter &Emitter) {
}
Emitter << YAML::EndMap;
for(int i = 1; i <= Parameters.size(); i++){
Emitter << YAML::Key << "Parameter" + std::to_string(i) << YAML::Value << YAML::LocalTag("l") << Parameters[i-1];
for(int i = 0; i < Parameters.size(); i++){
Emitter << YAML::Key << "Parameter" + std::to_string(i) << YAML::Value << YAML::LocalTag("l") << Parameters[i];
}
for(int i = 1; i <= FloatParameters.size(); i++){
Emitter << YAML::Key << "FloatParameter" + std::to_string(i) << YAML::Value << FloatParameters[i-1];
for(int i = 0; i < FloatParameters.size(); i++){
std::stringstream stream;
stream << std::fixed << std::setprecision(5) << FloatParameters[i];
std::string s = stream.str();
Emitter << YAML::Key << "FloatParameter" + std::to_string(i) << YAML::Value << stream.str();
}
for(auto opts: OtherOptions){

View file

@ -9,6 +9,7 @@
#include <boost/iostreams/device/file.hpp>
#include<iostream>
#include<boost/algorithm/string.hpp>
#include<algorithm>
//GENSERIALIZABLECONTENT(Map,(Objects,Rails))
@ -63,6 +64,25 @@ void Map::Export(boost::filesystem::path YamlOut) {
file.close();
}
Element *Map::GetElementById(std::string id) {
//Wish i could use some kind of cache but im too lazy to check removal from Rails or Objects as to not cause any stale references to be output
// might do it at some point in the future
auto elemRef1 = std::find_if(Objects.begin(), Objects.end(),[&](const LevelObject &obj){return obj.Name == id;});
if(elemRef1 != Objects.end())
return &*elemRef1;
if(std::any_of(id.begin(), id.end(),[](char c){return c=='/';})) {
id.erase(id.find('/'));
auto elemRef2 = std::find_if(Rails.begin(), Rails.end(), [&](const Rail &rail) { return rail.Name == id; });
if (elemRef2 != Rails.end())
return &*elemRef2;
}
return nullptr;
}
Map ConvertFromYaml(boost::filesystem::path File){