Building interior walls created with editor
This commit is contained in:
@@ -259,9 +259,4 @@ bool Vector3::zeroLength() const
|
||||
return (l < 1e-06 * 1e-06);
|
||||
}
|
||||
|
||||
void setupEditorAlt(Ogre::SceneManager *scnMgr, Ogre::SceneNode *cameraNode,
|
||||
Ogre::Camera *camera, Ogre::RenderWindow *window)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -347,8 +347,8 @@ public:
|
||||
break;
|
||||
long x = collider_queue.front().x;
|
||||
long y = collider_queue.front().y;
|
||||
std::cout << x << " " << y << " "
|
||||
<< collider_queue.size() << std::endl;
|
||||
// std::cout << x << " " << y << " "
|
||||
// << collider_queue.size() << std::endl;
|
||||
Ogre::Terrain *terrain = group->getTerrain(x, y);
|
||||
Ogre::Vector3 worldPos;
|
||||
group->convertTerrainSlotToWorldPosition(x, y,
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "TerrainModule.h"
|
||||
#include "physics.h"
|
||||
#include "PhysicsModule.h"
|
||||
#include "LuaData.h"
|
||||
#include "harbour.h"
|
||||
#include "temple.h"
|
||||
#include "town.h"
|
||||
@@ -30,6 +31,92 @@ void showItemPopup(const std::pair<flecs::entity, Ogre::String> &item)
|
||||
StaticGeometryModule::getItemProperties(item.first);
|
||||
nlohmann::json j = nlohmann::json::parse(prop);
|
||||
Ogre::String itemType = j["type"].get<Ogre::String>();
|
||||
bool changed = false;
|
||||
bool set = false;
|
||||
bool offset = false;
|
||||
Ogre::Vector3 offsetVal(0, 0, 0);
|
||||
int i;
|
||||
struct OffsetButton {
|
||||
Ogre::String label;
|
||||
Ogre::Vector3 offset;
|
||||
ImGuiDir direction;
|
||||
};
|
||||
struct OffsetButton buttons_large[] = {
|
||||
{ "ElevateUp", { 0, 1, 0 }, ImGuiDir::ImGuiDir_Up },
|
||||
{ "ElevateDown", { 0, -1, 0 }, ImGuiDir::ImGuiDir_Down },
|
||||
{ "X+", { 1, 0, 0 }, ImGuiDir::ImGuiDir_None },
|
||||
{ "X-", { -1, 0, 0 }, ImGuiDir::ImGuiDir_None },
|
||||
{ "Z+", { 0, 0, 1 }, ImGuiDir::ImGuiDir_None },
|
||||
{ "Z-", { 0, 0, -1 }, ImGuiDir::ImGuiDir_None },
|
||||
};
|
||||
struct OffsetButton buttons_small[] = {
|
||||
{ "SmallElevateUp",
|
||||
{ 0, 0.1f, 0 },
|
||||
ImGuiDir::ImGuiDir_Up },
|
||||
{ "SmallElevateDown",
|
||||
{ 0, -0.1f, 0 },
|
||||
ImGuiDir::ImGuiDir_Down },
|
||||
{ "0.1 X+", { 0.1f, 0, 0 }, ImGuiDir::ImGuiDir_None },
|
||||
{ "0.1 X-", { -0.1f, 0, 0 }, ImGuiDir::ImGuiDir_None },
|
||||
{ "0.1 Z+", { 0, 0, 0.1f }, ImGuiDir::ImGuiDir_None },
|
||||
{ "0.1 Z-", { 0, 0, -0.1f }, ImGuiDir::ImGuiDir_None },
|
||||
};
|
||||
|
||||
if (ImGui::SmallButton("Set position from cursor")) {
|
||||
changed = true;
|
||||
set = true;
|
||||
}
|
||||
auto buttonGroup = [&](struct OffsetButton *button, int count) {
|
||||
int i;
|
||||
for (i = 0; i < count; i++) {
|
||||
if (i > 0)
|
||||
ImGui::SameLine();
|
||||
if (button[i].direction !=
|
||||
ImGuiDir::ImGuiDir_None) {
|
||||
if (ImGui::ArrowButton(
|
||||
button[i].label.c_str(),
|
||||
button[i].direction)) {
|
||||
offsetVal = button[i].offset;
|
||||
offset = true;
|
||||
changed = true;
|
||||
}
|
||||
} else {
|
||||
if (ImGui::SmallButton(
|
||||
button[i].label.c_str())) {
|
||||
offsetVal = button[i].offset;
|
||||
offset = true;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
buttonGroup(buttons_large,
|
||||
sizeof(buttons_large) / sizeof(buttons_large[0]));
|
||||
buttonGroup(buttons_small,
|
||||
sizeof(buttons_small) / sizeof(buttons_small[0]));
|
||||
if (changed) {
|
||||
Ogre::Vector3 position =
|
||||
item.first.get<TerrainItem>().position;
|
||||
Ogre::Quaternion orientation =
|
||||
item.first.get<TerrainItem>().orientation;
|
||||
if (set) {
|
||||
position = ECS::get<EditorGizmo>()
|
||||
.sceneNode
|
||||
->_getDerivedPosition();
|
||||
orientation =
|
||||
ECS::get<EditorGizmo>()
|
||||
.sceneNode
|
||||
->_getDerivedOrientation();
|
||||
} else if (offset)
|
||||
position += offsetVal;
|
||||
item.first.get_mut<TerrainItem>().position = position;
|
||||
item.first.get_mut<TerrainItem>().orientation =
|
||||
orientation;
|
||||
item.first.modified<TerrainItem>();
|
||||
StaticGeometryModule::saveItems();
|
||||
StaticGeometryModule::destroyItemGeometry(item.first);
|
||||
StaticGeometryModule::createItemGeometry(item.first);
|
||||
}
|
||||
if (itemType == "harbour")
|
||||
createHarbourPopup(item);
|
||||
else if (itemType == "temple")
|
||||
@@ -82,8 +169,9 @@ void createItemsMenu()
|
||||
if (ImGui::BeginMenu("Town")) {
|
||||
Items::createTownMenu();
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
namespace Geometry
|
||||
{
|
||||
@@ -220,4 +308,4 @@ flecs::entity createMeshGeometry(const Ogre::String &meshName,
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,4 +86,4 @@ static void from_json(const nlohmann::json &j, Ogre::Quaternion &orientation)
|
||||
orientation.z = j["z"].get<float>();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -12,10 +12,16 @@ void createTownPopup(const std::pair<flecs::entity, Ogre::String> item);
|
||||
}
|
||||
namespace Geometry
|
||||
{
|
||||
void createCells(flecs::entity e, const nlohmann::json &jdistrict, int index,
|
||||
Ogre::SceneNode *sceneNode, Ogre::StaticGeometry *geo);
|
||||
void createTown(flecs::entity e, Ogre::SceneNode *sceneNode,
|
||||
Ogre::StaticGeometry *geo);
|
||||
void createTownPlazza(flecs::entity e, const nlohmann::json &jdistrict,
|
||||
Ogre::SceneNode *sceneNode, Ogre::StaticGeometry *geo);
|
||||
int index, Ogre::SceneNode *sceneNode,
|
||||
Ogre::StaticGeometry *geo);
|
||||
void createTownLots(flecs::entity e, const nlohmann::json &jdistrict,
|
||||
int index, Ogre::SceneNode *sceneNode,
|
||||
Ogre::StaticGeometry *geo);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user