Post big vgcore upgrade push
This commit is contained in:
parent
37ccb7226b
commit
a33d7f3c86
12 changed files with 102 additions and 90 deletions
|
|
@ -10,12 +10,11 @@ add_subdirectory(deps/vgcore)
|
||||||
add_subdirectory(Tools/MapTools)
|
add_subdirectory(Tools/MapTools)
|
||||||
|
|
||||||
add_executable(SpoonEdit src/main.cpp src/MainWindow.cpp src/MainWindow.h src/PropertiesWidget.cpp src/PropertiesWidget.h src/ObjectSelectWidget.cpp src/ObjectSelectWidget.h src/MainViewport.cpp src/MainViewport.h src/Model.cpp src/Model.h src/RailSelectWidget.cpp src/RailSelectWidget.h src/Config/Configs.h src/Config/Configs.cpp)
|
add_executable(SpoonEdit src/main.cpp src/MainWindow.cpp src/MainWindow.h src/PropertiesWidget.cpp src/PropertiesWidget.h src/ObjectSelectWidget.cpp src/ObjectSelectWidget.h src/MainViewport.cpp src/MainViewport.h src/Model.cpp src/Model.h src/RailSelectWidget.cpp src/RailSelectWidget.h src/Config/Configs.h src/Config/Configs.cpp)
|
||||||
|
set(CMAKE_CXX_FLAGS_DEBUG "-g")
|
||||||
|
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
|
||||||
|
|
||||||
target_link_libraries(SpoonEdit PUBLIC GCore SpoonMapTools Boost::thread Boost::chrono)
|
target_link_libraries(SpoonEdit PUBLIC GCore SpoonMapTools Boost::thread Boost::chrono)
|
||||||
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0")
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0")
|
|
||||||
|
|
||||||
install(TARGETS SpoonEdit
|
install(TARGETS SpoonEdit
|
||||||
CONFIGURATIONS Debug
|
CONFIGURATIONS Debug
|
||||||
RUNTIME DESTINATION Debug
|
RUNTIME DESTINATION Debug
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ inline LayerConfig ToLayerConfig(std::string cfg){
|
||||||
return Day;
|
return Day;
|
||||||
} else if(cfg == "Tmp") {
|
} else if(cfg == "Tmp") {
|
||||||
return Temporary;
|
return Temporary;
|
||||||
}
|
} else return Temporary;
|
||||||
}
|
}
|
||||||
|
|
||||||
class Element{
|
class Element{
|
||||||
|
|
@ -95,9 +95,9 @@ public:
|
||||||
|
|
||||||
std::string ModelName = "null";
|
std::string ModelName = "null";
|
||||||
|
|
||||||
LayerConfig Layer = Common;
|
std::string Layer = "Cmn";
|
||||||
|
|
||||||
std::vector<long> Parameters = std::vector<long>();
|
std::vector<int> Parameters = std::vector<int>();
|
||||||
std::vector<float> FloatParameters = std::vector<float>();
|
std::vector<float> FloatParameters = std::vector<float>();
|
||||||
|
|
||||||
//std::map<std::string,std::vector<Link>> Links = std::map<std::string,std::vector<Link>>();
|
//std::map<std::string,std::vector<Link>> Links = std::map<std::string,std::vector<Link>>();
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ struct Rail: public Element{
|
||||||
|
|
||||||
std::list<RailPoint> Points = std::list<RailPoint>();
|
std::list<RailPoint> Points = std::list<RailPoint>();
|
||||||
|
|
||||||
RailType RailType = Linear;
|
RailType m_railType = RailType::Linear;
|
||||||
bool IsClosed = false;
|
bool IsClosed = false;
|
||||||
bool IsLadder = false;
|
bool IsLadder = false;
|
||||||
long Priority = 100;
|
long Priority = 100;
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ Element::Element(const YAML::Node &ObjNode,std::list<std::string> PropertyBlockL
|
||||||
TF.Rotation = ObjNode["Rotate"];
|
TF.Rotation = ObjNode["Rotate"];
|
||||||
TF.Scale = ObjNode["Scale"];
|
TF.Scale = ObjNode["Scale"];
|
||||||
|
|
||||||
Layer = ToLayerConfig(ObjNode["LayerConfigName"].as<std::string>());
|
Layer = ObjNode["LayerConfigName"].as<std::string>();
|
||||||
|
|
||||||
ModelName = ObjNode["ModelName"].as<std::string>();
|
ModelName = ObjNode["ModelName"].as<std::string>();
|
||||||
IsLinkDest = ObjNode["IsLinkDest"].as<bool>();
|
IsLinkDest = ObjNode["IsLinkDest"].as<bool>();
|
||||||
|
|
@ -89,7 +89,7 @@ void Element::YamlInsertBody(YAML::Emitter &Emitter) {
|
||||||
|
|
||||||
Emitter << YAML::Key << "UnitConfigName" << YAML::Value << Type;
|
Emitter << YAML::Key << "UnitConfigName" << YAML::Value << Type;
|
||||||
|
|
||||||
Emitter << YAML::Key << "LayerConfigName" << YAML::Value << ToStringYaml(Layer);
|
Emitter << YAML::Key << "LayerConfigName" << YAML::Value << Layer;
|
||||||
if(ModelName == "null") {
|
if(ModelName == "null") {
|
||||||
Emitter << YAML::Key << "ModelName" << YAML::Value << YAML::LowerNull << YAML::Null;
|
Emitter << YAML::Key << "ModelName" << YAML::Value << YAML::LowerNull << YAML::Null;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -2,14 +2,14 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Rail::Rail(const YAML::Node &ObjNode) : Element(ObjNode, {"RailPoints","RailType","IsClosed","IsLadder","Priority"}) {
|
Rail::Rail(const YAML::Node &ObjNode) : Element(ObjNode, {"RailPoints","m_railType","IsClosed","IsLadder","Priority"}) {
|
||||||
YAML::Node railPointsNode = ObjNode["RailPoints"];
|
YAML::Node railPointsNode = ObjNode["RailPoints"];
|
||||||
|
|
||||||
for (auto rlpoint: railPointsNode) {
|
for (auto rlpoint: railPointsNode) {
|
||||||
Points.emplace_back(rlpoint);
|
Points.emplace_back(rlpoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
RailType = ToRailType(ObjNode["RailType"].as<std::string>());
|
m_railType = ToRailType(ObjNode["RailType"].as<std::string>());
|
||||||
IsClosed = ObjNode["IsClosed"].as<bool>();
|
IsClosed = ObjNode["IsClosed"].as<bool>();
|
||||||
IsLadder = ObjNode["IsLadder"].as<bool>();
|
IsLadder = ObjNode["IsLadder"].as<bool>();
|
||||||
Priority = ObjNode["Priority"].as<long>();
|
Priority = ObjNode["Priority"].as<long>();
|
||||||
|
|
@ -31,7 +31,7 @@ void Rail::YamlInsertBody(YAML::Emitter &Emitter) {
|
||||||
}
|
}
|
||||||
Emitter << YAML::EndSeq;
|
Emitter << YAML::EndSeq;
|
||||||
|
|
||||||
Emitter << YAML::Key << "RailType" << YAML::Key << ToString(RailType);
|
Emitter << YAML::Key << "RailType" << YAML::Key << ToString(m_railType);
|
||||||
Emitter << YAML::Key << "IsClosed" << YAML::Key << IsClosed;
|
Emitter << YAML::Key << "IsClosed" << YAML::Key << IsClosed;
|
||||||
Emitter << YAML::Key << "IsLadder" << YAML::Key << IsLadder;
|
Emitter << YAML::Key << "IsLadder" << YAML::Key << IsLadder;
|
||||||
Emitter << YAML::Key << "Priority" << YAML::Key << YAML::LocalTag("l") << Priority;
|
Emitter << YAML::Key << "Priority" << YAML::Key << YAML::LocalTag("l") << Priority;
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ namespace Configs {
|
||||||
g_areas = loadStringListConfig(gameCfgPath / "Areas.yaml");
|
g_areas = loadStringListConfig(gameCfgPath / "Areas.yaml");
|
||||||
g_dropIdOpts = loadValueDisplayConfig<long>(gameCfgPath / "DropIds.yaml");
|
g_dropIdOpts = loadValueDisplayConfig<long>(gameCfgPath / "DropIds.yaml");
|
||||||
g_teams = loadValueDisplayConfig<long>(gameCfgPath / "Teams.yaml");
|
g_teams = loadValueDisplayConfig<long>(gameCfgPath / "Teams.yaml");
|
||||||
|
g_layers = loadValueDisplayConfig<std::string>(gameCfgPath / "Layers.yaml");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,7 @@ namespace Configs {
|
||||||
inline std::vector<std::string> g_areas;
|
inline std::vector<std::string> g_areas;
|
||||||
inline std::vector<ValueDisplayOptions<long>> g_dropIdOpts;
|
inline std::vector<ValueDisplayOptions<long>> g_dropIdOpts;
|
||||||
inline std::vector<ValueDisplayOptions<long>> g_teams;
|
inline std::vector<ValueDisplayOptions<long>> g_teams;
|
||||||
|
inline std::vector<ValueDisplayOptions<std::string>> g_layers;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -72,8 +72,12 @@ MainViewport::MainViewport() : Graphics::ViewportWidget("Main Viewport", true),
|
||||||
|
|
||||||
//ObjMesh = Graphics::Mesh();
|
//ObjMesh = Graphics::Mesh();
|
||||||
|
|
||||||
GLint ObjColPos = m_internalFramebuf->m_shader.getUniformLocation("ObjColor");
|
ObjIdPos = m_internalFramebuf->m_shader.getUniformLocation("ObjIdIn");
|
||||||
glUniform4f(ObjColPos, 1, 1, 1, 1);
|
ObjColPos = m_internalFramebuf->m_shader.getUniformLocation("ObjColor");
|
||||||
|
TeamId = m_internalFramebuf->m_shader.getUniformLocation("TeamId");
|
||||||
|
CamPosLoc = m_internalFramebuf->m_shader.getUniformLocation("CameraPosition");
|
||||||
|
LightDirId = m_internalFramebuf->m_shader.getUniformLocation("LightDirection");
|
||||||
|
SunVpLoc = m_internalFramebuf->m_shader.getUniformLocation("SunVP");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -99,12 +103,7 @@ void MainViewport::Draw() {
|
||||||
|
|
||||||
m_internalFramebuf->m_shader.use();
|
m_internalFramebuf->m_shader.use();
|
||||||
|
|
||||||
GLint ObjIdPos = m_internalFramebuf->m_shader.getUniformLocation("ObjIdIn");
|
|
||||||
GLint ObjColPos = m_internalFramebuf->m_shader.getUniformLocation("ObjColor");
|
|
||||||
|
|
||||||
GLint TeamId = m_internalFramebuf->m_shader.getUniformLocation("TeamId");
|
|
||||||
|
|
||||||
GLint CamPosLoc = m_internalFramebuf->m_shader.getUniformLocation("CameraPosition");
|
|
||||||
|
|
||||||
|
|
||||||
static auto lasttime = boost::chrono::high_resolution_clock::now();
|
static auto lasttime = boost::chrono::high_resolution_clock::now();
|
||||||
|
|
@ -193,6 +192,13 @@ void MainViewport::Draw() {
|
||||||
m_internalFramebuf->m_shader = flatShader;
|
m_internalFramebuf->m_shader = flatShader;
|
||||||
|
|
||||||
|
|
||||||
|
ObjIdPos = m_internalFramebuf->m_shader.getUniformLocation("ObjIdIn");
|
||||||
|
ObjColPos = m_internalFramebuf->m_shader.getUniformLocation("ObjColor");
|
||||||
|
TeamId = m_internalFramebuf->m_shader.getUniformLocation("TeamId");
|
||||||
|
CamPosLoc = m_internalFramebuf->m_shader.getUniformLocation("CameraPosition");
|
||||||
|
LightDirId = m_internalFramebuf->m_shader.getUniformLocation("LightDirection");
|
||||||
|
SunVpLoc = m_internalFramebuf->m_shader.getUniformLocation("SunVP");
|
||||||
|
|
||||||
flatShading = !flatShading;
|
flatShading = !flatShading;
|
||||||
}
|
}
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
|
|
@ -200,12 +206,12 @@ void MainViewport::Draw() {
|
||||||
|
|
||||||
m_internalFramebuf->m_shader.use();
|
m_internalFramebuf->m_shader.use();
|
||||||
|
|
||||||
GLint LightDirId = m_internalFramebuf->m_shader.getUniformLocation("LightDirection");
|
|
||||||
|
|
||||||
|
|
||||||
glUniform3f(LightDirId, LightDir.x , LightDir.y,LightDir.z);
|
if(!flatShading)
|
||||||
|
glUniform3f(LightDirId, LightDir.x , LightDir.y,LightDir.z);
|
||||||
|
|
||||||
|
glUniform4f(ObjColPos, 1, 1, 1, 1);
|
||||||
|
|
||||||
|
|
||||||
auto &map = GetMainWindow()->loadedMap;
|
auto &map = GetMainWindow()->loadedMap;
|
||||||
|
|
@ -222,66 +228,79 @@ void MainViewport::Draw() {
|
||||||
|
|
||||||
unsigned int ObjID = 16;
|
unsigned int ObjID = 16;
|
||||||
|
|
||||||
|
if(!flatShading) {
|
||||||
|
|
||||||
|
glm::vec3 SunPos = (glm::normalize(LightDir) * 1500.0f) + camPos;
|
||||||
|
|
||||||
glm::vec3 SunPos = (glm::normalize(LightDir) * 1500.0f) + camPos;
|
glm::mat4 SunProj = glm::ortho(-shadowArea, shadowArea, -shadowArea, shadowArea, 1.0f, 4000.0f);
|
||||||
|
|
||||||
glm::mat4 SunProj = glm::ortho(-shadowArea,shadowArea,-shadowArea,shadowArea,1.0f,4000.0f);
|
glm::mat4 SunView = glm::lookAt(SunPos, camPos, {0, 1, 0});
|
||||||
|
|
||||||
glm::mat4 SunView = glm::lookAt(SunPos,camPos,{0,1,0});
|
glm::mat4 SunVP = SunProj * SunView;
|
||||||
|
|
||||||
glm::mat4 SunVP = SunProj * SunView;
|
SunCam->bind();
|
||||||
|
SunCam->m_shader.use();
|
||||||
|
|
||||||
SunCam->bind();
|
glEnable(GL_DEPTH_TEST);
|
||||||
SunCam->m_shader.use();
|
glDepthFunc(GL_LESS);
|
||||||
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_CULL_FACE);
|
||||||
glDepthFunc(GL_LESS);
|
glCullFace(GL_BACK);
|
||||||
|
|
||||||
glEnable(GL_CULL_FACE);
|
glDisable(GL_BLEND);
|
||||||
glCullFace(GL_BACK);
|
|
||||||
|
|
||||||
glClear(GL_DEPTH_BUFFER_BIT);
|
glClear(GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
for (auto &obj: map.Objects) {
|
for (auto &obj: map.Objects) {
|
||||||
if (IsArea(obj.Type)) {
|
if (IsArea(obj.Type)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
if (!MdlFromObj.contains(obj.Type)) {
|
|
||||||
if (boost::filesystem::exists(
|
|
||||||
boost::filesystem::current_path() / "Models" / obj.Type / (obj.Type + ".dae")))
|
|
||||||
MdlFromObj.insert({obj.Type, Model(obj.Type)});
|
|
||||||
else {
|
|
||||||
MdlFromObj.insert({obj.Type, Model("St_Default")});
|
|
||||||
std::cout << "Model missing: \n\t" << obj.Type << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!MdlFromObj.contains(obj.Type)) {
|
||||||
|
if (boost::filesystem::exists(
|
||||||
|
boost::filesystem::current_path() / "Models" / obj.Type / (obj.Type + ".dae")))
|
||||||
|
MdlFromObj.insert({obj.Type, Model(obj.Type)});
|
||||||
|
else {
|
||||||
|
MdlFromObj.insert({obj.Type, Model("St_Default")});
|
||||||
|
std::cout << "Model missing: \n\t" << obj.Type << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
auto &mdl = MdlFromObj.find(obj.Type)->second;
|
||||||
|
|
||||||
|
mdl.Draw(obj.TF, SunCam->m_shader, SunVP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_internalFramebuf->bind();
|
||||||
|
m_internalFramebuf->m_shader.use();
|
||||||
|
|
||||||
auto &mdl = MdlFromObj.find(obj.Type)->second;
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
glDepthFunc(GL_LESS);
|
||||||
|
|
||||||
mdl.Draw(obj.TF, SunCam->m_shader, SunVP);
|
glEnable(GL_CULL_FACE);
|
||||||
|
glCullFace(GL_FRONT);
|
||||||
|
|
||||||
|
auto &tex = SunCam->getFbTexByAttachment(GL_DEPTH_ATTACHMENT);
|
||||||
|
tex.m_texture->setActive(5);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
glUniformMatrix4fv(SunVpLoc,1,GL_FALSE,&SunVP[0][0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_internalFramebuf->bind();
|
|
||||||
m_internalFramebuf->m_shader.use();
|
|
||||||
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
|
||||||
glDepthFunc(GL_LESS);
|
|
||||||
|
|
||||||
glEnable(GL_CULL_FACE);
|
glEnable(GL_CULL_FACE);
|
||||||
glCullFace(GL_FRONT);
|
glCullFace(GL_FRONT);
|
||||||
|
|
||||||
auto &tex = SunCam->getFbTexByAttachment(GL_DEPTH_ATTACHMENT);
|
glEnable(GL_BLEND);
|
||||||
tex.m_texture->setActive(5);
|
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
GLint SunVpLoc = m_internalFramebuf->m_shader.getUniformLocation("SunVP");
|
|
||||||
|
|
||||||
glUniformMatrix4fv(SunVpLoc,1,GL_FALSE,&SunVP[0][0]);
|
|
||||||
|
|
||||||
for (auto &obj: map.Objects) {
|
for (auto &obj: map.Objects) {
|
||||||
glUniform1i(TeamId,(GLint)obj.Team);
|
if(!flatShading)
|
||||||
|
glUniform1i(TeamId,(GLint)obj.Team);
|
||||||
|
|
||||||
if (IsArea(obj.Type) && !drawAllAreas) {
|
if (IsArea(obj.Type) && !drawAllAreas) {
|
||||||
ObjID++;
|
ObjID++;
|
||||||
|
|
@ -289,7 +308,6 @@ void MainViewport::Draw() {
|
||||||
} else if (IsArea(obj.Type) && drawAllAreas) {
|
} else if (IsArea(obj.Type) && drawAllAreas) {
|
||||||
static auto AreaMdl = Model("St_Area");
|
static auto AreaMdl = Model("St_Area");
|
||||||
glUniform1ui(ObjIdPos, ObjID);
|
glUniform1ui(ObjIdPos, ObjID);
|
||||||
glUniform4f(ObjColPos, 1, 1, 1, 1);
|
|
||||||
AreaMdl.Draw(obj.TF, m_internalFramebuf->m_shader, VP);
|
AreaMdl.Draw(obj.TF, m_internalFramebuf->m_shader, VP);
|
||||||
ObjID++;
|
ObjID++;
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -308,12 +326,13 @@ void MainViewport::Draw() {
|
||||||
|
|
||||||
auto &mdl = MdlFromObj.find(obj.Type)->second;
|
auto &mdl = MdlFromObj.find(obj.Type)->second;
|
||||||
glUniform1ui(ObjIdPos, ObjID);
|
glUniform1ui(ObjIdPos, ObjID);
|
||||||
glUniform4f(ObjColPos, 1, 1, 1, 1);
|
|
||||||
|
|
||||||
if (&obj == GetMainWindow()->selectedElem)
|
if (&obj == GetMainWindow()->selectedElem)
|
||||||
glUniform4f(ObjColPos, 1, .7, .7, 1);
|
glUniform4f(ObjColPos, 1, .7, .7, 1);
|
||||||
|
|
||||||
mdl.Draw(obj.TF, m_internalFramebuf->m_shader, VP);
|
mdl.Draw(obj.TF, m_internalFramebuf->m_shader, VP);
|
||||||
|
if (&obj == GetMainWindow()->selectedElem)
|
||||||
|
glUniform4f(ObjColPos, 1, 1, 1, 1);
|
||||||
|
|
||||||
ObjID++;
|
ObjID++;
|
||||||
}
|
}
|
||||||
|
|
@ -321,19 +340,17 @@ void MainViewport::Draw() {
|
||||||
|
|
||||||
if (GetMainWindow()->selectedElem != nullptr) {
|
if (GetMainWindow()->selectedElem != nullptr) {
|
||||||
auto selobj = GetMainWindow()->selectedElem;
|
auto selobj = GetMainWindow()->selectedElem;
|
||||||
|
glUniform1ui(ObjIdPos, 0);
|
||||||
|
|
||||||
if (IsArea(selobj->Type)) {
|
if (IsArea(selobj->Type)) {
|
||||||
static auto AreaMdl = Model("St_Area");
|
static auto AreaMdl = Model("St_Area");
|
||||||
|
|
||||||
glUniform1ui(ObjIdPos, 0);
|
|
||||||
|
|
||||||
AreaMdl.Draw(selobj->TF, m_internalFramebuf->m_shader, VP);
|
AreaMdl.Draw(selobj->TF, m_internalFramebuf->m_shader, VP);
|
||||||
}
|
}
|
||||||
|
|
||||||
glClear(GL_DEPTH_BUFFER_BIT);
|
glClear(GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
for (Link &link: GetMainWindow()->selectedElem->Links) {
|
for (Link &link: GetMainWindow()->selectedElem->Links) {
|
||||||
glUniform1ui(ObjIdPos, 0);
|
|
||||||
Element *elem = GetMainWindow()->loadedMap.GetElementById(link.Destination);
|
Element *elem = GetMainWindow()->loadedMap.GetElementById(link.Destination);
|
||||||
if (elem == nullptr)
|
if (elem == nullptr)
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -344,15 +361,14 @@ void MainViewport::Draw() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Rail *rail = dynamic_cast<Rail *>(GetMainWindow()->selectedElem)) {
|
if (Rail *rail = dynamic_cast<Rail *>(GetMainWindow()->selectedElem)) {
|
||||||
glUniform1ui(ObjIdPos, 0);
|
|
||||||
RenderRail(rail);
|
RenderRail(rail);
|
||||||
}
|
}
|
||||||
|
|
||||||
//mdl.DrawSelection(selobj->TF);
|
//mdl.DrawSelection(selobj->TF);
|
||||||
|
|
||||||
glClear(GL_DEPTH_BUFFER_BIT);
|
//glClear(GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
if (CurrentGizmoType == Move) {
|
/*if (CurrentGizmoType == Move) {
|
||||||
static Model Arrow = Model("St_Arrow");
|
static Model Arrow = Model("St_Arrow");
|
||||||
|
|
||||||
auto tf = Transform();
|
auto tf = Transform();
|
||||||
|
|
@ -445,12 +461,10 @@ void MainViewport::Draw() {
|
||||||
Rotator.Draw(tf, m_internalFramebuf->m_shader, VP);
|
Rotator.Draw(tf, m_internalFramebuf->m_shader, VP);
|
||||||
|
|
||||||
glUniform4f(ObjColPos, 1, 1, 1, 1);
|
glUniform4f(ObjColPos, 1, 1, 1, 1);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glDisable(GL_DEPTH_TEST);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename t>
|
template<typename t>
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ private:
|
||||||
|
|
||||||
unsigned int HoveredObjId = 0;
|
unsigned int HoveredObjId = 0;
|
||||||
|
|
||||||
std::map<std::string,Model> MdlFromObj;
|
std::unordered_map<std::string,Model> MdlFromObj;
|
||||||
|
|
||||||
float FarClippingPlane = 10000.0f;
|
float FarClippingPlane = 10000.0f;
|
||||||
float NearClippingPlane = 0.1f;
|
float NearClippingPlane = 0.1f;
|
||||||
|
|
@ -79,6 +79,14 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Draw() override;
|
void Draw() override;
|
||||||
|
|
||||||
|
//GLUniform Location Cache
|
||||||
|
GLint ObjIdPos;
|
||||||
|
GLint ObjColPos;
|
||||||
|
GLint TeamId;
|
||||||
|
GLint CamPosLoc;
|
||||||
|
GLint LightDirId;
|
||||||
|
GLint SunVpLoc;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -126,7 +126,7 @@ MainWindow::MainWindow(): Graphics::Window("SpoonEdit") {
|
||||||
ObjCpy.TF.Rotation = {0, 0, 0};
|
ObjCpy.TF.Rotation = {0, 0, 0};
|
||||||
ObjCpy.TF.Position = {0, 0, 0};
|
ObjCpy.TF.Position = {0, 0, 0};
|
||||||
|
|
||||||
for(long ¶m: ObjCpy.Parameters){
|
for(int ¶m: ObjCpy.Parameters){
|
||||||
param = -99;
|
param = -99;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -134,7 +134,7 @@ MainWindow::MainWindow(): Graphics::Window("SpoonEdit") {
|
||||||
param = -99.0f;
|
param = -99.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjCpy.Layer = Common;
|
ObjCpy.Layer = "Cmn";
|
||||||
|
|
||||||
ExportObj(ObjCpy);
|
ExportObj(ObjCpy);
|
||||||
}
|
}
|
||||||
|
|
@ -156,7 +156,7 @@ MainWindow::MainWindow(): Graphics::Window("SpoonEdit") {
|
||||||
ObjCpy.Name = ObjCpy.Type;
|
ObjCpy.Name = ObjCpy.Type;
|
||||||
ObjCpy.Links = std::vector<Link>();
|
ObjCpy.Links = std::vector<Link>();
|
||||||
|
|
||||||
for(long ¶m: ObjCpy.Parameters){
|
for(int ¶m: ObjCpy.Parameters){
|
||||||
param = -99;
|
param = -99;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -164,7 +164,7 @@ MainWindow::MainWindow(): Graphics::Window("SpoonEdit") {
|
||||||
param = -99.0f;
|
param = -99.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjCpy.Layer = Common;
|
ObjCpy.Layer = "Cmn";
|
||||||
|
|
||||||
ObjCpy.TF.Scale = {1, 1, 1};
|
ObjCpy.TF.Scale = {1, 1, 1};
|
||||||
ObjCpy.TF.Rotation = {0, 0, 0};
|
ObjCpy.TF.Rotation = {0, 0, 0};
|
||||||
|
|
@ -182,8 +182,7 @@ MainWindow::MainWindow(): Graphics::Window("SpoonEdit") {
|
||||||
|
|
||||||
Configs::g_loadConfigs("Gambit");
|
Configs::g_loadConfigs("Gambit");
|
||||||
|
|
||||||
glfwMakeContextCurrent(GetGlfwWindow());
|
//Graphics::EnableVsync();
|
||||||
glfwSwapInterval(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::Update() {
|
void MainWindow::Update() {
|
||||||
|
|
|
||||||
|
|
@ -91,19 +91,13 @@ void Model::Draw(const Transform &tf, Graphics::Shader &shader, const glm::mat4
|
||||||
glm::vec3 scale(tf.Scale.X,tf.Scale.Y,tf.Scale.Z);
|
glm::vec3 scale(tf.Scale.X,tf.Scale.Y,tf.Scale.Z);
|
||||||
|
|
||||||
glm::mat4 translationMatrix = glm::translate(glm::mat4(1),glm::vec3(pos.x,pos.y,pos.z));
|
glm::mat4 translationMatrix = glm::translate(glm::mat4(1),glm::vec3(pos.x,pos.y,pos.z));
|
||||||
glm::mat4 translationNoYInvertMatrix = glm::translate(glm::mat4(1),glm::vec3(pos.x,pos.y,pos.z));
|
|
||||||
glm::mat4 rotationMatrixZ = glm::rotate(glm::mat4(1),glm::radians(rot.z), glm::vec3(0,0,1));
|
glm::mat4 rotationMatrixZ = glm::rotate(glm::mat4(1),glm::radians(rot.z), glm::vec3(0,0,1));
|
||||||
glm::mat4 rotationMatrixY = glm::rotate(rotationMatrixZ,glm::radians(rot.y), glm::vec3(0,1,0));
|
glm::mat4 rotationMatrixY = glm::rotate(rotationMatrixZ,glm::radians(rot.y), glm::vec3(0,1,0));
|
||||||
glm::mat4 rotationMatrix = glm::rotate(rotationMatrixY,glm::radians(rot.x), glm::vec3(1,0,0));
|
glm::mat4 rotationMatrix = glm::rotate(rotationMatrixY,glm::radians(rot.x), glm::vec3(1,0,0));
|
||||||
|
|
||||||
glm::mat4 nrmRotationMatrixZ = glm::rotate(glm::mat4(1),glm::radians(normalRot.z), glm::vec3(0,0,1));
|
|
||||||
glm::mat4 nrmRotationMatrixY = glm::rotate(nrmRotationMatrixZ,glm::radians(normalRot.y), glm::vec3(0,1,0));
|
|
||||||
glm::mat4 nrmRotationMatrix = glm::rotate(nrmRotationMatrixY,glm::radians(normalRot.x), glm::vec3(1,0,0));
|
|
||||||
glm::mat4 scaleMatrix = glm::scale(glm::mat4(1),scale);
|
glm::mat4 scaleMatrix = glm::scale(glm::mat4(1),scale);
|
||||||
|
|
||||||
glm::mat4 matrix = VP * translationMatrix * rotationMatrix * scaleMatrix;
|
glm::mat4 matrix = VP * translationMatrix * rotationMatrix * scaleMatrix;
|
||||||
glm::mat4 ModelMatrix = translationMatrix * rotationMatrix * scaleMatrix;
|
glm::mat4 ModelMatrix = translationMatrix * rotationMatrix * scaleMatrix;
|
||||||
glm::mat4 noYInvertMatrix = translationNoYInvertMatrix * nrmRotationMatrix * scaleMatrix;
|
|
||||||
|
|
||||||
GLuint MatrixID = shader.getUniformLocation("MVP");
|
GLuint MatrixID = shader.getUniformLocation("MVP");
|
||||||
glUniformMatrix4fv(MatrixID,1,GL_FALSE,&matrix[0][0]);
|
glUniformMatrix4fv(MatrixID,1,GL_FALSE,&matrix[0][0]);
|
||||||
|
|
@ -111,16 +105,12 @@ void Model::Draw(const Transform &tf, Graphics::Shader &shader, const glm::mat4
|
||||||
GLuint ModelMatrixID = shader.getUniformLocation("ModelMatrix");
|
GLuint ModelMatrixID = shader.getUniformLocation("ModelMatrix");
|
||||||
glUniformMatrix4fv(ModelMatrixID,1,GL_FALSE,&ModelMatrix[0][0]);
|
glUniformMatrix4fv(ModelMatrixID,1,GL_FALSE,&ModelMatrix[0][0]);
|
||||||
|
|
||||||
GLuint MatrixNoYInvID = shader.getUniformLocation("TransformationMatrixNoYInv");
|
|
||||||
glUniformMatrix4fv(MatrixNoYInvID,1,GL_FALSE,&noYInvertMatrix[0][0]);
|
|
||||||
|
|
||||||
GLuint RotationMatrixID = shader.getUniformLocation("NormalRotationMatrix");
|
GLuint RotationMatrixID = shader.getUniformLocation("NormalRotationMatrix");
|
||||||
glUniformMatrix4fv(RotationMatrixID,1,GL_FALSE,&nrmRotationMatrix[0][0]);
|
glUniformMatrix4fv(RotationMatrixID,1,GL_FALSE,&rotationMatrix[0][0]);
|
||||||
|
|
||||||
mesh->Draw(*Materials[texnum]);
|
mesh->Draw(*Materials[texnum]);
|
||||||
texnum++;
|
texnum++;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Model::DrawSelection(Transform tf, Graphics::Shader &shader, glm::mat4 VP) {
|
void Model::DrawSelection(Transform tf, Graphics::Shader &shader, glm::mat4 VP) {
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ void ImGuiDrawSelection(std::string id, t &val, iter optsBegin, iter optsEnd, st
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename t>
|
/*template<typename t>
|
||||||
void ImGuiDrawLayer(t *obj) {
|
void ImGuiDrawLayer(t *obj) {
|
||||||
if (ImGui::BeginCombo("Layer##PropWind", ToString(obj->Layer).c_str())) {
|
if (ImGui::BeginCombo("Layer##PropWind", ToString(obj->Layer).c_str())) {
|
||||||
if (ImGui::Selectable("Common##TeamsPropWind"))
|
if (ImGui::Selectable("Common##TeamsPropWind"))
|
||||||
|
|
@ -65,7 +65,7 @@ void ImGuiDrawLayer(t *obj) {
|
||||||
obj->Layer = Temporary;
|
obj->Layer = Temporary;
|
||||||
ImGui::EndCombo();
|
ImGui::EndCombo();
|
||||||
}
|
}
|
||||||
};
|
};*/
|
||||||
|
|
||||||
void ImGuiDrawTransform(Transform &tf, std::string id) {
|
void ImGuiDrawTransform(Transform &tf, std::string id) {
|
||||||
ImGui::Text("Transform:");
|
ImGui::Text("Transform:");
|
||||||
|
|
@ -103,7 +103,7 @@ void ImGuiDrawElem(Element *elem, std::string Id = "") {
|
||||||
ImGui::InputText(("##PropWindInputType" + Id).c_str(), &elem->Type);
|
ImGui::InputText(("##PropWindInputType" + Id).c_str(), &elem->Type);
|
||||||
ImGui::PopItemWidth();
|
ImGui::PopItemWidth();
|
||||||
ImGuiDrawTransform(elem->TF, "PropWind" + Id);
|
ImGuiDrawTransform(elem->TF, "PropWind" + Id);
|
||||||
ImGuiDrawLayer(elem);
|
Configs::g_imguiDrawOpts("Layer##" + Id, Configs::g_layers, elem->Layer);
|
||||||
ImGui::Checkbox(("Is Link Destination?##PropWindowIsLinkDest" + Id).c_str(), &elem->IsLinkDest);
|
ImGui::Checkbox(("Is Link Destination?##PropWindowIsLinkDest" + Id).c_str(), &elem->IsLinkDest);
|
||||||
if (ImGui::CollapsingHeader(("Links##" + Id).c_str())) {
|
if (ImGui::CollapsingHeader(("Links##" + Id).c_str())) {
|
||||||
ImGui::Indent();
|
ImGui::Indent();
|
||||||
|
|
@ -117,7 +117,7 @@ void ImGuiDrawElem(Element *elem, std::string Id = "") {
|
||||||
|
|
||||||
if (Element *gotoElem = GetMainWindow()->loadedMap.GetElementById(link.Destination)) {
|
if (Element *gotoElem = GetMainWindow()->loadedMap.GetElementById(link.Destination)) {
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if (ImGui::Button(ICON_FA_CHEVRON_RIGHT)) {
|
if (ImGui::Button((ICON_FA_CHEVRON_RIGHT + std::string("##GotoDest") + std::to_string(i)).c_str())) {
|
||||||
GetMainWindow()->selectedElem = gotoElem;
|
GetMainWindow()->selectedElem = gotoElem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -144,7 +144,7 @@ void ImGuiDrawElem(Element *elem, std::string Id = "") {
|
||||||
ImGui::Checkbox(("Is Closed?##" + Id).c_str(), &rail->IsClosed);
|
ImGui::Checkbox(("Is Closed?##" + Id).c_str(), &rail->IsClosed);
|
||||||
ImGui::Checkbox(("Is Ladder?##" + Id).c_str(), &rail->IsLadder);
|
ImGui::Checkbox(("Is Ladder?##" + Id).c_str(), &rail->IsLadder);
|
||||||
ImGui::InputInt(("Priority?##" + Id).c_str(), (int *) &rail->Priority);
|
ImGui::InputInt(("Priority?##" + Id).c_str(), (int *) &rail->Priority);
|
||||||
ImGuiDrawSelection("Rail Type", rail->RailType, AllRailTypeOptions.begin(), AllRailTypeOptions.end(),
|
ImGuiDrawSelection("Rail Type", rail->m_railType, AllRailTypeOptions.begin(), AllRailTypeOptions.end(),
|
||||||
[](RailType t) { return ToString(t); });
|
[](RailType t) { return ToString(t); });
|
||||||
if (ImGui::CollapsingHeader(("Rail Points##" + Id).c_str())) {
|
if (ImGui::CollapsingHeader(("Rail Points##" + Id).c_str())) {
|
||||||
ImGui::Indent();
|
ImGui::Indent();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue