Jump to content

SpiderPig

Members
  • Posts

    2,411
  • Joined

  • Last visited

Posts posted by SpiderPig

  1. Not sure if this is a bug or I'm not using it right - should SetTorque() on a kinematic joint disable all rotation?  I just want to position the joint and no matter what happens to it, have it never rotate.  Here moving the joint makes it rotate all over the place.

    #include "UltraEngine.h"
    
    using namespace UltraEngine;
    
    int main(int argc, const char* argv[])
    {
        auto plugin = LoadPlugin("Plugins/LELegacy.dll");
    
        //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 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);
    
    
        //Create a light
        auto light = CreateDirectionalLight(world);
        light->SetRotation(35, 45, 0);
        light->SetRange(-10, 10);
    
        auto floor = CreateBox(world, 100, 0.1, 100);
        floor->SetPosition(0, -1, 0);
    
    
        auto hub_pivot = CreateBox(world, 0.25f);
        hub_pivot->SetCollider(nullptr);
        hub_pivot->SetMass(1.0f);
        hub_pivot->SetColor(0, 1, 0);
    
        auto slider_pivot = CreateBox(world, 0.25f);
        slider_pivot->SetMass(1.0f);
        slider_pivot->SetColor(0, 0, 1);
    
        auto cam_pivot = CreatePivot(world);
        cam_pivot->SetParent(slider_pivot);
        cam_pivot->SetPosition(0.0f, 2.5f, 0.0f, true);
    
        camera->SetParent(cam_pivot);
        camera->SetPosition(0.0f, 1.8f, -5.0f, true);
        camera->SetRotation(25.0f, 0.0f, 0.0f);
    
        auto k = CreateKinematicJoint(Vec3(0, 0, 0), hub_pivot);
        k->SetMaxTorque(0.0f);
        auto s = CreateSliderJoint(Vec3(0, 0, 0), Vec3(0, 1, 0), hub_pivot, slider_pivot);
    
        Vec3 mousepos;
        float lookspeed = 0.1f;
        float looksmoothing = 0.5f;
    
        //Main loop
        while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
        {
            auto _displaySize = window->GetSize();
            float cx = Round((float)_displaySize.x / 2.0f);
            float cy = Round((float)_displaySize.y / 2.0f);
    
            auto mouse_position = Vec3(window->GetMousePosition().x, window->GetMousePosition().y, window->GetMousePosition().z);
            window->SetMousePosition(cx, cy);
            mouse_position = mouse_position * looksmoothing + mousepos * (1 - looksmoothing);
            auto dx = (mouse_position.x - cx) * lookspeed;
            auto dy = (mouse_position.y - cy) * lookspeed;
    
            auto camrot = cam_pivot->GetRotation();
            camrot.x += dy;
            camrot.y += dx;
            cam_pivot->SetRotation(camrot);
            mousepos = mouse_position;
    
            float angle = cam_pivot->GetRotation().y;
            Vec3 pos = hub_pivot->GetPosition(true);
            Vec3 up = Vec3(0.0f, 1.0f, 0.0f);
            Vec3 direction = Vec3(Sin(angle), 0, Cos(angle));
            Vec3 strafe = direction.Cross(up).Normalize();
    
            if (window->KeyDown(KEY_W)) { k->SetPose(pos + direction, Vec3()); }
            if (window->KeyDown(KEY_S)) { k->SetPose(pos - direction, Vec3()); }
            if (window->KeyDown(KEY_A)) { k->SetPose(pos + strafe, Vec3()); }
            if (window->KeyDown(KEY_D)) { k->SetPose(pos - strafe, Vec3()); }
    
            world->Update();
            world->Render(framebuffer);
        }
        return 0;
    }  

     

  2. I threw together a quick example for you showing some of the issues I'm still seeing with entities popping in and out.  The green cube pops in and out and in my other project so does the player cylinder, doesn't seem to happen here though.  The entities are always in the centre of the camera and they still pop in and out.  If you remove the player cylinder the blue cube seems to fine, it's just the cube attached the slider.

    #include "UltraEngine.h"
    #include "ComponentSystem.h"
    
    using namespace UltraEngine;
    
    int main(int argc, const char* argv[])
    {
        auto plugin = LoadPlugin("Plugins/LELegacy.dll");
    
        //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 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);
    
    
        //Create a light
        auto light = CreateDirectionalLight(world);
        light->SetRotation(35, 45, 0);
        light->SetRange(-10, 10);
    
        auto floor = CreateBox(world, 100, 0.1, 100);
        floor->SetPosition(0, -1, 0);
    
    
        auto hub_pivot = CreateBox(world, 0.25f);
        hub_pivot->SetCollider(nullptr);
        hub_pivot->SetMass(1.0f);
        hub_pivot->SetColor(0, 1, 0);
    
        auto slider_pivot = CreateBox(world, 0.25f);
        slider_pivot->SetMass(1.0f);
        slider_pivot->SetColor(0, 0, 1);
    
        auto player = CreateCylinder(world, 0.5f, 1.8f);
        player->SetCollider(nullptr);
        player->SetParent(slider_pivot);
    
        auto cam_pivot = CreatePivot(world);
        cam_pivot->SetParent(slider_pivot);
        cam_pivot->SetPosition(0.0f, 2.5f, 0.0f, true);
    
        camera->SetParent(cam_pivot);
        camera->SetPosition(0.0f, 1.8f, -5.0f, true);
        camera->SetRotation(25.0f, 0.0f, 0.0f);
    
        auto k = CreateKinematicJoint(Vec3(0, 0, 0), hub_pivot);
        auto s = CreateSliderJoint(Vec3(0, 0, 0), Vec3(0, 1, 0), hub_pivot, slider_pivot);
    
        Vec3 mousepos;
        float lookspeed = 0.1f;
        float looksmoothing = 0.5f;
    
        //Main loop
        while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
        {
            auto _displaySize = window->GetSize();
            float cx = Round((float)_displaySize.x / 2.0f);
            float cy = Round((float)_displaySize.y / 2.0f);
    
            auto mouse_position = Vec3(window->GetMousePosition().x, window->GetMousePosition().y, window->GetMousePosition().z);
            window->SetMousePosition(cx, cy);
            mouse_position = mouse_position * looksmoothing + mousepos * (1 - looksmoothing);
            auto dx = (mouse_position.x - cx) * lookspeed;
            auto dy = (mouse_position.y - cy) * lookspeed;
    
            auto camrot = cam_pivot->GetRotation();
            camrot.x += dy;
            camrot.y += dx;
            cam_pivot->SetRotation(camrot);
            mousepos = mouse_position;
    
            float angle = cam_pivot->GetRotation().y;
            Vec3 pos = hub_pivot->GetPosition(true);
            Vec3 up = Vec3(0.0f, 1.0f, 0.0f);
            Vec3 direction = Vec3(Sin(angle), 0, Cos(angle));
            Vec3 strafe = direction.Cross(up).Normalize();
    
            if (window->KeyDown(KEY_W)) { k->SetPose(pos + direction, Vec3()); }
            if (window->KeyDown(KEY_S)) { k->SetPose(pos - direction, Vec3()); }
            if (window->KeyDown(KEY_A)) { k->SetPose(pos + strafe, Vec3()); }
            if (window->KeyDown(KEY_D)) { k->SetPose(pos - strafe, Vec3()); }
    
            world->Update();
            world->Render(framebuffer);
        }
        return 0;
    }  

     

  3. This has me extremely puzzled - I just started working with kinematic joints again, and all was good, I could set its position with SetPose() and other things, but then a few builds later CreateKinematicJoint() started returning nullptr for no reason same as the slider joint too.  I uninstalled Ultra and reinstalled with no luck.  

    Here's an example project where 'k' is empty.

    #include "UltraEngine.h"
    #include "ComponentSystem.h"
    
    using namespace UltraEngine;
    
    int main(int argc, const char* argv[])
    {
        auto plugin = LoadPlugin("Plugins/LELegacy.dll");
    
        //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 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, 1, -3);
    
        //Create a light
        auto light = CreateBoxLight(world);
        light->SetRotation(35, 45, 0);
        light->SetRange(-10, 10);
    
        auto p = CreatePivot(world);
        auto k = CreateKinematicJoint(Vec3(0, 0, 0), p);
    
    
    
        //Main loop
        while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
        {
            world->Update();
            world->Render(framebuffer);
        }
        return 0;
    }  

     

  4. I wonder if the backups for files that have been updated should be moved to a single folder in the project directory rather than having mountains of .bak's lurking about, especially in the shaders folder.  It could keep the same hierarchy in the backups folder so you can find stuff.   I take it Ultra is going to be heavily updated over the coming months / years so it could get out of hand pretty quick.  Just a thought :)

    EDIT : Or has is been done already.. <_<

  5. On 12/5/2022 at 6:32 PM, Josh said:

    I don't plan to support raw Basis files. KTX2 includes Basis compression and is a better format. All mentions of the Basis plugin should be removed from the documentation, although you can still use it if you want.

    Are there any tools available to convert to KTX2?  I can't seem to find any...

  6. 1 hour ago, reepblue said:
    1 hour ago, Josh said:

    Does GUI work in 3D?

    I might want to check this out for myself as I was getting weird issues when making an in-game console a few months ago.

    I have noticed with 3D GUI that the borders of the buttons don't line up, and on LoadGame I'm holding the mouse down and you can see the triangles that make up the background mesh.  I think there are various issues like this with other widgets too.  Haven't tested with a small fresh project though, if you'd like an example I can put one together for you tonight.

    1679619648_3DGUI.png.3659f220bf9c31296d8cf03b4eb80317.png

  7. This is going to be hard to pin point but randomly every few launches in debug mode it will crash with this error...

    Error_Functional.png.eed71fb227cab8ef54d8e741f46f57f8.png

    Error_Functional2.thumb.png.eb5fc8c7a3939369245eea3a26211602.png

    Stopping and restarting the debug session and it will then work. :blink:  No idea how to solve it but thought it worth mentioning at least.

  8. That's looks good.  Is this an infinite water plane or will it work with any custom shape?

     

    @Josh A lots changed since I've last compiled a custom shader - is this still possible?  I get a few errors currently, I see Base.frag is now base_frag.glsl but I'm not sure if I should be suing that anymore...

  9. Might even be better again to create the new mesh instance and add it to a model as a different LOD mesh and let the shaders take care of LOD - is that how LOD works in Ultra?  My only thoughts here are for a massive terrain over time the RAM and GPU memory could increase to large numbers (more so thinking GPU memory).

    I could create the mesh on a separate thread and then assign it the model.  If memory does become a problem I could create an entirely new model for patches that haven't been visited for a while or are so far away and then delete the old model with all the extra meshes.

    Deleting a model will remove all the mesh information from the GPU and renderer?

×
×
  • Create New...