Maintain item list
This commit is contained in:
@@ -700,6 +700,7 @@ struct EditorGUIListener : public Ogre::RenderTargetListener {
|
||||
bool locationSelected = false;
|
||||
float strength = 0.0f;
|
||||
int size = 0;
|
||||
long slot_x, slot_y;
|
||||
void updateWorldTexture()
|
||||
{
|
||||
// Get the hardware pixel buffer
|
||||
@@ -748,16 +749,33 @@ struct EditorGUIListener : public Ogre::RenderTargetListener {
|
||||
|
||||
ECS::get<Terrain>().mTerrainGroup->update(true);
|
||||
}
|
||||
void setCameraPos()
|
||||
void setCursorPos(Ogre::Vector3 &cursorPosition,
|
||||
Ogre::Quaternion &orientation)
|
||||
{
|
||||
Ogre::Vector3 worldPos =
|
||||
ECS::get<Camera>().mCameraPivot->_getDerivedPosition();
|
||||
ECS::get<EditorGizmo>().sceneNode->_getDerivedPosition();
|
||||
worldPos.x = TerrainModule::get_world_x(selected_x);
|
||||
worldPos.z = TerrainModule::get_world_y(selected_y);
|
||||
worldPos.y = TerrainModule::get_height(
|
||||
ECS::get<Terrain>().mTerrainGroup, worldPos);
|
||||
ECS::get<EditorGizmo>().sceneNode->_setDerivedPosition(
|
||||
worldPos);
|
||||
cursorPosition = worldPos;
|
||||
orientation = ECS::get<EditorGizmo>()
|
||||
.sceneNode->_getDerivedOrientation();
|
||||
}
|
||||
void setCameraPos()
|
||||
{
|
||||
Ogre::Vector3 cursorPos;
|
||||
Ogre::Quaternion cursorOrientation;
|
||||
setCursorPos(cursorPos, cursorOrientation);
|
||||
Ogre::Vector3 cameraPos =
|
||||
ECS::get<Camera>().mCameraPivot->_getDerivedPosition();
|
||||
cameraPos.x = worldPos.x;
|
||||
cameraPos.z = worldPos.z;
|
||||
Ogre::Vector3 cameraOffset =
|
||||
cursorOrientation * Ogre::Vector3::UNIT_Z * 30.0f;
|
||||
cameraPos.x = cursorPos.x;
|
||||
cameraPos.z = cursorPos.z;
|
||||
cameraPos += cameraOffset;
|
||||
cameraPos.y =
|
||||
TerrainModule::get_height(
|
||||
ECS::get<Terrain>().mTerrainGroup, cameraPos) +
|
||||
@@ -765,9 +783,14 @@ struct EditorGUIListener : public Ogre::RenderTargetListener {
|
||||
if (cameraPos.y < 0.0f)
|
||||
cameraPos.y = 10.0f;
|
||||
ECS::get<Camera>().mCameraPivot->_setDerivedPosition(cameraPos);
|
||||
ECS::get<Camera>().mCameraPivot->_setDerivedOrientation(
|
||||
cursorOrientation);
|
||||
cameraPos =
|
||||
ECS::get<Camera>().mCameraGoal->_getDerivedPosition();
|
||||
ECS::get<Camera>().mCameraNode->_setDerivedPosition(cameraPos);
|
||||
ECS::get<Camera>().mCameraNode->_setDerivedOrientation(
|
||||
ECS::get<Camera>()
|
||||
.mCameraGoal->_getDerivedOrientation());
|
||||
updateHeightmap();
|
||||
}
|
||||
void worldMapView()
|
||||
@@ -784,10 +807,10 @@ struct EditorGUIListener : public Ogre::RenderTargetListener {
|
||||
OgreAssert(TerrainModule::get_world_y(worldMap->getHeight() /
|
||||
2) == 0.0f,
|
||||
"get_world_y");
|
||||
if (ECS::get<Camera>().mCameraPivot) {
|
||||
if (ECS::get<EditorGizmo>().sceneNode) {
|
||||
Ogre::Vector3 worldPos =
|
||||
ECS::get<Camera>()
|
||||
.mCameraPivot->_getDerivedPosition();
|
||||
ECS::get<EditorGizmo>()
|
||||
.sceneNode->_getDerivedPosition();
|
||||
selected_x = TerrainModule::get_img_x(worldPos.x);
|
||||
selected_y = TerrainModule::get_img_y(worldPos.z);
|
||||
locationSelected = true;
|
||||
@@ -797,6 +820,10 @@ struct EditorGUIListener : public Ogre::RenderTargetListener {
|
||||
OgreAssert(selected_y >= 0 &&
|
||||
selected_y < worldMap->getHeight(),
|
||||
"mix height");
|
||||
ECS::get<Terrain>()
|
||||
.mTerrainGroup
|
||||
->convertWorldPositionToTerrainSlot(
|
||||
worldPos, &slot_x, &slot_y);
|
||||
}
|
||||
ImGui::SetNextWindowSizeConstraints(ImVec2(512 + 20, 512 + 20),
|
||||
ImVec2(768, 768));
|
||||
@@ -856,6 +883,18 @@ struct EditorGUIListener : public Ogre::RenderTargetListener {
|
||||
ImDrawList *draw_list = ImGui::GetWindowDrawList();
|
||||
draw_list->AddCircleFilled(ImVec2(top_x + pos_x, top_y + pos_y),
|
||||
1.0f, IM_COL32(0, 255, 0, 255));
|
||||
{
|
||||
std::list<Ogre::Vector3> positions;
|
||||
TerrainModule::getItemPositions(&positions);
|
||||
for (auto pos : positions) {
|
||||
int item_x = TerrainModule::get_img_x(pos.x);
|
||||
int item_y = TerrainModule::get_img_y(pos.z);
|
||||
draw_list->AddCircleFilled(
|
||||
ImVec2(top_x + item_x, top_y + item_y),
|
||||
3.0f, IM_COL32(255, 255, 0, 255));
|
||||
std::cout << pos << std::endl;
|
||||
}
|
||||
}
|
||||
if (locationSelected)
|
||||
draw_list->AddCircleFilled(
|
||||
ImVec2(top_x + selected_x, top_y + selected_y),
|
||||
@@ -877,6 +916,13 @@ struct EditorGUIListener : public Ogre::RenderTargetListener {
|
||||
ImGui::Text(
|
||||
"Selected height: %f",
|
||||
worldMapImage.getColourAt(selected_x, selected_y, 0).r);
|
||||
{
|
||||
Ogre::Vector3 position =
|
||||
ECS::get<EditorGizmo>()
|
||||
.sceneNode->_getDerivedPosition();
|
||||
ImGui::Text("Cursor position %f %f %f", position.x,
|
||||
position.y, position.z);
|
||||
}
|
||||
if (ImGui::Button("Update terrain")) {
|
||||
ECS::get<Terrain>().mTerrainGroup->update(true);
|
||||
}
|
||||
@@ -948,6 +994,17 @@ struct EditorGUIListener : public Ogre::RenderTargetListener {
|
||||
setLevel = true;
|
||||
setLevelValue = 0.646f;
|
||||
}
|
||||
if (ImGui::Button("Harbour")) {
|
||||
Ogre::Vector3 itemPosition =
|
||||
ECS::get<EditorGizmo>()
|
||||
.sceneNode->_getDerivedPosition();
|
||||
Ogre::Quaternion itemOrientation =
|
||||
ECS::get<EditorGizmo>()
|
||||
.sceneNode->_getDerivedOrientation();
|
||||
TerrainModule::createItem(itemPosition, itemOrientation,
|
||||
"harbour");
|
||||
TerrainModule::saveItems();
|
||||
}
|
||||
if (riseLower) {
|
||||
int actualSize = 1 + size * 2;
|
||||
int i, j;
|
||||
|
||||
Reference in New Issue
Block a user