Jump to content

Pick collision and light does not work for Brush if it was parented to Pivot in the Editor


Recommended Posts

Posted

Example map: 
TestBox.zip

Light when not parented:

image.thumb.png.0d8882f1ed138351806771fcf8f250e4.png

When parented:

image.thumb.png.84050ab2703c121a9ab874d162a192bb.png

Click to test pick collision. For some reason pick works if you click on box when ground is behind it, otherwise pick is not successful. I was not able to reproduce if i create brush and pivot via code.

#include "Leadwerks.h"

using namespace Leadwerks;

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();
    shared_ptr<Camera> camera;
    auto scene = LoadMap(world, "maps/TestBox.map");
    for (auto entity : scene->entities) {
        if (entity->As<Camera>()) {
            camera = entity->As<Camera>();
            camera->SetDebugPhysicsMode(true);
            break;
        }
    }

    while (window->Closed() == false) {
        //Click on an object to change its color
        if (window->MouseHit(MOUSE_LEFT)) {
            auto mousepos = window->GetMousePosition();
            auto pick = camera->Pick(framebuffer, mousepos.x, mousepos.y, 0, true);
            if (pick.success) {
                pick.entity->SetColor(1, 0, 0);
            }
        }
        world->Update();
        world->Render(framebuffer);

    }
    return 0;
}

 

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...