Jump to content

Bounds not calculating


SpiderPig
 Share

Go to solution Solved by Josh,

Recommended Posts

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

Link to comment
Share on other sites

  • Solution

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.

  • Thanks 1

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

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...