Jump to content

Andy90

Developers
  • Posts

    219
  • Joined

  • Last visited

Everything posted by Andy90

  1. When dynamically adding and deleting items in a GridView widget during gameplay, rendering errors occur. After deleting and re-adding items, the GridView is not updated correctly, resulting in visual anomalies. Additionally, @Dreikblack discovered that blocks are overlaid when they are exactly on top of each other. He may provide further details on this. To reproduce the error, follow these steps: 1. Add the provided C++ classes from the GitHub repository https://github.com/Andy16823/UltraEngine-GridView-Widget/ to the project. 2. Create the GridView widget in main.cpp. 3. Add two items and observe correct rendering. 4. In the main loop, call the ClearGridItems function to delete the grid items. 5. Afterward, add new items and check for rendering errors. 6. It has been observed that the error does not occur if the initially created items are skipped. Create the Widget g_inventoryGrid = CreateGridView("Gridview", 20, 180, 6, 5, 90, 90, 2, window_2->panel, GridView_DEFAULT); g_inventoryGrid->AddGridItem(GridItem::CreateGridItem("Wood", "Images/wood.jpg", GRID_ITEM_TEXT_NO_BG)); g_inventoryGrid->AddGridItem(GridItem::CreateGridItem("Armor", "Images/armor.jpg")); Way to change the Items void Inventory::UpdateGUI() { g_inventoryGrid->ClearGridItems(); for (auto item : Items) { auto ivItem = InventoryGridItem::CreateInventoryGridItem(item->name, String(item->currentStackSize), item->itemIcon, STYLE_SHOW_PROGRESS_BAR); ivItem->SetProgress(50); g_inventoryGrid->AddGridItem(ivItem); } } Video from the bug https://streamable.com/rb2ypw
  2. The SetRotation() function appears to be malfunctioning, specifically with respect to Yaw and Roll, as both exhibit the same behavior. The issue is reproducible in the provided test project. https://1drv.ms/u/s!Aum5gwXzTrOyvz-rIJLpnkP0df9H?e=QhlFHn also within the editor it has the same effect https://streamable.com/36r9fr and second video https://streamable.com/k0yz0t
  3. It's more about being able to save, for instance, only the UI panels and then retrieve all other necessary objects from this single panel. While it's technically possible to store all variables in a global header, managing multiple variables for changes could become overwhelming. The idea is to streamline and minimize the number of global variables for improved organization and simplicity.
  4. Hello based on the Discord conversation, I suggest modifying the FindChild function by recommending the use of a name variable instead of the text variable. The reason behind this suggestion is straightforward: Imagine you have a panel with 5 labels, and you want to change the texts of these labels. To achieve this, you would need to store all five labels individually, as using FindChild with the text variable might not work accurately when the text is modified. Additionally, the name variable typically remains unchanged, enhancing the reliability and simplicity of locating and modifying labels in a panel.
  5. I had already created a similar window handler for Leadwerks in a previous project. As I'm currently importing my project into the new engine, I thought it was time to refine this functionality. But what exactly can the Window Handler do? As the name suggests, it manages multiple "UI Windows" so that only one is displayed at a time. This is particularly useful when working with different windows for the UI, such as one for inventory, another for a crafting menu, and yet another for dialog options, etc. The Window Handler prevents multiple windows from being open simultaneously, as it closes all others before opening a new one. How does the Window Handler work? The functionality is kept simple: You create a new variable of type UIWindowHandler and generate your "UI Windows" using the UIWindow class, which you then add to the UIWindowHandler. The UIWindow class automatically creates the desired panels. By using `window_manager->ShowWindow("window_1");`, for example, you can open a specific window. In my project, I've added the UIWindowHandler to a global header so that my components can access it. UIWindowHandler.h #pragma once #include "UltraEngine.h" #include "UIWindow.h" using namespace UltraEngine; using namespace std; class UIWindowHandler { public: vector<UIWindow*> windows; UIWindowHandler(); void AddWindow(UIWindow* window); void CloseAllWindows(); void ShowWindow(UIWindow* window); void ShowWindow(string widnowName); }; UIWindowHandler.cpp #include "UltraEngine.h" #include "UIWindowHandler.h" UIWindowHandler::UIWindowHandler() { } void UIWindowHandler::AddWindow(UIWindow* window) { this->windows.push_back(window); } void UIWindowHandler::CloseAllWindows() { for (auto window : this->windows) { window->CloseWindow(); } } void UIWindowHandler::ShowWindow(UIWindow* window) { this->CloseAllWindows(); window->ShowWindow(); } void UIWindowHandler::ShowWindow(string widnowName) { this->CloseAllWindows(); for (auto window : this->windows) { if (window->name == widnowName) { window->ShowWindow(); } } } UIWindow.h #pragma once #include "UltraEngine.h" using namespace UltraEngine; class UIWindow { private: shared_ptr<Interface> ui; public: string name; shared_ptr<Widget> panel; UIWindow(string name, shared_ptr<Interface> ui); UIWindow(string name, float x, float y, float width, float height, shared_ptr<Interface> ui); bool IsHidden(); void CloseWindow(); void ShowWindow(); }; UIWindow.cpp #include "UltraEngine.h" #include "UIWindow.h" UIWindow::UIWindow(string name, shared_ptr<Interface> ui) { this->name = name; this->ui = ui; this->panel = CreatePanel(0, 0, 128, 128, ui->root); } UIWindow::UIWindow(string name, float x, float y, float width, float height, shared_ptr<Interface> ui) { this->name = name; this->ui = ui; this->panel = CreatePanel(x, y, width, height, ui->root); } bool UIWindow::IsHidden() { if (this->panel != nullptr) { if (this->panel->GetHidden()) { return true; } } return false; } void UIWindow::CloseWindow() { this->panel->SetHidden(true); } void UIWindow::ShowWindow() { this->panel->SetHidden(false); }
  6. well this sound not intended i dont think a nav mesh needs 64GB Memmory
  7. Yeah, it will not work within the game it self. You can test it within the project i uploaded a few days ago. Even if you scale the coded version bigger then 8x8 it will not work anymore.
  8. Currently its not possible to create nav meshes wich are bigger then 8x8 cells.
  9. ok thats is it. I post the code in case some else in the future has a need of it. #include "UltraEngine.h" #include "ComponentSystem.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { RegisterComponents(); auto cl = ParseCommandLine(argc, argv); //Load FreeImage plugin (optional) auto fiplugin = LoadPlugin("Plugins/FITextureLoader"); //Get the displays auto displays = GetDisplays(); //Create a window auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR); //Create a world auto world = CreateWorld(); //Create a framebuffer auto framebuffer = CreateFramebuffer(window); //Create widget //auto label1 = CreateLabel("Label", 20, 20, 120, 30, ui->root); //auto label2 = CreateLabel("Border Label", 20, 50, 120, 30, ui->root, LABEL_BORDER | LABEL_CENTER | LABEL_MIDDLE); //Load the map WString mapname = "Maps/TestScene.ultra"; if (cl["map"].is_string()) mapname = std::string(cl["map"]); auto scene = LoadMap(world, mapname); // UI auto font = LoadFont("Fonts/arial.ttf"); auto ui = CreateInterface(world, font, framebuffer->size); ui->root->SetColor(0, 0, 0, 0); ui->SetRenderLayers(2); iVec2 sz = ui->root->ClientSize(); auto button = CreateButton("Button", sz.x / 2 - 75, sz.y / 2 - 15, 150, 30, ui->root); auto camera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC); camera->SetPosition(float(framebuffer->size.x) * 0.5f, float(framebuffer->size.y) * 0.5f, 0); camera->SetRenderLayers(2); camera->SetClearMode(CLEAR_DEPTH); //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { while (PeekEvent()) { const Event ev = WaitEvent(); switch (ev.id) { case EVENT_WINDOWCLOSE: if (ev.source == window) { return 0; } break; default: ui->ProcessEvent(ev); break; } } world->Update(); world->Render(framebuffer); } return 0; }
  10. I tested it with the color set to 0 but then i have the following result here is my code #include "UltraEngine.h" #include "ComponentSystem.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { RegisterComponents(); auto cl = ParseCommandLine(argc, argv); //Load FreeImage plugin (optional) auto fiplugin = LoadPlugin("Plugins/FITextureLoader"); //Get the displays auto displays = GetDisplays(); //Create a window auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR); //Create a world auto world = CreateWorld(); //Create a framebuffer auto framebuffer = CreateFramebuffer(window); //Create widget //auto label1 = CreateLabel("Label", 20, 20, 120, 30, ui->root); //auto label2 = CreateLabel("Border Label", 20, 50, 120, 30, ui->root, LABEL_BORDER | LABEL_CENTER | LABEL_MIDDLE); //Load the map WString mapname = "Maps/TestScene.ultra"; if (cl["map"].is_string()) mapname = std::string(cl["map"]); auto scene = LoadMap(world, mapname); auto font = LoadFont("Fonts/arial.ttf"); auto ui = CreateInterface(world, font, framebuffer->size); ui->root->SetColor(0, 0, 0, 0); ui->SetRenderLayers(2); iVec2 sz = ui->root->ClientSize(); auto button = CreateButton("Button", sz.x / 2 - 75, sz.y / 2 - 15, 150, 30, ui->root); auto camera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC); camera->SetPosition(float(framebuffer->size.x) * 0.5f, float(framebuffer->size.y) * 0.5f, 0); camera->SetRenderLayers(2); //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { while (PeekEvent()) { const Event ev = WaitEvent(); switch (ev.id) { case EVENT_WINDOWCLOSE: if (ev.source == window) { return 0; } break; default: ui->ProcessEvent(ev); break; } } world->Update(); world->Render(framebuffer); } return 0; }
  11. ok now it was working. But i cant see the game anymore. my goal was to make a smal "window" or panel.
  12. ok i changed my code to this #include "UltraEngine.h" #include "ComponentSystem.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { RegisterComponents(); auto cl = ParseCommandLine(argc, argv); //Load FreeImage plugin (optional) auto fiplugin = LoadPlugin("Plugins/FITextureLoader"); //Get the displays auto displays = GetDisplays(); //Create a window auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR); //Create a world auto world = CreateWorld(); //Create a framebuffer auto framebuffer = CreateFramebuffer(window); auto font = LoadFont("Fonts/arial.ttf"); auto ui = CreateInterface(world, font, framebuffer->size); iVec2 sz = ui->root->ClientSize(); auto button = CreateButton("Button", sz.x / 2 - 75, sz.y / 2 - 15, 150, 30, ui->root); //Create widget //auto label1 = CreateLabel("Label", 20, 20, 120, 30, ui->root); //auto label2 = CreateLabel("Border Label", 20, 50, 120, 30, ui->root, LABEL_BORDER | LABEL_CENTER | LABEL_MIDDLE); //Load the map WString mapname = "Maps/TestScene.ultra"; if (cl["map"].is_string()) mapname = std::string(cl["map"]); auto scene = LoadMap(world, mapname); //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { while (PeekEvent()) { const Event ev = WaitEvent(); switch (ev.id) { case EVENT_WINDOWCLOSE: if (ev.source == window) { return 0; } break; default: ui->ProcessEvent(ev); break; } } world->Update(); world->Render(framebuffer); } return 0; } and get this result
  13. Hello Guys i try to create an ui but it wont show anything. I think i missed something. This is my main.cpp code #include "UltraEngine.h" #include "ComponentSystem.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { RegisterComponents(); auto cl = ParseCommandLine(argc, argv); //Load FreeImage plugin (optional) auto fiplugin = LoadPlugin("Plugins/FITextureLoader"); //Get the displays auto displays = GetDisplays(); //Create a window auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR); auto ui = CreateInterface(window); //Create widget auto label1 = CreateLabel("Label", 20, 20, 120, 30, ui->root); auto label2 = CreateLabel("Border Label", 20, 50, 120, 30, ui->root, LABEL_BORDER | LABEL_CENTER | LABEL_MIDDLE); //Create a world auto world = CreateWorld(); //Create a framebuffer auto framebuffer = CreateFramebuffer(window); //Load the map WString mapname = "Maps/TestScene.ultra"; if (cl["map"].is_string()) mapname = std::string(cl["map"]); auto scene = LoadMap(world, mapname); //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { world->Update(); world->Render(framebuffer); } return 0; }
  14. the most of them yeah but i stard to rebuild the game with ultra allready. Since the most models are anyway pbr based. Right now im waiting also for the vegitation and the water within ultra.
  15. This component generates a Mouse Movement Controller featuring a free-look mode. Typically, such character controllers find application in ARPG (Action Role-Playing Game) or RTS (Real-Time Strategy) games. In this setup, you observe the character from a top-down perspective and direct their movement to a specified position by clicking the left mouse button. The Component itself need the terrain name and the name for the walk animation. Also your character needs an idle animation. You can switch into the "free look mode" by pressing the tab key. Within the "free look mode" you are able to move the camera with "W" "A" "S" "D" free around. If you press tab again you switch the mode back to the character. 1. C++ Header #pragma once #include "UltraEngine.h" #include "GatherWaterTask.h" using namespace UltraEngine; class MouseMovementController : public Component { private: shared_ptr<Map> scene; shared_ptr<NavMesh> nav_mesh; bool freeLook = false; public: string terrainName; string animationName; Vec3 destination; shared_ptr<NavAgent> agent; shared_ptr<Terrain> terrain; shared_ptr<Camera> camera; MouseMovementController(); void Start(); void Update(); bool Load(table& properties, shared_ptr<Stream> binstream, shared_ptr<Map> scene, const LoadFlags flags); bool Save(table& properties, shared_ptr<Stream> binstream, shared_ptr<Map> scene, const SaveFlags flags); shared_ptr<Component> Copy(); }; 2. C++ Source File #include "UltraEngine.h" #include "MouseMovementController.h" MouseMovementController::MouseMovementController() { this->name = "MouseMovementController"; } /// <summary> /// Setup the Controller /// </summary> void MouseMovementController::Start() { auto entity = GetEntity(); ///Create the camera and attach them to the player character this->camera = CreateCamera(entity->GetWorld()); Vec3 currentcameraposition = TransformPoint(0, 15, 5, entity, nullptr); //this->camera->SetParent(entity); this->camera->SetPosition(currentcameraposition, true); this->camera->SetRotation(Vec3(45, 0, 0)); this->camera->SetFov(40); this->camera->Point(entity); ///Creates a navmesh ToDo: Has to changed when the NavMesh bug is fixed this->nav_mesh = CreateNavMesh(entity->GetWorld(), 5, 8, 8); this->nav_mesh->SetPosition(0, 0, 0); this->nav_mesh->Build(); ///Create a new NavAgent for the player character this->agent = CreateNavAgent(this->nav_mesh); entity->Attach(agent); } //Update method, called once per loop void MouseMovementController::Update() { auto entity = GetEntity(); auto window = ActiveWindow(); auto world = entity->GetWorld(); if (window) { ///Set the destination if the player hits the left mouse button if (window->MouseHit(MOUSE_LEFT)) { auto mousePosition = window->GetMousePosition(); auto pick = this->camera->Pick(window->GetFramebuffer(), mousePosition.x, mousePosition.y, 0, true); if (pick.success) { auto pos = pick.position; if (pick.entity->name == this->terrainName) { this->destination = pos; } } } ///Move to the destination if the destination is not null if (this->destination != NULL) { if (entity->position.DistanceToPoint(this->destination) > 1.0f) { this->agent->Navigate(this->destination); auto model = entity->As<Model>(); model->Animate(this->animationName); } else { this->agent->Stop(); auto model = entity->As<Model>(); model->Animate("idle"); this->destination == NULL; } } ///Toggle the freelook mode if (window->KeyHit(KEY_TAB)) { if (this->freeLook) { this->freeLook = false; } else { this->freeLook = true; Vec3 currentcameraposition = TransformPoint(0, 15, 0, GetEntity(), nullptr); this->camera->SetPosition(currentcameraposition, true); this->camera->SetRotation(Vec3(90, 0, 0)); } } ///Position the camera according to the selected mode if (!this->freeLook) { Vec3 currentcameraposition = TransformPoint(0, 15, 5, GetEntity(), nullptr); this->camera->SetPosition(currentcameraposition, true); this->camera->Point(entity); } else { Vec3 camPos = this->camera->GetPosition(); if (window->KeyDown(KEY_W)) { camPos.z += 0.5f; } else if (window->KeyDown(KEY_S)) { camPos.z -= 0.5f; } else if (window->KeyDown(KEY_A)) { camPos.x -= 0.5f; } else if (window->KeyDown(KEY_D)) { camPos.x += 0.5f; } this->camera->SetPosition(camPos); } } } bool MouseMovementController::Load(table& properties, shared_ptr<Stream> binstream, shared_ptr<Map> scene, const LoadFlags flags) { this->scene = scene; this->terrainName = (String)properties["terrainName"]; this->animationName = (String)properties["animationName"]; for (auto e : scene->entities) { if (e->name == terrainName) { this->terrain = std::static_pointer_cast<Terrain>(e); } } return true; } bool MouseMovementController::Save(table& properties, shared_ptr<Stream> binstream, shared_ptr<Map> scene, const SaveFlags flags) { properties["terrainName"] = (String)terrain->name; properties["animationName"] = (String)this->animationName; return true; } shared_ptr<Component> MouseMovementController::Copy() { return std::make_shared<MouseMovementController>(*this); } 3. JSON File { "component": { "properties": [ { "name": "terrainName", "label": "Terrain Name", "value": "" }, { "name": "animationName", "label": "Animation Name", "value": "" } ] } }
  16. Drag & Drop a folder with models would be awesome. So you dont need to open the folder within the explorer. For object creation you could add it where the center of the viewport or camera currently is. So the user just clicks within the menu entry and it get placed automaticly. Also an Gizmo for the moving would be nice
  17. Omg you are right...it has to be the entity from the pick not the entity from the Mouse Controller thanks alot. ---- but if you have the project all ready you could have a look to the navmesh. The offset from the player character and the building from a bigger navmesh.
  18. Ok its uploaded. You can find it here: https://1drv.ms/u/s!Aum5gwXzTrOyvzFp9Q_eF9_0AiZl?e=77digt ----- You need to run the solution and then when the game is loaded left klick on the water well.
  19. Ok the last error i managed to fix with geting back to header and source files. Back to the problem with the nullptr
  20. More wired things happend. I changed the header to an hpp and removed the c++ source file. After this its not possible anymore to access the other component. The compiler says that "MouseMovementController" is not declarated but i includet the header file for this.... #pragma once #pragma once #include "UltraEngine.h" #include "MouseMovementController.hpp" using namespace UltraEngine; class CollectWaterTask : public Component { public: shared_ptr<Entity> entity; shared_ptr<Entity> player; shared_ptr<Map> scene; string description; string title; long duration; long cooldown; bool taskStarted; CollectWaterTask() { this->name = "CollectWaterTask"; } virtual void Start() { this->entity = GetEntity(); for (auto e : this->scene->entities) { auto controller = e->GetComponent<MouseMovementController>(); if (controller != NULL) { this->player = e; break; } } } virtual void Update() { } virtual void OnTaskStart(shared_ptr<Entity> source, shared_ptr<Entity> dest, shared_ptr<CollectWaterTask> task) { auto controler = source->GetComponent<MouseMovementController>(); controler->destination = dest->GetPosition(); this->taskStarted = true; // here this is null } virtual void OnTaskEnd() { } virtual bool Load(table& properties, shared_ptr<Stream> binstream, shared_ptr<Map> scene, const LoadFlags flags) { this->scene = scene; this->title = properties["title"]; this->description = properties["description"]; return true; } virtual bool Save(table& properties, shared_ptr<Stream> binstream, shared_ptr<Map> scene, const SaveFlags flags) { properties["title"] = this->title; properties["description"] = this->description; return true; } virtual shared_ptr<Component> Copy() { return std::make_shared<CollectWaterTask>(*this); } };
  21. i allready tryed this as well. Same problemm
  22. Here is my class. Header #pragma once #include "UltraEngine.h" #include "MouseMovementController.h" using namespace UltraEngine; class GatherWaterTask : public Component { private: shared_ptr<Entity> entity; public: string description; string title; long duration; long cooldown; bool taskStarted; GatherWaterTask(); void OnTaskStart(shared_ptr<Entity> source, shared_ptr<Entity> dest, shared_ptr<GatherWaterTask> task); void OnTaskEnd(); virtual void Start(); virtual void Update(); virtual bool Load(table& properties, shared_ptr<Stream> binstream, shared_ptr<Map> scene, const LoadFlags flags); virtual bool Save(table& properties, shared_ptr<Stream> binstream, shared_ptr<Map> scene, const SaveFlags flags); virtual shared_ptr<Component> Copy(); }; Source #include "UltraEngine.h" #include "GatherWaterTask.h" using namespace UltraEngine; GatherWaterTask::GatherWaterTask() { this->name = "GatherWaterTask"; // here this works } void GatherWaterTask::Start() { this->entity = GetEntity(); } void GatherWaterTask::Update() { } void GatherWaterTask::OnTaskStart(shared_ptr<Entity> source, shared_ptr<Entity> dest, shared_ptr<GatherWaterTask> task) { Print("Task Started!"); auto controler = source->GetComponent<MouseMovementController>(); controler->destination = dest->GetPosition(); this->taskStarted = true; // here this is null } void GatherWaterTask::OnTaskEnd() { } bool GatherWaterTask::Load(table& properties, shared_ptr<Stream> binstream, shared_ptr<Map> scene, const LoadFlags flags) { this->title = properties["title"]; this->description = properties["description"]; return true; } bool GatherWaterTask::Save(table& properties, shared_ptr<Stream> binstream, shared_ptr<Map> scene, const SaveFlags flags) { properties["title"] = this->title; properties["description"] = this->description; return true; } shared_ptr<Component> GatherWaterTask::Copy() { return std::make_shared<GatherWaterTask>(*this); }
  23. Same error. Well im kinda confused. Normaly it should work or ?
  24. Hello, i have 2 components wich work together. So within 1 component i check some cases if they are true i call a function within a second component. When i call the function everything is fine but when i try to use this i get an nullptr exception. Here are my 2 codes Component 1 else if (!pick.entity->tags.empty()) { for (auto tag : pick.entity->tags) { if (tag == "gather_water_task") { auto task = entity->GetComponent<GatherWaterTask>(); task->OnTaskStart(entity, pick.entity, task); break; } } } Component 2 void GatherWaterTask::OnTaskStart(shared_ptr<Entity> source, shared_ptr<Entity> dest, shared_ptr<GatherWaterTask> task) { Print("Task Started!"); auto controler = source->GetComponent<MouseMovementController>(); controler->destination = dest->GetPosition(); this->taskStarted = true; } and the error does anyone has an idee why this happens?
×
×
  • Create New...