SpiderPig Posted February 5, 2023 Posted February 5, 2023 The bounds are returning 0 size for some objects I'm loading. I think its when there are two or more entities in the file. Here cube1 shows the correct bounds size but cube2 (has two cubes in it) returns 0. #include "Engine.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { auto displays = GetDisplays(); auto window = CreateWindow("Ultra Engine", 0, 0, 800, 600, displays[0]); auto world = CreateWorld(); auto framebuffer = CreateFramebuffer(window); auto camera = CreateCamera(world); camera->SetClearColor(0.0f, 0.0f, 1.0f); camera->SetFov(70); camera->SetRange(0.01f, 1000.0f); camera->SetPosition(0, 1, -3); auto light = CreateDirectionalLight(world); light->SetColor(5.0f); light->SetRotation(35, 45, 0); auto font = LoadFont("Fonts/arial.ttf"); auto ui = CreateInterface(world, font, framebuffer->size); ui->SetRenderLayers(2); ui->root->SetColor(0, 0, 0, 0); auto ui_cam = CreateCamera(world, PROJECTION_ORTHOGRAPHIC); ui_cam->SetPosition(framebuffer->size.x / 2, framebuffer->size.y / 2, 0); ui_cam->SetRenderLayers(2); ui_cam->SetClearMode(CLEAR_DEPTH); auto label = CreateLabel("", 10, 10, 200, 30, ui->root); auto cube1 = LoadModel(world, "Cube.gltf"); auto cube2 = LoadModel(world, "Cube2.gltf"); auto b1 = cube1->GetBounds(); auto b2 = cube2->GetBounds(); while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { label->SetText("Size1 : " + String(b1.size.x) + ", " + String(b1.size.y) + ", " + String(b1.size.z) + "\n" "Size2 : " + String(b2.size.x) + ", " + String(b2.size.y) + ", " + String(b2.size.z)); world->Update(); world->Render(framebuffer, false); } return 0; } Cubes.zip Quote
Solution Josh Posted February 5, 2023 Solution Posted February 5, 2023 Without looking at it, I am guessing box2 has a node at the top of the hierarchy with no geometry, so it's just a point. You can get the recursive bounds and that will include all the children. 1 Quote Let's build cool stuff and have fun.
SpiderPig Posted February 5, 2023 Author Posted February 5, 2023 Ah yes. That did the trick. GetBounds(BOUNDS_RECURSIVE) 1 Quote
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.