Jump to content

Dreikblack

Members
  • Posts

    365
  • Joined

  • Last visited

Posts posted by Dreikblack

  1. GetCollider()->IntersectsPoint() seems to ignore changes of position and rotation of model with collider

    #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, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);
    
        //Create a framebuffer
        auto framebuffer = CreateFramebuffer(window);
    
        //Create a world
        auto world = CreateWorld();
    
        //Create a camera    
        auto camera = CreateCamera(world);
        camera->SetClearColor(0.8);
        camera->Turn(35, 0, 0);
        camera->Move(0, 0, -2);
        camera->SetDebugPhysicsMode(true);
    
        //Create light
        auto light = CreateBoxLight(world);
        light->SetRange(-20, 20);
        light->SetArea(20, 20);
        light->SetRotation(35, 35, 0);
    
        auto unlitMaterial = CreateMaterial();
        auto unlitShader = LoadShaderFamily("Shaders/Unlit.json");
        unlitMaterial->SetShaderFamily(unlitShader);
    
        int width = 2, height = 1, length = 3;
        auto model = CreateModel(world);
        auto mesh = model->AddMesh();
    
        mesh->AddVertex(0, 0, 0); //S
        mesh->AddVertex(-width * 0.5, -height * 0.5, length);//NW
        mesh->AddVertex(width * 0.5, -height * 0.5, length);//NE
    
        mesh->AddPrimitive(2, 1, 0);//S , NW, NE
    
        mesh->AddVertex(-width * 0.5, height * 0.5, length);//NW h
        mesh->AddVertex(width * 0.5, height * 0.5, length);//NE h
    
        mesh->AddPrimitive(0, 3, 4);//S , NW h, NE h
    
        mesh->AddPrimitive(0, 1, 3);//left
    
        mesh->AddPrimitive(4, 3, 1); //"face"
        mesh->AddPrimitive(2, 4, 1); //"face"
    
    
        mesh->AddPrimitive(0, 4, 2); //"right"
    
        auto& mat = unlitMaterial;
        mat->SetTransparent(true);
        model->SetMaterial(mat);
        model->SetColor(0.5f, 0.8f, 0, 0.25f);
    
        auto collider = CreateConvexHullCollider(mesh);
        model->SetCollider(collider);
    
        Vec3 targetPos(3, 0.5f, 0);
        model->Point(targetPos, 2, 1, 0);
        bool isInside = model->GetCollider()->IntersectsPoint(0, 0.5f, 3);
        Print(isInside);//should be false for this old position
        isInside = model->GetCollider()->IntersectsPoint(targetPos);
        Print(isInside);//should be true for this new position
        //Main loop
        while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
        {
            world->Update();
            world->Render(framebuffer);
        }
        return 0;
    }

     

  2. Made it work but i have strange triangle at bottom

    image.png.90bacf2eb3decbb1c60565f4cd04b2f6.png

    #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, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);
    
        //Create a framebuffer
        auto framebuffer = CreateFramebuffer(window);
    
        //Create a world
        auto world = CreateWorld();
    
        //Create a camera    
        auto camera = CreateCamera(world);
        camera->SetClearColor(0.8);
        camera->Turn(35, 0, 0);
        camera->Move(0, 0, -1);
    
        //Create light
        auto light = CreateBoxLight(world);
        light->SetRange(-20, 20);
        light->SetArea(20, 20);
        light->SetRotation(35, 35, 0);
    
        auto unlitMaterial = CreateMaterial();
        auto unlitShader = LoadShaderFamily("Shaders/Unlit.json");
        unlitMaterial->SetShaderFamily(unlitShader);
    
        int width = 4, height = 2, length = 6;
        auto model = CreateModel(world);
        auto mesh = model->AddMesh();
    
        mesh->AddVertex(0, 0, 0); //S
        mesh->AddVertex(-width * 0.5, -height * 0.5, length);//NW
        mesh->AddVertex(width * 0.5, -height * 0.5, length);//NE
    
        mesh->AddPrimitive(0, 1, 2);//S , NW, NE
    
        mesh->AddVertex(-width * 0.5, height * 0.5, length);//NW h
        mesh->AddVertex(width * 0.5, height * 0.5, length);//NE h
    
        mesh->AddPrimitive(0, 3, 4);//S , NW h, NE h
    
        mesh->AddPrimitive(0, 1, 3);//left
    
        mesh->AddPrimitive(1, 3, 4); //"face"
        mesh->AddPrimitive(1, 4, 2); //"face"
    
    
        mesh->AddPrimitive(2, 4, 0); //"right"
    
        model->SetColor(0.5f, 0.8f, 0, 0.25f);
        auto& mat = unlitMaterial;
        mat->SetTransparent(true);
        model->SetMaterial(mat);
        auto collider = CreateConvexHullCollider(model);
        model->SetCollider(collider);
    
        auto modelLine = CreateModel(world);
        auto meshLine = modelLine->AddMesh(MESH_LINES);
    
        meshLine->AddVertex(0, 0, 0); //S
        meshLine->AddVertex(-width * 0.5, -height * 0.5, length);//NW
        meshLine->AddVertex(width * 0.5, -height * 0.5, length);//NE
    
        meshLine->AddPrimitive(0, 1);//S , NW, NE
        meshLine->AddPrimitive(1, 2);//S , NW, NE
        meshLine->AddPrimitive(0, 2);//S , NW, NE
    
        meshLine->AddVertex(-width * 0.5, height * 0.5, length);//NW h
        meshLine->AddVertex(width * 0.5, height * 0.5, length);//NE h
    
        meshLine->AddPrimitive(0, 3);//S , NW h, NE h
        meshLine->AddPrimitive(3, 4);//S , NW h, NE h
        meshLine->AddPrimitive(0, 4);//S , NW h, NE h
    
    
        meshLine->AddPrimitive(0, 1);//left
        meshLine->AddPrimitive(1, 3);//left
        meshLine->AddPrimitive(0, 3);//left
    
        meshLine->AddPrimitive(1, 2); //"face"
        meshLine->AddPrimitive(2, 4); //"face"
        meshLine->AddPrimitive(4, 3); //"face"
        meshLine->AddPrimitive(1, 3); //"face"
    
        meshLine->AddPrimitive(2, 4); //"right"
        meshLine->AddPrimitive(4, 0); //"right"
        meshLine->AddPrimitive(2, 0); //"right"
    
        //Finalize the brush
        modelLine->SetColor(0, 0, 0, 1);
        auto matLine = unlitMaterial;
        matLine->SetLineStipple(LINE_STIPPLE_DASHED);
        modelLine->SetMaterial(matLine);
    
        //Main loop
        while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
        {
            world->Update();
            world->Render(framebuffer);
        }
        return 0;
    }

     

  3. Happens on mesh->AddPrimitive(1, 2, 4, 3); (54 line)

    Trying to remake tetrahedron as a model here.

    #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, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);
    
        //Create a framebuffer
        auto framebuffer = CreateFramebuffer(window);
    
        //Create a world
        auto world = CreateWorld();
    
        //Create a camera    
        auto camera = CreateCamera(world);
        camera->SetClearColor(0.8);
        camera->Turn(35, 0, 0);
        camera->Move(0, 0, -2);
    
        //Create light
        auto light = CreateBoxLight(world);
        light->SetRange(-20, 20);
        light->SetArea(20, 20);
        light->SetRotation(35, 35, 0);
    
        auto unlitMaterial = CreateMaterial();
        auto unlitShader = LoadShaderFamily("Shaders/Unlit.json");
        unlitMaterial->SetShaderFamily(unlitShader);
    
        int width = 4, height = 2, length = 6;
        auto model = CreateModel(world);
        auto mesh = model->AddMesh();
    
        mesh->AddVertex(0, 0, 0); //S
        mesh->AddVertex(-width * 0.5, -height * 0.5, length);//NW
        mesh->AddVertex(width * 0.5, -height * 0.5, length);//NE
    
        mesh->AddPrimitive(0, 1, 2);//S , NW, NE
    
        mesh->AddVertex(-width * 0.5, height * 0.5, length);//NW h
        mesh->AddVertex(width * 0.5, height * 0.5, length);//NE h
    
        mesh->AddPrimitive(0, 3, 4);//S , NW h, NE h
    
        mesh->AddPrimitive(0, 1, 3);//left
    
        mesh->AddPrimitive(1, 2); //"face"
        mesh->AddPrimitive(2, 4); //"face"
        mesh->AddPrimitive(4, 3); //"face"
        mesh->AddPrimitive(1, 3); //"face"
    
    
        mesh->AddPrimitive(2, 4, 0); //"right"
    
        model->SetColor(0.5f, 0.8f, 0, 0.25f);
        auto& mat = unlitMaterial;
        mat->SetTransparent(true);
        model->SetMaterial(mat);
        auto collider = CreateConvexHullCollider(model);
        model->SetCollider(collider);
    
        auto modelLine = CreateModel(world);
        auto meshLine = modelLine->AddMesh(MESH_LINES);
    
        meshLine->AddVertex(0, 0, 0); //S
        meshLine->AddVertex(-width * 0.5, -height * 0.5, length);//NW
        meshLine->AddVertex(width * 0.5, -height * 0.5, length);//NE
    
        meshLine->AddPrimitive(0, 1, 2);//S , NW, NE
    
        meshLine->AddVertex(-width * 0.5, height * 0.5, length);//NW h
        meshLine->AddVertex(width * 0.5, height * 0.5, length);//NE h
    
        meshLine->AddPrimitive(0, 3);//S , NW h, NE h
        meshLine->AddPrimitive(3, 4);//S , NW h, NE h
        meshLine->AddPrimitive(0, 4);//S , NW h, NE h
    
    
        meshLine->AddPrimitive(0, 1);//left
        meshLine->AddPrimitive(1, 3);//left
        meshLine->AddPrimitive(0, 3);//left
    
        meshLine->AddPrimitive(1, 2); //"face"
        meshLine->AddPrimitive(2, 4); //"face"
        meshLine->AddPrimitive(4, 3); //"face"
        meshLine->AddPrimitive(1, 3); //"face"
    
        meshLine->AddPrimitive(2, 4, 0); //"right"
    
        //Finalize the brush
        modelLine->SetColor(0.5f, 0.8f, 0, 0.25f);
        auto matLine = unlitMaterial;
        matLine->SetLineStipple(LINE_STIPPLE_DASHED);
        modelLine->SetMaterial(matLine);
    
        //Main loop
        while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
        {
            world->Update();
            world->Render(framebuffer);
        }
        return 0;
    }

     

  4. 1 hour ago, SpiderPig said:

    SetLineStipple() has to be the single most best thing about Ultra.

    Can you share a little example for SetLineStipple()? Not for UI but just something simple where stipple effect could be seen.

  5. I mostly finished basic core gameplay and GUI.

    - Changed available tiles look from outline to square unlit brushes

    - Added a nailgun that can shoot through armor multiply times at once with new number field next to Ok button.

    - Added an action properties row in an action dialog (action point cost, damage, distance etc.)

    - Added knockback for shotguns at close distance

    - Added spread for shotgun - multiply enemies can be shot

    - Added block and dodge system - action points (yellow) wastes at point blank distance for blocking and movement (blue) uses for dodges.

    - After death units became corpses

    - Corpses and alive units can be gibbed (to free tile) if enough damage was dealt to them

    - How much health, armor, action or movement points will be wasted after or shot or move now shows by blinking in unit bars (above units)

    - Yellow lines shows which targets in lines of sights for current weapon

    - Inventory - for equipping weapon, armor etc. from marine common inventory

    - Marine bars at left side with their status and ability to select one those marines

    - Added obstacles that can be used as covers and can be destroyed

    idk why sound is broken in the video, game sounds normal while playing.

     

    • Like 6
  6. I think block.SetPixmap work fine if a pixmap as member set in but with if it's another pixmap (to make few different icons for different blocks) i have an exception at Render(). An example:

    #include "UltraEngine.h"
    
    using namespace UltraEngine;
    
    class NewWidget : public Widget
    {
    protected:
        virtual void Draw(const int x, const int y, const int width, const int height)
        {
            for (int i = 0; i < 4; i++)
            {
    
                blocks[i].hidden = false;
                blocks[i].position = iVec2(i * 64, 0);
                blocks[i].size = iVec2(64, 64);
                blocks[i].filter = pixmapfilter;
                blocks[i].color = Vec4(1);
                auto px = LoadPixmap("https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets/Materials/Ground/dirt01.dds");
                blocks[i].SetPixmap(px);
            }
        }
    
    public:
        static shared_ptr<NewWidget> create(const int x, const int y, const int width, const int height, shared_ptr<Widget> parent, const int style = 0)
        {
            struct Struct : public NewWidget {
            };
            auto instance = std::make_shared<Struct>();
            instance->Initialize("", x, y, width, height, parent, style);
            return instance;
        }
    
        NewWidget()
        {
            blocks.resize(4);
        }
    };
    
    int main(int argc, const char* argv[])
    {
        //Get the displays
        auto displays = GetDisplays();
    
        //Create a window
        auto window = CreateWindow("Ultra Engine", 0, 0, 1920, 1080, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);
    
        //Create a framebuffer
        auto framebuffer = CreateFramebuffer(window);
    
        //Create a world
        auto world = CreateWorld();
    
        //Create a camera    
        auto camera = CreateCamera(world);
        camera->SetClearColor(0.6);
        camera->SetFov(90);
        camera->SetRotation(54.736f, 45, 0);
        camera->SetPosition(0, 4, 0);
    
        auto sz = framebuffer->GetSize();
    
        // Load a font
        auto font = LoadFont("Fonts/arial.ttf");
    
        // Create user interface
        auto ui = CreateInterface(world, font, framebuffer->GetSize());
        ui->SetRenderLayers(2);
        ui->root->SetColor(0.0f, 0.0f, 0.0f, 0.0f);
    
        // Create ui camera
        auto uiCamera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC);
        uiCamera->SetPosition(float(framebuffer->GetSize().x) * 0.5f, float(framebuffer->GetSize().y) * 0.5f, 0);
        uiCamera->SetRenderLayers(2);
        uiCamera->SetClearMode(CLEAR_DEPTH);
    
        auto widget = NewWidget::create(0, 0, 64 * 4, 64, ui->root, 0);
    
        //Create light
        auto light = CreateBoxLight(world);
        light->SetRange(-100, 100);
        light->SetArea(100, 100);
        light->SetRotation(35, 35, 0);
        light->SetColor(2);
    
        //Main loop
        while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
        {
            world->Update();
            world->Render(framebuffer, false);
        }
        return 0;
    }

     

×
×
  • Create New...