Dreikblack Posted May 22, 2023 Share Posted May 22, 2023 NavMesh can't be seen (with setDebuggint(true)) or used if you use brushes as a scene instead of models. #include "UltraEngine.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { //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 framebuffer auto framebuffer = CreateFramebuffer(window); //Create a world auto world = CreateWorld(); //Create a camera auto camera = CreateCamera(world); camera->SetFov(70); camera->SetClearColor(0.125); camera->SetPosition(0, 3, -6); camera->SetRotation(35, 0, 0); //Create light auto light = CreateBoxLight(world); light->SetRange(-20, 20); light->SetArea(20, 20); light->SetRotation(35, 35, 0); light->SetColor(3); //Create scene //auto ground = CreateBox(world, 10, 1, 10); //ground->SetPosition(0, -0.5, 0); //ground->SetColor(0, 1, 0); //auto wall = CreateBox(world, 1, 2, 4); float w = 10, h = 1, d = 10; auto brush = CreateBrush(world); //Add brush vertices brush->AddVertex(w * 0.5, 0, d * 0.5); brush->AddVertex(-w * 0.5, 0, d * 0.5); brush->AddVertex(-w * 0.5, 0, -d * 0.5); brush->AddVertex(w * 0.5, 0, -d * 0.5); brush->AddVertex(w * 0.5, -h, d * 0.5); brush->AddVertex(-w * 0.5, -h, d * 0.5); brush->AddVertex(-w * 0.5, -h, -d * 0.5); brush->AddVertex(w * 0.5, -h, -d * 0.5); //Add faces auto face = brush->AddFace(); face->AddIndice(0); face->AddIndice(1); face->AddIndice(2); face->AddIndice(3); face = brush->AddFace(); face->AddIndice(4); face->AddIndice(5); face->AddIndice(6); face->AddIndice(7); face = brush->AddFace(); face->AddIndice(0); face->AddIndice(1); face->AddIndice(5); face->AddIndice(4); face = brush->AddFace(); face->AddIndice(2); face->AddIndice(3); face->AddIndice(7); face->AddIndice(6); face = brush->AddFace(); face->AddIndice(1); face->AddIndice(2); face->AddIndice(6); face->AddIndice(5); face = brush->AddFace(); face->AddIndice(0); face->AddIndice(3); face->AddIndice(7); face->AddIndice(4); brush->Build(); //Create navmesh auto navmesh = CreateNavMesh(world, 10, 5, 10, 4, 4); navmesh->SetDebugging(true); navmesh->Build(); //Create player auto player = CreateCylinder(world, 0.4, 1.8); player->SetColor(0, 0, 1); auto agent = CreateNavAgent(navmesh); player->Attach(agent); //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { if (window->MouseHit(MOUSE_LEFT)) { auto mousepos = window->GetMousePosition(); auto rayinfo = camera->Pick(framebuffer, mousepos.x, mousepos.y); if (rayinfo.success) { agent->Navigate(rayinfo.position); } } world->Update(); world->Render(framebuffer); } return 0; } 1 Quote Link to comment Share on other sites More sharing options...
Josh Posted July 20, 2023 Share Posted July 20, 2023 Currently it seems to not work at all: #include "UltraEngine.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { //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 framebuffer auto framebuffer = CreateFramebuffer(window); //Create a world auto world = CreateWorld(); //Create a camera auto camera = CreateCamera(world); camera->SetFov(70); camera->SetClearColor(0.125); camera->SetPosition(0, 3, -6); camera->SetRotation(35, 0, 0); //Create light auto light = CreateBoxLight(world); light->SetRange(-20, 20); light->SetArea(20, 20); light->SetRotation(35, 35, 0); light->SetColor(3); //Create scene auto ground = CreateBox(world, 10, 1, 10); ground->SetPosition(0, -0.5, 0); ground->SetColor(0, 1, 0); auto wall = CreateBox(world, 1, 2, 4); wall->SetPosition(3, 0, 0); //Create navmesh auto navmesh = CreateNavMesh(world, 10, 5, 10, 4, 4); navmesh->SetDebugging(true); navmesh->Build(); //Create player auto player = CreateCylinder(world, 0.4, 1.8); player->SetColor(0, 0, 1); auto agent = CreateNavAgent(navmesh); player->Attach(agent); //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { if (window->MouseHit(MOUSE_LEFT)) { auto mousepos = window->GetMousePosition(); auto rayinfo = camera->Pick(framebuffer, mousepos.x, mousepos.y); if (rayinfo.success) { agent->Navigate(rayinfo.position); } } world->Update(); world->Render(framebuffer); } return 0; } Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Solution Josh Posted July 20, 2023 Solution Share Posted July 20, 2023 Okay, this will be fixed in the next update. It will be important to disable navigation on the player itself because mesh primitives are now being created with a collider added: player->SetNavObstacle(false); Scratch that, I added a check so if an entity is attached to an entity it will not contribute geometry into the navigation mesh. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.