Jump to content

Andy90

Members
  • Posts

    189
  • Joined

  • Last visited

Everything posted by Andy90

  1. well this sound not intended i dont think a nav mesh needs 64GB Memmory
  2. 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.
  3. Currently its not possible to create nav meshes wich are bigger then 8x8 cells.
  4. 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; }
  5. 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; }
  6. ok now it was working. But i cant see the game anymore. my goal was to make a smal "window" or panel.
  7. 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
  8. 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; }
  9. 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.
  10. 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": "" } ] } }
  11. 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
  12. 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.
  13. 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.
  14. Ok the last error i managed to fix with geting back to header and source files. Back to the problem with the nullptr
  15. 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); } };
  16. i allready tryed this as well. Same problemm
  17. 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); }
  18. Same error. Well im kinda confused. Normaly it should work or ?
  19. 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?
  20. For some reasons its also not possible to create a NavMesh wich is a bit bigger. I try it with this->nav_mesh = CreateNavMesh(entity->GetWorld(), 5, 16, 16); this->nav_mesh->SetPosition(0, 0, 0); this->nav_mesh->Build(); and get the following result Error: dtNavMesh::addTile failed it Prints this output multiple times. If i do the NavMesh with 8x8 its fine.
  21. Andy90

    Navmesh in-editor

    How to access them within an component ?
  22. After a long break due to illness and work, I have now started to create an old power plant.
  23. Sorry for the delayed response. I usually aim to release dev diaries on a weekly schedule, but I've been unwell for the past few days. The next dev diary will be released this Sunday.
  24. Well when it comes to multiplayer you can create a own service. Since you can use c++ scripts. And you can also do some bigger projects if you have a look at my project. I think @Josh is creating guides for FPS games because its more easy for beginners.
×
×
  • Create New...