Jump to content

SpiderPig

Members
  • Posts

    2,411
  • Joined

  • Last visited

Posts posted by SpiderPig

  1. Can't seem to get this to work... is there something I'm doing wrong?

    #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, 800, 600, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);
    
        //Create a world
        auto world = CreateWorld();
        world->SetGravity(0, -9.8, 0);
    
        //Create a framebuffer
        auto framebuffer = CreateFramebuffer(window);
    
        //Create a camera    
        auto camera = CreateCamera(world);
        camera->SetClearColor(0.125);
        camera->SetPosition(0, 5, -5);
    
        auto light = CreateLight(world, LIGHT_DIRECTIONAL);
        light->SetRotation(35, 35, 0);
    
        //Create the ground sprite
        auto ground = CreateBox(world, 100, 0.1, 100);
    
    
        auto player = CreateBox(world);
        player->SetPosition(0, 5, 0, true);
        player->SetMass(1.0f);
    
        //Create kinamatic joint
        auto joint = CreateKinematicJoint(Vec3(0, 5, 0), player);
        joint->SetMaxForce(100000);
        joint->SetMaxTorque(1000);
    
        //Main loop
        while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
        {
            camera->UpdateControls(window);
    
            auto pos = player->GetPosition(true);
            if (window->KeyDown(KEY_UP)) {
                auto p = pos + Vec3(0, 1, 0);
                joint->SetTargetPosition(p.x, p.y, p.z);
            }
    
            if (window->KeyDown(KEY_DOWN)) {
                auto p = pos + Vec3(0, -1, 0);
                joint->SetTargetPosition(p.x, p.y, p.z);
            }
    
            if (window->KeyDown(KEY_LEFT)) {
                auto p = pos + Vec3(-1, 0, 0);
                joint->SetTargetPosition(p.x, p.y, p.z);
            }
    
            if (window->KeyDown(KEY_RIGHT)) {
                auto p = pos + Vec3(1, 0, 0);
                joint->SetTargetPosition(p.x, p.y, p.z);
            }
    
            world->Update();
            world->Render(framebuffer);
        }
        return 0;
    }

     

  2. 5 hours ago, Josh said:

    Another update is uploaded. This fixes the kinematic joint error and the VkTexture imageview issue.

    Example works now thanks.  CreateKinematicJoint with a model or entity was returning nullptr because the entity didn't have a mass.

  3. On 9/18/2022 at 12:25 PM, Josh said:

    To load the Leadwerks material, you might need need to first load the Leadwerks plugin. However, some of the material properties are up-in-the-air right now so it might not work still.

    Just thought I'd mention that loading the LELegacy plugin didn't fix the issue.  Same error loading this JSON one too;

    {
    	"material":
    	{
    		"color": [1,1,1,1],
    		"emission": [0,0,0],
    		"metallic": 1,
    		"roughness": 1,
    		"textures":
    		[
    			{
    				"slot": "BASE",
    				"file": "./Rock001_DIFF.dds",
    				"filter": "LINEAR",
    				"clamp": [false, false, false]
    			},
    			{
    				"slot": "NORMAL",
    				"file": "./Rock001_NORM.dds",
    				"scale": 1
    			},
    			{
    				"slot": "BRDF",
    				"file": "Materials/BRDF/default.dds"
    			}
    		]
    	}
    }

     

  4. On 9/20/2022 at 1:47 AM, Josh said:

    I'm thinking about adding a feature to mark a volume as "indoors", meaning any pixels in that volume won't be affected by the skybox in the PBR reflection. If you had a house on stilts and added a 7-sided brush, it would create a volume inside the building that went all the way up into the rafters. The inside of the house would be dark, the outside would be bright, directional lights would still come through the door and windows, and there would be a soft shadowed area underneath the house. It could include a padding parameter to control how sharp the transition is.

    I think this is a good idea.  I think the ray tracing is great and looks superb but I can't see my self using it in a large procedurally generated world.  Just because it needs that extra processing power, and I'm greedy and want it to do other things :P

    I'm taking a look at the physics stuff now and want to setup my own player controller.  The KinematicJoint example crashes a few moments in and in my game, passing a model to it makes it return nullptr.  Is there still some work to do on physics?

  5. 19 hours ago, klepto2 said:

    Now that the error is gone :) this actually works:

    image.thumb.png.1ded85fa5e105314ca82e0b638a5dac0.png

    Note: The cubemap has currently just a fixed camera and light position, but it is rendered in realtime to the PBR materials :)

    Looks very nice, good job!  Are you working on a day / night cycle?

  6. I made a console for my game and after using it a few times it crashes.  I've reproduced the error here.  If you press 'P' to set the text and then press 'TAB' to show the widget, it will crash.  But no crash if you press 'TAB' first and then 'P'...

    #include "UltraEngine.h"
    
    
    int main(int argc, const char* argv[])
    {
        //Get the displays
        auto displays = GetDisplays();
    
        //Create a window
        auto window = CreateWindow("Ultra Engine", 0, 0, 1280 * displays[0]->scale, 720 * displays[0]->scale, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);
    
        //Create a world
        auto world = CreateWorld();
    
        //Create a framebuffer
        auto framebuffer = CreateFramebuffer(window);
    
        //Create a camera
        auto camera = CreateCamera(world);
        camera->SetClearColor(0, 1, 1);
        camera->SetFOV(70);
        camera->SetPosition(0, 0, -2);
    
        auto uicam = CreateCamera(world, PROJECTION_ORTHOGRAPHIC);
        uicam->SetClearMode(CLEAR_DEPTH);
        uicam->SetRenderLayers(RENDERLAYER_1);
        uicam->SetPosition(framebuffer->size.x / 2, framebuffer->size.y / 2);
        auto ui = CreateInterface(world, LoadFont("Fonts/arial.ttf"), framebuffer->size);
        ui->SetRenderLayers(RENDERLAYER_1);
        ui->background->SetColor(0, 0, 0, 0);
    
        //Create a light
        auto light = CreateLight(world, LIGHT_DIRECTIONAL);
        light->SetRotation(35, 45, 0);
    
        //Create a box
        auto box = CreateBox(world);
    
        auto textbox = CreateTextArea(10, 10, 100, 25, ui->root);
        textbox->SetHidden(true);
    
    
        //Main loop
        while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
        {
            while (PeekEvent()) {
                ui->ProcessEvent(WaitEvent());
            }
    
            if (window->KeyHit(KEY_P)) {
                textbox->SetText("Testing");
            }
    
            if (window->KeyHit(KEY_TAB)) {
                textbox->SetHidden(!textbox->GetHidden());
            }
    
            world->Update();
            world->Render(framebuffer);
        }
        return 0;
    }

     

  7. Awesome!  Noticed this in my project and managed to reproduce it in this program.  I've only noticed this on a sphere so far (a red sphere to be precise), sometimes these white pixels pop up for a single frame.  (It took a bit but I managed to take a picture of one! :P)  More noticeable if the camera moves but this sphere spins.  It might be at the UV seam perhaps?  Thought I'd mention it at least.  Project is up to date.

    WhiteSpots.png.9f0bb8c860f88da4feed50b78ac58894.png

    #include "UltraEngine.h"
    #include "ComponentSystem.h"
    
    
    int main(int argc, const char* argv[])
    {
        //Get the displays
        auto displays = GetDisplays();
    
        //Create a window
        auto window = CreateWindow("Ultra Engine", 0, 0, 1280 * displays[0]->scale, 720 * displays[0]->scale, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);
    
        //Create a world
        auto world = CreateWorld();
    
        //Create a framebuffer
        auto framebuffer = CreateFramebuffer(window);
    
        //Create a camera
        auto camera = CreateCamera(world);
        camera->SetClearColor(0.125);
        camera->SetFOV(70);
        camera->SetPosition(0, 0, -3);
    
        auto uicam = CreateCamera(world, PROJECTION_ORTHOGRAPHIC);
        uicam->SetClearMode(CLEAR_DEPTH);
        uicam->SetRenderLayers(RENDERLAYER_1);
        uicam->SetPosition(framebuffer->size.x / 2, framebuffer->size.y / 2);
        auto ui = CreateInterface(world, LoadFont("Fonts/arial.ttf"), framebuffer->size);
        ui->SetRenderLayers(RENDERLAYER_1);
        ui->background->SetColor(0, 0, 0, 0);
    
        world->SetEnvironmentMap(LoadTexture("Materials\\Environment\\Storm\\diffuse.dds"), ENVIRONMENTMAP_DIFFUSE);
        world->SetEnvironmentMap(LoadTexture("Materials\\Environment\\Storm\\specular.dds"), ENVIRONMENTMAP_SPECULAR);
    
        //Create a light
        auto light = CreateLight(world, LIGHT_DIRECTIONAL);
        light->SetRotation(35, 45, 0);
    
        //Create a box
        auto box = CreateSphere(world);
        box->SetColor(1.0f, 0.0f, 0.0f);
    
        auto floor = CreateBox(world, 10.0f, 0.1f, 10.0f);
        floor->SetPosition(0.0f, -1.0f, 0.0f);
    
        //Entity component system
        auto actor = CreateActor(box);
        auto component = actor->AddComponent<Mover>();
        component->rotation.y = 45;
    
        //Main loop
        while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
        {
    
            world->Update();
            world->Render(framebuffer);
        }
        return 0;
    }

     

  8. Small issue with a text field, the text changes colour when pressing the 2nd letter.

    WidgetIssue.png.7fe38031033ccde24f7cb38c45db788e.png

    #include "UltraEngine.h"
    #include "ComponentSystem.h"
    
    
    int main(int argc, const char* argv[])
    {
        //Get the displays
        auto displays = GetDisplays();
    
        //Create a window
        auto window = CreateWindow("Ultra Engine", 0, 0, 1280 * displays[0]->scale, 720 * displays[0]->scale, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);
    
        //Create a world
        auto world = CreateWorld();
    
        //Create a framebuffer
        auto framebuffer = CreateFramebuffer(window);
    
        //Create a camera
        auto camera = CreateCamera(world);
        camera->SetClearColor(0.125);
        camera->SetFOV(70);
        camera->SetPosition(0, 0, -3);
    
        auto uicam = CreateCamera(world, PROJECTION_ORTHOGRAPHIC);
        uicam->SetClearMode(CLEAR_DEPTH);
        uicam->SetRenderLayers(RENDERLAYER_1);
        uicam->SetPosition(framebuffer->size.x / 2, framebuffer->size.y / 2);
        auto ui = CreateInterface(world, LoadFont("Fonts/arial.ttf"), framebuffer->size);
        ui->SetRenderLayers(RENDERLAYER_1);
        ui->background->SetColor(0, 0, 0, 0);
    
        auto text_Box = CreateTextField(0, 0, 200, 50, ui->root);
    
        //Create a light
        auto light = CreateLight(world, LIGHT_DIRECTIONAL);
        light->SetRotation(35, 45, 0);
    
        //Create a box
        auto box = CreateBox(world);
    
        //Entity component system
        auto actor = CreateActor(box);
        auto component = actor->AddComponent<Mover>();
        component->rotation.y = 45;
    
        //Main loop
        while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
        {
            while (PeekEvent())
            {
                ui->ProcessEvent(WaitEvent());
            }
    
            world->Update();
            world->Render(framebuffer);
        }
        return 0;
    }

     

  9. 20 minutes ago, Josh said:

    Call uicam->SetClearMode(CLEAR_COLOR) so it shows the previously rendered color underneath.

    Once at setup or per frame?  I tried both and it made no difference.

    21 minutes ago, Josh said:

    This happens because culling is performed asynchronously, and visibility sets are reused to draw several frames. If it only happens in debug mode it's not a problem. Otherwise there is a camera frustum prediction feature I can toggle on and off that I am still toying with.

    It's exactly the same in release too.  It doesn't vanish too early at the edge of the frustum which I could understand in debug, it can vanish in the middle of the screen...

  10. I've noticed that objects still pop in an out as you move the camera sometimes.  This has been something I've noticed since the Steam BETA.

    Run this and hold space to move the box.  Follow the box by moving the mouse and the box will disappear sometimes.

    #include "UltraEngine.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], WINDOW_CENTER | WINDOW_TITLEBAR);
        auto world = CreateWorld();
        auto framebuffer = CreateFramebuffer(window);
    
        auto camera = CreateCamera(world);
        camera->SetClearColor(0.125);
        camera->SetRotation(45, 0, 0);
        camera->Move(0, 0, -10);
        camera->SetFOV(70);
    
        auto box = CreateBox(world);
    
        auto mousepos = Vec3();
        float lookspeed = 0.1f;
        float looksmoothing = 0.5f;
    
        auto _displaySize = window->GetSize();
        float cx = Round((float)_displaySize.x / 2.0f);
        float cy = Round((float)_displaySize.y / 2.0f);
        window->SetMousePosition(cx, cy);
    
        while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
        {
            if (window->KeyDown(KEY_SPACE)) {
                box->Move(0.05, 0, 0);
            }
    
            float dx = 0.0f, dy = 0.0f;
            _displaySize = window->GetSize();
            cx = Round((float)_displaySize.x / 2.0f);
            cy = Round((float)_displaySize.y / 2.0f);
            auto mpos = Vec3(window->GetMousePosition().x, window->GetMousePosition().y, window->GetMousePosition().z);
            window->SetMousePosition(cx, cy);
            mpos = mpos * looksmoothing + mousepos * (1 - looksmoothing);
            dx = (mpos.x - cx) * lookspeed;
            dy = (mpos.y - cy) * lookspeed;
    
            auto camrot = camera->GetRotation();
            camrot.x += dy;
            camrot.y += dx;
            camera->SetRotation(camrot);
            mousepos = mpos;
    
            world->Update();
            world->Render(framebuffer);
        }
        return 0;
    }

     

  11. I like that idea a lot.  When I implemented it in my project though I had no 3D objects showing up.  I ran this code in a fresh project and the box was not visible.  I think it should be in view in the centre of the screen...

     

    #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, 800, 600, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);
    
        //Create a world
        auto world = CreateWorld();
    
        //Create a framebuffer
        auto framebuffer = CreateFramebuffer(window);
    
        //Create a camera
        auto camera = CreateCamera(world);
        camera->SetClearColor(0.125);
        camera->SetRotation(45, 0, 0);
        camera->Move(0, 0, -10);
        camera->SetFOV(70);
    
        auto uicam = CreateCamera(world, PROJECTION_ORTHOGRAPHIC);
        uicam->SetRenderLayers(RENDERLAYER_1);
        uicam->SetPosition(framebuffer->size.x / 2, framebuffer->size.y / 2);
        auto ui = CreateInterface(world, LoadFont("Fonts/arial.ttf"), framebuffer->size);
        ui->SetRenderLayers(RENDERLAYER_1);
    
        auto sz = ui->root->ClientSize();
        auto textarea = CreateTextArea(10, 10, sz.x - 20, 100, ui->root, TEXTAREA_WORDWRAP);
    
        WString s;
    
        for (int n = 0; n < 300; ++n)
        {
            s += String(n) + "\n";
        }
    
        textarea->SetLayout(1, 1, 1, 1);
    
        //ui->SetScale(displays[0]->scale);
        textarea->SetText(s);
    
        auto box = CreateBox(world);
    
        //Main loop
        while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
        {
            while (PeekEvent())
            {
                ui->ProcessEvent(WaitEvent());
            }
    
            world->Update();
            world->Render(framebuffer);
        }
        return 0;
    }

     

  12. Found a few more things;

    1. CreateTextField() still compiles with an Interface as an argument but it leads to an unresolved external symbol error.  Setting it to use the root of the interface works.

    2.  CreateTextArea() is the same.  Still compiles but won't link.

    3. CreateInterface() takes an unknown float as the 3rd parameter and links with unresolved symbol.   I don't need it - just think it's there by accident...

    4. frambuffer is nullptr when using the flag WINDOW_RESIZEABLE in the CreateWindow()

    auto window = CreateWindow("MyApp", 0, 0, 1440, 900, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR | WINDOW_RESIZABLE);
    auto framebuffer = CreateFramebuffer(window);

    5.  Getting this error when loading a material in a fresh project.  (Files attached)

    auto mat = LoadMaterial("Materials\\Developer\\bluegrid.mat");

    MaterialError.thumb.png.65a77b4daaa8b78264c8285a283465b1.png

    Developer.zip

    • Like 1
  13. 8 hours ago, Josh said:

    Regarding large mesh building, the reason it would be slow with very big meshes is because the STL vector is being frequently resized as it grows, so it keeps allocating and copying a larger and larger block of memory. I'm not sure what should be done, maybe some new methods like this:

    
    
    Mesh::AddVertices(const std::vector<Vertex>& verts)
    Mesh::AddIndices(const std::vector<uint32_t>& indices)

    That's what I was thinking.  Commands like that would be perfect!  :D

     

    And removing verts too?  Maybe SetVertices() as well, I have needed to clear them before.

×
×
  • Create New...