Jump to content

Recommended Posts

Posted

And in same time PickFilter have this entity twice.

Example (space to do pick, result in console):

#include "Leadwerks.h"

using namespace Leadwerks;

bool PickFilter(std::shared_ptr<Entity> entity, std::shared_ptr<Object> extra) {
    if (entity->GetCollider() == nullptr) { return false; }
    return true;
}

int main(int argc, const char* argv[]) {
    // Get the displays
    auto displays = GetDisplays();

    //Create window
    auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);

    //Create world
    auto world = CreateWorld();

    //Create framebuffer
    auto framebuffer = CreateFramebuffer(window);

    //Set up camera
    auto camera = CreateCamera(world);
    camera->SetClearColor(0.125);
    camera->SetFov(70);
    camera->SetPosition(0, 2, -3);
    camera->SetRotation(25, 0, 0);

    //Add a light
    auto light = CreateDirectionalLight(world);
    light->SetRotation(35, 45, 0);
    light->SetColor(5);

    //Set up the scene
    auto floor = CreatePlane(world, 100, 100);
    floor->Move(0, -1, 0);

    auto b1 = CreateBox(world, 2.0f);
    b1->SetPosition(-3.0f, 0.0f, 0.0f);
    b1->SetColor(1, 0, 0);

   
    auto spin_speed = 0.5f;
    while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) {
        if (window->KeyDown(KEY_SPACE)) {
            auto pick_info = world->Pick(b1->GetPosition(true), b1->GetPosition(true), 0, true, PickFilter);
            if (pick_info.success) {
                Print("True");
            } else {
                Print("False");
            }
        }
        // Update the world
        world->Update();
        // Render the world
        world->Render(framebuffer);
    }
    return 0;
}

 

Check out Slipgate Tactics demo, which is made with Ultra Engine:

https://www.leadwerks.com/community/topic/61480-slipgate-tactics-demo/

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.

×
×
  • Create New...