Jump to content

SpiderPig

Members
  • Posts

    2,411
  • Joined

  • Last visited

Posts posted by SpiderPig

  1. I think I've narrowed down a problem I've been having with the GUI call-backs.  The child seems to be blocking a lot of the events to its parent.  If the child is smaller than the parent it receives more events but I don't think it gets all of them, hard to tell.

    #include "UltraEngine.h"
    #include "ComponentSystem.h"
    
    using namespace UltraEngine;
    
    bool EventCallback(const Event& event, shared_ptr<Object> extra) {
        switch (event.id) {
        case EVENT_MOUSEENTER:
            Print("MOUSE_ENTER");
            break;
        case EVENT_MOUSELEAVE:
            Print("MOUSE_LEAVE");
            break;
        case EVENT_MOUSEDOWN:
            Print("MOUSE_DOWN");
            break;
        case EVENT_MOUSEMOVE:
            Print("MOUSE_MOVE");
            break;
        case EVENT_MOUSEUP:
            Print("MOUSE_UP");
            break;
        case EVENT_MOUSEWHEEL:
            Print("MOUSE_WHEEL");
            break;
        }
    
        return true;
    }
    
    int main(int argc, const char* argv[])
    {
        auto displays = GetDisplays();
        auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);
        auto world = CreateWorld();
        auto framebuffer = CreateFramebuffer(window);
    
        auto camera = CreateCamera(world);
        camera->SetClearColor(0.125);
        camera->SetFov(70);
        camera->SetPosition(0, 0, -3);
    
        auto font = LoadFont("Fonts\\arial.ttf");
        auto ui = CreateInterface(world, font, framebuffer->size);
        ui->SetRenderLayers(2);
        ui->root->SetColor(0.0f, 0.0f, 0.0f, 0.0f);
    
        auto ui_camera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC);
        ui_camera->SetPosition((float)framebuffer->size.x * 0.5f, (float)framebuffer->size.y * 0.5f, 0);
        ui_camera->SetRenderLayers(2);
        ui_camera->SetClearMode(CLEAR_DEPTH);
    
        auto light = CreateBoxLight(world);
        light->SetRotation(35, 45, 0);
        light->SetRange(-10, 10);
    
        auto box = CreateBox(world);
        box->SetColor(0, 0, 1);
    
        auto actor = CreateActor(box);
        auto component = actor->AddComponent<Mover>();
        component->rotation.y = 45;
    
        auto w0 = CreatePanel(10, 10, 128, 128, ui->root);
        auto w1 = CreatePanel(10, 10, 128, 128, w0);
        w1->SetColor(1, 0, 0);
    
    
        ListenEvent(EVENT_NONE, w0, EventCallback);
    
        while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
        {
            while (PeekEvent()) {
                auto event = WaitEvent();
                ui->ProcessEvent(event);
            }
    
            world->Update();
            world->Render(framebuffer);
        }
        return 0;
    }

     

  2. GetBonePosition(true) is not returning the global position of the bone.  It's not taking into account the model scale and I don't think the rotation either...

    bone_pos = TransformPoint(bone_pos, Mat4(), model->GetMatrix().Inverse());

    EDIT : Yeah, it's just not being transformed.

  3. If you could at least initialize the order variable and keep it public I can do the rest.  Maybe make it a const so we can't edit?  Do you think there might be issues involved in moving sprites between widgets other than z-fighting?

  4. 1 minute ago, Josh said:

    Is the background a panel? Maybe it should be a sprite so you can control the depth?

    Possibly could... however I've got that panel parented to a tabber and it's texture is from a camera.  Then the head panel is parented to that panel.

    • Haha 1
  5. Panel pixmaps are working but they do not seem to be responding to alpha.  Also this example now shows that if the panel is smaller than the pixmap the border doesn't match up.

    #include "UltraEngine.h"
    #include "ComponentSystem.h"
    
    using namespace UltraEngine;
    
    int main(int argc, const char* argv[])
    {
        auto displays = GetDisplays();
        auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);
        auto world = CreateWorld();
        auto framebuffer = CreateFramebuffer(window);
    
        auto camera = CreateCamera(world);
        camera->SetClearColor(0.125);
        camera->SetFov(70);
        camera->SetPosition(0, 0, -3);
    
        auto font = LoadFont("Fonts\\arial.ttf");
        auto ui = CreateInterface(world, font, framebuffer->size);
        ui->SetRenderLayers(2);
        ui->root->SetColor(0.0f, 0.0f, 0.0f, 0.0f);
    
        auto ui_camera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC);
        ui_camera->SetPosition((float)framebuffer->size.x * 0.5f, (float)framebuffer->size.y * 0.5f, 0);
        ui_camera->SetRenderLayers(2);
        ui_camera->SetClearMode(CLEAR_DEPTH);
    
        auto light = CreateBoxLight(world);
        light->SetRotation(35, 45, 0);
        light->SetRange(-10, 10);
    
        auto box = CreateBox(world);
        box->SetColor(0, 0, 1);
    
        auto actor = CreateActor(box);
        auto component = actor->AddComponent<Mover>();
        component->rotation.y = 45;
    
        auto widget = CreatePanel(600, 350, 64, 64, ui->root, PANEL_BORDER);
        widget->SetColor(1.0f, 1.0f, 1.0f, 0.25f);
        widget->SetPixmap(LoadPixmap("Background.dds"));
    
        while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
        {
            world->Update();
            world->Render(framebuffer);
        }
        return 0;
    }

    Background.zip

  6. I'd like to set it between two panels like so:

    Depth.png.5253dbf3cfb7eb2bb2aacc7ba3d5a742.png

    In this case I tried random values until it worked, just to see if it would.

    float GetDepth() {
    	return 0.999f - float(102) / 10000.0f;
    }

     

    5 minutes ago, Josh said:

    It's probably an uninitialized value that hasn't been set yet. That should really be made a private member.

    If you could make some way of getting it's depth or order that would be great.  Maybe a widget could have the above function implemented? Taking a block index maybe?

    • Sad 1
  7. 7 hours ago, Josh said:

    Yeah, just nudge it forward away from the camera:

    line->SetPosition(line->position + Vec3(0,0,0.1));

    Is each widget created at its own z depth?  I'm wondering if it would be better to do something like this:

    line->SetPosition(line->position.x, line_position.y, panel_position.z + 0.1f);

    I can get the depth of a sprite (position.z) but I don't think I can get the depth of a widget...

  8. 7 hours ago, Josh said:

    Update

    • Fixed serious bug in thread manager that could have affected all system, physics, rendering, culling, etc. The wrong mutex was being locked when commands were added to the thread command buffer. 😱
    • Number of maximum GUI widgets visible will probably be about 20,000 now

    So this was the cause of the random crashes?

  9. 34 minutes ago, Josh said:

    No, in the GUI system everything is right angles. I thought about adding lines and Bezier curves in a future update.

    I manged to use a sprite for now.  Looks okay but maybe AnitAliasing will help with this when it's ready.  Can I simply change the depth position of a sprite so it can appear behind a widget?  In this case the line sprite needs to go behind the "head" panel.

    CharacterLines.png.d529abdb4f63c720d77feea8838a72cb.png

  10. I agree, thank you Josh for making a great engine!

     

    30 minutes ago, Josh said:

    Just use the correct camera and the correct render buffer, and everything works out:

    auto screen_pos = cam3->Project(box->position, buffer);

    So I can pass the TextureBuffer object to it? :huh:

    Got it to work, Thankyou.  Should the sprites follow the same position system as the GUI?  I mean 0,0 at the top left?

  11. How should we get the screen position of an object on a texture?  Should the result be scaled down to the size of the texture and then reposition based on the panel position?  I am not sure how to achieve this.

    ProjectIssue.thumb.png.c5cbfffe1c6583ab10926155aed5485b.png

     

    int main(int argc, const char* argv[])
    {
        auto displays = GetDisplays();
        auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);
        auto world = CreateWorld();
        auto framebuffer = CreateFramebuffer(window);
    
        auto camera = CreateCamera(world);
        camera->SetClearColor(0.125);
        camera->SetFov(70);
        camera->SetPosition(0, 2, -3);
    
        auto default_font = LoadFont("Fonts\\arial.ttf");
        auto ui = CreateInterface(world, default_font, framebuffer->size);
        ui->SetRenderLayers(2);
        ui->root->SetColor(0.0f, 0.0f, 0.0f, 0.0f);
    
        auto ui_camera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC);
        ui_camera->SetPosition((float)framebuffer->size.x * 0.5f, (float)framebuffer->size.y * 0.5f, 0);
        ui_camera->SetRenderLayers(2);
        ui_camera->SetClearMode(CLEAR_DEPTH);
    
        auto buffer = CreateTextureBuffer(256, 256);
    
        auto cam3 = CreateCamera(world);
        cam3->SetClearColor(1, 0, 0);
        cam3->SetRenderLayers(4);
        cam3->Move(0, 0, -2);
        cam3->SetRenderTarget(buffer);
    
    
    
        auto w1 = CreatePanel(0, 0, 256, 256, ui->root);
        w1->SetColor(1, 1, 1);
        w1->blocks[0].texture = buffer->GetColorAttachment();
    
        //Create a box
        auto box = CreateBox(world);
        box->SetRenderLayers(1 | 4);
        box->SetColor(0, 0, 1);
    
        //Entity component system
        auto actor = CreateActor(box);
        auto component = actor->AddComponent<Mover>();
        component->rotation.y = 45;
    
        auto sprite = CreateSprite(world, 16, 16);
        sprite->SetRenderLayers(2);
    
        auto text = CreateSprite(world, default_font, "", 12);
        text->SetRenderLayers(2);
    
        vector<shared_ptr<Widget>> widgets;
        widgets.push_back(ui->root);
    
        while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
        {
            while (PeekEvent()) {
                auto event = WaitEvent();
                ui->ProcessEvent(event);
            }
    
            auto screen_pos = cam3->Project(box->GetPosition(true), framebuffer);
            sprite->SetPosition(screen_pos.x, screen_pos.y);
            text->SetText("ScreenPos : " + String(screen_pos.x) + ", " + String(screen_pos.y));
    
            world->Update();
            world->Render(framebuffer);
        }
        return 0;
    }

     

  12. I made this example in an effort to get things to crash but have noted a few other issues in the process.  Please excuses the size the example.

    • No mouse events for tabber or button (disable the panel creating in the loop to see this)
    • Press Space a few times - Red panel clipping exceeds parents size by 1 pixel in both x & y
    • Sprite remains in renderlayer 0.  Solved!  Powers of 2 required.  Only downside to not use the enum ;)
    • Tab page and button left border clipped off
    • Drawing widgets stops at the 2,000 mark?  Excessive I know but is this some sort of limit or bug?
    #include "UltraEngine.h"
    #include "ComponentSystem.h"
    
    using namespace UltraEngine;
    
    bool EventCallback(const Event& event, shared_ptr<Object> extra) {
        switch (event.id) {
        case EVENT_MOUSEENTER:
            Print("MOUSE_ENTER");
            break;
        case EVENT_MOUSELEAVE:
            Print("MOUSE_LEAVE");
            break;
        case EVENT_MOUSEDOWN:
            Print("MOUSE_DOWN");
            break;
        case EVENT_MOUSEMOVE:
            //Print("MOUSE_MOVE");
            break;
        case EVENT_MOUSEUP:
            Print("MOUSE_UP");
            break;
        case EVENT_MOUSEWHEEL:
            Print("MOUSE_WHEEL");
            break;
        }
    
        return true;
    }
    
    int main(int argc, const char* argv[])
    {
        auto displays = GetDisplays();
        auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);
        auto world = CreateWorld();
        auto framebuffer = CreateFramebuffer(window);
    
        auto camera = CreateCamera(world);
        camera->SetClearColor(0.125);
        camera->SetFov(70);
        camera->SetPosition(0, 2, -3);
    
        auto default_font = LoadFont("Fonts\\arial.ttf");
        auto ui = CreateInterface(world, default_font, framebuffer->size);
        ui->SetRenderLayers(1);
        ui->root->SetColor(0.0f, 0.0f, 0.0f, 0.0f);
    
        auto ui_camera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC);
        ui_camera->SetPosition((float)framebuffer->size.x * 0.5f, (float)framebuffer->size.y * 0.5f, 0);
        ui_camera->SetRenderLayers(1);
        ui_camera->SetClearMode(CLEAR_DEPTH);
    
        auto w1 = CreatePanel(0, 0, 1, 1, ui->root);
        ListenEvent(EVENT_NONE, w1, EventCallback);
    
        auto w2 = CreatePanel(0, 0, 1, 1, w1);
        ListenEvent(EVENT_NONE, w2, EventCallback);
        w2->SetColor(1, 0, 0);
    
        auto w3 = CreateTabber(10, 10, 1, 1, ui->root);
        w3->SetShape(25, 25, 256, 256);
        w3->AddItem("Page1");
        w3->AddItem("Page2");
    
        auto w4 = CreateButton("Test", 0, 0, 32, 32, w3);
        w4->SetShape(5, 5, 100, 50);
    
        auto terrain = CreateTerrain(world, 512, 512);
        terrain->SetMaterial(LoadMaterial("Data\\bluegrid.mat"));
    
        auto c = CreateCylinder(world);
        c->SetPhysicsMode(PHYSICS_PLAYER);
    
        vector<shared_ptr<Entity>> entities;
        Vec3 offset = Vec3(10.0f, 1.0f, 5.0f);
        float scale = 2.0f;
        for (int z = 0; z < 10; z++) {
            for (int x = 0; x < 10; x++) {
                auto e = CreateSphere(world);
                e->SetColor(Random(), Random(), Random());
                e->SetPosition(Vec3((float)x * scale + Random() - 0.5f, 0.0f, (float)z * scale + Random() - 0.5f) + offset, true);
                e->SetMass(1.0f);
                entities.push_back(e);
            }
        }
    
        auto sprite = CreateSprite(world, default_font, "", 12);
        sprite->SetRenderLayers(1);//Still on layer 0?
        
    
        vector<shared_ptr<Widget>> widgets;
        widgets.push_back(ui->root);
    
        while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
        {
            if (window->KeyHit(KEY_SPACE)) {
                w1->SetShape(Random(0, 512), Random(0, 512), Random(64, 128), Random(64, 128));
                w2->SetShape(Random(0, 10), Random(0, 10), Random(16, 128), Random(16, 32));
            }
    
            auto w = CreatePanel(Random(0, 512), Random(0, 512), Random(64, 128), Random(64, 128), ui->root);// widgets[(int)Random(0.0f, (float)widgets.size() - 0.1f)]);
            w->SetColor(Random(), Random(), Random());
            ListenEvent(EVENT_NONE, w, EventCallback);
            widgets.push_back(w);
    
            sprite->SetText(String(widgets.size()));
    
            while (PeekEvent()) {
                auto event = WaitEvent();
                ui->ProcessEvent(event);
            }
    
            world->Update();
            world->Render(framebuffer);
        }
        return 0;
    }

     

  13. 3 hours ago, Josh said:

    This indicates a serious problem, but I am unable to produce any error with this code:

    I'm putting together an example now.  I think it has something to do with GUI so I'm going to spend most of today trying to make it happen.

  14. MOUSE_ENTER event not working either.  Everything else here seems okay.

    #include "UltraEngine.h"
    #include "ComponentSystem.h"
    
    using namespace UltraEngine;
    
    bool EventCallback(const Event& event, shared_ptr<Object> extra) {
        switch (event.id) {
        case EVENT_MOUSEENTER:
            Print("MOUSE_ENTER");//Not working
            break;
        case EVENT_MOUSELEAVE:
            Print("MOUSE_LEAVE");
            break;
        case EVENT_MOUSEDOWN:
            Print("MOUSE_DOWN");
            break;
        case EVENT_MOUSEMOVE:
            //Print("MOUSE_MOVE");//Works disabled to see other stuff
            break;
        case EVENT_MOUSEUP:
            Print("MOUSE_UP");
            break;
        case EVENT_MOUSEWHEEL:
            Print("MOUSE_WHEEL");
            break;
        }
    
        return true;
    }
    
    int main(int argc, const char* argv[])
    {
        auto displays = GetDisplays();
        auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);
        auto world = CreateWorld();
        auto framebuffer = CreateFramebuffer(window);
    
        auto camera = CreateCamera(world);
        camera->SetClearColor(0.125);
        camera->SetFov(70);
        camera->SetPosition(0, 0, -3);
    
        auto font = LoadFont("Fonts\\arial.ttf");
        auto ui = CreateInterface(world, font, framebuffer->size);
        ui->SetRenderLayers(RENDERLAYER_1);
        ui->root->SetColor(0.0f, 0.0f, 0.0f, 0.0f);
    
        auto ui_camera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC);
        ui_camera->SetPosition((float)framebuffer->size.x * 0.5f, (float)framebuffer->size.y * 0.5f, 0);
        ui_camera->SetRenderLayers(RENDERLAYER_1);
        ui_camera->SetClearMode(CLEAR_DEPTH);
    
        auto light = CreateBoxLight(world);
        light->SetRotation(35, 45, 0);
        light->SetRange(-10, 10);
    
        auto box = CreateBox(world);
        box->SetColor(0, 0, 1);
    
        auto actor = CreateActor(box);
        auto component = actor->AddComponent<Mover>();
        component->rotation.y = 45;
    
        auto widget = CreatePanel(0, 0, 128, 128, ui->root);
        ListenEvent(EVENT_NONE, widget, EventCallback);
    
        while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
        {
            while (PeekEvent()) {
                auto event = WaitEvent();
                ui->ProcessEvent(event);
            }
    
            world->Update();
            world->Render(framebuffer);
        }
        return 0;
    }

     

  15. Can't seem to get the panel to display this pixmap.  Just shows up as solid white.

    #include "UltraEngine.h"
    #include "ComponentSystem.h"
    
    using namespace UltraEngine;
    
    int main(int argc, const char* argv[])
    {
        auto displays = GetDisplays();
        auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);
        auto world = CreateWorld();
        auto framebuffer = CreateFramebuffer(window);
    
        auto camera = CreateCamera(world);
        camera->SetClearColor(0.125);
        camera->SetFov(70);
        camera->SetPosition(0, 0, -3);
    
        auto font = LoadFont("Fonts\\arial.ttf");
        auto ui = CreateInterface(world, font, framebuffer->size);
        ui->SetRenderLayers(RENDERLAYER_1);
        ui->root->SetColor(0.0f, 0.0f, 0.0f, 0.0f);
    
        auto ui_camera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC);
        ui_camera->SetPosition((float)framebuffer->size.x * 0.5f, (float)framebuffer->size.y * 0.5f, 0);
        ui_camera->SetRenderLayers(RENDERLAYER_1);
        ui_camera->SetClearMode(CLEAR_DEPTH);
    
        auto light = CreateBoxLight(world);
        light->SetRotation(35, 45, 0);
        light->SetRange(-10, 10);
    
        auto box = CreateBox(world);
        box->SetColor(0, 0, 1);
    
        auto actor = CreateActor(box);
        auto component = actor->AddComponent<Mover>();
        component->rotation.y = 45;
    
        auto widget = CreatePanel(0, 0, 128, 128, ui->root);
        widget->SetPixmap(LoadPixmap("Background.dds"));
    
        while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
        {
            world->Update();
            world->Render(framebuffer);
        }
        return 0;
    }

    Background.zip

     

    Also .dds is not an allowed file type to upload here?

×
×
  • Create New...